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
NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using save_weights.
#38
Open
nicewinter opened this issue
Aug 22, 2024
· 0 comments
When running the notebook titled "vae_faces.ipynb", following code threw a '' error. Note I have created a virtual env. with Python=3.10 and used 'pip install -r requirements.txt' to install all dependencies in this repo before running the notebook.
File ~\AppData\Local\anaconda3\envs\genai\lib\site-packages\keras\utils\traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.traceback)
68 # To get the full stack trace, call:
69 # tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
File ~\AppData\Local\anaconda3\envs\genai\lib\site-packages\keras\saving\save.py:153, in save_model(model, filepath, overwrite, include_optimizer, save_format, signatures, options, save_traces)
144 if (
145 save_format == "h5"
146 or (h5py is not None and isinstance(filepath, h5py.File))
147 or saving_utils.is_hdf5_filepath(filepath)
148 ):
149 # TODO(b/130258301): add utility method for detecting model type.
150 if not model._is_graph_network and not isinstance(
151 model, sequential.Sequential
152 ):
--> 153 raise NotImplementedError(
154 "Saving the model to HDF5 format requires the model to be a "
155 "Functional model or a Sequential model. It does not work for "
156 "subclassed models, because such models are defined via the "
157 "body of a Python method, which isn't safely serializable. "
158 "Consider saving to the Tensorflow SavedModel format (by "
159 'setting save_format="tf") or using save_weights.'
160 )
161 hdf5_format.save_model_to_hdf5(
162 model, filepath, overwrite, include_optimizer
163 )
164 else:
NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using save_weights.
The text was updated successfully, but these errors were encountered:
When running the notebook titled "vae_faces.ipynb", following code threw a '' error. Note I have created a virtual env. with Python=3.10 and used 'pip install -r requirements.txt' to install all dependencies in this repo before running the notebook.
vae.fit(
train,
epochs=EPOCHS,
callbacks=[
model_checkpoint_callback,
tensorboard_callback,
ImageGenerator(num_img=10, latent_dim=Z_DIM),
],
)
Epoch 1/10
1583/1583 [==============================] - ETA: 0s - loss: 93.3229 - reconstruction_loss: 62.5427 - kl_loss: 16.0481
NotImplementedError Traceback (most recent call last)
Cell In[21], line 1
----> 1 vae.fit(
2 train,
3 epochs=EPOCHS,
4 callbacks=[
5 model_checkpoint_callback,
6 tensorboard_callback,
7 ImageGenerator(num_img=10, latent_dim=Z_DIM),
8 ],
9 )
File ~\AppData\Local\anaconda3\envs\genai\lib\site-packages\keras\utils\traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.traceback)
68 # To get the full stack trace, call:
69 #
tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
File ~\AppData\Local\anaconda3\envs\genai\lib\site-packages\keras\saving\save.py:153, in save_model(model, filepath, overwrite, include_optimizer, save_format, signatures, options, save_traces)
144 if (
145 save_format == "h5"
146 or (h5py is not None and isinstance(filepath, h5py.File))
147 or saving_utils.is_hdf5_filepath(filepath)
148 ):
149 # TODO(b/130258301): add utility method for detecting model type.
150 if not model._is_graph_network and not isinstance(
151 model, sequential.Sequential
152 ):
--> 153 raise NotImplementedError(
154 "Saving the model to HDF5 format requires the model to be a "
155 "Functional model or a Sequential model. It does not work for "
156 "subclassed models, because such models are defined via the "
157 "body of a Python method, which isn't safely serializable. "
158 "Consider saving to the Tensorflow SavedModel format (by "
159 'setting save_format="tf") or using
save_weights
.'160 )
161 hdf5_format.save_model_to_hdf5(
162 model, filepath, overwrite, include_optimizer
163 )
164 else:
NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using
save_weights
.The text was updated successfully, but these errors were encountered: