Training an RNN model in TensorFlow

  1. Import the needed Python packages and define a few constants:
import numpy as npimport tensorflow as tffrom tensorflow.contrib.rnn import *import matplotlib.pyplot as pltnum_neurons = 100num_inputs = 1num_outputs = 1symbol = 'goog' # amznepochs = 500seq_len = 20 learning_rate = 0.001

numpy (http://www.numpy.org) is the most popular Python library for n-dimensional array operation, and Matplotlib (https://matplotlib.org) is the leading Python 2D plotting library. We'll use numpy to process the dataset and Matplotlib to visualize the stock prices and predictions. num_neurons is the number of neurons the RNN, or more accurately, an RNN cell, has at each time step - each neuron receives both the input element ...

Get Intelligent Mobile Projects with TensorFlow 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.