在tensorflow的translate的实例中遇到错误:
Traceback (most recent call last):
File "/Users/mac/PycharmProjects/Mytensorflow/RNN/translate/translate.py", line 319, in <module>
self()
File "/Users/mac/PycharmProjects/Mytensorflow/RNN/translate/translate.py", line 294, in self
5.0, 32, 0.3, 0.99, num_samples=8)
File "/Users/mac/PycharmProjects/Mytensorflow/RNN/translate/seq2seq_model.py", line 177, in __init__
softmax_loss_function=softmax_loss_function)
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 1201, in model_with_buckets
decoder_inputs[:bucket[1]])
File "/Users/mac/PycharmProjects/Mytensorflow/RNN/translate/seq2seq_model.py", line 176, in <lambda>
lambda x, y: seq2seq_f(x, y, False),
File "/Users/mac/PycharmProjects/Mytensorflow/RNN/translate/seq2seq_model.py", line 140, in seq2seq_f
dtype=dtype)
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 855, in embedding_attention_seq2seq
encoder_cell, encoder_inputs, dtype=dtype)
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn.py", line 197, in static_rnn
(output, state) = call_cell()
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn.py", line 184, in <lambda>
call_cell = lambda: cell(input_, state)
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 881, in __call__
return self._cell(embedded, state)
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 146, in __call__
with _checked_scope(self, scope or "gru_cell", reuse=self._reuse):
File "/anaconda/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 77, in _checked_scope
type(cell).__name__))
ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.GRUCell object at 0x1160d1d50> with a different variable scope than its first use. First use of cell was with scope 'embedding_attention_seq2seq/embedding_attention_decoder/attention_decoder/gru_cell', this attempt is with scope 'embedding_attention_seq2seq/rnn/gru_cell'. Please create a new instance of the cell if you would like it to use a different set of weights. If before you were using: MultiRNNCell([GRUCell(...)] * num_layers), change to: MultiRNNCell([GRUCell(...) for _ in range(num_layers)]). If before you were using the same cell instance as both the forward and reverse cell of a bidirectional RNN, simply create two instances (one for forward, one for reverse). In May 2017, we will start transitioning this cell's behavior to use existing stored weights, if any, when it is called with scope=None (which can lead to silent model degradation, so this error will remain until then.)
解决这个问题的方法是:将tendorflow升级到最新的tendorflow的1.4版本,但是还会出现
A[seq2seq_model.py AttributeError: 'NoneType' object has no attribute 'update'](http://blog.csdn.net/meijie770342/article/details/78984309),请参考