pub enum Layer {
Show 17 variants
Input {
dimensions: usize,
},
Signal(Vec<Arc<dyn Operator>>),
Embed(Vec<f64>),
Dense {
weights: Vec<f64>,
bias: Vec<f64>,
output_channels: usize,
input_channels: usize,
},
Flatten,
GlobalPool(GlobalPoolMethod),
Softmax,
BatchNorm {
epsilon: f64,
},
Dropout {
p: f64,
},
CNN1D {
weights: Vec<f64>,
bias: Vec<f64>,
output_channels: usize,
input_channels: usize,
kernel_size: usize,
stride: usize,
padding: usize,
},
CNN2D {
weights: Vec<f64>,
bias: Vec<f64>,
output_channels: usize,
input_channels: usize,
input_height: usize,
input_width: usize,
kernel_height: usize,
kernel_width: usize,
stride_height: usize,
stride_width: usize,
padding_height: usize,
padding_width: usize,
},
Propagate {
edge_label: String,
aggregation: AggregationKind,
direction: Direction,
},
Conv {
edge_label: String,
hop_weights: Vec<f64>,
direction: Direction,
},
Pool {
edge_label: String,
pool_size: usize,
method: PoolMethod,
direction: Direction,
},
Attention,
RNN {
weights_input: Vec<f64>,
weights_hidden: Vec<f64>,
bias: Vec<f64>,
hidden_channels: usize,
input_channels: usize,
return_sequences: bool,
},
LSTM {
weights_input: Vec<f64>,
weights_hidden: Vec<f64>,
bias: Vec<f64>,
hidden_channels: usize,
input_channels: usize,
return_sequences: bool,
},
}Variants§
Input
Runtime-provided feature vector. This layer is a no-op during execution; it marks the expected input dimension for trained models that receive feature batches from an ML backend.
Signal(Vec<Arc<dyn Operator>>)
Run a list of Operator signals, fuse them via log-odds
conjunction at the configured alpha, then add the resulting
logit to channel 0 as a residual connection.
Embed(Vec<f64>)
Initialize the channel map from a raw embedding vector. Element
i becomes node i+1 with a single-channel value.
Dense
Fully connected: out = W @ input + bias, then gating.
Fields
Flatten
Concatenate every node’s channel vector into a single vector.
GlobalPool(GlobalPoolMethod)
Reduce all spatial nodes to one vector.
Softmax
Numerically stable softmax per node.
BatchNorm
Per-channel batch normalization across all nodes.
Dropout
Inference-mode dropout: scale every value by 1 - p.
CNN1D
One-dimensional CNN over sorted sequence positions.
Weights are row-major as output_channels x kernel_size x input_channels.
Fields
CNN2D
Two-dimensional CNN over flattened H x W x C spatial positions.
Weights are row-major as
output_channels x kernel_height x kernel_width x input_channels.
Fields
Propagate
Propagate channel-0 scores through graph edges.
aggregation averages / sums / maxes the in-bounds neighbor
probabilities; the resulting logit is added as a residual on
channel 0. Requires ExecutionContext::graph.
Fields
aggregation: AggregationKindConv
Weighted multi-hop graph convolution on channel 0.
hop_weights[0] is the self weight, hop_weights[i] weights
the average over the hop-i neighbor ring. Weights are
L1-normalized; the result is converted back to logit and added
as a residual.
Fields
Pool
Spatial downsampling via greedy BFS partitioning.
Groups pool_size neighboring nodes via BFS, aggregates their
channel vectors element-wise (PoolMethod::{Avg, Max}), and
keeps the smallest doc id as the representative.
Fields
method: PoolMethodAttention
Self-attention across the per-node channel vectors with
Q = K = V = X, scaled-dot-product, no learned projections.
RNN
Vanilla RNN over sorted sequence positions.
Weights are row-major as hidden_channels x input_channels and
hidden_channels x hidden_channels.
LSTM
LSTM over sorted sequence positions.
Gate order is input, forget, candidate, output. Both weight
matrices are row-major with 4 * hidden_channels rows.