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 using the DataLoader
can save you a few lines of code in dealing with data.
In this post, you will see how you can use the the Data and DataLoader in PyTorch. After finishing this post, you will learn: