任何人都可以帮助我吗?我得到低于错误。我使用谷歌 Colab。如何解决这个错误。?
大小不匹配,m1:[64 x 100],m2:[784 x 128] 在 /pytorch/aten/src/TH/generic/THTensorMath.cpp:2070
下面的代码我正在尝试运行。
import torch
from torch import nn
import torch.nn.functional as F
from torchvision import datasets, transforms
# Define a transform to normalize the data
transform =
transforms.Compose([transforms.CenterCrop(10),transforms.ToTensor(),])
# Download the load the training data
trainset = datasets.MNIST('~/.pytorch/MNIST_data/', download=True,
train=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64,
shuffle=True)
# Build a feed-forward network
model = nn.Sequential(nn.Linear(784, 128),nn.ReLU(),nn.Linear(128,
64),nn.ReLU(),nn.Linear(64, 10))
# Define the loss
criterion = nn.CrossEntropyLoss()
# Get our data
images, labels = next(iter(trainloader)) …Run Code Online (Sandbox Code Playgroud) machine-learning image-processing computer-vision python-3.x pytorch