I am trying to get pytorch to work but I keep getting this error.
ModuleNotFoundError: No module named 'torch.nn'; 'torch' is not a package
I am using a Macbook, i've tried looking at the other answers on here but nothing is working.
import torch
import torchvision
import torchvision.transforms as transforms
transform = transforms.Compose(
[transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=4,
shuffle=True, num_workers=2)
testset = torchvision.datasets.CIFAR10(root='./data', train=False,
download=True, transform=transform)
testloader = torch.utils.data.DataLoader(testset, batch_size=4,
shuffle=False, num_workers=2)
classes = ('plane', 'car', 'bird', 'cat',
'deer', 'dog', 'frog', 'horse', 'ship', 'truck')
question from:
https://stackoverflow.com/questions/65910782/modulenotfounderror-no-module-named-torch-nn-torch-is-not-a-package-on-mac 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…