Skip to content

Conversation

@nfirle
Copy link

@nfirle nfirle commented Oct 18, 2025

This PR adds support for converting QKeras models built with Keras 3.
The internal naming scheme in Keras 3 has changed (e.g. added numerical suffixes to layer names), which previously caused quantizer name resolution to fail.

Main changes:

Extended quantizer name matching to handle Keras 3 naming patterns (using regex to match suffixes like _).

Added dynamic import for BaseQuantizer to support both old and new QKeras versions.

Updated Keras conversion tests to work with QKeras V3.

⚠️ Note: This functionality depends on the updated from_keras implementation in tf2onnx (PR #2398
).

@maltanar
Copy link
Collaborator

Thanks @nfirle . Couple of questions from me:

  • Will this break compatibility with the older versions? (Keras2/QKeras2) or will those still work?
  • There are some print statements in qkeras/onnx.py - if those are for debugging please remove/comment them out:
        match_keras3 = r"/" + re.escape(keras_name) + r"_\d+/"
        print("onnx:",onnx_name)
        print("keras:",keras_name)
        print("keras3:",match_keras3)

@nfirle
Copy link
Author

nfirle commented Oct 25, 2025

I have removed the print statements; I accidentally uploaded the wrong version. It remains compatible with the old version of keras2/qkeras2. However, it will only work once my pull request has been accepted by tf2onnx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants