0%

Implement classical and deep learning generative models through practical examples

Key Features

  • Explore creative and human-like capabilities of AI and generate impressive results
  • Use the latest research to expand your knowledge beyond this book
  • Experiment with practical TensorFlow 2.x implementations of state-of-the-art generative models

Book Description

In recent years, generative artificial intelligence has been instrumental in the creation of lifelike data (images, speech, video, music, and text) from scratch. In this book you will unpack how these powerful models are created from relatively simple building blocks, and how you might adapt these models to your own use cases.

You will begin by setting up clean containerized environments for Python and getting to grips with the fundamentals of deep neural networks, learning about core concepts like the perceptron, activation functions, backpropagation, and how they all tie together. Once you have covered the basics, you will explore deep generative models in depth, including OpenAI's GPT-series of news generators, networks for style transfer and deepfakes, and synergy with reinforcement learning.

As you progress, you will focus on abstractions where useful, and understand the “nuts and bolts” of how the models are composed in code, underpinned by detailed architecture diagrams. The book concludes with a variety of practical projects to generate music, images, text, and speech using the methods you have learned in prior sections, piecing together TensorFlow layers, utility functions, and training loops to uncover links between the different modes of generation.

By the end of this book, you will have acquired the knowledge to create and implement your own generative AI models.

What you will learn

  • Implement paired and unpaired style transfer with networks like StyleGAN
  • Use facial landmarks, autoencoders, and pix2pix GAN to create deepfakes
  • Build several text generation pipelines based on LSTMs, BERT, and GPT-2, learning how attention and transformers changed the NLP landscape
  • Compose music using LSTM models, simple generative adversarial networks, and the intricate MuseGAN
  • Train a deep learning agent to move through a simulated physical environment
  • Discover emerging applications of generative AI, such as folding proteins and creating videos from images

Who this book is for

This book will appeal to Python programmers, seasoned modelers, and machine learning engineers who are keen to learn about the creation and implementation of generative models. To make the most out of this book, you should have a basic familiarity with probability theory, linear algebra, and deep learning.

