gt
是 Open3D 中 open3d.core.Tensor
类的方法之一。它返回一个布尔值张量,表示输入张量的每个元素是否大于给定的标量、数组、张量或一个与之相同形状的张量。
def gt(self, other: Union[float, np.ndarray, 'Tensor']) -> 'Tensor':
other
:可以是一个浮点数、NumPy 数组、张量或一个形状相同的张量。other
。import open3d.core as o3c
import numpy as np
a = o3c.Tensor(np.array([1, 2, 3, 4, 5], dtype=np.float32))
print("input tensor:", a)
# scalar
print("tensor > 2.5:", a.gt(2.5))
# array
b = np.array([2, 4, 6, 8, 10], dtype=np.float32)
print("tensor > array:", a.gt(b))
# tensor
c = o3c.Tensor(np.array([3, 3, 3, 3, 3], dtype=np.float32))
print("tensor > tensor:", a.gt(c))
输出:
input tensor: [1., 2., 3., 4., 5.]
tensor > 2.5: [False, False, True, True, True]
tensor > array: [False, False, False, False, False]
tensor > tensor: [False, False, False, True, True]
TypeError
:如果 other
参数的类型不支持。