Hands-On Neural Networks with TensorFlow 2.0

Book description

A comprehensive guide to developing neural network-based solutions using TensorFlow 2.0

Key Features

  • Understand the basics of machine learning and discover the power of neural networks and deep learning
  • Explore the structure of the TensorFlow framework and understand how to transition to TF 2.0
  • Solve any deep learning problem by developing neural network-based solutions using TF 2.0

Book Description

TensorFlow, the most popular and widely used machine learning framework, has made it possible for almost anyone to develop machine learning solutions with ease. With TensorFlow (TF) 2.0, you'll explore a revamped framework structure, offering a wide variety of new features aimed at improving productivity and ease of use for developers.

This book covers machine learning with a focus on developing neural network-based solutions. You'll start by getting familiar with the concepts and techniques required to build solutions to deep learning problems. As you advance, you'll learn how to create classifiers, build object detection and semantic segmentation networks, train generative models, and speed up the development process using TF 2.0 tools such as TensorFlow Datasets and TensorFlow Hub.

By the end of this TensorFlow book, you'll be ready to solve any machine learning problem by developing solutions using TF 2.0 and putting them into production.

What you will learn

  • Grasp machine learning and neural network techniques to solve challenging tasks
  • Apply the new features of TF 2.0 to speed up development
  • Use TensorFlow Datasets (tfds) and the tf.data API to build high-efficiency data input pipelines
  • Perform transfer learning and fine-tuning with TensorFlow Hub
  • Define and train networks to solve object detection and semantic segmentation problems
  • Train Generative Adversarial Networks (GANs) to generate images and data distributions
  • Use the SavedModel file format to put a model, or a generic computational graph, into production

Who this book is for

If you're a developer who wants to get started with machine learning and TensorFlow, or a data scientist interested in developing neural network solutions in TF 2.0, this book is for you. Experienced machine learning engineers who want to master the new features of the TensorFlow framework will also find this book useful.

Basic knowledge of calculus and a strong understanding of Python programming will help you grasp the topics covered in this book.

