vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 753 forks source link

How to set numSubBatches parameters and how to use Matconvnet model in a product environment? #806

Closed starzhouchina closed 7 years ago

starzhouchina commented 7 years ago

Hi, We set load image batch is 100 images. and set opts.train.batchsize =64 opts.train.numSubBAtches= 1, How to set this two parameters ? We use a GPU with xeon e5 core6.

  If we get a model from train images in matconvnet using matlab, But if we neet use this model to 

a product environment, of course, can't use matlab, Is a simple solution use matconvnet training model, such as net1.eval(predict) result in a online environment through C++ interface ?

Thank you very much,

zhou
albanie commented 7 years ago

The batch size parameters are used to control the minibatch stochastic gradient descent algorithm that trains the network (see here for a description of the algorithm).

The batchSize is chosen to achieve the desired learning characteristics of your network while the numbSubBatches parameter is typically selected as a function of how much data you can fit onto your GPU. Essentially, it allows you to control how much of your batch is put into the network at a time (the more you can fit on, the more efficiently your network can run).

As an example, by using opts.train.numSubBatches = 1 and opts.train.batchSize = 64, you will load all 64 members of each batch into the network at a time, and all of them will be used in the weight update. If instead you set opts.train.numSubBatches = 2 and opts.train.batchSize = 64, you would run 2 sub batches of 32 inputs through the network (requiring less GPU space per sub batch) and the weights update would take place after both sub batches had been processed.

With regards to running in a product environment, this might be useful.

starzhouchina commented 7 years ago
 Very professional and valuable replay!
 Thank you very much, albanie!