image thumbnail

Deep Learning Toolbox Converter for ONNX Model Format

Import and export ONNX™ models within MATLAB for interoperability with other deep learning frameworks

2.6K 次下载

更新时间 2022/6/11

Import and export ONNX™ (Open Neural Network Exchange) models within MATLAB for interoperability with other deep learning frameworks. ONNX enables models to be trained in one framework and transferred to another for inference.

Opening the onnxconverter.mlpkginstall file from your operating system or from within MATLAB will initiate the installation process for the release you have.
This mlpkginstall file is functional for R2018a and beyond.

Usage example:
%% Export to ONNX model format
net = squeezenet; % Pretrained Model to be exported
filename = 'squeezenet.onnx';
exportONNXNetwork(net,filename);

%% Import the network that was exported
net2 = importONNXNetwork('squeezenet.onnx', 'OutputLayerType', 'classification');

% Compare the predictions of the two networks on a random input image
img = rand(net.Layers(1).InputSize);
y = predict(net, img);
y2 = predict(net2,img);

max(abs(y-y2))

To import an ONNX network in MATLAB, please refer:
https://www.mathworks.com/help/deeplearning/ref/importonnxnetwork.html

To export an ONNX network from MATLAB, please refer:
https://www.mathworks.com/help/nnet/ref/exportonnxnetwork.html

MATLAB 版本兼容性
创建方式 R2018a
兼容 R2018a 到 R2022a 的版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!