Saving a Flux ML model in a keras compatible format

Hey everyone,

I am now using Flux to train my model and the goal is to exploit these models in fortran. So far I have seen that there is a fortran library that is called neural-fortran that enables to use a neural network in fortran, but it loads models saved in the keras HDF5 format. Would there be a way to save Flux models into keras HDF5 files or would there be any documentation on the formats? So far I have looked on the internet to find solutions, but didn’t come across one.

Thank you so much for your answers!

Not that I know of. tf.keras.Model  |  TensorFlow v2.14.0 has a bit but your best bet may be to do some poking around in example saved weights.

In general, this process will have to be mostly manual translation since the Keras HDF5 format doesn’t appear to provide much info on layer structure. GitHub - FluxML/Functors.jl: Parameterise all the things and GitHub - FluxML/Optimisers.jl: Optimisers.jl defines many standard optimisers and utilities for learning loops. can help you save some boilerplate on that translation code. Although it’s converting in the other direction, you may also be able to gain some inspiration from the scripts in