Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batches counts error in logistic_sgd.py #87

Open
Huarong opened this issue Jun 5, 2015 · 3 comments · May be fixed by #88
Open

batches counts error in logistic_sgd.py #87

Huarong opened this issue Jun 5, 2015 · 3 comments · May be fixed by #88

Comments

@Huarong
Copy link

Huarong commented Jun 5, 2015

n_train_batches = train_set_x.get_value(borrow=True).shape[0] / batch_size
n_valid_batches = valid_set_x.get_value(borrow=True).shape[0] / batch_size
n_test_batches = test_set_x.get_value(borrow=True).shape[0] / batch_size

should be:

n_train_batches = train_set_x.get_value(borrow=True).shape[0] / batch_size + 1
n_valid_batches = valid_set_x.get_value(borrow=True).shape[0] / batch_size + 1
n_test_batches = test_set_x.get_value(borrow=True).shape[0] / batch_size + 1
@Lancelod-Liu
Copy link

Yes, I found the current version could not include all the samples if the sample number could not be divided with no remainder by the batch_size.
I do not agree with your solution because every batch must have exact batch_size samples.

@nouiz nouiz linked a pull request Jun 16, 2015 that will close this issue
@Huarong
Copy link
Author

Huarong commented Jun 16, 2015

@Lancelod-Liu Every batch is not required to have exact batch_size samples. I've tested my modification.

@Lancelod-Liu
Copy link

@Huarong I have reviewed the code and you are right when the case you are working on is the mlp model.
However, if you have tested the LeNet5 code (convolutional_mlp.py), you will find that the input to the LeNet5 is required to have the same batch_size:

        self.W = theano.shared(
            numpy.asarray(
                rng.uniform(low=-W_bound, high=W_bound, size=filter_shape),
                dtype=theano.config.floatX
            ),
            borrow=True
        )

W is the kernels that one convolutional layer owns and referring to the code, the filter_shape contains the batch_size info and once the model is built, the model only accepts with input of batch_size samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants