open3d.core.Tensor
的append
函数将一个张量追加到另一个张量的末尾。
torch.Tensor.append(other_tensor)
返回追加过新元素的新张量。
import open3d.core as o3c
tensor1 = o3c.Tensor([[1, 2, 3], [4, 5, 6]])
tensor2 = o3c.Tensor([[7, 8, 9], [10, 11, 12]])
tensor3 = tensor1.append(tensor2)
print(tensor1)
print(tensor2)
print(tensor3)
输出:
[[1. 2. 3.]
[4. 5. 6.]]
[[ 7. 8. 9.]
[10. 11. 12.]]
[[ 1. 2. 3.]
[ 4. 5. 6.]
[ 7. 8. 9.]
[10. 11. 12.]]
append
函数仅支持在末尾追加新元素。如果other_tensor
的形状与原始张量的形状不兼容,则会引发ValueError
异常。