SnakeLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

The Snake activation (Liu, Hartwig and Ueda 2020): f(x) = x + (1/α) sin²(αx) with a trainable frequency α per channel — a periodic nonlinearity BigVGAN uses to give its generator a periodic inductive bias.

Inheritance: LayerBase<T> → SnakeLayer<T>

Implements: IShapeContract

For Beginners

An activation that wiggles: it is the identity plus a learned sine-squared ripple, which helps a network produce and extend periodic signals such as the harmonics of speech.

How It Works

α starts at 1 and a small constant (1e-9) keeps 1/α finite, as BigVGAN’s Snake does. Channels are axis 1 of an input [batch, channels, time] (or axis 0 of [channels, time]).

Constructors

Constructor Summary
SnakeLayer(int channels) Creates the layer.

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].
void ResetState()
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) Replaces trainable parameter tensors (e.g., with ParameterBuffer views).
void ZeroGrad() Clears all gradient fields discovered by convention ({paramName}Gradient).