SILVA Presets API
The SILVA study's Figure 1 is the organizing contract for the package; the complete article citation is [1].
The map \(f_\theta\) is built from four visible pieces:
Here \(S_\theta\) is stimulus injection, \(H_\theta\) is an optional learned
self-interaction, \(L_\theta\) is local interaction, \(G_\theta\) is global
interaction, \(\chi\) is the recurrent signal map, and \(\Phi\) is the
domain-specific output block. In the SILVA defaults, self-persistence is
carried by the solver term \((1-\alpha)z_k\), so \(H_\theta=0\). The generic
package API also allows a learned self branch through self_term.
Figure 1 Blocks
| Figure 1 block | Package API | SILVA default | User control |
|---|---|---|---|
| Stimulus | StimulusEncoder, input_injection, W_stim |
Linear map into the state dimension | Replace with any encoder before a layer or subclass the layer |
| Self persistence | SolverConfig(alpha=...) |
\((1-\alpha)z_k\) | Any damping value per layer |
| Learned self term | self_term="linear" or custom module |
Disabled | Optional branch in SILVALayer and SILVAGraphNetwork |
| Local interaction | GraphAttentionLocal, GraphLocal, DynamicChannelLocal, custom module |
Domain-specific | Select by name or pass an nn.Module |
| Global interaction | GatedMeanFieldGlobal, StaticMeanFieldGlobal, TopKGlobalAttention, ChannelSelfAttentionGlobal, custom module |
Domain-specific | Select by name or pass an nn.Module |
| Solver | picard, anderson, broyden |
Picard for public defaults; Anderson/Broyden for accelerated or root-finding studies | Set solver or SolverConfig per layer |
| Backward mode | unrolled, implicit, or phantom |
Finite-step PyTorch gradients by default; exact adjoint and phantom approximations are selectable | Set a complete SolverConfig through solver_configs or the convenience backward arguments |
| Readout | build_mlp_head, task heads, regression heads |
Task-specific | Replace or extend as ordinary PyTorch modules |
What Can Be Varied
The reference constructors expose the main experimental degrees of freedom directly:
| Family | Size controls | Interaction controls | Solver controls |
|---|---|---|---|
SILVAGraphPresetNetwork |
in_dim, scalar or list hidden_dim, out_dim, stack_alphas, head_hidden_dims |
attention_mode, graph_mode, num_heads, k_neighbors, local_depth, task, pooling |
solver, max_iter, backward_mode, per-layer damping through stack_alphas |
SILVAVisionVectorClassifier |
in_dim, scalar or list hidden_dim, num_classes, alphas, head_hidden_dims |
attention_mode, graph_mode, k_neighbors, num_heads |
solver, max_iter, backward_mode, per-layer damping through alphas |
SILVAConvVisionClassifier |
in_channels, image_size, scalar or list hidden_dim, num_classes |
convolutional stem plus vector local/global channel modes | solver, max_iter, backward_mode, alphas |
SILVAImageCortexClassifier |
in_channels, image_size, scalar or list hidden_dim, num_classes, internal_depth, head_hidden_dims |
convolutional retina, linked cortex points, optional learned self branch, vector local/global channel modes | solver, max_iter, backward_mode, alphas |
SILVAMolecularRegressor |
scalar or list hidden_dim, num_atom_types, num_bond_types, atom_feature_dim, bond_feature_dim, out_dim |
bond-aware local attention, graph mean global context, num_heads, dropout, spectral_norm |
solver, max_iter, backward_mode, alphas |
Every high-level preset accepts solver_configs, either one SolverConfig or
one per equilibrium point. This exposes relative stopping, per-sample Anderson,
best-iterate return, sparse trajectory indexing, all backward solvers, and
phantom gradients without bypassing the preset.
For molecular equilibrium dropout, choose dropout_mode="variational" for a
fixed mask during each solve, "independent" for finite unrolling with a new
mask per call, or "disabled". Positive independent dropout is intentionally
rejected with exact implicit or phantom gradients
because those methods require one deterministic transition during a solve.
The lower-level SILVAGraphNetwork and SILVALayer accept built-in operator
names, module instances, or factories. This is the extension point for new
interaction matrices, new graph rules, new physical couplings, or a dataset
whose structure is not covered by the SILVA presets.
Case Matrix
| Case | Public class | State entities | Local term | Global term | Readout |
|---|---|---|---|---|---|
| graph/node | SILVAGraphPresetLayer, SILVAGraphPresetNetwork |
nodes | GAT, mean graph, or none | gated mean, static mean, top-k, mean, or none | node or graph head |
| vector vision | SILVAVisionVectorLayer, SILVAVisionVectorClassifier |
hidden channels per sample | dynamic channel kNN or none | channel attention, multi-head channel attention, static channel, or none | classifier head |
| convolutional vision | SILVAConvStem, SILVAConvVisionClassifier |
stem channels, then vector hidden channels | convolutional stem plus vector local term | vector channel global term | classifier head |
| cortex vision | SILVAImageCortexClassifier |
linked vector cortex states after a convolutional retina | dynamic channel kNN or none, plus optional learned self term | channel attention, multi-head channel attention, static channel, or none | classifier head |
| molecular graph | SILVAMolecularLayer, SILVAMolecularRegressor |
atoms | bond-aware graph attention | molecule-wise mean context | graph regression head |
| custom extension | SILVALayer, SILVAGraphNetwork, DEQLayer |
user-defined | user module | user module | user module |
Graph and Node SILVA
SILVAGraphPresetLayer implements the graph/node SILVA equation
SILVAGraphPresetNetwork stacks these layers. The default two-layer hierarchy
uses \(\alpha_1=0.5\) and \(\alpha_2=0.2\). The field stack_alphas extends this
to any number of separately solved equilibria:
from silva_networks import SILVAGraphPresetNetwork
model = SILVAGraphPresetNetwork(
in_dim=dataset_num_features,
hidden_dim=[64, 48],
out_dim=num_classes,
task="node",
attention_mode="simple",
graph_mode="GAT",
stack_alphas=[0.5, 0.35, 0.2],
max_iter=15,
)
Local Modes
graph_mode="GAT" selects graph attention over the supplied edge_index.
For source \(j\) and receiver \(i\),
graph_mode="none" removes the local branch. graph_mode="mean" uses
degree-normalized mean aggregation. The lower-level API accepts any module with
signature like forward(z, edge_index=None, batch=None).
Global Modes
attention_mode="simple" selects the scalar-gated mean-field term:
When batch is supplied, each graph receives its own \(g\) and \(\beta\).
This prevents nodes from different graphs in the same minibatch from sharing
global context.
attention_mode="static" uses \(G(y)_i=W_g g\). attention_mode="topk" uses
bounded node-to-node attention:
attention_mode="none" removes the global branch.
Vision SILVA
The flattened/vector vision family is implemented by SILVAVisionVectorLayer
and SILVAVisionVectorClassifier. Its state nodes are hidden channels of one
sample, not pixels from different samples:
The local branch builds a dynamic hidden-channel graph:
The package class is DynamicChannelLocal. The global branch
ChannelSelfAttentionGlobal computes per-sample channel attention:
Changing another sample in the batch does not change \(A_b\) for sample \(b\).
Convolutional Vision Stem
SILVAConvVisionClassifier adds a two-block convolutional stem before the
vector equilibrium stack. The stem computes
The first vector equilibrium receives \(u_b\) as stimulus:
Deeper layers use the previous equilibrium state:
The classifier head is
Use this case for CIFAR-style tensors with shape
(batch, channels, image_size, image_size).
Image Cortex Hierarchy
SILVAImageCortexClassifier exposes the retina-to-cortex hierarchy as a
single preset while keeping the lower-level SILVACortexLayer controls
available. The convolutional retina is
and cortex point \(\ell\) solves
Inside each point,
The internal_depth argument controls the depth of \(B_{\theta_\ell}\). The
self_interaction argument toggles \(H_{\theta_\ell}\). The attention_mode,
graph_mode, k_neighbors, and num_heads arguments select \(G\) and \(L\).
from silva_networks import SILVAImageCortexClassifier
model = SILVAImageCortexClassifier(
in_channels=3,
hidden_dim=[128, 128],
num_classes=10,
image_size=32,
attention_mode="simple",
graph_mode="GAT",
k_neighbors=4,
alphas=(0.5, 0.2),
max_iter=20,
internal_depth=2,
self_interaction=True,
)
Passing hidden_dim=[128, 96, 64] and alphas=(0.5, 0.35, 0.2) creates three
linked cortex points. Passing internal_depth=10 puts ten state-network blocks
inside each point.
Molecular SILVA
SILVAMolecularRegressor implements the ZINC-style molecular pattern:
Each equilibrium layer uses bond-aware local graph attention, graph mean context, and a LayerNorm-ReLU update:
The default stack again uses \(\alpha_1=0.5\), \(\alpha_2=0.2\), and mean pooling for graph-level regression.
Continuous atom and bond features can be used without changing the engine:
from silva_networks import SILVAMolecularRegressor
model = SILVAMolecularRegressor(
hidden_dim=[128, 64],
atom_feature_dim=atom_features.shape[1],
bond_feature_dim=bond_features.shape[1],
num_heads=4,
alphas=(0.5, 0.2),
)
Categorical tensors use num_atom_types and num_bond_types embeddings. If a
dataset provides multiple categorical columns per atom or bond, their embeddings
are summed into the first equilibrium width.
Custom Architectures
The SILVA presets are starting points, not restrictions. Any branch can be replaced:
import torch
from silva_networks import SILVAGraphNetwork, SolverConfig
class MyGlobal(torch.nn.Module):
def __init__(self, dim):
super().__init__()
self.proj = torch.nn.Linear(dim, dim)
def forward(self, z, batch=None):
context = z.max(dim=0, keepdim=True).values
return self.proj(context).expand_as(z)
model = SILVAGraphNetwork(
in_dim=8,
hidden_dims=[64, 64],
out_dim=3,
task="node",
local="gat",
global_term=MyGlobal(64),
self_term="linear",
config=[
SolverConfig(solver="picard", alpha=0.5, max_iter=15),
SolverConfig(solver="anderson", alpha=0.2, max_iter=15),
],
)
This keeps the SILVA form while allowing new datasets, new operators, new heads, and new solver settings.
Reference SILVA architectures.
This module provides clean PyTorch implementations of the SILVA model families described in "SILVA Networks as Structured Implicit Layers and Vector Attractors via Dynamic Interaction Fields" by Jose Luis Silva. The graph branches use graph-attention ideas from Velickovic et al. (2018), the attention branches use scaled dot-product attention from Vaswani et al. (2017), and the fixed-point framing follows deep equilibrium models from Bai, Kolter, and Koltun (2019).
SILVAConvStem
Bases: Module
Two-block convolutional stem used before vector equilibria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
Number of image input channels. |
required |
hidden_dim
|
int
|
Output feature dimension. |
required |
image_size
|
int
|
Square image size. |
32
|
dropout
|
float
|
Dropout probability after the convolution blocks. |
0.3
|
Inputs
x: Tensor with shape (batch, in_channels, image_size, image_size).
Output
Tensor: Tensor with shape (batch, hidden_dim).
Source code in src/silva_networks/presets.py
SILVAConvVisionClassifier
Bases: Module
CIFAR-style convolutional stem followed by vector SILVA layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
Number of image input channels. |
3
|
hidden_dim
|
int | Sequence[int]
|
Recurrent hidden-channel count, or one hidden-channel count
per value in |
64
|
num_classes
|
int
|
Number of class logits. |
10
|
image_size
|
int
|
Square image size. |
32
|
attention_mode
|
VisionAttentionMode
|
Global channel branch mode. |
'simple'
|
graph_mode
|
VisionGraphMode
|
Local channel branch mode. |
'GAT'
|
k_neighbors
|
int
|
Number of hidden-channel neighbors. |
4
|
num_heads
|
int
|
Number of channel-attention heads. |
4
|
alphas
|
Sequence[float]
|
Damping values, one per equilibrium layer. |
(0.5, 0.2)
|
max_iter
|
int
|
Solver iterations per layer. |
20
|
solver
|
str
|
Fixed-point solver name. |
'picard'
|
dropout
|
float
|
Dropout probability in the convolutional stem. |
0.3
|
Inputs
x: Tensor with shape (batch, in_channels, image_size, image_size).
Output
Tensor | SILVANetworkOutput: Logit tensor, or SILVANetworkOutput when state/results are requested.
Source code in src/silva_networks/presets.py
SILVAGraphPresetConfig
dataclass
Reference defaults for a SILVA equilibrium layer.
The defaults encode the common two-timescale SILVA settings used by the public examples: Picard iteration, a local graph branch, a global branch, and damping. Every field can be overridden at construction time or replaced with custom PyTorch modules in the lower-level API.
Source code in src/silva_networks/presets.py
SILVAGraphPresetLayer
Bases: Module
Reference graph/node SILVA equilibrium layer.
The layer computes
f(z, x) = LayerNorm(ReLU(W_stim x + L(tanh(z)) + G(tanh(z))))
and solves z = f(z, x) with the configured fixed-point solver. It is
designed for citation graphs, CLUSTER/PATTERN-style node tasks, and any
user dataset represented by feature matrix x and edge_index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features per node/entity. |
required |
hidden_dim
|
int
|
Recurrent state dimension. |
64
|
attention_mode
|
AttentionMode
|
Global branch: |
'simple'
|
graph_mode
|
GraphMode
|
Local branch: |
'GAT'
|
num_heads
|
int
|
Number of graph-attention heads. |
4
|
k_neighbors
|
int
|
Top-k support size for bounded global attention. |
16
|
local_depth
|
int
|
Number of weight-tied local applications inside one solver step. |
1
|
config
|
SolverConfig | None
|
Fixed-point solver configuration. |
None
|
normalize
|
bool
|
If true, apply |
True
|
Inputs
x: Tensor with shape (nodes, in_dim).
edge_index: Optional tensor with shape (2, edges), source row first.
batch: Optional graph id tensor with shape (nodes,).
z0: Optional initial state with shape (nodes, hidden_dim).
Output
Tensor: Tensor with shape (nodes, hidden_dim) or SolverResult when
return_result=True.
Source code in src/silva_networks/presets.py
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 157 158 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 | |
SILVAGraphPresetNetwork
Bases: Module
Stacked reference SILVA graph model.
By default this is the fast/slow two-layer architecture used for the
SILVA study's graph-node and CLUSTER/PATTERN-style cases:
alpha_1 = 0.5 and alpha_2 = 0.2. Passing stack_alphas exposes
the same hierarchy as an arbitrary-depth stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features per node/entity. |
required |
hidden_dim
|
int | Sequence[int]
|
Recurrent state dimension for every equilibrium layer, or
one dimension per layer when |
required |
out_dim
|
int
|
Number of output classes or regression targets. |
required |
task
|
TaskMode
|
|
'node'
|
pooling
|
PoolingMode
|
Graph pooling mode when |
'mean'
|
attention_mode
|
AttentionMode
|
Global branch mode. |
'simple'
|
graph_mode
|
GraphMode
|
Local branch mode. |
'GAT'
|
num_heads
|
int
|
Number of graph-attention heads. |
4
|
k_neighbors
|
int
|
Top-k support size for bounded global attention. |
16
|
local_depth
|
int
|
Weight-tied local repetitions inside a solver step. |
1
|
layer1_alpha
|
float
|
Damping for the first layer when |
0.5
|
layer2_alpha
|
float
|
Damping for the second layer when |
0.2
|
stack_alphas
|
Sequence[float] | None
|
Optional damping values for an arbitrary-depth stack. |
None
|
max_iter
|
int
|
Solver iterations per equilibrium layer. |
15
|
solver
|
str
|
Fixed-point solver name. |
'picard'
|
head_hidden_dims
|
Sequence[int]
|
Hidden dimensions for the readout head. |
()
|
dropout
|
float
|
Dropout probability inside the readout head. |
0.0
|
Inputs
x: Tensor with shape (nodes, in_dim).
edge_index: Optional tensor with shape (2, edges).
batch: Optional graph id tensor with shape (nodes,).
Output
Tensor | SILVANetworkOutput: Output tensor, or SILVANetworkOutput when state/results are requested.
Source code in src/silva_networks/presets.py
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 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 | |
SILVAImageCortexClassifier
Bases: Module
Article-style retina plus linked SILVA cortex equilibrium points.
This preset keeps the cortex hierarchy explicit: a convolutional front end maps an image to a vector stimulus, then each cortex point solves its own fixed point with its own damping value, solver, local branch, global branch, and optional internal transition network.
The default two-point hierarchy uses alphas (0.5, 0.2), matching the
fast/slow structure used in the SILVA article code. Passing longer alphas
and hidden_dim sequences creates deeper cortex hierarchies.
Reference: Jose Luis Silva, "SILVA Networks as Structured Implicit Layers and Vector Attractors via Dynamic Interaction Fields", arXiv:2607.28989.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
Number of image input channels. |
3
|
hidden_dim
|
int | Sequence[int]
|
Recurrent state width, or one width per cortex point. |
64
|
num_classes
|
int
|
Number of class logits. |
10
|
image_size
|
int
|
Square image size. |
32
|
attention_mode
|
VisionAttentionMode
|
Global branch: |
'simple'
|
graph_mode
|
VisionGraphMode
|
Local branch: |
'GAT'
|
k_neighbors
|
int
|
Hidden-channel neighbors for the dynamic local branch. |
4
|
num_heads
|
int
|
Attention heads for multi-head channel attention. |
4
|
alphas
|
Sequence[float]
|
One damping value per cortex point. |
(0.5, 0.2)
|
max_iter
|
int
|
Solver iterations per cortex point. |
20
|
solver
|
str
|
Fixed-point solver name. |
'picard'
|
backward_mode
|
BackwardMode
|
|
'unrolled'
|
internal_depth
|
int
|
Number of linear/tanh blocks inside each cortex point. |
1
|
self_interaction
|
bool
|
If true, add a learned self-interaction branch. |
False
|
dropout
|
float
|
Dropout probability in the convolutional stem. |
0.3
|
head_hidden_dims
|
Sequence[int]
|
Hidden widths for the classifier head. |
()
|
Inputs
x: Tensor with shape (batch, in_channels, image_size, image_size).
Output
Tensor | SILVACortexOutput: Logits, or structured cortex states and solver results when requested.
Source code in src/silva_networks/presets.py
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 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 | |
SILVAMolecularLayer
Bases: Module
Bond-aware graph SILVA layer for molecular node states.
The local branch is edge-aware graph attention; the global branch is graph mean pooling followed by a learned broadcast, matching the ZINC-style molecular SILVA configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_dim
|
int
|
Atom-state dimension. |
required |
num_heads
|
int
|
Number of local graph-attention heads. |
4
|
dropout
|
float
|
Dropout probability after the update block. |
0.1
|
spectral_norm
|
bool
|
If true, apply spectral normalization to stimulus and global projections. |
True
|
config
|
SolverConfig | None
|
Fixed-point solver configuration. |
None
|
Inputs
x_input: Tensor with shape (atoms, hidden_dim).
edge_index: Tensor with shape (2, bonds).
edge_attr: Tensor with shape (bonds, hidden_dim).
batch: Molecule id tensor with shape (atoms,).
Output
Tensor: Tensor with shape (atoms, hidden_dim) or SolverResult when
return_result=True.
Source code in src/silva_networks/presets.py
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 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 908 909 910 911 912 913 914 915 | |
SILVAMolecularRegressor
Bases: Module
Reference ZINC-style SILVA molecular regressor.
Inputs can be passed either as a PyG-like object with x, edge_index,
edge_attr, and batch attributes, or directly as keyword tensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_dim
|
int | Sequence[int]
|
Atom and bond embedding dimension, or one dimension per molecular equilibrium layer. |
128
|
num_atom_types
|
int
|
Number of categorical atom ids. |
21
|
num_bond_types
|
int
|
Number of categorical bond ids. |
4
|
atom_feature_dim
|
int | None
|
Input width for continuous atom features. When this is
|
None
|
bond_feature_dim
|
int | None
|
Input width for continuous bond features. When this is
|
None
|
num_heads
|
int
|
Number of local graph-attention heads. |
4
|
alphas
|
Sequence[float]
|
Damping values, one per molecular equilibrium layer. |
(0.5, 0.2)
|
max_iter
|
int
|
Solver iterations per layer. |
20
|
solver
|
str
|
Fixed-point solver name. |
'picard'
|
dropout
|
float
|
Dropout probability inside equilibrium layers. |
0.1
|
spectral_norm
|
bool
|
If true, constrain stimulus/global projections with spectral normalization. |
True
|
out_dim
|
int
|
Number of graph-level regression targets. |
1
|
Inputs
x: Atom ids with shape (atoms,) or atom features (atoms, hidden_dim).
edge_index: Bond index tensor with shape (2, bonds).
edge_attr: Bond ids with shape (bonds,) or bond features
(bonds, hidden_dim).
batch: Molecule id tensor with shape (atoms,).
Output
Tensor | SILVANetworkOutput: Graph-level prediction tensor, or SILVANetworkOutput when requested.
Source code in src/silva_networks/presets.py
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 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
SILVAVisionVectorClassifier
Bases: Module
Vector-input vision classifier using one or more SILVA vector layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Flattened input dimension. |
required |
hidden_dim
|
int | Sequence[int]
|
Recurrent hidden-channel count, or one hidden-channel count
per value in |
required |
num_classes
|
int
|
Number of class logits. |
required |
attention_mode
|
VisionAttentionMode
|
Global channel branch mode. |
'simple'
|
graph_mode
|
VisionGraphMode
|
Local channel branch mode. |
'GAT'
|
k_neighbors
|
int
|
Number of hidden-channel neighbors. |
4
|
num_heads
|
int
|
Number of channel-attention heads. |
4
|
alphas
|
Sequence[float]
|
Damping values, one per equilibrium layer. |
(0.25,)
|
max_iter
|
int
|
Solver iterations per layer. |
20
|
solver
|
str
|
Fixed-point solver name. |
'picard'
|
head_hidden_dims
|
Sequence[int]
|
Hidden dimensions for the readout head. |
()
|
dropout
|
float
|
Dropout probability inside the readout head. |
0.0
|
Inputs
x: Tensor with shape (batch, in_dim) or image-like tensor flattened
internally.
Output
Tensor | SILVANetworkOutput: Logit tensor, or SILVANetworkOutput when state/results are requested.
Source code in src/silva_networks/presets.py
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 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 | |
SILVAVisionVectorLayer
Bases: Module
Hidden-channel SILVA equilibrium for flattened vision features.
This layer mirrors the SILVA study's dynamic-channel vision family: local interaction is a state-dependent hidden-channel k-NN average, global interaction is per-sample channel attention, and the update map is a raw sum before the outer damped solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features per sample. |
required |
hidden_dim
|
int
|
Number of recurrent hidden channels. |
64
|
attention_mode
|
VisionAttentionMode
|
Global channel branch: |
'simple'
|
graph_mode
|
VisionGraphMode
|
Local channel branch: |
'GAT'
|
k_neighbors
|
int
|
Number of hidden-channel neighbors. |
4
|
num_heads
|
int
|
Number of attention heads for |
4
|
config
|
SolverConfig | None
|
Fixed-point solver configuration. |
None
|
Inputs
x: Tensor with shape (batch, in_dim).
z0: Optional initial state with shape (batch, hidden_dim).
Output
Tensor: Tensor with shape (batch, hidden_dim) or SolverResult when
return_result=True.
Source code in src/silva_networks/presets.py
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 450 | |
quadratic_interaction_energy
Quadratic Lyapunov-style alignment energy.
For each entity/sample row this computes
E_i = ||z_i||^2 - <z_i, interaction_i>.
It is a diagnostic proxy, not a proof of global Lyapunov stability for an arbitrary nonlinear network.
Source code in src/silva_networks/presets.py
silva_graph_preset
silva_graph_preset(*, hidden_dim=64, attention_mode='simple', graph_mode='GAT', num_heads=4, k_neighbors=16, local_depth=1, layer1_alpha=0.5, layer2_alpha=0.2, max_iter=15, solver='picard', backward_mode='unrolled', backward_solver='gmres', backward_max_iter=50, backward_tol=1e-06)
Return a serializable graph preset matching public defaults.
Source code in src/silva_networks/presets.py
Where to Go Next
| Question | Page |
|---|---|
| How do presets correspond to scientific cases? | Case Atlas |
| Where is a vision preset executed? | Vision Channels Example |
| How can a preset be replaced by a custom architecture? | Architectures API |