Summary of each layer of Caffe __caffe

Source: Internet
Author: User

Transferred from http://www.myexception.cn/other/1828071.html

How to configure the structure of each layer in Caffe

Recently in the computer installed good caffe, because there are different layers of neural network structure, different types of layers have different parameters, all according to the Caffe official website of the description of the document made a simple summary.


1. Vision Layers 1.1 convolution layer (convolution)

Type: Convolution

Example

Layers {
  Name: "Conv1"
  type:convolution
  Bottom: "Data" top
  : "Conv1"
  blobs_lr:1          # Learning Rate multiplier for the filters
  blobs_lr:2 # Learning rate multiplier for the          biases
  weight_decay:1      # we ight decay multiplier for the filters
  weight_decay:0      # weight decay for the multiplier biases
  param {
    num_output:96     # Learn filters
    kernel_size:11    # Each filter is 11x11
    stride:4          # step 4 pixels between each filter application
    Weight_filler {
      type: ' Gaussian ' # Initialize the filters from a Gaussian
      std:0.01        # Distribution with Stdev 0.01 (default mean:0)
    }
    Bias_filler {
      type: "Cons Tant "# Initialize the biases to zero (0)
      value:0
    }
  }
}


BLOBS_LR: Learning Rate adjustment parameters, in the above example set the weight learning rate and the operating solver to give the same learning rate, while the bias learning rate is twice times the weight.

Weight_decay:

Important parameters of convolution layer

Must be parameter:

Num_output (C_o): Number of filters

Kernel_size (or Kernel_h and Kernel_w): size of the filter

Optional Parameters:

Weight_filler [Default type: ' Constant ' value:0]: initialization method for parameters

Bias_filler: An initialization method for bias

Bias_term [Default True]: Specifies whether the offset item is turned on

Pad (or Pad_h and pad_w) [default 0]: Specifies how many pixels to add to each side of the input

Stride (or Stride_h and stride_w) [Default 1]: Specifies the step size of the filter

Group (g) [Default 1]: If g > 1, we restrict the connectivityof each filter to a subset of the input. Specifically, the input and outputchannels are separated into G groups, and the ith output group channels would beonly Conn ected to the ith input group channels.

Changes in size after convolution:

Input: N * c_i * h_i * w_i

Output: N * c_o * h_o * w_o, where h_o = (h_i + 2 * pad_h-kernel_h)/stride_h + 1,w_o are computed by the same method.


1.2 pool layer (pooling)

Type: Pooling

Example

Layers {
  Name: "Pool1"
  type:pooling
  Bottom: "conv1" top
  : "Pool1"
  pooling_param {
    Pool:max
    Kernel_size:3 # Pool over a 3x3 region
    stride:2      # Step two pixels (in the bottom blob) between pooling ONS
  }
}

Important parameters of convolution layer

Required Parameters:

Kernel_size (or Kernel_h and Kernel_w): size of the filter

Optional Parameters:

Pool [Default Max]:pooling method, currently has MAX, AVE, and stochastic three ways

Pad (or Pad_h and pad_w) [default 0]: Specifies how many pixels to add each time in the input

Stride (or Stride_h and Stride_w) [DEFAULT1]: Specifies the step size of the filter

Changes in size after pooling:

Input: N * c_i * h_i * w_i

Output: N * c_o * h_o * w_o, where h_o = (h_i + 2 * pad_h-kernel_h)/stride_h + 1,w_o are computed by the same method.


1.3 Local Response Normalization (LRN)

Type: LRN

The local responsenormalization is the normalization of a localized input region (activation A is added with a normalized weight (the denominator portion) to generate a new activation B), in two different forms, one with an input region of adjacent channels (cross Channel LRN), the other is a space area within the same channel (within channel LRN)

Calculation formula: dividing each input by

Optional Parameters:

Local_size [Default 5]: The number of neighboring channel that the cross channel LRN needs to sum; for within channel the side length of the space area where LRN is required to sum

Alpha [Default 1]:scaling parameter

Beta [default 5]: Index

norm_region [Default Across_channels]: Choose which LRN method Across_channels or Within_channel


2. Loss Layers

Depth learning is driven by the minimization of output and loss of goals.


2.1 Softmax type: Softmax_loss

