Open piotrlaczkowski opened 4 years ago
I guess this is the issue. But this is also not resolved https://github.com/tensorflow/tensorflow/issues/31927
The issue is not resolved on my side as well. Can someone from the tensorflow team take a look and help with this?
I have managed to understand several serialisation issues in TF more deeply.
It seams that everything related to preprocessing layers or some custom losses or custom function is not getting well serialised -> or I should rather say rendered by the tool called autograph
- which handles exporting correct namings into a serialised graph/files etc.
These issues were finally solved in TF 2.4 but reappeared magically again in TF 2.5 -> so the only version I can actually work with and use this kind of model is TF2.4.
If you are interested in some more details about this kind of model or problems with related architecture -> do not hesitate to contact me directly. (If enough people will be interested I can publish a blog about my deep dive into this isse and all the solutions I have implemented)
Have fun!
This looks like continues to be a problem with saving TensorFlow probability layers as indicated previously.
I was not able to read in a saved model so switched to building a model and reading weights. This worked with a model with a tfp.layers.DistributionLambda layer. However I now have a model with a tfp.layers.DenseVariational layer and reading weights now also fails. Wondering if this has been fixed or there is a workaround:-
I am using:-
tensorflow 2.7.0 tensorflow-estimator 2.7.0 tensorflow-probability 0.15.0 h5py 3.6.0
Traceback (most recent call last):
File "/DOWNSCALE_project/test_tfd_infer.py", line 210, in
@JohnTaylor2000 Hello, I have the same problem, could I have any tips please
The issue was fixed in the TF version > 2.6 (if I remember well) so if you use the latest version this same model works ! ;) It was related to the internal package error that was propagated through several versions and finally fixed in 2022.
Hope this helps
Thanks,That really works
I have a Tensorflow 2.x model which is using the TF preprocessing layer (tf.keras.layers.DenseFeatures) and the distributional layer from TF probability (DistributionLambda)
I can get some nice results for the regression problem with this model, but when I save it for further use I can't load it back anymore (I have tried all online tutorials and solutions, but nothing is working)!!
I can save it to a file (h5, tf, json etc...) i.e.:
but when loading I get:
I can't figure out what am I doing wrong - any help would be appreciated!
Also, I have tried all possible save extensions and backends: h5, tf, json, simple weights and other formats but none of them works ... I have even tried to do it on different systems: Mac, Ubuntu and on different Tensorflow versions: 2 and 2.1 ...
Of course, all the saving and loading works great for other models I use without the TF Probability layer (even the ones with a DenseFeatures layer).