Open
Conversation
|
|
1 similar comment
|
|
Contributor
|
Hi, is there a paper that details these new losses and benchmarks them on known public datasets? Even we do decide to move forward with this, the PR is missing:
|
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.
PR Description: Integration of Fourier-Domain Loss Functions
Overview
This PR introduces a suite of frequency-domain loss functions and a flexible
MixedFFTLossutility. These additions allow the model to optimize for spectral density and periodic structures, which provides a more robust loss function to trend and seasonality vs direct pointwise prediction errors.Fourier Loss Suite
I have implemented three core frequency-domain losses based on the magnitude spectrum of the Real Discrete Fourier Transform (RFFT):
FFTMAELoss: Mean Absolute Error in frequency space.FFTMSELoss: Mean Squared Error in frequency space.FFTRMSELoss: Root Mean Squared Error in frequency space.These losses operate on the magnitude spectrum$|F(y)|$ which ensures the loss remains real-valued, focuses on the power distribution of seasonal and trend components rather than exact point-in-time alignment.
Hybrid Optimization (
MixedFFTLoss)To balance point-wise accuracy with structural frequency alignment, I added
MixedFFTLoss. This allows for a composite objective function. This function provides the best balance for real-world use cases:Key Features:
normparameter to ensure loss stability across varying sequence lengths (BasePointLossinterface to seamlessly integrate with existing loss functions in the repository.Testing
Tests were performed locally via PyTest. The baseline formulas were computed in pure numpy and compared against the pytorch functions implemented. The loss functions are numerically stable and work within the NeuralForecast repository.