Tensorflow StackPopV2错误调用Pop()时堆栈为空

时间:2017-12-07 08:09:17

标签: python tensorflow lstm recurrent-neural-network

我正在尝试运行tensorflow dynamic_rnn:

with tf.name_scope("RNN_forward"):
    outputs, state = tf.nn.dynamic_rnn(cell=multi_rnn_cell,
                                       inputs=input_emb,
                                       sequence_length=tf.squeeze(lengths),
                                       dtype=tf.float32)

Input_emb的形状为64x20x300,长度为64x1。

此代码不断发出此错误:

File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 236, in _rnn_step
    new_output, new_state = call_cell()
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 748, in <lambda>
    call_cell = lambda: cell(input_t, state)
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 183, in __call__
    return super(RNNCell, self).__call__(inputs, state)
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 575, in __call__
    outputs = self.call(inputs, *args, **kwargs)
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1066, in call
    cur_inp, new_state = cell(cur_inp, cur_state)
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 891, in __call__
    output, new_state = self._cell(inputs, state, scope)
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 183, in __call__
    return super(RNNCell, self).__call__(inputs, state)
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 575, in __call__
    outputs = self.call(inputs, *args, **kwargs)
  File "/home/ubuntu/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 441, in call
    value=self._linear([inputs, h]), num_or_size_splits=4, axis=1)

InvalidArgumentError (see above for traceback): Stack[gradients_2/lstm_disc_net_1/RNN_forward/rnn/while/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/MatMul_grad/MatMul_1/f_acc_0] is empty when calling Pop().
         [[Node: gradients_2/lstm_disc_net_1/RNN_forward/rnn/while/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/MatMul_grad/MatMul_1/StackPopV2 = StackPopV2[elem_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](gradients_2/lstm_disc_net_1/RNN_forward/rnn/while/rnn/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/MatMul_grad/MatMul_1/StackPopV2/Enter, ^gradients_2/Sub)]]

有没有人曾经遇到过这样的错误?我无法在网上找到任何参考资料。

0 个答案:

没有答案