Showing results for 
Search instead for 
Did you mean: 

How can I use QKeras models with X-Cube-AI?




I am trying to use a QKeras model with mixed precision on STM32H747I-DISCO board. I run ‘Analyze’ my QKeras model using stmai 8.1.0, but encountered the following error. I tried an old version of QKeras, but got a different error.


I would appreciate any help on how to solve this issue?

Thanks in advance!


------------- error ------------- 

>>> stm32ai validate --model model_test.h5 --allocate-inputs --allocate-outputs --relocatable --compression none --optimization balanced --name network --workspace workspace --output output

Neural Network Tools for STM32 family v1.7.0 ( v8.1.0-19520)

E010(InvalidModelError): Couldn't load Keras model model_test.h5,

error: Error when deserializing class 'QBatchNormalization' using config={'name': 'bn_0', 'trainable': True, 'dtype': 'float32', 'axis': [3], 'momentum': 0.99, 'epsilon': 0.001, 'center': True, 'scale': True, 'beta_initializer': {'class_name': 'Zeros', 'config': {}, 'shared_object_id': 6}, 'gamma_initializer': {'class_name': 'Ones', 'config': {}, 'shared_object_id': 7}, 'moving_mean_initializer': {'class_name': 'Zeros', 'config': {}, 'shared_object_id': 8}, 'moving_variance_initializer': {'class_name': 'Ones', 'config': {}, 'shared_object_id': 9}, 'beta_regularizer': None, 'gamma_regularizer': None, 'beta_constraint': None, 'gamma_constraint': None, 'beta_quantizer': None, 'gamma_quantizer': None, 'mean_quantizer': None, 'variance_quantizer': None, 'inverse_quantizer': None, 'beta_range': None, 'gamma_range': None}.

Exception encountered: ('Keyword argument not understood:', 'inverse_quantizer')

ST Employee

Can you share your model (even with fake weights) so we can try to fix the issue



Thank you for your reply. I tested with the model I got from the notebook that QKeras provides as a tutorial. I added the code to get a trained model. but when I run ‘Analyze’, I encountered an error. So I will attach the notebook file as well.