src.canns.trainer.bcm¶
BCM (Bienenstock-Cooper-Munro) sliding-threshold plasticity trainer.
Classes¶
BCM (Bienenstock-Cooper-Munro) sliding-threshold plasticity trainer. |
Module Contents¶
- class src.canns.trainer.bcm.BCMTrainer(model, learning_rate=0.01, weight_attr='W', compiled=True, **kwargs)[source]¶
Bases:
src.canns.trainer._base.TrainerBCM (Bienenstock-Cooper-Munro) sliding-threshold plasticity trainer.
The BCM rule uses a dynamic postsynaptic threshold to switch between potentiation and depression based on recent activity, yielding stable receptive-field development and experience-dependent refinement.
- Learning Rule:
ΔW_ij = η * y_i * (y_i - θ_i) * x_j
- where:
W_ij is the weight from input j to neuron i
x_j is the presynaptic activity
y_i is the postsynaptic activity
θ_i is the modification threshold for neuron i
- The threshold θ evolves as a sliding average:
θ_i = <y_i^2>
- This creates two regimes:
If y > θ: potentiation (LTP, strengthen synapses)
If y < θ: depression (LTD, weaken synapses)
- Reference:
Bienenstock, E. L., Cooper, L. N., & Munro, P. W. (1982). Theory for the development of neuron selectivity. Journal of Neuroscience, 2(1), 32-48.
Initialize BCM trainer.
- Parameters:
model (src.canns.models.brain_inspired.BrainInspiredModel) – The model to train (typically LinearLayer with use_bcm_threshold=True)
learning_rate (float) – Learning rate η for weight updates
weight_attr (str) – Name of model attribute holding the connection weights
compiled (bool) – Whether to use JIT-compiled training loop (default: True)
**kwargs – Additional arguments passed to parent Trainer
- predict(pattern, *args, **kwargs)[source]¶
Predict output for a single input pattern.
- Parameters:
pattern – Input pattern of shape (input_size,)
- Returns:
Output pattern of shape (output_size,)
- train(train_data)[source]¶
Train the model using BCM rule.
- Parameters:
train_data (collections.abc.Iterable) – Iterable of input patterns (each of shape (input_size,))