Pytorch学习日志之函数用法记录

1.torch.max() return 所有元素中的最大值.

   torch.max(input,dim,keepdim=False),dim =0时返回每一列的最大值及索引,dim=1时返回每一行的最大值及索引。

    keepdim=True时返回的值的形状与dim相同

2.torch.squeeze(a)压缩第a维维度为1的轴,torch.squeeze(),压缩所有维度为1的轴,torch.unsqueeze(a),在第a个轴上扩充一个维度为1的轴

3.torch.Tensor.view(),根据原有数据重新分配为一个新的张量,eg: x = torch.randn(2,4),y=x.view(4,2)

  torch.Tensor.view_as(tensor)相当于torch.Tensor.view_as(tensor.size())

猜你喜欢

转载自blog.csdn.net/qq_40103460/article/details/80665385