GradientNormEvent

Models & Types · AiDotNet.Configuration

Emitted per parameter tensor after tape.ComputeGradients returns, before the optimizer step runs. Captures the L2 norm of the gradient flowing back into that tensor. The fingerprint of gradient-flow bugs (issue #1328) is: head-side params show non-zero norm but embedding / attention QKV / output-projection norms are zero or near-zero.

Inheritance: TrainingDiagnosticEvent → GradientNormEvent

Implements: IEquatable<GradientNormEvent>

Constructors

Constructor Summary
GradientNormEvent(int StepIndex, int ParamIndex, int[] ParamShape, long ParamLength, bool HasGradient, double GradientL2Norm, LayerCategory LayerCategory, string LayerTypeName)

Properties

Property Summary
LayerCategory LayerCategory { get; } Type-safe categorization of the owning layer.
bool HasGradient { get; } True when the gradient tape produced a gradient for this parameter.
double GradientL2Norm { get; } L2 norm of the gradient at emission time; 0 when HasGradient is false.
int ParamIndex { get; } Position of this parameter in the network’s enumerated trainable-tensor list.
int StepIndex { get; } Sequence number of the training step that emitted this event.
int[] ParamShape { get; } Defensive snapshot of the parameter tensor’s shape at emission time.
long ParamLength { get; } Total scalar element count of the parameter tensor.
string LayerTypeName { get; } Concrete layer-class name for diagnostic readability.

Methods

Method Summary
GradientNormEvent <Clone>$()
bool Equals(GradientNormEvent other)
bool Equals(TrainingDiagnosticEvent other)
bool Equals(object obj)
bool op_Equality(GradientNormEvent left, GradientNormEvent right)
bool op_Inequality(GradientNormEvent left, GradientNormEvent right)
int GetHashCode()
string ToString()