utils

torchvectorized.utils.overload_diag(inputs: torch.Tensor)

Add an EPSILON to the diagonal of every 3x3 matrix represented by the 9 channels of an input of shape Bx9xDxHxW to improve numerical stability

Parameters:inputs (torch.Tensor) – The input tensor of shape Bx9xDxHxW, where the 9 channels represent flattened 3x3 symmetric matrices.
Returns:A volume of shape Bx9xDxHxW where each voxel represent a flattened 3x3 symmetric matrix.
Return type:torch.Tensor
Example:
import torch
from torchvectorized.utils import sym, overloadd_diag

b, c, d, h, w = 1, 9, 32, 32, 32
inputs = overload_diag(sym(torch.rand(b, c, d, h, w)))
torchvectorized.utils.sym(inputs: torch.Tensor)

Symmetrizes every 3x3 matrix represented by the 9 channels of an input of shape Bx9xDxHxW by applying \frac{1}{2}(\mathbf{X} + \mathbf{X}^{\top}).

Parameters:inputs (torch.Tensor) – The input tensor of shape Bx9xDxHxW, where the 9 channels represent flattened 3x3 symmetric matrices.
Returns:A volume of shape Bx9xDxHxW where each voxel represent a flattened 3x3 symmetric matrix.
Return type:torch.Tensor
Example:
import torch
from torchvectorized.utils import sym

b, c, d, h, w = 1, 9, 32, 32, 32
inputs = sym(torch.rand(b, c, d, h, w))