Thanks a lot @ptrblck! The loss still doesn’t seem to change. The code doesn’t throw any error but shows the same loss value in each epoch. What could be the possible reason?
def listwiseloss(output):
  s=0
  b=0
  
  for i in range(n_unique_qid):
    for j in range(list_size[i]-1):
      s=s-output[sum(list_size[:i])+j]
      for k in range(j,list_size[i]):
        b =b+torch.exp(output[sum(list_size[:i])+k])
      s = s+torch.log(b)
      b=0  
  return s