dynamic_decode引发ValueError

时间:2018-09-24 23:18:03

标签: python tensorflow

我正在尝试构建一个非常简单的seq2seq模型,并且不断收到奇怪的错误消息。我正在建立的模型类似于https://github.com/tensorflow/nmt

我在解码阶段不断收到ValueError

lstm_dec = tf.contrib.rnn.LSTMCell(nodes)

helper = tf.contrib.seq2seq.TrainingHelper(
    output_embed, output_len, time_major=False, name = "trainHelper"
)

projLayer = tf.layers.Dense(DICTIONARY_SIZE, name="projection_layer")

# Decoder
decoder = tf.contrib.seq2seq.BasicDecoder(
    lstm_dec,
    helper,
    last_state
)

# Dynamic decoding
outputs, _, _ = tf.contrib.seq2seq.dynamic_decode(decoder)

logits = projLayer(outputs.rnn_output)
错误看起来像这样:

ValueError: Could not flatten dictionary. Key had 2 elements, but value had 1 elements. Key: [<tf.Tensor 'decoding/decoder/transpose:0' shape=(70, ?, 128) dtype=float32>, <tf.Tensor 'decoding/decoder/transpose_1:0' shape=(70, ?) dtype=int32>]

这是在我执行dynamic_decode()时发生的 以防万一-我的batch_size为70,nodes = 128

还有其他人遇到类似的问题吗?

谢谢!

0 个答案:

没有答案