Convolutional Layers¶
2D hyperbolic convolutions and pooling for the Hyperboloid, Poincaré, and Proper Velocity models. For which conv to pick see the NN Layers guide.
Dimensional growth is internal, not in the output shape
HypConv2DHyperboloid / HypConv2DHyperboloidFHNN / FGGConv2D
HCat-concatenate a d+1-ambient input over the N-pixel receptive field
into a (d×N)+1-ambient intermediate, which the kernel projects down to
out_channels. The output ambient width is always out_channels; a
larger kernel costs parameters and compute, not output width.
LorentzConv2D does no HCat, and its output is also out_channels.
Hyperboloid¶
HypConv2DHyperboloid (the robust default) uses HCat patch extraction + Lorentz FC
(Bdeir et al. 2023). HypConv2DHyperboloidILNN is the intrinsic Lorentz conv (Shi
et al. 2026): LogCat (log-radius-preserving concatenation) + PLFC, with origin
padding. LorentzConv2D is the HRC-based variant (Euclidean conv on the spatial part; faster,
lower accuracy — legacy/benchmarking).
hyperbolix.nn_layers.HypConv2DHyperboloid ¶
HypConv2DHyperboloid(
manifold_module: Hyperboloid,
in_channels: int,
out_channels: int,
kernel_size: int | tuple[int, int],
*,
rngs: Rngs,
stride: int | tuple[int, int] = 1,
padding: str = "SAME",
input_space: str = "manifold",
reset_params: str = "fan_in",
param_dtype: DTypeLike = jnp.float32,
)
Bases: Module
Hyperbolic 2D Convolutional Layer for Hyperboloid model.
This layer implements fully hyperbolic convolution as described in "Fully Hyperbolic Convolutional Neural Networks for Computer Vision".
Computation steps: 1) Extract receptive field (kernel_size x kernel_size) of hyperbolic points 2) Apply HCat (Lorentz direct concatenation) to combine receptive field points 3) Pass through hyperbolic linear layer (LFC)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifold_module
|
object
|
Class-based Hyperboloid manifold instance |
required |
in_channels
|
int
|
Number of input channels |
required |
out_channels
|
int
|
Number of output channels |
required |
kernel_size
|
int or tuple[int, int]
|
Size of the convolutional kernel |
required |
rngs
|
Rngs
|
Random number generators for parameter initialization |
required |
stride
|
int or tuple[int, int]
|
Stride of the convolution (default: 1) |
1
|
padding
|
str
|
Padding mode, either 'SAME' or 'VALID' (default: 'SAME') |
'SAME'
|
input_space
|
str
|
Type of the input tensor, either 'tangent' or 'manifold' (default: 'manifold'). Note: This is a static configuration - changing it after initialization requires recompilation. |
'manifold'
|
reset_params
|
str
|
Kernel initialization scheme; the bias starts at zero in every scheme
(default:
Neither is the reference init: the conv layer of Bdeir et al. 2023
( |
'fan_in'
|
param_dtype
|
DTypeLike
|
Storage dtype of the trainable parameters (default: jnp.float32).
Compute precision of manifold operations is set by |
float32
|
Notes
JIT Compatibility: This layer is designed to work with nnx.jit. Configuration parameters (padding, input_space) are treated as static and will be baked into the compiled function.
References
Ahmad Bdeir, Kristian Schwethelm, and Niels Landwehr. "Fully hyperbolic convolutional neural networks for computer vision." arXiv preprint arXiv:2303.15919 (2023).
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
__call__ ¶
__call__(
x: Float[Array, "batch height width in_channels"],
c: float = 1.0,
) -> Float[
Array, "batch out_height out_width out_channels"
]
Forward pass through the hyperbolic convolutional layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array of shape (batch, height, width, in_channels)
|
Input feature map where each pixel is a point on the Hyperboloid manifold |
required |
c
|
float
|
Manifold curvature (default: 1.0) |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Array of shape (batch, out_height, out_width, out_channels)
|
Output feature map on the Hyperboloid manifold |
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
hyperbolix.nn_layers.HypConv2DHyperboloidFHNN ¶
HypConv2DHyperboloidFHNN(
manifold_module: Hyperboloid,
in_channels: int,
out_channels: int,
kernel_size: int | tuple[int, int],
*,
rngs: Rngs,
stride: int | tuple[int, int] = 1,
padding: str = "SAME",
input_space: str = "manifold",
init_scale: float = 2.3,
eps: float = 1e-05,
activation: Callable[[Array], Array] | None = None,
dropout_rate: float | None = None,
deterministic: bool = True,
param_dtype: DTypeLike = jnp.float32,
)
Bases: Module
Fully Hyperbolic Neural Networks 2D convolutional layer (Chen et al. 2021).
Uses HCat (Lorentz direct concatenation) to combine receptive field points, then applies the FHNN linear transform (time-primary sigmoid parameterization) for channel mixing.
Computation steps: 1) Map input to manifold via expmap_0 if input_space="tangent" 2) Extract receptive field (kernel_size x kernel_size) of hyperbolic points 3) Apply HCat (Lorentz direct concatenation) to combine receptive field points 4) Pass through FHNN linear (sigmoid time + spatial rescaling)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifold_module
|
Hyperboloid
|
Class-based Hyperboloid manifold instance |
required |
in_channels
|
int
|
Number of input channels (ambient dimension, including time component) |
required |
out_channels
|
int
|
Number of output channels (ambient dimension, including time component) |
required |
kernel_size
|
int or tuple[int, int]
|
Size of the convolutional kernel |
required |
rngs
|
Rngs
|
Random number generators for parameter initialization |
required |
stride
|
int or tuple[int, int]
|
Stride of the convolution (default: 1) |
1
|
padding
|
str
|
Padding mode, either 'SAME' or 'VALID' (default: 'SAME') |
'SAME'
|
input_space
|
str
|
Type of the input tensor, either 'tangent' or 'manifold' (default: 'manifold'). Note: This is a static configuration - changing it after initialization requires recompilation. |
'manifold'
|
init_scale
|
float
|
Initial value for the learnable sigmoid scale (default: 2.3) |
2.3
|
eps
|
float
|
Numerical stability epsilon (default: 1e-5) |
1e-05
|
activation
|
callable or None
|
Activation function to apply before the linear transformation (default: None). |
None
|
dropout_rate
|
float or None
|
Dropout rate applied before the linear transformation (default: None). |
None
|
deterministic
|
bool
|
If True, dropout is disabled (default: True, so a layer built with a
|
True
|
param_dtype
|
DTypeLike
|
Storage dtype of the trainable parameters (default: jnp.float32).
Compute precision of manifold operations is set by |
float32
|
Notes
JIT Compatibility: This layer is designed to work with nnx.jit. Configuration parameters (padding, input_space, activation) are treated as static and baked into the compiled function.
See Also
HypConv2DHyperboloid : Equivalent convolution using FHCNN linear instead of FHNN. HypLinearHyperboloidFHNN : The underlying FHNN linear layer.
References
Weize Chen, et al. "Fully hyperbolic neural networks." arXiv preprint arXiv:2105.14686 (2021).
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
__call__ ¶
__call__(
x: Float[Array, "batch height width in_channels"],
c: float = 1.0,
deterministic: bool | None = None,
) -> Float[
Array, "batch out_height out_width out_channels"
]
Forward pass through the FHNN hyperbolic convolutional layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array of shape (batch, height, width, in_channels)
|
Input feature map where each pixel is a point on the Hyperboloid manifold |
required |
c
|
float
|
Manifold curvature (default: 1.0) |
1.0
|
deterministic
|
bool or None
|
If True, dropout is disabled. None uses the inner |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Array of shape (batch, out_height, out_width, out_channels)
|
Output feature map on the Hyperboloid manifold |
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
hyperbolix.nn_layers.HypConv2DHyperboloidILNN ¶
HypConv2DHyperboloidILNN(
manifold_module: Hyperboloid,
in_channels: int,
out_channels: int,
kernel_size: int | tuple[int, int],
*,
rngs: Rngs,
stride: int | tuple[int, int] = 1,
padding: str = "SAME",
pad_mode: str = "origin",
input_space: str = "manifold",
v_max: float = 10.0,
use_gyro_bias: bool = False,
kernel_init_std: float | None = None,
param_dtype: DTypeLike = jnp.float32,
)
Bases: Module
Intrinsic Lorentz Neural Network (ILNN) 2D convolutional layer (Hyperboloid model).
Implements the Lorentz convolution of Shi et al. 2026, Eq. (11):
y = PLFC(LogCat({x_patch})). Receptive-field points are combined with the
log-radius-preserving concatenation (LogCat) and mixed across channels by the
PLFC linear transform (MLR scores -> sinh diffeomorphism -> time
reconstruction). This extends the HNN++ linearized-kernel convolution
(Shimizu et al. 2020) by replacing the Euclidean FC and naive concatenation
with their intrinsic Lorentz counterparts. Formerly named
HypConv2DHyperboloidPP.
Computation steps:
1) Extract receptive field (kernel_size x kernel_size) of hyperbolic points,
padding with the manifold origin if needed
2) Apply LogCat (log-radius-preserving concatenation) to combine receptive field points
3) Pass through PLFC linear (MLR scores -> guard -> sinh -> time reconstruction)
4) Optionally add an intrinsic gyro-bias y <- y (+) exp_0([0, b])
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifold_module
|
Hyperboloid
|
Class-based Hyperboloid manifold instance |
required |
in_channels
|
int
|
Number of input channels (ambient dimension, including time component) |
required |
out_channels
|
int
|
Number of output channels (ambient dimension, including time component) |
required |
kernel_size
|
int or tuple[int, int]
|
Size of the convolutional kernel |
required |
rngs
|
Rngs
|
Random number generators for parameter initialization |
required |
stride
|
int or tuple[int, int]
|
Stride of the convolution (default: 1) |
1
|
padding
|
str
|
Padding mode, either 'SAME' or 'VALID' (default: 'SAME') |
'SAME'
|
pad_mode
|
str
|
How to fill padding pixels for 'SAME' padding: |
'origin'
|
input_space
|
str
|
Type of the input tensor, either 'tangent' or 'manifold' (default: 'manifold'). Note: This is a static configuration - changing it after initialization requires recompilation. |
'manifold'
|
v_max
|
float
|
Output-side guard: the sinh argument |
10.0
|
use_gyro_bias
|
bool
|
If True, add a learnable intrinsic bias via Lorentz gyroaddition,
|
False
|
kernel_init_std
|
float or None
|
Standard deviation of the normal kernel init. The default |
None
|
param_dtype
|
DTypeLike
|
Storage dtype of the trainable parameters (default: jnp.float32).
Compute precision of manifold operations is set by |
float32
|
Notes
Weight Initialization:
The default std = sqrt(1 / out_spatial) is norm-preserving. Linearize the
layer around the manifold origin, where the PLFC chain is small-signal: with
the bias at its 0 init, compute_mlr reduces to
v = ||z||/sqrt(c) * asinh(sqrt(c) <u_s, z> / ||z||) ~= <u_s, z> and the
output map y_s = sinh(sqrt(c) v)/sqrt(c) ~= v, so y_s ~= W u_s — a
plain matmul. For a Gaussian W of shape (O, I) with entry std
sigma this has RMS gain sigma * sqrt(O), and the LogCat input u_s
carries the per-pixel spatial radius by construction (that is what the
digamma rescale buys), so sigma = 1/sqrt(O) gives an overall gain of 1.
Measured on a depth-3 stack (c=0.1, 3x3 kernel, 8x8 input, float64), the
per-layer mean spatial norm ratio is 0.82-0.95 across widths 8-64 — the
residual shortfall is the origin-padded border, whose interior-only ratios
are 0.92-0.98.
The previous fixed default ``0.02`` was tuned against the *pre-fix* LogCat,
which amplified the spatial radius by ~sqrt(N) per block instead of shrinking
it (a sign error in the digamma difference, shared with the Shi et al. 2026
reference; fixed 2026-07-31). The two errors cancelled at width ~64: gain
``0.02 * sqrt(64) * 9 ~= 1.4`` for a 3x3 kernel. Under the corrected LogCat
the same ``0.02`` is strongly contractive — probe-measured per-layer ratios
0.05-0.15, i.e. a depth-3 stack collapses onto the manifold origin at init —
so ``kernel_init_std=0.02`` now restores the Shi et al. 2026 regime, which
implicitly assumed the pre-fix LogCat amplification, rather than a safe
default. Use it only to reproduce that reference.
JIT Compatibility: This layer is designed to work with nnx.jit. Configuration parameters (padding, pad_mode, input_space, v_max) are treated as static and baked into the compiled function.
See Also
HypLinearHyperboloidPLFC : The underlying PLFC linear layer. hyperbolix.manifolds.hyperboloid.Hyperboloid.log_radius_concat : The LogCat operation.
References
Xianglong Shi, Ziheng Chen, Yunhan Jiang, and Nicu Sebe. "Intrinsic Lorentz Neural Network." ICLR 2026, arXiv:2602.23981 (Sec. 4.3: Lorentz convolution, log-radius concatenation). Shimizu Ryohei, Yusuke Mukuta, and Tatsuya Harada. "Hyperbolic neural networks++." arXiv preprint arXiv:2006.08210 (2020).
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
__call__ ¶
__call__(
x: Float[Array, "batch height width in_channels"],
c: float = 1.0,
) -> Float[
Array, "batch out_height out_width out_channels"
]
Forward pass through the ILNN hyperboloid convolutional layer (LogCat + PLFC).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array of shape (batch, height, width, in_channels)
|
Input feature map where each pixel is a point on the Hyperboloid manifold |
required |
c
|
float
|
Manifold curvature (default: 1.0) |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Array of shape (batch, out_height, out_width, out_channels)
|
Output feature map on the Hyperboloid manifold |
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
hyperbolix.nn_layers.FGGConv2D ¶
FGGConv2D(
manifold_module: Hyperboloid,
in_channels: int,
out_channels: int,
kernel_size: int | tuple[int, int],
*,
rngs: Rngs,
stride: int | tuple[int, int] = 1,
padding: str = "SAME",
pad_mode: str = "origin",
activation: Callable | None = None,
reset_params: str = "fan_out",
use_weight_norm: bool = False,
init_kernel_scale: float | None = None,
init_bias: float = 0.0,
gain: float = 1.0,
eps: float = 1e-07,
param_dtype: DTypeLike = jnp.float32,
)
Bases: Module
Fast and Geometrically Grounded Lorentz 2D convolutional layer.
Uses HCat (Lorentz direct concatenation) to combine receptive field points, then applies FGGLinear for the channel mixing. This matches the reference implementation pattern from Klis et al. 2026.
Computation steps: 1) Extract receptive field patches, pad with manifold origin if needed 2) Apply HCat (Lorentz direct concatenation) to combine patch points 3) Pass through FGGLinear for channel transformation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifold_module
|
Hyperboloid
|
Class-based Hyperboloid manifold instance. |
required |
in_channels
|
int
|
Input ambient channels (D_in + 1), including time component. |
required |
out_channels
|
int
|
Output ambient channels (D_out + 1), including time component. |
required |
kernel_size
|
int or tuple[int, int]
|
Size of the convolutional kernel. |
required |
rngs
|
Rngs
|
Random number generators for parameter initialization. |
required |
stride
|
int or tuple[int, int]
|
Stride of the convolution (default: 1). |
1
|
padding
|
str
|
Padding mode: |
'SAME'
|
pad_mode
|
str
|
How to fill padding pixels: |
'origin'
|
activation
|
Callable or None
|
Euclidean activation for the FGGLinear (default: None). |
None
|
reset_params
|
str
|
Weight init for FGGLinear: |
'fan_out'
|
use_weight_norm
|
bool
|
Weight normalization in FGGLinear (default: False). Note |
False
|
init_kernel_scale
|
float or None
|
Column norm of U at init under |
None
|
init_bias
|
float
|
Initial bias for FGGLinear (default: 0.0). A zero bias removes the
|
0.0
|
gain
|
float
|
Multiplier on the random init (default: 1.0). With |
1.0
|
eps
|
float
|
Numerical stability floor (default: 1e-7). |
1e-07
|
param_dtype
|
DTypeLike
|
Storage dtype of the trainable parameters (default: jnp.float32).
Compute precision of manifold operations is set by |
float32
|
References
Klis et al. "Fast and Geometrically Grounded Lorentz Neural Networks" (2026).
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
__call__ ¶
__call__(
x: Float[Array, "batch height width in_channels"],
c: float = 1.0,
) -> Float[
Array, "batch out_height out_width out_channels"
]
Forward pass through the FGG convolutional layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(Array, shape(B, H, W, in_channels))
|
Input feature map on the hyperboloid. |
required |
c
|
float
|
Curvature parameter (default: 1.0). |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Array, shape (B, H', W', out_channels)
|
Output feature map on the hyperboloid. |
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
hyperbolix.nn_layers.LorentzConv2D ¶
LorentzConv2D(
manifold_module: Hyperboloid,
in_channels: int,
out_channels: int,
kernel_size: int | tuple[int, int],
*,
rngs: Rngs,
stride: int | tuple[int, int] = 1,
padding: str = "SAME",
param_dtype: DTypeLike = jnp.float32,
)
Bases: Module
Lorentz 2D Convolutional Layer using the Hyperbolic Layer (HL) approach.
This layer applies convolution to the space-like components of Lorentzian vectors and reconstructs the time-like component to maintain the manifold constraint. This is equivalent to an HRC (Hyperbolic Regularization Component) wrapper around a standard Conv2D.
Computation steps: 1) Extract space-like components x_s from input x = [x_t, x_s]^T 2) Apply Euclidean convolution: y_s = Conv2D(x_s) 3) Reconstruct time component: y_t = sqrt(||y_s||^2 + 1/c) 4) Return y = [y_t, y_s]^T
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifold_module
|
object
|
Class-based Hyperboloid manifold instance |
required |
in_channels
|
int
|
Number of input channels (ambient dimension, including time component) |
required |
out_channels
|
int
|
Number of output channels (ambient dimension, including time component) |
required |
kernel_size
|
int or tuple[int, int]
|
Size of the convolutional kernel |
required |
rngs
|
Rngs
|
Random number generators for parameter initialization |
required |
stride
|
int or tuple[int, int]
|
Stride of the convolution (default: 1) |
1
|
padding
|
str or int or tuple
|
Padding mode: 'SAME', 'VALID', or explicit padding (default: 'SAME') |
'SAME'
|
param_dtype
|
DTypeLike
|
Storage dtype of the trainable parameters (default: jnp.float32).
Compute precision follows Flax's promotion of the input's and the
parameters' dtypes; |
float32
|
Notes
Superseded by :class:FGGConv2D and :class:HypConv2DHyperboloidILNN; kept for
reproduction of the LResNet results (He et al. 2025). It is not a hyperbolic
convolution: it applies a Euclidean convolution to the space-like components and
reconstructs the time component from the constraint, so the receptive field is
combined in the ambient tangent directions rather than intrinsically. That makes it
cheaper than the HCat-based layers (:class:HypConv2DHyperboloid) but geometrically
weaker — prefer the superseding layers for new work.
See Also
hyperbolix.nn_layers.hyperboloid_core.hrc : Core HRC function this layer is based on HypConv2DHyperboloid : Full hyperbolic convolution using HCat concatenation
References
He, Neil, Menglin Yang, and Rex Ying. "Lorentzian residual neural networks." Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining V. 1. 2025.
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
__call__ ¶
__call__(
x: Float[Array, "batch height width in_channels"],
c: float = 1.0,
) -> Float[
Array, "batch out_height out_width out_channels"
]
Forward pass through the Lorentz convolutional layer.
This layer is a specific instance of the Hyperbolic Regularization Component (HRC) where the regularization function f_r is a 2D convolution. The HRC pattern: 1. Extracts space components 2. Applies Euclidean convolution 3. Reconstructs time component using Lorentz constraint
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array of shape (batch, height, width, in_channels)
|
Input feature map where x[..., 0] is time component and x[..., 1:] are space components on the Lorentz manifold |
required |
c
|
float
|
Manifold curvature parameter (default: 1.0) |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Array of shape (batch, out_height, out_width, out_channels)
|
Output feature map on the Lorentz manifold |
Notes
This implementation uses the hrc function from
:mod:hyperbolix.nn_layers.hyperboloid_core, demonstrating that LorentzConv2D
(from LResNet) and HRC (from Hypformer) are mathematically equivalent approaches
to adapting Euclidean operations for hyperbolic geometry.
Source code in hyperbolix/nn_layers/hyperboloid_conv.py
Poincaré¶
HypConv2DPoincare extracts patches, applies beta-concatenation (HNN++, Shimizu
et al. 2020) over the receptive field, then a HypLinearPoincarePP layer. The
concatenated K²·C_in patch is mapped to C_out. Input is tangent by default
(input_space="manifold" accepts ball points); output is always tangent vectors.
hyperbolix.nn_layers.HypConv2DPoincare ¶
HypConv2DPoincare(
manifold_module: Poincare,
in_channels: int,
out_channels: int,
kernel_size: int | tuple[int, int],
*,
rngs: Rngs,
stride: int | tuple[int, int] = 1,
padding: str = "SAME",
input_space: str = "tangent",
id_init: bool = True,
param_dtype: DTypeLike = jnp.float32,
)
Bases: Module
Hyperbolic 2D Convolutional Layer for Poincaré ball model.
This layer implements hyperbolic convolution following the Poincaré ResNet (van Spengler et al. 2023) approach: beta-scaling in tangent space, patch extraction, expmap to manifold, HNN++ fully-connected, logmap back to tangent space.
The layer operates in tangent space internally and returns tangent-space output, matching the reference implementation. This design avoids the numerically unstable logmap_0 round-trips that cause NaN gradients when points approach the Poincaré ball boundary.
Computation steps: 1) Map to tangent space if input is on manifold 2) Scale tangent vectors by beta function ratio (beta-concatenation scaling) 3) Extract patches via im2col (zero-padding in tangent space) 4) Apply the HNN++ fully-connected layer to the patch vectors mapped to the manifold via expmap_0, and map its output back to tangent space via logmap_0 — both maps evaluated in closed form on the tangent vectors, without forming the ball points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifold_module
|
Poincare
|
Class-based Poincaré manifold instance |
required |
in_channels
|
int
|
Number of input channels (Poincaré ball dimension per pixel) |
required |
out_channels
|
int
|
Number of output channels (Poincaré ball dimension per pixel) |
required |
kernel_size
|
int or tuple[int, int]
|
Size of the convolutional kernel |
required |
rngs
|
Rngs
|
Random number generators for parameter initialization |
required |
stride
|
int or tuple[int, int]
|
Stride of the convolution (default: 1) |
1
|
padding
|
str
|
Padding mode, either 'SAME' or 'VALID' (default: 'SAME') |
'SAME'
|
input_space
|
str
|
Type of the input tensor, either 'tangent' or 'manifold' (default: 'tangent'). Note: This is a static configuration - changing it after initialization requires recompilation. |
'tangent'
|
id_init
|
bool
|
If True (default), initialize the linear sublayer weights as |
True
|
param_dtype
|
DTypeLike
|
Storage dtype of the trainable parameters (default: jnp.float32).
Compute precision of manifold operations is set by |
float32
|
Notes
Output Space: This layer always returns tangent-space output (matching the reference). Between conv layers, use standard activations (e.g., jax.nn.relu) directly on the tangent-space features. Use expmap_0 to map back to the manifold only when needed (e.g., before the classification head).
JIT Compatibility: This layer is designed to work with nnx.jit. Configuration parameters (padding, input_space) are treated as static and will be baked into the compiled function.
Dimension math: - beta-scaling + patch extraction: (H, W, C_in) → (oh, ow, K^2 * C_in) - HNN++ linear: in_dim = K^2 * C_in, out_dim = C_out
References
Shimizu et al. "Hyperbolic neural networks++." arXiv:2006.08210 (2020). van Spengler et al. "Poincaré ResNet." ICML 2023.
Source code in hyperbolix/nn_layers/poincare_conv.py
__call__ ¶
__call__(
x: Float[Array, "batch height width in_channels"],
c: float = 1.0,
) -> Float[
Array, "batch out_height out_width out_channels"
]
Forward pass through the Poincaré convolutional layer.
Follows the reference computation flow: tangent-space beta-scaling, patch extraction, expmap_0, HNN++ FC, logmap_0 — with expmap_0 and logmap_0 evaluated on the tangent vectors, never forming the ball points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array of shape (batch, height, width, in_channels)
|
Input feature map. Can be tangent-space or manifold points depending on input_space setting. |
required |
c
|
float
|
Manifold curvature (default: 1.0) |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Array of shape (batch, out_height, out_width, out_channels)
|
Output feature map in tangent space at the origin. Use standard activations (e.g., jax.nn.relu) between layers. |
Source code in hyperbolix/nn_layers/poincare_conv.py
Proper Velocity¶
HypConv2DPV (Chen et al. 2026, Sec 5.3). Because PV geometry is unconstrained
\(\mathbb{R}^n\), patch concatenation coincides with Euclidean concatenation — no
beta-scaling step; the output width is out_channels. Outputs live on the PV manifold, so
Euclidean activations apply directly between conv layers.
hyperbolix.nn_layers.HypConv2DPV ¶
HypConv2DPV(
manifold_module: ProperVelocity,
in_channels: int,
out_channels: int,
kernel_size: int | tuple[int, int],
*,
rngs: Rngs,
stride: int | tuple[int, int] = 1,
padding: str = "SAME",
input_space: str = "manifold",
inner_activation: Callable[[Array], Array]
| None = None,
kernel_init_std: float | None = None,
param_dtype: DTypeLike = jnp.float32,
)
Bases: Module
Hyperbolic 2D Convolutional Layer for the Proper Velocity model.
Implements Chen et al. 2026, Sec 5.3. Because PV's geometry is unconstrained
(ℝⁿ), patch concatenation coincides with Euclidean concatenation — no
beta-scaling step is required (unlike HypConv2DPoincare). The layer
returns points on the PV manifold; between conv layers, activations can be
applied directly in PV space (paper Sec 5.3 "Activation").
Computation steps:
1) Optionally lift tangent-space input to the PV manifold via expmap_0.
2) Extract patches with zero-padding via jax.lax.conv_general_dilated_patches.
3) Flatten batch x spatial dimensions.
4) Apply the PV FC forward (_pv_fc_forward, shared with HypLinearPV).
5) Reshape back to spatial output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifold_module
|
ProperVelocity
|
Class-based Proper Velocity manifold instance. |
required |
in_channels
|
int
|
Number of input channels (PV dimension per pixel). |
required |
out_channels
|
int
|
Number of output channels (PV dimension per pixel). |
required |
kernel_size
|
int or tuple[int, int]
|
Size of the convolutional kernel. |
required |
rngs
|
Rngs
|
Random number generators for parameter initialization. |
required |
stride
|
int or tuple[int, int]
|
Stride of the convolution (default: 1). |
1
|
padding
|
str
|
Padding mode, either 'SAME' or 'VALID' (default: 'SAME'). |
'SAME'
|
input_space
|
str
|
Type of the input tensor, either 'tangent' or 'manifold' (default: 'manifold'). Note: This is a static configuration — changing it after initialization requires recompilation. |
'manifold'
|
inner_activation
|
Callable[[Array], Array] | None
|
Optional activation applied inside the outer sinh (paper Eq. 23). Default None. |
None
|
kernel_init_std
|
float | None
|
Standard deviation for the Gaussian kernel init. If |
None
|
param_dtype
|
DTypeLike
|
Storage dtype of the trainable parameters (default: jnp.float32).
Compute precision of manifold operations is set by |
float32
|
Notes
Output Space:
Unlike HypConv2DPoincare (which returns tangent space), this layer
returns points on the PV manifold. Between conv layers, apply activations
directly on the PV features — no expmap_0/logmap_0 round-trips needed.
JIT Compatibility: Configuration parameters (padding, input_space, inner_activation) are treated as static and are baked into the compiled function.
Dimension math: - patch extraction: (H, W, C_in) → (oh, ow, K²·C_in) - PV FC: in_dim = K²·C_in, out_dim = C_out
References
Chen et al. "Proper Velocity Neural Networks." ICLR 2026.
Source code in hyperbolix/nn_layers/pv_conv.py
__call__ ¶
__call__(
x: Float[Array, "batch height width in_channels"],
c: float = 1.0,
) -> Float[
Array, "batch out_height out_width out_channels"
]
Forward pass through the PV convolutional layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array of shape (batch, height, width, in_channels)
|
Input feature map. PV manifold points or tangent-space vectors at the
origin, depending on |
required |
c
|
float
|
Manifold curvature (default: 1.0). |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
Array of shape (batch, out_height, out_width, out_channels)
|
Output feature map on the PV manifold. |
Source code in hyperbolix/nn_layers/pv_conv.py
Pooling & flattening (conv → FC bridge)¶
Two ways to turn an (B, H', W', C) hyperboloid feature map into one point per
sample before a classification head. hyp_avg_pool2d averages the spatial parts over
the grid and keeps the width (C in → C out). hyp_flatten2d keeps every pixel by
LogCat-concatenating them, so the width grows to H'·W'·(C−1) + 1.
Do not flatten a feature map with a plain reshape
Concatenating N = H'·W' hyperboloid points without the LogCat digamma rescale
inflates the flattened point's spatial radius by ≈ √(H'·W') — the same
dimension-widening bias Hyperboloid.log_radius_concat exists to correct inside
HypConv2DHyperboloidILNN's per-patch concat, but with N = the whole feature
map instead of one 3×3 receptive field. Use hyp_flatten2d; see the
numerical-stability guide.
hyperbolix.nn_layers.hyp_avg_pool2d ¶
hyp_avg_pool2d(
x: Float[Array, "... H W dim_plus_1"],
c: float,
eps: float = 1e-07,
) -> Float[Array, "... dim_plus_1"]
Global average pooling over 2D spatial dimensions on the hyperboloid.
Averages the spatial components over the height and width dimensions,
then reconstructs the time component via the hyperboloid constraint.
This is the HRC pattern with f_r = mean_over_spatial:
.. math::
\text{space} = \text{mean}_{H,W}(x[..., 1:])
x_0 = \sqrt{\|\text{space}\|^2 + 1/c}
\text{output} = [x_0, \text{space}]
The function expects the NHWC layout used throughout hyperbolix:
(..., H, W, ambient_dim) where ambient_dim = spatial_dim + 1.
This operation is hyperboloid-only because it relies on the time/spatial
decomposition x[..., 0] (time) and x[..., 1:] (spatial). Poincaré
ball points do not have a time component. To pool Poincaré features, first
convert to hyperboloid via
:func:~hyperbolix.manifolds.isometry_mappings.poincare_to_hyperboloid,
pool, then convert back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(Array, shape(..., H, W, dim + 1))
|
Hyperboloid feature map with curvature |
required |
c
|
float
|
Curvature parameter (positive, c > 0). |
required |
eps
|
float
|
Numerical stability floor for the time reconstruction (default: 1e-7). |
1e-07
|
Returns:
| Type | Description |
|---|---|
(Array, shape(..., dim + 1))
|
Pooled hyperboloid points with curvature |
See Also
spatial_to_hyperboloid : Low-level curvature scaling + time reconstruction. hrc : General HRC wrapper for arbitrary Euclidean functions. lorentz_midpoint : Weighted Lorentzian midpoint (geometrically exact aggregation).
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>> from hyperbolix.manifolds import Hyperboloid
>>> from hyperbolix.nn_layers.hyperboloid_core import hyp_avg_pool2d
>>>
>>> hyperboloid = Hyperboloid(dtype=jnp.float32)
>>> key = jax.random.PRNGKey(0)
>>> v = jax.random.normal(key, (4, 7, 7, 64), dtype=jnp.float32) * 0.1
>>> v = v.at[..., 0].set(0.0) # tangent vectors at the origin
>>> x = jax.vmap(jax.vmap(jax.vmap(
... hyperboloid.expmap_0, in_axes=(0, None)
... ), in_axes=(0, None)), in_axes=(0, None))(v, 1.0)
>>> x.shape
(4, 7, 7, 64)
>>> y = hyp_avg_pool2d(x, c=1.0)
>>> y.shape
(4, 64)
Source code in hyperbolix/nn_layers/hyperboloid_core.py
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 | |
hyperbolix.nn_layers.hyp_flatten2d ¶
hyp_flatten2d(
x: Float[Array, "... H W dim_plus_1"],
manifold_module: Manifold,
c: float,
) -> Float[Array, "... flat_dim_plus_1"]
LogCat-flatten a hyperboloid feature map into one point per sample (conv → FC boundary).
Concatenates the H·W per-pixel hyperboloid points of a feature map into a single
hyperboloid point, using the log-radius-preserving concatenation
:meth:~hyperbolix.manifolds.hyperboloid.Hyperboloid.log_radius_concat (LogCat, Shi
et al. 2026, Sec. 4.3) rather than a plain reshape/hcat. This is the flatten
step between a hyperboloid convolutional trunk and an FC / MLR head.
Why not a plain reshape. Stacking the N = H·W spatial blocks without a
correction widens the spatial dimension from D to N·D while leaving each
block's entries untouched. For Gaussian-ish spatial parts ‖v‖² ~ χ²_k, so
E[log‖v‖] = ½·(ψ(k/2) + log 2) grows with the dimension k: the flattened
point's spatial radius (and hence its geodesic radius from the origin) inflates by
≈ √(H·W). At a conv → FC boundary N is the whole feature map — tens to low
hundreds — so the inflation is far larger than the √9 of a single 3x3 receptive
field. Before the MLR asinh clamp was removed, an MLR head fed such a point sat
pinned at that clamp at init, with near-zero gradients.
LogCat rescales every block by the digamma ratio
s = exp(½·(ψ(D/2) - ψ(N·D/2))) ≈ 1/√N before concatenating and then recomputes
the time coordinate, so the expected log spatial radius of the flattened point
matches that of one pixel.
Dimension bookkeeping (all hyperboloid channel counts are ambient, time first):
H·W blocks of D = A - 1 spatial dims each become one point with H·W·D
spatial dims plus a single time coordinate, i.e. A' = H·W·(A - 1) + 1. Note this
grows the width — pair it with a dimensionality-reducing head, or pool with
:func:hyp_avg_pool2d instead when a fixed-width global summary is what you want.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(Array, shape(..., H, W, A))
|
Hyperboloid feature map with curvature |
required |
manifold_module
|
Manifold
|
Hyperboloid manifold instance (e.g. |
required |
c
|
float
|
Curvature parameter (positive, c > 0). |
required |
Returns:
| Type | Description |
|---|---|
(Array, shape(..., H * W * (A - 1) + 1))
|
One hyperboloid point per sample, on the widened hyperboloid with curvature |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
See Also
hyperbolix.manifolds.hyperboloid.Hyperboloid.log_radius_concat : The LogCat operation. hyperbolix.manifolds.hyperboloid.Hyperboloid.hcat : Unscaled concatenation (inflates the radius). hyp_avg_pool2d : Dimension-preserving global pool — the alternative conv → FC bridge.
References
Shi et al. "Intrinsic Lorentz Neural Network." ICLR 2026, Sec. 4.3 (LogCat).
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>> from hyperbolix.manifolds import Hyperboloid
>>> from hyperbolix.nn_layers.hyperboloid_core import hyp_flatten2d
>>>
>>> hyperboloid = Hyperboloid(dtype=jnp.float32)
>>> key = jax.random.PRNGKey(0)
>>> v = jax.random.normal(key, (4, 4, 4, 17), dtype=jnp.float32) * 0.1
>>> v = v.at[..., 0].set(0.0) # tangent vectors at the origin
>>> x = jax.vmap(jax.vmap(jax.vmap(
... hyperboloid.expmap_0, in_axes=(0, None)
... ), in_axes=(0, None)), in_axes=(0, None))(v, 1.0)
>>> x.shape
(4, 4, 4, 17)
>>> y = hyp_flatten2d(x, hyperboloid, c=1.0)
>>> y.shape # 4*4 blocks of 16 spatial dims + 1 time coordinate
(4, 257)
Source code in hyperbolix/nn_layers/hyperboloid_core.py
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | |
Example¶
import jax, jax.numpy as jnp
from flax import nnx
from hyperbolix.nn_layers import HypConv2DHyperboloid
from hyperbolix.manifolds import Hyperboloid
conv = HypConv2DHyperboloid(
manifold_module=Hyperboloid(), in_channels=17, out_channels=32,
kernel_size=(3, 3), stride=(1, 1), rngs=nnx.Rngs(0),
)
x = jax.random.normal(jax.random.PRNGKey(1), (8, 28, 28, 16))
x_amb = jnp.concatenate([jnp.sqrt(jnp.sum(x**2, -1, keepdims=True) + 1.0), x], -1) # (8,28,28,17)
output = conv(x_amb, c=1.0)
print(output.shape) # (8, 28, 28, 32) — output width is out_channels, independent of kernel size