Keras H5 modele format documentation

Good morning,

My team and I have been working for over 3 years now on a deep learning framework for LabVIEW called HAIBAL. “Modified by moderator”
This framework, as its name suggests, allows you to run deep learning models under LabVIEW.
We have adopted the H5 format and we have even made our framework compatible with the importation of Keras H5 models.
I would now like to be able to save in H5 Keras to allow my users complete intercompatibility between our frameworks. My problem is that I can’t find anywhere the details of the structure and data format used by Keras for H5 files.

For the moment we have just done some reverse engineering to be able to read the H5 Keras and convert them into our format.

Where can you find this H5 Keras documentation? Today we do not have all the parameters per layer offered by Keras and we can offer parameters that are specific to us but I would like to be able to save my models in H5 Keras with the parameters common to our framework. My problem is knowing the exact formatting layer by layer and the arrangement of parameters.

Thanks for your help,

“Modified by moderator”


Hi @Youssef_Menjour, When we save the model in h5, the h5 file contains the model weights and architecture. The weights are stored in a binary format, while the architecture is stored in a JSON.
H5 files are organized into groups, which are similar to folders. Groups can contain datasets or other groups info, forming a hierarchical structure.

To get the group names you can use:

import h5py

file_path = 'mnist.h5'

with h5py.File(file_path, 'r') as file:
    all_keys = list(file.keys())

    print("All keys in the H5 file:", all_keys)

    for key in all_keys:
        print(f"Key: {key}")
        value = file[key]
        if isinstance(value, h5py.Group):
            print("Subkeys:", list(value.keys()))
All keys in the H5 file: ['model_weights', 'optimizer_weights']
Key: model_weights
Subkeys: ['conv2d', 'conv2d_1', 'dense', 'dropout', 'global_average_pooling2d', 'max_pooling2d', 'max_pooling2d_1', 'top_level_model_weights']
Key: optimizer_weights
Subkeys: ['Adam', 'iteration:0']

Thank You.