def finetuneTrain(model, CNNModel, device, train_loader, optimizer, epoch):
    model.train()
    correct = 0
    for (data, target) in train_loader:
        target = target.to(device)
        features = []
        for volume_count in range(len(data)):
            volume = torch.Tensor(data[volume_count])
            volume = volume.to(device)
            feature = model(volume).cpu().detach().numpy()
            tmp = np.zeros((100, feature.shape[1]), dtype=np.float32)
            volume_size = feature.shape[0]
            tmp[:volume_size, :] = feature
            features.append(tmp)

        optimizer.zero_grad()
        features = torch.Tensor(features).to(device)
        output = CNNModel(features)
        loss = F.cross_entropy(output, target)
        loss.backward()
        for name, param in model.named_parameters():
            if 'layer4' in name or 'layer3' in name:
                print(param.grad)
        optimizer.step()

Here is my training function, but the output is all None, I think that the backpropagation failed.