Pytorch基础操作 —— 17. 绝对值、取整
Function | Description | Detail |
---|---|---|
abs | Computes the absolute value of each element in input. | 返回元素的绝对值 |
absolute | Alias for torch.abs() | torch.abs 的别名 |
ceil | Returns a new tensor with the ceil of the elements of input, the smallest integer greater than or equal to each element. | 对元素向上取整 |
round | Returns a new tensor with each of the elements of input rounded to the closest integer. | 对元素四舍五入 |
floor | Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element. | 对元素向下取整 |
文章目录
- torch.abs
- 原型
- 说明
- 例子
- torch.ceil
- 原型
- 说明
- 例子
- torch.round
- 原型
- 说明
- 例子
- torch.floor
- 原型
- 说明
- 例子
torch.abs
原型
torch.abs(input, *, out=None) → Tensor
说明
对张量里的每一个元素计算绝对值
outi=∣inputi∣out_i = | input_i | outi=∣inputi∣
例子
>>> torch.abs(torch.tensor([-1, -2, 3]))
tensor([ 1, 2, 3])
torch.ceil
原型
torch.ceil(input, *, out=None) → Tensor
说明
向上取整
outi=⌈inputi⌉out_i = \left \lceil input_i \right \rceil outi=⌈inputi⌉
例子
>>> a = torch.randn(4)
>>> a
tensor([-0.6341, -1.4208, -1.0900, 0.5826])
>>> torch.ceil(a)
tensor([-0., -1., -1., 1.])
torch.round
原型
torch.round(input, *, out=None) → Tensor
说明
四舍五入
例子
>>> a = torch.randn(4)
>>> a
tensor([ 0.9920, 0.6077, 0.9734, -1.0362])
>>> torch.round(a)
tensor([ 1., 1., 1., -1.])
torch.floor
原型
torch.floor(input, *, out=None) → Tensor
说明
向下取整
outi=⌊inputi⌋out_i = \left \lfloor input_i \right \rfloor outi=⌊inputi⌋
例子
>>> a = torch.randn(4)
>>> a
tensor([-0.8166, 1.5308, -0.2530, -0.2091])
>>> torch.floor(a)
tensor([-1., 1., -1., -1.])
Pytorch基础操作 —— 17. 绝对值、取整相关推荐
- Pytorch基础操作 —— 6. 如何使用自定义数据集
文章目录 自定义数据集 Step 1. 熟悉你的数据集 有数据就要有标签 数据大小.维度一定要一样 归一化 Step 2. 确定如何加载你的数据集 使用 DataLoader 批量加载数据 需要注意的 ...
- 02.PyTorch基础操作(3-1 机器学习中的分类与回归问题-机器学习基本构成元素)
@[TOC](02.PyTorch基础操作(3-1 机器学习中的分类与回归问题-机器学习基本构成元素)) 来自慕课网 一.3-1 机器学习中的分类与回归问题-机器学习基本构成元素
- pytorch基础操作
处理数据(Torch) 文章目录 处理数据(Torch) 数据初始化 tensor的索引.切片.连接.变异操作 数学操作 Tensor是一种特殊的数据结构,在Pytorch中,就是用Tensor来编码 ...
- pytorch基础操作学习笔记(autograd,Tensor)
简述 简单讲讲关于torch.autograd内容(因为我也有点菜) 文章目录 简述 简单讲讲 Tensor 介绍Tensor 创建Tensor 获取Tensor数据规模 将tensor转成其他数据类 ...
- oracle 取整点的数据,Oracle SQL语句操作数字:取整、四舍五入及格式化
用oracle sql对数字进行操作: 取上取整.向下取整.保留N位小数.四舍五入.数字格式化 取整(向下取整): select floor(5.534) from dual; select trun ...
- oracle 数字格式取整,Oracle SQL语句操作数字:取整、四舍五入及格式化
用oracle sql对数字进行操作: 取上取整.向下取整.保留N位小数.四舍五入.数字格式化 取整(向下取整): select floor(5.534) from dual; select trun ...
- oracle sql查询取整,Oracle SQL语句操作数字:取整、四舍五入及格式化
用oracle sql对数字进行操作: 取上取整.向下取整.保留N位小数.四舍五入.数字格式化 取整(向下取整): select floor(5.534) from dual; select trun ...
- math的向上取整_Javascript中Math常用操作,向上取整、向下取整、四舍五入
写在前面,最最常用几个方法: 绝对值:Math.abs(x) 最大值:Math.max([x[, y[, -]]]) 最小值:Math.min([x[, y[, -]]]) 随机值:Math.rand ...
- 多项式的基础操作(逆元/除法/取模/对数ln/开根sqrt/指数exp/快速幂)带模板+luogu全套例题
文章目录 多项式的逆元 理论推导 模板 例题:[luogu P4238][模板]多项式乘法逆 题目 code 多项式的除法/取模 理论推导 多项式牛顿迭代法 模板 例题:[luoguP4512][模板 ...
最新文章
- Halliburton首席数据科学家兼技术研究员谈能源行业AI应用现状
- Webhook与Jenkins自动构建(上)
- nagios系列(六)之nagios实现对服务器cpu温度的监控
- 基于Android和WI-FI通信的智能家居系统
- latex 图片大小_用LaTeX写作业——插入图片(二)
- 张朝阳:“搜狐时尚盛典”是搜狐布局内容生态的一部分
- 关于高德地图转换经纬度为屏幕点,方便自定义需链接网络的marker且添加属性动画
- 官方发布 激情世界杯】浩海技术 GHOST XP SP3 世界杯装机特别版★用稳定压倒一切!...
- python通过正则匹配指定字符开头与结束提取中间内容
- MTK_android11_WIFI(内网)和4G(外网)共存
- 【Unity开发小技巧】Unity日志输出存储
- iis 安装完ssl 证书谷歌浏览器还是提示不安全的解决方法
- 基于瞬时功率理论的APF的SIMULINK模型
- 对于公司裁员和转型的无力吐槽
- 再讲卷积的本质及物理意义,解释的真幽默!
- Android 新手引导添加View的方法
- 区块链产业月报丨中国区块链企业已达1400家,专利申请数量全球领先!
- 关于使用mathtype插件对word公式进行右编号,章节编号更新,以及红色字体去掉问题
- #边学边记 必修4 高项:对事的管理 第5章 项目成本管理 之 项目成本预算
- Jenkins报Failed to remove prefix from file named