Downloading the example code for this ebook: You can download the example code files for this ebook on GitHub at the following link: https://github.com/PacktPublishing/Hands-On-Neural-Networks-with-TensorFlow-2.0. If you require support please email: customercare@packt.com

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Neural Networks with TensorFlow 2.0
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the author
    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. Get in touch
      1. Reviews
  6. Section 1: Neural Network Fundamentals
  7. What is Machine Learning?
    1. The importance of the dataset
      1. n-dimensional spaces
      2. The curse of dimensionality
    2. Supervised learning
      1. Distances and similarities – the k-NN algorithm
      2. Parametric models
      3. Measuring model performance – metrics
        1. Using accuracy
        2. Using the confusion matrix
          1. Precision
          2. Recall
          3. Classifier regime
          4. F1 score
          5. Using the area under the ROC curve
        3. Mean absolute error
        4. Mean squared error
    3. Unsupervised learning
    4. Semi-supervised learning
    5. Summary
    6. Exercises
  8. Neural Networks and Deep Learning
    1. Neural networks
      1. Biological neurons
      2. Artificial neurons
      3. Fully connected layers
      4. Activation functions
      5. Loss function
      6. Parameter initialization
    2. Optimization
      1. Gradient descent
        1. Stochastic gradient descent
        2. Mini-batch gradient descent
      2. Gradient descent optimization algorithms
        1. Vanilla
        2. Momentum
        3. ADAM
      3. Backpropagation and automatic differentiation
    3. Convolutional neural networks
      1. The convolution operator
      2. 2D convolution
      3. 2D convolutions among volumes
      4. 1 x 1 x D convolutions
    4. Regularization
      1. Dropout
        1. How dropout works
        2. Inverted dropout
        3. Dropout and L2 regularization
      2. Data augmentation
      3. Early stopping
      4. Batch normalization
    5. Summary
    6. Exercises
  9. Section 2: TensorFlow Fundamentals
  10. TensorFlow Graph Architecture
    1. Environment setup
      1. TensorFlow 1.x environment
      2. TensorFlow 2.0 environment
    2. Dataflow graphs
      1. The main structure – tf.Graph
      2. Graph definition – from tf.Operation to tf.Tensor
      3. Graph placement – tf.device
      4. Graph execution – tf.Session
      5. Variables in static graphs
        1. tf.Variable
        2. tf.get_variable
    3. Model definition and training
      1. Defining models with tf.layers
      2. Automatic differentiation – losses and optimizers
    4. Interacting with the graph using Python
      1. Feeding placeholders
      2. Writing summaries
      3. Saving model parameters and model selection
    5. Summary
    6. Exercises
  11. TensorFlow 2.0 Architecture
    1. Relearning the framework
    2. The Keras framework and its models
      1. The Sequential API
      2. The Functional API
      3. The subclassing method
    3. Eager execution and new features
      1. Baseline example
      2. Functions, not sessions
      3. No more globals
      4. Control flow
      5. GradientTape
      6. Custom training loop
      7. Saving and restoring the model's status
      8. Summaries and metrics
      9. AutoGraph
    4. Codebase migration
    5. Summary
    6. Exercises
  12. Efficient Data Input Pipelines and Estimator API
    1. Efficient data input pipelines
      1. Input pipeline structure
      2. The tf.data.Dataset object
      3. Performance optimizations
        1. Prefetching
        2. Cache elements
        3. Using TFRecords
      4. Building your dataset
      5. Data augmentation
      6. TensorFlow Datasets – tfds
        1. Installation
        2. Usage
      7. Keras integration
      8. Eager integration
    2. Estimator API
      1. Data input pipeline
      2. Custom estimators
      3. Premade estimators
        1. Using a Keras model
        2. Using a canned estimator
    3. Summary
    4. Exercises
  13. Section 3: The Application of Neural Networks
  14. Image Classification Using TensorFlow Hub
    1. Getting the data
    2. Transfer learning
      1. TensorFlow Hub
      2. Using Inception v3 as a feature extractor
      3. Adapting data to the model
      4. Building the model – hub.KerasLayer
      5. Training and evaluating
      6. Training speed
    3. Fine-tuning
      1. When to fine-tune
      2. TensorFlow Hub integration
      3. Train and evaluate
      4. Training speed
    4. Summary
    5. Exercises
  15. Introduction to Object Detection
    1. Getting the data
    2. Object localization
      1. Localization as a regression problem
      2. Intersection over Union
      3. Average precision
      4. Mean Average Precision
      5. Improving the training script
    3. Classification and localization
      1. Multitask learning
      2. Double-headed network
      3. Anchor-based detectors
      4. Anchor-boxes
    4. Summary
    5. Exercises
  16. Semantic Segmentation and Custom Dataset Builder
    1. Semantic segmentation
      1. Challenges
      2. Deconvolution – transposed convolution
      3. The U-Net architecture
    2. Create a TensorFlow DatasetBuilder
      1. Hierarchical organization
      2. The dataset class and DatasetInfo
      3. Creating the dataset splits
      4. Generating the example
      5. Use the builder
    3. Model training and evaluation
      1. Data preparation
      2. Training loop and Keras callbacks
      3. Evaluation and inference
    4. Summary
    5. Exercises
  17. Generative Adversarial Networks
    1. Understanding GANs and their applications
      1. Value function
      2. Non-saturating value function
      3. Model definition and training phase
      4. Applications of GANs
    2. Unconditional GANs
      1. Preparing the data
      2. Defining the Generator
      3. Defining the Discriminator
      4. Defining the loss functions
      5. Adversarial training process in unconditional GANs
    3. Conditional GANs
      1. Getting the data for a conditional GAN
      2. Defining the Generator in a conditional GAN
      3. Defining the Discriminator in a conditional GAN
      4. Adversarial training process
    4. Summary
    5. Exercises
  18. Bringing a Model to Production
    1. The SavedModel serialization format
      1. Features
      2. Creating a SavedModel from a Keras model
      3. Converting a SavedModel from a generic function
    2. Python deployment
      1. Generic computational graph
      2. Keras models
      3. Flat graphs
    3. Supported deployment platforms
      1. TensorFlow.js
        1. Converting a SavedModel into model.json format
        2. Converting a Keras Model into model.json format
      2. Go Bindings and tfgo
        1. Setup
        2. Go bindings
        3. Working with tfgo
    4. Summary
    5. Exercises
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Hands-On Neural Networks with TensorFlow 2.0
  • Author(s): Paolo Galeone
  • Release date: September 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789615555