【发布时间】:2021-09-07 04:56:14
【问题描述】:
我正在尝试将 resnet-50 模型的冻结图转换为 onnx 模型,然后再转换为 tensorRT。我想确保每次转换的浮点精度。
【问题讨论】:
-
请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。
标签: tensorflow onnx tensorrt
我正在尝试将 resnet-50 模型的冻结图转换为 onnx 模型,然后再转换为 tensorRT。我想确保每次转换的浮点精度。
【问题讨论】:
标签: tensorflow onnx tensorrt
假设您将图像 x 传递给 model(x) 或 model.forward(x) 等模型,那么您可以检查 x 的数据类型。 您可以使用 dtype 属性来获取 tensorflow 变量的类型。
> x = tf.Variable(tf.random_normal([256, 100]))
> x.dtype
<dtype: 'float32_ref'>
您可以使用 dtype 的 as_numpy_dtype 属性将 tf.dtype 转换为 numpy dtype。
> x = tf.Variable(tf.random_normal([256, 100]))
> x.dtype.as_numpy_dtype
<class 'numpy.float32'>
对于 Onnx,您可以导入 onnx/graphsurgeon 库来执行各种操作。但最简单的方法是使用netron。
【讨论】: