onnx / tutorials

Tutorials for creating and using ONNX models
Apache License 2.0
3.36k stars 629 forks source link

Export Pytorch to Onnx -> Dummy input? #158

Open echan00 opened 4 years ago

echan00 commented 4 years ago

I'm a little confused by what the dummy input should be in the documentation to export from Pytorch to Onnx?

Is this something I can determine from the Pytorch model's state_dict? https://gist.github.com/echan00/4154458473c4698c93d0597c617ff01a

glm-nchaverou commented 4 years ago

In case you have not found the answer (and for future readers who will stumbled upon this thread)

ONNX export from Pytorch is done by tracing the graph; that is, it executes the graph once with the dummy input it's given While excuting the graph, it keeps track of PyTorch operations executed and then converts each of those operations to ONNX format You could use key-value parameter verbose=True to write the output to the terminal screen while exporting. it gives the intermediate representation of the graph in ONNX

Source: PyTorch Deep Learning Hands-On - Sherin Thomas, Sudhanshu Passi