thank you for your reply mate!
But this won’t help because optimizer.zero_grad() is required before the gradient calculation i.e loss.backward(). So it wont make any difference.
setting model.train() also wont help because models are by default into train mode until we explicitly put it into evaluation mode.