Skip to Content
PyTorch Pocket Reference
book

PyTorch Pocket Reference

by Joe Papa
May 2021
Intermediate to advanced
307 pages
6h 1m
English
O'Reilly Media, Inc.
Book available
Content preview from PyTorch Pocket Reference

Chapter 5. Customizing PyTorch

Up until now, you have been using built-in PyTorch classes, functions, and libraries to design and train various predefined models, model layers, and activation functions. But what if you have a novel idea or you’re conducting cutting-edge deep learning research? Perhaps you’ve invented a totally new layer architecture or activation function. Maybe you’ve developed a new optimization algorithm or a special loss function that no one’s ever seen before.

In this chapter, I’ll show you how to create your own custom deep learning components and algorithms in PyTorch. We’ll begin by exploring how to create custom layers and activation functions, and then we’ll see how to combine these components into custom model architectures. Next, I’ll show you how to create your own loss functions and optimizer algorithms. Finally, we’ll look at how to create custom loops for training, validation, and testing.

PyTorch offers flexibility: you can extend an existing library or you can combine your customizations into your own library or package. By creating custom components you can solve new deep learning problems, speed up training, and discover innovative ways to perform deep learning.

Let’s get started by creating some custom deep learning layers and activation functions.

Custom Layers and Activations

PyTorch offers an extensive set of built-in layers and activation functions. However, what makes PyTorch so popular, especially in the research community, is how easy ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Pipelines Pocket Reference

Data Pipelines Pocket Reference

James Densmore
Practical MLOps

Practical MLOps

Noah Gift, Alfredo Deza
The Kaggle Book

The Kaggle Book

Konrad Banachewicz, Luca Massaron

Publisher Resources

ISBN: 9781492089995Errata PageSupplemental Content