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 PyTorch datasets

We create a transformation object containing all the basic transformations required and use the ImageFolder to load the images from the data directory that we created in Chapter 5, Deep Learning for Computer Vision. In the following code, we create the datasets:

data_transform = transforms.Compose([        transforms.Resize((299,299)),        transforms.ToTensor(),        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])    ])# For Dogs & Cats datasettrain_dset = ImageFolder('../../chapter5/dogsandcats/train/',transform=data_transform)val_dset = ImageFolder('../../chapter5/dogsandcats/valid/',transform=data_transform)classes=2

By now, most of the preceding code will be self-explanatory.

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