1
$\begingroup$

I am interested to know, what happens when I choose batch_size=1 or batch_size=1000 or any other numbers in Keras.lstm.mode.fit() function for example when I am configuring batch_input_shape? Does this make effect on my final result and changing them?

I need for future prediction using batch_size=1 but affraid of getting bad/wrong result!

May someone explains the important effects of choosing batch_size from 1 to N numbers?

$\endgroup$
3
$\begingroup$

I need for future prediction using batch_size=1 but affraid of getting bad/wrong result!

Batch size is not connected to the future prediction - it's just the number of samples which will be used in one forward pass to calculate the loss and then in a backward pass to calculate the gradients and parameter updates.

In order to regulate the future prediction (as far as I understand from your question), you just need to define the sample size (or width, or time steps, whatever name you use ...).

Regarding the "important effects of choosing batch_size from 1 to N numbers?" - with a larger batch size your training process might finish faster, but with smaller you might avoid local minimum (but that - local minimum, generally, shouldn't be a problem with deep neural networks).

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Just adding a little elaboration to the idea behind batch sizes: Batch size > 1 are used normally during training, not just to speed up the training process but also to learn better. Having a batch size > 1 lets the network learn the mistakes its making by looking at multiple samples and correcting them quickly. This in turn speeds up the process because the direction and magnitude of gradient is chosen more optimally compared to choosing when using batch size of 1. $\endgroup$ – Nischal Hp Feb 23 '19 at 16:52
  • $\begingroup$ Thank you Antonie, but the problem is that in Keras library, it seems if you train your model with a batch_size=N, then you should predict with same batch_size. Take a loot at my other question here please, maybe could help to clarification: datascience.stackexchange.com/questions/46023/… $\endgroup$ – user145959 Feb 23 '19 at 18:25
  • $\begingroup$ This tutorial also tries to find a solution for this problem I think, with batch_size=1. $\endgroup$ – user145959 Feb 23 '19 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.