chuckcho / video-caffe

Video-friendly caffe -- comes with the most recent version of Caffe (as of Jan 2019), a video reader, 3D(ND) pooling layer, and an example training script for C3D network and UCF-101 data
Other
175 stars 93 forks source link

How to use the Batch Normalization layer with video-caffe? #88

Closed rpand002 closed 6 years ago

rpand002 commented 7 years ago

Does video-caffe supports batch normalization layer? How can I use the Batch normalization layer (BN), with this caffe version? Thank you for your assistance.

chuckcho commented 7 years ago

Batch normalization should work as it's already included in this version of Caffe (both master / refactor branches): https://github.com/chuckcho/video-caffe/blob/master/include/caffe/layers/batch_norm_layer.hpp

rpand002 commented 7 years ago

Thanks for your response. I have tried using the batch normalization layer before each relu layer but getting error. I have added the following lines in the prototxt file.

----- 1st group -----

layer { name: "conv1a" type: "NdConvolution" bottom: "data" top: "conv1a" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 64 kernel_shape { dim: 3 dim: 3 dim: 3 } stride_shape { dim: 1 dim: 1 dim: 1 } pad_shape { dim: 1 dim: 1 dim: 1 } weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } } }

layer { name: "bn1" type: "BatchNorm" bottom: "conv1a" top: "bn1" param { lr_mult: 0 } param { lr_mult: 0 } param { lr_mult: 0 } }

layer { name: "relu1a" type: "ReLU" bottom: "bn1" top: "relu1a" } layer { name: "pool1" type: "NdPooling" bottom: "relu1a" top: "pool1" pooling_param { pool: MAX kernel_shape { dim: 1 dim: 2 dim: 2 } stride_shape { dim: 1 dim: 2 dim: 2 } } } ------ Error-----

Check failed: target_blobs[j]->shape() == source_blob->shape() Cannot share param 0 weights from layer 'bn1'; shape mismatch. Source param shape is 128 (128); target param shape is 64 (64).

Can you please look into this? Thanks for your assistance.

chuckcho commented 6 years ago

i didn't encounter any issue. look at the following snippet:


layer {
  name: "conv1a"
  type: "NdConvolution"
  bottom: "data"
  top: "conv1a"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 64
    kernel_shape { dim: 3 dim: 3 dim: 3 }
    stride_shape { dim: 1 dim: 1 dim: 1 }
    pad_shape    { dim: 1 dim: 1 dim: 1 }
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}

layer {
  name: "bn1"
  type: "BatchNorm"
  bottom: "conv1a"
  top: "bn1"
  param { lr_mult: 0 }
  param { lr_mult: 0 }
  param { lr_mult: 0 }
}

layer {
  name: "relu1a"
  type: "ReLU"
  bottom: "bn1"
  top: "bn1"
}

layer {
  name: "pool1"
  type: "NdPooling"
  bottom: "bn1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_shape { dim: 1 dim: 2 dim: 2 }
    stride_shape { dim: 1 dim: 2 dim: 2 }
  }
}```
chuckcho commented 6 years ago

closing as this doesn't seem like an issue