Is there a way to train net on a batch with arbitrary shapes?

102 views
Skip to first unread message

Ilya Zhenin

unread,
Sep 12, 2016, 8:51:37 AM9/12/16
to Caffe Users
Since we can train fully-convolutional networks and networks with fully-connected layers transformed to convolutional(that's it, fully convolutional too), 
1. Can we do it on a batch with different shapes(first image 300x400, second 500x500,etc) with current caffe realsisation? 
2. Does it have a sense - saving shapes, no crops, or network trained or random crops will behave the same or even better?

Jonathan R. Williford

unread,
Sep 12, 2016, 9:32:33 AM9/12/16
to Caffe Users
The blobs for each batch are saved as a single 4-dimensional array, so the spatial dimension has to be set to the largest example size. You can, however, pad the images and use a mask. I'm not sure off the top of my head if this can be done with modifying the Caffe code.

Cheers,
Jonathan

Evan Shelhamer

unread,
Sep 14, 2016, 2:48:57 PM9/14/16
to Jonathan R. Williford, Caffe Users
The reference FCN code at fcn.berkeleyvision.org reshapes each input so that every batch has different dimensions.

While the dimensions within a computational batch have to have the same dimensions, since it's all in a single array, the learning batch size can be made of different sized inputs by accumulating gradients. To do so, set the `iter_size` field of the solver to >1. With the regular FCN batch size of 1, `iter_size` is effectively the batch size.

That said, I advise batch size == 1 and high momentum over accumulating gradients, or at least trying that first. In my experiments on semantic segmentation I've found online learning over images in this way to train faster.

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+unsubscribe@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/75e6ddd5-4b34-4182-8b6a-d596da9ec403%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages