xiph / rnnoise

Recurrent neural network for audio noise reduction
BSD 3-Clause "New" or "Revised" License
3.89k stars 882 forks source link

Control the size of model #229

Closed BancoLin closed 1 month ago

BancoLin commented 1 month ago

I use my own data to train a model, but its size is 3X larger than the default rnnoise_data.c. The difference between the two models is the number of weights in GRUs. I used default settings in the training, so I have no idea why my model is 3X larger .

(base) XXX:~/tools/rnnoise/src$ diff <(grep "^static" rnnoise_data.c) <(grep "^static" my_rnnoise_data.c)
8,10c8,10
< static const opus_int8 gru1_input_weights_int8[147456] = {
< static const float gru1_input_weights_float[147456] = {
< static const int gru1_input_weights_idx[4752] = {
---
> static const opus_int8 gru1_input_weights_int8[442368] = {
> static const float gru1_input_weights_float[442368] = {
> static const int gru1_input_weights_idx[13968] = {
...
BancoLin commented 1 month ago

After tracing source code, there are sparsify_start and sparsify_stop parameters in ./torch/rnnoise/rnnoise.py. Default value of sparsify_start = 2500 indicates the model weight sparsification starts at step 2500, which means the number of training steps must be greater than this number. So I increase the size of training data, the sparsification starts to work now.