Stock price prediction with LSTM

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:

  1. The first containing the samples.
  2. The second containing the timeseries.
  3. 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.

  1. First of all, some imports:
import matplotlib.pyplot as pltimport numpy as npimport tensorflow as tffrom evaluate_ts ...

Get TensorFlow Deep Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.