Created
January 7, 2022 21:13
-
-
Save daniel-e/4e2b8a42160e5d1a16001d06cb02a794 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from torch import utils\n", | |
"from torchvision import datasets, transforms\n", | |
"\n", | |
"# Transform PIL image into a tensor. The values are in the range [0, 1]\n", | |
"t = transforms.ToTensor()\n", | |
"\n", | |
"# Load datasets for training and apply the given transformation.\n", | |
"mnist = datasets.MNIST(root='data', train=True, download=True, transform=t)\n", | |
"\n", | |
"# Specify a data loader which returns 500 examples in each iteration.\n", | |
"n = 500\n", | |
"loader = utils.data.DataLoader(mnist, batch_size=n, shuffle=True)\n", | |
"\n", | |
"# Iterate over the batches.\n", | |
"for imgs, labels in loader:\n", | |
" # do something" | |
] | |
} | |
], | |
"metadata": { | |
"interpreter": { | |
"hash": "3c31154c2e6d078d13498c87eb48ca372ee3ad3d9153e56081b43cdb07df7cf4" | |
}, | |
"kernelspec": { | |
"display_name": "Python 3.8.10 64-bit ('venv': venv)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.8.10" | |
}, | |
"orig_nbformat": 4 | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment