slice/split keras 和 caffe 中的一层
slice/split a layer in keras as in caffe
我已经使用 this 转换器将 Caffe 模型转换为 Keras。但是我的一层是 slice
类型,它也需要转换,但转换器目前不支持它并引发异常。有什么解决方法吗?这是我的图层:
layer {
name: "slice_label"
type: SLICE
bottom: "label"
top: "label_wpqr"
top: "label_xyz"
slice_param {
slice_dim: 1
slice_point: 4
}
}
您似乎想使用 Lambda
图层。在这种情况下,您可以执行以下操作:
sliced = Lambda(lambda x: x[:,slicing_indeces], output_shape=(sliced_shape))(input)
请注意,在 x
中您需要考虑样本轴,而在 output_shape
中则不再需要。
我已经使用 this 转换器将 Caffe 模型转换为 Keras。但是我的一层是 slice
类型,它也需要转换,但转换器目前不支持它并引发异常。有什么解决方法吗?这是我的图层:
layer {
name: "slice_label"
type: SLICE
bottom: "label"
top: "label_wpqr"
top: "label_xyz"
slice_param {
slice_dim: 1
slice_point: 4
}
}
您似乎想使用 Lambda
图层。在这种情况下,您可以执行以下操作:
sliced = Lambda(lambda x: x[:,slicing_indeces], output_shape=(sliced_shape))(input)
请注意,在 x
中您需要考虑样本轴,而在 output_shape
中则不再需要。