Skip to Content
Deep Learning with PyTorch
book

Deep Learning with PyTorch

by Vishnu Subramanian
February 2018
Intermediate to advanced
262 pages
6h 59m
English
Packt Publishing
Content preview from Deep Learning with PyTorch

Creating a custom PyTorch dataset class for the pre-convoluted features and loader

We have already seen how to create a PyTorch dataset. It should be a subclass of the torch.utils.data dataset class and should implement the __getitem__(self, index) and __len__(self) methods, which return the length of the data in the dataset. In the following code, we implement a custom dataset for the pre-convoluted features:

class FeaturesDataset(Dataset):        def __init__(self,featlst,labellst):        self.featlst = featlst        self.labellst = labellst            def __getitem__(self,index):        return (self.featlst[index],self.labellst[index])        def __len__(self):        return len(self.labellst)

Once the custom dataset class is created, creating a data loader for the pre-convoluted features ...

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

Deep Learning with PyTorch

Deep Learning with PyTorch

Eli Stevens, Thomas Viehmann, Luca Pietro Giovanni Antiga
Grokking Deep Learning

Grokking Deep Learning

Andrew W. Trask

Publisher Resources

ISBN: 9781788624336Supplemental Content