caffe - BatchNorm and Reshuffle train images after each epoch -
the recommended way of using batchnorm reshuffle training imageset between each epoch, given image not fall in mini-batch same images on each pass.
how achieve caffe?
if use imagedata layer input, set "shuffle" true
.
for example, if have:
layer { name: "data" type: "imagedata" top: "data" top: "label" transform_param { mirror: false crop_size: 227 mean_file: "data/ilsvrc12/imagenet_mean.binaryproto" } image_data_param { source: "examples/_temp/file_list.txt" batch_size: 50 new_height: 256 new_width: 256 } }
just add:
layer { name: "data" type: "imagedata" top: "data" top: "label" transform_param { mirror: false crop_size: 227 mean_file: "data/ilsvrc12/imagenet_mean.binaryproto" } image_data_param { source: "examples/_temp/file_list.txt" batch_size: 50 new_height: 256 new_width: 256 shuffle: true } }
for documentation, see:
- http://caffe.berkeleyvision.org/tutorial/layers.html#images
- https://github.com/bvlc/caffe/blob/master/src/caffe/proto/caffe.proto#l770
you can find source code here:
of particular interest code within function load_batch
re-shuffles data @ end of each epoch:
lines_id_++; if (lines_id_ >= lines_size) { // have reached end. restart first. dlog(info) << "restarting data prefetching start."; lines_id_ = 0; if (this->layer_param_.image_data_param().shuffle()) { shuffleimages(); } }
Comments
Post a Comment