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

0

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]])
Posted by: Guest on November-12-2020

Code answers related to "RuntimeError: input must have 3 dimensions, got 4 site:stackoverflow.com"

Python Answers by Framework

Browse Popular Code Answers by Language