Skip to content

Instantly share code, notes, and snippets.

@tkshnkmr
Last active November 5, 2019 13:56
Show Gist options
  • Save tkshnkmr/ba492ec5691d59fe3dd4d5c341e31b9d to your computer and use it in GitHub Desktop.
Save tkshnkmr/ba492ec5691d59fe3dd4d5c341e31b9d to your computer and use it in GitHub Desktop.
# data loader
batch_size = 1
num_workers = 4
data_loader = torch.utils.data.DataLoader(my_dataset,
batch_size=batch_size,
shuffle=False,
num_workers=num_workers
)
import numpy as np
import matplotlib.pyplot as plt
for images, labels in data_loader:
# image shape is [batch_size, 3 (due to RGB), height, width]
img = transforms.ToPILImage()(images[0])
plt.imshow(img)
plt.show()
print(labels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment