SynapticPlasticityLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a synaptic plasticity layer that models biological learning mechanisms through spike-timing-dependent plasticity.
Inheritance: LayerBase<T> → SynapticPlasticityLayer<T>
Implements: IShapeContract
For Beginners
This layer mimics how brain cells (neurons) learn by strengthening or weakening their connections.
Think of it like forming memories:
- When two connected neurons activate in sequence (one fires, then the other), their connection gets stronger
- When they activate in the opposite order, their connection gets weaker
- Over time, pathways that represent useful patterns become stronger
For example, imagine learning to associate a bell sound with food (like Pavlov’s dog experiment):
- Initially, there’s a weak connection between “hear bell” neurons and “expect food” neurons
- When the bell regularly comes before food, the connection strengthens
- Eventually, just the bell alone strongly activates the “expect food” response
This mimics how real brains learn patterns and form associations between related events.
How It Works
A synaptic plasticity layer implements biologically-inspired learning rules that modify connection strengths based on the relative timing of pre- and post-synaptic neuron activations. This implements spike-timing-dependent plasticity (STDP), a form of Hebbian learning observed in biological neural systems. The layer maintains traces of neuronal activity and applies long-term potentiation (LTP) and long-term depression (LTD) based on the temporal relationship between spikes.
Constructors
| Constructor | Summary |
|---|---|
SynapticPlasticityLayer(int size, double stdpLtpRate, double stdpLtdRate, double homeostasisRate, double minWeight, double maxWeight, double traceDecay) |
Initializes a new instance of the SynapticPlasticityLayer class. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
Methods
| Method | Summary |
|---|---|
Dictionary<string, string> GetParameterRoles() |
Returns parameter roles for per-role optimizer configuration (e.g., weight decay exemption for biases). |
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
Derived from this type’s [TensorLayout] declarations. |
IReadOnlyList<Tensor<T>> GetTrainableParameters() |
Returns all trainable parameter tensors marked with [TrainableParameter]. |
IReadOnlyList<ValueTuple<string, Tensor<T>>> GetRegisteredBuffers() |
|
void ResetState() |
Resets the internal state of the layer. |
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) |
Replaces trainable parameter tensors (e.g., with ParameterBuffer views). |
void UpdateParameters(T learningRate) |
|
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |