Search
 
SCRIPT & CODE EXAMPLE
 

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

PREVIOUS NEXT
Code Example
Python :: np array n same values 
Python :: python read file delete first line 
Python :: model load pytorch 
Python :: stripping /n in a readlines for a pytgon file 
Python :: python regex numbers only 
Python :: save machine learning model python 
Python :: python pil image flip 
Python :: django create app command 
Python :: filter dataframe with list 
Python :: concat dataFrame without index reset 
Python :: pandas change dtype to string 
Python :: pandas columns starting with 
Python :: python selenium scroll all down 
Python :: python copy file 
Python :: ggplot2 histogram 
Python :: check cuda version pytorch 
Python :: pandas remove row if missing value in column 
Python :: correlation matrix python 
Python :: python run 2 functions at the same time 
Python :: flask minimal install 
Python :: django filter not equal to 
Python :: python read url 
Python :: python how much memory does a variable need 
Python :: image capture from camera python 
Python :: import randomforestclassifier 
Python :: set os environment variable python 
Python :: exclude columns pandas 
Python :: special characters list in python 
Python :: python ffmpeg 
Python :: extract frames from video python 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =