tensorflow / models

Models and examples built with TensorFlow
Other
77.16k stars 45.77k forks source link

wrong with `tutorials/rnn/translate/seq2seq_model.py` #1875

Closed zklgame closed 7 years ago

zklgame commented 7 years ago

I download the code, go to tutorials/rnn/translate, run the command:

python translate.py --self_test

but something wrong happened:

Self-test for neural translation model.
Traceback (most recent call last):
  File "translate.py", line 322, in <module>
    tf.app.run()
  File "/Users/zklgame/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "translate.py", line 315, in main
    self_test()
  File "translate.py", line 299, in self_test
    5.0, 32, 0.3, 0.99, num_samples=8)
  File "/Users/zklgame/Developer/tensorflow:models/tutorials/rnn/translate/seq2seq_model.py", line 179, in __init__
    softmax_loss_function=softmax_loss_function)
  File "/Users/zklgame/anaconda2/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/zklgame/Developer/tensorflow:models/tutorials/rnn/translate/seq2seq_model.py", line 178, in <lambda>
    lambda x, y: seq2seq_f(x, y, False),
  File "/Users/zklgame/Developer/tensorflow:models/tutorials/rnn/translate/seq2seq_model.py", line 142, in seq2seq_f
    dtype=dtype)
  File "/Users/zklgame/anaconda2/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 "/Users/zklgame/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn.py", line 197, in static_rnn
    (output, state) = call_cell()
  File "/Users/zklgame/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn.py", line 184, in <lambda>
    call_cell = lambda: cell(input_, state)
  File "/Users/zklgame/anaconda2/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 "/Users/zklgame/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 953, in __call__
    cur_inp, new_state = cell(cur_inp, cur_state)
  File "/Users/zklgame/anaconda2/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 "/Users/zklgame/anaconda2/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/Users/zklgame/anaconda2/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 0x11b87de10> with a different variable scope than its first use.  First use of cell was with scope 'embedding_attention_seq2seq/embedding_attention_decoder/attention_decoder/multi_rnn_cell/cell_0/gru_cell', this attempt is with scope 'embedding_attention_seq2seq/rnn/multi_rnn_cell/cell_0/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.)

I check the code, line 129 of seq2seq_model.py is: cell = tf.contrib.rnn.MultiRNNCell([single_cell() for _ in range(num_layers)])

Continued: I found why the error happened:

encoder_cell = copy.deepcopy(cell)

If I don't use deep copy, but define encoder_cell and decoder_cell separately:

encoder_cell = tf.contrib.rnn.MultiRNNCell([single_cell() for _ in range(num_layers)])
decoder_cell = tf.contrib.rnn.MultiRNNCell([single_cell() for _ in range(num_layers)])

and make corresponding changes,then the program will run correctly!

So why this happened? Thanks for any explanation.

David-Levinthal commented 7 years ago

I am also having a problem with translate.py --self_test I have tensorflow R1.2 installed python -c 'import tensorflow as tf; print(tf.version)' 1.2.0

