評價此頁

torch.ceil#

torch.ceil(input, *, out=None) Tensor#

返回一個新張量,其中包含input元素的向上取整值,即大於或等於每個元素的最小整數。

對於整數輸入,遵循 array-api 約定,返回輸入張量的副本。

outi=inputi\text{out}_{i} = \left\lceil \text{input}_{i} \right\rceil
引數

input (Tensor) – 輸入張量。

關鍵字引數

out (Tensor, optional) – 輸出張量。

示例

>>> a = torch.randn(4)
>>> a
tensor([-0.6341, -1.4208, -1.0900,  0.5826])
>>> torch.ceil(a)
tensor([-0., -1., -1.,  1.])