feat: add Log-Spectral Distance (LSD) metric and support spatial frequency analysis#508
Open
sohampatil01-svg wants to merge 2 commits intomllam:mainfrom
Open
feat: add Log-Spectral Distance (LSD) metric and support spatial frequency analysis#508sohampatil01-svg wants to merge 2 commits intomllam:mainfrom
sohampatil01-svg wants to merge 2 commits intomllam:mainfrom
Conversation
Author
|
@observingClouds Please have a Look at it ! |
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.
Describe your changes
This PR introduces a generalized Log-Spectral Distance (LSD) metric to
neural-lam, providing a powerful tool for evaluating and potentially training models in the spatial frequency domain across all supported grid types.Motivation
Standard point-wise metrics (MSE, MAE, NLL, CRPS) often fail to distinguish between physically realistic forecasts and overly smooth ("blurry") fields that result from "regression to the mean." LSD addresses this by comparing the power spectra of predictions and targets, directly penalizing discrepancies in energy distribution across different spatial scales.
Following a challenge to support irregular grids, this implementation now works for both:
torch.fft.rfft2).Key Changes:
log_spectral_distanceto handle both regular and unstructured grids._compute_laplacian_momentshelper for efficient GSP-based spectral analysis using power iterations.self.edge_indextoARModelto store graph connectivity.training_step,validation_step, andtest_stepto passedge_indexto the loss function.self.edge_indexfrom the mesh graph (finest level for hierarchical models).Dependencies
torchsparse operations andtorch.fftavailable in modern PyTorch).Issue Link
Solves #506
Type of change
Checklist before requesting a review
Checklist for reviewers
Each PR comes with its own improvements and flaws. The reviewer should check the following:
Author checklist after completed review
Checklist for assignee