Skip to content

fix(fit_line): keep the sample weights non-negative - #118

Merged
ducha-aiki merged 1 commit into
masterfrom
fix/fit-line-nonnegative-weights
Oct 6, 2026
Merged

ducha-aiki merged 1 commit into
masterfrom
fix/fit-line-nonnegative-weights

Conversation

@ducha-aiki

Copy link
Copy Markdown
Member

What does this pull request do?

nbs/fit_line.ipynb builds its weights as 1 - p2_noise.mean(), where p2_noise = torch.rand_like(p2) * std and std = 1.2. The mean of two U(0, 1.2) draws is above 1 with probability ≈ 5.6%, so with 50 unseeded points at least one weight is negative ≈ 94% of the time. Since kornia/kornia#5108, fit_line rejects negative weights (ValueCheckError: fit_line requires non-negative weights), and the tutorials job of kornia's scheduled CPU tests has failed on this notebook in most runs since 2026-10-03, for example https://github.com/kornia/kornia/actions/runs/37397633192/job/112057348727.

The weight is now 1 - p2_noise.mean() / std. It lies in [0, 1] and keeps the original intent: noisier points get less weight.

What did you check?

I executed the notebook's code cells (plotting cell excluded) against current kornia main, with seeds 0–199:

before: 185 / 200 seeds raise "fit_line requires non-negative weights"
after:    0 / 200

The notebook still parses as JSON. Only that one source line changes.

Posted on behalf of @ducha-aiki by Claude (Opus 5.5).

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ducha-aiki
ducha-aiki merged commit 05d1c2c into master Oct 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant