maskbit icon indicating copy to clipboard operation
maskbit copied to clipboard

Entropy loss is Negative

Open Luckygyana opened this issue 1 year ago • 2 comments

Entropy loss is coming Negative and that making total loss also negative, is it normal?

[2025-01-04 03:41:09] Data (t): 113.0258 Batch (t): 113.5286 Steps/Sec: 0.8808 LR: 0.000002 Step: 100 Total Loss: 1.1701 Entropy Loss: -0.1207 Sample Entropy: 0.1276 Avg Entropy: 6.1613 
[2025-01-04 03:44:21] Data (t): 191.6203 Batch (t): 192.1211 Steps/Sec: 0.5205 LR: 0.000004 Step: 200 Total Loss: -0.0196 Entropy Loss: -0.1336 Sample Entropy: 0.0423 Avg Entropy: 6.7223

Luckygyana avatar Jan 04 '25 03:01 Luckygyana

Yes that is the case due to the loss design. The entropy loss includes two terms:

  1. We would like to minimize the per token entropy, i.e. each token is clearly assigned to one bit tokens / codebook entry.
  2. We would like to maximize the codebook entropy, i.e. we would like to use all bit tokens / codebook entries equally. (this is computed per mini-batch).

Since the 2nd term is maximized (and not minimized like all other losses), we subtract it from the total loss, instead of adding it to the loss. Hence, the total loss can be negative.

If you like standard loss curves more, you could report the total loss excluding the entropy loss. I hope that helps.

markweberdev avatar Jan 05 '25 20:01 markweberdev

Thank you for the exaplanantion

Luckygyana avatar Jan 06 '25 08:01 Luckygyana