-
Notifications
You must be signed in to change notification settings - Fork 759
Open
Description
🚀 The feature
In some research cases, the Wav2Vec2 or HuBERT is expected to be frozen (i.e. make reuqires_grad=False for all params).
- Users use it as a feature extractor that generates pretty robust representations and jointly train with down-stream neural networks. In this case, people don't want to fine-tune the Wav2Vec2/HuBERT to avoid over-fitting on the downstream dataset.
- Users want to jointly train their front-end model and use the gradient of Wav2Vec2/HuBERT only for back-propagation.
It'll be good to add an argument to set the model to frozen state so that users don't need to set requires_grad=False by themselves.
Motivation, pitch
SpeechBrain has similar implementation by adding freeze argument when initilizing the model. https://github.com/speechbrain/speechbrain/blob/f1f421b3bb58dabc75d67c3fd5f6e3359943b927/speechbrain/lobes/models/fairseq_wav2vec.py#L78
if self.freeze:
self.model.eval()
# Freeze parameters
for param in model.parameters():
param.requires_grad = Falsecc @mthrok
Reactions are currently unavailable