Hi,
I want to get argmax of my preds in batch.when I print argmax in model, It return values, but when I save the perds in list, it return zeros for all elements in list. I don’t know why it is happend, how can I get values in list?
my code is:
for epoch in tqdm(range(1, num_epochs + 1)):
    # start_time = time.time()
    num_examples =0
    scheduler.step()
    correct_pred = 0
    lr = scheduler.get_lr()[0]

    model.eval()
    train_loss_total = 0.0
    num_steps = 0
    test_loss_total = 0
    num = 0

    ### Training
    for i, batch in enumerate(test1_loader):

        input_samples, gt_samples = batch[2], batch[3]
        var_input =input_samples
        var_gt = gt_samples
        optimizer.zero_grad()

        preds = model(var_input)
        var_gt = var_gt.reshape(8,64,64,64)
        var_gt = var_gt.long()

        # print(preds.shape)
        loss1 = criterion(preds, var_gt)   
        # loss.backward(retain_graph=True)
        loss1.backward()
        optimizer.step()
        test1_loss_total += loss1.item()
        num_steps += 1

        _, predicted_test = torch.max(preds.data, 1)
        total_test1 += var_gt.nelement()
        correct_test1 += predicted_test.eq(var_gt.data).sum().item()
        print('************************************************************************')

        print(preds.shape)
        _, v = torch.max(preds, dim=0)
        print(v.unique())
        _, v1 = torch.max(var_gt, dim=0)
        print('   v1     ',v1.unique())


        print('----------------')

        if epoch == num_epochs:
           predslist.append(preds)
           var_gtlist.append(var_gt)
           print('done')

    test1_accuracy = 100 * correct_test1 / total_test1
    print('Epoch {}, test Loss: {:.3f}'.format(epoch, test1_loss_total / num_steps),
          "Testing Accuracy: %d %%" % (test1_accuracy))

    print("finished training")

and result is:
Epoch 4, test Loss: 0.148 Testing Accuracy: 99 %
finished training
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 3, 4, 5, 6, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 3, 4, 5, 6, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([2, 3, 4, 5, 6, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 3, 4, 5, 6, 7])
   v1      tensor([0, 3, 7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 4, 5, 6, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 3, 4, 5, 6, 7])
   v1      tensor([2, 5, 7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 6, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 3, 4, 5, 6, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 3, 4, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
tensor([0, 1, 2, 3, 4, 5, 6, 7])
   v1      tensor([7])
----------------
done
************************************************************************
torch.Size([8, 21, 64, 64, 64])
100%|██████████| 5/5 [21:29<00:00, 257.86s/it]tensor([0, 1, 2, 3, 4, 5, 6, 7])
   v1      tensor([7])
----------------
done
Epoch 5, test Loss: 0.185 Testing Accuracy: 99 %
finished training

my code for list is:
for ii in predslist:
  for j in range(0, batch_size):
      om = torch.argmax(ii[j].squeeze(), dim=0)
      print (om.unique()) 

that it return zeros.