BufferAttribute

Attributes · AiDotNet.Attributes

Marks a tensor field as persistent NON-TRAINABLE state: saved with the model, never touched by the optimizer.

Inheritance: Attribute → BufferAttribute

For Beginners

use this for numbers the layer needs to remember but should never learn — running averages, lookup tables, fixed random weights. Use TrainableParameterAttribute for weights the model should learn, and ScratchAttribute for temporary values that do not need saving at all.

How It Works

This is the equivalent of PyTorch’s register_buffer, and it exists for the same reason: some state must survive a save/load round trip without ever receiving a gradient. BatchNormalization’s running mean and variance, ALiBi’s slope table, and an Echo State Network reservoir’s fixed weights are all buffers — a reloaded model that lost them predicts differently, and nothing fails to say so.

A field marked this way is counted by ParameterCount and appears in GetParameters()/SetParameters(), but is excluded from GetTrainableParameters(), which is the set the optimizer and the gradient tape walk. That separation is what makes it impossible to train a buffer by accident.

Constructors

Constructor Summary
BufferAttribute()

Properties

Property Summary
ParameterAvailability Availability { get; set; } Gets or sets when this persistent state is expected to become available.
PersistentTensorRole Role { get; set; } GPU-residency / persistence role.
string Name { get; set; } Name this buffer is stored under.