Skip to main content
wg_it
Associate II
May 11, 2023
Solved

I can train cifar10 data set with pytorch up to 80%? It's only 30 percent accurate on the CUBEAI desktop

  • May 11, 2023
  • 2 replies
  • 3014 views

..

    This topic has been closed for replies.
    Best answer by jean-michel.d

    Thanks for your data and models (and status). Effectively after analysis, I had detected an issue in cifar10_test_label.npy file where the one shot encoding representation was wrong (left-shift per one in the index). I dont't know if the "MCU_AI-masterCIFAR10etinynet_epoch272_params.oonx" model was correctly trained but with the provided data, I had a bad accuracy using directly the onnx file (outside X-CUBE-AI). Idem with "CIFAR10mobilenetSlim_quant_static.onnx" file.

    However, I have noted that the model has been quantized with the option "per_channel=False", it is recommended to use "per_channel=True" to have a better precision.

    br,

    Jean-Michel

    2 replies

    ST Employee
    May 11, 2023

    Hello,

    To compute the accuracy with CUBEAI desktop, you provide your own data or you use the random data?

    Exported ONNX model (from Pytorch) is quantized or not?

    Regards,

    Jean-Michel

    wg_it
    wg_itAuthor
    Associate II
    May 12, 2023

    Thank you very much for your answer. I used self-generated data, and the model didn't quantify it. Here is my model and the data

    wg_it
    wg_itAuthor
    Associate II
    May 12, 2023

    Here is my model and the data

    jean-michel.dBest answer
    ST Employee
    May 15, 2023

    Thanks for your data and models (and status). Effectively after analysis, I had detected an issue in cifar10_test_label.npy file where the one shot encoding representation was wrong (left-shift per one in the index). I dont't know if the "MCU_AI-masterCIFAR10etinynet_epoch272_params.oonx" model was correctly trained but with the provided data, I had a bad accuracy using directly the onnx file (outside X-CUBE-AI). Idem with "CIFAR10mobilenetSlim_quant_static.onnx" file.

    However, I have noted that the model has been quantized with the option "per_channel=False", it is recommended to use "per_channel=True" to have a better precision.

    br,

    Jean-Michel

    wg_it
    wg_itAuthor
    Associate II
    May 15, 2023

    Thank you very much for your answer, I found the problem. I did not perform the same transform as in the training process when generating npy data, nor did I perform the same data transform when generating calibration data in the static quantization process. So it's very low precision.

    I would like to know how to modify the code if I want to add the camera to collect images for target detection in the future. The generated code seems a little difficult to read, is there any demo you can refer to? I use stm32f746G-discovery.