unsqueeze () function
Action: increase the dimensions of the tensor;
import torch
import numpy as np
a = torch.tensor(np.arange(0, 6))
print(a)
print(a.shape)
a = a.unsqueeze(1)
print(a)
print(a.shape)
Action: increase the dimensions of the tensor;
import torch
import numpy as np
a = torch.tensor(np.arange(0, 6))
print(a)
print(a.shape)
a = a.unsqueeze(1)
print(a)
print(a.shape)