a=torch.randn(1,2,3)
b=torch.max(a,dim=0).values
c=torch.max(a,dim=1).values
d=torch.max(a,dim=2).values
b.shape=[2,3]
c.shape=[1,3]
d.shape=[1,2]
本文通过实例展示了如何使用PyTorch进行张量的最大值计算,并分别沿不同维度进行操作,同时解析了操作后的张量形状变化。
a=torch.randn(1,2,3)
b=torch.max(a,dim=0).values
c=torch.max(a,dim=1).values
d=torch.max(a,dim=2).values
b.shape=[2,3]
c.shape=[1,3]
d.shape=[1,2]
您可能感兴趣的与本文相关的镜像
PyTorch 2.5
PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理
580
1万+
2438
2701
1240
210

被折叠的 条评论
为什么被折叠?