Search
 
SCRIPT & CODE EXAMPLE
 

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])
Comment

PREVIOUS NEXT
Code Example
Python :: panda search strings in column 
Python :: lambda python 
Python :: menubar pyqt 
Python :: twitter api v2 python tweepy 
Python :: rename pandas columns with list of new names 
Python :: get the current date and time in python 
Python :: python keep value recursive function 
Python :: find duplicated entries present in a list 
Python :: uninstall python linux 
Python :: qtablewidget clear python 
Python :: making a virtual environment python 
Python :: relative path django 
Python :: get query param in django 
Python :: python get function name 
Python :: qfiledialog python save 
Python :: how to multiply a string in python 
Python :: how to create a python server 
Python :: how to change the values of a column in numpy array 
Python :: how to remove duplicates from a python list 
Python :: remove character(s)from each column in dataframe 
Python :: if else one line python 
Python :: add caption to plot python 
Python :: webscrapping with python 
Python :: Python function to compute factorial of a number. 
Python :: how to get dictionary input from user in python 
Python :: get multiple inputs in python 
Python :: python cocktail sort 
Python :: Determine the sum of al digits of n 
Python :: matplotlib python background color 
Python :: how to download a .xlsx file from google colab 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =