How to do it...

We will proceed with the recipe as follows:

  1. We will start by loading the necessary libraries. This time, we are loading the scikit-learn TF-IDF preprocessing library for our texts. Use the following code to do this:
import tensorflow as tf 
import matplotlib.pyplot as plt 
import csv 
import numpy as np 
import os 
import string 
import requests 
import io 
import nltk 
from zipfile import ZipFile 
from sklearn.feature_extraction.text import TfidfVectorizer
  1. We will start a graph session and declare our batch size and maximum feature size for our vocabulary:
sess = tf.Session() 
batch_size= 200 
max_features = 1000 
  1. Next, we will load the data, either from the web or from our temp data folder if we have saved it before. Use the following ...

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.