Machine learning Keras中沿特定轴的三维张量列表的串联

Machine learning Keras中沿特定轴的三维张量列表的串联,machine-learning,tensorflow,nlp,keras,Machine Learning,Tensorflow,Nlp,Keras,我写了上面的代码片段,其中y\u word\u max\u len=9 主解码器是一个形状张量(无,9256) 和y\u char\u max\u len=7 58是我输出的大小 在片段被删除后,输出被删除 子解码器输出是张量(“整形2/整形:0”,整形=(?,1,7, 58),数据类型=32) 子解码器输出是张量(“整形3/整形:0”,整形=(?,1,7, 58),数据类型=32) 子解码器输出为张量(“整形_4/整形:0”,整形=(?,1,7, 58),数据类型=32) 子解码器的输出是张量

我写了上面的代码片段,其中y\u word\u max\u len=9

主解码器是一个形状张量(无,9256)

y\u char\u max\u len=7

58是我输出的大小 在片段被删除后,输出被删除

子解码器输出是张量(“整形2/整形:0”,整形=(?,1,7, 58),数据类型=32)

子解码器输出是张量(“整形3/整形:0”,整形=(?,1,7, 58),数据类型=32)

子解码器输出为张量(“整形_4/整形:0”,整形=(?,1,7, 58),数据类型=32)

子解码器的输出是张量(“整形_5/整形:0”,整形=(?,1,7, 58),数据类型=32)

子解码器输出为张量(“整形_6/整形:0”,整形=(?,1,7, 58),数据类型=32)

子解码器输出为张量(“整形_7/整形:0”,整形=(?,1,7, 58),数据类型=32)

子解码器的输出是张量(“整形_8/整形:0”,整形=(?,1,7, 58),数据类型=32)

子解码器的输出是张量(“整形_9/整形:0”,形状=(?,1,7, 58),数据类型=32)

子解码器的输出是张量(“整形_10/整形:0”,形状=(?,1,7, 58),数据类型=32)


现在我想把由此得到的所有张量(9)连接成一个

形状(?,9,7,58)

我如何在Keras中实现这一点。
谢谢添加连接层:

for i in range(y_word_max_len):
    sub_decoder_input = gather(main_decoder,(i))
    # print(sub_decoder_input)
    sub_decoder_input_repeated = RepeatVector(y_char_max_len)(sub_decoder_input)
    sub_decoder = LSTM(256,return_sequences=True,name='sub_decoder')(sub_decoder_input_repeated)
    sub_decoder_output = TimeDistributed(Dense(58,activation='softmax'),name='sub_decoder_output')(sub_decoder)
    sub_decoder_output_reshaped = Reshape((1,y_char_max_len,58))(sub_decoder_output)
    print("Sub decoder output is ",sub_decoder_output_reshaped)
为此,最好创建一个子传感器列表,并使用循环附加到此列表:

joined = Concatenate(axis=1)([sub1, sub2, sub3, sub4, sub5....])

添加连接层:

for i in range(y_word_max_len):
    sub_decoder_input = gather(main_decoder,(i))
    # print(sub_decoder_input)
    sub_decoder_input_repeated = RepeatVector(y_char_max_len)(sub_decoder_input)
    sub_decoder = LSTM(256,return_sequences=True,name='sub_decoder')(sub_decoder_input_repeated)
    sub_decoder_output = TimeDistributed(Dense(58,activation='softmax'),name='sub_decoder_output')(sub_decoder)
    sub_decoder_output_reshaped = Reshape((1,y_char_max_len,58))(sub_decoder_output)
    print("Sub decoder output is ",sub_decoder_output_reshaped)
为此,最好创建一个子传感器列表,并使用循环附加到此列表:

joined = Concatenate(axis=1)([sub1, sub2, sub3, sub4, sub5....])