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表示剩下的值 ...
随机推荐
- 【原创】Airflow 简介&如何部署一个健壮的 apache-airflow 调度系统
声明 本文摘录了很多前辈的文章,原文如下: https://www.jianshu.com/p/2ecef979c606 Airflow 简介 Airflow是一个可编程,调度和监控的工作流平台,基于 ...
- 13.生产环境中的 redis 是怎么部署的?
作者:中华石杉 面试题 生产环境中的 redis 是怎么部署的? 面试官心理分析 看看你了解不了解你们公司的 redis 生产集群的部署架构,如果你不了解,那么确实你就很失职了,你的 redis 是主 ...
- LR性能测试分析流程
LR性能测试分析流程 一. 判断测试结果的有效性 (1)在整个测试场景的执行过程中,测试环境是否正常. (2)测试场景的设置是否正确.合理. (3)测试结果是否直接暴露出系统的一些问题. (4 ...
- IDEA 一键生成所有setter方法(GenerateAllSetter插件)
GenerateAllSetter插件使用效果如下: alt+enter快捷键选择Generate all setter 之后就会自动生成其中的所有setter方法 下面介绍idea安装步骤: alt ...
- Mysql使用语法总结
查看数据库 show databases; 使用数据库 use honeypot; 查看数据表 show tables; 查看数据表结构 desc TABLEname; 修改数据表的某个字段的类型 a ...
- 201871010131-张兴盼《面向对象程序设计(java)》第十四周学习总结
项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业要求在哪里 https://www.cnblogs.com/lily-2018/p/1 ...
- day36_8_20数据库3外键
一.一对多 在数据库使用数据中经常遇到一对多的情况,以公司员工为例. 一张完整的员工表有以下字段: id name gender dep_name dep_desc . 以此建表得: id n ...
- eclipse打可运行的jar
参考:https://www.cnblogs.com/wangzhisdu/p/7832666.html 用eclipse打包可运行的jar比较坑的地方: 3.1 从下拉框选择该jar的入口文件,即m ...
- C++随机马赛克图程序
效果: 或者灰度,cell大小可调 代码: #include <opencv2\opencv.hpp> #include <Windows.h> struct paramete ...
- CSS中的父相子绝布局
主要应用场景,就是我想要块的布局根据父级来定位,而不是根据页面. 例如,下面的例子中,我用两个半圆拼成一个正圆,思路是用一个父级标签把两个子标签包起来,父标签是一个正圆,然后子标签各占一半,先化成两个 ...