Answers for "torch add extra add to existing dimension"

1

pytorch tensor add one dimension

# ADD ONE DIMENSION: .unsqueeze(dim)

my_tensor = torch.tensor([1,3,4])
# tensor([1,3,4])

my_tensor.unsqueeze(0)
# tensor([[1,3,4]])

my_tensor.unsqueeze(1)
# tensor([[1],
#         [3],
#         [4]])
Posted by: Guest on October-15-2020

Code answers related to "torch add extra add to existing dimension"

Python Answers by Framework

Browse Popular Code Answers by Language