O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Python Deep Learning Cookbook

Book Description

Solve different problems in modelling deep neural networks using Python, Tensorflow, and Keras with this practical guide

About This Book

  • Practical recipes on training different neural network models and tuning them for optimal performance
  • Use Python frameworks like TensorFlow, Caffe, Keras, Theano for Natural Language Processing, Computer Vision, and more
  • A hands-on guide covering the common as well as the not so common problems in deep learning using Python

Who This Book Is For

This book is intended for machine learning professionals who are looking to use deep learning algorithms to create real-world applications using Python. Thorough understanding of the machine learning concepts and Python libraries such as NumPy, SciPy and scikit-learn is expected. Additionally, basic knowledge in linear algebra and calculus is desired.

What You Will Learn

  • Implement different neural network models in Python
  • Select the best Python framework for deep learning such as PyTorch, Tensorflow, MXNet and Keras
  • Apply tips and tricks related to neural networks internals, to boost learning performances
  • Consolidate machine learning principles and apply them in the deep learning field
  • Reuse and adapt Python code snippets to everyday problems
  • Evaluate the cost/benefits and performance implication of each discussed solution

In Detail

Deep Learning is revolutionizing a wide range of industries. For many applications, deep learning has proven to outperform humans by making faster and more accurate predictions. This book provides a top-down and bottom-up approach to demonstrate deep learning solutions to real-world problems in different areas. These applications include Computer Vision, Natural Language Processing, Time Series, and Robotics.

The Python Deep Learning Cookbook presents technical solutions to the issues presented, along with a detailed explanation of the solutions. Furthermore, a discussion on corresponding pros and cons of implementing the proposed solution using one of the popular frameworks like TensorFlow, PyTorch, Keras and CNTK is provided. The book includes recipes that are related to the basic concepts of neural networks. All techniques s, as well as classical networks topologies. The main purpose of this book is to provide Python programmers a detailed list of recipes to apply deep learning to common and not-so-common scenarios.

Style and approach

