Python – PyTorch ceil() method Last Updated : 26 May, 2020 Improve Improve Like Article Like Save Share Report PyTorch torch.ceil() method returns a new tensor having the ceil value of the elements of input, Which is the smallest integer larger than or equal to each element. Syntax: torch.ceil(inp, out=None) Arguments inp: This is input tensor. out: The output tensor. Return: It returns a Tensor. Let’s see this concept with the help of few examples: Example 1: # Importing the PyTorch library import torch # A constant tensor of size n a = torch.FloatTensor([1.3, -5.6, 7.9, 10.1]) print(a) # Applying the ceil function and # storing the result in 'out' out = torch.ceil(a) print(out) Output: 1.3000 -5.6000 7.9000 10.1000 [torch.FloatTensor of size 4] 2 -5 8 11 [torch.FloatTensor of size 4] Example 2: # Importing the PyTorch library import torch # A constant tensor of size n a = torch.FloatTensor([1.00001, -5.699, 7.100001, 10.0001]) print(a) # Applying the ceil function and # storing the result in 'out' out = torch.ceil(a) print(out) Output: 1.0000 -5.6990 7.1000 10.0001 [torch.FloatTensor of size 4] 2 -5 8 11 [torch.FloatTensor of size 4] Like Article Suggest improvement Next Python - PyTorch clamp() method Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Pandas Series dt.ceil | Ceil DateTime To Specified Frequency PyTorch vs PyTorch Lightning floor() and ceil() function Python Python | Pandas DatetimeIndex.ceil() Python | Pandas TimedeltaIndex.ceil Python | Pandas Timestamp.ceil Python | Pandas Timedelta.ceil() Python | math.ceil() function Ceil and floor of the dataframe in Pandas Python – Round up and Truncate numpy.ceil() in Python Like P PranchalKatiyar Follow Article Tags : Python-PyTorch Python Practice Tags : python