Import pretrained ONNX network
imports a pretrained network from the ONNX™ (Open Neural Network Exchange) file net
= importONNXNetwork(modelfile
,'OutputLayerType',outputtype
)modelfile
and specifies
the output layer type of the imported network.
This function requires the Deep Learning Toolbox™ Converter for ONNX Model Format support package. If this support package is not installed, then the function provides a download link.
additionally specifies the classes for a classification network.net
= importONNXNetwork(modelfile
,'OutputLayerType',outputtype
,'Classes',classes
)
importONNXNetwork
supports ONNX versions as follows:
The function supports ONNX intermediate representation version 6.
The function fully supports ONNX operator sets 6, 7, 8, and 9.
The function offers limited support for ONNX operator sets 10 and 11.
Note
If you import an exported network, layers of the reimported network might differ from the original network and might not be supported.
If the ONNX network contains a layer that Deep Learning Toolbox Converter for ONNX Model Format does not support (see Supported ONNX Layers), then
importONNXNetwork
returns an error message. In this case, you can still
use importONNXLayers
to import the network architecture and weights.
You can import an ONNX network with multiple inputs and a single output using
importONNXNetwork
. If the network has multiple outputs, use
importONNXLayers
. The importONNXLayers
function
inserts placeholder layers for the outputs. After importing, you can find and replace
the placeholder layers by using findPlaceholderLayers
and replaceLayer
,
respectively. For an example, see Import and Assemble ONNX Network with Multiple Outputs. To learn about a deep
learning network with multiple inputs and multiple outputs, see Multiple-Input and Multiple-Output Networks.
To use a pretrained network for prediction or transfer learning on new images, you must preprocess your images in the same way the images that were used to train the imported model were preprocessed. The most common preprocessing steps are resizing images, subtracting image average values, and converting the images from BGR images to RGB.
For more information on preprocessing images for training and prediction, see Preprocess Images for Deep Learning.
exportONNXNetwork
| importCaffeLayers
| importCaffeNetwork
| importKerasLayers
| importKerasNetwork
| importONNXFunction
| importONNXLayers
| importTensorFlowLayers
| importTensorFlowNetwork