Cannot load HDF5 model after export
See original GitHub issueI tried the example of Titanic Survival Prediction from your document and export the model with the following code ,although the model is exported I got numpy error.
model = clf.export_model()
model.save('titanic.h5')
Traceback (most recent call last): File "titanic.py", line 17, in <module> model.save('titanic.h5') File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\engine\network.py", line 1008, in save signatures, options) File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\save.py", line 112, in save_model model, filepath, overwrite, include_optimizer) File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 109, in save_model_to_hdf5 save_weights_to_hdf5_group(model_weights_group, model_layers) File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 627, in save_weights_to_hdf5_group weight_values = K.batch_get_value(weights) File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\backend.py", line 3270, in batch_get_value return [x.numpy() for x in tensors] File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\backend.py", line 3270, in <listcomp> return [x.numpy() for x in tensors] AttributeError: 'TrackableWeightHandler' object has no attribute 'numpy'
When I was trying to load the HDF5 model for prediction , errors occurs
model = tf.keras.models.load_model('titanic.h5', custom_objects=ak.CUSTOM_OBJECTS)
Traceback (most recent call last): File "load_model.py", line 4, in <module> model = tf.keras.models.load_model('titanic.h5', custom_objects=ak.CUSTOM_OBJECTS) File "C:\Users\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\save.py", line 146, in load_model return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile) File "C:\Users\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 171, in load_model_from_hdf5 load_weights_from_hdf5_group(f['model_weights'], model.layers) File "C:\Users\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 668, in load_weights_from_hdf5_group g = f[name] File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "C:\Users\Python\Python37\lib\site-packages\h5py\_hl\group.py", line 264, in __getitem__ oid = h5o.open(self.id, self._e(name), lapl=self._lapl) File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py\h5o.pyx", line 190, in h5py.h5o.open KeyError: "Unable to open object (object 'dense' doesn't exist)"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:12 (5 by maintainers)
Top GitHub Comments
any news ?
Hello,
Is there any update regarding this topic?
I find myself in the same situation…
Thanks!
(tf 2.1)