I am trying to convert a frozen graph of a resnet-50 model to onnx model and then to tensorRT. I want to make sure the floating point precision at each conversion.
Asked
Active
Viewed 440 times
-1
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Sep 11 '21 at 19:11
1 Answers
1
Suppose you are passing an image x to the model like model(x) or model.forward(x), then you can check the datatype of x. You can use dtype property to get the type of a tensorflow variable.
> x = tf.Variable(tf.random_normal([256, 100]))
> x.dtype
<dtype: 'float32_ref'>
You can use as_numpy_dtype property of dtype to convert from tf.dtype to numpy dtype.
> x = tf.Variable(tf.random_normal([256, 100]))
> x.dtype.as_numpy_dtype
<class 'numpy.float32'>
For Onnx, you can import the onnx/graphsurgeon library to perform various operations. But the easiest way would be to use netron.
- pip install netron
- open https://localhost:8080
- Click the input node
- The information panel on the right would give a lot of information including data-type.

romil
- 68
- 1
- 8