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 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.