为什么我在 X-Cube-AI / STM32CubeMX.AI 中获得完全相同的压缩级别 "None" 和“4x”权重?

Why do I get the exact same weights for compression levels "None" and "4x" in X-Cube-AI / STM32CubeMX.AI?

我有一个以 HDF5 (*.h5) 格式保存的 Keras 模型。我正在使用 stm32ai 命令行工具生成我的文件 nn.c/.h 以及 nn_data.c/.h。一个示例命令如下:

~/STM32Cube/Repository/Packs/STMicroelectronics/X-CUBE-AI/5.2.0/Utilities/linux/stm32ai generate --model nn.h5 --verbosity 2 --type keras --name nn --compression 4

nn_data.c 文件包含我的神经网络的权重。但是,当我将压缩设置为 1 时,这意味着没有压缩,我得到:

#include "nn_data.h"

ai_handle ai_nn_data_weights_get(void)
{

  AI_ALIGNED(4)
  static const ai_u8 s_nn_weights[ 3196 ] = {
    0x56, 0xff, 0xa5, 0x3d, 0xb6, 0xa2, 0xf3, 0x3d, 0x18, 0x2c,
    0x4e, 0xbc, 0x69, 0x64, 0xa4, 0x3d, 0x09, 0xf4, 0x27, 0x3e,
...

当我将压缩设置为 4 (4x) 时,我得到完全相同的权重!

仅针对 8 的压缩,我得到不同的权重:

#include "nn_data.h"

ai_handle ai_nn_data_weights_get(void)
{

  AI_ALIGNED(4)
  static const ai_u8 s_nn_weights[ 728 ] = {
    0x0d, 0x5d, 0xa0, 0xbe, 0x20, 0xf7, 0x86, 0xbe, 0x83, 0xe4,
    0x66, 0xbe, 0xca, 0x73, 0x36, 0xbe, 0x8d, 0xa9, 0xf7, 0xbd,
...

我们可以清楚地看到 8 倍压缩的权重缓冲区明显更小。

有人知道为什么压缩级别 None 和 4 的权重没有差异吗?

与我的预期相反,压缩似乎并不总是完成,但仅在某些未完全为 public 定义的情况下完成:See here 此外,我研究了模型转换报告 nn_generate_report.txt 并且它没有显示压缩级别 4 的任何神经网络层的压缩标记“(c)”。但是对于压缩级别 8,所有层都标有它。所以,我认为一切都很好。