【发布时间】:2018-04-29 18:20:54
【问题描述】:
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)
我已经写了上面的 sn-p where y_word_max_len = 9
而 main_decoder 是一个形状张量 (None,9,256)
和 y_char_max_len = 7
58 是我输出的大小 执行 sn-p 后,输出为
子解码器输出为 Tensor("reshape_2/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_3/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_4/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_5/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_6/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_7/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_8/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_9/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
子解码器输出为 Tensor("reshape_10/Reshape:0", shape=(?, 1, 7, 58), dtype=float32)
现在我想将由此获得的所有张量 (9) 连接成单个结果张量
形状 (?,9,7,58)
我怎样才能在 Keras 中实现这一点。 谢谢
【问题讨论】:
标签: machine-learning tensorflow nlp keras