StopGradientLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

Passes its input through unchanged in the forward direction while blocking gradient flow backwards — the layer form of a stop-gradient / detach barrier.

Inheritance: LayerBase<T> → StopGradientLayer<T>

Implements: IShapeContract

How It Works

Useful wherever an architecture deliberately trains two components as independent functional units inside a single sequential stack. The canonical example is ABINet’s Autonomous principle (Fang et al., CVPR 2021, arXiv:2103.06495), which blocks gradient flow between the vision model and the language model so the language model is forced to learn explicit language modelling rather than becoming an extension of the visual features. The paper measures roughly 0.9% worse accuracy when that gradient is allowed to flow.

Forward is the identity, so inference is completely unaffected; only the backward pass changes. Implemented with Engine.StopGradient so the tape records the barrier itself rather than the layer silently detaching outside the graph.

Constructors

Constructor Summary
StopGradientLayer() Initializes a new stop-gradient barrier.

Properties

Property Summary
bool SupportsTraining { get; }

Methods

Method Summary
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) Derived from this type’s [TensorLayout] declarations.
void ResetState()