📌  相关文章
📜  RuntimeError:输入必须有 3 个维度,得到 4 个站点:stackoverflow.com - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:10.327000             🧑  作者: Mango

代码示例1
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]])