Thanks to LSTM, we can exploit the temporal redundancy contained in our signals. From the previous section, we learned that the observation matrix should be reformatted into a 3D tensor, with three axes:
- The first containing the samples.
- The second containing the timeseries.
- The third containing the input features.
Since we're dealing with just a mono-dimensional signal, the input tensor for the LSTM should have the size (None, time_dimension, 1), where time_dimension is the length of the time window. Let's code now, starting with the cosine signal. We suggest you name the file 4_rnn_cosine.py.
- First of all, some imports:
import matplotlib.pyplot as pltimport numpy as npimport tensorflow as tffrom evaluate_ts ...