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)

What this book covers

Chapter 1, Getting Started with Keras, covers an overview of the Keras environment. We will learn how to install and configure Keras, how to work with the Keras library, and we will discover the basic concepts of the Keras architecture. We will also see how Keras uses TensorFlow as its tensor manipulation library, as well as how we can switch the Keras backend from TensorFlow (which is the default option) to Theano and CNTK, which are other available frameworks. Finally, we will understand the different types of Keras models, looking at model classes used with sequential layers and model classes used with functional API layers.

Chapter 2, Modeling Real Estate Using Regression Analysis, looks at the different types of regression techniques. We will apply regression methods to your data and understand how the regression algorithm works. We will then understand the basic concepts that multiple linear regression methods use to fit equations to data using the Keras layers. We will also learn how to evaluate the model's performance and how to tune a model to improve the model's performance.

Chapter 3, Heart Disease Classification with Neural Networks, covers the basic concept of the classification problem. We will look at a practical case of heart disease classification using Keras. The basic concepts of classification methods and how to implement them in the Keras environment will be covered. How to import and organize data for neural network classification analysis, and how to implement a Keras classification model using a real-life example, will be explored.

Chapter 4, Concrete Quality Prediction Using Deep Neural Networks, covers the basic concepts of multilayer neural networks (MNNs) and how to implement them in the Keras environment. Many variations of MNNs will be introduced, such as CNNs, RNNs, deep belief networks (DBNs), and restricted Boltzmann machines (RBMs). We will look at an example of a multilayered artificial network. We will learn about how to implement a model that allows us to calculate the compressive strength of concrete according to the ingredients used in the mixture. Finally, we will see how to remove outliers to improve the performance of the model.

Chapter 5, Fashion Article Recognition Using Convolutional Neural Networks, covers the connection pattern between neurons in CNNs, which is inspired by the structure of the visual cortex in the brain. We will see how the individual neurons present in this part of the brain (visual cortex) respond to certain stimuli in a narrow region of observation called the receptive field. The receptive fields of different neurons are partially overlapped so that together they cover the entire field of view. The response of a single neuron to stimuli taking place in its receptive field can be mathematically approximated by a convolution operation. In this chapter, a CNN will be trained to solve a pattern recognition problem.

Chapter 6, Movie Review Sentiment Analysis Using Recurrent Neural Networks, covers the RNN, which is a neural model wherein a bidirectional flow of information is present. In other words, while the propagation of signals in feedforward networks takes place only in a continuous manner in a direction from inputs to outputs, RNNs are different. In them, this propagation can also occur from a neural layer following a previous one, or between neurons belonging to the same layer, and even between a neuron and itself. In this chapter, an RNN is used to solve a language recognition problem.

Chapter 7, Stock Volatility Forecasting Using Long-Short Term Memory, covers the basic concepts of forecasting techniques. Forecast horizon and several forecast methods will be analyzed. Time series data will also be dealt with. A time series constitutes a sequence of observations of a phenomenon. In a time series, we can identify several components—trend, seasonality, cycle, and residual. We will learn how to remove seasonality from a time series with a practical example. We will address the most-used models to represent time seriesAR, MA, ARMA, and ARIMA. For each one, the basic concepts will be analyzed and then a mathematical formulation of the model will be provided. Finally, a Keras LSTM model for time series analysis will be proposed. Using a practical example, we will see how to deal with a time series regression problem with an RNN model of the LSTM type.

Chapter 8, Reconstruction of Handwritten Digital Images Using Autoencoders, looks at autoencoders. The autoencoder is a neural network whose purpose is to code its input into small dimensions, where the result obtained helps to reconstruct the input itself. Autoencoders are made up of the union of two subnets: an encoder and a decoder. The encoder and the decoder will be differentiable with respect to the distance function, so the parameters of the encoding/decoding functions can be optimized to minimize the loss of reconstruction, using the stochastic gradient. In this chapter, an autoencoder is used to reconstruct handwritten digit images.

Chapter 9, Robot Control System Using Deep Reinforcement Learning, introduces the basic concepts of reinforcement learning and how to use these techniques to control a mechanical system. To start with, an overview of robot control will be addressed. Then, the OpenAI Gym library will be introduced, which helps us to implement algorithms based on reinforcement learning. It includes a growing collection of benchmark issues that are shared on a common interface, and a website where people can share their results and compare algorithm performance. We will explore the different environments available and how to install the library. Finally, the CartPole system will be used to implement Q-learning and Deep Q-learning algorithms. The CartPole system is a classic problem of reinforcement learning. The system consists of a pole (which acts like an inverted pendulum) attached to a cart via a joint. The system is controlled by applying a force of +1 or -1 to the cart. The force applied to the cart can be controlled, and the objective is to swing the pole upward and stabilize it.

Chapter 10, Reuters Newswire Topics Classifier in Keras, covers natural language processing (NLP), which is the process of automatically processing information that is written or spoken in a natural language using an electronic calculator. This process is made particularly difficult and complex due to the intrinsic ambiguity of human language. In this chapter, Keras layers are used to build a model to classify Reuter's newswire topics. Data is available from a dataset that contains 11,228 newswires from Reuters with 46 labeled topics. This dataset is from Keras, and each wire is encoded as a sequence of word indexes.

Chapter 11, What is Next?, will summarize what will have been covered in this book and what the next steps are that you can take. You will learn how to apply the skills you have gained to other projects, including real-life challenges in building and deploying Keras deep learning models and other common technologies that data scientists often use. By the end of this chapter, you will have a better understanding of the real-life challenges in building and deploying machine learning models, and the additional resources and technologies that you can use to sharpen your machine learning skills.