Python Deep Learning Projects

Book description

Insightful practical projects to master deep learning and neural network architectures using Python, Keras and MXNet

About This Book

  • Rich projects on computer vision, NLP, and image processing
  • Build your own neural network and explore innumerable possibilities with deep learning
  • Explore the power of Python for deep learning in various scenarios using insightful projects

Who This Book Is For

This book is for developers, data scientists, or enthusiasts, who have sound knowledge of python programming, basics of machine learning, and want to break into deep learning, either for opening a new career opportunity or for realizing their own AI projects.

What You Will Learn

  • Set up a Deep Learning development environment on AWS, using GPU-powered instances and the Deep Learning AMI
  • Implement Sequence to Sequence Networks for modeling natural language processing
  • Develop an end-to-end speech recognition system
  • Build a system for pixel-wise semantic labeling of an image
  • Develop a system that generates images and their regions

In Detail

Deep Learning has quietly revolutionized every field of Artificial Intelligence, enabling the development of applications that a few years ago were considered almost impossible.

This book will provide all the knowledge needed to implement complex deep learning projects in the field of computational linguistics and computer vision. Each new project will build upon the experience and knowledge accumulated in the previous ones, allowing the reader to progressively master the subject.

You will learn neural network models implementing a text classifier system using Recurrent Neural network model (RNN) and optimize it to understand the shortcomings you might come across while implementing a simple deep learning system. If you are looking to implement intelligent systems like Automatic Machine Translation, Handwriting Generation, Character Text Generation, Object Classification in Photographs, Colorization of Images, Image Caption Generation, Character Text Generation or Automatic Game Playing into your application then this book is for you.

By the end of this book, you will come across various Recurrent and Convolutional Neural network implementations with practical hands-on to modeling concepts like regularization, Gradient clipping, and gradient normalization, LSTM, Bidirectional RNN's through a series engaging projects.

Style and approach

