2016년 6월 30일 목요일

caffe, layer examples

관련링크: http://caffe.berkeleyvision.org/tutorial/layers.html

layer  {
   name: layer의 이름/ID같은 것
   type: 종류, 위 링크 참조
   top: output화살표의 이름. 이를 받는 input화살표(bottom)도 있어야 됨.
}

실제 사용했던 예들

< concatenation layer >
layer {
  name: "layer_concat1_012"
  type: "Concat"
  bottom: "pool6_01"
  bottom: "pool6_11"
  bottom: "pool6_21"
  top: "concat1_012"
}

< Slicing layer >
# slicing into 2 layer in depth/channel
layer {
  name: "layer_slicer_01"
  type: "Slice"
  bottom: "pool5_01"
  ## Example of label with a shape N x 3 x 1 x 1
  top: "pool5_01_u"
  top: "pool5_01_b"
  slice_param {
    axis: 1    # 1 is ch, 0 is num
    slice_point: 256
  }
}
# axis indicates the target axis; slice_point indicates indexes 
in the selected dimension (the number of indices must b
equal to the number of top blobs minus one).

< ElementWise layer >
layer {
  name: "layer_eltwiseMax_01"
  type: "Eltwise"
  bottom: "pool5_01_u"
  bottom: "pool5_01_b"
  top: "pool6_01"
  eltwise_param { operation: MAX }
}




< Network-in-network >
> #output x ch x 1 x 1 conv layer사용하기
layer {
  name: "layer_conv6_01"
  type: "Convolution"
  bottom: "pool5_01"
  top: "pool6_01"
  param {
    name: "conv6_w"
    lr_mult: 1
  }
  param {
    name: "conv6_b"
    lr_mult: 2
  }
  convolution_param {
    num_output: 128
    pad: 0
    kernel_size: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}

< data layer >
http://caffe.berkeleyvision.org/tutorial/data.html
layer {
  name: "layer_data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mean_value: 84.819519043 # (x - mean)*scale
    mean_value: 96.4913330078
    mean_value: 118.523254395
    scale: 0.00390625
  }
  data_param {
    source: "/media/tr_data"
    batch_size: 32
    backend: LMDB
  }
}

<python layer>
http://chrischoy.github.io/research/caffe-python-layer/