Closed kishan042p closed 4 weeks ago
I have the same problem in Kaggle notebook while executing the following code:
history=model1.fit(train_img_datagen, steps_per_epoch=steps_per_epoch, epochs=100, verbose=1, callbacks = [ keras.callbacks.ModelCheckpoint('UNet_100.h5', save_weights_only=False, save_best_only=True, monitor='val_loss', mode='min'), keras.callbacks.ReduceLROnPlateau(), ], validation_data=val_img_datagen, validation_steps=val_steps_per_epoch, )
@kishan042p I have just solved the problem by installing an older versio of keras:
!pip install keras==2.15.0 import keras print(keras.version)
But you have to restart your kernel before using it,
Good luck
@kishan042p I have just solved the problem by installing an older versio of keras:
!pip install keras==2.15.0 import keras print(keras.version)
But you have to restart your kernel before using it,
Good luck
But i Want to save model in .h5 file not in .keras so please provide solution regarding it.
Yes I use my old code, where I save my model in .h5 file not .keras You don't have to change anything, you just have to iinstall an older version of keras and everything will be OK
In Keras 3, for checkpoint filepath, you need to provide in .keras
format only, if you're saving only weights file name should end with .weights.h5
.
You can save and load the model in .h5 using below method https://keras.io/guides/migrating_to_keras_3/#saving-a-model-in-the-tf-savedmodel-format
In Keras 3, if you want to save your model in .h5 file in any case, set "save_weights_only=True", and change your flie name to "xxx.weights.h5".
for your code:
CKPT_path = "Model_ckpt.weights.h5"
checkpointing_cb = tf.keras.callbacks.ModelCheckpoint(CKPT_path, save_best_only=True, save_weights_only=True)
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.
https://keras.io/guides/migrating_to_keras_3/#saving-a-model-in-the-tf-savedmodel-format
"The following snippet of code will reproduce the above error:
sequential_model = keras.Sequential([
keras.layers.Dense(2)
])
sequential_model.save("saved_model")
How to fix it: use model.export(filepath) instead of model.save(filepath)"
Issue Type
Support
Source
source
Keras Version
3.2.1
Custom Code
Yes
OS Platform and Distribution
Linux Ubuntu 22.04.4
Python version
3.11.5
GPU model and memory
16 gm
Current Behavior?
please solve this error
Standalone code to reproduce the issue or tutorial link
Relevant log output