Tensorflow1.2导致错误:无法在deepcopy或Cpickle上挑选_thread.lock对象

时间:2017-07-10 14:54:59

标签: python tensorflow pickle deep-copy autoencoder

有关

encoder_cell = copy.deepcopy(cell) 

encoder_cell = cPickle.loads(cPickle.dumps(cell, -1))

在tensoflow1.2中,它会引发错误,如:

    encoder_cell = cPickle.loads(cPickle.dumps(cell, -1))
TypeError: can't pickle _thread.lock objects

但它在tensorflow1.0.1上运行良好

1 个答案:

答案 0 :(得分:0)

如果您正在使用旧版seq2seq.py,请将其添加到您的脚本中:

setattr(tf.contrib.rnn.GRUCell, '__deepcopy__', lambda self, _: self)
setattr(tf.contrib.rnn.BasicLSTMCell, '__deepcopy__', lambda self, _: self)
setattr(tf.contrib.rnn.MultiRNNCell, '__deepcopy__', lambda self, _: self)