Keras3 and Qkeras3 Conversion to QONNX
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 ).
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
printstatements inqkeras/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)
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.