preds_T[0].detach()
# print (preds_S[0].shape)
# print (preds_T[0].shape)
assert preds_S[0].shape == preds_T[0].shape , 'The output dim of teacher & student differ ’
C,W,H = preds_S.shape
#C = 1
#softmax_pred_T = F.softmax(preds_T[0].permute(0,1).contiguous().view(-1,1), dim = 1)
softmax_pred_T = F.softmax(preds_T[0], dim = 1)
#softmax_pred_S = self.LogSoftMax(preds_S[0].permute(0,1).contiguous())
#softmax_pred_S = nn.LogSoftmax(preds_S[0].permute(0,1).contiguous().view(-1,1),dim=1)
softmax_pred_S = nn.LogSoftmax(preds_S[0])
#loss = (torch.sum(-softmax_pred_T * softmax_pred_S ))
#loss = self.KlLoss(softmax_pred_S,softmax_pred_T)
softmax_pred_T1 = F.softmax(preds_T[0].permute(0, 1).contiguous().view(-1, C), dim=1)
logsoftmax1 = nn.LogSoftmax(dim=1)
softmax_pred_S1 = nn.LogSoftmax(preds_S[0].permute(0,1).contiguous().view(-1,C))
loss1 = (torch.sum( - softmax_pred_T1 * logsoftmax1(preds_S[0].permute(0,1).contiguous().view(-1,C))))/W/H
    loss = nn.KLDivLoss(reduction='batchmean').cuda()
    loss_value = loss(softmax_pred_S.dim,softmax_pred_T)

i do the same like softmax and log softmax, but my loos_value is always negative, can you please clear me. it will be a great help thanks in advance @ptrblck  @coincheung @saba @ani0075 @ani0075 @apaszke @alexis-jacq @alexis-jacq