Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

RuntimeError: input must have 3 dimensions, got 4 site:stackoverflow.com

import torch
r = torch.tensor([[[5,10,11,18,19],[900,98,97,51,64],[89,87,45,64,88]]])#this is a 4 dimensions
print(r)
>>> tensor([[[5,10,11,18,19],[900,98,97,51,64],[89,87,45,64,88]]])
#if we convert it into 3 dimensions from 4 dimensions,we need to use torch.squeeze() function
r.squeeze()
>>> tensor([[5,10,11,18,19],[900,98,97,51,64],[89,87,45,64,88]])
Comment

PREVIOUS NEXT
Code Example
Python :: nltk document 
Python :: split credit card number python 
Python :: python inline print variable 
Python :: python-wordpress-xmlrpc custom fields 
Python :: pandan jaya lrt 
Python :: save gif python 
Python :: tkinter lottery app 
Python :: plot a against b 
Python :: python numpy read from stdin 
Python :: inspect rows in dictionary pthon 
Python :: mutliple inxed conditions py 
Python :: custom dense layer 
Python :: iloc[ ] slicing 
Python :: error in matplotlib setup command: use_2to3 is invalid 
Python :: install plotly manually 
Python :: pd drop a range of dates 
Python :: Get Today’s Year, Month, and Date using today method 
Python :: input what is your name python 
Python :: bs4 check element type 
Python :: forward fill in pyspark 
Python :: convert depth image to point cloud 
Python :: ValueError: y_true and y_pred contain different number of classes 6, 2. Please provide the true labels explicitly through the labels argument. Classes found in y_true: [0 1 2 3 4 5] 
Python :: how to reference second line of matrix in python 
Python :: type hinting with default value python 
Python :: get a list of colors that appear of the image python 
Python :: How to combine two or more querysets in a Django view? 
Python :: Replace and count string delimiter 
Python :: replace python enter number of characters 
Python :: python nc group variables 
Python :: reate the "soup." This is a beautiful soup object: 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =