keras-js
keras-js copied to clipboard
Unable to generate model_weights.buf and model_metadata.json
I got error when running:
$ python encoder.py /path/to/model.hdf5
Which is :
Traceback (most recent call last): File "encoder.py", line 114, in <module> encoder.serialize() File "encoder.py", line 62, in serialize self.model.model_config = hdf5_file.attrs['model_config'] 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 "/home/ghassan/anaconda2/lib/python2.7/site-packages/h5py/_hl/attrs.py", line 58, in __getitem__ attr = h5a.open(self._id, self._e(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 "h5py/h5a.pyx", line 77, in h5py.h5a.open KeyError: "Can't open attribute (Can't locate attribute: 'model_config')"
The way I generated the model.hdf5 file is by :
happyModel.save_weights("model.hdf5")
Using Keras version: 2.0.7
I'm having the same issue using latest version of Keras. After digging around the closed issues I was able to use encoder.py and got a .bin file. I do not know what to do with it now cause I just want to load it inside my html file but keras still requires the three separate files. I am not using node.js, should I?
I did the same by saving the whole model as hdf5 file I was able to generate the .bin using the encoder.py but then when trying to load the model in keras.js it expect 3 files !. I am also using keras.js as a file, I don't think it would make such a different using node.js only if the module in node,js is updated such that when creating a new model it could take the file .bin as the only argument.
The encoder.py from the keras.js v3 release page:https://github.com/transcranial/keras-js/releases gives you the model_weights.buf and model_metadata.json files. I got no errors this time.
@kvue , keras.js v3, worked for me. Thanks
@kvue Also worked for me ! much appreciated. You know also when downloading the project from https://github.com/transcranial/keras-js/releases the hierarchy of files is different for example the "encoder.py" is in the root.
The releases encoder.py file also works for me! Thanks
Thanks for pointing to the right solution!!