MobileNetV2Network<T>

Models & Types · AiDotNet.NeuralNetworks

Implements the MobileNetV2 architecture for efficient mobile inference.

Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → ImageClassifierModelLayoutBase<T> → MobileNetV2Network<T>

For Beginners

MobileNetV2 is designed to be efficient on mobile devices.

Key innovations:

  • Inverted Residuals: Expand → Depthwise Conv → Project (opposite of traditional bottlenecks)
  • Linear Bottlenecks: No activation after the projection layer (preserves information)
  • ReLU6: Activation capped at 6 for better quantization on mobile devices
  • Depthwise Separable Convolutions: Much fewer parameters than standard convolutions

How It Works

MobileNetV2 (Sandler et al., 2018) introduced the inverted residual structure with linear bottlenecks, making it highly efficient for mobile and embedded vision applications.

Architecture overview:

Where t=expansion, c=output channels, n=repeat count, s=stride.

Constructors

Constructor Summary
MobileNetV2Network() Initializes a new instance of the MobileNetV2Network class.
MobileNetV2Network(NeuralNetworkArchitecture<T> architecture, MobileNetV2Configuration configuration, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, MobileNetV2Options options)

Properties

Property Summary
MobileNetV2WidthMultiplier WidthMultiplier { get; } Gets the width multiplier used by this network.
int NumClasses { get; } Gets the number of output classes.

Methods

Method Summary
Dictionary<string, Tensor<T>> GetNamedLayerActivations(Tensor<T> input)
ILayer<T> GetLayer(int index) Deserializes and validates network-specific configuration data.
MobileNetV2Network<T> MobileNetV2_035(int numClasses, int inputChannels) Initializes a new MobileNetV2 with width multiplier 0.35 (smallest).
MobileNetV2Network<T> MobileNetV2_050(int numClasses, int inputChannels) Initializes a new MobileNetV2 with width multiplier 0.5.
MobileNetV2Network<T> MobileNetV2_075(int numClasses, int inputChannels) Initializes a new MobileNetV2 with width multiplier 0.75.
MobileNetV2Network<T> MobileNetV2_100(int numClasses, int inputChannels) Initializes a new MobileNetV2 with width multiplier 1.0.
MobileNetV2Network<T> MobileNetV2_130(int numClasses, int inputChannels) Initializes a new MobileNetV2 with width multiplier 1.3.
MobileNetV2Network<T> MobileNetV2_140(int numClasses, int inputChannels) Initializes a new MobileNetV2 with width multiplier 1.4 (largest).
ModelMetadata<T> GetModelMetadata()
Tensor<T> Forward(Tensor<T> input) Performs a forward pass through the network.