PyTorch 2 · Training and saving

Load a model

Create the model, then load the saved weights.

model = Net()
model.load_state_dict(torch.load("model.pt", weights_only=True))
model.eval()

Official PyTorch 2 documentation

More training and saving commands

All training and saving commands · PyTorch 2 cheatsheet

Was this page helpful?