小编sar*_*ara的帖子

pytorch 模型 -> onnx -> 张量流

我为机器学习制作了 pytorch 模型,我想将其转换为张量流模型。我想我将 pytorch 模型转换为 onnx。所以现在我想将onnx转换为tensorflow(pb)模型。

这是我的代码。

import onnx
from onnx_tf.backend import prepare
onnx_model = onnx.load("./sales_predict_model.onnx")  # load onnx model
tf_rep = prepare(onnx_model)  # prepare tf representation
tf_rep.export_graph("sales_predict_model.pb")  # export the model
Run Code Online (Sandbox Code Playgroud)

我在这里遇到了错误。

AssertionError: Tried to export a function which references untracked object Tensor("1076:0", shape=(), dtype=resource)`.
TensorFlow objects (e.g. `tf.Variable`) captured by functions must be tracked by assigning them to an attribute of a tracked object or assigned to an attribute of the main object directly.
Run Code Online (Sandbox Code Playgroud)

我使用的是 TensorFlow 版本 1.14.0。 …

machine-learning tensorflow pytorch onnx

5
推荐指数
0
解决办法
1921
查看次数

标签 统计

machine-learning ×1

onnx ×1

pytorch ×1

tensorflow ×1