Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:NVIDIA DALI EfficientNet Backbone

From Leeroopedia
Revision as of 15:54, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/NVIDIA_DALI_EfficientNet_Backbone.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Object_Detection, TensorFlow
Last Updated 2026-02-08 16:00 GMT

Overview

Implements the EfficientNet convolutional neural network backbone architecture in TensorFlow/Keras, including Mobile Inverted Bottleneck (MBConv) blocks with squeeze-and-excitation.

Description

This module contains the complete TensorFlow/Keras implementation of the EfficientNet model architecture as described in the paper "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" (Tan & Le, ICML 2019). The implementation uses compound scaling to jointly scale network width, depth, and resolution through `width_coefficient` and `depth_coefficient` parameters defined in `GlobalParams`.

The module defines several key components: `GlobalParams` and `BlockArgs` named tuples for parameterizing the network; `SE` (Squeeze-and-Excitation) layer for channel attention; `SuperPixel` layer for resolution manipulation; `MBConvBlock` implementing the core Mobile Inverted Bottleneck block with depthwise separable convolutions, optional squeeze-and-excitation, and residual connections with drop connect; and the top-level `Model` class that assembles the full EfficientNet architecture from stem, repeated MBConv blocks, and head layers.

Helper functions provide custom kernel initializers (`conv_kernel_initializer`, `dense_kernel_initializer`), filter/repeat rounding utilities (`round_filters`, `round_repeats`) that apply the scaling coefficients, and block decoding utilities for constructing block configurations from string specifications. The model supports configurable data formats (channels_first/channels_last), batch normalization parameters, gradient checkpointing, and local pooling options.

Usage

Use this module as the feature extraction backbone within the EfficientDet object detection pipeline. It is instantiated by the `efficientnet_builder` module using model name strings (e.g., 'efficientnet-b0' through 'efficientnet-b7') and provides multi-scale feature maps for the Feature Pyramid Network.

Code Reference

Source Location

Signature

GlobalParams = collections.namedtuple("GlobalParams", [
    "batch_norm_momentum", "batch_norm_epsilon", "dropout_rate",
    "data_format", "num_classes", "width_coefficient", "depth_coefficient",
    "depth_divisor", "min_depth", "survival_prob", "relu_fn", "batch_norm",
    "use_se", "local_pooling", "condconv_num_experts",
    "clip_projection_output", "blocks_args", "fix_head_stem", "grad_checkpoint",
])

BlockArgs = collections.namedtuple("BlockArgs", [
    "kernel_size", "num_repeat", "input_filters", "output_filters",
    "expand_ratio", "id_skip", "strides", "se_ratio", "conv_type",
    "fused_conv", "super_pixel", "condconv",
])

class SE(tf.keras.layers.Layer):
    def __init__(self, global_params, se_filters, output_filters, name=None): ...
    def call(self, inputs): ...

class MBConvBlock(tf.keras.layers.Layer):
    def __init__(self, block_args, global_params, name=None): ...
    def call(self, inputs, training, survival_prob=None): ...

class Model(tf.keras.Model):
    def __init__(self, blocks_args=None, global_params=None, name=None): ...
    def call(self, inputs, training, features_only=None): ...

def conv_kernel_initializer(shape, dtype=None, partition_info=None): ...
def dense_kernel_initializer(shape, dtype=None, partition_info=None): ...
def round_filters(filters, global_params, skip=False): ...
def round_repeats(repeats, global_params, skip=False): ...

Import

from model.backbone import efficientnet_model

# Typically accessed via efficientnet_builder:
from model.backbone import efficientnet_builder
backbone = efficientnet_builder.get_model("efficientnet-b1", override_params={})

I/O Contract

Inputs

Name Type Required Description
inputs tf.Tensor Yes Input image tensor of shape [batch, height, width, 3] (or channels_first)
training bool Yes Whether the model is in training mode (affects dropout and batch norm)
features_only bool No If True, return intermediate feature maps instead of final classification output
blocks_args list[BlockArgs] Yes List of BlockArgs namedtuples defining each MBConv block
global_params GlobalParams Yes GlobalParams namedtuple with model-wide configuration

Outputs

Name Type Description
features list[tf.Tensor] Multi-scale feature maps from different network stages (when features_only=True)
logits tf.Tensor Classification logits of shape [batch, num_classes] (when features_only=False)

Usage Examples

Create EfficientNet-B1 Backbone

from model.backbone import efficientnet_builder

# Build EfficientNet-B1 with custom overrides
override_params = {
    "data_format": "channels_last",
    "survival_prob": 0.8,
}
model = efficientnet_builder.get_model(
    "efficientnet-b1",
    override_params=override_params,
)

# Extract multi-scale features
features = model(images, training=True, features_only=True)
# features is a list of tensors at different spatial resolutions

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment