danijar / dreamerv3

Mastering Diverse Domains through World Models
https://danijar.com/dreamerv3
MIT License
1.28k stars 219 forks source link

Difference between model_loss and model_opt_loss #56

Closed subho406 closed 1 year ago

subho406 commented 1 year ago

Hey,

I was just going through the logs for one of the runs generated using DreamerV3 and noticed that the code logs two different model losses (1) model_loss and (2) model_opt_loss. I found that the value of model_opt_loss is generally way higher than the model_loss for the Crafter environment. I was wondering if you could explain me the differences between the two? If you could point me to the equations in the paper they refer to, that would be great. Thanks!

danijar commented 1 year ago

Hi, I think that's because of dynamic loss scaling that happens when you train in mixed precision (float16) mode. There is also a summary model_opt_loss_scale that should equal to difference between the two metrics you're mentioning.

The loss scale is only an implementation detail to avoid numeric overflows during the backward pass due to the very limited exponent range of float16 and is undone on the gradients before applying them.