InnovArul:

only2probs = F.softmax(newProbs[:,:,0:2], dim=-1) zeros = torch.zeros(only2probs.shape[0], only2probs.shape[1], 1) newProbs = torch.cat((only2probs, zeros), dim=-1)


Thank You so much Arul. It did work!
It does retain the grad as well.