Constructing the TensorFlow graph

As an initial step, we import the required Python libraries (you can see this in the neural_machine_translation.py file):

import tensorflow as tfimport numpy as npfrom sklearn.model_selection import train_test_splitimport data_utilsimport matplotlib.pyplot as plt

tensorflow and numpy should already be familiar to you. matplotlib is a handy python library used for visualizing data (you will see how we use it shortly). Then, we use the train_test_split function of sklearn to split the data into random train and test arrays.

We also import data_utils, which is used to access the data collections mentioned in the previous section.

An important modification to do before splitting the data is making sure each ...

Get Recurrent Neural Networks with Python Quick Start Guide 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.