Table of Contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  2. An Introduction to Generative AI: "Drawing" Data from Models
    1. Applications of AI
    2. Discriminative and generative models
    3. Implementing generative models
    4. The rules of probability
    5. Discriminative and generative modeling and Bayes' theorem
    6. Why use generative models?
    7. The promise of deep learning
    8. Building a better digit classifier
    9. Generating images
    10. Style transfer and image transformation
    11. Fake news and chatbots
    12. Sound composition
    13. The rules of the game
    14. Unique challenges of generative models
    15. Summary
    16. References
  3. Setting Up a TensorFlow Lab
    1. Deep neural network development and TensorFlow
    2. TensorFlow 2.0
    3. VSCode
    4. Docker: A lightweight virtualization solution
    5. Important Docker commands and syntax
    6. Connecting Docker containers with docker-compose
    7. Kubernetes: Robust management of multi-container applications
    8. Important Kubernetes commands
    9. Kustomize for configuration management
    10. Kubeflow: an end-to-end machine learning lab
    11. Running Kubeflow locally with MiniKF
    12. Installing Kubeflow in AWS
    13. Installing Kubeflow in GCP
    14. Installing Kubeflow on Azure
    15. Installing Kubeflow using Terraform
    16. A brief tour of Kubeflow's components
    17. Kubeflow notebook servers
    18. Kubeflow pipelines
    19. Using Kubeflow Katib to optimize model hyperparameters
    20. Summary
    21. References
  4. Building Blocks of Deep Neural Networks
    1. Perceptrons – a brain in a function
    2. From tissues to TLUs
    3. From TLUs to tuning perceptrons
    4. Multi-layer perceptrons and backpropagation
    5. Backpropagation in practice
    6. The shortfalls of backpropagation
    7. Varieties of networks: Convolution and recursive
    8. Networks for seeing: Convolutional architectures
    9. Early CNNs
    10. AlexNet and other CNN innovations
    11. AlexNet architecture
    12. Networks for sequence data
    13. RNNs and LSTMs
    14. Building a better optimizer
    15. Gradient descent to ADAM
    16. Xavier initialization
    17. Summary
    18. References
  5. Teaching Networks to Generate Digits
    1. The MNIST database
    2. Retrieving and loading the MNIST dataset in TensorFlow
    3. Restricted Boltzmann Machines: generating pixels with statistical mechanics
    4. Hopfield networks and energy equations for neural networks
    5. Modeling data with uncertainty with Restricted Boltzmann Machines
    6. Contrastive divergence: Approximating a gradient
    7. Stacking Restricted Boltzmann Machines to generate images: the Deep Belief Network
    8. Creating an RBM using the TensorFlow Keras layers API
    9. Creating a DBN with the Keras Model API
    10. Summary
    11. References
  6. Painting Pictures with Neural Networks Using VAEs
    1. Creating separable encodings of images
    2. The variational objective
    3. The reparameterization trick
    4. Inverse Autoregressive Flow
    5. Importing CIFAR
    6. Creating the network from TensorFlow 2
    7. Summary
    8. References
  7. Image Generation with GANs
    1. The taxonomy of generative models
    2. Generative adversarial networks
    3. The discriminator model
    4. The generator model
    5. Training GANs
    6. Non-saturating generator cost
    7. Maximum likelihood game
    8. Vanilla GAN
    9. Improved GANs
    10. Deep Convolutional GAN
    11. Vector arithmetic
    12. Conditional GAN
    13. Wasserstein GAN
    14. Progressive GAN
    15. The overall method
    16. Progressive growth-smooth fade-in
    17. Minibatch standard deviation
    18. Equalized learning rate
    19. Pixelwise normalization
    20. TensorFlow Hub implementation
    21. Challenges
    22. Training instability
    23. Mode collapse
    24. Uninformative loss and evaluation metrics
    25. Summary
    26. References
  8. Style Transfer with GANs
    1. Paired style transfer using pix2pix GAN
    2. The U-Net generator
    3. The Patch-GAN discriminator
    4. Loss
    5. Training pix2pix
    6. Use cases
    7. Unpaired style transfer using CycleGAN
    8. Overall setup for CycleGAN
    9. Adversarial loss
    10. Cycle loss
    11. Identity loss
    12. Overall loss
    13. Hands-on: Unpaired style transfer with CycleGAN
    14. Generator setup
    15. Discriminator setup
    16. GAN setup
    17. The training loop
    18. Related works
    19. DiscoGAN
    20. DualGAN
    21. Summary
    22. References
  9. Deepfakes with GANs
    1. Deepfakes overview
    2. Modes of operation
    3. Replacement
    4. Re-enactment
    5. Editing
    6. Key feature set
    7. Facial Action Coding System (FACS)
    8. 3D Morphable Model
    9. Facial landmarks
    10. Facial landmark detection using OpenCV
    11. Facial landmark detection using dlib
    12. Facial landmark detection using MTCNN
    13. High-level workflow
    14. Common architectures
    15. Encoder-Decoder (ED)
    16. Generative Adversarial Networks (GANs)
    17. Replacement using autoencoders
    18. Task definition
    19. Dataset preparation
    20. Autoencoder architecture
    21. Training our own face swapper
    22. Results and limitations
    23. Re-enactment using pix2pix
    24. Dataset preparation
    25. Pix2pix GAN setup and training
    26. Results and limitations
    27. Challenges
    28. Ethical issues
    29. Technical challenges
    30. Generalization
    31. Occlusions
    32. Temporal issues
    33. Off-the-shelf implementations
    34. Summary
    35. References
  10. The Rise of Methods for Text Generation
    1. Representing text
    2. Bag of Words
    3. Distributed representation
    4. Word2vec
    5. GloVe
    6. FastText
    7. Text generation and the magic of LSTMs
    8. Language modeling
    9. Hands-on: Character-level language model
    10. Decoding strategies
    11. Greedy decoding
    12. Beam search
    13. Sampling
    14. Hands-on: Decoding strategies
    15. LSTM variants and convolutions for text
    16. Stacked LSTMs
    17. Bidirectional LSTMs
    18. Convolutions and text
    19. Summary
    20. References
  11. NLP 2.0: Using Transformers to Generate Text
    1. Attention
    2. Contextual embeddings
    3. Self-attention
    4. Transformers
    5. Overall architecture
    6. Multi-head self-attention
    7. Positional encodings
    8. BERT-ology
    9. GPT 1, 2, 3…
    10. Generative pre-training: GPT
    11. GPT-2
    12. Hands-on with GPT-2
    13. Mammoth GPT-3
    14. Summary
    15. References
  12. Composing Music with Generative Models
    1. Getting started with music generation
    2. Representing music
    3. Music generation using LSTMs
    4. Dataset preparation
    5. LSTM model for music generation
    6. Music generation using GANs
    7. Generator network
    8. Discriminator network
    9. Training and results
    10. MuseGAN – polyphonic music generation
    11. Jamming model
    12. Composer model
    13. Hybrid model
    14. Temporal model
    15. MuseGAN
    16. Generators
    17. Critic
    18. Training and results
    19. Summary
    20. References
  13. Play Video Games with Generative AI: GAIL
    1. Reinforcement learning: Actions, agents, spaces, policies, and rewards
    2. Deep Q-learning
    3. Inverse reinforcement learning: Learning from experts
    4. Adversarial learning and imitation
    5. Running GAIL on PyBullet Gym
    6. The agent: Actor-Critic network
    7. The discriminator
    8. Training and results
    9. Summary
    10. References
  14. Emerging Applications in Generative AI
    1. Finding new drugs with generative models
    2. Searching chemical space with generative molecular graph networks
    3. Folding proteins with generative models
    4. Solving partial differential equations with generative modeling
    5. Few shot learning for creating videos from images
    6. Generating recipes with deep learning
    7. Summary
    8. References
    9. Why subscribe?
  15. Other Books You May Enjoy
  16. Index
18.207.163.25