DepthwiseSeparableConvolutionalLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a depthwise separable convolutional layer that performs convolution as two separate operations.
Inheritance: LayerBase<T> → DepthwiseSeparableConvolutionalLayer<T>
Implements: IShapeContract
For Beginners
A depthwise separable convolution is like a more efficient way to filter an image.
Think of it as a two-step process:
- First step (depthwise): Apply separate filters to each input channel (like filtering red, green, and blue separately)
- Second step (pointwise): Mix these filtered channels together (like combining the filtered colors)
For example, in image processing:
- Standard convolution might use 100,000 calculations for a single operation
- Depthwise separable convolution might do the same job with only 10,000 calculations
This makes your neural network faster and smaller while still capturing important patterns. It’s commonly used in mobile and edge devices where efficiency is critical.
How It Works
A depthwise separable convolutional layer splits the standard convolution operation into two parts: a depthwise convolution, which applies a single filter per input channel, and a pointwise convolution, which uses 1×1 convolutions to combine the outputs. This approach dramatically reduces the number of parameters and computational cost compared to standard convolution.
Constructors
| Constructor | Summary |
|---|---|
DepthwiseSeparableConvolutionalLayer(int outputDepth, int kernelSize, int stride, int padding, IActivationFunction<T> activation) |
Initializes a new instance of the DepthwiseSeparableConvolutionalLayer class with the specified parameters and a vector activation function. |
DepthwiseSeparableConvolutionalLayer(int outputDepth, int kernelSize, int stride, int padding, IVectorActivationFunction<T> vectorActivation) |
Initializes a new instance of the DepthwiseSeparableConvolutionalLayer class with the specified parameters and 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]. |
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 UpdateParametersGpu(IGpuOptimizerConfig config) |
Updates parameters on GPU using the configured optimizer. |
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |