awslabs / gluonts

Probabilistic time series modeling in Python
https://ts.gluon.ai
Apache License 2.0
4.54k stars 747 forks source link

Personalize cost function #1330

Open edarca opened 3 years ago

edarca commented 3 years ago

Description

I have been looking for some method to change loss function, and I have not found anything...

I don't know if it's a feature request, but anyway:

How can I change the loss function to be, for instance, the MSE with respect to the mean of the distribution?

mbohlkeschneider commented 3 years ago

Hi @edarca,

for which model do you want to change the loss function? For the non-probabilistic ones, it is straightforward, you can just implement what you want. For parametric probabilistic methods, it is a bit trickier.

One way to arrive at MSE is to take the GaussianOutput and fix sigma like we do in this test: https://github.com/awslabs/gluon-ts/blob/master/test/distribution/test_mx_distribution_inference.py#L609. This basically arrives at MSE/L2 loss.