You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run a model I trained in Python on TensorFlow.NET. I have the weights in HDF5 format and the model replicated in TensorFlow.NET, but when I use model.load_weights(path.h5) it fails to load the weights because it can't find the weights by name.
I did some debugging and found out that it expects dollar signs in the path for some reason, which are normally not there in the weight names.
Hello, thank you for your attention to TensorFlow.NET, this PR does looks have some problems, we will fix it. BTW, model.load_weights does not implemented prefect in TensorFlow.NET, you can try use model.save and keras.models.load_model to save and load the whole model, we recommend you to use this api, because it implemented better in TensorFlow.NET
Hello, thank you for your attention to TensorFlow.NET, this PR does looks have some problems, we will fix it. BTW, model.load_weights does not implemented prefect in TensorFlow.NET, you can try use model.save and keras.models.load_model to save and load the whole model, we recommend you to use this api, because it implemented better in TensorFlow.NET
Using keras.models.load_model is what I tried initially but it didnt work because I got a NotImplementedException at
Description
I'm trying to run a model I trained in Python on TensorFlow.NET. I have the weights in HDF5 format and the model replicated in TensorFlow.NET, but when I use
model.load_weights(path.h5)
it fails to load the weights because it can't find the weights by name.I did some debugging and found out that it expects dollar signs in the path for some reason, which are normally not there in the weight names.
https://github.com/SciSharp/TensorFlow.NET/blob/fa2d2dcfc894686846f475a98300b6f8af0bfa94/src/TensorFlowNET.Keras/Saving/hdf5_format.cs#L137C21-L141C61
This code seems to be recently added by #1137. The code looks awful, so please revert that change.
Reproduction Steps
In Python with TensorFlow, export some model weights using
model.save_weights('my_checkpoint.h5')
Then in C# with TensorFlow.NET, load the weights using
model.load_weights("my_checkpoint.h5");
Known Workarounds
Exporting weights using TensorFlow.NET inserts the dollar signs so loading works in that case.
It might be possible to workaround if you manually replace all weight names in the saved weights file.
Configuration and Other Information
The text was updated successfully, but these errors were encountered: