Saturday, October 24, 2015

mnist using lenet (example in depth)

The input and output data is stored in lmdb format.
http://caffe.berkeleyvision.org/tutorial/data.html

when you run mnist using lenet, you can save the log file using the following command
./examples/mnist/train_lenet.sh > mylog  2>&1

It is observed that,  cudnn_conv_layer.cpp is used in convolution layer.

Solving LeNet starts from solver.cpp, and for every iteration it uses sgd_solver.cpp.

During training/testing, solver.cpp is used.
The Step() function is called, which use TestAll() function to check the performance.

in src/caffe/net.cpp, it uses ForwardFromTo(), to accumulate the loss using Forward() function.

net and layer use the shared_pointer.
like forward(), backward() is also switching between backward_cpu and backward_gpu.

forward_gpu() and backward_gpu() are all virtual functions.
Their specific implemantions are stored in .cu files, located src/caffe/layer/ folder.

in src/caffe/layer_factory.cpp, if using cudnn, the corresponding cudnn (conv, pooling, lrc ...) layer will be created.

When they process data, the blob (gpu) data is requested.
for convolution, the blobs for weight, bottom and top are needed.

src/caffe/synchedmem.cpp contains the gpu data transfer, sync or async.

For the forward algorithm in cudnn_conv_layer.cu,
=>leiming: FWD                                                                  
I0211 23:02:12.374897 18363 cudnn_conv_layer.cu:23] =>leiming: blobs[0] 20 1 5 5 (500)
I0211 23:02:12.374899 18363 cudnn_conv_layer.cu:24] =>leiming: bottom size :1   
I0211 23:02:12.374990 18363 cudnn_conv_layer.cu:30] =>leiming: bottom[0] size:100 1 28 28 (78400)
I0211 23:02:12.374997 18363 cudnn_conv_layer.cu:31] =>leiming: top[0] size:100 20 24 24 (1152000)
I0211 23:02:12.375000 18363 cudnn_conv_layer.cu:32] =>leiming: groups: 1        
I0211 23:02:12.375037 18363 cudnn_conv_layer.cu:48] =>leiming: using bias term: 1
I0211 23:02:12.375319 18363 cudnn_conv_layer.cu:51] =>leiming: blobs[1] 20 (20) 
I0211 23:02:12.375555 18363 cudnn_conv_layer.cu:22]

Which means that,
blobs, 20 number, 1 channel, width 5, height 5

No comments:

Post a Comment