Slice / split layer in keras like in coffee

I used this converter to convert Caffe model to Keras. But one of my layers has a type slice

and needs to be converted as well, but currently the converter does not support this and throws an exception. Is there a job for this? 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
    }
}

      

+3


source to share


1 answer


It seems like what you want to use Lambda

. In this case, you can do the following:

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

      



Note that in x

you you need to consider the reference axis, while in output_shape

it you no longer need.

+4


source







All Articles