Я получаю:
RuntimeError: Ошибка утверждения: cur_target> = 0 && cur_target
при запуске этого кода:
criterion = nn.CrossEntropyLoss()
#Define the optimizer
optimizer=optim.SGD(net.parameters(),lr=0.01,momentum=0.9)
epochs=20
for epoch in range(epochs):
print ("epoch #", epoch)
running_loss=0.0
for i, data in enumerate(train_loader,0):
inputs,labels=data
inputs,labels= inputs.to(device),labels.to(device)
optimizer.zero_grad()
#train
output=net(inputs)
loss=criterion(output,labels)
print ("loss: ", loss.item())
running_loss+=loss.item()
loss.backward()
optimizer.step()
print ('Finished Training')