~/tensorflow/tensorflow/models/tutorials/rnn/translate$ python translate.py --self_test 2017-07-07 09:57:04.585901: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX512F instructions, but these are available on your machine and could speed up CPU computations. 2017-07-07 09:57:06.287275: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties: name: Tesla P4 major: 6 minor: 1 memoryClockRate (GHz) 1.1135 pciBusID 0000:86:00.0 Total memory: 7.46GiB Free memory: 7.34GiB 2017-07-07 09:57:06.287319: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0 2017-07-07 09:57:06.287323: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: Y 2017-07-07 09:57:06.287360: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla P4, pci bus id: 0000:86:00.0) Self-test for neural translation model. Traceback (most recent call last): File "translate.py", line 322, in tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "translate.py", line 315, in main self_test() File "translate.py", line 299, in self_test 5.0, 32, 0.3, 0.99, num_samples=8) File "/home/levinth/tensorflow/tensorflow/models/tutorials/rnn/translate/seq2seq_model.py", line 179, in init softmax_loss_function=softmax_loss_function) File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 1206, in model_with_buckets decoder_inputs[:bucket[1]]) File "/home/levinth/tensorflow/tensorflow/models/tutorials/rnn/translate/seq2seq_model.py", line 178, in lambda x, y: seq2seq_f(x, y, False), File "/home/levinth/tensorflow/tensorflow/models/tutorials/rnn/translate/seq2seq_model.py", line 142, in seq2seq_f dtype=dtype) File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 848, in embedding_attention_seq2seq encoder_cell = copy.deepcopy(cell) File "/usr/lib/python2.7/copy.py", line 174, in deepcopy y = copier(memo) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 476, in deepcopy setattr(result, k, copy.deepcopy(v, memo)) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 230, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 230, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 230, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 237, in _deepcopy_tuple y.append(deepcopy(a, memo)) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct state = deepcopy(state, memo) File "/usr/lib/python2.7/copy.py", line 163, in deepcopy y = copier(x, memo) File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) File "/usr/lib/python2.7/copy.py", line 343, in _reconstruct y.dict.update(state) AttributeError: 'NoneType' object has no attribute 'update'

cy89 commented 7 years ago

@nealwu PTAL.

nealwu commented 7 years ago

@ebrevdo could you take a look?

ebrevdo commented 7 years ago

Fixed at master.

David-Levinthal commented 7 years ago

the interest in the rnn tutorials is that they make very very nice HW evaluation benchmarks straightforward..very clean so it might be good to keep the idea of the tutorials as the basis for hw evaluation in mind tf_cnn_benchmarks is what we have converged on for CNNs the rnn tutorials make a solid next piece :-)

when could I download a functioning translate version? what would be needed in the base TF install? (full rebuild?) thanks again d

On Fri, Jul 7, 2017 at 8:03 PM, ebrevdo notifications@github.com wrote:

Fixed at master.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1875#issuecomment-313829430, or mute the thread https://github.com/notifications/unsubscribe-auth/AIUuT0BhJEQeu73gjpld_J3izawKpABNks5sLvGSgaJpZM4OPqRN .

cy89 commented 7 years ago

@tfboyd any thoughts from the hardware/benchmarking perspective?

tfboyd commented 7 years ago

I would not use these for benchmarking hardware unless they are the only examples. If you take a look at out benchmarks page, we use a script called tf_cnn_benchmark. Unfortunately, it currently only does CNNs but that is changing.

https://www.tensorflow.org/performance/benchmarks

David-Levinthal commented 7 years ago

We are using tf_cnn_benchmarks for cnns. For rnns we need something else. It appears ptb can be modified a bit ( print out words per second during verify) and it is then rather useful as the memory requirements are easily changed. It would appear translate could work for grus. D

On Jul 10, 2017 3:15 PM, "Toby Boyd" notifications@github.com wrote:

I would not use these for benchmarking hardware unless they are the only examples. If you take a look at out benchmarks page, we use a script called tf_cnn_benchmark. Unfortunately, it currently only does CNNs but that is changing.

https://www.tensorflow.org/performance/benchmarks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1875#issuecomment-314265420, or mute the thread https://github.com/notifications/unsubscribe-auth/AIUuT7-ug4UUsFgN9SaSuAQAAj37x-ucks5sMqKRgaJpZM4OPqRN .

tfboyd commented 7 years ago

The perf team should be updating ptb soon, if my memory is correct. We have some tweaks to have it use cuDNN, which should make it a much better measure. If you want to track the progress or track getting a good RNN benchmark, open a ticket and assign to me or mention me and I will assign it to myself and update it with progress. Glad/hope you find the benchmark tool useful.

Toby

On Mon, Jul 10, 2017 at 10:07 PM, David-Levinthal notifications@github.com wrote:

