in train.py
loss_critic = F.smooth_l1_loss(y_predicted, y_expected)
self.critic_optimizer.zero_grad()
loss_critic.backward()
self.critic_optimizer.step()
Is it correct to set the gradients in the optimizer to zero after calculating the loss or should it be the other way around i.e. setting all gradients to zero, then taking the loss and performing an update?
in train.py
Is it correct to set the gradients in the optimizer to zero after calculating the loss or should it be the other way around i.e. setting all gradients to zero, then taking the loss and performing an update?