이 제출물을 팔로우합니다
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다
The converter for PyTorch models enables you to import pretrained PyTorch models and weights into MATLAB.
Limitation: the importNetworkFromPyTorch function fully supports PyTorch version 2.0. The function can import most models created in other PyTorch versions (1.10 to 2.0).
Note: the model must be traced in PyTorch before importing into MATLAB. See below for an example:
# This example loads a pretrained PyTorch model from torchvision,
# traces it with example inputs, and saves the trace as a .pt file.
import torch
from torchvision import models
# Load the model with pretrained weights
model = models.mobilenet_v2(pretrained=True)
# Call "eval" to ensure that layers like batch norm and dropout are set to
# inference mode
model.eval()
# Move the model to the CPU
model.to("cpu")
# Create example inputs
X = torch.rand(1, 3, 224, 224)
# Trace model with the example input
traced_model = torch.jit.trace(model.forward, X)
# Save the traced model to a .pt file
traced_model.save('traced_mobilenetv2.pt')
The initial release in R2022b supports importing image classification models. Support for other model types will be added in future updates.
MATLAB 릴리스 호환 정보
- R2022b에서 R2026b까지의 릴리스와 호환
플랫폼 호환성
- Windows
- macOS (Apple Silicon)
- macOS (Intel)
- Linux
