load
函数用于从磁盘中读取保存的张量数据。
class Tensor:
@staticmethod
def load(file_path: str) -> Tensor:
pass
file_path
:要读取的文件路径。文件格式必须是 .npy
或 .npz
。返回一个 Tensor
对象,表示从文件中读取的张量数据。
import open3d.core as o3c
# 保存张量数据
tensor = o3c.Tensor([[1, 2], [3, 4]])
o3c.Tensor.save("tensor.npy", tensor)
# 读取张量数据
loaded_tensor = o3c.Tensor.load("tensor.npy")
print(loaded_tensor)
# 输出:o3c.core.Tensor[shape={2, 2}, stride={2, 1}, Int32, between[1, 4]]
FileNotFoundError
:指定的文件路径不存在或无法访问。ValueError
:文件格式无效或文件中保存的数据与当前环境不兼容。