MobileNetV3Network<T>

Models & Types · AiDotNet.NeuralNetworks

Implements the MobileNetV3 architecture for efficient mobile inference.

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

For Beginners

MobileNetV3 is the latest in the MobileNet family, optimized for both accuracy and latency on mobile devices.

Key innovations over V2:

  • Hard-Swish: A faster activation function that works better with quantization
  • SE blocks: Helps the network learn which channels are most important
  • Network search: The architecture was found using neural architecture search (NAS)
  • Two variants: “Large” for higher accuracy, “Small” for extreme efficiency

How It Works

MobileNetV3 (Howard et al., 2019) builds on MobileNetV2 with three key improvements:

  1. Hard-Swish activation: x * min(max(0, x+3), 6) / 6 - computationally efficient
  2. Squeeze-and-Excitation blocks: Adaptive channel weighting
  3. Efficient network head: Reduced computational cost in final layers

Example

var input = Tensor<float>.CreateRandom(new[] { 1, 3, 224, 224 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new MobileNetV3Network<float>())
    .Build(trainX, trainY);
var output = result.Predict(input);

Constructors

Constructor Summary
MobileNetV3Network() Initializes a new instance with default settings.
MobileNetV3Network(NeuralNetworkArchitecture<T> architecture, MobileNetV3Configuration configuration, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, MobileNetV3Options options) Initializes a new instance of the MobileNetV3Network class.

Properties

Property Summary
MobileNetV3Variant Variant { get; } Gets the MobileNetV3 variant used by this network.
int NumClasses { get; } Gets the number of output classes.

Methods

Method Summary
ILayer<T> GetLayer(int index) Gets the layer at the specified index.
MobileNetV3Network<T> MobileNetV3Large(int numClasses, int inputChannels) Creates a MobileNetV3-Large network.
MobileNetV3Network<T> MobileNetV3Small(int numClasses, int inputChannels) Creates a MobileNetV3-Small network.
ModelMetadata<T> GetModelMetadata()
Tensor<T> Forward(Tensor<T> input) Performs a forward pass through the network.