ResNetConfiguration
Options & Configuration · AiDotNet.Configuration
Configuration options for ResNet (Residual Network) neural network architectures.
For Beginners
ResNet networks are deep convolutional neural networks that use skip connections to enable training of very deep architectures. This configuration lets you choose which ResNet variant to use (ResNet18, ResNet34, ResNet50, ResNet101, or ResNet152), set the number of output classes for your classification task, and optionally customize the input image dimensions and other parameters.
How It Works
This configuration class provides all the settings needed to instantiate a ResNet network. It follows the AiDotNet pattern where users provide minimal configuration and the library supplies sensible defaults.
Typical Usage:
Constructors
| Constructor | Summary |
|---|---|
ResNetConfiguration(ResNetVariant variant, int numClasses, int inputHeight, int inputWidth, int inputChannels, bool includeClassifier, bool zeroInitResidual) |
Initializes a new instance of the ResNetConfiguration class. |
Properties
| Property | Summary |
|---|---|
ResNetVariant Variant { get; } |
Gets the ResNet variant to use. |
bool IncludeClassifier { get; } |
Gets whether to include the fully connected classifier layer. |
bool UseAutodiff { get; set; } |
Gets or sets whether to use automatic differentiation for backpropagation. |
bool UsesBottleneck { get; } |
Gets whether this variant uses BasicBlock (ResNet18/34) or BottleneckBlock (ResNet50/101/152). |
bool ZeroInitResidual { get; } |
Gets whether to use zero-initialization for the last batch normalization in each residual block. |
int Expansion { get; } |
Gets the expansion factor for the blocks. |
int InputChannels { get; } |
Gets the number of input channels. |
int InputHeight { get; } |
Gets the height of input images in pixels. |
int InputWidth { get; } |
Gets the width of input images in pixels. |
int NumClasses { get; } |
Gets the number of output classes for classification. |
int NumConvLayers { get; } |
Gets the total number of convolutional layers in the network. |
int NumWeightLayers { get; } |
Gets the total number of weight layers (conv + FC). |
int TotalInputSize { get; } |
Gets the total number of input features (channels * height * width). |
int[] BaseChannels { get; } |
Gets the base channel counts for each stage. |
int[] BlockCounts { get; } |
Gets the block counts for each of the 4 stages based on the variant. |
int[] InputShape { get; } |
Gets the computed input shape as [channels, height, width]. |
Methods
| Method | Summary |
|---|---|
ResNetConfiguration CreateForCIFAR(ResNetVariant variant, int numClasses) |
Creates a configuration optimized for CIFAR-10/CIFAR-100 datasets. |
ResNetConfiguration CreateLightweight(int numClasses) |
Creates a lightweight configuration using ResNet18. |
ResNetConfiguration CreateResNet50(int numClasses) |
Creates a new configuration for ResNet50. |