Class ResNet<T>
- Namespace
- AiDotNet.ComputerVision.Detection.Backbones
- Assembly
- AiDotNet.dll
ResNet backbone network for feature extraction.
public class ResNet<T> : BackboneBase<T>
Type Parameters
TThe numeric type used for calculations.
- Inheritance
-
BackboneBase<T>ResNet<T>
- Inherited Members
Remarks
For Beginners: ResNet (Residual Network) is a foundational architecture that introduced skip connections to enable training of very deep networks. It's widely used as a backbone for detection models like Faster R-CNN.
Key features: - Residual blocks with skip connections prevent gradient vanishing - Multiple variants: ResNet-18, 34, 50, 101, 152 - Bottleneck blocks (3 convolutions) for deeper networks
Reference: He et al., "Deep Residual Learning for Image Recognition", CVPR 2016
Constructors
ResNet(ResNetVariant, int)
Creates a new ResNet backbone.
public ResNet(ResNetVariant variant = ResNetVariant.ResNet50, int inChannels = 3)
Parameters
variantResNetVariantResNet variant (18, 34, 50, 101, or 152).
inChannelsintNumber of input channels (default 3 for RGB).
Properties
Name
Name of this backbone architecture.
public override string Name { get; }
Property Value
OutputChannels
Number of output channels for each feature level.
public override int[] OutputChannels { get; }
Property Value
- int[]
Remarks
Modern detectors use multi-scale features. This array contains the number of channels at each scale, typically from high resolution (small objects) to low resolution (large objects).
Strides
The stride (downsampling factor) at each feature level.
public override int[] Strides { get; }
Property Value
- int[]
Remarks
A stride of 8 means the feature map is 1/8 the size of the input. Common strides are [8, 16, 32] for 3-level feature pyramids.
Methods
ExtractFeatures(Tensor<T>)
Extracts multi-scale features from an input image tensor.
public override List<Tensor<T>> ExtractFeatures(Tensor<T> input)
Parameters
inputTensor<T>Input image tensor with shape [batch, channels, height, width].
Returns
- List<Tensor<T>>
List of feature maps at different scales, from highest to lowest resolution.
Remarks
For Beginners: This method runs the input image through the backbone and returns feature maps at multiple scales. Small objects need high-resolution features, while large objects are detected in low-resolution features.
GetParameterCount()
Gets the total number of parameters in the backbone.
public override long GetParameterCount()
Returns
- long
Number of trainable parameters.
ReadParameters(BinaryReader)
Reads parameters from a binary reader for deserialization.
public override void ReadParameters(BinaryReader reader)
Parameters
readerBinaryReaderThe binary reader to read from.
WriteParameters(BinaryWriter)
Writes all parameters to a binary writer for serialization.
public override void WriteParameters(BinaryWriter writer)
Parameters
writerBinaryWriterThe binary writer to write to.