cancel
Showing results for 
Search instead for 
Did you mean: 

While analyzing the model with STM32 AI (GUI), confronted a "TOOL ERROR: (1, 4, 12, 10) is not a permutation for (2, 0, 1)"

HKim.16.78
Associate II

I confronted an error "TOOL ERROR:  (1, 4, 12, 10) is not a permutation for (2, 0, 1)"

It seems there's some issues with handling the model structure. But I can't figure it out.

The model perfectly works on python and the structure is not so different from models which had been successfully imported to the my board (NUCLEO-L452RE)

The tool version is X-CUBE-AI 5.1.2 and I'm using the STM32CubeMX GUI.

The model has the structure shown below (checked by model.summary())

_________________________________________________________________

Layer (type) Output Shape Param #

=================================================================

input_8 (InputLayer) [(None, 36, 100, 1)] 0

_________________________________________________________________

conv2d_16 (Conv2D) (None, 36, 100, 5) 130

_________________________________________________________________

average_pooling2d_5 (Average (None, 9, 25, 5) 0

_________________________________________________________________

re_lu_14 (ReLU) (None, 9, 25, 5) 0

_________________________________________________________________

conv2d_17 (Conv2D) (None, 9, 25, 10) 1260

_________________________________________________________________

max_pooling2d_9 (MaxPooling2 (None, 4, 12, 10) 0

_________________________________________________________________

re_lu_15 (ReLU) (None, 4, 12, 10) 0

_________________________________________________________________

flatten_1 (Flatten) (None, 480) 0

_________________________________________________________________

dense_5 (Dense) (None, 6) 2886

_________________________________________________________________

softmax_1 (Softmax) (None, 6) 0

=================================================================

Total params: 4,276

Trainable params: 4,276

Non-trainable params: 0

_________________________________________________________________

The structure shown below is successfully anaylized.

------------------------------------------------------------------------------------------------------------------------ 

id  layer (type)        output shape      param #     connected to             macc           rom                 

------------------------------------------------------------------------------------------------------------------------ 

0   input_2 (Input)     (16, 100, 1)                                                                              

    conv2d_0 (Conv2D)   (16, 100, 5)      130         input_2                  208,005        520                 

------------------------------------------------------------------------------------------------------------------------ 

1   pool_1 (Pool)       (4, 25, 5)                    conv2d_0                                                    

    nl_1 (Nonlinearity) (4, 25, 5)                    pool_1                   500                                

------------------------------------------------------------------------------------------------------------------------ 

2   conv2d_2 (Conv2D)   (4, 25, 10)       1,260       nl_1                     125,970        5,040               

------------------------------------------------------------------------------------------------------------------------ 

3   pool_3 (Pool)       (2, 12, 10)                   conv2d_2                                                    

    nl_3 (Nonlinearity) (2, 12, 10)                   pool_3                   240                                

------------------------------------------------------------------------------------------------------------------------ 

4   conv2d_4 (Conv2D)   (2, 12, 6)        546         nl_3                     13,110         2,184               

------------------------------------------------------------------------------------------------------------------------ 

5   pool_5 (Pool)       (1, 1, 6)                     conv2d_4                                                    

------------------------------------------------------------------------------------------------------------------------ 

6   nl_6 (Nonlinearity) (1, 1, 6)                     pool_5                   90                                 

------------------------------------------------------------------------------------------------------------------------

1 ACCEPTED SOLUTION

Accepted Solutions
jean-michel.d
ST Employee

Hello HKim,

I suppose that you use a tflite model which has been converted from a Keras model in a TFensorFlow 2.2 or later environment. If you confirm, this issue is in a change of the behavior of TFLiteConverter (vs TF 1.15 or 2.0) which managed differently the conversion of the dense layer (including the flatten operator). Now a reshape tflite operator is systematically introduced. Unfortunately, in X-CUBE-AI 5.1.2, this change has not be fully fixed and with a 3-dim input shape, this error can appear. This issue is now fixed and will be delivery in the X-CUBE-AI 5.2.0 release.

Do you confirm my analysis about the usage of the TFLite model? If not, is it possible to have more details about the imported model, environment used to generate the model: Keras?, TFlite? Is it possible to share the model file imported in X-CUBE-AI?

br,

Jean-Michel

View solution in original post

2 REPLIES 2
jean-michel.d
ST Employee

Hello HKim,

I suppose that you use a tflite model which has been converted from a Keras model in a TFensorFlow 2.2 or later environment. If you confirm, this issue is in a change of the behavior of TFLiteConverter (vs TF 1.15 or 2.0) which managed differently the conversion of the dense layer (including the flatten operator). Now a reshape tflite operator is systematically introduced. Unfortunately, in X-CUBE-AI 5.1.2, this change has not be fully fixed and with a 3-dim input shape, this error can appear. This issue is now fixed and will be delivery in the X-CUBE-AI 5.2.0 release.

Do you confirm my analysis about the usage of the TFLite model? If not, is it possible to have more details about the imported model, environment used to generate the model: Keras?, TFlite? Is it possible to share the model file imported in X-CUBE-AI?

br,

Jean-Michel

Hello Mr. Jean-Michel

Thanks for your detailed explanation.

As you mentioned, my model was tflite model converted from Keras model using TFLiteConverter. But I'm not sure the issue had come from TFLiteConverter API. Anyway, I just checked this issue didn't appear in X-CUBE-AI version 5.2.0.

Best regards,

HKim.