Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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]])
 
PREVIOUS NEXT
Tagged: #input
ADD COMMENT
Topic
Name
7+8 =