-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
is it possible to specify different batch sizes for train and validation? #8550
Comments
If you don't specify any batch_size in your model definition (I think that you never have to, but I may be wrong), your model has a dynamic batch_size. You then use the batch_size parameter of the fit and predict methods of your keras models. |
I use fit_generator I see that event though no batch size was defined, keras will break the test data to batches in the size of the train set batch (I added a dummy metric that calculates the length of the batch to confirm this) |
For that scenario, my advice is to do the epochs loop yourself : Another solution is to use a generator for the validation data, so you have control over the batch_size of your validation data You could also use a custom Keras Callback |
But you're right, maybe a validation_batch_size parameter is missing for the case where validation_data is not a generator |
I need this feature now. I am implementing a custom metric that calculates correlation. If I use the training batch size of 32 it is too small for my custom metric and I can get runs that are all zeros resulting in nan output for the validation metric. I would think this could be a common issue for any metric that needs longer string of data to process accurately or in a stable way. Seems like this would be an easy feature to add? |
@boulderZ I'm not sure if this would help your issue, but when I ran into an |
my advice is to define your validate function,use self define metric function |
for train data, there are reasons to keep batches relatively small (batch size can effect training results)
however for the validation set, using a single reasonably big batch, allows simple use of metric functions that don't work well when averaging batches (precision \ recall \ f1)
The text was updated successfully, but these errors were encountered: