6

I have used this converter to convert a Caffe model to Keras. But one of my layers is of type slice and it needs to be converted as well but the converter currently does not support this and raises an exception. Is there any work around for it? Here is my layer:

layer {
    name: "slice_label"
    type: SLICE
    bottom: "label"
    top: "label_wpqr"
    top: "label_xyz"
    slice_param {
        slice_dim: 1
        slice_point: 4
    }
}
Marcin Możejko
  • 39,542
  • 10
  • 109
  • 120
Bilal Ch
  • 358
  • 4
  • 15

1 Answers1

8

It seems that you want to use a Lambda layer. In this case you may do the following:

sliced = Lambda(lambda x: x[:,slicing_indeces], output_shape=(sliced_shape))(input)

Note that in x you need to take into account the samples axis whereas in output_shape it's not needed anymore.

HugoMailhot
  • 1,275
  • 1
  • 10
  • 19
Marcin Możejko
  • 39,542
  • 10
  • 109
  • 120