opengsl.module.functional

opengsl.module.functional.normalize(mx, style='symmetric', add_loop=True, p=None)[source]

Normalize the feature matrix or adj matrix.

Parameters
  • mx (torch.tensor) – Feature matrix or adj matrix to normalize. Note that either sparse or dense form is supported.

  • style (str) – If set as row, mx will be row-wise normalized. If set as symmetric, mx will be normalized as in GCN. If set as softmax, mx will be normalized using softmax. If set as row-norm, mx will be normalized using F.normalize in pytorch.

  • add_loop (bool) – Whether to add self loop.

  • p (float) – The exponent value in the norm formulation. Onlu used when style is set as row-norm.

Returns

normalized_mx – The normalized matrix.

Return type

torch.tensor