How to convert a saved Keras .h5 file to csv file or .mat file?


#1

Hi all,

I trained a classifier model using keras then I saved the weights of the model in a H5 file and the architecture in Json file. I was wondering how can I convert the H5 file into any other file like .csv or .mat? And how can I load after that the model architecture with these files?
my code part is :
classifier.save_weights(‘model_weights.h5’)

Save the model architecture

with open(‘model_architecture.json’, ‘w’) as f:
f.write(classifier.to_json())


#2

I trained a classifier model using keras then I saved the weights of the model
in a H5 file and the architecture in Json file.

First of all, that’s very interesting… there’s an uptick of new folks in the community who are discovering HDF5 through keras. If you’re able to share, what’s your project about?

I was wondering how can I convert the H5 file into any other file like .csv or .mat?
And how can I load after that the model architecture with these files?

I’ll defer to others here on the specific question on HDF5 to CSV conversion, but I wanted to point out that MathWorks MATLAB natively supports HDF5, so no converstion necessary if you’re just trying to open in MATLAB. And of course, once you’re in MATLAB, you’ll have a number of options to export data in a variety of ways.

Hope this helps.

–Dave


#3

Thanks for the reply!

First of all, that’s very interesting… there’s an uptick of new folks in the community who are discovering HDF5 through keras. If you’re able to share, what’s your project about?

Actually I want to implement my classifier model in pynq board but there was a problem with the H5 file so I was trying to use another file version maybe it can solve the problem


#4

What’s the problem “with the H5 file”?


#5

When I tried to load the weights saved in the h5 file I get a message “kernel died”


#6

There should be a more informative message, but if you are using something like

jupyter with ipython stderr may be discarded. See %%capture in https://ipython.readthedocs.io/en/stable/interactive/magics.html