From 41e42f892772586d7ff7bba72562b2075418e442 Mon Sep 17 00:00:00 2001 From: Somshubra Majumdar Date: Thu, 20 May 2021 07:20:19 -0700 Subject: [PATCH 01/11] Alias Swish to SiLU (#2239) * Alias Swish to SiLU and move activations to inplace execution if possible Signed-off-by: smajumdar * Remove unused import Signed-off-by: smajumdar --- nemo/collections/asr/modules/conv_asr.py | 5 +++++ nemo/collections/asr/parts/activations.py | 7 ++----- nemo/collections/asr/parts/jasper.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nemo/collections/asr/modules/conv_asr.py b/nemo/collections/asr/modules/conv_asr.py index 3022325101bd..10efbee7aee5 100644 --- a/nemo/collections/asr/modules/conv_asr.py +++ b/nemo/collections/asr/modules/conv_asr.py @@ -127,6 +127,11 @@ def __init__( jasper = OmegaConf.to_container(jasper) activation = jasper_activations[activation]() + + # If the activation can be executed in place, do so. + if hasattr(activation, 'inplace'): + activation.inplace = True + feat_in = feat_in * frame_splicing self._feat_in = feat_in diff --git a/nemo/collections/asr/parts/activations.py b/nemo/collections/asr/parts/activations.py index 627eef295717..55ebaca7e12f 100644 --- a/nemo/collections/asr/parts/activations.py +++ b/nemo/collections/asr/parts/activations.py @@ -12,16 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import torch import torch.nn as nn __all__ = ['Swish'] -class Swish(nn.Module): +class Swish(nn.SiLU): """ Swish activation function introduced in 'https://arxiv.org/abs/1710.05941' + Mathematically identical to SiLU. See note in nn.SiLU for references. """ - - def forward(self, x): - return x * torch.sigmoid(x) diff --git a/nemo/collections/asr/parts/jasper.py b/nemo/collections/asr/parts/jasper.py index 73cc213dd8c3..9b33fbb0be15 100644 --- a/nemo/collections/asr/parts/jasper.py +++ b/nemo/collections/asr/parts/jasper.py @@ -34,7 +34,7 @@ except ImportError: PYTORCH_QUANTIZATION_AVAILABLE = False -jasper_activations = {"hardtanh": nn.Hardtanh, "relu": nn.ReLU, "selu": nn.SELU, "swish": Swish} +jasper_activations = {"hardtanh": nn.Hardtanh, "relu": nn.ReLU, "selu": nn.SELU, "swish": Swish, "silu": nn.SiLU} def tds_uniform_(tensor, mode='fan_in'): From b6c15c3c72da3c408ccba7a05119cf2a9b08c6aa Mon Sep 17 00:00:00 2001 From: Oleksii Kuchaiev Date: Thu, 20 May 2021 15:45:18 -0700 Subject: [PATCH 02/11] Update README.rst --- README.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.rst b/README.rst index 85db0f92699a..6b302f5619b4 100644 --- a/README.rst +++ b/README.rst @@ -32,12 +32,6 @@ Introduction ------------ -NeMo is a toolkit for creating `Conversational AI `_ applications. - -`NeMo product page. `_ - -`Introductory video. `_ - The toolkit comes with extendable collections of pre-built modules and ready-to-use models for: * `Automatic Speech Recognition (ASR) `_ From f8fc1b477286af87d44e3857b3803a790e60baa5 Mon Sep 17 00:00:00 2001 From: fayejf <36722593+fayejf@users.noreply.github.com> Date: Thu, 20 May 2021 16:10:09 -0700 Subject: [PATCH 03/11] Offline asr notebook bug fix (#2242) * fix Signed-off-by: fayejf * install Signed-off-by: fayejf --- tutorials/asr/Offline_ASR.ipynb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tutorials/asr/Offline_ASR.ipynb b/tutorials/asr/Offline_ASR.ipynb index 16168c06ce19..026230f725fe 100644 --- a/tutorials/asr/Offline_ASR.ipynb +++ b/tutorials/asr/Offline_ASR.ipynb @@ -62,12 +62,18 @@ " !pip install plotly\n", " from plotly import graph_objects as go\n", "\n", + "# check if we have optional ipywidgets for tqdm/notebook\n", + "try:\n", + " import ipywidgets\n", + "except ModuleNotFoundError:\n", + " !pip install ipywidgets\n", + "\n", "# check if CTC beam decoders are installed\n", "try:\n", " import ctc_decoders\n", "except ModuleNotFoundError:\n", " # install beam search decoder\n", - " !apt-get install swig\n", + " !apt-get install -y swig\n", " !git clone https://github.com/NVIDIA/NeMo -b \"$BRANCH\"\n", " !cd NeMo && bash scripts/asr_language_modeling/ngram_lm/install_beamsearch_decoders.sh\n", " print('Restarting Colab runtime to successfully import built module.')\n", @@ -274,7 +280,7 @@ " return e / e.sum(axis=-1).reshape([logits.shape[0], 1])\n", "\n", "# let's do inference once again but without decoder\n", - "logits = asr_model.transcribe(files, logprobs=True)[0].cpu().numpy()\n", + "logits = asr_model.transcribe(files, logprobs=True)[0]\n", "probs = softmax(logits)\n", "\n", "# 20ms is duration of a timestep at output of the model\n", @@ -494,4 +500,4 @@ "outputs": [] } ] -} \ No newline at end of file +} From 5967a46b61acc5098b940694723b5aa028d333a9 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Thu, 20 May 2021 18:37:10 -0700 Subject: [PATCH 04/11] Fix docstring (#2244) * fix comments Signed-off-by: Yang Zhang * fix doc string Signed-off-by: Yang Zhang --- .../inverse_text_normalization/verbalizers/money.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nemo_text_processing/inverse_text_normalization/verbalizers/money.py b/nemo_text_processing/inverse_text_normalization/verbalizers/money.py index b6c312116fdb..30dec90c76e0 100644 --- a/nemo_text_processing/inverse_text_normalization/verbalizers/money.py +++ b/nemo_text_processing/inverse_text_normalization/verbalizers/money.py @@ -28,7 +28,7 @@ class MoneyFst(GraphFst): """ Finite state transducer for verbalizing money, e.g. - money { integer_part: "12" fractional_part: 05 currency: "$" } -> $12.05 + money { integer_part: "12" fractional_part: "05" currency: "$" } -> $12.05 Args: decimal: DecimalFst From dcf56188961f007d5619efdac8c2b09e313f3c8c Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 21 May 2021 00:02:07 -0400 Subject: [PATCH 05/11] Update "last" Checkpoint (#2241) * fix Signed-off-by: Jason * change Signed-off-by: Jason * fix Signed-off-by: Jason Co-authored-by: Sandeep Subramanian --- nemo/utils/exp_manager.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nemo/utils/exp_manager.py b/nemo/utils/exp_manager.py index 4ef13d1844bf..4419035dd315 100644 --- a/nemo/utils/exp_manager.py +++ b/nemo/utils/exp_manager.py @@ -640,9 +640,7 @@ def on_train_end(self, trainer, pl_module): pl_module.save_to(save_path=os.path.join(self.dirpath, self.prefix + self.postfix)) -def configure_checkpointing( - trainer: 'pytorch_lightning.Trainer', log_dir: Path, name: str, params: 'DictConfig', -): +def configure_checkpointing(trainer: 'pytorch_lightning.Trainer', log_dir: Path, name: str, params: 'DictConfig'): """ Adds ModelCheckpoint to trainer. Raises CheckpointMisconfigurationError if trainer already has a ModelCheckpoint callback or if trainer.weights_save_path was passed to Trainer. """ @@ -699,6 +697,7 @@ def configure_checkpointing( ) checkpoint_callback = NeMoModelCheckpoint(**params) + checkpoint_callback.last_model_path = trainer.resume_from_checkpoint or "" trainer.callbacks.append(checkpoint_callback) From 740af1105482b40f6a9451b50014f48ced71ed9e Mon Sep 17 00:00:00 2001 From: Elena Rastorgueva <80532067+erastorgueva-nv@users.noreply.github.com> Date: Fri, 21 May 2021 19:45:25 +0100 Subject: [PATCH 06/11] Add pretrained model stt_es_citrinet_512 (#2247) Signed-off-by: Elena Rastorgueva --- nemo/collections/asr/models/ctc_bpe_models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nemo/collections/asr/models/ctc_bpe_models.py b/nemo/collections/asr/models/ctc_bpe_models.py index f6b3ede113ec..00718bae6c8c 100644 --- a/nemo/collections/asr/models/ctc_bpe_models.py +++ b/nemo/collections/asr/models/ctc_bpe_models.py @@ -66,6 +66,14 @@ def list_available_models(cls) -> Optional[PretrainedModelInfo]: results.append(model) + model = PretrainedModelInfo( + pretrained_model_name="stt_es_citrinet_512", + description="For details about this model, please visit https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_es_citrinet_512", + location="https://api.ngc.nvidia.com/v2/models/nvidia/nemo/stt_es_citrinet_512/versions/1.0.0/files/stt_es_citrinet_512.nemo", + ) + + results.append(model) + model = PretrainedModelInfo( pretrained_model_name="stt_en_conformer_ctc_small", description="For details about this model, please visit https://ngc.nvidia.com/catalog/models/nvidia:nemo:stt_en_conformer_ctc_small", From 30633c1a0e03ad4f93629d1bb25321ea975b5dfd Mon Sep 17 00:00:00 2001 From: Eric Harper Date: Fri, 21 May 2021 17:16:33 -0600 Subject: [PATCH 07/11] [BUGFIX] Only process tarfile artifacts when model was restored from tarfile (#2250) * process tarfile artifacts only if model is being restored Signed-off-by: ericharper * process tarfile artifacts only if model was restored from a tarfile Signed-off-by: ericharper --- nemo/core/classes/modelPT.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nemo/core/classes/modelPT.py b/nemo/core/classes/modelPT.py index b02d73f5fb4a..b2fd7e5ff35e 100644 --- a/nemo/core/classes/modelPT.py +++ b/nemo/core/classes/modelPT.py @@ -272,7 +272,7 @@ def _handle_artifacts(self, nemo_file_folder): # Process current tarfile artifacts by unpacking the previous tarfile and extract the artifacts # that are currently required. - if len(tarfile_artifacts) > 0: + if len(tarfile_artifacts) > 0 and app_state.model_restore_path is not None: # Need to step into nemo archive to extract file # Get path where the command is executed - the artifacts will be "retrieved" there # (original .nemo behavior) From 3c5aace91fb8c51267a272822ef17f3123e08ec5 Mon Sep 17 00:00:00 2001 From: Abhinav Khattar Date: Mon, 24 May 2021 16:05:32 -0400 Subject: [PATCH 08/11] Log average metrics for Multi-validation in NMT (#2251) * add avg metrics NMT Signed-off-by: Abhinav Khattar * name change Signed-off-by: Abhinav Khattar --- .../nlp/models/machine_translation/mt_enc_dec_model.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nemo/collections/nlp/models/machine_translation/mt_enc_dec_model.py b/nemo/collections/nlp/models/machine_translation/mt_enc_dec_model.py index 647070ce8a62..08f48905666e 100644 --- a/nemo/collections/nlp/models/machine_translation/mt_enc_dec_model.py +++ b/nemo/collections/nlp/models/machine_translation/mt_enc_dec_model.py @@ -285,6 +285,9 @@ def eval_epoch_end(self, outputs, mode): # if user specifies one validation dataloader, then PTL reverts to giving a list of dictionary instead of a list of list of dictionary if isinstance(outputs[0], dict): outputs = [outputs] + + loss_list = [] + sb_score_list = [] for dataloader_idx, output in enumerate(outputs): if dataloader_idx == 0: eval_loss = getattr(self, f'{mode}_loss').compute() @@ -339,6 +342,8 @@ def eval_epoch_end(self, outputs, mode): else: sb_score = 0.0 + loss_list.append(eval_loss.cpu().numpy()) + sb_score_list.append(sb_score) if dataloader_idx == 0: self.log(f"{mode}_loss", eval_loss, sync_dist=True) self.log(f"{mode}_sacreBLEU", sb_score, sync_dist=True) @@ -348,6 +353,10 @@ def eval_epoch_end(self, outputs, mode): self.log(f"{mode}_sacreBLEU_dl_index_{dataloader_idx}", sb_score, sync_dist=True) getattr(self, f'{mode}_loss_{dataloader_idx}').reset() + if len(loss_list) > 1: + self.log(f"{mode}_loss_avg", np.mean(loss_list), sync_dist=True) + self.log(f"{mode}_sacreBLEU_avg", np.mean(sb_score_list), sync_dist=True) + def validation_epoch_end(self, outputs): """ Called at the end of validation to aggregate outputs. From bf2291d18f9eb797bb8a68b192b2658cb2c97932 Mon Sep 17 00:00:00 2001 From: Somshubra Majumdar Date: Tue, 25 May 2021 09:43:19 -0700 Subject: [PATCH 09/11] Update Primer notebook (#2258) Signed-off-by: smajumdar --- tutorials/00_NeMo_Primer.ipynb | 2560 ++++++++++++++++---------------- 1 file changed, 1280 insertions(+), 1280 deletions(-) diff --git a/tutorials/00_NeMo_Primer.ipynb b/tutorials/00_NeMo_Primer.ipynb index d7e4385e4521..50a42570fb7a 100644 --- a/tutorials/00_NeMo_Primer.ipynb +++ b/tutorials/00_NeMo_Primer.ipynb @@ -1,1281 +1,1281 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "7LfkL2r2Q1tr" - }, - "source": [ - "# Getting Started: Exploring Nemo Fundamentals\n", - "\n", - "NeMo is a toolkit for creating [Conversational AI](https://developer.nvidia.com/conversational-ai#started) applications.\n", - "\n", - "NeMo toolkit makes it possible for researchers to easily compose complex neural network architectures for conversational AI using reusable components - Neural Modules. Neural Modules are conceptual blocks of neural networks that take typed inputs and produce typed outputs. Such modules typically represent data layers, encoders, decoders, language models, loss functions, or methods of combining activations.\n", - "\n", - "The toolkit comes with extendable collections of pre-built modules and ready-to-use models for automatic speech recognition (ASR), natural language processing (NLP) and text synthesis (TTS). Built for speed, NeMo can utilize NVIDIA's Tensor Cores and scale out training to multiple GPUs and multiple nodes.\n", - "\n", - "For more information, please visit https://docs.nvidia.com/deeplearning/nemo/user-guide/docs/en/main/#" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "zLSy94NEQi-e" - }, - "outputs": [], - "source": [ - "\"\"\"\n", - "You can run either this notebook locally (if you have all the dependencies and a GPU) or on Google Colab.\n", - "\n", - "Instructions for setting up Colab are as follows:\n", - "1. Open a new Python 3 notebook.\n", - "2. Import this notebook from GitHub (File -> Upload Notebook -> \"GITHUB\" tab -> copy/paste GitHub URL)\n", - "3. Connect to an instance with a GPU (Runtime -> Change runtime type -> select \"GPU\" for hardware accelerator)\n", - "4. Run this cell to set up dependencies.\n", - "\"\"\"\n", - "# If you're using Google Colab and not running locally, run this cell.\n", - "\n", - "## Install dependencies\n", - "!pip install wget\n", - "!apt-get install sox libsndfile1 ffmpeg\n", - "!pip install unidecode\n", - "\n", - "# ## Install NeMo\n", - "BRANCH = 'v1.0.0'\n", - "!python -m pip install git+https://github.com/NVIDIA/NeMo.git@$BRANCH#egg=nemo_toolkit[all]\n", - "\n", - "## Install TorchAudio\n", - "!pip install torchaudio>=0.6.0 -f https://download.pytorch.org/whl/torch_stable.html\n", - "\n", - "## Grab the config we'll use in this example\n", - "!mkdir configs" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "6G2TZkaxcM0e" - }, - "source": [ - "## Foundations of NeMo\n", - "---------\n", - "\n", - "NeMo models leverage [PyTorch Lightning](https://github.com/PyTorchLightning/pytorch-lightning) Module, and are compatible with the entire PyTorch ecosystem. This means that users have the full flexibility of using the higher level APIs provided by PyTorch Lightning (via Trainer), or write their own training and evaluation loops in PyTorch directly (by simply calling the model and the individual components of the model).\n", - "\n", - "For NeMo developers, a \"Model\" is the neural network(s) as well as all the infrastructure supporting those network(s), wrapped into a singular, cohesive unit. As such, all NeMo models are constructed to contain the following out of the box (at the bare minimum, some models support additional functionality too!) - \n", - "\n", - " - Neural Network architecture - all of the modules that are required for the model.\n", - "\n", - " - Dataset + Data Loaders - all of the components that prepare the data for consumption during training or evaluation.\n", - "\n", - " - Preprocessing + Postprocessing - all of the components that process the datasets so they can easily be consumed by the modules.\n", - "\n", - " - Optimizer + Schedulers - basic defaults that work out of the box, and allow further experimentation with ease.\n", - "\n", - " - Any other supporting infrastructure - tokenizers, language model configuration, data augmentation etc.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "XxAwtqWBQrNk" - }, - "outputs": [], - "source": [ - "import nemo\n", - "nemo.__version__" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "H01SHfKQh-gV" - }, - "source": [ - "## NeMo Collections\n", - "\n", - "NeMo is sub-divided into a few fundamental collections based on their domains - `asr`, `nlp`, `tts`. When you performed the `import nemo` statement above, none of the above collections were imported. This is because you might not need all of the collections at once, so NeMo allows partial imports of just one or more collection, as and when you require them.\n", - "\n", - "-------\n", - "Let's import the above three collections - " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "J09NNa8fhth7" - }, - "outputs": [], - "source": [ - "import nemo.collections.asr as nemo_asr\n", - "import nemo.collections.nlp as nemo_nlp\n", - "import nemo.collections.tts as nemo_tts" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "bSvYoeBrjPza" - }, - "source": [ - "## NeMo Models in Collections\n", - "\n", - "NeMo contains several models for each of its collections, pertaining to certain common tasks involved in conversational AI. At a brief glance, let's look at all the Models that NeMo offers for the above 3 collections." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "9LbbC_92i41f" - }, - "outputs": [], - "source": [ - "asr_models = [model for model in dir(nemo_asr.models) if model.endswith(\"Model\")]\n", - "asr_models" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "t5_ax9Z8j9FC" - }, - "outputs": [], - "source": [ - "nlp_models = [model for model in dir(nemo_nlp.models) if model.endswith(\"Model\")]\n", - "nlp_models" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "bQdR6RJdkezq" - }, - "outputs": [], - "source": [ - "tts_models = [model for model in dir(nemo_tts.models) if model.endswith(\"Model\")]\n", - "tts_models" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "iWKxKQnSkj9Z" - }, - "source": [ - "## The NeMo Model\n", - "\n", - "Let's dive deeper into what a NeMo model really is. There are many ways we can create these models - we can use the constructor and pass in a config, we can instantiate the model from a pre-trained checkpoint, or simply pass a pre-trained model name and instantiate a model directly from the cloud !\n", - "\n", - "---------\n", - "For now, let's try to work with an ASR model - [QuartzNet](https://arxiv.org/abs/1910.10261)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "n-XOQaW1kh3v" - }, - "outputs": [], - "source": [ - "quartznet = nemo_asr.models.EncDecCTCModel.from_pretrained('QuartzNet15x5Base-En')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "YP4X7KVPli6g" - }, - "outputs": [], - "source": [ - "quartznet.summarize();" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "MB91Swu0pIKr" - }, - "source": [ - "## Model Configuration using OmegaConf\n", - "--------\n", - "\n", - "So we could download, instantiate and analyse the high level structure of the `QuartzNet` model in a few lines! Now let's delve deeper into the configuration file that makes the model work.\n", - "\n", - "First, we import [OmegaConf](https://omegaconf.readthedocs.io/en/latest/). OmegaConf is an excellent library that is used throughout NeMo in order to enable us to perform yaml configuration management more easily. Additionally, it plays well with another library, [Hydra](https://hydra.cc/docs/intro/), that is used by NeMo to perform on the fly config edits from the command line, dramatically boosting ease of use of our config files !" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "RkgrDJvumFER" - }, - "outputs": [], - "source": [ - "from omegaconf import OmegaConf" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "CktakfBluA56" - }, - "source": [ - "All NeMo models come packaged with their model configuration inside the `cfg` attribute. While technically it is meant to be config declaration of the model as it has been currently constructed, `cfg` is an essential tool to modify the behaviour of the Model after it has been constructed. It can be safely used to make it easier to perform many essential tasks inside Models. \n", - "\n", - "To be doubly sure, we generally work on a copy of the config until we are ready to edit it inside the model" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "ISd6z7sXt9Mm" - }, - "outputs": [], - "source": [ - "import copy" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "N2_SiLHRve8A" - }, - "outputs": [], - "source": [ - "cfg = copy.deepcopy(quartznet.cfg)\n", - "print(OmegaConf.to_yaml(cfg))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "W_V3e3W7vqOb" - }, - "source": [ - "## Analysing the contents of the Model config\n", - "----------\n", - "\n", - "Above we see a configuration for the QuartzNet model. As discussed in the beginning, NeMo models contain the entire definition of the neural network(s) as well as most of the surrounding infrastructure to support that model within themselves. Here, we see a perfect example of this behaviour.\n", - "\n", - "QuartzNet contains within its config - \n", - "\n", - "- `preprocessor` - MelSpectrogram preprocessing layer\n", - "- `encoder` - The acoustic encoder model.\n", - "- `decoder` - The CTC decoder layer.\n", - "- `optim` (and potentially `sched`) - Optimizer configuration. Can optionally include Scheduler information.\n", - "- `spec_augment` - Spectrogram Augmentation support.\n", - "- `train_ds`, `validation_ds` and `test_ds` - Dataset and data loader construction information." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "sIwhdXkwxn6R" - }, - "source": [ - "## Modifying the contents of the Model config\n", - "----------\n", - "\n", - "Say we want to experiment with a different preprocessor (we want MelSpectrogram, but with different configuration than was provided in the original configuration). Or say we want to add a scheduler to this model during training. \n", - "\n", - "OmegaConf makes this a very simple task for us!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "WlSZ8EA4yGKo" - }, - "outputs": [], - "source": [ - "# OmegaConf won't allow you to add new config items, so we temporarily disable this safeguard.\n", - "OmegaConf.set_struct(cfg, False)\n", - "\n", - "# Let's see the old optim config\n", - "print(\"Old Config: \")\n", - "print(OmegaConf.to_yaml(cfg.optim))\n", - "\n", - "sched = {'name': 'CosineAnnealing', 'warmup_steps': 1000, 'min_lr': 1e-6}\n", - "sched = OmegaConf.create(sched) # Convert it into a DictConfig\n", - "\n", - "# Assign it to cfg.optim.sched namespace\n", - "cfg.optim.sched = sched\n", - "\n", - "# Let's see the new optim config\n", - "print(\"New Config: \")\n", - "print(OmegaConf.to_yaml(cfg.optim))\n", - "\n", - "# Here, we restore the safeguards so no more additions can be made to the config\n", - "OmegaConf.set_struct(cfg, True)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "-nMDN66502kn" - }, - "source": [ - "## Updating the model from config\n", - "----------\n", - "\n", - "NeMo Models can be updated in a few ways, but we follow similar patterns within each collection so as to maintain consistency.\n", - "\n", - "Here, we will show the two most common ways to modify core components of the model - using the `from_config_dict` method, and updating a few special parts of the model.\n", - "\n", - "Remember, all NeMo models are PyTorch Lightning modules, which themselves are PyTorch modules, so we have a lot of flexibility here!" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "qrKzFYkZ20aa" - }, - "source": [ - "### Update model using `from_config_dict`\n", - "\n", - "In certain config files, you will notice the following pattern : \n", - "\n", - "```yaml\n", - "preprocessor:\n", - " _target_: nemo.collections.asr.modules.AudioToMelSpectrogramPreprocessor\n", - " normalize: per_feature\n", - " window_size: 0.02\n", - " sample_rate: 16000\n", - " window_stride: 0.01\n", - " window: hann\n", - " features: 64\n", - " n_fft: 512\n", - " frame_splicing: 1\n", - " dither: 1.0e-05\n", - " stft_conv: false\n", - "```\n", - "\n", - "You might ask, why are we using `_target_`? Well, it is generally rare for the preprocessor, encoder, decoder and perhaps a few other details to be changed often from the command line when experimenting. In order to stabilize these settings, we enforce that our preprocessor will always be of type `AudioToMelSpectrogramPreprocessor` for this model by setting its `_target_` attribute in the config. In order to provide its parameters in the class constructor, we simply add them after `_target_`.\n", - "\n", - "---------\n", - "Note, we can still change all of the parameters of this `AudioToMelSpectrogramPreprocessor` class from the command line using hydra, so we don't lose any flexibility once we decide what type of preprocessing class we want !\n", - "\n", - "This also gives us a flexible way to instantiate parts of the model from just the config object !" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "1Be08R4szkT3" - }, - "outputs": [], - "source": [ - "new_preprocessor_config = copy.deepcopy(cfg.preprocessor)\n", - "new_preprocessor = quartznet.from_config_dict(new_preprocessor_config)\n", - "print(new_preprocessor)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "UzJQ7Y8H4S_U" - }, - "source": [ - "So how do we actually update our model's internal preprocessor with something new? Well, since NeMo Model's are just pytorch Modules, we can just replace their attribute !" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "WdtnPKX84OJ-" - }, - "outputs": [], - "source": [ - "quartznet.preprocessor = new_preprocessor" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "OMz2KR-24xTO" - }, - "outputs": [], - "source": [ - "quartznet.summarize();" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "gPb_BdPN40Ro" - }, - "source": [ - "--------\n", - "This might look like nothing changed - because we didn't actually modify the config for the preprocessor at all ! But as we showed above, we can easily modify the config for the preprocessor, instantiate it from config, and then just set it to the model." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "IV8WKJkD5E_Q" - }, - "source": [ - "-------\n", - "**NOTE**: Preprocessors don't generally have weights, so this was easy, but say we want to replace a part of the model which actually has trained parameters?\n", - "\n", - "Well, the above approach will still work, just remember the fact that the new module you inserted into `quartznet.encoder` or `quartznet.decoder` actually won't have pretrained weights. You can easily rectify that by loading the state dict for the module *before* you set it to the Model though!" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "YplQcgfG6S1U" - }, - "source": [ - "### Preserving the new config\n", - "\n", - "So we went ahead and updated the preprocessor of the model. We however also need to perform a crucial step - **preserving the updated config**!\n", - "\n", - "Why do we want to do this? NeMo has many ways of saving and restoring its models, which we will discuss a bit later. All of them depend on having an updated config that defines the model in its entirety, so if we modify anything, we should also update the corresponding part of the config to safely save and restore models." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "dsxQHBV86R4a" - }, - "outputs": [], - "source": [ - "# Update the config copy\n", - "cfg.preprocessor = new_preprocessor_config\n", - "# Update the model config\n", - "quartznet.cfg = cfg" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "eXRRBnJk5tCv" - }, - "source": [ - "## Update a few special components of the Model\n", - "---------\n", - "\n", - "While the above approach is good for most major components of the model, NeMo has special utilities for a few components.\n", - "\n", - "They are - \n", - "\n", - " - `setup_training_data`\n", - " - `setup_validation_data` and `setup_multi_validation_data`\n", - " - `setup_test_data` and `setup_multi_test_data`\n", - " - `setup_optimization`\n", - "\n", - "These special utilities are meant to help you easily setup training, validation, testing once you restore a model from a checkpoint.\n", - "\n", - "------\n", - "One of the major tasks of all conversational AI models is fine-tuning onto new datasets - new languages, new corpus of text, new voices etc. It is often insufficient to have just a pre-trained model. So these setup methods are provided to enable users to adapt models *after* they have been already trained or provided to you.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "B7Y7wt2x9goJ" - }, - "source": [ - "You might remember having seen a few warning messages the moment you tried to instantiate the pre-trained model. Those warnings are in fact reminders to call the appropriate setup methods for the task you want to perform. \n", - "\n", - "Those warnings are simply displaying the old config that was used to train that model, and are a basic template that you can easily modify. You have the ability to modify the `train_ds`, `validation_ds` and `test_ds` sub-configs in their entirety in order to evaluate, fine-tune or train from scratch the model, or any further purpose as you require it.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "1hXXdaup-QmG" - }, - "source": [ - "Let's discuss how to add the scheduler to the model below (which initially had just an optimizer in its config)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "cveKWvMZ4zBo" - }, - "outputs": [], - "source": [ - "# Let's print out the current optimizer\n", - "print(OmegaConf.to_yaml(quartznet.cfg.optim))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "XVguw3k0-f6b" - }, - "outputs": [], - "source": [ - "# Now let's update the config\n", - "quartznet.setup_optimization(cfg.optim);" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "1JZBCQeW-21X" - }, - "source": [ - "-------\n", - "We see a warning - \n", - "\n", - "```\n", - "Neither `max_steps` nor `iters_per_batch` were provided to `optim.sched`, cannot compute effective `max_steps` !\n", - " Scheduler will not be instantiated !\n", - "```\n", - "\n", - "We don't have a train dataset setup, nor do we have max_steps in the config. Most NeMo schedulers cannot be instantiated without computing how many train steps actually exist!\n", - "\n", - "Here, we can temporarily allow the scheduler construction by explicitly passing a max_steps value to be 100" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "mqC89hfE-tqf" - }, - "outputs": [], - "source": [ - "OmegaConf.set_struct(cfg.optim.sched, False)\n", - "\n", - "cfg.optim.sched.max_steps = 100\n", - "\n", - "OmegaConf.set_struct(cfg.optim.sched, True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "r22IqOBK_q6l" - }, - "outputs": [], - "source": [ - "# Now let's update the config and try again\n", - "quartznet.setup_optimization(cfg.optim);" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "U7Eezf_sAVS0" - }, - "source": [ - "You might wonder why we didnt explicitly set `quartznet._cfg.optim = cfg.optim`. \n", - "\n", - "This is because the `setup_optimization()` method does it for you! You can still update the config manually." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "THqhXy_lQ7i8" - }, - "source": [ - "### Optimizer & Scheduler Config\n", - "\n", - "Optimizers and schedulers are common components of models, and are essential to train the model from scratch.\n", - "\n", - "They are grouped together under a unified `optim` namespace, as schedulers often operate on a given optimizer.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "6HY51nuoSJs5" - }, - "source": [ - "### Let's breakdown the general `optim` structure\n", - "```yaml\n", - "optim:\n", - " name: novograd\n", - " lr: 0.01\n", - "\n", - " # optimizer arguments\n", - " betas: [0.8, 0.25]\n", - " weight_decay: 0.001\n", - "\n", - " # scheduler setup\n", - " sched:\n", - " name: CosineAnnealing\n", - "\n", - " # Optional arguments\n", - " max_steps: null # computed at runtime or explicitly set here\n", - " monitor: val_loss\n", - " reduce_on_plateau: false\n", - "\n", - " # scheduler config override\n", - " warmup_steps: 1000\n", - " warmup_ratio: null\n", - " min_lr: 1e-9\n", - "```\n", - "\n", - "Essential Optimizer components - \n", - "\n", - " - `name`: String name of the optimizer. Generally a lower case of the class name.\n", - " - `lr`: Learning rate is a required argument to all optimizers.\n", - "\n", - "Optional Optimizer components - after the above two arguments are provided, any additional arguments added under `optim` will be passed to the constructor of that optimizer as keyword arguments\n", - "\n", - " - `betas`: List of beta values to pass to the optimizer\n", - " - `weight_decay`: Optional weight decay passed to the optimizer.\n", - "\n", - "Optional Scheduler components - `sched` is an optional setup of the scheduler for the given optimizer.\n", - "\n", - "If `sched` is provided, only one essential argument needs to be provided : \n", - "\n", - " - `name`: The name of the scheduler. Generally, it is the full class name.\n", - "\n", - "Optional Scheduler components - \n", - "\n", - " - `max_steps`: Max steps as an override from the user. If one provides `trainer.max_steps` inside the trainer configuration, that value is used instead. If neither value is set, the scheduler will attempt to compute the `effective max_steps` using the size of the train data loader. If that too fails, then the scheduler will not be created at all.\n", - "\n", - " - `monitor`: Used if you are using an adaptive scheduler such as ReduceLROnPlateau. Otherwise ignored. Defaults to `loss` - indicating train loss as monitor.\n", - "\n", - " - `reduce_on_plateau`: Required to be set to true if using an adaptive scheduler.\n", - "\n", - "Any additional arguments under `sched` will be supplied as keyword arguments to the constructor of the scheduler.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "V3pQM2aj_6WX" - }, - "source": [ - "## Difference between the data loader setup methods\n", - "----------\n", - "\n", - "You might notice, we have multiple setup methods for validation and test data sets. We also don't have an equivalent `setup_multi_train_data`. \n", - "\n", - "In general, the `multi` methods refer to multiple data sets / data loaders. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "g33nMx9WCJdj" - }, - "source": [ - "### Where's `setup_multi_train_data`?\n", - "With the above in mind, let's tackle why we don't have `setup_multi_train_data`. \n", - "\n", - "NeMo is concerned with multiple domains - `asr`, `nlp` and `tts`. The way datasets are setup and used in these domains is dramatically different. It is often unclear what it means to have multiple train datasets - do we concatenate them? Do we randomly sample (with same or different probability) from each of them? \n", - "\n", - "Therefore we leave such support for multiple datasets up to the model itself. For example, in ASR, you can concatenate multiple train manifest files by using commas when providing the `manifest_filepath` value!" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "BjI2Q5LECJib" - }, - "source": [ - "### What are multi methods?\n", - "\n", - "In many cases, especially true for ASR and NLP, we may have multiple validation and test datasets. The most common example for this in ASR is `Librispeech`, which has `dev_clean`, `dev_other`, `test_clean`, `test_other`.\n", - "\n", - "NeMo standardizes how to handle multiple data loaders for validation and testing, so that all of our collections have a similar look and feel, as well as ease development of our models. During evaluation, these datasets are treated independently and prepended with resolved names so that logs are separate!\n", - "\n", - "The `multi` methods are therefore generalizations of the single validation and single test data setup methods, with some additional functionality. If you provide multiple datasets, you still have to write code for just one dataset and NeMo will automatically attach the appropriate names to your logs so you can differentiate between them!\n", - "\n", - "Furthermore, they also automatically preserve the config the user passes to them when updating the validation or test data loaders.\n", - "\n", - "**In general, it is preferred to call the `setup_multi_validation_data` and `setup_multi_test_data` methods, even if you are only using single datasets, simply for the automated management they provide.**" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ZKURHn0jH_52" - }, - "source": [ - "## Creating Model from constructor vs restoring a model\n", - "---------\n", - "\n", - "You might notice, we discuss all of the above setup methods in the context of model after it is restored. However, NeMo scripts do not call them inside any of the example train scripts themselves.\n", - "\n", - "This is because these methods are automatically called by the constructor when the Model is created for the first time, but these methods are skipped during restoration (either from a PyTorch Lightning checkpoint using `load_from_checkpoint`, or via `restore_from` method inside NeMo Models).\n", - "\n", - "This is done as most datasets are stored on a user's local directory, and the path to these datasets is set in the config (either set by default, or set by Hydra overrides). On the other hand, the models are meant to be portable. On another user's system, the data might not be placed at exactly the same location, or even on the same drive as specified in the model's config!\n", - "\n", - "Therefore we allow the constructor some brevity and automate such dataset setup, whereas restoration warns that data loaders were not set up and provides the user with ways to set up their own datasets.\n", - "\n", - "------\n", - "\n", - "Why are optimizers not restored automatically? Well, optimizers themselves don't face an issue, but as we saw before, schedulers depend on the number of train steps in order to calculate their schedule.\n", - "\n", - "However, if you don't wish to modify the optimizer and scheduler, and prefer to leave them to their default values, that's perfectly alright. The `setup_optimization()` method is automatically called by PyTorch Lightning for you when you begin training your model!" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "g91FE8mlMcnh" - }, - "source": [ - "## Saving and restoring models\n", - "----------\n", - "\n", - "NeMo provides a few ways to save and restore models. If you utilize the Experiment Manager that is part of all NeMo train scripts, PyTorch Lightning will automatically save checkpoints for you in the experiment directory.\n", - "\n", - "We can also use packaged files using the specialized `save_to` and `restore_from` methods." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "NzMxga7QNYn8" - }, - "source": [ - "### Saving and Restoring from PTL Checkpoints\n", - "----------\n", - "\n", - "The PyTorch Lightning Trainer object will periodically save checkpoints when the experiment manager is being used during training.\n", - "\n", - "PyTorch Lightning checkpoints can then be loaded and evaluated / fine-tuned just as always using the class method `load_from_checkpoint`.\n", - "\n", - "For example, restore a QuartzNet model from a checkpoint - \n", - "\n", - "```python\n", - "quartznet = nemo_asr.models.EncDecCTCModel.load_from_checkpoint()\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "W4YzAG-KOBkZ" - }, - "source": [ - "### Saving and Restoring from .nemo files\n", - "----------\n", - "\n", - "There are a few models which might require external dependencies to be packaged with them in order to restore them properly.\n", - "\n", - "One such example is an ASR model with an external BPE tokenizer. It is preferred if the model includes all of the components required to restore it, but a binary file for a tokenizer cannot be serialized into a PyTorch Lightning checkpoint.\n", - "\n", - "In such cases, we can use the `save_to` and `restore_from` method to package the entire model + its components (here, the tokenizer file(s)) into a tarfile. This can then be easily imported by the user and used to restore the model." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "P6_vMSwXNJ74" - }, - "outputs": [], - "source": [ - "# Save the model\n", - "quartznet.save_to('quartznet_15x5.nemo')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "HrBhgaqyP4rU" - }, - "outputs": [], - "source": [ - "!ls -d -- *.nemo " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "Tyht1E0DQGb_" - }, - "outputs": [], - "source": [ - "# Restore the model\n", - "temp_qn = nemo_asr.models.EncDecCTCModel.restore_from('quartznet_15x5.nemo')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "dqNpmYYJQS2H" - }, - "outputs": [], - "source": [ - "temp_qn.summarize();" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "A5e42EoiZYjf" - }, - "outputs": [], - "source": [ - "# Note that the preprocessor + optimizer config have been preserved after the changes we made !\n", - "print(OmegaConf.to_yaml(temp_qn.cfg))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "OI3RxwpcV-UF" - }, - "source": [ - "Note, that .nemo file is a simple .tar.gz with checkpoint, configuration and, potentially, other artifacts such as tokenizer configs being used by the model" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "jFBAGcaDWLiu" - }, - "outputs": [], - "source": [ - "!cp quartznet_15x5.nemo quartznet_15x5.tar.gz\n", - "!tar -xvf quartznet_15x5.tar.gz" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "mkau4Q9jZo1l" - }, - "source": [ - "### Extracting PyTorch checkpoints from NeMo tarfiles (Model level)\n", - "-----------\n", - "\n", - "While the .nemo tarfile is an excellent way to have a portable model, sometimes it is necessary for researchers to have access to the basic PyTorch save format. NeMo aims to be entirely compatible with PyTorch, and therefore offers a simple method to extract just the PyTorch checkpoint from the .nemo tarfile." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "qccPANeycCoq" - }, - "outputs": [], - "source": [ - "import torch" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "A4zswOKHar9q" - }, - "outputs": [], - "source": [ - "state_dict = temp_qn.extract_state_dict_from('quartznet_15x5.nemo', save_dir='./pt_ckpt/')\n", - "!ls ./pt_ckpt/" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ACB-0dfnbFG3" - }, - "source": [ - "As we can see below, there is now a single basic PyTorch checkpoint available inside the `pt_ckpt` directory, which we can use to load the weights of the entire model as below" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "4ZAF_A0uc5bB" - }, - "outputs": [], - "source": [ - "temp_qn.load_state_dict(torch.load('./pt_ckpt/model_weights.ckpt'))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Hkq6EM99cS6y" - }, - "source": [ - "### Extracting PyTorch checkpoints from NeMo tarfiles (Module level)\n", - "----------\n", - "\n", - "While the above method is exceptional when extracting the checkpoint of the entire model, sometimes there may be a necessity to load and save the individual modules that comprise the Model.\n", - "\n", - "The same extraction method offers a flag to extract the individual model level checkpoints into their individual files, so that users have access to per-module level checkpoints." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "LW6wve2zbT9D" - }, - "outputs": [], - "source": [ - "state_dict = temp_qn.extract_state_dict_from('quartznet_15x5.nemo', save_dir='./pt_module_ckpt/', split_by_module=True)\n", - "!ls ./pt_module_ckpt/" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "DtV5vpb5d1ni" - }, - "source": [ - "Now, we can load and assign the weights of the individual modules of the above QuartzNet Model !" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "rVHylSKFdywn" - }, - "outputs": [], - "source": [ - "temp_qn.preprocessor.load_state_dict(torch.load('./pt_module_ckpt/preprocessor.ckpt'))\n", - "temp_qn.encoder.load_state_dict(torch.load('./pt_module_ckpt/encoder.ckpt'))\n", - "temp_qn.decoder.load_state_dict(torch.load('./pt_module_ckpt/decoder.ckpt'))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "88vOGV7VYcuu" - }, - "source": [ - "# NeMo with Hydra\n", - "\n", - "[Hydra](https://hydra.cc/docs/intro/) is used throughout NeMo as a way to enable rapid prototyping using predefined config files. Hydra and OmegaConf offer great compatibility with each other, and below we show a few general helpful tips to improve productivity with Hydra when using NeMo." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "DfY6Ha3qYcxG" - }, - "source": [ - "## Hydra Help\n", - "--------\n", - "\n", - "Since our scripts are written with hydra in mind, you might notice that using `python --help` returns you a config rather than the usual help format from argparse. \n", - "\n", - "Using `--help` you can see the default config attached to the script - every NeMo script has at least one default config file attached to it. This gives you a guide on how you can modify values for an experiment.\n", - "\n", - "Hydra also has a special `--hydra-help` flag, which will offer you more help with respect to hydra itself as it is set up in the script.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "gEsZlnfaYc3X" - }, - "source": [ - "## Changing config paths and files\n", - "---------\n", - "\n", - "While all NeMo models come with at least 1 default config file, one might want to switch configs without changing code. This is easily achieved by the following commands : \n", - "\n", - "- `--config-path`: Path to the directory which contains the config files\n", - "- `--config-name`: Name of the config file we wish to load.\n", - "\n", - "Note that these two arguments need to be at the very beginning of your execution statement, before you provide any command line overrides to your config file." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ZyNHlArpYc9A" - }, - "source": [ - "## Overriding config from the command line\n", - "----------\n", - "\n", - "Hydra allows users to provide command line overrides to any part of the config. There are three cases to consider - \n", - "\n", - " - Override existing value in config\n", - " - Add new value in config\n", - " - Remove old value in config" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "96CKbvn6Yc7f" - }, - "source": [ - "### Overriding existing values in config\n", - "\n", - "Let's take the case where we want to change the optimizer from `novograd` to `adam`. Let's also change the beta values to default adam values.\n", - "\n", - "Hydra overrides are based on the `.` syntax - each `.` representing a level in the config itself.\n", - "\n", - "```sh\n", - "$ python