09.05.2023 Views

pdfcoffee

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Neural Network Foundations with TensorFlow 2.0

The next step is to insert your code (see Figure 35) in the appropriate colab notebook

cells and voila! You are good to go. Execute the code and happy deep learning

without the hassle of buying very expensive hardware to start your experiments!

Figure 35 contains an example of code in a Google notebook:

Figure 35: An example of code in a notebook

Sentiment analysis

What is the code we used to test colab? It is an example of sentiment analysis

developed on top of the IMDb dataset. The IMDb dataset contains the text of 50,000

movie reviews from the Internet Movie Database. Each review is either positive or

negative (for example, thumbs up or thumbs down). The dataset is split into 25,000

reviews for training and 25,000 reviews for testing. Our goal is to build a classifier

that is able to predict the binary judgment given the text. We can easily load IMDb

via tf.keras and the sequences of words in the reviews have been converted to

sequences of integers, where each integer represents a specific word in a dictionary.

We also have a convenient way of padding sentences to max_len, so that we can

use all sentences, whether short or long, as inputs to a neural network with an input

vector of fixed size (we will look at this requirement in more detail in Chapter 8,

Recurrent Neural Networks):

[ 42 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!