PyTorch torch.floor()
方法返回一個新的張量,該張量是輸入元素的下限,小於或等於每個元素的最大整數。
用法: torch.floor(input, out=None)
參數
- input:這是輸入張量。
- out:輸出張量。
返回:它返回張量。
讓我們借助幾個示例來了解這個概念:
範例1:
範例1:
# Importing the PyTorch library
import torch
# A constant tensor of size n
a = torch.FloatTensor([1.5, 4.2, 6.7, 3.9])
print(a)
# Applying the floor function and
# storing the result in 'out'
out = torch.floor(a)
print(out)
輸出:
1.5000 4.2000 6.7000 3.9000 [torch.FloatTensor of size 4] 1 4 6 3 [torch.FloatTensor of size 4]
範例2:
# Importing the PyTorch library
import torch
# A constant tensor of size n
a = torch.FloatTensor([1.59, 4.5999, 6.78, 3.99999])
print(a)
# Applying the floor function and
# storing the result in 'out'
out = torch.floor(a)
print(out)
輸出:
1.5900 4.5999 6.7800 4.0000 [torch.FloatTensor of size 4] 1 4 6 3 [torch.FloatTensor of size 4]
相關用法
- Python PyTorch sin()用法及代碼示例
- Python PyTorch sinh()用法及代碼示例
- Python PyTorch cosh()用法及代碼示例
- Python PyTorch tanh()用法及代碼示例
- Python PyTorch cos()用法及代碼示例
- Python PyTorch tan()用法及代碼示例
- Python PyTorch asin()用法及代碼示例
- Python PyTorch acos()用法及代碼示例
- Python PyTorch atan()用法及代碼示例
- Python PyTorch zeros()用法及代碼示例
- Python Pytorch ones()用法及代碼示例
- Python Pytorch arange()用法及代碼示例
- Python Pytorch linspace()用法及代碼示例
- Python Pytorch range()用法及代碼示例
- Python Pytorch logspace()用法及代碼示例
- Python Pytorch eye()用法及代碼示例
- Python Pytorch empty()用法及代碼示例
- Python Pytorch full()用法及代碼示例
- Python PyTorch fmod()用法及代碼示例
- Python PyTorch log()用法及代碼示例
注:本文由純淨天空篩選整理自PranchalKatiyar大神的英文原創作品 Python – PyTorch floor() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。