SeparableConvolutionalLayer<T>
Layers ยท AiDotNet.NeuralNetworks.Layers
Represents a separable convolutional layer that decomposes standard convolution into depthwise and pointwise operations.
Inheritance: LayerBase<T> โ SeparableConvolutionalLayer<T>
Implements: IShapeContract
For Beginners
This layer processes images or other grid-like data more efficiently than standard convolution.
Think of it like a two-step process:
- First step (depthwise): Applies filters to each input channel separately to extract features
- Second step (pointwise): Combines these features across all channels to create new feature maps
Benefits include:
- Fewer calculations needed (faster processing)
- Fewer parameters to learn (uses less memory)
- Often similar performance to standard convolution
For example, in image processing, the depthwise convolution might detect edges in each color channel separately, while the pointwise convolution would combine these edges into more complex features like shapes or textures.
How It Works
A separable convolutional layer splits the standard convolution operation into two simpler operations: a depthwise convolution followed by a pointwise convolution. This factorization significantly reduces computational complexity and number of parameters while maintaining similar model expressiveness.
Constructors
| Constructor | Summary |
|---|---|
SeparableConvolutionalLayer(int outputDepth, int kernelSize, int stride, int padding, IActivationFunction<T> scalarActivation) |
Initializes a new instance of the SeparableConvolutionalLayer class with a vector activation function. |
SeparableConvolutionalLayer(int outputDepth, int kernelSize, int stride, int padding, IVectorActivationFunction<T> vectorActivation) |
Initializes a new instance of the SeparableConvolutionalLayer class with a vector activation function. |
Properties
| Property | Summary |
|---|---|
bool SupportsGpuTraining { get; } |
Gets a value indicating whether this layer supports GPU-resident training. |
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 separable convolutional layer. |
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 the calculated gradients and momentum. |
void UpdateParametersGpu(IGpuOptimizerConfig config) |
Updates parameters on GPU using the configured optimizer. |
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |