Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mask NaNs in training loss function #72

Open
wants to merge 42 commits into
base: develop
Choose a base branch
from

Conversation

sahahner
Copy link
Member

@sahahner sahahner commented Oct 2, 2024

Variables with missing values that are imputed by the imputer should not be considered in the loss.

Solves issue 271

Describe the solution
Pass the product of the imputer NaN mask(s) to the loss in the first forward pass and multiply the contributions to the loss of imputed grid points by zero.
Also, apply the remapper to the mask to remap the NaN mask in case the remapper is used.

The NaN masks are prepared in the imputer. The remapper contains a new function to remap the NaN mask.
These changes are part of anemoi-model, PR #56

Attention
This changes the default behaviour when using variables that contain NaN values that are imputed.

@FussyDuck
Copy link

FussyDuck commented Oct 2, 2024

CLA assistant check
All committers have signed the CLA.

CHANGELOG.md Outdated Show resolved Hide resolved
@HCookie
Copy link
Member

HCookie commented Oct 3, 2024

The loss function code is being altered in #70 to enable flexible configuration of loss functions.
This PR will require some changes to be compatible.

Changes

  • masks will need to be added to ‘mae’, and ‘logcosh’
  • Initialisation of loss functions needs to be pulled from the other PR
  • Setting of the mask will require a ‘hasattr’ check to determine if the loss function exposes that functionality.

@sahahner sahahner added the enhancement New feature or request label Nov 7, 2024
@sahahner sahahner marked this pull request as ready for review November 12, 2024 16:21
@sahahner
Copy link
Member Author

This has to be merged after #137

@sahahner sahahner changed the base branch from develop to fix-allow-updated-scalars November 13, 2024 08:02
@sahahner sahahner changed the base branch from fix-allow-updated-scalars to develop November 13, 2024 08:03
HCookie
HCookie previously approved these changes Nov 14, 2024
@jakob-schloer
Copy link
Collaborator

After discussing with @sahahner and a quick test with an ocean dataset, I approve the PR.

Copy link
Collaborator

@jakob-schloer jakob-schloer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve after testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants