Skip to content

Fix RMS spot size calculation order#105

Merged
singer-yang merged 1 commit intovccimaging:devfrom
ejin-photonium:fix-rms-calculation
Feb 6, 2026
Merged

Fix RMS spot size calculation order#105
singer-yang merged 1 commit intovccimaging:devfrom
ejin-photonium:fix-rms-calculation

Conversation

@ejin-photonium
Copy link
Copy Markdown
Contributor

Summary

  • Fix RMS formula: compute sqrt(mean(x^2)) instead of mean(sqrt(x^2)) in geolens.py, optim.py, and 2_autolens_rms.py
  • Numerical stability: add EPSILON inside sqrt in training loss paths to prevent NaN gradients from sqrt(0) when field points have zero valid rays

Fixes #102

🤖 Generated with Claude Code

RMS = sqrt(mean(x^2)), but the code was computing mean(sqrt(x^2)).
Apply sqrt after averaging across rays, not before. Also add EPSILON
inside sqrt in training loss paths to prevent NaN gradients from
sqrt(0) when field points have zero valid rays.

Fixes vccimaging#102

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@singer-yang singer-yang merged commit 68e4406 into vccimaging:dev Feb 6, 2026
1 check passed
@ejin-photonium ejin-photonium deleted the fix-rms-calculation branch February 6, 2026 16:04
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