Open matsen opened 4 years ago
I think we'd have to use named functions instead of lambdas in the JointDistributionNamed
constructor. This might be easier with a different JointDistribution
concrete class - you could do it with a single named function in JointDistributionCoroutine
By the way, I tried using the dill serializer and got a TypeError: can't pickle HashableWeakRef objects error.
Seems like the way to do this would be to build things up slowly...
This from the TFP mailing list:
Saving models: This was probably the biggest headache for us. At the
commencement of the contest we had to send a saved model to the organizers.
We thought it would be as easy as inheriting tf.Module and using
tensorflow's saved model capabilities. We were wrong. We relied a lot on
using JointDistributionNamed objects and these objects completely refused
to be saved. In order to get our model object to save at all, I had to
exclude all JointDistributionNamed objects using NoDependency which in
essence meant that our model wasn't saved. We started developing the
project before JointDistributionCoroutine was included in TFP - no idea if
that has the same issue. Additionally, other non-tensorflow attributes such
as lists and dictionaries with model attributes didn't get saved when using
saved model. Eventually, we developed our own serialization using pickle.
cc @miparedes
I tried pickling a variational approximation by adding this to the treeflow experiment
experiments/2020-06-18-getting-started
:... and got the error
Poking around, it looks like this might not be too hard to fix.
Or is there a better way to serialize such models?