Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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]])
 
PREVIOUS NEXT
Tagged: #pytorch #tensor #add #dimension
ADD COMMENT
Topic
Name
4+4 =