BaşlayınÜcretsiz başlayın

PyTorch DataLoader

Good job defining the Dataset class! The WaterDataset you just created is now available for you to use.

The next step in preparing the training data is to set up a DataLoader. A PyTorch DataLoader can be created from a Dataset to load data, split it into batches, and perform transformations on the data if desired. Then, it yields a data sample ready for training.

In this exercise, you will build a DataLoader based on the WaterDataset. The DataLoader class you will need has already been imported for you from torch.utils.data. Let's get to it!

Bu egzersiz, kursun bir parçasıdır

Intermediate Deep Learning with PyTorch

Kursa Göz Atın

Egzersiz talimatları

  • Create an instance of WaterDataset from water_train.csv, assigning it to dataset_train.
  • Create dataloader_train based on dataset_train, using a batch size of two and shuffling the samples.
  • Get a batch of features and labels from the DataLoader and print them.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Create an instance of the WaterDataset
dataset_train = ____(____)

# Create a DataLoader based on dataset_train
dataloader_train = ____(
    ____,
    batch_size=____,
    shuffle=____,
)

# Get a batch of features and labels
features, labels = ____
print(features, labels)
Kodu Düzenle ve Çalıştır