I am trying to train my first CNN after trying an existing one but it didn’t work . this error was appeared and i cann’t understand it.Screenshot from 2020-09-29 17-03-081920×1080 320 KB
I work on ubuntu 18.0 , GTX 1660 Ti 6G.  this is a code sample that i think causes the error:
the code
for epoch in range(num_epochs):
model.train()
for batch_idx, (features, targets, levels, x) in enumerate(train_loader):
features = features.to(DEVICE)
targets = targets
targets = targets.to(DEVICE)
levels = levels.to(DEVICE)
    logits, probas = model(features)
    if epoch >= 190:
        print('\n i=',batch_idx,'logits  =', logits)
        print( '\n i=',batch_idx,' probas =',probas)

    impf=torch.ones([logits.shape[0], NUM_CLASSES])
    for i in range(len(x) ):
        impf[i]=impFactor(x[i])
    impf = impf.to(DEVICE)                
    logits= (logits * impf).to(DEVICE)
    cost = cost_fn(logits, levels)
    optimizer.zero_grad()
    cost.backward()
    optimizer.step()