Unique blend of independent recipes arranged in the most logical manner

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Errata
      3. Piracy
      4. Questions
  2. Programming Environments, GPU Computing, Cloud Solutions, and Deep Learning Frameworks
    1. Introduction
    2. Setting up a deep learning environment
      1. How to do it...
    3. Launching an instance on Amazon Web Services (AWS)
      1. Getting ready
      2. How to do it...
    4. Launching an instance on Google Cloud Platform (GCP)
      1. Getting ready
      2. How to do it...
    5. Installing CUDA and cuDNN
      1. Getting ready
      2. How to do it...
    6. Installing Anaconda and libraries
      1. How to do it...
    7. Connecting with Jupyter Notebooks on a server
      1. How to do it...
    8. Building state-of-the-art, production-ready models with TensorFlow
      1. How to do it...
    9. Intuitively building networks with Keras 
      1. How to do it...
    10. Using PyTorch’s dynamic computation graphs for RNNs
      1. How to do it...
    11. Implementing high-performance models with CNTK
      1. How to do it...
    12. Building efficient models with MXNet
      1. How to do it...
    13. Defining networks using simple and efficient code with Gluon
      1. How to do it...
  3. Feed-Forward Neural Networks
    1. Introduction
    2. Understanding the perceptron
      1. How to do it...
    3. Implementing a single-layer neural network
      1. How to do it...
    4. Building a multi-layer neural network
      1. How to do it...
    5. Getting started with activation functions
      1. How to do it...
    6. Experiment with hidden layers and hidden units
      1. How to do it...
      2. There's more...
    7. Implementing an autoencoder
      1. How to do it...
    8. Tuning the loss function
      1. How to do it...
    9. Experimenting with different optimizers
      1. How to do it...
    10. Improving generalization with regularization
      1. How to do it...
    11. Adding dropout to prevent overfitting
      1. How to do it...
  4. Convolutional Neural Networks
    1. Introduction
      1. Getting started with filters and parameter sharing
      2. How to do it...
    2. Applying pooling layers
      1. How to do it...
    3. Optimizing with batch normalization
      1. How to do it...
    4. Understanding padding and strides
      1. How to do it...
    5. Experimenting with different types of initialization
      1. How to do it...
    6. Implementing a convolutional autoencoder
      1. How to do it...
    7. Applying a 1D CNN to text
      1. How to do it...
  5. Recurrent Neural Networks
    1. Introduction
    2. Implementing a simple RNN
      1. How to do it...
    3. Adding Long Short-Term Memory (LSTM)
      1. How to do it...
    4. Using gated recurrent units (GRUs)
      1. How to do it...
    5. Implementing bidirectional RNNs
      1. How to do it...
    6. Character-level text generation
      1. How to do it...
  6. Reinforcement Learning
    1. Introduction
    2. Implementing policy gradients
      1. Getting ready
      2. How to do it...
    3. Implementing a deep Q-learning algorithm
      1. Getting ready
      2. How to do it...
  7. Generative Adversarial Networks
    1. Introduction
    2. Understanding GANs
      1. How to do it...
    3. Implementing Deep Convolutional GANs (DCGANs) 
      1. How to do it...
    4. Upscaling the resolution of images with Super-Resolution GANs (SRGANs)
      1. How to do it...
  8. Computer Vision
    1. Introduction
    2. Augmenting images with computer vision techniques
      1. How to do it...
    3. Classifying objects in images
      1. How to do it...
    4. Localizing an object in images
      1. How to do it...
      2. Real-time detection frameworks
    5. Segmenting classes in images with U-net
      1. How to do it...
    6. Scene understanding (semantic segmentation)
      1. How to do it...
    7. Finding facial key points
      1. How to do it...
    8. Recognizing faces
      1. How to do it...
    9. Transferring styles to images
      1. How to do it...
  9. Natural Language Processing
    1. Introduction
    2. Analyzing sentiment
      1. How to do it...
    3. Translating sentences
      1. How to do it...
    4. Summarizing text
      1. How to do it...
  10. Speech Recognition and Video Analysis
    1. Introduction
    2. Implementing a speech recognition pipeline from scratch
      1. How to do it...
    3. Identifying speakers with voice recognition
      1. How to do it...
    4. Understanding videos with deep learning
      1. How to do it...
  11. Time Series and Structured Data
    1. Introduction
    2. Predicting stock prices with neural networks
      1. How to do it...
    3. Predicting bike sharing demand
      1. How to do it...
    4. Using a shallow neural network for binary classification
      1. How to do it...
  12. Game Playing Agents and Robotics
    1. Introduction
    2. Learning to drive a car with end-to-end learning
      1. Getting started
      2. How to do it...
    3. Learning to play games with deep reinforcement learning
      1. How to do it...
    4. Genetic Algorithm (GA) to optimize hyperparameters
      1. How to do it..
  13. Hyperparameter Selection, Tuning, and Neural Network Learning
    1. Introduction
    2. Visualizing training with TensorBoard and Keras
      1. How to do it...
    3. Working with batches and mini-batches
      1. How to do it...
    4. Using grid search for parameter tuning
      1. How to do it...
    5. Learning rates and learning rate schedulers
      1. How to do it...
    6. Comparing optimizers
      1. How to do it...
    7. Determining the depth of the network
    8. Adding dropouts to prevent overfitting
      1. How to do it...
    9. Making a model more robust with data augmentation
      1. How to do it...
      2. Leveraging test-time augmentation (TTA) to boost accuracy
  14. Network Internals
    1. Introduction
    2. Visualizing training with TensorBoard
      1. How to do it..
      2. Visualizing the network architecture with TensorBoard
    3. Analyzing network weights and more
      1. How to do it...
    4. Freezing layers
      1. How to do it...
    5. Storing the network topology and trained weights
      1. How to do it... 
  15. Pretrained Models
    1. Introduction
    2. Large-scale visual recognition with GoogLeNet/Inception
      1. How to do it...
    3. Extracting bottleneck features with ResNet
      1. How to do it...
    4. Leveraging pretrained VGG models for new classes
      1. How to do it...
    5. Fine-tuning with Xception
      1. How to do it...