Open n3011 opened 4 years ago
Using tf_agents.policies.policy_loader.load
I can load policy. Thanks.
In this case, my concern is how I can use TF Serving if the policy can not be loaded with standard saved_model.load
?
+1
I'm trying to convert a policy to TFLite and hit the same error. Not being fully 'Saved Model' is a real barrier.
Does it work on TF 2.4?
Just tried nightly. Didn't work.
_DistributionTypeSpec
is a Tensorflow Probability object that we use in our policies because we serialize the _distribution()
method as well. Tensorflow Probability renamed this object to _TFPTypeSpec
about 4 months ago: https://github.com/tensorflow/probability/commit/2ffe65af9fbc1f1ce0a66a33073a243f3f089ed3
So in this case, the issue may be due to a policy saved with an older version of TFP but loaded with a recent version of TFP. I'll include the TFP team to see if they can make this backwards compatible.
Another possible issue here is that the type spec is only registered if you import tfp.experimental
; unfortunately may be lazy-loaded (https://github.com/tensorflow/probability/blob/master/tensorflow_probability/python/__init__.py#L118). If you could run two experiments:
Let us know if doing either of these fixes the issue.
Facing the same issue with tensorflow==2.4.1
, tf_agents==0.7.1
And adding "import tensorflow_probability" fixes the issue (tf.saved_model.load
works)
1. Import tensorflow_probability then try to do saved_model.load
I was facing a similar issue, not being able to load a policy. I added the import tensorflow_probability
line at the beginning of the module, and it worked.
I was trying to load a saved model policy using the following code, but it ends with errors pasted below
saved_policy = tf.saved_model.load('policy_0')
Software versions: