Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNN结果和onnx结果不一致,mnn结果错误 #3097

Open
gtfaiwxm opened this issue Nov 22, 2024 · 0 comments
Open

MNN结果和onnx结果不一致,mnn结果错误 #3097

gtfaiwxm opened this issue Nov 22, 2024 · 0 comments

Comments

@gtfaiwxm
Copy link

平台(如果交叉编译请再附上交叉编译目标平台):

Ubuntu22.04
原始模型是2分类模型
mnn推理代码:
def inference(model_path, input_format, input_data):

interpreter = MNN.Interpreter(model_path)
session = interpreter.createSession()
input_tensor = interpreter.getSessionInput(session)

tmp_input = MNN.Tensor(input_format, MNN.Halide_Type_Float, np.float32(input_data), MNN.Tensor_DimensionType_Caffe)
input_tensor.copyFrom(tmp_input)
interpreter.runSession(session)
# interpreter.runSessionWithCallBackInfo(session, begin_callback, end_callback)


output_tensor = interpreter.getSessionOutput(session)       # 获得模型的输出
# out_put_1 = interpreter.getSessionOutput(session,"/bneck/bneck.3/act3/Mul_output_0")
# print(out_put_1)

tmp_output = MNN.Tensor((2),                   # 用来做输出的临时变量
                        MNN.Halide_Type_Float, 
                        np.ones([2]).astype(np.float32), 
                        MNN.Tensor_DimensionType_Caffe)
output_tensor.copyToHostTensor(tmp_output)                  # 将模型的输出给 tmp_output 变量
x = tmp_output.getNumpyData() 

输出结果:
[4.1752697e-38 0.0000000e+00]
mnn的结果基本上都为0
onnx的输出结果:
[ 1.1735201 -0.9136288],onnx的结果正确
onnx和mnn模型的输入已经确定是一致的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant