Prerequisites:
import torch
from PIL import Image
import numpy as np
torch.zeros(10)
torch.ones(10)
torch.ones([4,5])
v = torch.ones(5)
print( v.dtype, v.shape )
v = torch.arange(100)
v
v.shape
m = v.view((10,10))
m
m.shape
I = Image.open('cat.jpg')
I
np.array(I)
np.array(I).shape
from torchvision import transforms
image_to_tensor = transforms.ToTensor()
image_tensor = image_to_tensor(I)
image_tensor
image_tensor.shape
tensor_to_image = transforms.ToPILImage()
tensor_to_image(image_tensor)