Skip to content

batches counts error in logistic_sgd.py #87

@Huarong

Description

@Huarong
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

Activity

Lancelod-Liu

Lancelod-Liu commented on Jun 16, 2015

@Lancelod-Liu

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.

linked a pull request that will close this issue on Jun 16, 2015
Huarong

Huarong commented on Jun 16, 2015

@Huarong
Author

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

Lancelod-Liu

Lancelod-Liu commented on Jun 16, 2015

@Lancelod-Liu

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Huarong@Lancelod-Liu

      Issue actions

        batches counts error in logistic_sgd.py · Issue #87 · lisa-lab/DeepLearningTutorials