Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pytorch unsqueeze

ft = torch.Tensor([0, 1, 2])
print(ft.shape)
>>> torch.Size([3])

print(ft.unsqueeze(0)) # 0 means first dimension
print(ft.unsqueeze(0).shape)
>>> tensor([[0., 1., 2.]])
>>> torch.Size([1, 3])
Source by wikidocs.net #
 
PREVIOUS NEXT
Tagged: #pytorch #unsqueeze
ADD COMMENT
Topic
Name
1+3 =