LSTMs remember, forget, and pick what to pass on and then output depending on the current state and input. An LSTM has many more moving parts, but using the native TensorFlow API, it will be quite straightforward:
from __future__ import print_function, divisionimport tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltfrom tensorflow.contrib import rnn"""define all the constants"""numEpochs = 10seriesLength = 50000backpropagationLength = 15stateSize = 4numClasses = 2echoStep = 3batchSize = 5num_batches = seriesLength // batchSize // backpropagationLength"""generate data"""def generateData(): x = np.array(np.random.choice(2, seriesLength, p=[0.5, 0.5])) y = np.roll(x, echoStep) y[0:echoStep] = 0 x = x.reshape((batchSize ...