Conv1DTransposeLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
1D transposed convolution (“deconvolution”) for sequence / waveform data —
the learnable temporal-upsampling primitive used by HiFi-GAN (Kong et al.
2020) and the GAN-vocoder family. Operates on rank-3 input
[B, C_in, T] and produces rank-3 output [B, C_out, T_out]
where, matching PyTorch nn.ConvTranspose1d exactly:
Inheritance: LayerBase<T> → Conv1DTransposeLayer<T>
Implements: IShapeContract
How It Works
PyTorch parity: the weight layout is [C_in, C_out, kernelSize] (the
transposed-convolution convention — input channels first, opposite of the
forward Conv1DLayer’s [C_out, C_in, K]), and the
T_out formula above is bit-identical to nn.ConvTranspose1d.
Implemented by delegating to Engine.ConvTranspose2D with the time axis
expanded to a degenerate 2D layout — input [B, C, T] is reshaped to
[B, C, 1, T], kernel shape is [C_in, C_out, 1, kernelSize],
stride is (1, stride), padding (0, padding), output padding
(0, outputPadding). This reuses the engine’s transposed-conv kernel
(including the fused GPU path) and keeps the tape autodiff backward identical
to DeconvolutionalLayer — no hand-written backward needed.
We exceed the stock PyTorch op by routing through the engine’s fused
conv-transpose + bias (+ activation) kernel when available.
Shaped for HiFi-GAN-style generators: each upsample stage is a
ConvTranspose1d(ch, ch/2, kernel=2*rate, stride=rate, padding=rate/2)
matching the official jik876/hifi-gan generator
(upsample_rates=[8,8,2,2], upsample_kernel_sizes=[16,16,4,4]).
Constructors
| Constructor | Summary |
|---|---|
Conv1DTransposeLayer(int inputChannels, int outputChannels, int kernelSize, int stride, int? padding, int outputPadding, int dilation, IActivationFunction<T> activation, IInitializationStrategy<T> initializationStrategy) |
Eager-init constructor — pre-allocates kernel/bias at construction when the input channel count is known up-front (the HiFi-GAN generator stack has fixed per-stage channel counts), so ParameterCount and GetParameters agree before the fi… |
Conv1DTransposeLayer(int outputChannels, int kernelSize, int stride, int? padding, int outputPadding, int dilation, IActivationFunction<T> activation, IInitializationStrategy<T> initializationStrategy) |
Lazy-input-channel constructor (mirrors PyTorch’s lazy conv semantics). |
Properties
| Property | Summary |
|---|---|
bool HasUninitializedParameters { get; } |
|
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) |
|
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). |