1

I have a Caffe prototxt as follows:

stepsize: 20000
iter_size: 4
batch_size: 10
gamma =0.1

in which, the dataset has 40.000 images. It means after 20000 iters, the learning rate will decrease 10 times. In pytorch, I want to compute the number of the epoch to have the same behavior in caffe (for learning rate). How many epoch should I use to decrease learning rate 10 times (note that, we have iter_size=4 and batch_size=10). Thanks

Ref: Epoch vs Iteration when training neural networks

My answer: Example: if you have 40000 training examples, and batch size is 10, then it will take 40000/10 =4000 iterations to complete 1 epoch. Hence, 20000 iters to reduce learning rate in caffe will same as 5 epochs in pytorch.

Shai
  • 111,146
  • 38
  • 238
  • 371
Jame
  • 3,746
  • 6
  • 52
  • 101

1 Answers1

2

You did not take into account iter_size: 4: when batch is too large to fit into memory, you can "split" it into several iterations.
In your example, the actual batch size is batch_sizexiter_size=10 * 4 = 40. Therefore, an epoch takes only 1,000 iterations and therefore you need to decrease the learning rate after 20 epochs.

Shai
  • 111,146
  • 38
  • 238
  • 371