noether.modeling.modules.layers.continuous_sincos_embed¶
Classes¶
Configuration for Continuous Sine-Cosine Embedding layer. |
|
Embedding layer for continuous coordinates using sine and cosine functions. |
Module Contents¶
- class noether.modeling.modules.layers.continuous_sincos_embed.ContinuousSincosEmbeddingConfig(/, **data)¶
Bases:
pydantic.BaseModelConfiguration for Continuous Sine-Cosine Embedding layer.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
Dimensionality of the output embedding.
- mode: Literal['wavelength', 'nerf'] = None¶
Frequency schedule.
"wavelength"(default): transformer-style geometric wavelengths from1tomax_wavelength. Suitable for integer / unnormalized coordinates."nerf": NeRF-style log-spaced frequencies fromπtoπ * max_frequency. Suitable for coordinates normalized to[-1, 1]. TheLavailable bands are distributed evenly in log-frequency across this range.
- max_frequency: float | None = None¶
Highest frequency band for NeRF mode, in units of
π. TheLfrequencies are log-spaced betweenπ(wavelength 2, spans the[-1, 1]domain) andπ * max_frequency(wavelength2 / max_frequency). Required whenmode == "nerf"; pick based on the smallest spatial scale you need to resolve in normalized coordinates (rough heuristic:1 / typical_point_spacing).
- class noether.modeling.modules.layers.continuous_sincos_embed.ContinuousSincosEmbed(config)¶
Bases:
torch.nn.ModuleEmbedding layer for continuous coordinates using sine and cosine functions. The original implementation from the Attenion is All You Need paper, deals with descrete 1D cordinates (i.e., a sequence). Howerver, this implementation is able to deal with 2D and 3D coordinate systems as well.
Two frequency schedules are supported via
config.mode:"wavelength"(default): geometric wavelengths from1tomax_wavelength, matching the original Transformer encoding. Use this for integer / unnormalized coordinates."nerf": log-spaced frequencies fromπtoπ * max_frequency. Use this for coordinates normalized to[-1, 1].
- Parameters:
config (ContinuousSincosEmbeddingConfig) – Configuration for the ContinuousSincosEmbed module. See
ContinuousSincosEmbeddingConfigfor the available options.
- omega: torch.Tensor¶
- padding_tensor: torch.Tensor¶
- input_dim¶
- ndim_padding¶
- sincos_padding¶
- mode¶
- max_wavelength¶
- max_frequency¶
- padding¶
- forward(coords)¶
Forward method of the ContinuousSincosEmbed layer.
- Parameters:
coords (torch.Tensor) – Tensor of coordinates. The shape of the tensor should be [batch size, number of points, coordinate dimension] or [number of points, coordinate dimension].
- Raises:
NotImplementedError – Only supports sparse (i.e. [number of points, coordinate dimension]) or dense (i.e. [batch size, number of points, coordinate dimension]) coordinates systems.
- Returns:
Tensor with embedded coordinates.
- Return type: