ICreditRule<T>
Interfaces · AiDotNet.Interfaces
A pluggable credit-assignment (a.k.a. “learning”) rule that decides how the per-parameter updates are produced during neural-network training. The default rule is standard back-propagation; alternative published rules — Feedback Alignment, Direct Feedback Alignment, Sign-Symmetric, and any custom rule you implement — replace how the error signal is routed to each layer while reusing the same forward pass, optimizer, batching, scheduler and observability.
Known implementations: IFeedbackLearningRule<T>, ILocalObjectiveCreditRule<T>
For Beginners
imagine every layer needs to be told “here’s how wrong your output was” so it can adjust. Back-prop computes that message exactly by chaining backwards through all later layers. Direct Feedback Alignment instead hands each layer a fixed random shortcut of the final error — and the network still learns, because the forward weights rotate to align with the random feedback. This interface is where you define how that per-layer “how wrong were you” message is produced.
How It Works
What a rule does. Back-propagation sends the output error backward through the exact transpose of every weight. A credit rule instead decides, for every trainable layer, a teaching signal at that layer’s output — the error the layer should be trained against. The training engine then converts each teaching signal into that layer’s parameter gradients via a local vector-Jacobian product (one backward step through only that layer). Because the engine handles the local gradient mechanics, a rule can be applied to any layer type — dense, multi-head attention, feed-forward, LayerNorm, embedding — which is exactly why Direct Feedback Alignment scales to Transformers (Nøkland 2016; Launay et al. 2020).
Contract. Given an ICreditAssignmentContext (the ordered trainable layers, their output
shapes, and the network output error), a rule fills in TeachingSignal for every
hidden trainable layer. The final (output) layer is trained with the exact loss gradient by the engine,
so a rule may leave its teaching signal unset. A rule may hold internal state (e.g. fixed random feedback
matrices) across steps; allocate it in Initialize.
Properties
| Property | Summary |
|---|---|
bool IsExactBackprop { get; } |
True only for the reference back-propagation rule. |
string Name { get; } |
A short human-readable identifier for this rule (used in diagnostics), e.g. |
Methods
| Method | Summary |
|---|---|
void ComputeTeachingSignals(ICreditAssignmentContext<T> context) |
Produces the teaching signals for one training step by writing TeachingSignal on every hidden trainable layer of context (the output layer is handled by the engine’s exact loss gradient). |
void Initialize(ICreditAssignmentContext<T> context) |
Called once, before the first update, so the rule can allocate any fixed internal state sized to the concrete network (for example the per-layer random feedback matrices used by Feedback Alignment and Direct Feedback Alignment). |