Skip to content

Commit 5f10e99

Browse files
Update autograd_tutorial.py (#2021)
The parameter 'pretrained' is deprecated. Updated it to latest standard. Co-authored-by: Nikita Shulga <[email protected]>
1 parent 8e0cd41 commit 5f10e99

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

beginner_source/blitz/autograd_tutorial.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
This tutorial work only on CPU and will not work on GPU (even if tensor are moved to CUDA).
4444
4545
"""
46-
import torch, torchvision
47-
model = torchvision.models.resnet18(pretrained=True)
46+
import torch
47+
from torchvision.models import resnet18, ResNet18_Weights
48+
model = resnet18(weights=ResNet18_Weights.DEFAULT)
4849
data = torch.rand(1, 3, 64, 64)
4950
labels = torch.rand(1, 1000)
5051

@@ -283,7 +284,7 @@
283284

284285
from torch import nn, optim
285286

286-
model = torchvision.models.resnet18(pretrained=True)
287+
model = resnet18(weights=ResNet18_Weights.DEFAULT)
287288

288289
# Freeze all the parameters in the network
289290
for param in model.parameters():

0 commit comments

Comments
 (0)