TensorFlow (Beginner): Classification of Movie Reviews

In this course, you will learn how to classify movie reviews as either positive or negative with the help of TensorFlow and Keras. We will use the popular IMDB dataset in this course. This is an introduction to how sentiment analysis can be done with the help of TensorFlow.

Start for Free
First 2 tasks free. Then, decide to pay $9.99 for the rest
TensorFlow (Beginner): Classification of Movie Reviews

Duration (mins)

Learners

5.0 / 5

Rating

Task List


We will cover the following tasks in 52 minutes:


Introduction

We will understand the Rhyme interface and our learning environment. You will get a virtual machine, you will need Jupyter Notebook and TensorFlow for this course and both of these are already installed on your virtual machine. Jupyter Notebooks are very popular with Data Science and Machine Learning Engineers as one can write code in cells and use other cells for documentation.


Importing Tensorflow and Dataset

We are going to use the IMDB movie reviews from the Internet Movie Database as our dataset. These are split into 25k for training and 25k reviews for testing. The training and testing sets consists of equal numbers of positive and negative reviews. This dataset comes packaged with Keras and a bulk of pre-processing that is typically required is already done on this pre-packaged dataset. The dataset is pre-processed where each example is an array of integers representing the words of the movie review. Each label is an integer value of either 0 (negative sentiment) or 1 (positive sentiment).


Preparing the Data

Before feeding into a Neural Network model, we need to convert our examples (the reviews) into tensors. A tensor is a generalization of vectors and matrices to potentially higher dimensions and has a shape and a base data type. We will need our example with the same shape and data type before we feed them into the model. We can do this by padding the arrays so they all have same lengths. We can find the example with max length and pad every other example by additional values so that all examples are of same length.


Building the Model

The model will consist of an input layer, an output layer and two hidden layers. The first layer is an embedding layer takes the integer-encoded vocabulary and looks up the embedding vector for each word-index. These vectors are learned as the model trains. A GlobalAveragePooling1D layer will then average the embeddings of all the words. The last layer is densely connected with a single output node. Using the sigmoid activation function, this value is a float between 0 and 1, representing a probability, or confidence level of the model.


Training the Model

We will use the fit method on our model to train the model. We will set epochs to 40 so that there are 40 iterations over all samples in the training data. While training, we will monitor the model’s loss and accuracy on our validation set. We will use a batch size of 512 samples.


Accuracy and Loss Plots

The evaluate method on our model will return loss and accuracy given a dataset. The model.fit() method returns a History object that contains a dictionary with everything that happened during training. We will use this dictionary to plot our model’s loss and accuracy for both the training set and validation set. This will help us understand the training process better.

Watch Preview

Preview the instructions that you will follow along in a hands on session in your browser.

Amit

About the Host (Amit)


I have been writing code since 1993, when I was 11, and my first passion project started with a database management software that I wrote for a local hospital. More recently, I wrote an award winning education Chatbot for a multi-billion-revenue company. I solved a recurrent problem for my client where they wanted to make basic cyber safety and privacy education accessible for their users. This bot enabled my client to reach out to their customers with personalised and real-time education. In the last one year, I’ve continued my interest in this field by constantly learning and growing in Machine Learning, NLP and Deep Learning. I'm very excited to share my variety of experience and learnings with you with the help of Rhyme.com.



Frequently Asked Questions


In Rhyme, all sessions are completely hands on. You don't just passively watch someone else. You use the software directly while following the host's (Amit) instructions. Using the software is the only way to achieve mastery. With the "Live Guide" option, you can ask for help and get immediate response.
Nothing! Just join through your web browser. Your host (Amit) has already installed all required software and configured all data.
You can go to https://rhyme.com/for-companies, sign up for free, and follow this visual guide How to use Rhyme to create your own sessions. If you have custom needs or company-specific environment, please email us at help@rhyme.com
Absolutely. We offer Rhyme for workgroups as well larger departments and companies. Universities, academies, and bootcamps can also buy Rhyme for their settings. You can select sessions and trainings that are mission critical for you and, as well, author your own that reflect your own needs and tech environments. Please email us at help@rhyme.com
Please email us at help@rhyme.com and we'll respond to you within one business day.

First 2 tasks free. Then, decide to pay $9.99 for the rest