DeconvolutionalLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a deconvolutional layer (also known as transposed convolution) in a neural network.
Inheritance: LayerBase<T> → DeconvolutionalLayer<T>
Implements: IShapeContract
For Beginners
A deconvolutional layer is like zooming in on an image in a smart way.
Think of it like the reverse of a convolutional layer:
- A convolutional layer summarizes information (making images smaller)
- A deconvolutional layer expands information (making images larger)
For example, if you have a small feature map representing “cat features,” a deconvolutional layer could expand it back to a cat-shaped image.
This is particularly useful for:
- Generating images from small encoded representations
- Increasing the resolution of feature maps
- Creating detailed outputs from simplified inputs
Applications include image generation, super-resolution, and segmentation tasks where you need to expand the spatial dimensions of your data.
How It Works
A deconvolutional layer performs the opposite operation of a convolutional layer. While convolution reduces spatial dimensions by applying filters, deconvolution expands spatial dimensions by applying learnable filters to upsample the input. This is particularly useful in generative models and image segmentation networks where upsampling is required.
Constructors
| Constructor | Summary |
|---|---|
DeconvolutionalLayer(int outputDepth, int kernelSize, int stride, int padding, IActivationFunction<T> activationFunction) |
Initializes a new instance of the DeconvolutionalLayer class with the specified parameters and a vector activation function. |
DeconvolutionalLayer(int outputDepth, int kernelSize, int stride, int padding, IVectorActivationFunction<T> vectorActivationFunction) |
Initializes a new instance of the DeconvolutionalLayer class with the specified parameters and a vector activation function. |
Properties
| Property | Summary |
|---|---|
bool HasUninitializedParameters { get; } |
Gets a value indicating whether this layer supports training through backpropagation. |
bool SupportsTraining { get; } |
|
int InputDepth { get; set; } |
Gets the depth (number of channels) of the input data. |
int KernelSize { get; } |
Gets the size of each filter (kernel) used in the deconvolution operation. |
int OutputDepth { get; } |
Gets the depth (number of channels) of the output data. |
int Padding { get; } |
Gets the amount of padding applied during the deconvolution operation. |
int Stride { get; } |
Gets the step size for positioning the kernel across the output data. |
Methods
| Method | Summary |
|---|---|
DeconvolutionalLayer<T> WithInputDepth(int inputDepth, int outputDepth, int kernelSize, int stride, int padding, IActivationFunction<T> activationFunction) |
Creates an allocation-free transposed convolution whose channel dimensions are known at construction time. |
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 ClearGradients() |
|
void ResetState() |
Resets the internal state of the layer. |
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) |
Replaces trainable parameter tensors (e.g., with ParameterBuffer views). |
void UpdateParameters(T learningRate) |
Updates the layer’s parameters (kernel weights and biases) using the calculated gradients. |
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |