ARM-software / ML-KWS-for-MCU

Keyword spotting on Arm Cortex-M Microcontrollers
Apache License 2.0
1.13k stars 417 forks source link

Cannot write weights to weights.h for DS_CNN #126

Closed Ankitj03 closed 4 years ago

Ankitj03 commented 4 years ago

Hi, I am trying to run quant_test.py after fold_batchnorm.py on my dscnn checkpoint but the weights are still in 4D array. It shows the following error:

$ python quant_test.py --model_architecture ds_cnn --model_size_info 5 64 10 4 2 2 64 3 3 1 1 64 3 3 1 1 64 3 3 1 1 64 3 3 1 1 --dct_coefficient_count 10 --window_size_ms 40 --window_stride_ms 20 --checkpoint tmp/speech_commands_train/best/ds_cnn_9298.ckpt-14800_bnfused --act_max 32 0 0 0 0 0 0 0 0 0 0 0

INFO:tensorflow:Restoring parameters from tmp/speech_commands_train/best/ds_cnn_9298.ckpt-14800_bnfused Traceback (most recent call last): File "quant_test.py", line 306, in tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) File "C:\Users\ajoshi\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "quant_test.py", line 204, in main FLAGS.model_architecture, FLAGS.model_size_info) File "quant_test.py", line 112, in run_quant_inference np.savetxt(f,var_values.transpose(),fmt='%d',delimiter=', ',newline=', ') File "<__array_function__ internals>", line 6, in savetxt File "C:\Users\ajoshi\AppData\Roaming\Python\Python37\site-packages\numpy\lib\npyio.py", line 1382, in savetxt "Expected 1D or 2D array, got %dD array instead" % X.ndim) ValueError: Expected 1D or 2D array, got 4D array instead