d8sconz
d8sconz

Reputation: 279

How to set batch size and epoch value in Keras for infinite data set?

I want to feed images to a Keras CNN. The program randomly feeds either an image downloaded from the net, or an image of random pixel values. How do I set batch size and epoch number? My training data is essentially infinite.

Upvotes: 3

Views: 2216

Answers (2)

sand
sand

Reputation: 137

It is because implementations are vectorised for faster & efficient execution. When the data is large, all the data cannot fit the memory & hence we use batch size to still get some vectorisation. In my opinion, one should use a batch size as large as your machine can handle.

Upvotes: 0

Dr. Snoopy
Dr. Snoopy

Reputation: 56357

Even if your dataset is infinite, you have to set both batch size and number of epochs.

For batch size, you can use the largest batch size that fits into your GPU/CPU RAM, by just trial and error. For example you can try power of two batch sizes like 32, 64, 128, 256.

For number of epochs, this is a parameter that always has to be tuned for the specific problem. You can use a validation set to then train until the validation loss is maximized, or the training loss is almost constant (it converges). Make sure to use a different part of the dataset to decide when to stop training. Then you can report final metrics on another different set (the test set).

Upvotes: 2

Related Questions