我有一个以HDF5 (*.h5)格式保存的Keras模型。我正在使用stm32ai命令行工具生成我的文件nn.c/.h和nndata.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 4nn_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的权重没有不同吗?
发布于 2021-01-15 18:48:30
与我的预期相反,压缩似乎并不总是完成,但只有在某些情况下,这些情况并不是完全为公众定义的:See here此外,我查看了模型转换报告nn_generate_report.txt,它没有显示压缩级别为4的任何神经网络层的压缩标记"(c)“,但对于压缩级别8,所有层都标有压缩标记。所以,我假设一切都很好。
https://stackoverflow.com/questions/65724879
复制相似问题