MinkowskiNormalization

MinkowskiBatchNorm

class MinkowskiEngine.MinkowskiBatchNorm(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

用于稀疏张量的批归一化层。

有关更多详细信息,请参见 pytorch torch.nn.BatchNorm1d

__init__(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

初始化内部模块状态,由 nn.Module 和 ScriptModule 共享。

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)

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

应被所有子类重写。

注意

虽然 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 (如果给定),但 dtype 不变。 当设置了 non_blocking 时,它会尝试相对于主机异步转换/移动,例如,将具有固定内存的 CPU 张量移动到 CUDA 设备。

请参见下面的示例。

注意

此方法会就地修改模块。

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

和缓冲区

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

此模块中的浮点参数和缓冲区

tensor (torch.Tensor): 张量,其 dtype 和 device 是此模块中所有参数和缓冲区的所需 dtype 和 device

所有参数和缓冲区的 dtype 和 device

memory_format (torch.memory_format): 此模块中 4D 参数和缓冲区的所需内存格式(仅关键字参数)

此模块中的 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

MinkowskiSyncBatchNorm

class MinkowskiEngine.MinkowskiSyncBatchNorm(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, process_group=None)

具有多 GPU 同步的批归一化层。

__init__(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, process_group=None)

初始化内部模块状态,由 nn.Module 和 ScriptModule 共享。

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)

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

应被所有子类重写。

注意

虽然 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 (如果给定),但 dtype 不变。 当设置了 non_blocking 时,它会尝试相对于主机异步转换/移动,例如,将具有固定内存的 CPU 张量移动到 CUDA 设备。

请参见下面的示例。

注意

此方法会就地修改模块。

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

和缓冲区

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

此模块中的浮点参数和缓冲区

tensor (torch.Tensor): 张量,其 dtype 和 device 是此模块中所有参数和缓冲区的所需 dtype 和 device

所有参数和缓冲区的 dtype 和 device

memory_format (torch.memory_format): 此模块中 4D 参数和缓冲区的所需内存格式(仅关键字参数)

此模块中的 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

MinkowskiInstanceNorm

class MinkowskiEngine.MinkowskiInstanceNorm(num_features)

用于稀疏张量的实例归一化层。

__init__(num_features)

参数

num_features (int): 输入特征的维度。

mode (GlobalPoolingModel, optional): 内部全局池化计算模式。

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)

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

应被所有子类重写。

注意

虽然 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 (如果给定),但 dtype 不变。 当设置了 non_blocking 时,它会尝试相对于主机异步转换/移动,例如,将具有固定内存的 CPU 张量移动到 CUDA 设备。

请参见下面的示例。

注意

此方法会就地修改模块。

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

和缓冲区

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

此模块中的浮点参数和缓冲区

tensor (torch.Tensor): 张量,其 dtype 和 device 是此模块中所有参数和缓冲区的所需 dtype 和 device

所有参数和缓冲区的 dtype 和 device

memory_format (torch.memory_format): 此模块中 4D 参数和缓冲区的所需内存格式(仅关键字参数)

此模块中的 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