-
Notifications
You must be signed in to change notification settings - Fork 1
MNIST computation do not give the good result. #2
Comments
This comment has been minimized.
This comment has been minimized.
I have tried the mnist example with caffe2 from the docker image:
then run this script: import numpy as np
import onnx
import os
import glob
import caffe2.python.onnx.backend as backend
from onnx import numpy_helper
model = onnx.load('model.onnx')
test_data_dir = 'test_data_set_0'
# Load inputs
inputs = []
inputs_num = len(glob.glob(os.path.join(test_data_dir, 'input_*.pb')))
for i in range(inputs_num):
input_file = os.path.join(test_data_dir, 'input_{}.pb'.format(i))
tensor = onnx.TensorProto()
with open(input_file, 'rb') as f:
tensor.ParseFromString(f.read())
inputs.append(numpy_helper.to_array(tensor))
# Load reference outputs
ref_outputs = []
ref_outputs_num = len(glob.glob(os.path.join(test_data_dir, 'output_*.pb')))
for i in range(ref_outputs_num):
output_file = os.path.join(test_data_dir, 'output_{}.pb'.format(i))
tensor = onnx.TensorProto()
with open(output_file, 'rb') as f:
tensor.ParseFromString(f.read())
ref_outputs.append(numpy_helper.to_array(tensor))
# Run the model on the backend
outputs = list(backend.run_model(model, inputs))
# Compare the results with reference outputs.
for ref_o, o in zip(ref_outputs, outputs):
np.testing.assert_almost_equal(ref_o, o) which gives this result:
I think that I will raise an issue within the onnx model zoo |
I can now analyze the graph a bit better and it looks that a stupid Add operation is not working as expected. Here is a way to reproduce the behavior: First checkout gorgonnx and the version that holds the tracer:
Then download the MNIST example:
And then launch the graph: and point your browser to http://localhost:8080. On the graph, click on the nodes |
Bad news: I have tried to rewrite the parser and Gorgonia (see the branch "directed-graph"). So the problem does not come from the graph definition. It may be related to the computation phase of Gorgonia. |
The convolution operator now seems to run as expected (according its unit test).
I have two options for debugging:
The text was updated successfully, but these errors were encountered: