当前位置:网站首页>关于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)
边栏推荐
猜你喜欢

3D 语义分割——2DPASS

完全二叉树问题

(PC+WAP)织梦模板螺钉手柄类网站

(PC+WAP)织梦模板不锈钢类网站

Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!

Unity 截取3D图像 与 画中画PIP的实现

complete binary tree problem

CAS: 178744-28-0, mPEG-DSPE, DSPE-mPEG, methoxy-polyethylene glycol-phosphatidylethanolamine supply

Jmeter-参数化

jav一键生成数据库文档
随机推荐
internship:编写excel表的上传方法(导入)
Why Flutter Flutter of tutorials is the best choice for business?
Kotlin - 扩展函数和运算符重载
2022/8/3 Exam Summary
C语言实验十四 结构体
使用unbound在RHEL7上搭建DNS服务
rosbridge-WSL2 && carla-win11
ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
一文搞定 SQL Server 执行计划
redis持久化方式
Create function report error, prompting DECLARE definition syntax problem
Super perfect version of the layout have shortcut, background replacement (solve the problem of opencv Chinese path)
RSS feeds WeChat public - feed43 asain
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
[RYU] rest_router.py source code analysis
JS获得URL超链接的参数值
【职场杂谈】售前与销售工作配合探讨
响应式织梦模板塑身瑜伽类网站
雅思大作文写作模版
FinClip, help smart TV more imagination