Skip to main content

A package for spherical positional encoding

Project description

Spherical-Implicit-Neural-Representation

A package for spherical implicit neural representations using Herglotz-based positional encoding.

Installation

You can install the package from PyPI:

pip install spherical-inr

Or install the development version locally:

git clone https://github.com/yourusername/spherical_inr.git
cd spherical_inr
pip install -e .

Getting Started

Instantiate a Network

Below is an example of how to instantiate and use the HerglotzNet module:

import torch
import spherical_inr as sph 


# Parameters for HerglotzNet
input_dim = 2         # must be 1 or 2 for HerglotzNet
output_dim = 8
num_atoms = 16
mlp_sizes = 3*[32]  # hidden layer sizes
omega0 = 1.0
unit_sphere = True
seed = 42

# Instantiate the network
model = sph.HerglotzNet(
    input_dim=input_dim,
    output_dim=output_dim,
    num_atoms=num_atoms,
    mlp_sizes=mlp_sizes,
    bias=True,
    omega0=omega0,
    seed=seed
)

# Example input (for input_dim=2)
dummy_input = torch.randn(4, input_dim)
output = model(dummy_input)
print(output)

Instantiate and Use a Positional Encoding

You can also directly instantiate a positional encoding and use it in your own torch model:

import torch
import torch.nn as nn
import spherical_inr as sph 

# Instantiate Herglotz positional encoding (input_dim must be at least 2)
pe = sph.HerglotzPE(
    num_atoms=16,
    input_dim=3,
    bias=True,
    omega0=1.0,
    seed=42
)

# Example model using the positional encoding
class MyModel(nn.Module):
    def __init__(self, pe):
        super().__init__()
        self.pe = pe
        self.linear = nn.Linear(16, 8)
        
    def forward(self, x):
        x = self.pe(x)
        return self.linear(x)

model = MyModel(pe)
dummy_input = torch.randn(4, 3)
output = model(dummy_input)
print(output)

📚 References

  1. Théo Hanon, Nicolas Mil-Homens Cavaco, John Kiely, Laurent Jacques,
    Herglotz-NET: Implicit Neural Representation of Spherical Data with Harmonic Positional Encoding,
    arXiv preprint, 2025.
    arXiv:2502.13777

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spherical_inr-0.2.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spherical_inr-0.2.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file spherical_inr-0.2.1.tar.gz.

File metadata

  • Download URL: spherical_inr-0.2.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spherical_inr-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b37131c4f224c475aba535e88d51a9c435bf6171b11ab255444c7f82b9b67172
MD5 dcac8608927951d7075e704801ee6fbd
BLAKE2b-256 cdf9c45486b2d1bfcb6ab1d3d4db2ee61622e9823d3f960e3d4659b82a88d695

See more details on using hashes here.

File details

Details for the file spherical_inr-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: spherical_inr-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spherical_inr-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d29c1cab585451463d5adebe2f7a42b4065df0fe64af566a7173e5b4849f9c4e
MD5 b4800f5b9254262287c7362510f79ef6
BLAKE2b-256 3df6db81d0a4270b7a49828e34ebbd32472bd2e45f920902f6822686103e247e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page