Export network to ONNX model format
Export a trained Neural Network Toolbox™ deep learning network to the ONNX™ (Open Neural Network Exchange) model format . You can then import the ONNX model to other deep learning frameworks, such as TensorFlow®, that support ONNX model import. This function requires the Neural Network Toolbox Converter for ONNX Model Format support package. To download and install the support package, use the Add-On Explorer. You can also download the support package from MathWorks Neural Network Toolbox Team.
Download and install the Neural Network Toolbox Converter for ONNX Model Format support package using the Add-On Explorer. You can also download the support package from MathWorks Neural Network Toolbox Team.
Load a pretrained SqueezeNet convolutional neural network.
net = squeezenet
net = DAGNetwork with properties: Layers: [68×1 nnet.cnn.layer.Layer] Connections: [75×2 table]
Export the network to an ONNX format file
squeezenet.onnx in the current folder.
filename = 'squeezenet.onnx'; exportONNXNetwork(net,filename)
You can now import the
squeezenet.onnx file to another deep
learning framework that supports import from ONNX. You can also visualize the ONNX model structure in Python®
filename— Name of file
Name of file, specified as a character vector or string.
netName— Name of ONNX network
'Network'(default) | character vector | string
Name of ONNX network to store in the saved file, specified as a character vector or string.
exportONNXNetwork does not export settings or properties related to
network training such as training options, learning rate factors, or regularization
If the network that you want to export contains a layer that the ONNX format does not support, then
exportONNXNetwork saves a placeholder ONNX operator in place of the unsupported layer and returns a warning. It
is not possible to import the ONNX model to other deep learning frameworks, but you can
still visualize the model structure in Python
exportONNXNetwork does not support networks containing recurrent layers
such as LSTM or BiLSTM layers.
 Open Neural Network Exchange. https://github.com/onnx/
 ONNX. https://onnx.ai/
 Visualizing an ONNX Model. https://github.com/onnx/tutorials/blob/master/tutorials/VisualizingAModel.md