igl.core
Geometry-agnostic primitives: encoder, Green kernel, solver, trainer, losses.
Encoders
igl.core.encoder.MLPEncoder
Bases: Module
MLP encoder: depth × (Linear → Norm → Activation) → Linear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dim
|
int
|
Ambient dimension |
required |
max_dim
|
int
|
Latent dimension |
required |
hidden
|
int | Sequence[int]
|
Either a single width applied uniformly to every hidden layer
(default |
256
|
depth
|
int | None
|
Optional explicit depth. When |
None
|
norm
|
NormTypeLike
|
Type of normalization in each block (default
:data: |
LAYER
|
activation
|
ActivationTypeLike
|
Activation function (default
:data: |
SILU
|
Raises:
| Type | Description |
|---|---|
IGLConfigError
|
If any dimension is non-positive, |
igl.core.encoder.LinearEncoder
igl.core.encoder.build_mlp_encoder(input_dim, max_dim, *, config)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dim
|
int
|
Ambient dimension |
required |
max_dim
|
int
|
Latent dimension |
required |
config
|
EncoderConfig
|
Encoder configuration. |
required |
Raises:
| Type | Description |
|---|---|
IGLConfigError
|
If |
Green kernel
igl.core.kernel.GreenKernel
Bases: Module
Multi-scale, multi-operator Green's-function kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dim
|
int
|
Latent dimension |
required |
n_anchors
|
int
|
Number of anchor positions |
64
|
n_scales
|
int
|
Total number of scales |
4
|
operator
|
str | Sequence[str]
|
Single operator name (e.g. |
'gaussian'
|
sigma_log_range
|
tuple[float, float]
|
|
(-1.5, 1.5)
|
anchor_init_std
|
float
|
Standard deviation for the Gaussian initialisation
of anchor positions (default |
0.5
|
null_space
|
NullSpaceBasis | None
|
Optional :class: |
None
|
operator_names
property
Names of the operators in registration order.
compute_design_matrix(z, *, gate_mask=None)
Build the design matrix from latent coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
Tensor
|
Latent coordinates of shape |
required |
gate_mask
|
Tensor | None
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Design matrix of shape |
forward(z, *, gate_mask=None)
Alias of :meth:compute_design_matrix.
Solver
igl.core.solver.direct_solve_weights(phi, y, *, l2=0.001)
Solve the Tikhonov-regularised least-squares problem.
The solution is computed via QR (torch.linalg.lstsq) on the stacked
system [Φ; √λ I] w ≈ [y; 0] so the regularisation is correctly applied
even when Φ is rank-deficient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phi
|
Tensor
|
Design matrix |
required |
y
|
Tensor
|
Targets |
required |
l2
|
float
|
Tikhonov coefficient relative to Φ's mean column norm (default
|
0.001
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Tensor
|
(e.g. catastrophic conditioning), the function emits a |
Tensor
|
|
Normalization
igl.core.normalization.normalize_phi(phi, mode)
Normalize the design matrix per row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phi
|
Tensor
|
Design matrix of shape |
required |
mode
|
NormalizeModeLike
|
A :class: |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
The normalised matrix, same shape as |
Raises:
| Type | Description |
|---|---|
IGLConfigError
|
If |
Loss strategies
igl.core.loss.CrossEntropyLoss
Multiclass cross-entropy with one-hot lstsq targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_classes
|
int
|
Number of classes |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
higher_is_better |
bool
|
Always |
curve_score(pred, target)
0/1 classification error rate — used for dimension-curve elbow detection.
Cross-entropy saturates on easy tasks and smears the elbow; error rate is discrete and gives sharper transitions.
loss(pred, target)
Cross-entropy loss; target is one-hot, taken back to class indices.
metric(pred, target)
Top-1 classification accuracy.
target(y)
Convert integer class labels [N] to one-hot float targets [N, C].
igl.core.loss.MSELoss
Mean squared error for scalar or multi-output regression.
Attributes:
| Name | Type | Description |
|---|---|---|
higher_is_better |
bool
|
Always |
curve_score(pred, target)
MSE — already lower-is-better and non-saturating; same as metric.
target(y)
Ensure the target is at least 2-D [N, C].
Trainer
igl.core.trainer.MatryoshkaTrainer
Train an :class:IGLModule with Matryoshka VP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MatryoshkaConfig | None
|
:class: |
None
|
loss
|
LossStrategy
|
:class: |
required |
sampler
|
MatryoshkaSampler | None
|
Optional explicit :class: |
None
|
fit(module, x_train, y_train, *, x_val=None, y_val=None, extra_losses=())
Fit module on the training tensors and return the history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
IGLModule
|
An :class: |
required |
x_train
|
Tensor
|
Training inputs |
required |
y_train
|
Tensor
|
Training targets. |
required |
x_val
|
Tensor | None
|
Optional validation inputs. |
None
|
y_val
|
Tensor | None
|
Optional validation targets. |
None
|
extra_losses
|
Sequence[ExtraLoss]
|
Optional :class: |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
TrainingHistory
|
|
Raises:
| Type | Description |
|---|---|
IGLConvergenceError
|
If the training loss becomes non-finite. |
igl.core.trainer.TrainingHistory
dataclass
Per-epoch training history returned by :meth:MatryoshkaTrainer.fit.