0
這是一個將成功序列化爲dill
的片段,但是會以pickle
失敗。令人驚訝的是Tensor
對象不是本機可醃的。這是線程感知張量的根本限制,還是僅僅是沒有實現?酸洗tensorflow張量爲什麼會失敗?
import dill
import pickle
import tensorflow as tf
dill.dumps(tf.zeros((1,1)))
print("Dill succeeded")
pickle.dumps(tf.zeros((1,1)))
print("Pickle succeeded")
輸出:
$ python foo.py
Dill succeeded
Traceback (most recent call last):
File "foo.py", line 7, in <module>
pickle.dumps(tf.zeros((1,1)))
TypeError: can't pickle _thread.lock objects
可能的重複http://stackoverflow.com/questions/39286665/how-to-avoid-pickling-errors-when-sharing-objects-between-threads – DyZ