Infineon / mtb-example-ml-profiler

This code example demonstrates how to run through the ModusToolbox Machine Learning (MTB-ML) development flow with PSoC 6 MCU, where the end user has a pre-trained Neural Network (NN) model, which can be profiled and validated at the PC and target device.
Other
0 stars 2 forks source link

RuntimeError: tensorflow/lite/kernels/conv.cc:346 input->dims->size != 4 (3 != 4)Node number 0 (CONV_2D) failed to prepare. #3

Open dhruvil1607 opened 11 months ago

dhruvil1607 commented 11 months ago

Prerequisites A H5 file of a pretrained model with input shape float32[?,128,6,1] and a Model calipbration file with shape int64[155,4] is passed in Ml configurator to generate source.

Description: The Model is being Load successfully but the optimization file is not generated due the below reasons. **RuntimeError: tensorflow/lite/kernels/conv.cc:346 input->dims->size != 4 (3 != 4)Node number 0 (CONV_2D) failed to prepare.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "parse_model.py", line 259, in load_tflite_model_from_h5 File "keras_converter\keras_to_tflite_converter.py", line 154, in keras_to_tflite_converter Exception**

Steps to Reproduce:

1.Open MTB > choose CYSBSYKIT-01

2.In Machine Learning Pack select NN Profiler

3.From Quick Pannel Open ML Configurator

  1. Attach the pretrained_NN model and in Model Calibartioon a NPZ file.

Expected Result: A tflite model in mtb_ml_gen dir

Actual Result: RuntimeError: tensorflow/lite/kernels/conv.cc:346 input->dims->size != 4 (3 != 4)Node number 0 (CONV_2D) failed to prepare.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "parse_model.py", line 259, in load_tflite_model_from_h5 File "keras_converter\keras_to_tflite_converter.py", line 154, in keras_to_tflite_converter Exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "ml-coretools.py", line 167, in deploy File "deploy_script.py", line 66, in deploy_script File "parse_model.py", line 121, in init File "parse_model.py", line 269, in load_tflite_model_from_h5 Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "ml-coretools.py", line 287, in File "click\core.py", line 1130, in call File "click\core.py", line 1055, in main File "click\core.py", line 1657, in invoke File "click\core.py", line 1404, in invoke File "click\core.py", line 760, in invoke File "click\decorators.py", line 26, in new_func File "ml-coretools.py", line 176, in deploy Exception [25752] Failed to execute script 'ml-coretools' due to unhandled exception!

Target: CYSBSYKIT-01 Host OS and Version:

Windows 11

Compiler:

GNU compiler

Environment

Eclipse IDE in MTB

THANKS!
lossio commented 8 months ago

Hello,

Thanks for your interest in our ML code example.

When using calibration data, the dimensions must match between your input model and the dataset. Based on the error message, that's not the case. Typically, you can use your test or training data as calibration data. The data type shall also match. In your case, I see the model uses float32, but your calibration data is int64.

(PS: I don't see any attachment to this issue. Reading your post, it seems you attempted to attach the model and calibration data?)