Make the SPNE softmax layer support the 4D model with axis=3

实现SNPE softmax layer的4D tensor 第4轴的排序

SNPE的softmax只支持1D和2D的输入,如何实现4D数据的排序呢? 并且SNPE的排序的轴是固定的axis=-1,如何对4D数据的第3个轴排序呢?

def softmax(sft_data, axis=3):
    dt_shape = data.get_shape().as_list()
    dt_axis1 = tf.split(sft_data[0], num_or_size_splits=dt_shape[1], axis=0)
    for i in range(0, dt_shape[1]):
        tf.nn.softmax(dt_axis1[i][0], axis=-1)
    return data

上面的函数是我实现的SNPE支持的4D数据第3轴的排序,至于第1,2轴的排序可以照着这个例子推出来。简单说就是用2D的轴为-1的softmax排序拼出来4D的第3轴数据。
I implement the function which can apply the softmax to the 4D data with the axis = 3, and it is easy to implement softmax with other axis=1 or 2 following my codes. The idea is that I use many softmax suppoted 2D data with axis=-1 to achieve the same result to the softmax which supports 4D data with axis=3.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值