We are using tf_cnn_benchmarks for cnns. For rnns we need something else. It appears ptb can be modified a bit ( print out words per second during verify) and it is then rather useful as the memory requirements are easily changed. It would appear translate could work for grus. D

On Jul 10, 2017 3:15 PM, "Toby Boyd" notifications@github.com wrote:

I would not use these for benchmarking hardware unless they are the only examples. If you take a look at out benchmarks page, we use a script called tf_cnn_benchmark. Unfortunately, it currently only does CNNs but that is changing.

https://www.tensorflow.org/performance/benchmarks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/tensorflow/models/issues/1875#issuecomment-314265420 , or mute the thread https://github.com/notifications/unsubscribe-auth/AIUuT7- ug4UUsFgN9SaSuAQAAj37x-ucks5sMqKRgaJpZM4OPqRN .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1875#issuecomment-314324146, or mute the thread https://github.com/notifications/unsubscribe-auth/AWZestL-kZxIGZkpcQoXC9cMts4M8A8iks5sMwL0gaJpZM4OPqRN .

David-Levinthal commented 7 years ago

Fantastic. Will do Thanks

On Jul 11, 2017 6:04 PM, "Toby Boyd" notifications@github.com wrote:

The perf team should be updating ptb soon, if my memory is correct. We have some tweaks to have it use cuDNN, which should make it a much better measure. If you want to track the progress or track getting a good RNN benchmark, open a ticket and assign to me or mention me and I will assign it to myself and update it with progress. Glad/hope you find the benchmark tool useful.

Toby

On Mon, Jul 10, 2017 at 10:07 PM, David-Levinthal < notifications@github.com> wrote:

We are using tf_cnn_benchmarks for cnns. For rnns we need something else. It appears ptb can be modified a bit ( print out words per second during verify) and it is then rather useful as the memory requirements are easily changed. It would appear translate could work for grus. D

On Jul 10, 2017 3:15 PM, "Toby Boyd" notifications@github.com wrote:

I would not use these for benchmarking hardware unless they are the only examples. If you take a look at out benchmarks page, we use a script called tf_cnn_benchmark. Unfortunately, it currently only does CNNs but that is changing.

https://www.tensorflow.org/performance/benchmarks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/tensorflow/models/issues/1875# issuecomment-314265420 , or mute the thread https://github.com/notifications/unsubscribe-auth/AIUuT7- ug4UUsFgN9SaSuAQAAj37x-ucks5sMqKRgaJpZM4OPqRN .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/tensorflow/models/issues/1875#issuecomment-314324146 , or mute the thread https://github.com/notifications/unsubscribe-auth/AWZestL- kZxIGZkpcQoXC9cMts4M8A8iks5sMwL0gaJpZM4OPqRN .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1875#issuecomment-314492212, or mute the thread https://github.com/notifications/unsubscribe-auth/AIUuT3nGmLBtameNLmOFYrYL42VLwXpjks5sM50fgaJpZM4OPqRN .

David-Levinthal commented 7 years ago

RNN Benchmark derived from rnn tutorial #1983

d

On Tue, Jul 11, 2017 at 9:04 AM, Toby Boyd notifications@github.com wrote:

The perf team should be updating ptb soon, if my memory is correct. We have some tweaks to have it use cuDNN, which should make it a much better measure. If you want to track the progress or track getting a good RNN benchmark, open a ticket and assign to me or mention me and I will assign it to myself and update it with progress. Glad/hope you find the benchmark tool useful.

Toby

On Mon, Jul 10, 2017 at 10:07 PM, David-Levinthal < notifications@github.com> wrote:

We are using tf_cnn_benchmarks for cnns. For rnns we need something else. It appears ptb can be modified a bit ( print out words per second during verify) and it is then rather useful as the memory requirements are easily changed. It would appear translate could work for grus. D

On Jul 10, 2017 3:15 PM, "Toby Boyd" notifications@github.com wrote:

