Book Image

Keras 2.x Projects

By : Giuseppe Ciaburro
Book Image

Keras 2.x Projects

By: Giuseppe Ciaburro

Overview of this book

Keras 2.x Projects explains how to leverage the power of Keras to build and train state-of-the-art deep learning models through a series of practical projects that look at a range of real-world application areas. To begin with, you will quickly set up a deep learning environment by installing the Keras library. Through each of the projects, you will explore and learn the advanced concepts of deep learning and will learn how to compute and run your deep learning models using the advanced offerings of Keras. You will train fully-connected multilayer networks, convolutional neural networks, recurrent neural networks, autoencoders and generative adversarial networks using real-world training datasets. The projects you will undertake are all based on real-world scenarios of all complexity levels, covering topics such as language recognition, stock volatility, energy consumption prediction, faster object classification for self-driving vehicles, and more. By the end of this book, you will be well versed with deep learning and its implementation with Keras. You will have all the knowledge you need to train your own deep learning models to solve different kinds of problems.
Table of Contents (13 chapters)

Implementing a DNN to label sentences

To labeling sentences, we'll use the Reuters newswire topics dataset. This is a dataset of 11,228 newswires from Reuters, labeled over 46 topics, published by Reuters in 1986. As with the IMDB dataset used in Chapter 6, Movie Reviews Sentiment Analysis Using Recurrent Neural Network, each wire is encoded as a sequence of word indexes.

Just as MNIST, Fashion-MNIST, and IMDB already used in the previous chapters, the Reuters dataset comes packaged as part of the Keras distribution, where there's also a detailed description of its content, as shown at the following link:

To import the Reuters dataset in the Python environment, the following code must be used:

from keras.datasets import reuters
(XTrain, YTrain), (XTest, YTest) = reuters.load_data(path="reuters.npz",