torch.max
torch.max()
torch.max(input) -> Tensor
Explation:
Returns the maximum value of all elements in the input tensor
Example:
>>> a = torch.randn(1, 3)
>>> a
tensor([[-0.7461, -0.7730, 0.6381]])
>>> torch.max(a)
tensor(0.6381)
torch.max(input, dim, keepdim=False, out=None) ->(Tensor, LongTensor)
Explation:
Returns a namedtuple (values, indices) where values is the maximum value of each row of the input tensor in the given dimension dim. And indices is the index location of each maximum value found (argmax).
Parameters:
- input(Tensor) - the input tensor
- dim(int) - the dimension to reduce
- keepdim(bool, optional) - whether the output tensors have
dimretained or not. Default:False. - out(tuple, optional) - the result tuple of two output tensors (max, max_indices)
Example:
>>> a = torch.randn(4, 4)
tensor([[-0.7037, -0.9814, -0.2549, 0.7349],
[-0.0937, 0.9692, -0.2475, -0.3693],
[ 0.5427, 0.9605, 0.2246, 0.3269],
[-0.9964, 0.6920, 0.7989, -0.2616]])
>>> torch.max(a)
torch.return_types.max(values=tensor([0.7349, 0.9692, 0.9605, 0.7989]),
indices=tensor([3, 1, 1, 2]))
torch.max(input, other, out=None) ->Tensor
Explation:
Each element of the tensor input is compared with the corresponding element of the tensor other and an element-wise maximum is taken. The shapes of input and other don’t need to match, but they must be broadcastable.
\]
Parameters:
- input(Tensor) - the input tensor
- other(Tensor) - the second input tensor
- out(Tensor, optional) - the output tensor
Example:
>>> a = torch.randn(4)
>>> a
tensor([ 0.2942, -0.7416, 0.2653, -0.1584])
>>> b = torch.randn(4)
>>> b
tensor([ 0.8722, -1.7421, -0.4141, -0.5055])
>>> torch.max(a, b)
tensor([ 0.8722, -0.7416, 0.2653, -0.1584])
同理,这些方法可推广至torch.min().
torch.max的更多相关文章
- torch.max与torch.argmax
形式: torch.max(input) → Tensor 返回输入tensor中所有元素的最大值: a = torch.randn(1, 3) >>0.4729 -0.2266 -0.2 ...
- (原)torch的训练过程
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6221622.html 参考网址: http://ju.outofmemory.cn/entry/284 ...
- PyTorch官方中文文档:torch.Tensor
torch.Tensor torch.Tensor是一种包含单一数据类型元素的多维矩阵. Torch定义了七种CPU tensor类型和八种GPU tensor类型: Data tyoe CPU te ...
- PyTorch官方中文文档:torch
torch 包 torch 包含了多维张量的数据结构以及基于其上的多种数学操作.另外,它也提供了多种工具,其中一些可以更有效地对张量和任意类型进行序列化. 它有CUDA 的对应实现,可以在NVIDIA ...
- torch分类问题
import torch from torch.autograd import Variable import torch.nn.functional as F import matplotlib.p ...
- pytorch max和clamp
torch.max() torch.max(a):数组a的最大值 torch.max(a, dim=1):多维数组沿维度1方向上的最大值,若a为二维数组,则为每行的最大值(此时是对每行的每列值比较取最 ...
- torch文档学习笔记
下面为官方文档学习笔记 http://pytorch.org/docs/0.3.0/index.html 1.torch.Tensor from __future__ import print_ ...
- torch基础学习
目录 Pytorch Leture 05: Linear Rregression in the Pytorch Way Logistic Regression 逻辑回归 - 二分类 Lecture07 ...
- pytorch中的view函数和max函数
一.view函数 代码: a=torch.randn(,,,) b = a.view(,-) print(b.size()) 输出: torch.Size([, ]) 解释: 其中参数-1表示剩下的值 ...
随机推荐
- Qt 连接MySQL
工程文件 QT += sql 举例 QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName(&q ...
- weblogic删除域
彻底删除weblogic域的方法: 例如:删除域名为:fm_ump的域 第一步,删除域注册记录: [bofm@UAT02-BIZ-ZJCG-AP-008 Middleware]$ cd /home/s ...
- jQuery基础的HTML与text区别
浏览器样式 <body> <h1>jQueryAPI特点<a href="#">a标<i>来个斜体</i>签</a ...
- python从入门到放弃之进程进阶篇
什么我们得了解清楚什么是进程,进程就是系统分配的一个资源单位,真正在程序中干活得是线程,默认是每个进程中都拥有一个线程 然后我们在了解下什么是进程池这个概念 进程池是的数量是取决于我当前电脑的逻辑处理 ...
- Java数据库连接组件C3P0和DBCP
C3P0连接池组件 开源数据库连接池组件 jar包:c3p0-0.9.2.jar和mchange-commons-java-0.2.2.3.jar 支持JDBC3规范和JDBC2的标准扩展 使用项目H ...
- Java面试题:JVM中的类加载机制
JVM 的类加载机制是指 JVM 把描述类的数据从 .class 文件加载到内存,并对数据进行校验.转换解析和初始化,最终形成可以被虚拟机直接使用的 Java 类型,这就是 JVM 的类加载机制. 类 ...
- 未加载opencv_world330.pdb
根据设置下载对应的pdb文件. 无法查找或打开pdb文件
- python 函数,模块知识点运用示例
给定验证码长度n,生成随机验证码,验证码由数字.字母组成(参考chr()内置方法) # 给定验证码长度n,生成随机验证码,验证码由数字.字母组成(参考chr()内置方法) # 第33-126号(共94 ...
- Portainer
docker search portainer docker pull portainer/portainer docker run -it \ --name prtainer \ -p 9000:9 ...
- 03-numpy-笔记-expand_dims
>>> x = np.array([[1,2,3],[4,5,6]]) >>> x.shape (2, 3) >>> np.expand_dims ...