ConditionalLayerNormalizationLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Layer normalization whose scale and bias are computed from a conditioning vector instead of being free parameters:
CLN(x, e) = (e W_γ) ⊙ (x − μ) / σ + e W_β.
Inheritance: LayerBase<T> → ConditionalLayerNormalizationLayer<T>
Implements: IShapeContract
For Beginners
Ordinary layer normalization rescales each feature vector with a learned scale and shift. Here the scale and shift depend on who is speaking, so changing the speaker re-tunes every normalization in the decoder without touching any other weight.
How It Works
AdaSpeech (Chen et al. 2021, §2.2, Eq. 1) replaces every layer normalization in the mel decoder with this layer,
conditioned on the speaker embedding E_s: “the conditional network consists of two simple linear layers
W_γ and W_β that take speaker embedding E_s as input and output the scale and bias vector respectively”,
γ = E_s W_γ, β = E_s W_β. Adapting a voice then fine-tunes only these two matrices (and the speaker
embedding), and a deployed voice needs only the resulting γ and β.
Inputs: x is [time, hidden] with a condition [condition] (or [1, condition]), or
[batch, time, hidden] with a condition [batch, condition]. Normalization is over the last axis.
Constructors
| Constructor | Summary |
|---|---|
ConditionalLayerNormalizationLayer(int hiddenSize, int conditionSize, double epsilon) |
Creates a conditional layer normalization. |
Properties
| Property | Summary |
|---|---|
BiasFreeLinearLayer<T> BiasProjection { get; } |
The bias projection W_β. |
BiasFreeLinearLayer<T> ScaleProjection { get; } |
The scale projection W_γ. |
bool RequiresMultipleInputs { get; } |
|
bool SupportsTraining { get; } |
|
int ConditionSize { get; } |
Width of the conditioning vector. |
int HiddenSize { get; } |
Width of the normalized features. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<ILayer<T>> GetSubLayers() |
|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
Derived from this type’s [TensorLayout] declarations. |
Tensor<T> Forward(Tensor<T> input, Tensor<T> condition) |
Normalizes input with the scale and bias computed from condition. |
void ResetState() |