kdgutier / esrnn_torch

MIT License
156 stars 44 forks source link

Negative or very small positive values produce nan values of loss and metric during training #18

Closed ramdhan1989 closed 3 years ago

ramdhan1989 commented 4 years ago

Hi, I am struggle with nan values of loss and metric during training. several things that has been tried to solve it but still doesn't work :

  1. change range of target (negative - positive) into 0-1 using minmaxscaler
  2. exclude series with constant values throughout the time
  3. change unique_id and x from integer type to str type

do you have any idea to solve it ?

thanks

kdgutier commented 3 years ago

Multiplicative regression models like ESRNN estimate the parameters on log transformed data, if one uses negative values the logarithms will fail.

An advisable data preprocessing before taking it into the ESRNN model is to translate (to make positive) and then transform (scaling). The min-max transformation may still face the same challenges as log(0) is not bounded.

If your data is already preprocessed to be positive and scaled, then I would check the learning rates in case the optimization procedure is diverging. Hope this solves the problem.

ramdhan1989 commented 3 years ago

thanks, it works ! the data is translated to positive by adding the value with absolute of min value and add 10. so the value is between 10 and (max + absolute of min). what do you think ? do you have better alternative ?

please advice, thanks

kdgutier commented 3 years ago

That is what I would do, good that it works.