hello everyone
i get this error when i use from SGD-loss function. plz help me…
criterion = nn.CrossEntropyLoss()
optimizer = optim.SGD(model.parameters(), lr=0.002, momentum=0.9)

num_epochs = 10
losses_SGD = []
for epoch in range(num_epochs):
    for i, (inputs, targets) in enumerate(train_dl):
        inputs = to_var(inputs)
        targets = to_var(targets)
        
         # forwad pass
        optimizer.zero_grad()
        outputs = model(inputs)
        
         # loss
        loss = criterion(outputs, targets)
        losses += [loss.data]
         # backward pass
        loss.backward()
        
         # update parameters
        optimizer.step()
        
         # report
        if (i + 1) % 50 == 0:
             print('Epoch [%2d/%2d], Step [%3d/%3d], Loss: %.4f'
                   % (epoch + 1, num_epochs, i + 1, len(train_ds) // batch_size, loss.data))