Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the depth of PASST. #47

Open
Rishabh-S1899 opened this issue Apr 11, 2024 · 1 comment
Open

Changing the depth of PASST. #47

Rishabh-S1899 opened this issue Apr 11, 2024 · 1 comment

Comments

@Rishabh-S1899
Copy link

I want to change the depth of the transformer while finetuning the model. I am using the following command (inspired from ESC50) :

python3 ex_dcase.py with models.net.s_patchout_t=10 models.net.s_patchout_f=5 basedataset.fold=1 -p

I have already prepared the ex_dcase.py and dataset.py files for DCASE2020 dataset (inspired from ESC50 file provided by you). I have already been able to finetune the whole model once. Now I want to add a depth parameter to the commandline to run finetune script, so that I can control how many block I want to finetune on the architecture.
Currently I change the depth by changing the depth variable of the desired architecture here.
Suggest the required changes I need to make so that I can execute a command in the commandline and only finetune selective layers.

@kkoutini
Copy link
Owner

There are two options, you can either make a new function similar to passt_s_kd_p16_128_ap486 and make the depth a parameter to the function and add it as a parameter to get_model method. In that case, you can change it directly from the command line usind sacred syntax:

python ex_audioset.py with models.net.depth=x -p

However, if you are loading a pretrained model this may break the loading, since now the model now have different weights.
I recommend using lighten_model method (as used in passt-L) which will:

  • remove alternating layers after loading the pre-trained model (remove every n layer): if (cut_depth=-n) < 0.
  • remove the last n layers after loading the pre-trained model: if cut_depth=n > 0.

example:

python ex_audioset.py with models.net.depth=x models.net.cut_depth=-2 -p

will remove every other layer from the pre-trained model to reduce the depth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants