Python 官方文档:入门教程 => 点击学习
文章目录 一、一个参数时的 torch.max()1. 函数介绍2. 实例 二、增加指定维度时的 torch.max()1. 函数介绍2. 实例 三、两个输入张量时的 torch.ma
torch.max(input)
参数:
import torch# 返回张量中的最大值a = torch.randn(2, 3)print(a)print(torch.max(a))
输出结果:
tensor([[ 0.0031, -0.5391, -0.9214], [-0.4647, -1.9750, 0.6924]])tensor(0.6924)
torch.max(input, dim, max=None, max_indices=None) -> (Tensor, LongTensor)
返回张量 input 在压缩指定维度 dim 时的最大值及其下标。
import torch# 返回张量在压缩指定维度时的最大值及其下标b = torch.randn(4, 4)print(b)print(torch.max(b, 0)) # 指定0维,压缩0维,0维消失,也就是行消失,返回列最大值及其下标print(torch.max(b, 1)) # 指定1维,压缩1维,1维消失,也就是列消失,返回行最大值及其下标
输出结果:
tensor([[-0.8862, 0.3502, 0.0223, 0.6035], [-2.0135, -0.1346, 2.0575, 1.4203], [ 1.0107, 0.9302, -0.1321, 0.0704], [-1.4540, -0.4780, 0.7016, 0.3029]])torch.return_types.max(values=tensor([1.0107, 0.9302, 2.0575, 1.4203]),indices=tensor([2, 2, 1, 1]))torch.return_types.max(values=tensor([0.6035, 2.0575, 1.0107, 0.7016]),indices=tensor([3, 2, 0, 2]))
torch.max(input, other_input, out=None) → Tensor
返回两张量 input 和 other_input 在对应位置上的最大值形成的新张量。
import torch# 返回两张量对应位置上的最大值c = torch.randn(4,2)d = torch.randn(4,2)print(c)print(d)print(torch.max(c, d))
输出结果:
tensor([[ 0.6778, 1.2714], [-0.9020, -1.3789], [ 0.8541, 1.2193], [-0.8481, -0.8211]])tensor([[ 2.4616, -1.2502], [ 0.0173, -0.5501], [ 1.0224, -1.5892], [ 1.3325, 0.2587]])tensor([[ 2.4616, 1.2714], [ 0.0173, -0.5501], [ 1.0224, 1.2193], [ 1.3325, 0.2587]])
来源地址:https://blog.csdn.net/weixin_44211968/article/details/128224243
--结束END--
本文标题: 【Pytorch】torch.max() 函数详解
本文链接: https://www.lsjlt.com/news/421962.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模
0