通过上图可以看出,无论 dim 参数值是正整数还是负整数,其具体范围都和输入张量的维度有关。...如果指定 dim 参数超过其取值范围,会抛出 IndexError。...>>> import torch
>>> # 使用随机生成的正态分布模拟[b,c,h,w]
>>> input = torch.randn(1, 1, 28, 28)
>>> print(input.size...>>> import torch
>>> # 使用随机生成的正态分布模拟[b,c,h,w]
>>> input = torch.randn(1, 1, 28, 28)
>>> print(input.size...>>> import torch
>>> # 使用随机生成的正态分布模拟[b,c,h,w]
>>> input = torch.randn(1, 1, 28, 28)
>>> print(input.size