Converting Flux pretrained models saved in .bson to .h5

Hello everyone,

I have seen on the Flux page that one can save Flux pretrained neural models in .bson files quite easily.
Yet, I want to use these models in a fortran code and so far the most pertinent ways to do this seems to be using fortran codes such as neural-fortran or FKB that enable to import neural networks saved in a HDF5 format, that would be generated when saving pretrained models with keras.

Is there a way to save Julia’s Flux pretrained models in the same format as keras?

Thank you for your answers
Gonzague Radureau

There are plenty of Julia libraries which let you serialize values to HDF5. HDF5.jl and JLD2.jl are the most popular, I believe. The problem you’ll run into is not how to convert to HDF5, but that libraries like Keras impose their own structure/schema on top of HDF5. I don’t think it’d be too difficult to match the Keras h5 structure (no idea about the Fortran libraries mentioned), but it would require almost 100% manual translation on your end.

1 Like