My Account Log in

1 option

Mastering Pytorch : Create and Deploy Deep Learning Models from CNNs to Multimodal Models, LLMs, and Beyond / Ashish Ranjan Jha.

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Jha, Ashish Ranjan, author.
Series:
Expert insight.
Expert insight
Language:
English
Subjects (All):
Neural networks (Computer science).
Python (Computer program language).
Artificial intelligence.
Physical Description:
1 online resource (559 pages)
Edition:
Second edition.
Place of Publication:
Birmingham, England : Packt Publishing Ltd., [2024]
Summary:
PyTorch is making it easier than ever before for anyone to build deep learning applications. This PyTorch deep learning book will help you uncover expert techniques to get the most out of your data and build complex neural network models. You’ll build convolutional neural networks for image classification and recurrent neural networks and transformers for sentiment analysis. As you advance, you'll apply deep learning across different domains, such as music, text, and image generation, using generative models, including diffusion models. You'll not only build and train your own deep reinforcement learning models in PyTorch but also learn to optimize model training using multiple CPUs, GPUs, and mixed-precision training. You’ll deploy PyTorch models to production, including mobile devices. Finally, you’ll discover the PyTorch ecosystem and its rich set of libraries. These libraries will add another set of tools to your deep learning toolbelt, teaching you how to use fastai to prototype models and PyTorch Lightning to train models. You’ll discover libraries for AutoML and explainable AI (XAI), create recommendation systems, and build language and vision transformers with Hugging Face. By the end of this book, you'll be able to perform complex deep learning tasks using PyTorch to build smart artificial intelligence models.
Contents:
Cover
Copyright
Contributors
Table of Contents
Preface
Chapter 1: Overview of Deep Learning Using PyTorch
A refresher on deep learning
Activation functions
Optimization schedule
Exploring the PyTorch library in contrast to TensorFlow
Tensor modules
PyTorch modules
torch.nn
torch.optim
torch.utils.data
Training a neural network using PyTorch
Summary
Reference list
Chapter 2: Deep CNN Architectures
Why are CNNs so powerful?
Evolution of CNN architectures
Developing LeNet from scratch
Using PyTorch to build LeNet
Training LeNet
Testing LeNet
Fine-tuning the AlexNet model
Using PyTorch to fine-tune AlexNet
Running a pretrained VGG model
Exploring GoogLeNet and Inception v3
Inception modules
1x1 convolutions
Global average pooling
Auxiliary classifiers
Inception v3
Discussing ResNet and DenseNet architectures
ResNet
DenseNet
Understanding EfficientNets and the future of CNN architectures
References
Chapter 3: Combining CNNs and LSTMs
Building a neural network with CNNs and LSTMs
Text encoding demo
Building an image caption generator using PyTorch
Downloading the image captioning datasets
Preprocessing caption (text) data
Preprocessing image data
Defining the image captioning data loader
Defining the CNN-LSTM model
Training the CNN-LSTM model
Generating image captions using the trained model
Chapter 4: Deep Recurrent Model Architectures
Exploring the evolution of recurrent networks
Types of recurrent neural networks
RNNs
Bidirectional RNNs
LSTMs
Extended and bidirectional LSTMs
Multi-dimensional RNNs
Stacked LSTMs
GRUs
Grid LSTMs
Gated orthogonal recurrent units
Training RNNs for sentiment analysis.
Loading and preprocessing the text dataset
Instantiating and training the model
Building a bidirectional LSTM
Loading and preprocessing the text dataset
Instantiating and training the LSTM model
Discussing GRUs and attention-based models
GRUs and PyTorch
Attention-based models
Chapter 5: Advanced Hybrid Models
Building a transformer model for language modeling
Reviewing language modeling
Understanding the transformer model architecture
Defining a transformer model in PyTorch
Loading and processing the dataset
Training the transformer model
Developing a RandWireNN model from scratch
Understanding RandWireNNs
Developing RandWireNNs using PyTorch
Defining a training routine and loading data
Defining the randomly wired graph
Defining RandWireNN model modules
Transforming a random graph into a neural network
Training the RandWireNN model
Evaluating and visualizing the RandWireNN model
Chapter 6: Graph Neural Networks
Introduction to GNNs
Understanding the intuition behind GNNs
Using regular NNs on graph data - a thought experiment
Understanding the power of GNNs with computational graphs
Types of graph learning tasks
Understanding node-level tasks
Understanding edge-level tasks
Understanding graph-level tasks
Reviewing prominent GNN models
Understanding graph convolutions with GCNs
Using attention in graphs with GAT
Performing graph sampling with GraphSAGE
Building a GCN model using PyTorch Geometric
Loading and exploring the citation networks dataset
Building a simple NN-based node classifier
Building a GCN model for node classification
Training a GAT model with PyTorch Geometric
Chapter 7: Music and Text Generation with PyTorch.
Building a transformer-based text generator with PyTorch
Training the transformer-based language model
Saving and loading the language model
Using the language model to generate text
Using GPT models as text generators
Out-of-the-box text generation with GPT-2
Text generation strategies using PyTorch
Greedy search
Beam search
Top-k and top-p sampling
Text generation with GPT-3
Generating MIDI music with LSTMs using PyTorch
Loading the MIDI music data
Defining the LSTM model and training routine
Training and testing the music generation model
Chapter 8: Neural Style Transfer
Understanding how to transfer style between images
Implementing neural style transfer using PyTorch
Loading the content and style images
Loading and trimming the pretrained VGG19 model
Building the neural style transfer model
Training the style transfer model
Experimenting with the style transfer system
Chapter 9: Deep Convolutional GANs
Defining the generator and discriminator networks
Understanding the DCGAN generator and discriminator
Training a DCGAN using PyTorch
Defining the generator
Defining the discriminator
Loading the image dataset
Training loops for DCGANs
Using GANs for style transfer
Understanding the pix2pix architecture
Exploring the pix2pix generator
Exploring the pix2pix discriminator
Chapter 10: Image Generation Using Diffusion
Understanding image generation using diffusion
Understanding how diffusion works
Training a forward diffusion model
Performing reverse diffusion or denoising
Training a diffusion model for image generation
Loading the dataset using Hugging Face datasets
Processing the dataset using torchvision transforms.
Adding noise to images using diffusers
Defining the UNet model
Training the UNet model
Defining the optimizer and learning schedule
Using Hugging Face Accelerate to accelerate training
Running the model training loop
Generating realistic anime images using (reverse) diffusion
Understanding text-to-image generation using diffusion
Encoding text input into an embedding vector
Ingesting additional text data in the (conditional) UNet model
Using the Stable Diffusion model to generate images from text
Chapter 11: Deep Reinforcement Learning
Reviewing RL concepts
Types of RL algorithms
Model-based
Model-Free
Discussing Q-learning
Understanding deep Q-learning
Using two separate DNNs
Experience replay buffer
Building a DQN model in PyTorch
Initializing the main and target CNN models
Defining the experience replay buffer
Setting up the environment
Defining the CNN optimization function
Managing and running episodes
Training the DQN model to learn Pong
Chapter 12: Model Training Optimizations
Distributed training with PyTorch
Training the MNIST model in a regular fashion
Training the MNIST model in a distributed fashion
Distributed training on GPUs with CUDA
Automatic mixed precision training
Regular model training on a GPU
Mixed precision training on a GPU
Chapter 13: Operationalizing PyTorch Models into Production
Model serving in PyTorch
Creating a PyTorch model inference pipeline
Saving and loading a trained model
Building the inference pipeline
Building a basic model server
Writing a basic app using Flask
Using Flask to build our model server
Setting up model inference for Flask serving
Building a Flask app to serve model.
Using a Flask server to run predictions
Creating a model microservice
Serving a PyTorch model using TorchServe
Installing TorchServe
Launching and using a TorchServe server
Exporting universal PyTorch models using TorchScript and ONNX
Understanding the utility of TorchScript
Model tracing with TorchScript
Model scripting with TorchScript
Running a PyTorch model in C++
Using ONNX to export PyTorch models
Serving PyTorch models in the cloud
Using PyTorch with AWS
Serving a PyTorch model using an AWS instance
Using TorchServe with Amazon SageMaker
Serving PyTorch models on Google Cloud
Serving PyTorch models with Azure
Working with Azure's DSVMs
Discussing Azure Machine Learning Service
Chapter 14: PyTorch on Mobile Devices
Deploying a PyTorch model on Android
Converting the PyTorch model to a mobile-friendly format
Setting up the Android app development environment
Using the phone camera in the Android app to capture images
Enabling the camera during app startup
Handling camera permissions in Android
Opening the camera for image capture
Capturing images using the phone camera
Running ML model inference on camera-captured images
Validating the ML model binary path
Performing image classification on camera-captured images
Launching the app on an Android mobile device
Building PyTorch apps on iOS
Setting up the iOS development environment
Using a phone camera in the iOS app to capture images
Chapter 15: Rapid Prototyping with PyTorch
Using fastai to set up model training in a few minutes
Setting up fastai and loading data
Training an MNIST model using fastai
Evaluating and interpreting the model using fastai.
Training models on any hardware using PyTorch Lightning.
Notes:
Includes bibliographical references and index.
Description based on publisher supplied metadata and other sources.
Description based on print version record.
Other Format:
Print version: Jha, Ashish Ranjan Mastering Pytorch
ISBN:
9781801079969
OCLC:
1438929463

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Library Catalog Using Articles+ Library Account