Skip to content

Support for Keras v3 file format #831

@vloncar

Description

@vloncar

Prerequisites

Keras has introduced a new file format called "Keras v3" in recent versions of TF (2.13 or 2.12, I don't remember), that is now preferred over the h5 and the SavedModel formats. This is part of a wider set of changes coming in Keras v3 that will come out later this year and become the version TF uses internally.

Details

The new format uses the extension .keras and it seems to be a zip archive of 3 components: the model json, the model metadata (versions of tools) and the weights in the familiar h5 format.

New behavior

With this change, hls4ml will be compatible with the latest version of TF andthe ecosystem will widen quite a bit.

Motivation

Keras v3 will be a major milestone and that will reintroduce support for additional backends, namely PyTorch and Jax. More here.

Parts of hls4ml being affected

The Keras converter will have to be extended. Should be a low impact on the existing codebase, since we will have to extract the JSON config and the h5 of the weights from the .keras file and proceed with the parse as before. The format of the JSON has changed slightly, but the attributes of the layer config (obtained with Layer.get_config()) remain the same or have useful extra features (like shape info), meaning all handlers should work unmodified. We will only need to extract the class name differently (it is now called "module") and optionally use the new information from the layer config.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions