像在咖啡中一样在喀拉拉邦中切/切一层 [英] slice/split a layer in keras as in caffe

查看:63
本文介绍了像在咖啡中一样在喀拉拉邦中切/切一层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用转换器进行转换凯拉斯(Keras)的Caffe模型.但是我的一层是slice类型,它也需要转换,但是转换器当前不支持该转换,并引发异常.有什么解决办法吗?这是我的图层:

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
    }
}

推荐答案

似乎您要使用 Lambda 层.在这种情况下,您可以执行以下操作:

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)

请注意,在x中,您需要考虑采样轴,而在output_shape中,则不再需要.

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

这篇关于像在咖啡中一样在喀拉拉邦中切/切一层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