Here's a snippet that will succeed in serializing with dill
, but fail with pickle
. It is surprising that Tensor
objects aren't natively pickleable. Is this a fundamental limitation of thread-aware Tensors, or is it just not implemented?
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")
Output:
$ 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