Caffe Convolution "Pad" parameter conversion to Keras Conv2D

123 views
Skip to first unread message

pmpa...@gmail.com

unread,
Sep 6, 2018, 7:52:39 AM9/6/18
to Keras-users
I am trying to convert a Caffe-model (in prototxt) to its equivalent in Keras.

One convolutional layer has the following attributes :

layer {
  name: "conv2"
  type: "Convolution"
  bottom: "norm1"
  top: "conv2"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 384
    kernel_size: 5
   pad : 1
   group: 2
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.1
    }
  }
}

My question is how can I implement this parameter in Keras syntax ( using Conv2D layer ) ?
I know that pad='same' may be used, but how can I define that i want 1 pixel around each input, as defined in Caffe?

Sergey O.

unread,
Sep 6, 2018, 8:39:15 AM9/6/18
to pmpa...@gmail.com, Keras-users
From Caffe:
pad (or pad_h and pad_w) [default 0]: specifies the number of pixels to (implicitly) add to each side of the input

Since this is done at the input (before doing actual convolution), you can use kera's zeropadding layer:

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users+unsubscribe@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/c7d60dac-97fb-41d9-a2e4-7cb6b89581a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pmpa...@gmail.com

unread,
Sep 6, 2018, 10:13:57 AM9/6/18
to Keras-users
Thank you sokrypton for your quick response.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages