tensorflow - 如何正确使用 tf-coreml?
问题描述
我想将 tensorflow 模型(https://github.com/vanhuyz/CycleGAN-TensorFlow)转换为 coreml 模型,以便能够在 iOS 上导入它。
我知道要执行转换,使用这段代码就足够了:
import tfcoreml as tf_converter
tf_converter.convert(tf_model_path = 'my_model.pb',
mlmodel_path = 'my_model.mlmodel',
output_feature_names = ['softmax:0'])
但我不知道在第三个参数“output_feature_names”中放什么。有什么想法?
解决方案
如果您使用Netron打开 .pb 文件并一直滚动到底部,您会看到最后一层是 EncodeJpeg,因此输出特征名称将是EncodeJpeg:0
.
但是,Core ML 没有“encode jpeg”操作,因此您无法转换整个图形。您需要找到 Core ML 仍然支持的最后一个张量。
我会尝试output_feature_names=["G_7/output/Tanh:0"]
,但很可能图中还有其他无法转换的东西。
推荐阅读
- oracle - APEX ORACLE - 将多个参数插入到从顶点到数据库表的多个列中
- python - Python 检查嵌套 JSON 键值是否存在
- django - Django 翻译解析顺序
- robotframework - 是否可以覆盖机器人中的列表变量?
- python - pymysql.err.InternalError:(1327,'未声明的变量:无')
- clojure - 如何有条件地生成打嗝结构?
- javascript - 如何使用 Redux 商店中的 useState 挂钩设置初始值?
- css - CSS宽度自动在自动换行后添加unwated空间
- r - 对列表元素应用过滤功能
- python - 根据值选择多行和多列