Name 'ResNet18_Weights' is not defined

pretrained_net = torchvision.models.resnet18(weights=ResNet18_Weights.DEFAULT)
I have imported torchvision, but it still went wrong.

Make sure to import the weights from torchvision.models via:

from torchvision.models import ResNet50_Weights
1 Like