How to change the trainning batch size in FCN?

880 views
Skip to first unread message

邰磊

unread,
Jul 19, 2016, 11:01:14 AM7/19/16
to Caffe Users
From the github code of FCN https://github.com/shelhamer/fcn.berkeleyvision.org

The input data is defined from some python layers like voc_layers.py. It seems that the input batch size is 1.

So how can I change the input batch size?

Do I need to change the forward() function to change the batch size of top[0] and top[1]??

Evan Shelhamer

unread,
Jul 25, 2016, 5:15:45 PM7/25/16
to 邰磊, Caffe Users
The simplest way to switch the batch size of an FCN is to adjust the `iter_size`: https://github.com/shelhamer/fcn.berkeleyvision.org/blob/master/voc-fcn32s/solver.prototxt#L14. This controls the number of forward-backward passes over which to accumulate gradients for an update.

Please note however that our latest experiments show improved learning with batch size 1 and high momentum over our earlier training setup with gradient accumulation.

Evan Shelhamer





--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/84406ffd-63a8-4cf8-b85a-43f549d67d93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

HIMANSHU RAI

unread,
Sep 6, 2017, 3:42:41 PM9/6/17
to Caffe Users, onlyt...@gmail.com
@Evan Shelhamer, so from the prototxt file posted here, it means that the update to the net will be done after a forward and backward pass through each image (iter_size=1, batch_size=1) right? Also the total number of times that you will have a complete pass on the data-set here will be (max_iter/total-images in data-set) right? For example in Pascal-voc-2012 , since there are 9,993 images for segmentation part, so your code will iterate through the entire data-set around( 100000/9,993)=10 times right?

Thanks! 

raw...@gmail.com

unread,
Sep 6, 2017, 11:03:52 PM9/6/17
to Caffe Users
if iter_size =1 and batch_size = 1, then a forward and backward pass through one image.

HIMANSHU RAI

unread,
Sep 7, 2017, 12:58:07 AM9/7/17
to Caffe Users
And the total number of times that we iterate over the complete data set is (max_iter/total-images in data-set) right ? 
Reply all
Reply to author
Forward
0 new messages