Skip to content

feat: add GaussianNLLLoss#5182

Open
Bellman281 wants to merge 3 commits into
tracel-ai:mainfrom
Bellman281:loss/gaussian-nll
Open

feat: add GaussianNLLLoss#5182
Bellman281 wants to merge 3 commits into
tracel-ai:mainfrom
Bellman281:loss/gaussian-nll

Conversation

@Bellman281

Copy link
Copy Markdown
Contributor

Checklist

  • Confirmed that cargo run-checks command has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

Part of the PyTorch loss-parity effort, following SoftMarginLoss (#5149),
MarginRankingLoss (#5151), HingeEmbeddingLoss, TripletMarginLoss, and MultiMarginLoss.

Changes

Adds GaussianNLLLoss / GaussianNLLLossConfig, matching torch.nn.GaussianNLLLoss:
0.5 · (log(var) + (input − target)² / var) element-wise, with var clamped to eps
(default 1e-6) and an optional full term 0.5·log(2π) (default off). Composed from existing
ops so autodiff is free. Follows the MarginRankingLoss config/module pattern; added to the
book's loss table.

Testing

Known-answer tests for the base and full = true cases (forward_no_reduction + Mean + Sum)
verified against PyTorch reference values, plus a display test. cargo run-checks passes.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.79518% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.11%. Comparing base (12cba54) to head (94aff2f).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
crates/burn-nn/src/loss/gaussian_nll.rs 98.79% 1 Missing ⚠️

❌ Your project check has failed because the head coverage (66.11%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5182      +/-   ##
==========================================
+ Coverage   66.03%   66.11%   +0.07%     
==========================================
  Files        1206     1213       +7     
  Lines      183117   183466     +349     
==========================================
+ Hits       120927   121295     +368     
+ Misses      62190    62171      -19     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants