外部のプラットフォームからの事前学習済みのネットワーク
R2026b外部の深層学習プラットフォームから事前学習済みネットワークを利用するには、モデルをインポートするか、共同実行を使用して外部モデルの学習およびテストを行うかという 2 つの方法があります。可能な限り、モデルをインポートする方法が推奨されます。
Deep Learning Toolbox™ は、TensorFlow™ 2、TensorFlow-Keras、Keras 3、PyTorch®、ONNX™ (Open Neural Network Exchange) モデル形式、および Caffe からのニューラル ネットワークのインポートをサポートしています。ディープ ネットワーク デザイナー アプリを使用して対話形式でネットワークをインポートするか、コマンド ライン関数を使用してプログラムでインポートします。アプリは、インポートのプロセスを要約し、必要なアクションを強調表示するインポート レポートを生成します。詳細については、事前学習済みの深層ニューラル ネットワークとInteroperability Between Deep Learning Toolbox, TensorFlow, PyTorch, and ONNXを参照してください。
Deep Learning Toolbox のインポート関数を使用するには、特定のサポート パッケージが必要です。必要なサポート パッケージがインストールされていない場合、各関数によって、アドオン エクスプローラーの対応するサポート パッケージへのダウンロード リンクが表示されます。使用している MATLAB® のバージョンに対応する既定の場所にサポート パッケージをダウンロードしてください。サポート パッケージは直接ダウンロードすることも可能です。
importNetworkFromONNXには、Deep Learning Toolbox Converter for ONNX Model Format が必要です。サポート パッケージをダウンロードするには、https://www.mathworks.com/matlabcentral/fileexchange/67296-deep-learning-toolbox-converter-for-onnx-model-formatに移動します。importNetworkFromPyTorchには、Deep Learning Toolbox Converter for PyTorch Models が必要です。サポート パッケージをダウンロードするには、https://www.mathworks.com/matlabcentral/fileexchange/111925-deep-learning-toolbox-converter-for-pytorch-modelsに移動します。importNetworkFromTensorFlowおよびimportNetworkFromKerasには、Deep Learning Toolbox Converter for TensorFlow Models が必要です。サポート パッケージをダウンロードするには、https://www.mathworks.com/matlabcentral/fileexchange/64649-deep-learning-toolbox-converter-for-tensorflow-modelsに移動します。
MATLAB と外部の深層学習プラットフォームの間の相互運用
事前学習済みネットワークのインポートが不可能な場合は、共同実行を使用して外部モデルを実行できます。共同実行は、TensorFlow、ONNX、PyTorch、およびカスタム Python® モデルを含む、Python ベースのモデルでサポートされています。PyTorch モデルの場合、PyTorchModel オブジェクトを使用して MATLAB 内でモデルを直接実行できます。このオブジェクトは、MATLAB–Python インターフェイスを介して Python でモデルを実行するラッパーとして機能し、モデルのインポートを必要とせずに連携を可能にします。arrayToTorchTensor 関数と torchTensorToArray 関数を使用することで、MATLAB の数値配列と PyTorch テンソルの間の変換も可能です。
アプリ
| ディープ ネットワーク デザイナー | 深層学習ネットワークの設計と可視化 |
関数
オブジェクト
PyTorchModel | Reference to a PyTorch model for Python execution (R2026b 以降) |
トピック
インポート
- Use PyTorch and MATLAB for Deep Learning Workflows
Learn how to use PyTorch models with MATLAB and Simulink® for deep learning workflows. - Interoperability Between Deep Learning Toolbox, TensorFlow, PyTorch, and ONNX
Learn how to import networks from TensorFlow, Keras 3, PyTorch, and ONNX and use the imported networks for common Deep Learning Toolbox workflows. Learn how to export networks to TensorFlow and ONNX. - TensorFlow、PyTorch、および ONNX からモデルをインポートする際のヒント
TensorFlow、Keras、PyTorch、および ONNX から Deep Learning Toolbox ネットワークをインポートする際のヒント。 - ディープ ネットワーク デザイナーを使用した PyTorch モデルのインポート
この例では、ディープ ネットワーク デザイナー アプリを使用して、PyTorch® モデルを対話形式でインポートする方法を示します。 (R2023b 以降) - 事前学習済みの深層ニューラル ネットワーク
分類、転移学習、特徴抽出用の事前学習済みの畳み込みニューラル ネットワークのダウンロード方法と使用方法を学習します。 - Inference Comparison Between TensorFlow and Imported Networks for Image Classification
Perform prediction in TensorFlow with a pretrained network, import the network into MATLAB usingimportTensorFlowNetwork, and then compare inference results between TensorFlow and MATLAB networks. - Inference Comparison Between ONNX and Imported Networks for Image Classification
Perform prediction in ONNX with a pretrained network, import the network into MATLAB usingimportONNXNetwork, and then compare inference results between ONNX and MATLAB networks. - Classify Images in Simulink with Imported TensorFlow Network
Import a pretrained TensorFlow network usingimportTensorFlowNetwork, and then use the Predict block for image classification in Simulink. - Deploy Imported TensorFlow Model with MATLAB Compiler
Import third-party pretrained networks and deploy the networks using MATLAB Compiler™. - View Autogenerated Custom Layers Using Deep Network Designer
This example shows how to import a pretrained TensorFlow™ network and view the autogenerated layers in Deep Network Designer. - Verify Robustness of Imported ONNX Network
This example shows how to verify the adversarial robustness of an imported ONNX™ deep neural network. (R2024a 以降)
Simulink ブロックの Python 共同実行
- Classify Images Using TensorFlow Model Predict Block
Classify images using TensorFlow Model Predict block. - Classify Images Using ONNX Model Predict Block
Classify images using ONNX Model Predict block. - Classify Images Using PyTorch Model Predict Block
Classify images using PyTorch Model Predict block. - TensorFlow Model Predict ブロックを使用した応答の予測
TensorFlow Model Predict ブロックを使用して応答を予測する。 - ONNX Model Predict ブロックを使用した応答の予測
ONNX Model Predict ブロックを使用して応答を予測する。 - PyTorch Model Predict ブロックを使用した応答の予測
PyTorch Model Predict ブロックを使用して応答を予測する。 - Simulink でのカスタム Python モデルを使用した応答の予測 (Statistics and Machine Learning Toolbox)
この例では、Custom Python Model Predict (Statistics and Machine Learning Toolbox)ブロックを Simulink® での予測に使用する方法を示します。 - Set Up Python Environment for Deep Learning with PyTorch Workflows
Configure Python and install PyTorch for use with MATLAB deep learning workflows.
MATLAB コマンド ラインでの PyTorch 共同実行
- Offline Training and Testing of PyTorch Model for CSI Feedback Compression (5G Toolbox)
Train an autoencoder-based PyTorch neural network offline and test for CSI compression. (R2025a 以降)
カスタム層
- カスタム深層学習層の定義
カスタム深層学習層の定義方法を学習します。
関連情報
- https://www.mathworks.com/matlabcentral/fileexchange/67296-deep-learning-toolbox-converter-for-onnx-model-format
- https://www.mathworks.com/matlabcentral/fileexchange/64649-deep-learning-toolbox-converter-for-tensorflow-models
- https://www.mathworks.com/matlabcentral/fileexchange/111925-deep-learning-toolbox-converter-for-pytorch-models
- https://www.mathworks.com/matlabcentral/fileexchange/61735-deep-learning-toolbox-importer-for-caffe-models
