Repository navigation
Leave loss inputs intact when applying position weights - #8
Merged
Merged
Conversation
PoissonMultinomialLoss scaled y_true and y_pred in place, so the trainer's train/valid r, r2 and spec (and the spec stop_stat) were computed on edge-downweighted tensors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
PoissonMultinomialLoss.forwardscaledy_trueandy_predby the position weights in place. The trainer computes the loss before updating its metrics (_train_batch_cov,_validate_cov). So the train/valid r, r² and spec it logs, and thestop_statbuilt from them, were computed on edge-downweighted tensors. This PR makes the multiply out of place. Loss values and gradients are unchanged.Impact on logged metrics: with
weight_range: 10, weight_exp: 8, the edge bins are scaled to 0.1. Down-weighting them inflates valid r by about 0.005 overall, and by up to about 0.015 for broad histone marks (e.g. H3K36me3, H3K4me1).hound_evalscores unweighted tensors, so its numbers never matched the trainer's for the same checkpoint and fold. After this change they do. Metrics logged by earlierpoisson_mnruns are position-weighted.Evidence:
hound_evalto 1e-4.test_position_weights_leave_inputs_intactfails onmainand passes here.src/tests/test_loss_weight.py: 34 passed.🤖 Generated with Claude Code