ONNX 模型库
返回模型

说明文档

DS-CNN

来自 MLCommons 仓库的 DS-CNN 模型 https://github.com/mlcommons/tiny/tree/master/benchmark/training/keyword_spotting

通过以下操作从 .pb 模型导出的 ONNX 版本

# setup environment
python3.10 -m venv pytf
source pytf/bin/activate

# install latest officially compatible versions
pip install tensorflow==2.15.1 tf2onnx==1.16.1

# use most recent opset officially supported
python -m tf2onnx.convert \
  --saved-model <path/to/dir> \
  --output converted_ds_cnn.onnx --opset 18

此版本的输入格式为 NHWC。 以下 Python 代码将 MatMul+Add 融合为 Gemm,并折叠第一个 Reshape 算子。

import onnx
import onnxruntime

import aidge_core as ai
import aidge_onnx

model_onnx = onnx.load_model(\"converted_ds_cnn.onnx\")
model_onnx_clean_nhwc = aidge_onnx.onnx_cleaner.clean_onnx(
    model_onnx, {\"input_1\": [[1, 49, 10, 1]]}, \"test_clean\", opset_version=18
)
model = aidge_onnx.convert_onnx_to_aidge(model_onnx_clean_nhwc)

to_replace: set[ai.Node] = set(
    [
        model.get_node(\"StatefulPartitionedCall_functional_1_conv2d_BiasAdd__6\"),
        model.get_node(\"new_shape__103_out0\"),
    ]
)

model.replace(to_replace, set())
model.set_mandatory_inputs_first()

model.forward_dims(dims=[[1, 1, 49, 10]], allow_data_dependency=True)
model_onnx_clean_nchw = aidge_onnx.convert_aidge_to_onnx(model, \"ds_cnn\", opset=18)
onnx.save_model(model_onnx_clean_nchw, \"ds_cnn.onnx\")

Aidge 支持

注意:我们已针对以下功能测试了此网络。如果您遇到任何错误,请提交一个 issue。未在 CI 中测试的功能可能无法正常工作。

功能 CI 中已测试
ONNX 导入 ✔️
CPU 运行时 ✔️
CUDA 运行时 ✔️
CPU 导出 ✔️

模型

  • 算子:43 个(9 种类型)
    • AvgPooling2D: 1
    • Conv2D: 4
    • FC: 1
    • PaddedConv2D: 1
    • PaddedConvDepthWise2D: 4
    • Producer: 21
    • ReLU: 9
    • Reshape: 1
    • Softmax: 1

Google Speech Commands v2

  • Opset: 18
  • 来源:Google
  • 输入
    • 大小:[N, 1, 49, 10]
    • 格式:[N, C, H, W]
    • 预处理:
      • ?
  • 输出
    • 大小:[N, 12]

EclipseAidge/ds_cnn

作者 EclipseAidge

image-classification
↓ 0 ♥ 0

创建时间: 2025-11-12 12:25:04+00:00

更新时间: 2025-12-02 17:26:50+00:00

在 Hugging Face 上查看

文件 (3)

.gitattributes
README.md
ds_cnn.onnx ONNX