mirror of
https://github.com/deepseek-ai/Janus.git
synced 2026-11-05 00:57:18 +00:00
[PR #234] [CLOSED] fix: remove inconsistent +1e-5 offset in entropy loss log_softmax #233
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/Janus#233
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/Janus/pull/234
Author: @Mr-Neutr0n
Created: 2/11/2026
Status: ❌ Closed
Base:
main← Head:fix/entropy-loss-consistent-softmax📝 Commits (1)
277b071fix: remove inconsistent offset in log_softmax for entropy loss📊 Changes
1 file changed (+1 additions, -1 deletions)
View changed files
📝
janus/models/vq_model.py(+1 -1)📄 Description
Summary
In
compute_entropy_loss()injanus/models/vq_model.py,probsandlog_probsshould represent the same probability distribution, but they diverge because of an unnecessary+ 1e-5offset applied beforelog_softmax:The
+ 1e-5offset shifts the logits before computinglog_softmax, which meanslog_probs != log(probs). This causes the sample entropy term (-sum(probs * log_probs)) to not be a true entropy computation, introducing a small but systematic bias in the entropy loss.F.log_softmaxis already numerically stable (it uses the log-sum-exp trick internally), so the+ 1e-5offset is not needed for numerical safety and only serves to makeprobsandlog_probsinconsistent.Fix
Remove the
+ 1e-5so bothprobsandlog_probsare computed from the same input:Test plan
compute_entropy_lossproduces correct entropy values by checkinglog_probs == log(probs)for sample inputsF.log_softmaxis inherently stable)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.