EfficientNetNetwork<T>

Models & Types · AiDotNet.NeuralNetworks

Implements the EfficientNet architecture with compound scaling.

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

For Beginners

EfficientNet achieves excellent accuracy while being very efficient.

Key innovations:

  • Compound Scaling: Balances network width, depth, and resolution together
  • MBConv blocks: Mobile Inverted Bottleneck with Squeeze-and-Excitation
  • Swish activation: Smooth, self-gated activation function (x * sigmoid(x))
  • Neural Architecture Search (NAS): The baseline B0 was found via automated search

The scaling philosophy: increasing only one dimension (width/depth/resolution) quickly saturates accuracy. Compound scaling increases all three proportionally.

How It Works

EfficientNet (Tan & Le, 2019) introduced compound scaling, which uniformly scales network width, depth, and resolution using a principled approach. This achieves state-of-the-art accuracy with significantly fewer parameters than previous models.

Architecture overview (EfficientNet-B0 baseline):

Where k=kernel size, c=output channels, n=num layers, s=stride.

Constructors

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

Properties

Property Summary
EfficientNetVariant Variant { get; } Gets the EfficientNet variant.
int InputResolution { get; } Gets the input resolution for this variant.
int NumClasses { get; } Gets the number of output classes.

Methods

Method Summary
Dictionary<string, Tensor<T>> GetNamedLayerActivations(Tensor<T> input) EfficientNet’s stem-and-blocks pipeline expects rank-4 [B, C, H, W] per Tan & Le 2019 §3 — same constraint as Train’s EnsureBatchForCnnTraining promotion.
EfficientNetNetwork<T> EfficientNetB0(int numClasses, int inputChannels) Creates an EfficientNet-B0 network (baseline model).
EfficientNetNetwork<T> EfficientNetB1(int numClasses, int inputChannels) Creates an EfficientNet-B1 network.
EfficientNetNetwork<T> EfficientNetB2(int numClasses, int inputChannels) Creates an EfficientNet-B2 network.
EfficientNetNetwork<T> EfficientNetB3(int numClasses, int inputChannels) Creates an EfficientNet-B3 network.
EfficientNetNetwork<T> EfficientNetB4(int numClasses, int inputChannels) Creates an EfficientNet-B4 network.
EfficientNetNetwork<T> EfficientNetB5(int numClasses, int inputChannels) Creates an EfficientNet-B5 network.
EfficientNetNetwork<T> EfficientNetB6(int numClasses, int inputChannels) Creates an EfficientNet-B6 network.
EfficientNetNetwork<T> EfficientNetB7(int numClasses, int inputChannels) Creates an EfficientNet-B7 network.
EfficientNetNetwork<T> ForTesting(int numClasses, int inputChannels) Creates a minimal EfficientNet network optimized for fast test execution.
ILayer<T> GetLayer(int index) Deserializes and validates network-specific configuration data.
ModelMetadata<T> GetModelMetadata()
Tensor<T> Forward(Tensor<T> input) The class probabilities of an image [C, H, W] or a batch [B, C, H, W]: the trunk, global average pooling, dropout (training only) and the classifier.
Tensor<T> ForwardForTraining(Tensor<T> input)