I am using tesorflow version 1.2 (gpu)
i try to run tensorflow chatbot which is a varient of translate example . fixed many problems due to version change ,but can't fix this error
Traceback (most recent call last):
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\execute.py", line 319, in <module>
train()
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\execute.py", line 137, in train
model = create_model(sess, False)
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\execute.py", line 104, in create_model
model = seq2seq_model.Seq2SeqModel( gConfig['enc_vocab_size'], gConfig['dec_vocab_size'], _buckets, gConfig['layer_size'], gConfig['num_layers'], gConfig['max_gradient_norm'], gConfig['batch_size'], gConfig['learning_rate'], gConfig['learning_rate_decay_factor'], forward_only=forward_only)
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\seq2seq_model.py", line 150, in __init__
softmax_loss_function=softmax_loss_function)
File "C:\Python35\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 1221, in model_with_buckets
softmax_loss_function=softmax_loss_function))
File "C:\Python35\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 1134, in sequence_loss
softmax_loss_function=softmax_loss_function))
File "C:\Python35\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 1089, in sequence_loss_by_example
crossent = softmax_loss_function(labels=target, logits=logit)
TypeError: sampled_loss() got an unexpected keyword argument 'logits'
error causing line of code
self.outputs, self.losses = tf.contrib.legacy_seq2seq.model_with_buckets(
self.encoder_inputs, self.decoder_inputs, targets,
self.target_weights, buckets,
lambda x, y: seq2seq_f(x, y, False),
softmax_loss_function=softmax_loss_function)
<-- line 150 from seq2seq.py
and softmax_loss_function is come from here
def sampled_loss(inputs, labels):
labels = tf.reshape(labels, [-1, 1])
return tf.nn.sampled_softmax_loss(w_t, b, labels, inputs, num_samples,
self.target_vocab_size)
softmax_loss_function = sampled_loss
please help
@athuldevin Hi, i also met this error, but when i changed 'sampled_loss(inputs, labels)' to 'sampled_loss(labels, logits) : labels = tf.reshape(labels, [-1, 1]) return tf.nn.sampled_softmax_loss(w_t, b, labels, logits, num_samples, self.target_vocab_size) ' , the error gone.
@StephenLee2016 hi, thanks that error is fixed but a new one is generated may be it is related to that one
Traceback (most recent call last):
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\execute.py", line 319, in <module>
train()
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\execute.py", line 137, in train
model = create_model(sess, False)
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\execute.py", line 104, in create_model
model = seq2seq_model.Seq2SeqModel( gConfig['enc_vocab_size'], gConfig['dec_vocab_size'], _buckets, gConfig['layer_size'], gConfig['num_layers'], gConfig['max_gradient_norm'], gConfig['batch_size'], gConfig['learning_rate'], gConfig['learning_rate_decay_factor'], forward_only=forward_only)
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\seq2seq_model.py", line 150, in __init__
softmax_loss_function=softmax_loss_function)
File "C:\Python35\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 1206, in model_with_buckets
decoder_inputs[:bucket[1]])
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\seq2seq_model.py", line 149, in <lambda>
lambda x, y: seq2seq_f(x, y, False),
File "C:\Users\win-7\Downloads\tensorflow_chatbot-master\new\seq2seq_model.py", line 113, in seq2seq_f
feed_previous=do_decode)
File "C:\Python35\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 848, in embedding_attention_seq2seq
encoder_cell = copy.deepcopy(cell)
File "C:\Python35\lib\copy.py", line 166, in deepcopy
y = copier(memo)
File "C:\Python35\lib\site-packages\tensorflow\python\layers\base.py", line 476, in __deepcopy__
setattr(result, k, copy.deepcopy(v, memo))
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 166, in deepcopy
y = copier(memo)
File "C:\Python35\lib\site-packages\tensorflow\python\layers\base.py", line 476, in __deepcopy__
setattr(result, k, copy.deepcopy(v, memo))
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 291, in _reconstruct
args = deepcopy(args, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 223, in _deepcopy_tuple
y = [deepcopy(a, memo) for a in x]
File "C:\Python35\lib\copy.py", line 223, in <listcomp>
y = [deepcopy(a, memo) for a in x]
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list
y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 223, in _deepcopy_tuple
y = [deepcopy(a, memo) for a in x]
File "C:\Python35\lib\copy.py", line 223, in <listcomp>
y = [deepcopy(a, memo) for a in x]
File "C:\Python35\lib\copy.py", line 155, in deepcopy
y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 306, in _reconstruct
y.__dict__.update(state)
AttributeError: 'NoneType' object has no attribute 'update'
is i need to change this line of code from execute.py
"""Create model and initialize or load parameters"""
def create_model(session, forward_only):
model = seq2seq_model.Seq2SeqModel( gConfig['enc_vocab_size'], gConfig['dec_vocab_size'], _buckets, gConfig['layer_size'], gConfig['num_layers'], gConfig['max_gradient_norm'], gConfig['batch_size'], gConfig['learning_rate'], gConfig['learning_rate_decay_factor'], forward_only=forward_only)
this error also happens in translate program
thanks for helping
@athuldevin Hi, I also met this issue now, maybe translate.py need be updated, and you can focus https://github.com/tensorflow/models/issues/1733
Hi,
I also got this error when trying to run seq2seq model (translate.py) with tensorflow 1.2 python 3.5.
...
File "C:\Python35\lib\copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 297, in _reconstruct state = deepcopy(state, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 243, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python35\lib\copy.py", line 155, in deepcopy y = copier(x, memo)
File "C:\Python35\lib\copy.py", line 218, in _deepcopy_list y.append(deepcopy(a, memo))
File "C:\Python35\lib\copy.py", line 182, in deepcopy y = _reconstruct(x, rv, 1, memo)
File "C:\Python35\lib\copy.py", line 306, in _reconstruct y.__dict__.update(state) AttributeError: 'NoneType' object has no attribute 'update'
...
Please help to fix it.
can you share the full error message
@athuldevin Thanks my error is resolved but now i received another error
python3 execute.py
Mode : train
Preparing data in working_dir/
2017-09-05 17:03:48.291647: 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-09-05 17:03:48.291668: 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-09-05 17:03:48.291673: 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-09-05 17:03:48.291677: 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 128 units.
Traceback (most recent call last):
File "execute.py", line 290, in
train()
File "execute.py", line 114, in train
model = create_model(sess, False)
File "execute.py", line 82, in create_model
model = seq2seq_model.Seq2SeqModel( gConfig['enc_vocab_size'], gConfig['dec_vocab_size'], _buckets, gConfig['layer_size'], gConfig['num_layers'], gConfig['max_gradient_norm'], gConfig['batch_size'], gConfig['learning_rate'], gConfig['learning_rate_decay_factor'], forward_only=forward_only)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/chatbot_model/chatbot-master/seq2seq_model.py", line 112, in __init__
softmax_loss_function=softmax_loss_function)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 1206, in model_with_buckets
decoder_inputs[:bucket[1]])
File "/Users/ttmac2/Documents/Shahab/MachineLearning/chatbot_model/chatbot-master/seq2seq_model.py", line 111, in
lambda x, y: seq2seq_f(x, y, False),
File "/Users/ttmac2/Documents/Shahab/MachineLearning/chatbot_model/chatbot-master/seq2seq_model.py", line 75, in seq2seq_f
feed_previous=do_decode)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 848, in embedding_attention_seq2seq
encoder_cell = copy.deepcopy(cell)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 161, in deepcopy
y = copier(memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 487, in __deepcopy__
setattr(result, k, copy.deepcopy(v, memo))
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 215, in _deepcopy_list
append(deepcopy(a, memo))
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/ttmac2/Documents/Shahab/MachineLearning/anaconda/lib/python3.6/copy.py", line 169, in deepcopy
rv = reductor(4)
TypeError: can't pickle _thread.lock objects
current solution for this error is downgrading your tensorflow version to 1.0.0 as said by the community
this not solution. solution is to update code !!!
@MartinAbilev where do we update? could you give few directions?
@shahabdroid i am also getting the same error.
@StephenLee2016 solved this problem
@shahabdroid @anne1994 This error is actually, firstly, not an error, and secondly, not related to tensorflow
. Basically numpy
or tensor
objects cannot be pickled (atleast normally through the pickle module) since they are thread.locked, and deepcopy cannot copy such objects. Refer to this for a similar discussion.
HEllo I'm having same issue , any solutions?
what is the issue ?? :)
Most helpful comment
@athuldevin Hi, i also met this error, but when i changed 'sampled_loss(inputs, labels)' to 'sampled_loss(labels, logits) : labels = tf.reshape(labels, [-1, 1]) return tf.nn.sampled_softmax_loss(w_t, b, labels, logits, num_samples, self.target_vocab_size) ' , the error gone.