The input is not an image type, it is an m * n matrix

The input is not an image type, it is an m * n matrix, and the data is not an integer. Is there a specific explanation for the parameters passed in when using ksnn for conversion?

Hello @googleearth maybe you need to use

mtx = np.expand_dims(mtx, axis = -1)

mtx - can represent your matrix variable

By the way, KSNN at the moment does not support non-matrix inputs so they should have 2 dims at minimum and dims >= 2.

Hello, I have processed the input type as you suggested,but the result is incorrect.

This is my onnx model for Multiple linear regression(Y = w1X1 + w2X2 + w3X3 + b):
image

Convert txt to npy file(The content of the txt file is: 0.8, 0.3, 0.6)

python3 npy_input_generate.py 
--action tensor2npy  
--src-platform onnx 
--input-file input.txt 
--shape "1 3 1" 
--numpy-data-file input.npy

This is my convert command:(./data/dataset/dataset1.txt points to the path of input.npy)

./convert \
--model-name p_linear_multi --platform onnx  \
--model ../demo/model/p_linear_multi.onnx  \
--inputs input \
--input-size-list '1,3,1' \
--outputs output \
--mean-values '0 0 0 1' \
--quantized-dtype dynamic_fixed_point --qtype int8 \
--source-files ./data/dataset/dataset1.txt \
--kboard VIM3 --print-level 1

After successful conversion, execute nn_inference on the board. When the input is [0,0,1], the result on the PC is 8.96951, and the result on the VIM3 board is 2.375
————————————————————————————————————————————
So, where is the problem?

@Electr1 By the way, how can I view the parameters of the converted .nb model file?

@googleearth you will not be able to view the parameters of the .nb file, they are only the raw weights file of amlogic npu sdk format.

btw, your weights are converted into int8 weights by quantization from float32, maybe this is why your result is not matching.

@Electr1 How should I solve this problem? use int16? Can you provide a solution? Thank you!

btw, your weights are converted into int8 weights by quantization from float32, maybe this is why your result is not matching.

@googleearth KSNN will not be the most suitable way for your specific example.

Since it is very small, maybe you can run it on the CPU for full float capability.

Otherwise, for hardware accelerated methods, you can try using the GPU or NPU with tflite delegates provided.

For CPU & GPU usage.
https://docs.khadas.com/products/sbc/vim3/applications/armnn-tflite

For NPU usage.
https://docs.khadas.com/products/sbc/vim3/npu/vx-tflite

These should support your model as you need and can run with full float32 without loss of precision.

Cheers.