【Pytorch基础】二维/三维情况下 torch.mean()函数使用

目录

  • 1 前言
  • 2 一维二维
  • 3 参考文献

1 前言

  在这篇介绍中【Pytorch】张量的维度/轴/dim的理解已经解释了dim的用法,下面具体看torch.mean()的用例。

2 一维二维

# 二维 
a = torch.arange(6) * 1.
b = a.reshape(2, 3)
print(b.shape)
print(b)
print(b.mean(dim=0).shape)
print(b.mean(dim=0))
print(b.mean(dim=1).shape)
print(b.mean(dim=1))

3 参考文献

[1]torch.mean()
[2]PyTorch基础(九)----- torch.mean()方法
[3]orch.mean()、tensor.mean() 用法及维度的理解(二维、三维)
[4]torch.mean()

你可能感兴趣的:(Pytorch学习,pytorch,深度学习,python)