Skip to content

Recommend a versatile and easy-to-implement loss function #1301

@HowardZJU

Description

@HowardZJU

Description

Hi there,

I am writing to introduce a loss function tailored for time-series forecasting proposed in FreDF. The source code is provided in https://github.com/Master-PLC/FreDF. Nevertheless, you can ignore the released repo and directly implement FreDF through two lines of code as follows.

# The canonical temporal loss
loss_tmp = ((outputs-batch_y)**2).mean()
# The proposed frequency loss
loss_feq = (torch.fft.rfft(outputs, dim=1) - torch.fft.rfft(batch_y, dim=1)).abs().mean() 
# Note. The frequency loss can be used individually or fused with the temporal loss using finetuned relative weights. Both witness performance gains, see the ablation study in our paper.

The efficacy of the loss function has been investigated through extensive experiments in this study. I recognized that there is a losses module in NeuralForecast so I guess it would be helpful to include this plain and effective method.

Use case

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions