Conditioning¶
A conditioner is a layer c(h, z) → y that transforms an inner activation h based on a context vector z. pyrox_nn ships three concrete conditioners that cover the literature in one consistent API, plus Bayesian variants and a composite that wraps any inner network with per-layer conditioning.
Decision rubric¶
| Pattern | Use when | Cost | Where it shows up |
|---|---|---|---|
ConcatConditioner |
You want a cheap baseline; cond_dim is small. |
(C + K) · C + C per layer |
DiffeqMLP-style CNF vector fields |
AffineModulation (FiLM) |
Feature-wise modulation is enough; you want low generator cost regardless of cond_dim. |
2C · K + 2C per layer |
π-GAN, Modulated SIREN, conditional INRs |
HyperLinear |
You need the full target weight matrix to depend on z; want NIF/MetaSDF. |
K · (C·C_in + C) per layer |
NIF (Pan et al. 2023), MetaSDF, Ha et al. hypernets |
The Bayesian variants put Normal(0, prior_std) priors on the generator weights only. Posterior cost scales with the generator size, not the target network — that's the whole point of Bayesian amortised inference.
End-to-end use¶
import jax.random as jr
import jax.numpy as jnp
from pyrox_nn import SIREN, AffineModulation, ConditionedINR, HyperSIREN
key = jr.key(0)
# 1) FiLM-modulate every hidden layer of a SIREN
inner = SIREN.init(2, 32, 1, depth=4, key=key)
wrapped = ConditionedINR.init(
inner, conditioner_cls=AffineModulation, cond_dim=4, key=key
)
y = wrapped(jnp.ones((10, 2)), jnp.ones((10, 4))) # (10, 1)
# 2) Full NIF stack — ParameterNet → per-layer HyperLinear → ShapeNet (SIREN)
import equinox as eqx
class IdentityNet(eqx.Module):
def __call__(self, mu): return mu
nif = HyperSIREN(
in_features=2, hidden_features=32, out_features=1,
depth=5, cond_dim=3, parameter_net=IdentityNet(), key=key,
)
y = nif(jnp.ones((10, 2)), jnp.ones((3,))) # (10, 1)
For a hands-on walkthrough see the Conditional Neural Fields notebook.
Protocol¶
AbstractConditioner
¶
Bases: Module
Duck-typed protocol for (h, z) -> y conditioning layers.
Concrete subclasses share the contract __call__(h, z) -> Array
where h.shape == (num_features,) and z.shape == (cond_dim,).
There is no abstractmethod enforcement — subclasses simply
implement __call__.
Attributes:
| Name | Type | Description |
|---|---|---|
num_features |
int
|
Output channel count, matching |
cond_dim |
int
|
Latent / context dimension, matching |
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
Concrete conditioners¶
ConcatConditioner
¶
Bases: AbstractConditioner
Concatenate h and z then apply a single Linear.
Cheapest, most expressive in principle, but parameter count grows
linearly with cond_dim: (num_features + cond_dim) * num_features
+ num_features (the bias). No init ceremony required — uses
eqx.nn.Linear defaults.
Attributes:
| Name | Type | Description |
|---|---|---|
proj |
Linear
|
Linear projection |
num_features |
int
|
Output channels |
cond_dim |
int
|
Context dimension |
Examples:
>>> import jax.random as jr, jax.numpy as jnp
>>> layer = ConcatConditioner.init(num_features=8, cond_dim=4, key=jr.key(0))
>>> y = layer(jnp.ones(8), jnp.ones(4))
>>> y.shape
(8,)
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
init(num_features: int, cond_dim: int, *, key: PRNGKeyArray) -> ConcatConditioner
classmethod
¶
Build a ConcatConditioner with default eqx.nn.Linear init.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_features
|
int
|
Output channel count. |
required |
cond_dim
|
int
|
Context dimension. |
required |
key
|
PRNGKeyArray
|
PRNG key for the projection's init. |
required |
Returns:
| Type | Description |
|---|---|
ConcatConditioner
|
Initialised |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
AffineModulation
¶
Bases: AbstractConditioner
Feature-wise Linear Modulation (FiLM): y = γ(z) ⊙ h + β(z).
A single eqx.nn.Linear of output size 2 * num_features
produces the concatenated (raw_β, raw_γ) from the context vector.
The two halves are split on the feature axis via
einx.id (no raw jnp.split), then γ is passed
through the chosen activation:
"one_plus_tanh"(default):γ = 1 + tanh(raw_γ)— identity at init when the generator's bias is zero. The choice that gives FiLM its "does nothing until trained" property."exp":γ = exp(raw_γ)— strictly positive, required for bijection use. In this modelog_detreturnssum(raw_γ, axis=-1), the closed-form log-Jacobian of an element-wise scale."softplus":γ = softplus(raw_γ)— strictly positive, slower to leave the prior thanexp."identity":γ = raw_γ— no shape guarantee, rarely useful.
Attributes:
| Name | Type | Description |
|---|---|---|
generator |
Linear
|
Linear |
num_features |
int
|
Output channels |
cond_dim |
int
|
Context dimension |
gamma_activation |
GammaActivation
|
Parameterisation of |
Examples:
>>> import jax.random as jr, jax.numpy as jnp
>>> film = AffineModulation.init(num_features=8, cond_dim=4, key=jr.key(0))
>>> y = film(jnp.ones(8), jnp.ones(4))
>>> y.shape
(8,)
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
init(num_features: int, cond_dim: int, *, key: PRNGKeyArray, gamma_activation: GammaActivation = 'one_plus_tanh') -> AffineModulation
classmethod
¶
Build AffineModulation with the default 2-output Linear generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_features
|
int
|
Output channel count. |
required |
cond_dim
|
int
|
Context dimension. |
required |
key
|
PRNGKeyArray
|
PRNG key for the generator's init. |
required |
gamma_activation
|
GammaActivation
|
Parameterisation of |
'one_plus_tanh'
|
Returns:
| Type | Description |
|---|---|
AffineModulation
|
Initialised |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
log_det(z: Float[Array, ' K']) -> Float[Array, '']
¶
Sum of log γ across the feature axis.
Only valid when gamma_activation="exp" — that's the only
parameterisation for which log γ = raw_γ exactly. For other
modes this raises NotImplementedError; callers that need
a generic Jacobian must compute it manually.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
Float[Array, ' K']
|
Context vector of shape |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, '']
|
Scalar log-determinant of the diagonal scaling. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
Examples:
>>> import jax.numpy as jnp
>>> import jax.random as jr
>>> film = AffineModulation.init(
... num_features=4, cond_dim=2, key=jr.PRNGKey(0),
... gamma_activation="exp",
... )
>>> film.log_det(jnp.zeros(2)).shape # scalar Σ log γ = Σ raw_γ
()
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
FiLM = AffineModulation
module-attribute
¶
HyperLinear
¶
Bases: AbstractConditioner
Generate a target Linear's (W, b) from z, then apply.
A single eqx.nn.Linear of output size target_out * target_in +
target_out produces the flat parameter vector for an ad-hoc linear
layer; W and b are split out via einx.id. The forward
consumes single-example vectors x: (C_in,) and z: (K,) and
returns (C_out,).
The generator weight scale is multiplied by init_scale so the
generated W magnitude starts small and the composite is near-zero
at init. Default init_scale=0.1 matches NIF (Pan et al. 2023).
Attributes:
| Name | Type | Description |
|---|---|---|
generator |
Linear
|
Linear |
target_in |
int
|
Inner |
target_out |
int
|
Inner |
cond_dim |
int
|
Context dimension |
num_features |
int
|
Alias for |
Examples:
>>> import jax.random as jr, jax.numpy as jnp
>>> hyper = HyperLinear.init(
... target_in=4, target_out=8, cond_dim=3, key=jr.key(0)
... )
>>> y = hyper(jnp.ones(4), jnp.ones(3))
>>> y.shape
(8,)
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
init(target_in: int, target_out: int, cond_dim: int, *, key: PRNGKeyArray, init_scale: float = 0.1) -> HyperLinear
classmethod
¶
Build a HyperLinear with a small-magnitude generator init.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_in
|
int
|
Input dimension of the generated |
required |
target_out
|
int
|
Output dimension of the generated |
required |
cond_dim
|
int
|
Context dimension. |
required |
key
|
PRNGKeyArray
|
PRNG key for generator init. |
required |
init_scale
|
float
|
Multiplicative factor on the generator weights so
the generated |
0.1
|
Returns:
| Type | Description |
|---|---|
HyperLinear
|
Initialised |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any of |
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
Bayesian variants¶
BayesianConcatConditioner
¶
Bases: PyroxModule
geonnax.ConcatConditioner with Normal priors on the projection.
Registers two NumPyro sample sites — {scope}.proj_W and
{scope}.proj_b — under Normal(0, prior_std). Total of two
sites per forward call; nothing is sampled from the inner h or
the context z.
Holds a frozen geonnax.ConcatConditioner core whose
proj weights are swapped with the sampled arrays each call.
Attributes:
| Name | Type | Description |
|---|---|---|
core |
ConcatConditioner
|
Frozen |
num_features |
int
|
Output channels. |
cond_dim |
int
|
Context dimension. |
prior_std |
float
|
Scale of the Normal priors. |
pyrox_name |
str | None
|
Optional explicit scope name for NumPyro. |
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
init(num_features: int, cond_dim: int, *, prior_std: float = 1.0, pyrox_name: str | None = None) -> BayesianConcatConditioner
classmethod
¶
Build a BayesianConcatConditioner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_features
|
int
|
Output channels. |
required |
cond_dim
|
int
|
Context dimension. |
required |
prior_std
|
float
|
Scale of the Normal priors. |
1.0
|
pyrox_name
|
str | None
|
Optional explicit scope name. |
None
|
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
BayesianAffineModulation
¶
Bases: PyroxModule
geonnax.AffineModulation with Normal priors on the FiLM generator.
Registers two sites — {scope}.gen_W and {scope}.gen_b —
under Normal(0, prior_std). The γ activation is fixed by
construction (default "one_plus_tanh") so the prior over the raw
generator output induces a well-defined prior over γ, β.
Holds a frozen geonnax.AffineModulation core whose
generator weights are swapped with the sampled arrays each call.
Attributes:
| Name | Type | Description |
|---|---|---|
core |
AffineModulation
|
Frozen |
num_features |
int
|
Output channels. |
cond_dim |
int
|
Context dimension. |
gamma_activation |
GammaActivation
|
Parameterisation of |
prior_std |
float
|
Scale of the Normal priors. |
pyrox_name |
str | None
|
Optional explicit scope name. |
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
init(num_features: int, cond_dim: int, *, gamma_activation: GammaActivation = 'one_plus_tanh', prior_std: float = 1.0, pyrox_name: str | None = None) -> BayesianAffineModulation
classmethod
¶
Build a BayesianAffineModulation.
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
BayesianHyperLinear
¶
Bases: PyroxModule
geonnax.HyperLinear with Normal priors on the generator only.
Two sites: {scope}.gen_W and {scope}.gen_b. The target
weights (W_target, b_target) are generated — not sampled — so
Bayesian inference cost scales with the generator size
cond_dim * (target_out * target_in + target_out), not with the
target-network size. This is the architectural advantage of doing
Bayesian amortised inference via hypernetworks.
Attributes:
| Name | Type | Description |
|---|---|---|
core |
HyperLinear
|
Frozen |
target_in |
int
|
Inner |
target_out |
int
|
Inner |
cond_dim |
int
|
Context dimension |
num_features |
int
|
Alias for |
prior_std |
float
|
Scale of the Normal priors on the generator. |
pyrox_name |
str | None
|
Optional explicit scope name. |
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
init(target_in: int, target_out: int, cond_dim: int, *, prior_std: float = 1.0, pyrox_name: str | None = None) -> BayesianHyperLinear
classmethod
¶
Build a BayesianHyperLinear.
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
Spectral hyper-conditioning¶
HyperFourierFeatures is the conditional analogue of RBFFourierFeatures: instead of sampling the random Fourier features' (W, b, lengthscale) from a fixed prior, a user-supplied parameter network produces them from the context vector. ConditionedRFFNet adds a learnable linear readout — the conditional analogue of RandomKitchenSinks.
HyperFourierFeatures
¶
Bases: PyroxModule
Random Fourier features with (W, b, log_lengthscale) from a parameter net.
The deterministic counterpart pyrox_nn.RBFFourierFeatures
samples its frequencies and lengthscale from priors. This layer
instead amortises them over a context vector z via a user-supplied
parameter_net:
Two execution modes are supported:
- Shared mode (
z.ndim == 1): the parameter net runs once and the generated features are reused across all rows ofx— same efficiency trick asHyperLinear's shared path. - Per-sample mode (
z.ndim == 2): a distinct(W, b, log_lengthscale)is generated per row ofzviajax.vmapand applied witheinx.dot. This is substantially more expensive in compute and memory because the Fourier parameters are no longer shared across rows ofx, but it is required when eachxrow needs its own context.
The flat output of parameter_net(z) must have size
in_features * n_features + n_features + 1 (frequencies, phases,
log-lengthscale). init does not invoke parameter_net —
a misshapen output surfaces only on the first call.
Attributes:
| Name | Type | Description |
|---|---|---|
parameter_net |
PyroxModule | Module
|
Callable |
in_features |
int
|
Coordinate dimension ( |
n_features |
int
|
Number of frequency pairs; output dim is
|
cond_dim |
int
|
Context dimension expected by |
pyrox_name |
str | None
|
Optional explicit scope name. |
Examples:
>>> import jax.random as jr, jax.numpy as jnp
>>> import equinox as eqx
>>> key = jr.key(0)
>>> # Parameter net: (cond_dim=2,) -> (1*16 + 16 + 1 = 33,)
>>> pnet = eqx.nn.MLP(in_size=2, out_size=33, width_size=32, depth=2, key=key)
>>> hff = HyperFourierFeatures.init(
... parameter_net=pnet, in_features=1, n_features=16, cond_dim=2,
... )
>>> y = hff(jnp.ones((5, 1)), jnp.ones((2,)))
>>> y.shape
(5, 32)
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | |
init(*, parameter_net: PyroxModule | eqx.Module, in_features: int, n_features: int, cond_dim: int, pyrox_name: str | None = None) -> HyperFourierFeatures
classmethod
¶
Build HyperFourierFeatures.
parameter_net is not invoked at construction time, so
Bayesian / numpyro-aware parameter nets that rely on
pyrox_sample work without needing a seed handler at init.
The expected output size is in_features * n_features +
n_features + 1; a mismatch surfaces as a shape error on the
first __call__.
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
ConditionedRFFNet
¶
Bases: PyroxModule
Conditional analogue of pyrox_nn.RandomKitchenSinks.
Composes a HyperFourierFeatures feature map with a learnable
linear readout. The full forward is
where \(\phi(x; z)\) is the HyperFourierFeatures output and
(beta, b_out) are the readout's deterministic weights. For the
Bayesian variant, wrap readout in a DenseReparameterization and
move the priors there — this composite stays minimal.
Attributes:
| Name | Type | Description |
|---|---|---|
feat |
HyperFourierFeatures
|
A |
readout |
Linear
|
|
pyrox_name |
str | None
|
Optional explicit scope name. |
Examples:
>>> import jax.random as jr, jax.numpy as jnp
>>> import equinox as eqx
>>> key = jr.key(0)
>>> pnet = eqx.nn.MLP(
... in_size=4, out_size=1 * 32 + 32 + 1, width_size=32, depth=2, key=key,
... )
>>> feat = HyperFourierFeatures.init(
... parameter_net=pnet, in_features=1, n_features=32, cond_dim=4,
... )
>>> net = ConditionedRFFNet.init(feat=feat, out_features=1, key=key)
>>> y = net(jnp.zeros((10, 1)), jnp.zeros((10, 4)))
>>> y.shape
(10, 1)
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
init(*, feat: HyperFourierFeatures, out_features: int, key: Array, pyrox_name: str | None = None) -> ConditionedRFFNet
classmethod
¶
Build ConditionedRFFNet with a default linear readout.
Source code in packages/pyrox-nn/src/pyrox_nn/_conditioning.py
Composites¶
ConditionedINR
¶
Bases: Module
Wrap an inner network's per-layer activations with conditioners.
Given an inner network exposing a layers sequence (true for
geonnax.SIREN and any module that holds a list of callables
named layers), ConditionedINR runs the inner forward and
inserts a conditioner after each non-readout layer:
z_0 = layer_0(x)
z_0 = cond_0(z_0, c)
z_1 = layer_1(z_0)
z_1 = cond_1(z_1, c)
...
y = layer_{L-1}(z_{L-2}) # readout, not conditioned
The mode="input" shortcut applies a single head conditioner to
x (concatenation for ConcatConditioner, FiLM-style
modulation for AffineModulation, or input-generation for
HyperLinear) before running inner — useful for inner
networks that don't expose a layers sequence (e.g. plain
eqx.nn.MLP instances).
Conditioners must be AbstractConditioner instances whose
num_features matches the corresponding inner layer's output
width.
Attributes:
| Name | Type | Description |
|---|---|---|
inner |
Module
|
Inner network with a |
conditioners |
list[AbstractConditioner]
|
Per-layer conditioner list. Length equals
|
cond_dim |
int
|
Context dimension shared by all conditioners. |
mode |
ConditionedMode
|
|
Examples:
>>> import jax.random as jr, jax.numpy as jnp
>>> from geonnax import SIREN
>>> key = jr.key(0)
>>> inner = SIREN.init(2, 32, 1, depth=4, key=key)
>>> wrapped = ConditionedINR.init(
... inner, conditioner_cls=AffineModulation, cond_dim=4, key=key
... )
>>> y = wrapped(jnp.zeros(2), jnp.zeros(4))
>>> y.shape
(1,)
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
init(inner: eqx.Module, *, conditioner_cls: type[AbstractConditioner], cond_dim: int, key: PRNGKeyArray, mode: ConditionedMode = 'feature', **conditioner_kwargs: object) -> ConditionedINR
classmethod
¶
Build a ConditionedINR around inner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner
|
Module
|
Inner network. Must have |
required |
conditioner_cls
|
type[AbstractConditioner]
|
One of |
required |
cond_dim
|
int
|
Context dimension passed to each conditioner. |
required |
key
|
PRNGKeyArray
|
PRNG key, split internally for each conditioner. |
required |
mode
|
ConditionedMode
|
|
'feature'
|
**conditioner_kwargs
|
object
|
Extra kwargs forwarded to each
|
{}
|
Returns:
| Type | Description |
|---|---|
ConditionedINR
|
Initialised |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
HyperSIREN(in_features: int, hidden_features: int, out_features: int, *, depth: int, cond_dim: int, parameter_net: eqx.Module, key: PRNGKeyArray, first_omega: float = 30.0, hidden_omega: float = 30.0, c: float = 6.0, init_scale: float = 0.1) -> GeneratedSiren
¶
NIF-style ShapeNet/ParameterNet composite (Pan, Brunton, Kutz — JMLR 2023).
Builds a SIREN shape-net of the requested topology, then constructs a
parallel list of HyperLinear generators — one per SIREN layer
— whose init_scale is calibrated per Sitzmann regime so the
expected magnitude of each generated W matches the half-width
of Sitzmann's geonnax.siren.siren_W_limit at init.
Without this calibration the ShapeNet's pre-activation variance is
wrong and training is unstable.
The user-supplied parameter_net runs once on mu per forward
call to produce the latent z; z then drives every per-layer
HyperLinear. parameter_net must be callable with signature
(P,) -> (cond_dim,).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_features
|
int
|
Coordinate dimension of the SIREN. |
required |
hidden_features
|
int
|
Hidden width. |
required |
out_features
|
int
|
Output dimension. |
required |
depth
|
int
|
SIREN depth (must be ≥ 2). |
required |
cond_dim
|
int
|
Latent dimension produced by |
required |
parameter_net
|
Module
|
User-supplied callable |
required |
key
|
PRNGKeyArray
|
PRNG key, split internally for the SIREN init and the hyper generators. |
required |
first_omega
|
float
|
First-layer |
30.0
|
hidden_omega
|
float
|
Hidden-layer |
30.0
|
c
|
float
|
SIREN Theorem-1 constant. |
6.0
|
init_scale
|
float
|
Multiplicative factor applied on top of the per-regime
calibration; default |
0.1
|
Returns:
| Type | Description |
|---|---|
GeneratedSiren
|
A composite that takes |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
>>> import jax.numpy as jnp
>>> import jax.random as jr
>>> import equinox as eqx
>>> pnet_key, build_key = jr.split(jr.PRNGKey(0))
>>> pnet = eqx.nn.MLP(
... in_size=2, out_size=4, width_size=8, depth=2, key=pnet_key
... )
>>> net = HyperSIREN(
... in_features=3, hidden_features=8, out_features=2, depth=2,
... cond_dim=4, parameter_net=pnet, key=build_key,
... )
>>> net(jnp.zeros(3), jnp.zeros(2)).shape
(2,)
Source code in .venv/lib/python3.12/site-packages/geonnax/conditioning.py
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | |