Keras Deep Learning Cookbook

Book description

Leverage the power of deep learning and Keras to develop smarter and more efficient data models

Key Features

  • Understand different neural networks and their implementation using Keras
  • Explore recipes for training and fine-tuning your neural network models
  • Put your deep learning knowledge to practice with real-world use-cases, tips, and tricks

Book Description

Keras has quickly emerged as a popular deep learning library. Written in Python, it allows you to train convolutional as well as recurrent neural networks with speed and accuracy.

The Keras Deep Learning Cookbook shows you how to tackle different problems encountered while training efficient deep learning models, with the help of the popular Keras library. Starting with installing and setting up Keras, the book demonstrates how you can perform deep learning with Keras in the TensorFlow. From loading data to fitting and evaluating your model for optimal performance, you will work through a step-by-step process to tackle every possible problem faced while training deep models. You will implement convolutional and recurrent neural networks, adversarial networks, and more with the help of this handy guide. In addition to this, you will learn how to train these models for real-world image and language processing tasks.

By the end of this book, you will have a practical, hands-on understanding of how you can leverage the power of Python and Keras to perform effective deep learning

What you will learn

  • Install and configure Keras in TensorFlow
  • Master neural network programming using the Keras library
  • Understand the different Keras layers
  • Use Keras to implement simple feed-forward neural networks, CNNs and RNNs
  • Work with various datasets and models used for image and text classification
  • Develop text summarization and reinforcement learning models using Keras

Who this book is for

