In [35]:
import torch
import torchvision.datasets as datasets
import torch.utils.data as data
import torchvision.models as models
import torchvision.transforms as transforms
from torch.autograd import Variable
import os
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
In [ ]:
class TinyImageDataset(Dataset):
In [ ]:
In [75]:
print("Loading stored model ...")
model = models.resnet18(pretrained=True)
print("Loaded model successfully.")
# load data set
print("Reading data...")
val_dir = os.path.expanduser('~/nta/datasets/tiny-imagenet-200/val')
val_dataset = datasets.ImageFolder(val_dir, transform=transforms.ToTensor())
val_loader = data.DataLoader(val_dataset, batch_size=128)
print("Loaded: %s" % val_dir)
In [21]:
predicted
Out[21]:
In [22]:
labels
Out[22]:
In [25]:
val_loader
Out[25]:
In [78]:
input, target = next(iter(val_loader))
input.shape
Out[78]:
In [84]:
rand = np.random.randint(input.shape[0])
plt.imshow(input[rand].permute(1,2,0).numpy()), target[rand]
Out[84]:
In [86]:
target
Out[86]:
In [ ]: