按照Sequence to Sequence教程中的说明操作时收到以下错误消息: https://www.tensorflow.org/tutorials/seq2seq
当我跑步时
python translate.py --data-dir [your data directory]
当脚本创建图层时,我最终会收到以下错误:
AttributeError: 'NoneType' object has no attribute 'update'
(下面的完整堆栈跟踪)
系统信息:
此外,已下载并处理WMT数据。我按照教程中的说明下载了英语到法语的数据。
非常感谢任何帮助。
Preparing WMT data in /tmp
2017-06-16 09:28:44.185353: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 09:28:44.185383: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 09:28:44.185388: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 09:28:44.185393: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Creating 3 layers of 1024 units.
Traceback (most recent call last):
File "translate.py", line 322, in <module>
tf.app.run()
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "translate.py", line 319, in main
train()
File "translate.py", line 178, in train
model = create_model(sess, False)
File "translate.py", line 136, in create_model
dtype=dtype)
File "/Users/<redacted>/models/tutorials/rnn/translate/seq2seq_model.py", line 179, in __init__
softmax_loss_function=softmax_loss_function)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 1206, in model_with_buckets
decoder_inputs[:bucket[1]])
File "/Users/<redacted>/models/tutorials/rnn/translate/seq2seq_model.py", line 178, in <lambda>
lambda x, y: seq2seq_f(x, y, False),
File "/Users/<redacted>/models/tutorials/rnn/translate/seq2seq_model.py", line 142, in seq2seq_f
dtype=dtype)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 848, in embedding_attention_seq2seq
encoder_cell = copy.deepcopy(cell)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 166, in deepcopy
y = copier(memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/site-packages/tensorflow/python/layers/base.py", line 476, in __deepcopy__
setattr(result, k, copy.deepcopy(v, memo))
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 223, in _deepcopy_tuple
y = [deepcopy(a, memo) for a in x]
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 223, in <listcomp>
y = [deepcopy(a, memo) for a in x]
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/Users/<redacted>/anaconda/envs/tf/lib/python3.5/copy.py", line 306, in _reconstruct
y.__dict__.update(state)
AttributeError: 'NoneType' object has no attribute 'update'
答案 0 :(得分:5)
RNNCell的深度复制似乎存在问题,我们正在跟踪这个github错误:https://github.com/tensorflow/tensorflow/issues/8191
另外,还有一个新的TensorFlow seq2seq仓库,里面有很多模型:https://github.com/google/seq2seq如果你只对结果而不是模型感兴趣,那么我们这里有新模型:{{3对于任何情况下的错误,请注意,请查看github错误页面,了解有关该解决方案的更多详细信息。
答案 1 :(得分:3)
如果您只有一个桶,该模型似乎可以正常工作。在等待修复错误的同时,如果您只想查看一些初始结果,请在translate.py中更改4个桶的列表: _buckets = [(5,10),(10,15),(20,25),(40,50)] 只有一个桶,例如_buckets = [(10,15)]。