"Turn" Caffe (eight) Blob,layer and net and corresponding configuration file writing

Source: Internet
Author: User

Deep Network (NET) is a composite model that is composed of many interconnected layers (layers). Caffe is the establishment of a deep network of such a tool, according to a certain strategy, a layer of one layer to build their own model. It defines all information data as blobs for convenient operation and communication. BLOBs are a standard array in the Caffe framework, a unified memory interface that describes in detail how information is stored and how it communicates between tiers.

1. Blob

The blobs encapsulates the runtime's data information and provides synchronization between the CPU and the GPU. Mathematically, a blob is an n-dimensional array. It is the basic unit of data in Caffe, just as the matrix is the basic Operation object in MATLAB. Only the matrix is two-dimensional, and the blob is n-dimensional. n can be 2,3,4 and so on. For picture data, blobs can be represented as a 4-D array (n*c*h*w). where n represents the number of pictures, and C represents the number of channels of the picture, and H and W represent the height and width of the picture, respectively. Of course, in addition to picture data, blobs can also be used for non-image data. For example, the traditional multilayer perceptron, is a relatively simple all-connected network, with 2D blob, call innerproduct layer to calculate on it.

2. Layer

Layer is the constituent element of network model and the basic unit of computation. There are many types of layers, such as data,convolution,pooling,relumsoftmax-loss,accuracy, and the definition of a layer is roughly as follows:

The input of the data from the bottom, after calculation, is output through the top. The yellow polygon in the figure represents the input and output data, and the blue rectangle represents the layer.

Each type of layer is defined as three key calculations: Setup,forward and Backword

Setup: the creation and initialization of layers, and the initialization of connections throughout the model.

Forward: The input data is obtained from the bottom, calculated, and the results are sent to top for output.

Backward: The gradient of the data is obtained from the top of the output of the layer, the gradient of the current layer is computed, and the result is sent to the bottom, which is passed forward.

3, Net

Just like building blocks, a net is composed of multiple layer layers.

A simple model definition of a 2-layer neural network (plus the loss layer becomes three layers) is given, and the network topology is given first.

First layer : name Mnist,type is data, no input (bottom), only two outputs (top), one is data, one is label

Second layer : name Ip,type for innerproduct, input data, output data IP

The third layer : name is loss,type for Softmaxwithloss, there are two inputs, one for IP, one for label, one for output loss, no drawing.

The corresponding configuration file Prototxt can be written like this:

Name"Logreg"Layer {name:"mnist"Type:"Data"Top:"Data"Top:"label"Data_param {Source:"Input_leveldb"batch_size:64}} layer {name:"IP"Type:"innerproduct"Bottom:"Data"Top:"IP"Inner_product_param {num_output:2}} layer {name:"Loss"Type:"Softmaxwithloss"Bottom:"IP"Bottom:"label"Top:"Loss"  }  

The first line of the model is named Logreg, then the definition of three layers, the parameters are relatively simple, only the necessary parameters are listed.

"Turn" Caffe (eight) Blob,layer and net and corresponding configuration file writing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.