当前位置:网站首页>关于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)
边栏推荐
- Walk the Maze BFS
- 七夕活动浪漫上线,别让网络拖慢和小姐姐的开黑时间
- 密码学基础以及完整加密通讯过程解析
- jav一键生成数据库文档
- 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
- libnet
- Flutter教程之为什么 Flutter 是创业的最佳选择?
- The Chinese Valentine's Day event is romantically launched, don't let the Internet slow down and miss the dark time
- 【论文阅读】TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve
- 使用tf.image.resize() 和tf.image.resize_with_pad()调整图像大小
猜你喜欢
随机推荐
The super perfect layout has shortcut keys and background replacement
Walk the Maze BFS
响应式织梦模板除尘器类网站
智能管理PoE交换机
ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
代码重构:面向单元测试
RSS订阅微信公众号初探-feed43
3D Semantic Segmentation - 2DPASS
密码学基础以及完整加密通讯过程解析
超级完美版布局有快捷键,有背景置换
Unity2021发布WebGL雾效消失问题
Redis persistence method
[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve
Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!
LeetCode 0155. 最小栈
响应式织梦模板餐饮酒店类网站
七夕活动浪漫上线,别让网络拖慢和小姐姐的开黑时间
Binary search tree to solve the fallen leaves problem
Jmeter-参数化
绕任意轴旋转矩阵推导









