SubpixelConvolutionalLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a subpixel convolutional layer that performs convolution followed by pixel shuffling for upsampling.
Inheritance: LayerBase<T> → SubpixelConvolutionalLayer<T>
Implements: IShapeContract
For Beginners
This layer helps make images larger and more detailed in neural networks.
Think of it like rearranging a small mosaic to create a larger picture:
- First, the layer creates many detailed patterns from the input (convolution step)
- Then, it rearranges these patterns to form a larger, higher-resolution output (pixel shuffling step)
For example, if you’re working with a low-resolution image that’s 32×32 pixels, this layer can help transform it into a higher-resolution image of 64×64 or 128×128 pixels by intelligently filling in the details between the original pixels.
This is often used in applications like:
- Making blurry images clearer (super-resolution)
- Generating detailed images from rough sketches
- Converting low-quality videos to higher quality
How It Works
A subpixel convolutional layer combines convolution with a pixel shuffling operation to efficiently increase spatial resolution of feature maps. It first applies convolution to produce an output with more channels, then rearranges these channels into a higher resolution output with fewer channels. This approach is particularly useful for super-resolution tasks and generative models where upsampling is required.
Constructors
| Constructor | Summary |
|---|---|
SubpixelConvolutionalLayer(int outputDepth, int upscaleFactor, int kernelSize, IActivationFunction<T> activation) |
Initializes a new instance of the SubpixelConvolutionalLayer class with vector activation function. |
SubpixelConvolutionalLayer(int outputDepth, int upscaleFactor, int kernelSize, IVectorActivationFunction<T> vectorActivation) |
Initializes a new instance of the SubpixelConvolutionalLayer class with vector activation function. |
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) |
|
IReadOnlyList<Tensor<T>> GetTrainableParameters() |
Returns all trainable parameter tensors marked with [TrainableParameter]. |
IReadOnlyList<ValueTuple<string, Tensor<T>>> GetRegisteredBuffers() |
|
void ClearGradients() |
|
void ResetState() |
Resets the internal state of the layer and reinitializes weights. |
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) |
Replaces trainable parameter tensors (e.g., with ParameterBuffer views). |
void UpdateParameters(T learningRate) |
Updates the parameters of the layer using calculated gradients and momentum. |
void UpdateParametersGpu(IGpuOptimizerConfig config) |
Updates parameters using GPU-based optimizer. |
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |