我正在尝试用tensorflow建立一个图表。但它给了我一个错误,我有错误的形状等级。所以,我试图找出哪一步出了问题。在构建图形时,是否有机会找出元素输出的形状
例如,我的代码是:
def inference_decoding_layer(start_token, end_token, embeddings, dec_cell, initial_state, output_layer,
max_summary_length, batch_size):
'''Create the inference logits'''
start_tokens = tf.tile(tf.constant([start_token], dtype=tf.int32), [batch_size], name='start_tokens')
inference_helper = tf.contrib.seq2seq.GreedyEmbeddingHelper(embeddings, #shape (2000,25,768)
start_tokens,
end_token)
inference_decoder = tf.contrib.seq2seq.BasicDecoder(dec_cell,
inference_helper,
initial_state,
output_layer)
inference_logits, _ , _ = tf.contrib.seq2seq.dynamic_decode(inference_decoder,
output_time_major=False,
impute_finished=True,
maximum_iterations=max_summary_length)
return inference_decoder
问题出现在动态_解码器上。以下是错误:
ValueError: Shape must be rank 3 but is rank 2 for 'decode/decoder/while/BasicDecoderStep/decoder/attention_wrapper/concat_6' (op: 'ConcatV2') with input shapes: [32,25,768], [32,256], [].
所以,我想知道是否有一种方法可以找出,例如,我们从GreedEmbeddingHelper和BasicDecoder得到的值的形状。。。或者是我整个代码中的其他东西。所以,我会找出问题所在
另外,如果在这种情况下有任何其他方法/建议如何定位问题,我将非常感谢
为了便于调试,引入了
eager
模式。使用渴望模式,您可以在执行每行代码后继续打印输出形状在TF 1.x中,要启用它,必须运行以下代码:
在TF 2.0中,默认情况下将启用急切模式。此外,您正在处理的包已在TF2.0中移动到TensorFlow Addons
相关问题 更多 >
编程相关推荐