'RuntimeError: The size of tensor a (10) must match the size of tensor b (35000) at non-singleton dimension 1
data = b1.send(bob)
data.shape # torch.Size([35000, 1, 28, 28])
pred = model(data)
pred.shape #torch.Size([35000, 10])
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.fc1 = nn.Linear(784, 500)
self.fc2 = nn.Linear(500, 10)
def forward(self, x):
x = x.view(-1, 784)
x = self.fc1(x)
x = F.relu(x)
x = self.fc2(x)
return x
model=Net()
for i in range(10):
# Train Bob's Model
opt.zero_grad()
pred = model(data)
loss = criterion(pred, target.view(1, -1))
loss.backward()
opt.step()
This throws the error:
RuntimeError: The size of tensor a (10) must match the size of tensor b (35000) at non-singleton dimension 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
