[Learning] pytorch unsqueeze () function

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)

 

 

Published 83 original articles · won praise 14 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_38121168/article/details/103160348