tnet
Orthogonality regularizer of the T-Net transforms (PointNet's feature-transform regularization).
Classes:
-
TNetOrthogonalityRegularizerβModule form of
tnet_orthogonality_regularizer.
TNetOrthogonalityRegularizer [source] ΒΆ
Bases: Module
Module form of tnet_orthogonality_regularizer.
Example
import torch
from torch_pointcloud.layers import TNet
from torch_pointcloud.losses import TNetOrthogonalityRegularizer
ftnet = TNet(local_channels=[32, 64], global_channels=[32], k=16)
out = ftnet(torch.randn(10, 16), torch.arange(2).repeat_interleave(5))
TNetOrthogonalityRegularizer()(ftnet).shape # torch.Size([])
tnet_orthogonality_regularizer [source] ΒΆ
Pull the transforms predicted by every T-Net in module towards an orthogonal matrix.
The feature-transform regularization of PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation (Qi et al., 2017), \(\lVert I - A A^\top \rVert_F\) averaged over the samples of the batch and summed over the T-Nets found in module. Pass the T-Net (or the sub-module) to regularize, e.g. a PointNet's feature transform model.ftnet to leave its input transform free, as the PointNet paper does.
The matrices are read from the running_transform the layers keep from their last forward pass, so call it after the forward and before the backward of the same batch.
Parameters:
-
module(Module) βA
TNet/DynamicTNet, or a module containing some.
Returns:
-
TensorβThe scalar regularizer (zero when
moduleholds no T-Net).
Raises:
-
RuntimeErrorβIf a T-Net has no stored transform (no forward pass yet, or
track_running_stats=False).