ValueError:as_list()未定义?

时间:2019-01-10 08:05:01

标签: tensorflow

我想用我的训练模型测试一些示例,但是在测试过程中会发生错误,请告诉我我的代码中的错误是集中在第119行:

line112: cell_fw = LSTMCell(self.hidden_dim,forget_bias=0.4)
line113: cell_bw = LSTMCell(self.hidden_dim,forget_bias=0.4)
line114: (output_fw_seq, output_bw_seq), _ = 
            tf.nn.bidirectional_dynamic_rnn(
line115:    cell_fw=cell_fw,
line116:    cell_bw=cell_bw,
line117:    inputs=self.word_embeddings,
line118:    sequence_length=self.sequence_lengths,
line119     dtype=tf.float32)

控制台错误如下:

 File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/rnn.py", line 416, in bidirectional_dynamic_rnn
    time_major=time_major, scope=fw_scope)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/rnn.py", line 632, in dynamic_rnn
    dtype=dtype)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/rnn.py", line 697, in _dynamic_rnn_loop
    const_time_steps, const_batch_size = inputs_got_shape[0].as_list()[:2]
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/tensor_shape.py", line 812, in as_list
    raise ValueError("as_list() is not defined on an unknown TensorShape.")
ValueError: as_list() is not defined on an unknown TensorShape.

0 个答案:

没有答案