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

fix ssl models ptl monitor val through logging #7608

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions nemo/collections/asr/models/ssl_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def training_step(self, batch, batch_nb):

return {'loss': loss_value, 'log': tensorboard_logs}

def validation_step(self, batch, batch_idx, dataloader_idx=0):
def validation_pass(self, batch, batch_idx, dataloader_idx=0):
# Set flag to register tensors
self._in_validation_step = True

Expand All @@ -554,9 +554,17 @@ def validation_step(self, batch, batch_idx, dataloader_idx=0):
self.reset_registry()
del self._in_validation_step

return {
'val_loss': loss_value,
}
metrics = {'val_loss': loss_value}

return metrics

def validation_step(self, batch, batch_idx, dataloader_idx=0):
metrics = self.validation_pass(batch, batch_idx, dataloader_idx)
if type(self.trainer.val_dataloaders) == list and len(self.trainer.val_dataloaders) > 1:
self.validation_step_outputs[dataloader_idx].append(metrics)
else:
self.validation_step_outputs.append(metrics)
return metrics

def multi_validation_epoch_end(self, outputs, dataloader_idx: int = 0):
val_loss_mean = torch.stack([x['val_loss'] for x in outputs]).mean()
Expand Down
6 changes: 3 additions & 3 deletions tutorials/asr/Self_Supervised_Pre_Training.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
" file_id[file_id.find('-')+1 : file_id.rfind('-')],\n",
" file_id + '.wav')\n",
"\n",
" duration = librosa.core.get_duration(filename=audio_path)\n",
" duration = librosa.core.get_duration(path=audio_path)\n",
"\n",
" # Write the metadata to the manifest\n",
" metadata = {\n",
Expand Down Expand Up @@ -331,7 +331,7 @@
"\n",
"cfg.model.optim.sched.name = \"CosineAnnealing\"\n",
"cfg.model.optim.sched.warmup_steps = 1000\n",
"cfg.model.optim.sched.max_steps = 5000\n",
"cfg.model.optim.sched.max_steps = 2000\n",
"#in practice you will usually want a much larger amount of pre-training steps\n",
"cfg.model.optim.sched.min_lr = 0\n",
"cfg.model.optim.lr = 0.015\n",
Expand Down Expand Up @@ -554,7 +554,7 @@
"\n",
"cfg.model.optim.sched.name = \"CosineAnnealing\"\n",
"cfg.model.optim.sched.warmup_steps = 500\n",
"cfg.model.optim.sched.max_steps = 2000\n",
"cfg.model.optim.sched.max_steps = 1000\n",
"cfg.model.optim.sched.min_lr = 0\n",
"cfg.model.optim.lr = 0.015 #if encoder is frozen, lr can be much higher\n",
"cfg.model.optim.weight_decay = 0\n",
Expand Down
Loading