当前位置:网站首页>关于mnn模型输出的数据杂乱无章问题
关于mnn模型输出的数据杂乱无章问题
2022-08-03 23:45:00 【氵文大师】
这俩天顺便用了阿里的MNN:
https://github.com/alibaba/MNN
还挺好用的,就是不知道带有opencl后端的引擎怎么用Python API调用
我遇到一个小坑,输出的数据是这样杂乱无章的:
而不是这样的:
反复debug,发现:
原来是模型的输出不能直接 getData()
output_tensor = interpreter.getSessionOutput(session) # 获得模型的输出
tmp_output = MNN.Tensor((1, 2, 224, 224), # 用来做输出的临时变量
MNN.Halide_Type_Float,
np.ones([1, 2, 224, 224]).astype(np.float32),
MNN.Tensor_DimensionType_Caffe)
output_tensor.copyToHostTensor(tmp_output) # 将模型的输出给 tmp_output 变量
x = tmp_output.getNumpyData()[0] # 获取 numpy 格式的数据
这段代码没啥问题,但要把最后一行:
x = tmp_output.getNumpyData()[0] # 获取 numpy 格式的数据
替换为:
x = output_tensor.getNumpyData()[0] # 获取 numpy 格式的数据
就会变成杂乱无章的数据,可能是数据先行后列之类的出问题了??
他俩都是 MNN.Tensor 的数据类型
所以我感觉,MNN模型输出的Tensor,要先转化为对应的格式MNN.Tensor_DimensionType_Caffe,才能打印出来
或者说这一步就是转化数据格式的:
tmp_output = MNN.Tensor((1, 2, 224, 224), # 用来做输出的临时变量
MNN.Halide_Type_Float,
np.ones([1, 2, 224, 224]).astype(np.float32),
MNN.Tensor_DimensionType_Caffe)
边栏推荐
猜你喜欢

Prometheus监控Harbor(二进制版)

2021年数据泄露成本报告解读

689. 三个无重叠子数组的最大和

In V8 how arrays (with source code, picture and text easier to understand)

响应式织梦模板除尘器类网站

The principle and use of AOSP CameraLatencyHistogram

Fluorescein-PEG-CLS, cholesterol-polyethylene glycol-fluorescein scientific research reagent

【OpenCV图像处理】 图像拼接技术

简单了解下 TCP,学习握手和挥手以及各种状态到底是怎么样的

【MySQL —— 索引】
随机推荐
P1449 后缀表达式
Unity2021发布WebGL雾效消失问题
FinClip, help smart TV more imagination
YOLOv7改进之二十二:涨点神器——引入递归门控卷积(gnConv)
电子邮件安全或面临新威胁!
智能管理PoE交换机
ML's yellowbrick: A case of interpretability (threshold map) for LoR logistic regression model using yellowbrick based on whether Titanic was rescued or not based on the two-class prediction dataset
3D 语义分割——2DPASS
Binary search tree to solve the fallen leaves problem
Free自由协议系统开发
Scala basics [regular expressions, framework development principles]
Zilliz 2023 Fall Campus Recruitment Officially Launched!
最小化安装debian11
Software testing is seriously involution, how to improve your competitiveness?
The super perfect layout has shortcut keys and background replacement
Code Casual Recording Notes_Dynamic Programming_416 Segmentation and Subsetting
Unity intercepts 3D images and the implementation of picture-in-picture PIP
rosbridge-WSL2 && carla-win11
vscode插件设置——Golang开发环境配置
[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve