Anyone who could tell me how to get the gradients of loss ? The code is as below:
loss_seg = criterion_seg(outputs_seg, targets_seg[:, 0])
        targets_ins = Variable(labels_ins)
        loss_ins = criterion_ins(outputs_ins, targets_ins[:, 0], n_objects, MAX_N_OBJECTS)

        loss = loss_seg + loss_ins

        optimizer.zero_grad()
        loss.backward()
        optimizer.step()