2.2 Sum-of-squares/euclidean

Type: Euclidean_loss


2.3 hinge/margin Type: Hinge_loss

Example:

# L1 Norm
Layers {
  name: "Loss"
  Type:hinge_loss bottom
  : "pred"
  Bottom: "Label"
}

# L2 Norm
Layers {
  name: "Loss"
  Type:hinge_loss
  Bottom: "pred"
  Bottom: "Label" Top
  : "Loss"
  Hinge_loss_param {
    norm:l2
  }
}

Optional Parameters:

Norm [Default L1]: Select L1 or L2 norm

Input:

n * C * H * wpredictions

n * 1 * 1 * 1Labels

Output

1 * 1 * 1 * 1Computed Loss


2.4 sigmoid cross-entropy type: Sigmoid_cross_entropy_loss

2.5 infogain Type: Infogain_loss

2.6 accuracy and top-k type: Accuracy
Used to calculate the correctness of the output and the target, in fact it is not a loss, and there is no backward this step.

3. Excitation layer (Activation/neuron Layers) in general, the excitation layer is element-wise operation, the input and output of the same size, under normal circumstances is a non-linear function.

3.1 relu/rectified-linear and Leaky-relu type: Relu

Example:

Layers {
  Name: "RELU1"
  type:relu
  Bottom: "conv1" top
  : "Conv1"
}

Optional Parameters:

Negative_slope [Default 0]: Specifies an output that has an input value less than zero.

Relu is the current use of long incentive functions, mainly because it converges faster, and can maintain the same effect.

The standard Relu function is max (x, 0), which is typically x > 0 o'clock Output X, but x <= 0 o'clock output negative_slope. The Relu layer supports in-place calculations, which means that bottom output is the same as input to avoid memory consumption.


3.2 sigmoid type: sigmoid

Example:

Layers {
  Name: "Encode1neuron"
  Bottom: "encode1" top
  : "Encode1neuron"
  type:sigmoid
}
The sigmoid layer calculates the output of each input x by sigmoid (x), and the function is shown below.

3.3 tanh/hyperbolic Tangent type: TanH

Example:

Layers {
  Name: "Encode1neuron"
  Bottom: "encode1" top
  : "Encode1neuron"
  type:sigmoid
}

The Tanh layer calculates the output of each input x by Tanh (x), and the function is shown below.
3.3 Absolute Value type: absval

Example:

Layers {
  name: ' Layer '
  bottom: ' In ' top
  : ' Out '
  type:absval
}
The Absval layer calculates the output of each input x through ABS (x).


3.4 Power Type: Power

Example:

Layers {
  name: ' Layer '
  bottom: ' In ' top
  : ' Out '
  type:power
  power_param {
    power:1
    Scale:1
    shift:0
  }
}

Optional Parameters:
Power [Default 1]
scale [Default 1]
Shift [Default 0]

The power layer calculates the output of each input x by (SHIFT + scale * x) ^ Power.


3.5 bnll Type: BNLL

Example:

Layers {
  name: ' Layer '
  bottom: ' In ' top
  : ' Out '
  TYPE:BNLL
}

The BNLL (binomial normal log likelihood) layer calculates the output of each input x through log (1 + exp (x)).


4. Data Layer (Layers)

Data enters caffe through the data layer, and the data layer is at the bottom of the entire network. Data can come from an efficient database (LEVELDB or Lmdb), directly from memory. If you do not pursue efficiency, you can read data from your hard disk in HDF5 or in a generic image format.


4.1 Database

Type: DATA

Must be parameter:

Source: Directory name containing data

Batch_size: Number of inputs processed at one time

Optional Parameters:

Rand_skip: Skip this value from the input at the beginning, which is useful when the asynchronous random gradient drops (SGD)

Backend [Default LEVELDB]: choose to use LEVELDB or Lmdb


4.2 in-memory Type: memory_data
Required Parameters:
Batch_size, channels, height, Width: Specifies the size of the data to be read from memory
The memory data layer reads data directly from memory, without copying it. In order to use it, one must call Memorydatalayer::reset (from C + +) or net.set_input_arrays (from Python) in the to spec Ify a source of contiguous data (as 4D row major array), which is read one batch-sized chunk in a time.


</

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.