Skip to content Skip to footer

Neural Networks For Periodic Functions | by Dr. Robert Kübler | Jan, 2024


When ReLU’s extrapolation capabilities are not enough

Photo by Willian Justen de Vasconcellos on Unsplash

Neural networks are known to be great approximators for any function — at least whenever we don’t move too far away from our dataset. Let us see what that means. Here is some data:

Image by the author.

It does not only look like a sine wave, it actually is, with some noise added. We can now train a normal feed-forward neural network having 1 hidden layer with 1000 neurons and ReLU activation. We get the following fit:

Image by the author.

It looks quite decent, apart from the edges. We could fix this by adding more neurons to the hidden layer according to Cybenko’s universal approximation theorem. But I want to point you something else:

Image by the author.

We could argue now that this extrapolation behavior is bad if we assume the wave pattern to continue outside of the observed range. But if there is no domain knowledge or more data we can resort to, it would just be this: an assumption.

However, in the remainder of this article, we will assume that any periodic pattern we can pick up within the data continues outside as well. This is a common assumption when doing time series modeling, where we naturally want to extrapolate into the future. We assume that any observed seasonality in the training data will just continue like that, because what else can we say without any additional information? In this article, I want to show you how using sine-based activation functions helps bake this assumption into the model.

But before we go there, let us shortly dive deeper into how ReLU-based neural networks extrapolate in general, and why we should not use them for time series forecasting as is.



Source link