Advanced level · Module 4: Deploying Deep Learning Models · Lesson 1 of 4
Exporting Models
Convert trained PyTorch models into portable formats for other runtimes.
In this lesson you will
- Export models with TorchScript and ONNX
- Verify exported models give the same results
Key concepts
TorchScriptONNXruntimeexport verification
The lesson
Training code is not deployment code. Exporting converts a model into a format that runs without the original Python training setup: TorchScript for PyTorch runtimes, ONNX for many runtimes and devices.
Export with an example input and check that the exported model gives the same outputs as the original on test images, within a tiny tolerance.
Record the export format, version and input requirements in the model's documentation.
Step by step
- Export the model to ONNX.
- Run it with ONNX Runtime.
- Compare outputs with the PyTorch model.
- Document the input format.
Practice activity
Export the project model and verify it.
Expected result: An exported model whose outputs match the original.
Check your understanding
-
Why export models for deployment?
Show answer
To run them without the training code and on other runtimes and devices.
-
How do you verify an export?
Show answer
Compare its outputs with the original model on test inputs.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.