src.canns.models.brain_inspired.linear¶
Generic linear layer for brain-inspired learning algorithms.
Classes¶
Generic linear feedforward layer supporting multiple brain-inspired learning rules. |
Module Contents¶
- class src.canns.models.brain_inspired.linear.LinearLayer(input_size, output_size, use_bcm_threshold=False, threshold_tau=100.0, **kwargs)[source]¶
Bases:
src.canns.models.brain_inspired._base.BrainInspiredModelGeneric linear feedforward layer supporting multiple brain-inspired learning rules.
This model provides a simple linear transformation with optional sliding threshold for BCM-style plasticity. It can be used with various trainers: - OjaTrainer: Normalized Hebbian learning for PCA - BCMTrainer: Sliding threshold plasticity (requires use_bcm_threshold=True) - HebbianTrainer: Standard Hebbian learning
- Computation:
y = W @ x
where W is the weight matrix, x is the input, and y is the output.
- For BCM learning, an optional sliding threshold θ tracks output activity:
θ ← θ + (1/τ) * (y² - θ)
References
Oja (1982): Simplified neuron model as a principal component analyzer
Bienenstock et al. (1982): Theory for the development of neuron selectivity
Initialize the linear layer.
- Parameters:
input_size (int) – Dimensionality of input vectors
output_size (int) – Number of output neurons (features to extract)
use_bcm_threshold (bool) – Whether to maintain sliding threshold for BCM learning
threshold_tau (float) – Time constant for threshold sliding average (only used if use_bcm_threshold=True)
**kwargs – Additional arguments passed to parent class
- forward(x)[source]¶
Forward pass through the layer.
- Parameters:
x (jax.numpy.ndarray) – Input vector of shape (input_size,)
- Returns:
Output vector of shape (output_size,)
- Return type:
jax.numpy.ndarray