philtabor / Deep-Q-Learning-Paper-To-Code

MIT License
347 stars 146 forks source link

The dqn_agent.py loss function is the wrong way around #19

Closed i1Cps closed 7 months ago

i1Cps commented 7 months ago

In dqn_agent.py, shouldnt the loss function be:

loss = self.q_eval.loss(q_pred, q_target).to(self.q_eval.device)

Instead of:

loss = self.q_eval.loss(q_target, q_pred).to(self.q_eval.device)

Pytorch documentation for reference

i1Cps commented 7 months ago

"The magnitude of the loss is always the same regardless of the order." "The gradients of the loss function, with respect to the weights of the network, for a constant (i.e. the target) is always zero."