onnx / tutorials

Tutorials for creating and using ONNX models
Apache License 2.0
3.34k stars 626 forks source link

Negative values when making inference on notebook PytorchTensorflowMnist.ipynb #262

Open handreyeg opened 2 years ago

handreyeg commented 2 years ago

I'm using the PytorchTensorflowMnist.ipynb notebook available here.

When I run the code below, the prediction is right (the number in the image is 2), but shouldn't the output variable be the precision value? If it's the precision value, why is it negative? Or what output variable represents and how can I get the precision value?

img = Image.open('assets/two.png').resize((28, 28)).convert('L') 
display(img)
output = tf_rep.run(np.asarray(img, dtype=np.float32)[np.newaxis, np.newaxis, :, :])
print('The digit is classified as ', np.argmax(output))
print(output._0)

The output of the code above is

The digit is classified as 2
[[-697.756   -923.469   0.   -448.76907   -864.5122   -835.3161   -455.5511   -717.3065   -596.7475   -544.3611 ]]

Any help would be appreciated, thanks.