How to do it...

We will proceed with the recipe as follows:

  1. We will start by loading the necessary libraries and starting a graph session, as follows:
import tensorflow as tf 
import matplotlib.pyplot as plt 
import numpy as np 
import random 
import os 
import pickle 
import string 
import requests 
import collections 
import io 
import tarfile 
import urllib.request 
import text_helpers 
from nltk.corpus import stopwords 
sess = tf.Session() 
  1. We will load the movie review corpus, just as we did in the previous two recipes. Use the following code to do this:
texts, target = text_helpers.load_movie_data() 
  1. We will declare the model parameters, like so:
batch_size = 500 vocabulary_size = 7500 generations = 100000 model_learning_rate = 0.001 embedding_size ...

Get TensorFlow Machine Learning Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.