Deep learning with TensorFlow and Keras
Minimum price
Suggested price

Deep learning with TensorFlow and Keras

About the Book

Topics covered include Convolutional Neural networks, Recurrent Neural Networks, TensorBoard, Transfer learning, custom training loops, and Keras Functional API.

About the Author

Derrick Mwiti
Derrick Mwiti

Derrick Mwiti is a Data Scientist with expertise in machine learning, data analytics, and visualization. He enjoys working with data to derive meaningful insights that help business executives in decision making. He is an alumnus of the prestigious Meltwater Entrepreneurial School of Technology(MEST). Derrick is an avid contributor to the data science community. He does so by contributing to popular data science publications such as KDnuggets, Heartbeat, and Datacamp just to mention a few. He holds a Bachelor of Science in Mathematics and Computer Science from Multimedia University.

Table of Contents

How to build artificial neural networks with Keras and TensorFlow

What is deep learning?

What is an activation function?

Sigmoid function

Softmax activation function

Rectified linear unit (ReLU)

How does a neural network learn?

Gradient descent

How backpropagation works

What is TensorFlow?

Why TensorFlow?

TensorFlow vs. Keras

TensorFlow basics



Automatic differentiation

How TensorFlow works

How TensorFlow models are defined

How to train artificial neural networks with Keras

Data pre-processing

Data transformation

How to build the artificial neural network

How to visualize model performance

Add dropout regularization to fight overfitting

How to accelerate network training with batch normalization

How to stop model training at the right time with early stopping

How to save the best model with checkpoints

Make predictions on the test set

Check the confusion matrix

Make a single prediction

How to save and load Keras models

How to evaluate the Keras model with cross-validation

How to tune model hyperparameters in Keras

How to tune the network parameters

How to build CNN in TensorFlow

What is CNN?

How do CNNs work?



Apply ReLU


Deep learning with TensorFlow and Keras

Dropout regularization


Full connection

Activation function

Convolutional Neural Networks (CNN) in TensorFlow

How to install TensorFlow

How to confirm TensorFlow is installed

What are Keras and tf.keras?

Develop multilayer CNN models

Data preprocessing

Model definition

Compiling the model

Train the model

How to plot model learning curves

Model evaluation

How to halt training at the right time with Early Stopping

How to accelerate training with batch normalization

How to create custom callbacks for TensorFlow CNN

How to visualize a deep learning model

How to save and load your model

Running CNNs with TensorFlow in the real world

Loading the images

Generate a

Buffered dataset prefetching

Image augmentation

Model definition

Compiling the model

Training the model

Model evaluation

Monitoring the model’s performance

Visualize CNN graph with TensorBoard

How to profile with TensorBoard

Making predictions

CNN architectures

Model without weights

Model with weights

TensorFlow Recurrent Neural Networks

What is a Recurrent Neural Network?

Backpropagation through time

Types of Recurrent Neural Networks

Weaknesses of RNNs

1. Vanishing gradient problem

2. Exploding gradient problem

Long-Short Term Memory (LSTM)

Applications of LSTM

Bidirectional LSTM

Time series analysis with LSTM in TensorFlow

Create LSTM network in Keras

Compile the LSTM model

LSTM model evaluation

Intent classification with LSTM

Text vectorization

Create LSTM network

LSTM model evaluation

Transfer learning guide

What is transfer learning?

Advantages of using pre-trained models

Types of transfer learning

Inductive transfer learning

Unsupervised transfer learning

Transductive transfer learning

Homogeneous transfer learning

Heterogeneous transfer learning

What is the difference between transfer learning and fine-tuning?

Why use transfer learning?

When do you use transfer learning?

When does transfer learning not work?

How to implement transfer learning?

Transfer learning in 6 steps

Step 1: Obtain the pre-trained model

Step 2: Create a base model

Step 3: Freeze layers so they don’t change during training

Step 4: Add new trainable layers

Step 5: Train the new layers on the dataset

Step 6: Improve the model via fine-tuning

Where to find pre-trained models?

Keras pre-trained models

Transfer learning using TensorFlow Hub

