官网 tutorial:http://caffe.berkeleyvision.org/tutorial/
caffe模型
Nets网络由layers层构成,在层中的计算和层与层之间的数据流动依赖于Blobs
caffe模型训练
Forward:Data->layers->loss
Backward:loss->diff->update weight(solver:optimization method)
Blob
PS:关于这个
1.Blob与数据
A Blob is a wrapper over the actual data being processed and passed along by Caffe. Blobs provide a unified memory interface holding data; e.g., batches of images, model parameters, and derivatives for optimization.
forward、backward过程中输入数据、模型权重、梯度值,都是以blob的形式在层与层之间的流动以及计算
A blob stores two chunks of memories, data and diff. The former is the normal data that we pass along, and the latter is the gradient computed by the network.
一个blob对应于计算后需要流入下一层的数据和梯度
2.Blob的维度
A blob is an N-dimensional array stored in a C-contiguous fashion.
C contiguous fashion means that the n-dim data is stored as a long and contiguous array in memory. The order of the elements in memory is according to C fashion: trailing dimensions are stored first. That is if you have c by h by w 3d blob, in memory rows will be saved one after the other, and after completing all the rows of the first channel, only then the rows of the next channel are written.
conventional blob dimensions for batches of image data:
batch size N x channel K x height H x width W
3.CPU与GPU的同步
The reason for such design is that, a Blob uses a SyncedMem class to synchronize values between the CPU and GPU in order to hide the synchronization details and to minimize data transfer.
SyncedMem 类实现CPU与GPU的同步,具体实现是依赖标志位