Python Keras:如何在Keras中对一层的o/p进行重新排序?

Python Keras:如何在Keras中对一层的o/p进行重新排序?,python,neural-network,deep-learning,keras,keras-layer,Python,Neural Network,Deep Learning,Keras,Keras Layer,我有九千五百维向量作为o/p,来自合并层和重塑层的组合: ... N=3 merge_rf=merge(cells_rf,mode='concat') rf_top = Reshape((N*N, 500))(merge_rf) #proper reordering code here - TODO 我需要使用已知映射对rf\u top中的(9500)dim向量重新排序 eg - (0,1,2,3,4,5,6,7,8) to -> (0,1,2,5,4,3,6,7,8) for rf_

我有九千五百维向量作为o/p,来自合并层和重塑层的组合:

...
N=3
merge_rf=merge(cells_rf,mode='concat')
rf_top = Reshape((N*N, 500))(merge_rf)
#proper reordering code here - TODO

我需要使用已知映射对
rf\u top
中的
(9500)
dim向量重新排序

eg - (0,1,2,3,4,5,6,7,8) to -> (0,1,2,5,4,3,6,7,8) for rf_top
我应该使用哪种keras层进行此操作?如何做到这一点?

尝试使用:

reorder_top = merge([Lambda(lambda x: x[:, index, :], 
    output_shape = (1, 500))(rf_top) for index in permutation], 
    mode='concat', concat_axis=1)
其中,
permutation
是要根据其排列图层的排列。该层的输出被展平,因此您应该通过以下方式对其进行整形:

reorder_top = Reshape ((N*N, 500))(reorder_top)
reorder_top = Reshape ((N*N, 500))(reorder_top)