Pretrained word embeddings

Stanford’s GloVe pre-trained word embeddings

Below is an example of an implementation for the GloVe pre-trained word embeddings.

Google’s Word2vec


Hugging Face

Transfer learning with PyTorch

How can you use pre-trained models?


Feature extraction


Example of transfer learning for images with Keras

Transfer learning with image data

Getting the dataset

Loading the dataset from a directory

Data pre-processing

Create a base model from the pre-trained Inception model

Create the final dense layer

Train the model

Fine-tuning the model

Example of transfer learning with natural language processing

Pretrained word embeddings

Loading the dataset

Data pre-processing

Vectorizing the words

Using GloVe Embeddings

Create the embedding layer

Create the model

Training the model


Advantages of using Tensorboard

How to use TensorBoard

How to install TensorBoard

PIP installation

Conda installation

Docker installation

Using TensorBoard with Jupyter notebooks and Google Colab

How to run TensorBoard

How to use TensorBoard callback

How to launch TensorBoard

Running TensorBoard remotely

TensorBoard dashboards

TensorBoard scalars

TensorBoard images

TensorBoard graphs

TensorBoard distributions

TensorBoard histograms

Fairness indicators

What-If Tool (WIT)

Displaying data in TensorBoard

Using the TensorBoard embedding projector

Plot training examples with TensorBoard

Visualize images in TensorBoard

Displaying text data in TensorBoard

Log confusion matrix to TensorBoard

Hyperparameter tuning with TensorBoard

TensorFlow Profiler

Overview page

Trace viewer

Input pipeline analyzer

TensorFlow stats

GPU kernel stats

Memory profile page

How to enable debugging on TensorBoard

Using TensorBoard with deep learning frameworks

TensorBoard in PyTorch

TensorBoard in Keras

TensorBoard in XGBoost

TensorBoard in JAX and Flax

Download TensorBoard data as Pandas DataFrame

Limitations of using TensorBoard

How to build TensorFlow models with the Keras Functional API

Keras Sequential models

Keras Functional models

Defining input

Connecting layers

Functional API Python syntax

Creating the model

Training and evaluation of Functional API models

Save and serialize Functional API models

How to convert a Functional model to a Sequential API model

How to convert a Sequential model to a Functional API model

Standard network models

Multilayer perception

Convolutional Neural Network

Recurrent Neural Network

Shared layers model

Shared input layer

Shared feature extraction layer

Multiple input and output models

Multiple input model

Multiple output model

Use the same graph of layers to define multiple models

Keras Functional API end-to-end example

Data download

Data processing

Add image path column

Create face attributes columns

Label encoding

Generate dataset

Visualize the training data

Define Keras Functional network

Plot and inspect the Keras Functional model

Compile Keras Functional network

Training the Functional network

Evaluate TensorFlow Functional network

Make predictions with Keras Functional model

Keras Functional API strengths and weaknesses

Functional API best practices

How to create custom training loops in Keras

Batch the dataset

How to create model with custom layers in Keras

Define the loss function

Define the gradients function

Create an optimizer

Create custom training loop

Visualize the loss

Evaluate model on test dataset

Use the trained model to make predictions

How to train deep learning models on Apple Silicon GPU

Training deep learning models on Apple Silicon


Install Tensorflow-metal PluggableDevice

Train TensorFlow model on Apple Silicon GPU


Object detection with TensorFlow 2 Object detection API

Object detection datasets

Preparing datasets for object detection

What is TensorFlow 2 Object Detection API?

Install TensorFlow 2 Object Detection API on Google Colab

Install TensorFlow 2 Object Detection API locally

Download object detection dataset

Download Mask R-CNN model

Edit the object detection pipeline config file

Convert the images to TFRecords

Train the model

Model evaluation and visualization

Download model from Google Colab

Object detection with Mask R-CNN

Load an image from file into a NumPy array

Visualize detections

Create model from the last checkpoint

Map labels for inference decoding

Run detector on test image

Image segmentation with Mask R-CNN

Set label map

Set test image paths

Create inference function

Perform segmentation and detection

Final thoughts

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub