majianjia / nnom

A higher-level Neural Network library for microcontrollers.
Apache License 2.0
909 stars 245 forks source link

example:keyword spotting discuss #113

Closed wanglong100 closed 3 years ago

wanglong100 commented 3 years ago

Hi jianjia,

I see the snip code in file (https://github.com/majianjia/nnom/blob/master/examples/keyword_spotting/kws.py) as below: ` def normalize(data, n, quantize=True): limit = pow(2, n) data = np.clip(data, -limit, limit) / limit if quantize: data = np.round(data * 128) / 128.0 return data

# instead of using maximum value for quantised, we allows some saturation to save more details in small values.
x_train = normalize(x_train, 3)
x_test = normalize(x_test, 3)
x_val = normalize(x_val, 3)`

You select [-8,8] as the range for the dataset.

I wonder how to decide the feature range for the dataset. Thanks.

majianjia commented 3 years ago

Hi @DumBoFly ,

The original thought was to get more resolution in higher frequency bands. The MFCC features have the largest dynamic range in the first/second bands(the lower frequency), if we don't saturate them, will result in much smaller numbers in higher frequencies.

You can remove them to test if there is any different. but remember to do the same in the C code.

A similar operation is also implemented in the RNN denoise example.

Thanks,

wanglong100 commented 3 years ago

Sorry for late reply. Thank you for your explanation and I think i have got it.