topobench.nn.backbones.graph.nsd_utils.orthogonal module#

class Orthogonal(d, orthogonal_map)#

Bases: Module

Orthogonal transformation module for sheaf restriction maps.

Converts lower-triangular parameters into orthogonal matrices using either the matrix exponential or Cayley transform. Based on PyTorch’s parametrization utilities.

Reference: https://pytorch.org/docs/stable/_modules/torch/nn/utils/parametrizations.html#orthogonal

Parameters:
dint

Dimension of the square orthogonal matrices to generate.

orthogonal_mapstr

Method for generating orthogonal matrices. Options are ‘matrix_exp’ or ‘cayley’.

Raises:
AssertionError

If orthogonal_map is not ‘matrix_exp’ or ‘cayley’.

__init__(d, orthogonal_map)#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(params)#

Convert parameters to orthogonal matrices.

Parameters:
paramstorch.Tensor

Lower-triangular parameters of shape [batch_size, d*(d+1)/2].

Returns:
torch.Tensor

Orthogonal matrices of shape [batch_size, d, d].

Raises:
ValueError

If an unsupported orthogonal_map method is specified.