Point Architectures API
The point-architecture module provides ten shape-preserving internal fields for
SILVACortexLayer. Use the registry to inspect the available names and the
factory to build a module from configuration.
Their source patterns have stable entries for the MLP lineage
[25], residual networks
[26], U-Net
[27], DenseNet
[28], Transformer
[29], MobileNetV2
[30], FNO
[31], MLP-Mixer
[33], and ConvNeXt V2
[34].
from silva_networks import (
available_silva_point_architectures,
silva_point_architecture,
silva_point_architecture_info,
)
print(available_silva_point_architectures())
info = silva_point_architecture_info("unet")
transition = silva_point_architecture("unet", channels=8, base_channels=16)
The modules are compact SILVA-compatible implementations. Their source
architectures define the internal computation pattern; they do not reproduce a
paper's complete model, training schedule, or benchmark protocol.
Role Inside a Point
For a SILVACortexLayer, the internal architecture supplies the named
state-network contribution \(A_\theta\):
\[
z^\star
=
\Phi\left{
S_\theta(x)
+A_\theta(z^\star)
+H_\theta(z^\star)
+L_\theta(z^\star,E)
+G_\theta(z^\star,b)
\right\}.
\]
The factory modules are shape preserving, so
\[
A_\theta:\mathbb R^{d_1\times\cdots\times d_r}
\rightarrow
\mathbb R^{d_1\times\cdots\times d_r}.
\]
That condition lets the architecture participate in repeated fixed-point
evaluation. It does not by itself guarantee convergence; output scaling,
damping, normalization, and the combined Jacobian of all active branches still
matter.
Layout Table
| Factory name |
State layout |
Internal pattern |
mlp |
(..., channels) |
feed-forward channel mixing |
residual_mlp |
(..., channels) |
residual channel blocks |
residual_cnn |
(batch, channels, height, width) |
residual convolutions |
unet |
(batch, channels, height, width) |
down path, bottleneck, up path, skip |
dense_cnn |
(batch, channels, height, width) |
dense feature concatenation |
transformer |
(batch, tokens, channels) |
token attention and feed-forward mixing |
inverted_residual |
(batch, channels, height, width) |
expansion, depthwise convolution, projection |
fourier_operator |
(batch, channels, height, width) |
retained Fourier modes plus local projection |
mlp_mixer |
(batch, tokens, channels) |
alternating token and channel MLPs |
convnext_v2 |
(batch, channels, height, width) |
depthwise convolution and response normalization |
Put a Factory Module in SILVA
import torch
from silva_networks import SILVACortexLayer, SolverConfig, silva_point_architecture
field = silva_point_architecture(
"fourier_operator",
channels=8,
modes_height=4,
modes_width=4,
scale=0.05,
)
point = SILVACortexLayer(
input_encoder=torch.nn.Conv2d(3, 8, kernel_size=1),
state_network=field,
normalizer=torch.nn.GroupNorm(2, 8),
config=SolverConfig(max_iter=20, alpha=0.4, tol=1e-5),
)
x = torch.randn(2, 3, 16, 16)
result = point(x, return_result=True)
assert result.z.shape == (2, 8, 16, 16)
print(result.residuals[-1])
Inspect the residual trajectory and combined transition Jacobian after changing
an internal architecture or its scale. The full derivations, constructor
arguments, and composition examples are in the
Point Architecture Catalog; operator,
ODE, and PDE connections are developed in
Neural Operators, ODEs, PDEs, and SILVA.
Primary architecture sources are listed in
Point Architecture Sources.
silva_networks.point_architectures
Shape-preserving internal architectures for SILVA equilibrium points.
SILVAPointArchitectureInfo
dataclass
Description of one built-in SILVA point architecture.
Attributes:
| Name |
Type |
Description |
name |
SILVAPointArchitectureName
|
Stable name accepted by :func:silva_point_architecture.
|
state_layout |
str
|
Tensor layout expected by the module.
|
introduced |
int | None
|
Publication year of the source architecture, when applicable.
|
reference_url |
str | None
|
Primary source for the architecture, when applicable.
|
summary |
str
|
Short description of the internal computation.
|
Source code in src/silva_networks/point_architectures.py
| @dataclass(frozen=True)
class SILVAPointArchitectureInfo:
"""Description of one built-in SILVA point architecture.
Attributes:
name: Stable name accepted by :func:`silva_point_architecture`.
state_layout: Tensor layout expected by the module.
introduced: Publication year of the source architecture, when applicable.
reference_url: Primary source for the architecture, when applicable.
summary: Short description of the internal computation.
"""
name: SILVAPointArchitectureName
state_layout: str
introduced: int | None
reference_url: str | None
summary: str
|
SILVAMLPPointArchitecture
Bases: Module
Feed-forward field for vector or token SILVA states.
Source code in src/silva_networks/point_architectures.py
| class SILVAMLPPointArchitecture(nn.Module):
"""Feed-forward field for vector or token SILVA states."""
def __init__(
self,
dim: int,
hidden_dim: int | None = None,
depth: int = 2,
scale: float = 0.1,
):
super().__init__()
_check_positive(dim, "dim")
_check_positive(depth, "depth")
hidden_dim = hidden_dim or 2 * dim
_check_positive(hidden_dim, "hidden_dim")
layers: list[nn.Module] = [nn.Linear(dim, hidden_dim), nn.GELU()]
for _ in range(depth - 1):
layers.extend([nn.Linear(hidden_dim, hidden_dim), nn.GELU()])
layers.append(nn.Linear(hidden_dim, dim))
self.network = nn.Sequential(*layers)
self.dim = dim
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
if z.shape[-1] != self.dim:
raise ValueError(
f"SILVAMLPPointArchitecture expects last dimension {self.dim}; "
f"received shape {tuple(z.shape)}"
)
return self.scale * self.network(z)
|
SILVAResidualMLPPointArchitecture
Bases: Module
Residual multilayer field for vector or token SILVA states.
Source code in src/silva_networks/point_architectures.py
| class SILVAResidualMLPPointArchitecture(nn.Module):
"""Residual multilayer field for vector or token SILVA states."""
def __init__(
self,
dim: int,
hidden_dim: int | None = None,
depth: int = 2,
scale: float = 0.1,
):
super().__init__()
_check_positive(dim, "dim")
_check_positive(depth, "depth")
hidden_dim = hidden_dim or 2 * dim
_check_positive(hidden_dim, "hidden_dim")
self.blocks = nn.ModuleList(
[_ResidualMLPBlock(dim, hidden_dim) for _ in range(depth)]
)
self.dim = dim
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
if z.shape[-1] != self.dim:
raise ValueError(
f"SILVAResidualMLPPointArchitecture expects last dimension {self.dim}; "
f"received shape {tuple(z.shape)}"
)
state = z
for block in self.blocks:
state = block(state)
return self.scale * state
|
SILVAResidualConvPointArchitecture
Bases: Module
Residual convolutional field for spatial SILVA states in NCHW layout.
Source code in src/silva_networks/point_architectures.py
| class SILVAResidualConvPointArchitecture(nn.Module):
"""Residual convolutional field for spatial SILVA states in NCHW layout."""
def __init__(
self,
channels: int,
depth: int = 2,
kernel_size: int = 3,
scale: float = 0.1,
):
super().__init__()
_check_positive(channels, "channels")
_check_positive(depth, "depth")
if kernel_size % 2 != 1:
raise ValueError("kernel_size must be odd to preserve spatial shape")
self.blocks = nn.ModuleList(
[_ResidualConvBlock(channels, kernel_size) for _ in range(depth)]
)
self.channels = channels
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 4, self.__class__.__name__, "(batch, channels, height, width)")
if z.shape[1] != self.channels:
raise ValueError(f"expected {self.channels} channels; received {z.shape[1]}")
state = z
for block in self.blocks:
state = block(state)
return self.scale * state
|
SILVAUNetPointArchitecture
Bases: Module
Compact U-Net-shaped field that restores the spatial SILVA state shape.
Source code in src/silva_networks/point_architectures.py
| class SILVAUNetPointArchitecture(nn.Module):
"""Compact U-Net-shaped field that restores the spatial SILVA state shape."""
def __init__(
self,
channels: int,
base_channels: int | None = None,
scale: float = 0.1,
):
super().__init__()
_check_positive(channels, "channels")
base_channels = base_channels or 2 * channels
_check_positive(base_channels, "base_channels")
self.encoder = _ResidualConvBlock(channels)
self.down = nn.Conv2d(channels, base_channels, kernel_size=3, stride=2, padding=1)
self.bottleneck = _ResidualConvBlock(base_channels)
self.up = nn.ConvTranspose2d(base_channels, channels, kernel_size=2, stride=2)
self.decoder = nn.Sequential(
nn.Conv2d(2 * channels, channels, kernel_size=3, padding=1),
nn.GELU(),
nn.Conv2d(channels, channels, kernel_size=3, padding=1),
)
self.channels = channels
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 4, self.__class__.__name__, "(batch, channels, height, width)")
if z.shape[1] != self.channels:
raise ValueError(f"expected {self.channels} channels; received {z.shape[1]}")
skip = self.encoder(z)
low = self.bottleneck(F.gelu(self.down(skip)))
up = self.up(low)
if up.shape[-2:] != skip.shape[-2:]:
up = F.interpolate(up, size=skip.shape[-2:], mode="bilinear", align_corners=False)
return self.scale * self.decoder(torch.cat([skip, up], dim=1))
|
SILVADenseConvPointArchitecture
Bases: Module
DenseNet-style concatenated convolutional field for spatial SILVA states.
Source code in src/silva_networks/point_architectures.py
| class SILVADenseConvPointArchitecture(nn.Module):
"""DenseNet-style concatenated convolutional field for spatial SILVA states."""
def __init__(
self,
channels: int,
growth_rate: int | None = None,
depth: int = 3,
scale: float = 0.1,
):
super().__init__()
_check_positive(channels, "channels")
_check_positive(depth, "depth")
growth_rate = growth_rate or channels
_check_positive(growth_rate, "growth_rate")
self.layers = nn.ModuleList()
width = channels
for _ in range(depth):
self.layers.append(
nn.Sequential(
nn.GroupNorm(1, width),
nn.GELU(),
nn.Conv2d(width, growth_rate, kernel_size=3, padding=1),
)
)
width += growth_rate
self.project = nn.Conv2d(width, channels, kernel_size=1)
self.channels = channels
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 4, self.__class__.__name__, "(batch, channels, height, width)")
if z.shape[1] != self.channels:
raise ValueError(f"expected {self.channels} channels; received {z.shape[1]}")
features = [z]
for layer in self.layers:
features.append(layer(torch.cat(features, dim=1)))
return self.scale * self.project(torch.cat(features, dim=1))
|
Bases: Module
Transformer encoder field for token SILVA states in BND layout.
Source code in src/silva_networks/point_architectures.py
| class SILVATransformerPointArchitecture(nn.Module):
"""Transformer encoder field for token SILVA states in BND layout."""
def __init__(
self,
dim: int,
heads: int = 2,
hidden_dim: int | None = None,
scale: float = 0.1,
):
super().__init__()
_check_positive(dim, "dim")
_check_positive(heads, "heads")
if dim % heads != 0:
raise ValueError("dim must be divisible by heads")
hidden_dim = hidden_dim or 4 * dim
self.layer = nn.TransformerEncoderLayer(
d_model=dim,
nhead=heads,
dim_feedforward=hidden_dim,
dropout=0.0,
activation="gelu",
batch_first=True,
norm_first=True,
)
self.dim = dim
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 3, self.__class__.__name__, "(batch, tokens, channels)")
if z.shape[-1] != self.dim:
raise ValueError(f"expected channel width {self.dim}; received {z.shape[-1]}")
return self.scale * self.layer(z)
|
SILVAInvertedResidualPointArchitecture
Bases: Module
MobileNetV2-style inverted residual field for spatial SILVA states.
Source code in src/silva_networks/point_architectures.py
| class SILVAInvertedResidualPointArchitecture(nn.Module):
"""MobileNetV2-style inverted residual field for spatial SILVA states."""
def __init__(self, channels: int, expansion: int = 4, scale: float = 0.1):
super().__init__()
_check_positive(channels, "channels")
_check_positive(expansion, "expansion")
expanded = expansion * channels
self.expand = nn.Conv2d(channels, expanded, kernel_size=1)
self.depthwise = nn.Conv2d(
expanded,
expanded,
kernel_size=3,
padding=1,
groups=expanded,
)
self.norm = nn.GroupNorm(1, expanded)
self.project = nn.Conv2d(expanded, channels, kernel_size=1)
self.channels = channels
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 4, self.__class__.__name__, "(batch, channels, height, width)")
if z.shape[1] != self.channels:
raise ValueError(f"expected {self.channels} channels; received {z.shape[1]}")
update = F.gelu(self.expand(z))
update = F.gelu(self.norm(self.depthwise(update)))
return self.scale * (z + self.project(update))
|
SILVAFourierOperatorPointArchitecture
Bases: Module
Fourier-operator field with spectral and local spatial branches.
Source code in src/silva_networks/point_architectures.py
| class SILVAFourierOperatorPointArchitecture(nn.Module):
"""Fourier-operator field with spectral and local spatial branches."""
def __init__(
self,
channels: int,
modes_height: int = 4,
modes_width: int = 4,
scale: float = 0.1,
):
super().__init__()
_check_positive(channels, "channels")
self.spectral = _SpectralConv2d(channels, modes_height, modes_width)
self.local = nn.Conv2d(channels, channels, kernel_size=1)
self.channels = channels
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 4, self.__class__.__name__, "(batch, channels, height, width)")
if z.shape[1] != self.channels:
raise ValueError(f"expected {self.channels} channels; received {z.shape[1]}")
return self.scale * (self.spectral(z) + self.local(z))
|
SILVAMLPMixerPointArchitecture
Bases: Module
MLP-Mixer field for fixed-length token SILVA states in BND layout.
Source code in src/silva_networks/point_architectures.py
| class SILVAMLPMixerPointArchitecture(nn.Module):
"""MLP-Mixer field for fixed-length token SILVA states in BND layout."""
def __init__(
self,
tokens: int,
dim: int,
token_hidden_dim: int | None = None,
channel_hidden_dim: int | None = None,
depth: int = 1,
scale: float = 0.1,
):
super().__init__()
_check_positive(tokens, "tokens")
_check_positive(dim, "dim")
_check_positive(depth, "depth")
token_hidden_dim = token_hidden_dim or 2 * tokens
channel_hidden_dim = channel_hidden_dim or 2 * dim
self.blocks = nn.ModuleList(
[
_MLPMixerBlock(tokens, dim, token_hidden_dim, channel_hidden_dim)
for _ in range(depth)
]
)
self.tokens = tokens
self.dim = dim
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 3, self.__class__.__name__, "(batch, tokens, channels)")
if z.shape[1:] != (self.tokens, self.dim):
raise ValueError(
f"expected token shape ({self.tokens}, {self.dim}); "
f"received {tuple(z.shape[1:])}"
)
state = z
for block in self.blocks:
state = block(state)
return self.scale * state
|
SILVAConvNeXtV2PointArchitecture
Bases: Module
ConvNeXt V2-style depthwise and response-normalized spatial field.
Source code in src/silva_networks/point_architectures.py
| class SILVAConvNeXtV2PointArchitecture(nn.Module):
"""ConvNeXt V2-style depthwise and response-normalized spatial field."""
def __init__(
self,
channels: int,
expansion: int = 4,
depth: int = 1,
scale: float = 0.1,
):
super().__init__()
_check_positive(channels, "channels")
_check_positive(expansion, "expansion")
_check_positive(depth, "depth")
self.blocks = nn.ModuleList(
[_ConvNeXtV2Block(channels, expansion) for _ in range(depth)]
)
self.channels = channels
self.scale = float(scale)
def forward(self, z: Tensor) -> Tensor:
_check_rank(z, 4, self.__class__.__name__, "(batch, channels, height, width)")
if z.shape[1] != self.channels:
raise ValueError(f"expected {self.channels} channels; received {z.shape[1]}")
state = z
for block in self.blocks:
state = block(state)
return self.scale * state
|
available_silva_point_architectures
available_silva_point_architectures() -> tuple[SILVAPointArchitectureName, ...]
Return the stable names of the ten built-in point architectures.
Source code in src/silva_networks/point_architectures.py
| def available_silva_point_architectures() -> tuple[SILVAPointArchitectureName, ...]:
"""Return the stable names of the ten built-in point architectures."""
return tuple(_ARCHITECTURE_CLASSES)
|
silva_point_architecture_info
silva_point_architecture_info(name: SILVAPointArchitectureName | str) -> SILVAPointArchitectureInfo
Return tensor-layout and source metadata for one point architecture.
Source code in src/silva_networks/point_architectures.py
| def silva_point_architecture_info(
name: SILVAPointArchitectureName | str,
) -> SILVAPointArchitectureInfo:
"""Return tensor-layout and source metadata for one point architecture."""
try:
return _ARCHITECTURE_INFO[name] # type: ignore[index]
except KeyError as exc:
choices = ", ".join(available_silva_point_architectures())
raise ValueError(f"Unknown SILVA point architecture '{name}'. Choose from: {choices}") from exc
|
silva_point_architecture
silva_point_architecture(name: SILVAPointArchitectureName | str, **kwargs) -> nn.Module
Build a shape-preserving internal architecture for a SILVA point.
Constructor arguments are forwarded to the selected architecture class.
Use :func:silva_point_architecture_info to inspect the expected state
layout before construction.
Source code in src/silva_networks/point_architectures.py
| def silva_point_architecture(
name: SILVAPointArchitectureName | str,
**kwargs,
) -> nn.Module:
"""Build a shape-preserving internal architecture for a SILVA point.
Constructor arguments are forwarded to the selected architecture class.
Use :func:`silva_point_architecture_info` to inspect the expected state
layout before construction.
"""
try:
architecture = _ARCHITECTURE_CLASSES[name] # type: ignore[index]
except KeyError as exc:
choices = ", ".join(available_silva_point_architectures())
raise ValueError(f"Unknown SILVA point architecture '{name}'. Choose from: {choices}") from exc
return architecture(**kwargs)
|
Where to Go Next