diff --git a/beginner_source/blitz/autograd_tutorial.py b/beginner_source/blitz/autograd_tutorial.py index d2c3824021d..67336be7fa1 100644 --- a/beginner_source/blitz/autograd_tutorial.py +++ b/beginner_source/blitz/autograd_tutorial.py @@ -43,8 +43,9 @@ This tutorial work only on CPU and will not work on GPU (even if tensor are moved to CUDA). """ -import torch, torchvision -model = torchvision.models.resnet18(pretrained=True) +import torch +from torchvision.models import resnet18, ResNet18_Weights +model = resnet18(weights=ResNet18_Weights.DEFAULT) data = torch.rand(1, 3, 64, 64) labels = torch.rand(1, 1000) @@ -283,7 +284,7 @@ from torch import nn, optim -model = torchvision.models.resnet18(pretrained=True) +model = resnet18(weights=ResNet18_Weights.DEFAULT) # Freeze all the parameters in the network for param in model.parameters():