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:
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) |
chevron_right
filter_none
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) |
chevron_right
filter_none
Output:
1.0000 -5.6990 7.1000 10.0001 [torch.FloatTensor of size 4] 2 -5 8 11 [torch.FloatTensor of size 4]
Recommended Posts:
- Python - PyTorch add() method
- Python - PyTorch abs() method
- Python | PyTorch tan() method
- Python | PyTorch cos() method
- Python | PyTorch sin() method
- Python - PyTorch div() method
- Python - PyTorch exp() method
- Python - PyTorch log() method
- Python Pytorch ones() method
- Python Pytorch eye() method
- Python - PyTorch numel() method
- Python | PyTorch sinh() method
- Python | PyTorch cosh() method
- Python | PyTorch tanh() method
- Python - PyTorch is_storage() method
- Python - PyTorch trunc() method
- Python - PyTorch floor() method
- Python - PyTorch is_tensor() method
- Python - PyTorch frac() method
- Python - PyTorch is_storage() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

