Pytorch基础操作

您所在的位置:网站首页 复数torch Pytorch基础操作

Pytorch基础操作

2024-07-07 02:23| 来源: 网络整理| 查看: 265

FunctionDescriptionDetailabsComputes the absolute value of each element in input.返回元素的绝对值absoluteAlias for torch.abs()torch.abs 的别名ceilReturns a new tensor with the ceil of the elements of input, the smallest integer greater than or equal to each element.对元素向上取整roundReturns a new tensor with each of the elements of input rounded to the closest integer.对元素四舍五入floorReturns 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 说明

对张量里的每一个元素计算绝对值

o u t i = ∣ i n p u t i ∣ 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 说明

向上取整

o u t i = ⌈ i n p u t i ⌉ 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 说明

向下取整

o u t i = ⌊ i n p u t i ⌋ 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.])


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3