# Converting Flux pretrained models saved in .bson to .h5

**URL:** <https://discourse.julialang.org/t/converting-flux-pretrained-models-saved-in-bson-to-h5/96549>\
**Category:** New to Julia\
**Created:** [March 24, 2023, 8:51am UTC](https://discourse.julialang.org/t/converting-flux-pretrained-models-saved-in-bson-to-h5/96549 "2023-03-24T08:51:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gradureau](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gradureau](https://discourse.julialang.org/u/gradureau)\
**Post date:** [March 24, 2023, 8:51am UTC](https://discourse.julialang.org/t/converting-flux-pretrained-models-saved-in-bson-to-h5/96549/1 "2023-03-24T08:51:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [March 24, 2023, 3:14pm UTC](https://discourse.julialang.org/t/converting-flux-pretrained-models-saved-in-bson-to-h5/96549/2 "2023-03-24T15:14:27Z")

</div>

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.
