Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Neural Network Programming with TensorFlow

You're reading from  Neural Network Programming with TensorFlow

Product type Book
Published in Nov 2017
Publisher Packt
ISBN-13 9781788390392
Pages 274 pages
Edition 1st Edition
Languages
Authors (2):
Manpreet Singh Ghotra Manpreet Singh Ghotra
Profile icon Manpreet Singh Ghotra
Rajdeep Dua Rajdeep Dua
Profile icon Rajdeep Dua
View More author details
Toc

Table of Contents (17) Chapters close

Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Maths for Neural Networks 2. Deep Feedforward Networks 3. Optimization for Neural Networks 4. Convolutional Neural Networks 5. Recurrent Neural Networks 6. Generative Models 7. Deep Belief Networking 8. Autoencoders 9. Research in Neural Networks 10. Getting started with TensorFlow

Sentiment analysis


We will now write an app to predict sentiments of a movie review. Reviews are made up of a sequence of words and the order of words encodes very useful information to predict sentiment. The first step is to map words to word embeddings. The second step is the RNN that receives a sequence of vectors as input and considers the order of the vectors to generate the prediction.

Word embeddings

We will now train a neural network for word to vector representation. Given a particular word in the center of a sentence, which is the input word, we look at the words nearby. The network is going to tell us the probability for every word in our vocabulary of being the nearby word that we choose.

import time
import tensorflow as tf
import numpy as np
import utility
from tqdm import tqdm
from urllib.request import urlretrieve
from os.path import isfile, isdir
import zipfile
from collections import Counter
import random

dataDir = 'data'
dataFile = 'text8.zip'
datasetName = 'text 8 data set...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime