cancel
Showing results for 
Search instead for 
Did you mean: 

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

erectbranch
Associate

Hi,

 

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 (stm.ai 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')

2 REPLIES 2
fauvarque.daniel
ST Employee

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

Regards

Daniel


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

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 qmodel.save(model_test.h5) to get a trained model. but when I run ‘Analyze’, I encountered an error. So I will attach the notebook file as well.