Besides, The model is trained:

model = resnet_cbam.resnet50_cbam(pretrained=False)
model = model.to(device)
criterion = nn.BCEWithLogitsLoss()
optimizer = torch.optim.Adam(model.parameters())

And when i was training:

for img_data, target in tqdm_notebook(train_loader, desc=‘Training’):
img_data, target = img_data.to(device), target.to(device)
    output = model(img_data) 

    loss = criterion(output, target) #Cross entropy loss
    c_loss = loss.data.item()
    ax1.plot(count, c_loss, 'r.')
    loss_val += c_loss


The problem occurs as mentioned above.