Repository navigation
Keep classification likelihood calculations in log space - #40
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
Author
|
Following up on this. Is there anything you’d like changed before it can move forward? Happy to address review feedback. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Marginal, joint, and polyadic classification likelihoods materialize softmax probabilities before taking their logarithm. Finite logits such as
[0, -1000]therefore produce infinite negative log likelihood and non-finite derivatives after the labelled probability underflows to zero.Change
Use log_softmax for labelled class log probabilities. Keep marginal mixtures in log space with logsumexp minus the log sample count, and retain the existing joint-sample aggregation. Preserve the intended averaging of probabilities rather than averaging log probabilities. The probability-input categorical_log_likelihood helper and accuracy/calibration calculations are unchanged.
The operation follows the JAX log_softmax definition.
Validation
git diff --checkpass.python -m pytest enn/metrics.Python 3.12.14, JAX/jaxlib 0.11.2, NumPy 2.5.3 and SciPy 1.18.1 on macOS arm64 CPU. The metrics package imports TensorFlow Probability for calibration, so local validation used tfp-nightly 0.26.0.dev20261006; one existing JAX deprecation warning was emitted. No repository dependency files changed. Full ENN training/network tests, static typing, model checkpoints and GPU execution were not run.
Reproduced against
c30ae1630bbb41f2f89d061215d851562bc0003c.