diff --git a/docs/docs_zh/sources/source/collections/nemo_asr.rst b/docs/docs_zh/sources/source/collections/nemo_asr.rst index 19135143a520..83f92615e563 100644 --- a/docs/docs_zh/sources/source/collections/nemo_asr.rst +++ b/docs/docs_zh/sources/source/collections/nemo_asr.rst @@ -1,9 +1,9 @@ -NeMo_ASR collection +NeMo ASR collection =================== 语音数据处理模块 ------------------------------ -.. automodule:: nemo_asr.data_layer +.. automodule:: nemo.collections.asr.data_layer :members: :undoc-members: :show-inheritance: @@ -11,7 +11,7 @@ NeMo_ASR collection 语音识别模块 ------------------------------------ -.. automodule:: nemo_asr.jasper +.. automodule:: nemo.collections.asr.jasper :members: :undoc-members: :show-inheritance: diff --git a/docs/docs_zh/sources/source/collections/nemo_nlp.rst b/docs/docs_zh/sources/source/collections/nemo_nlp.rst index ccd744efd4a4..223cd71d3b6d 100644 --- a/docs/docs_zh/sources/source/collections/nemo_nlp.rst +++ b/docs/docs_zh/sources/source/collections/nemo_nlp.rst @@ -1,48 +1,47 @@ -NeMo_NLP collection +NeMo NLP collection =================== NLP 数据处理模块 --------------------------- -.. automodule:: nemo_nlp.data_layers +.. automodule:: nemo.collections.nlp.data.datasets :members: :undoc-members: :show-inheritance: - :exclude-members: forward NLP 分词器 -------------- -.. automodule:: nemo_nlp.data.tokenizers.bert_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.bert_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.char_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.char_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.gpt2_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.gpt2_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.spc_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.sentencepiece_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.tokenizer_spec +.. automodule:: nemo.collections.nlp.data.tokenizers.tokenizer_spec :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.word_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.word_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.yttm_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.youtokentome_tokenizer :members: :undoc-members: :show-inheritance: @@ -50,27 +49,52 @@ NLP 分词器 NLP 神经模块 ------------------ -.. automodule:: nemo_nlp.modules.classifiers + +.. automodule:: nemo.collections.nlp.nm.data_layers :members: :undoc-members: :show-inheritance: :exclude-members: forward -.. automodule:: nemo_nlp.modules.losses +.. automodule:: nemo.collections.nlp.nm.losses :members: :undoc-members: :show-inheritance: :exclude-members: forward -.. automodule:: nemo_nlp.modules.pytorch_utils +.. automodule:: nemo.collections.nlp.nm.trainables.common.sequence_classification_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.common.sequence_regression_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.common.token_classification_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.common.transformer.transformer_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.dialogue_state_tracking.state_tracking_trade_nm :members: :undoc-members: :show-inheritance: :exclude-members: forward -.. automodule:: nemo_nlp.modules.transformer_nm +.. automodule:: nemo.collections.nlp.nm.trainables.joint_intent_slot.joint_intent_slot_nm :members: :undoc-members: :show-inheritance: @@ -79,7 +103,7 @@ NLP 神经模块 NLP Hugging Face 神经模块 ------------------------------- -.. automodule:: nemo_nlp.huggingface.bert +.. automodule:: nemo.collections.nlp.nm.trainables.common.huggingface.bert_nm :members: :undoc-members: :show-inheritance: diff --git a/docs/docs_zh/sources/source/collections/nemo_tts.rst b/docs/docs_zh/sources/source/collections/nemo_tts.rst index 8b189efd5224..aa852bba56eb 100644 --- a/docs/docs_zh/sources/source/collections/nemo_tts.rst +++ b/docs/docs_zh/sources/source/collections/nemo_tts.rst @@ -1,9 +1,9 @@ -NeMo_TTS collection +NeMo TTS collection =================== 语音数据处理模块 ------------------------------ -.. automodule:: nemo_tts.data_layers +.. automodule:: nemo.collections.tts.data_layers :members: :undoc-members: :show-inheritance: @@ -11,7 +11,7 @@ NeMo_TTS collection Tacotron 2 模块 ------------------ -.. automodule:: nemo_tts.tacotron2_modules +.. automodule:: nemo.collections.tts.tacotron2_modules :members: :undoc-members: :show-inheritance: @@ -19,7 +19,7 @@ Tacotron 2 模块 Waveglow 模块 ------------------ -.. automodule:: nemo_tts.waveglow_modules +.. automodule:: nemo.collections.tts.waveglow_modules :members: :undoc-members: :show-inheritance: diff --git a/docs/docs_zh/sources/source/conf.py b/docs/docs_zh/sources/source/conf.py index faa8502da823..b8220000049e 100644 --- a/docs/docs_zh/sources/source/conf.py +++ b/docs/docs_zh/sources/source/conf.py @@ -25,11 +25,6 @@ sys.path.insert(0, os.path.abspath(".")) sys.path.insert(0, os.path.abspath("../../../")) -sys.path.insert(0, os.path.abspath("../../../nemo/nemo")) -sys.path.insert(0, os.path.abspath("../../../collections")) -sys.path.insert(0, os.path.abspath("../../../collections/nemo_asr")) -sys.path.insert(0, os.path.abspath("../../../collections/nemo_nlp")) -# sys.path.insert(0, os.path.abspath("../../../collections/nemo_lpr")) # ---- Mocking up the classes. ----- MOCK_CLASSES = {'Dataset': 'torch.utils.data', 'Module': 'torch.nn'} @@ -63,6 +58,7 @@ def __getattr__(cls, name): 'h5py', 'kaldi_io', 'transformers', + 'transformers.tokenization_bert', ] sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) diff --git a/docs/sources/source/collections/nemo_asr.rst b/docs/sources/source/collections/nemo_asr.rst index ae1765070e20..95d2e53779a2 100644 --- a/docs/sources/source/collections/nemo_asr.rst +++ b/docs/sources/source/collections/nemo_asr.rst @@ -1,9 +1,9 @@ -NeMo_ASR collection +NeMo ASR collection =================== Speech data processing modules ------------------------------ -.. automodule:: nemo_asr.data_layer +.. automodule:: nemo.collections.asr.data_layer :members: :undoc-members: :show-inheritance: @@ -11,7 +11,7 @@ Speech data processing modules Automatic Speech Recognition modules ------------------------------------ -.. automodule:: nemo_asr.jasper +.. automodule:: nemo.collections.asr.jasper :members: :undoc-members: :show-inheritance: diff --git a/docs/sources/source/collections/nemo_nlp.rst b/docs/sources/source/collections/nemo_nlp.rst index b0ddc62c4f8e..8c862d84fb66 100644 --- a/docs/sources/source/collections/nemo_nlp.rst +++ b/docs/sources/source/collections/nemo_nlp.rst @@ -1,48 +1,47 @@ -NeMo_NLP collection +NeMo NLP collection =================== NLP data processing modules --------------------------- -.. automodule:: nemo_nlp.data_layers +.. automodule:: nemo.collections.nlp.data.datasets :members: :undoc-members: :show-inheritance: - :exclude-members: forward NLP Tokenizers -------------- -.. automodule:: nemo_nlp.data.tokenizers.bert_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.bert_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.char_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.char_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.gpt2_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.gpt2_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.spc_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.sentencepiece_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.tokenizer_spec +.. automodule:: nemo.collections.nlp.data.tokenizers.tokenizer_spec :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.word_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.word_tokenizer :members: :undoc-members: :show-inheritance: -.. automodule:: nemo_nlp.data.tokenizers.yttm_tokenizer +.. automodule:: nemo.collections.nlp.data.tokenizers.youtokentome_tokenizer :members: :undoc-members: :show-inheritance: @@ -50,27 +49,51 @@ NLP Tokenizers NLP Neural Modules ------------------ -.. automodule:: nemo_nlp.modules.classifiers +.. automodule:: nemo.collections.nlp.nm.data_layers :members: :undoc-members: :show-inheritance: :exclude-members: forward -.. automodule:: nemo_nlp.modules.losses +.. automodule:: nemo.collections.nlp.nm.losses :members: :undoc-members: :show-inheritance: :exclude-members: forward -.. automodule:: nemo_nlp.modules.pytorch_utils +.. automodule:: nemo.collections.nlp.nm.trainables.common.sequence_classification_nm :members: :undoc-members: :show-inheritance: :exclude-members: forward -.. automodule:: nemo_nlp.modules.transformer_nm +.. automodule:: nemo.collections.nlp.nm.trainables.common.sequence_regression_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.common.token_classification_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.common.transformer.transformer_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.dialogue_state_tracking.state_tracking_trade_nm + :members: + :undoc-members: + :show-inheritance: + :exclude-members: forward + +.. automodule:: nemo.collections.nlp.nm.trainables.joint_intent_slot.joint_intent_slot_nm :members: :undoc-members: :show-inheritance: @@ -79,7 +102,7 @@ NLP Neural Modules NLP Hugging Face Neural Modules ------------------------------- -.. automodule:: nemo_nlp.huggingface.bert +.. automodule:: nemo.collections.nlp.nm.trainables.common.huggingface.bert_nm :members: :undoc-members: :show-inheritance: diff --git a/docs/sources/source/collections/nemo_tts.rst b/docs/sources/source/collections/nemo_tts.rst index 958642a2f092..be7a8c7a8d07 100644 --- a/docs/sources/source/collections/nemo_tts.rst +++ b/docs/sources/source/collections/nemo_tts.rst @@ -1,9 +1,9 @@ -NeMo_TTS collection +NeMo TTS collection =================== Speech data processing modules ------------------------------ -.. automodule:: nemo_tts.data_layers +.. automodule:: nemo.collections.tts.data_layers :members: :undoc-members: :show-inheritance: @@ -11,7 +11,7 @@ Speech data processing modules Tacotron 2 modules ------------------ -.. automodule:: nemo_tts.tacotron2_modules +.. automodule:: nemo.collections.tts.tacotron2_modules :members: :undoc-members: :show-inheritance: @@ -19,7 +19,7 @@ Tacotron 2 modules Waveglow modules ------------------ -.. automodule:: nemo_tts.waveglow_modules +.. automodule:: nemo.collections.tts.waveglow_modules :members: :undoc-members: :show-inheritance: diff --git a/docs/sources/source/conf.py b/docs/sources/source/conf.py index 77a048fad9f5..8caeaaede9b5 100644 --- a/docs/sources/source/conf.py +++ b/docs/sources/source/conf.py @@ -25,12 +25,6 @@ sys.path.insert(0, os.path.abspath(".")) sys.path.insert(0, os.path.abspath("../../../")) -sys.path.insert(0, os.path.abspath("../../../nemo/nemo")) -sys.path.insert(0, os.path.abspath("../../../collections")) -sys.path.insert(0, os.path.abspath("../../../collections/nemo_asr")) -sys.path.insert(0, os.path.abspath("../../../collections/nemo_nlp")) -sys.path.insert(0, os.path.abspath("../../../collections/nemo_tts")) -# sys.path.insert(0, os.path.abspath("../../../collections/nemo_lpr")) # ---- Mocking up the classes. ----- MOCK_CLASSES = {'Dataset': 'torch.utils.data', 'Module': 'torch.nn'} @@ -66,6 +60,7 @@ def __getattr__(cls, name): 'h5py', 'kaldi_io', 'transformers', + 'transformers.tokenization_bert', ] sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) diff --git a/examples/image/gan.py b/examples/image/gan.py index 61aee8c252f7..08c43899ef21 100644 --- a/examples/image/gan.py +++ b/examples/image/gan.py @@ -44,7 +44,7 @@ batch_size=batch_size, shuffle=True, train=True, root=args.train_dataset ) -generator = nemo_simple_gan.SimpleGenerator() +generator = nemo_simple_gan.SimpleGenerator(batch_size) discriminator = nemo_simple_gan.SimpleDiscriminator() neg_disc_loss = nemo_simple_gan.DiscriminatorLoss(neg=True) disc_loss = nemo_simple_gan.DiscriminatorLoss() diff --git a/examples/image/resnet50.py b/examples/image/resnet50.py index b6ca608f06b5..92c7e2d4b037 100644 --- a/examples/image/resnet50.py +++ b/examples/image/resnet50.py @@ -54,41 +54,37 @@ optimization_level=nemo.core.Optimization.mxprO0, ) -resnet = neural_factory.get_module( - name="resnet50", params={"placement": device}, collection="torchvision", pretrained=False, -) +resnet = neural_factory.get_module(name="resnet50", params={}, collection="torchvision", pretrained=False) dl_train = neural_factory.get_module( name="ImageFolderDataLayer", collection="torchvision", params={ "batch_size": batch_size, - "input_size": resnet.inputs["x"].axis2type[2].dim, + "input_size": resnet.input_ports["x"].axis2type[2].dim, "shuffle": True, "path": args.data_root + "train", # "path": "/mnt/D1/Data/ImageNet/ImageFolder/train", - "placement": device, }, ) -L_train = neural_factory.get_module(name="CrossEntropyLoss", collection="toys", params={"placement": device}) +L_train = neural_factory.get_module(name="CrossEntropyLoss", collection="toys", params={}) dl_eval = neural_factory.get_module( name="ImageFolderDataLayer", collection="torchvision", params={ "batch_size": batch_size, - "input_size": resnet.inputs["x"].axis2type[2].dim, + "input_size": resnet.input_ports["x"].axis2type[2].dim, "shuffle": False, "is_eval": True, "path": args.data_root + "val", # "path": "/mnt/D1/Data/ImageNet/ImageFolder/val", # "path": "/raid/okuchaiev/Data/ImageNet/ImageFolder/val", - "placement": device, }, ) -L_eval = neural_factory.get_module(name="CrossEntropyLoss", collection="toys", params={"placement": device}) +L_eval = neural_factory.get_module(name="CrossEntropyLoss", collection="toys", params={}) step_per_epoch = int(len(dl_train) / (batch_size * num_gpus)) diff --git a/nemo/collections/simple_gan/gan.py b/nemo/collections/simple_gan/gan.py index 16e83bbdf5c5..cc28d7dad4d9 100644 --- a/nemo/collections/simple_gan/gan.py +++ b/nemo/collections/simple_gan/gan.py @@ -123,8 +123,10 @@ def output_ports(self): ) } - def __init__(self): + def __init__(self, batch_size): super().__init__() + self._batch_size = batch_size + self.layers = torch.nn.Sequential( torch.nn.ConvTranspose2d(64, 128, 3, stride=2), torch.nn.ReLU(),