## 导入需要的包 import torch from torch import nn from torch.utils.data import DataLoader from torchvision import datasets from torchvision.transforms import ToTensor 判断是不是可以在GPU上进行训练 如果可以就使用GPU,否则使用CPU device = 'cuda' if torch.cuda.is_available() else 'cpu' training_data = datasets.FashionMNIST( root="data", train=True, download=True, transform=ToTensor() ) test_data = datasets.FashionMNIST( root="data", train=False, download=True, transform=ToTensor() ) training_dataloader = DataLoader(training_data, batch_size=64, shuffle=True) test_dataloader = DataLoader(test_data, batch_size=64, shuffle=False) class Network(nn.Module):