def img_convert(tensor):
image = tensor.clone().detach().numpy()
image = image.transpose(1, 2, 0)
print(image.shape)
image = image*np.array(0.5,) + np.array(0.5,)
image = image.clip(0, 1)
return image
dataiter = iter(training_loader)
images, labels = dataiter.next()
fig = plt.figure(figsize=(25, 4))
for idx in np.arange(20):
ax = fig.add_subplot(2, 10, idx+1, xticks=[], yticks=[])
plt.imshow(img_convert(images[idx]))
ax.set_title([labels[idx].item()])