seq2seq_model.py ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_ce

在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),请参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值