Keras Deep Learning Cookbook is for you if you are a data scientist or machine learning expert who wants to find practical solutions to common problems encountered while training deep learning models. A basic understanding of Python and some experience in machine learning and neural networks is required for this book.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Keras Deep Learning Cookbook
  3. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Get in touch
      1. Reviews
  6. Keras Installation
    1. Introduction
    2. Installing Keras on Ubuntu 16.04
      1. Getting ready
      2. How to do it...
        1. Installing miniconda
        2. Installing numpy and scipy
        3. Installing mkl
        4. Installing TensorFlow
        5. Installing Keras
        6. Using the Theano backend with Keras
    3. Installing Keras with Jupyter Notebook in a Docker image
      1. Getting ready
      2. How to do it...
        1. Installing the Docker container 
        2. Installing the Docker container with the host volume mapped
    4. Installing Keras on Ubuntu 16.04 with GPU enabled
      1. Getting ready
      2. How to do it...
        1. Installing cuda
        2. Installing cudnn
        3. Installing NVIDIA CUDA profiler tools interface development files
        4. Installing the TensorFlow GPU version
        5. Installing Keras
  7. Working with Keras Datasets and Models
    1. Introduction
    2. CIFAR-10 dataset
      1. How to do it...
    3. CIFAR-100 dataset
      1. How to do it...
        1. Specifying the label mode
    4. MNIST dataset
      1. How to do it...
    5. Load data from a CSV file
      1. How to do it...
    6. Models in Keras – getting started
      1. Anatomy of a model
      2. Types of models
    7. Sequential models
      1. How to do it...
        1. Create a Sequential model
        2. Compile the model
        3. Train the model 
        4. Evaluate the model
        5. Predict using the model
        6. Putting it all together
        7. Model inspection internals
        8. Model compilation internals
        9. Initialize the loss
        10. Model training
        11. Output of the sample 
    8. Shared layer models
      1. Introduction – shared input layer
      2. How to do it...
        1. Concatenate function
    9. Keras functional APIs
      1. How to do it...
      2. The output of the example
    10. Keras functional APIs – linking the layers
      1. How to do it...
        1. Model class
    11. Image classification using Keras functional APIs
      1. How to do it...
  8. Data Preprocessing, Optimization, and Visualization
    1. Feature standardization of image data
      1. Getting ready
      2. How to do it...
        1. Initializing ImageDataGenerator
    2. Sequence padding
      1. Getting ready
      2. How to do it...
        1. Pre-padding with default 0.0 padding
        2. Post-padding
        3. Padding with truncation
        4. Padding with a non-default value
    3. Model visualization
      1. Getting ready
      2. How to do it...
        1. Code listing
    4. Optimization 
    5. Common code for samples
    6. Optimization with stochastic gradient descent
      1. Getting ready
      2. How to do it...
    7. Optimization with Adam
      1. Getting ready
      2. How to do it...
    8. Optimization with AdaDelta
      1. Getting ready
      2. How to do it...
        1. Adadelta optimizer
    9. Optimization with RMSProp
      1. Getting ready
      2. How to do it...
  9. Classification Using Different Keras Layers
    1. Introduction
    2. Classification for breast cancer
      1. How to do it...
        1. Data processing
        2. Modeling
      2. Full code listing 
    3. Classification for spam detection
      1. How to do it...
        1. Data processing
        2. Modeling
      2. Full code listing
  10. Implementing Convolutional Neural Networks
    1. Introduction
    2. Cervical cancer classification
      1. Getting ready
      2. How to do it…
        1. Data processing
        2. Modeling
        3. Predictions
    3. Digit recognition
      1. Getting ready
      2. How to do it…
        1. Modeling
  11. Generative Adversarial Networks
    1. Introduction
      1. GAN overview
    2. Basic GAN
      1. Getting ready
      2. How to do it...
        1. Building a generator 
        2. Building a discriminator
        3. Initialize the GAN instance
        4. Training the GAN 
        5. Output plots
        6. Average metrics of the GAN
    3. Boundary seeking GAN
      1. Getting ready
      2. How to do it...
        1. Generator
        2. Discriminator
        3. Initializing the BGAN class
          1. Boundary seeking loss
        4. Train the BGAN
        5. Output the plots
          1. Iteration 0
          2. Iteration 10000
          3. Metrics of the BGAN model
          4. Plotting the metrics 
    4. DCGAN
      1. Getting ready
      2. How to do it...
        1. Generator
          1. Summary of the generator
          2. Training the generator
        2. Discriminator
          1. Build the discriminator
          2. Summary of the discriminator
          3. Compile the discriminator
        3. Combined model - generator and discriminator
        4. Train the generator using feedback from a discriminator
        5. Putting it all together
        6. The output of the program
          1. Average metrics of the model
  12. Recurrent Neural Networks
    1. Introduction
      1. The need for RNNs
    2. Simple RNNs for time series data
      1. Getting ready
        1. Loading the dataset
      2. How to do it…
        1. Instantiate a sequential model
    3. LSTM networks for time series data
      1. LSTM networks
      2. LSTM memory example
      3. Getting ready
      4. How to do it...
        1. Encoder
        2. LSTM configuration and model
        3. Train the model
        4. Full code listing 
    4. Time series forecasting with LSTM
      1. Getting ready
        1.  Load the dataset
      2. How to do it…
        1. Instantiate a sequential model
        2. Observation
    5. Sequence to sequence learning for the same length output with LSTM
      1. Getting ready
      2. How to do it…
        1. Training data 
        2. Model creation
        3. Model fit and prediction
  13. Natural Language Processing Using Keras Models
    1. Introduction
    2. Word embedding
      1. Getting ready
      2. How to do it...
        1. Without embeddings
        2. With embeddings
    3. Sentiment analysis
      1. Getting ready
      2. How to do it…
      3. Full code listing 
  14. Text Summarization Using Keras Models
    1. Introduction
    2. Text summarization for reviews
      1. How to do it…
        1. Data processing
        2. Encoder-decoder architecture
        3. Training
      2. See also
  15. Reinforcement Learning
    1. Introduction
    2. The CartPole game with Keras
      1. How to do it...
        1. Implementing the DQN agent
        2. The memory and remember
        3. The replay function
        4. The act function
        5. Hyperparameters for the DQN
        6. DQN agent class
        7. Training the agent
    3. Dueling DQN to play Cartpole 
      1. Getting ready
        1. DQN agent
          1. init method
        2. Setting the last layer of the network
          1. Dueling policy
        3. Init code base
        4. BoltzmannQPolicy
          1. Adjustment during training
        5. Sequential memory
      2. How to do it...
        1. Plotting the training and testing results
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Keras Deep Learning Cookbook
  • Author(s): Rajdeep Dua, Manpreet Singh Ghotra
  • Release date: October 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788621755