I would not use these for benchmarking hardware unless they are the only examples. If you take a look at out benchmarks page, we use a script called tf_cnn_benchmark. Unfortunately, it currently only does CNNs but that is changing.

https://www.tensorflow.org/performance/benchmarks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/tensorflow/models/issues/1875# issuecomment-314265420 , or mute the thread https://github.com/notifications/unsubscribe-auth/AIUuT7- ug4UUsFgN9SaSuAQAAj37x-ucks5sMqKRgaJpZM4OPqRN .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/tensorflow/models/issues/1875#issuecomment-314324146 , or mute the thread https://github.com/notifications/unsubscribe-auth/AWZestL- kZxIGZkpcQoXC9cMts4M8A8iks5sMwL0gaJpZM4OPqRN .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1875#issuecomment-314492212, or mute the thread https://github.com/notifications/unsubscribe-auth/AIUuT3nGmLBtameNLmOFYrYL42VLwXpjks5sM50fgaJpZM4OPqRN .

zhuoqianxiongdi commented 6 years ago

Traceback (most recent call last): File "F:/test/models-master/tutorials/rnn/translate/a.py", line 315, in self() File "F:/test/models-master/tutorials/rnn/translate/a.py", line 299, in self 5.0, 32, 0.3, 0.99, num_samples=8) File "F:\test\models-master\tutorials\rnn\translate\seq2seq_model.py", line 181, in init softmax_loss_function=softmax_loss_function) File "C:\ProgramData\Anaconda2\envs\python3\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 1209, in model_with_buckets decoder_inputs[:bucket[1]]) File "F:\test\models-master\tutorials\rnn\translate\seq2seq_model.py", line 180, in lambda x, y: seq2seq_f(x, y, False), File "F:\test\models-master\tutorials\rnn\translate\seq2seq_model.py", line 144, in seq2seq_f dtype=dtype) File "C:\ProgramData\Anaconda2\envs\python3\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 851, in embedding_attention_seq2seq encoder_cell = copy.deepcopy(cell) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 166, in deepcopy y = copier(memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\site-packages\tensorflow\python\layers\base.py", line 655, in deepcopy setattr(result, k, copy.deepcopy(v, memo)) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 218, in _deepcopy_list y.append(deepcopy(a, memo)) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 297, in _reconstruct state = deepcopy(state, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 243, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 297, in _reconstruct state = deepcopy(state, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 243, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 218, in _deepcopy_list y.append(deepcopy(a, memo)) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 297, in _reconstruct state = deepcopy(state, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 243, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 218, in _deepcopy_list y.append(deepcopy(a, memo)) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 223, in _deepcopy_tuple y = [deepcopy(a, memo) for a in x] File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 223, in y = [deepcopy(a, memo) for a in x] File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 155, in deepcopy y = copier(x, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 243, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo) File "C:\ProgramData\Anaconda2\envs\python3\lib\copy.py", line 306, in _reconstruct y.dict.update(state) AttributeError: 'NoneType' object has no attribute 'update'

修改这个问题的方法将seq2seq_model.py中line133的:

The seq2seq function: we use embedding for the input and attention.

def seq2seq_f(encoder_inputs, decoder_inputs, do_decode):
  return tf.contrib.legacy_seq2seq.embedding_attention_seq2seq(
      encoder_inputs,
      decoder_inputs, cell,
      num_encoder_symbols=source_vocab_size,
      num_decoder_symbols=target_vocab_size,
      embedding_size=size,
      output_projection=output_projection,
      feed_previous=do_decode,
      dtype=dtype)

change to: def seq2seq_f(encoder_inputs, decoder_inputs, do_decode): tmp_cell = copy.deepcopy(cell) return tf.contrib.legacy_seq2seq.embedding_attention_seq2seq( encoder_inputs, decoder_inputs, tmp_cell, num_encoder_symbols=source_vocab_size, num_decoder_symbols=target_vocab_size, embedding_size=size, output_projection=output_projection, feed_previous=do_decode, dtype=dtype)