This is the code repository for Advanced Deep Learning with TensoFlow 2 and Keras, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.
Please note that the code examples have been updated to support TensorFlow 2.0 Keras API only.
Advanced Deep Learning with TensorFlow 2 and Keras, Second Edition is a completely updated edition of the bestselling guide to the advanced deep learning techniques available today. Revised for TensorFlow 2.x, this edition introduces you to the practical side of deep learning with new chapters on unsupervised learning using mutual information, object detection (SSD), and semantic segmentation (FCN and PSPNet), further allowing you to create your own cutting-edge AI projects.
Using Keras as an open-source deep learning library, the book features hands-on projects that show you how to create more effective AI with the most up-to-date techniques.
Starting with an overview of multi-layer perceptrons (MLPs), convolutional neural networks (CNNs), and recurrent neural networks (RNNs), the book then introduces more cutting-edge techniques as you explore deep neural network architectures, including ResNet and DenseNet, and how to create autoencoders. You will then learn about GANs, and how they can unlock new levels of AI performance.
Next, you’ll discover how a variational autoencoder (VAE) is implemented, and how GANs and VAEs have the generative power to synthesize data that can be extremely convincing to humans. You'll also learn to implement DRL such as Deep Q-Learning and Policy Gradient Methods, which are critical to many modern results in AI.
It is recommended to run within conda enviroment. Pls download Anacoda from: Anaconda. To install anaconda:
sh <name-of-downloaded-Anaconda3-installer>
A machine with at least 1 NVIDIA GPU (1060 or better) is required. The code examples have been tested on 1060, 1080Ti, RTX 2080Ti, V100, RTX Quadro 8000 on Ubuntu 18.04 LTS. Below is a rough guide to install NVIDIA driver and CuDNN to enable GPU support.
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo ubuntu-drivers autoinstall
sudo reboot
nvidia-smi
At the time of writing, nvidia-smi
shows the NVIDIA driver version is 440.64 and CUDA version is 10.2.
We are almost there. The last set of packages must be installed as follows. Some steps might require sudo
access.
conda create --name packt
conda activate packt
cd <github-dir>
git clone https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras
cd Advanced-Deep-Learning-with-Keras
pip install -r requirements.txt
sudo apt-get install python-pydot
sudo apt-get install ffmpeg
Test if a simple model can be trained without errors:
cd chapter1-keras-quick-tour
python3 mlp-mnist-1.3.2.py
The final output shows the accuracy of the trained model on MNIST test dataset is about 98.2%.
If you are having problems with CUDA libraries (ie tf
could not load or find libcudart.so.10.X
), TensorFlow and CUDA libraries can be installed together using conda:
pip uninstall tensorflow-gpu
conda install -c anaconda tensorflow-gpu
Advanced Deep Learning with TensorFlow 2 and Keras code examples used in the book.
Sample outputs for random digits:
Sample outputs for random cifar10 images:
Sample outputs for random digits:
Sample outputs for digits 0 to 9:
Sample outputs for random digits:
Sample outputs for random digits:
Sample outputs for digits 0 to 9:
Sample outputs for digits 0 to 9:
Sample outputs for digits 0 to 9:
Sample outputs for random cifar10 images:
Sample outputs for MNIST to SVHN:
Generated MNIST by navigating the latent space:
Mnih, Volodymyr, et al. "Human-level control through deep reinforcement learning." Nature 518.7540 (2015): 529
DQN on Cartpole Environment:
Sutton and Barto, Reinforcement Learning: An Introduction
Policy Gradient on MountainCar Continuous Environment:
Single-Shot Detection on 3 Objects
Semantic Segmentation
If you find this work useful, please cite:
@book{atienza2020advanced,
title={Advanced Deep Learning with TensorFlow 2 and Keras: Apply DL, GANs, VAEs, deep RL, unsupervised learning, object detection and segmentation, and more},
author={Atienza, Rowel},
year={2020},
publisher={Packt Publishing Ltd}
}