majianjia / nnom

A higher-level Neural Network library for microcontrollers.
Apache License 2.0
820 stars 235 forks source link

Deploying a 2D Convolutional Network from Keras #153

Open mengna0707 opened 2 years ago

mengna0707 commented 2 years ago

Hello, I found a convenient and efficient tool from the issues of CMSIS_5. I tried to use the conversion of 2D Convolutional Network weights mentioned in the nnom_utils.py file(https://github.com/majianjia/nnom/blob/87bc55e039713f60ac2716443b9c222c8db94cdd/scripts/nnom_utils.py#L150

For the Convolutional Layer: In Keras,the input's shape is(1,3,3,2), weight's shape is (3,3,2,4). Here is my converter statement.

transposed_input= input.transpose(2,1,0)  # reorder the input
transposed_wts= weight.transpose(3,0,1,2)   # reorder the weights 
transposed_bias=np.transpose(bias)  # reorder the bias

But I got the wrong result. Is there something wrong with my conversion mode? Any advice would be appreciated!