One stop guide to gain deep learning knowledge and skills by working on authentic, engaging and complex projects with detailed end-to-end implementations.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Python Deep Learning Projects
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  6. 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. Get in touch
      1. Reviews
  7. Building Deep Learning Environments
    1. Building a common DL environment
      1. Get focused and into the code!
    2. DL environment setup locally
      1. Downloading and installing Anaconda
        1. Installing DL libraries
    3. Setting up a DL environment in the cloud
    4. Cloud platforms for deployment 
      1. Prerequisites
      2. Setting up the GCP
    5. Automating the setup process
    6. Summary
  8. Training NN for Prediction Using Regression
    1. Building a regression model for prediction using an MLP deep neural network
    2. Exploring the MNIST dataset
    3. Intuition and preparation
      1. Defining regression
      2. Defining the project structure
    4. Let's code the implementation!
      1. Defining hyperparameters
      2. Model definition
      3. Building the training loop
        1. Overfitting and underfitting 
      4. Building inference
    5. Concluding the project
    6. Summary
  9. Word Representation Using word2vec
    1. Learning word vectors
      1. Loading all the dependencies
        1. Preparing the text corpus
        2. Defining our word2vec model
        3. Training the model
        4. Analyzing the model
        5. Plotting the word cluster using the t-SNE algorithm
    2. Visualizing the embedding space by plotting the model on TensorBoard
    3. Building language models using CNN and word2vec
      1. Exploring the CNN model
        1. Understanding data format
        2. Integrating word2vec with CNN
        3. Executing the model 
      2. Deploy the model into production
    4. Summary
  10. Building an NLP Pipeline for Building Chatbots
    1. Basics of NLP pipelines
      1. Tokenization
      2. Part-of-Speech tagging
        1. Extracting nouns
        2. Extracting verbs
      3. Dependency parsing
      4. NER
    2. Building conversational bots
      1. What is TF-IDF?
        1. Preparing the dataset
        2. Implementation
          1. Creating the vectorizer
          2. Processing the query
          3. Rank results
      2. Advanced chatbots using NER
        1. Installing Rasa
        2. Preparing dataset
        3. Training the model
        4. Deploying the model
    3. Serving chatbots
    4. Summary
  11. Sequence-to-Sequence Models for Building Chatbots
    1. Introducing RNNs
      1. RNN architectures
    2. Implementing basic RNNs
      1. Importing all of the dependencies
      2. Preparing the dataset
      3. Hyperparameters
      4. Defining a basic RNN cell model
      5. Training the RNN Model
      6. Evaluation of the RNN model
    3. LSTM architecture
    4. Implementing an LSTM model
      1. Defining our LSTM model
      2. Training the LSTM model
      3. Evaluation of the LSTM model
    5. Sequence-to-sequence models
      1. Data preparation
      2. Defining a seq2seq model
      3. Hyperparameters
      4. Training the seq2seq model
      5. Evaluation of the seq2seq model
    6. Summary
  12. Generative Language Model for Content Creation
    1. LSTM for text generation
      1. Data pre-processing
      2. Defining the LSTM model for text generation
      3. Training the model
      4. Inference and results
    2. Generating lyrics using deep (multi-layer) LSTM
      1. Data pre-processing
      2. Defining the model
      3. Training the deep TensorFlow-based LSTM model
      4. Inference
      5. Output
    3. Generating music using a multi-layer LSTM
      1. Pre-processing data
      2. Defining the model and training
      3. Generating music
    4. Summary
  13. Building Speech Recognition with DeepSpeech2
    1. Data preprocessing
      1. Corpus exploration
      2. Feature engineering
      3. Data transformation
    2. DS2 model description and intuition
    3. Training the model
    4. Testing and evaluating the model
    5. Summary
  14. Handwritten Digits Classification Using ConvNets
    1. Code implementation
      1. Importing all of the dependencies
      2. Exploring the data
      3. Defining the hyperparameters
      4. Building and training a simple deep neural network
        1. Fitting a model
        2. Evaluating a model
        3. MLP – Python file
      5. Convolution
      6. Convolution in Keras
        1. Fitting the model
        2. Evaluating the model
        3. Convolution – Python file
      7. Pooling
        1. Fitting the model
        2. Evaluating the model
        3. Convolution with pooling – Python file
      8. Dropout
        1. Fitting the model
        2. Evaluating the model
        3. Convolution with pooling – Python file
      9. Going deeper
        1. Compiling the model
        2. Fitting the model
        3. Evaluating the model
        4. Convolution with pooling and Dropout – Python file
      10. Data augmentation
        1. Using ImageDataGenerator
        2. Fitting ImageDataGenerator
        3. Compiling the model
        4. Fitting the model
        5. Evaluating the model
        6. Augmentation – Python file
      11. Additional topic – convolution autoencoder
        1. Importing the dependencies
        2. Generating low-resolution images
        3. Scaling
        4. Defining the autoencoder
        5. Fitting the autoencoder
        6. Loss plot and test results
        7. Autoencoder – Python file
    2. Conclusion
    3. Summary
  15. Object Detection Using OpenCV and TensorFlow
    1. Object detection intuition
      1. Improvements in object detection models
    2. Object detection using OpenCV
      1. A handcrafted red object detector
        1. Installing dependencies 
        2. Exploring image data
        3. Normalizing the image
        4. Preparing a mask
        5. Post-processing of a mask
        6. Applying a mask
    3. Object detection using deep learning
      1. Quick implementation of object detection
        1. Installing all the dependencies
        2. Implementation
        3. Deployment
      2. Object Detection In Real-Time Using YOLOv2
        1. Preparing the dataset
          1. Using the pre-existing COCO dataset
          2. Using the custom dataset
        2. Installing all the dependencies
        3. Configuring the YOLO model
        4. Defining the YOLO v2 model
        5. Training the model
        6. Evaluating the model
    4. Image segmentation
      1. Importing all the dependencies
      2. Exploring the data
        1. Images
        2. Annotations
      3. Preparing the data
        1. Normalizing the image 
        2. Encoding
        3. Model data 
      4. Defining hyperparameters
      5. Define SegNet
        1. Compiling the model
        2. Fitting the model
        3. Testing the model
    5. Conclusion
    6. Summary
  16. Building Face Recognition Using FaceNet
    1. Setup environment
      1. Getting the code
      2. Building the Docker image
      3. Downloading pre-trained models
    2. Building the pipeline
    3. Preprocessing of images
      1. Face detection
      2. Aligning faces
      3. Feature extraction
      4. Execution on Docker
    4. Training the classifier
    5. Evaluation
    6. Summary
  17. Automated Image Captioning
    1. Data preparation
      1. Initialization
      2. Download and prepare the MS-COCO dataset
      3. Data preparation for a deep CNN encoder
        1. Performing feature extraction
      4. Data prep for a language generation (RNN) decoder
      5. Setting up the data pipeline
    2. Defining the captioning model
      1. Attention
      2. CNN encoder
      3. RNN decoder
      4. Loss function
    3. Training the captioning model
    4. Evaluating the captioning model
    5. Deploying the captioning model
    6. Summary
  18. Pose Estimation on 3D models Using ConvNets
    1. Code implementation
    2. Importing the dependencies
      1. Exploring and pre-processing the data
      2. Preparing the data
        1. Cropping
        2. Resizing
        3. Plotting the joints and limbs
        4. Transforming the images
      3. Defining hyperparameters for training
      4. Building the VGG16 model
        1. Defining the VGG16 model
        2. Training loop
        3. Plot training and validation loss
      5. Predictions
      6. Scripts in modular form
        1. Module 1 – crop_resize_transform.py
        2. Module 2 – plotting.py
        3. Module 3 – test.py
        4. Module 4 – train.py
    3. Conclusion
    4. Summary
  19. Image Translation Using GANs for Style Transfer
    1. Let's code the implementation!
      1. Importing all of the dependencies
      2. Exploring the data
      3. Preparing the data
        1. Type conversion, centering, and scaling
        2. Masking/inserting noise
        3. Reshaping
        4. MNIST classifier
      4. Defining hyperparameters for GAN
      5. Building the GAN model components
        1. Defining the generator
        2. Defining the discriminator
        3. Defining the DCGAN
      6. Training GAN
        1. Plotting the training – part 1
        2. Plotting the training – part 2
        3. Training loop
      7. Predictions
        1. CNN classifier predictions on the noised and generated images
      8. Scripts in modular form
        1. Module 1 – train_mnist.py
        2. Module 2 – training_plots.py
        3. Module 3 – GAN.py
        4. Module 4 – train_gan.py
    2. The conclusion to the project
    3. Summary
  20. Develop an Autonomous Agent with Deep R Learning
    1. Let's get to the code!
    2. Deep Q-learning
      1. Importing all of the dependencies
      2. Exploring the CartPole game
        1. Interacting with the CartPole game
          1. Loading the game
          2. Resetting the game
          3. Playing the game
        2. Q-learning
      3. Defining hyperparameters for Deep Q Learning (DQN)
      4. Building the model components
        1. Defining the agent
        2. Defining the agent action
        3. Defining the memory
        4. Defining the performance plot
        5. Defining replay
        6. Training loop
        7. Testing the DQN model
      5. Deep Q-learning scripts in modular form
        1. Module 1 – hyperparameters_dqn.py
        2. Module 2 – agent_replay_dqn.py
        3. Module 3 – test_dqn.py
        4. Module 4 – train_dqn.py
    3. Deep SARSA learning
      1. SARSA learning
        1. Importing all of the dependencies
        2. Loading the game environment
        3. Defining the agent
        4. Training the agent
        5. Testing the agent
      2. Deep SARSA learning script in modular form
    4. The conclusion to the project
    5. Summary
  21. Summary and Next Steps in Your Deep Learning Career
    1. Python deep learning – building the foundation – two projects
      1. Chapter 1 – Building the Deep Learning Environment
      2. Chapter 2 – Training NN for Prediction Using Regression
    2. Python deep learning – NLP – 5 projects
      1. Chapter 3 – Word Representations Using word2vec
      2. Chapter 4 – Build an NLP Pipeline for Building Chatbots
      3. Chapter 5 – Sequence-to-Sequence Models for Building Chatbots
      4. Chapter 6 – Generative Language Model for Content Creation
      5. Chapter 7 – Building Speech Recognition with DeepSpeech2
    3. Deep learning – computer vision – 6 projects
      1. Chapter 8 – Handwritten Digit Classification Using ConvNets
      2. Chapter 9 – Object Detection Using OpenCV and TensorFlow
      3. Chapter 10 – Building Facial Recognition Using OpenFace
      4. Chapter 11 – Automated Image Captioning
      5. Chapter 12 – Pose Estimation on 3D Models Using ConvNets
      6. Chapter 13 – Image Translation Using GANs for Style Transfer
    4. Python deep learning – autonomous agents – 1 project
      1. Chapter 14 – Develop an Autonomous Agent with Deep Reinforcement Learning
    5. Next steps – AI strategy and platforms
      1. AI strategy
      2. Deep learning platforms – TensorFlow Extended (TFX)
    6. Conclusion and thank you!
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Python Deep Learning Projects
  • Author(s): Matthew Lamons, Rahul Kumar, Abhishek Nagaraja
  • Release date: October 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788997096