Save and Load Your PyTorch Models

A deep learning model is a mathematical abstraction of data, in which a lot of parameters are involved. Training these parameters can take hours, days, and even weeks but afterward, you can make use of the result to apply on new data. This is called inference in machine learning. It is important to know how we can preserve the trained model in disk and later, load it for use in inference. In this post, you will discover how to save […]

Read more

Using Activation Functions in Deep Learning Models

A deep learning model in its simplest form are layers of perceptrons connected in tandem. Without any activation functions, they are just matrix multiplications with limited power, regardless how many of them. Activation is the magic why neural network can be an approximation to a wide variety of non-linear function. In PyTorch, there are many activation functions available for use in your deep learning models. In this post, you will see how the choice of activation functions can impact the […]

Read more

Loss Functions in PyTorch Models

The loss metric is very important for neural networks. As all machine learning models are one optimization problem or another, the loss is the objective function to minimize. In neural networks, the optimization is done with gradient descent and backpropagation. But what are loss functions, and how are they affecting your neural networks? In this chapter, you will learn what loss functions are and delve into some commonly used loss functions and how you can apply them to your neural […]

Read more

Using Dropout Regularization in PyTorch Models

Dropout is a simple and powerful regularization technique for neural networks and deep learning models. In this post, you will discover the Dropout regularization technique and how to apply it to your models in PyTorch models. After reading this post, you will know: How the Dropout regularization technique works How to use Dropout on your input layers How to use Dropout on your hidden layers How to tune the dropout level on your problem Kick-start your project with my book […]

Read more

Using Learning Rate Schedule in PyTorch Training

Training a neural network or large deep learning model is a difficult optimization task. The classical algorithm to train neural networks is called stochastic gradient descent. It has been well established that you can achieve increased performance and faster training on some problems by using a learning rate that changes during training. In this post, you will discover what is learning rate schedule and how you can use different learning rate schedules for your neural network models in PyTorch. After […]

Read more

Training a PyTorch Model with DataLoader and Dataset

When you build and train a PyTorch deep learning model, you can provide the training data in several different ways. Ultimately, a PyTorch model works like a function that takes a PyTorch tensor and returns you another tensor. You have a lot of freedom in how to get the input tensors. Probably the easiest is to prepare a large tensor of the entire dataset and extract a small batch from it in each training step. But you will see that […]

Read more

Understand Model Behavior During Training by Visualizing Metrics

You can learn a lot about neural networks and deep learning models by observing their performance over time during training. For example, if you see the training accuracy went worse with training epochs, you know you have issue with the optimization. Probably your learning rate is too fast. In this post, you will discover how you can review and visualize the performance of PyTorch models over time during training. After completing this post, you will know: What metrics to collect […]

Read more

Managing a PyTorch Training Process with Checkpoints and Early Stopping

A large deep learning model can take a long time to train. You lose a lot of work if the training process interrupted in the middle. But sometimes, you actually want to interrupt the training process in the middle because you know going any further would not give you a better model. In this post, you will discover how to control the training loop in PyTorch such that you can resume an interrupted process, or early stop the training loop. […]

Read more

Visualizing a PyTorch Model

PyTorch is a deep learning library. You can build very sophisticated deep learning models with PyTorch. However, there are times you want to have a graphical representation of your model architecture. In this post, you will learn: How to save your PyTorch model in an exchange format How to use Netron to create a graphical representation. Kick-start your project with my book Deep Learning with PyTorch. It provides self-study tutorials with working code. Let’s get started. Visualizing a PyTorch ModelPhoto […]

Read more

Building a Convolutional Neural Network in PyTorch

Neural networks are built with layers connected to each other. There are many different kind of layers. For image related applications, you can always find convolutional layers. It is a layer with very few parameters but applied over a large sized input. It is powerful because it can preserve the spatial structure of the image. Therefore it is used to produce state-of-the-art results on computer vision neural networks. In this post, you will learn about the convolutional layer and the […]

Read more
1 88 89 90 91 92 973