efficientnet
birdnet_stm32.models.efficientnet
¶
N6-B0: an EfficientNet-B0 backbone for INT8 on the STM32N6 (2.2).
EfficientNet-B0's inverted-residual MBConv blocks (Tan & Le 2019) behind the project's audio frontends, with the three changes that make B0 survive INT8 on the Neural-ART NPU: ReLU6 instead of SiLU, no squeeze-and-excite, and a bounded residual stream (ReLU6 after each projection and residual add, so the stream stays in [0, 6] as in the DS-CNN blocks). B0 as published lost 14% of its WABAD AP to post-training quantization; N6-B0 trained to 2.2's float WABAD-61 AUPRC 0.465 (2.1 Raw: 0.374), INT8 0.441.
The block table and stochastic depth follow B0 at width and depth 1.0. The top
1x1 conv emits embeddings_size channels (1280), pooled by the same gap
layer as the DS-CNN so the embedding loss and the head fine-tune find their
layers.
mbconv_block(x, out_ch, expand, kernel, stride, drop_rate, name)
¶
MBConv without squeeze-and-excite: 1x1 expand, k x k depthwise, 1x1 project, bounded residual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor [B, F, T, C]. |
required |
out_ch
|
int
|
Output channels of the projection. |
required |
expand
|
int
|
Expansion ratio of the hidden width (1 skips the expand conv). |
required |
kernel
|
int
|
Square depthwise kernel size. |
required |
stride
|
int
|
Depthwise stride on both axes. |
required |
drop_rate
|
float
|
Stochastic-depth rate on the residual branch. |
required |
name
|
str
|
Base name for layers. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor [B, F', T', out_ch]. |
Source code in birdnet_stm32/models/efficientnet.py
efficientnet_b0_backbone(x, embeddings_size, blocks=B0_BLOCKS)
¶
N6-B0 stem, seven MBConv stages and the top conv on a frontend's [B, F, T, C] output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Frontend output. |
required |
embeddings_size
|
int
|
Channels of the top 1x1 conv (the pooled embedding). |
required |
blocks
|
tuple
|
The stage table, (expand, kernel, repeats, output channels, first stride) per stage; B0's by default. |
B0_BLOCKS
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Feature map [B, F/32, T/32, embeddings_size]. |