INRs#

class spherical_inr.inr.HerglotzNet(num_atoms: int, mlp_sizes: List[int], output_dim: int, *, bias: bool = True, L_init: int = 15, omega0_mlp: float = 1.0, rot: bool = False)[source]#

Bases: Module

Herglotz-Net on the 2-sphere.

This network represents functions defined on the unit sphere by combining a Herglotz positional encoding with a sine-activated multilayer perceptron.

Inputs are provided in spherical coordinates \((\theta,\phi)\) and internally converted to Cartesian coordinates on the unit sphere,

\[x(\theta,\phi) = (\sin\theta\cos\phi,\; \sin\theta\sin\phi,\; \cos\theta).\]

The overall mapping implemented by the network is

\[f(\theta,\phi) = \operatorname{SineMLP} \Bigl( \psi^{H}\bigl(x(\theta,\phi)\bigr) \Bigr),\]

where \(\psi^{\mathrm{H}}\) is the Cartesian Herglotz positional encoding defined in HerglotzPE.

Parameters:
  • num_atoms (int) – Number of Herglotz atoms (output channels of the positional encoding).

  • mlp_sizes (list[int]) – Hidden-layer widths of the sine-activated MLP.

  • output_dim (int) – Dimensionality of the network output.

  • bias (bool, optional) – Whether to include bias terms in the MLP. Default = True

  • L_init (int, optional) – Upper bound used to initialize the Herglotz magnitude parameters \(\rho_k\). Default = 15

  • omega0_mlp (float, optional) – Frequency factor \(\omega_0^{\mathrm{MLP}}\) used in the sine activations of the MLP. Default = 1.0

  • rot (bool, optional) – If True, enables a learnable quaternion rotation in the Herglotz positional encoding. Default = False

forward(x: Tensor)[source]#

Evaluate the Herglotz-based SIREN on the 2-sphere.

The input angles \((\theta,\phi)\) are first mapped to Cartesian coordinates on the unit sphere, then encoded using the Cartesian Herglotz positional encoding and processed by a sine-activated MLP.

Parameters:

x (torch.Tensor) – Tensor of shape (..., 2) containing spherical angles \((\theta,\phi)\) in radians.

Returns:

Network output of shape (..., output_dim).

Return type:

torch.Tensor

Raises:

ValueError – If x.shape[-1] != 2.

class spherical_inr.inr.INR(positional_encoding: Module, mlp: Module)[source]#

Bases: Module

Composable implicit neural representation.

This class represents an implicit function as the composition

\[f(x) = \mathrm{MLP}(\psi(x)),\]

where \(\psi\) is a positional encoding and the MLP is a pointwise neural network.

Parameters:
  • positional_encoding (PositionalEncoding) – Positional encoding module \(\psi\). Must expose an out_dim attribute and be callable on a tensor.

  • mlp (MLP) – Backbone network applied to the encoded features. Must expose in_dim and out_dim attributes and be callable.

forward(x: Tensor)[source]#

Evaluate the implicit neural representation.

This method applies the positional encoding followed by the MLP backbone.

Parameters:

x (torch.Tensor) – Input tensor passed to the positional encoding. Shape and interpretation depend on the chosen encoding pe.

Returns:

Output of the MLP applied to the encoded input. Shape (..., mlp.out_dim).

Return type:

torch.Tensor

Notes

The method doesn’t check whether the dimensions between the backbone and the positional encodings are consistent.

class spherical_inr.inr.SirenNet(num_atoms: int, mlp_sizes: List[int], output_dim: int, *, bias: bool = True, omega0_pe: float = 30.0, omega0_mlp: float = 30.0)[source]#

Bases: Module

SIREN on the 2-sphere with learned Fourier positional encoding.

This network represents a function of spherical angles \((\theta,\phi)\) by applying a learned Fourier feature map directly to the angles, followed by a sine-activated multilayer perceptron:

\[f(\theta,\phi) = \operatorname{SineMLP}\bigl(\psi^{\mathrm{F}}(\theta,\phi)\bigr),\]

where \(\psi^{\mathrm{F}}\) is the Fourier positional encoding defined in FourierPE.

No coordinate transformation is applied: the angles are treated as inputs in \(\mathbb{R}^2\).

Parameters:
  • num_atoms (int) – Number of Fourier features (output channels of the positional encoding).

  • mlp_sizes (list[int]) – Hidden-layer widths of the sine-activated MLP.

  • output_dim (int) – Dimensionality of the network output.

  • bias (bool, optional) – Whether to include bias terms in both the positional encoding and the MLP. Default = True

  • omega0_pe (float, optional) – Frequency factor \(\omega_0^{\mathrm{PE}}\) used in the Fourier encoding. Default = 30.0

  • omega0_mlp (float, optional) – Frequency factor \(\omega_0^{\mathrm{MLP}}\) used in the sine activations of the MLP. Default = 30.0

  • input_dim (int, optional) – Dimensionality of the input space. Must be 2 for \((\theta,\phi)\). Default = 2

forward(x: Tensor)[source]#

Evaluate the SIREN on spherical angles.

The input angles \((\theta,\phi)\) are encoded using learned Fourier features and then processed by a sine-activated MLP.

Parameters:

x (torch.Tensor) – Tensor of shape (..., 2) containing spherical angles \((\theta,\phi)\) in radians.

Returns:

Network output of shape (..., output_dim).

Return type:

torch.Tensor

class spherical_inr.inr.SphericalSirenNet(num_atoms: int, mlp_sizes: List[int], output_dim: int, *, bias: bool = True, omega0_mlp: float = 1.0)[source]#

Bases: Module

Spherical-SIREN on the 2-sphere using real spherical harmonics.

This network represents functions defined on the sphere by first encoding angular coordinates \((\theta,\phi)\) using real spherical harmonics, then applying a sine-activated multilayer perceptron.

The mapping is

\[f(\theta,\phi) = \operatorname{SineMLP}\bigl(\psi^{\mathrm{SH}}(\theta,\phi)\bigr),\]

where \(\psi^{\mathrm{SH}}\) denotes the real spherical harmonics positional encoding.

Parameters:
  • num_atoms (int) – Number of spherical harmonic basis functions retained (i.e. the first num_atoms channels in the standard \((\ell,m)\) ordering).

  • mlp_sizes (list[int]) – Hidden-layer widths of the sine-activated MLP.

  • output_dim (int) – Dimensionality of the network output.

  • bias (bool, optional) – Whether to include bias terms in the MLP.

  • omega0_mlp (float, optional) – Frequency factor \(\omega_0^{\mathrm{MLP}}\) used in the sine activations of the MLP. Default : 1.0.

forward(x: Tensor) Tensor[source]#

Evaluate the spherical-harmonics SIREN.

The input angles \((\theta,\phi)\) are encoded using real spherical harmonics and then processed by a sine-activated MLP.

Parameters:

x (torch.Tensor) – Tensor of shape (..., 2) containing spherical angles \((\theta,\phi)\) in radians.

Returns:

Network output of shape (..., output_dim).

Return type:

torch.Tensor

Raises:

ValueError – If x.shape[-1] != 2.