import torch
a = torch.rand((2,3))
print(a)
out = a.reshape(3,2)
print(out)
tensor([[0.9521, 0.0812, 0.1984],
[0.2137, 0.3824, 0.9961]])
tensor([[0.9521, 0.0812],
[0.1984, 0.2137],
[0.3824, 0.9961]])
print(torch.t(out))
tensor([[0.9521, 0.1984, 0.3824],
[0.0812, 0.2137, 0.9961]])
print(torch.transpose(out,0,1))
tensor([[0.9521, 0.1984, 0.3824],
[0.0812, 0.2137, 0.9961]])
a = torch.rand(1,2,3)
out = torch.transpose(a,1,0)
print(a)
print(out)
print(out.shape)
tensor([[[0.5815, 0.3386, 0.0553],
[0.1253, 0.3207, 0.9636]]])
tensor([[[0.5815, 0.3386, 0.0553]],
[[0.1253, 0.3207, 0.9636]]])
torch.Size([2, 1, 3])
out = torch.squeeze(a)
print(out)
print(out.shape)
out = torch.unsqueeze(a,-1)
print(out.shape)
tensor([[0.5815, 0.3386, 0.0553],
[0.1253, 0.3207, 0.9636]])
torch.Size([2, 3])
torch.Size([1, 2, 3, 1])
out = torch.unbind(a,dim = 1)
print(out)
(tensor([[0.5815, 0.1253]]), tensor([[0.3386, 0.3207]]), tensor([[0.0553, 0.9636]]))
print(a)
print(torch.flip(a,dims=[1,2]))
tensor([[[0.5815, 0.3386, 0.0553],
[0.1253, 0.3207, 0.9636]]])
tensor([[[0.9636, 0.3207, 0.1253],
[0.0553, 0.3386, 0.5815]]])
a = torch.rand((2,3))
print(a)
print(torch.rot90(a))
tensor([[0.9152, 0.1834, 0.8199],
[0.8542, 0.5633, 0.1858]])
tensor([[0.8199, 0.1858],
[0.1834, 0.5633],
[0.9152, 0.8542]])
print(torch.rot90(a,2))
tensor([[0.1858, 0.5633, 0.8542],
[0.8199, 0.1834, 0.9152]])