keras
keras copied to clipboard
model trainable params have changed after saving and reloading
Shortly
- [env Keras V2] I have keras model in
.h5format and SavedModel format. - [env Keras V2] I saved keras model in
.weights.h5format. - [env Keras V3] I loaded
.weights.h5fromat (model_a) and inference matched properly with previous.h5. - [env Keras V3] I saved
.weights.h5loaded Keras V3 model in.kerasformat (model_b). It saved and later reloaded properly. - Issue 1 is, the model's parameter of model_a and model_b are different despite being the same arch, initialized with same input. How best way to inspect these weights? Further, if I saved model_a to SavedModel format using
tf.saved_model.saveand reloaded withkeras.layers.TFSMLayer, it remains safe unlike.kerasformat. So, shortly using Keras V3, the.weights.h5and SavedModel file works fine but not in.kerasformat. - Issue 2 is, with
torchbackend, the inference with.weights.h5format works as expected but changing totensorflowandjaxgive different logits. I can ensure the low-level ops are properly set. So, I'm wondering, is there any known fact we need to care while using keras API with different backend? In other word, I usedkeras.ops,keras.layerswhich suppose to behave same for different backend, or no!
@nkovela1 , Could you please take a look into this issue. Thanks!