MinkowskiInterpolation

MinkowskiInterpolation

class MinkowskiEngine.MinkowskiInterpolation(return_kernel_map=False, return_weights=False)

在提供的点上采样线性插值特征。

__init__(return_kernel_map=False, return_weights=False)

在指定坐标处采样线性插值特征。

参数

return_kernel_map (bool): 除了采样的特征之外,该层还会返回内核映射,作为输入行索引和输出行索引的配对。默认为 False。

return_weights (bool): 如果为 True,则返回线性插值权重。默认为 False。

cpu() → T

将所有模型参数和缓冲区移动到 CPU。

返回值

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

将所有模型参数和缓冲区移动到 GPU。

这也会使相关的参数和缓冲区成为不同的对象。因此,如果模块在优化时将驻留在 GPU 上,则应在构建优化器之前调用它。

参数
device (int, optional): 如果指定,所有参数将

复制到该设备

返回值

Module: self

double() → T

将所有浮点参数和缓冲区转换为 double 数据类型。

返回值

Module: self

float() → T

将所有浮点参数和缓冲区转换为 float 数据类型。

返回值

Module: self

forward(input: MinkowskiSparseTensor.SparseTensor, tfield: torch.Tensor)

定义每次调用时执行的计算。

应该被所有子类重写。

注意

尽管 forward 过程的配方需要在该函数中定义,但之后应该调用 Module 实例,而不是这个函数,因为前者负责运行注册的钩子,而后者会默默地忽略它们。

to(*args, **kwargs)

移动和/或转换参数和缓冲区。

可以这样调用

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

它的签名与 torch.Tensor.to() 类似,但仅接受浮点型所需的 dtype。此外,此方法只会将浮点参数和缓冲区转换为 dtype(如果给定)。整数参数和缓冲区将被移动到 device(如果给定),但数据类型不变。当设置 non_blocking 时,它会尝试相对于主机异步转换/移动(如果可能),例如,将具有固定内存的 CPU 张量移动到 CUDA 设备。

请参见下面的示例。

注意

此方法就地修改模块。

参数
device (torch.device): 此模块中参数的所需设备

和缓冲区

dtype (torch.dtype): 此模块中浮点参数的所需浮点类型

和缓冲区

tensor (torch.Tensor): 张量,其 dtype 和设备是

此模块中所有参数和缓冲区的所需 dtype 和设备

memory_format (torch.memory_format): 所需的内存

此模块中 4D 参数和缓冲区的格式(仅关键字参数)

返回值

Module: self

示例

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

将所有参数和缓冲区转换为 dst_type

参数

dst_type (type or string): 所需的类型

返回值

Module: self