I am a new beginner in pytorch.
I try to import these:
import torch
from torch import nn
from torch.utils.data
import DataLoader from torchvision
import datasets from torchvision.transforms import ToTensor
but Studio Code cant resolve it
I am a new beginner in pytorch.
I try to import these:
import torch
from torch import nn
from torch.utils.data
import DataLoader from torchvision
import datasets from torchvision.transforms import ToTensor
but Studio Code cant resolve it
Hello!
Your format/syntax of calling the imports seem to be faulty.
import torch
from torch import nn
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision.transforms import ToTensor
I think you could try this.
Python Modules This is a nice intro to what import actually is!
oooohhhhhh thaaaaank you.
It was the code from a tutorial, and I was changeing everything on my system.
Thank you.
Thats the whole code.
import torch
from torch import nn
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision.transforms import ToTensor
training_data = datasets.MNIST(
root=“data”,
train=True,
download=True,
transform=ToTensor(),
)
test_data = datasets.MNIST(
root=“data”,
train=False,
download=True,
transform=ToTensor(),
)
batch_size = 64
train_dataloader = DataLoader(training_data, batch_size=batch_size)
test_dataloader = DataLoader(test_data, batch_size=batch_size)
device = “cuda” if torch.cuda.is_available() else “cpu”
print(f"Using {device} device")