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 module config docs #393

Merged
merged 6 commits into from
Feb 21, 2020
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
8 changes: 4 additions & 4 deletions docs/sources/source/tutorials/module_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Let us start by creating the :class:`NeuralFactory` object and instatiating the

.. literalinclude:: ../../../../examples/start_here/module_configuration.py
:language: python
:lines: 20-33
:lines: 25-35

Now we can export the configuration of any of the existing modules by using the :meth:`export_to_config()`, for \
example we can export the configuration of the trainable :class:`TaylorNet` by calling:

.. literalinclude:: ../../../../examples/start_here/module_configuration.py
:language: python
:lines: 36
:lines: 38

Importing the configuration
---------------------------
Expand All @@ -37,7 +37,7 @@ There is an analogical function :meth:`import_from_config()` responsible for loa

.. literalinclude:: ../../../../examples/start_here/module_configuration.py
:language: python
:lines: 39
:lines: 41

.. note::
The :meth:`import_from_config()` function actually creates a new instance of object of the class that was stored \
Expand All @@ -49,7 +49,7 @@ For example, we can build a graph and train it with a NeMo trainer:

.. literalinclude:: ../../../../examples/start_here/module_configuration.py
:language: python
:lines: 41-
:lines: 43-


.. include:: module_custom_configuration.rst
Expand Down
12 changes: 6 additions & 6 deletions docs/sources/source/tutorials/module_custom_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ and extend it by those methods. But first, let us define a simple :class:`Status

.. literalinclude:: ../../../../examples/start_here/module_custom_configuration.py
:language: python
:lines: 31-33
:lines: 33-35

Now let us define the :class:`CustomTaylorNet` Neural Module class:

.. literalinclude:: ../../../../examples/start_here/module_custom_configuration.py
:language: python
:lines: 36-41
:lines: 38-43


In order to properly handle the export of the :class:`Status` enum we must implement a custom function \
:meth:`export_to_config()`:

.. literalinclude:: ../../../../examples/start_here/module_custom_configuration.py
:language: python
:lines: 43-74
:lines: 45-76


Note that the configuration is actually a dictionary consisting of two sections:
Expand All @@ -44,7 +44,7 @@ Analogically, we must overload the :meth:`import_from_config()` method:

.. literalinclude:: ../../../../examples/start_here/module_custom_configuration.py
:language: python
:lines: 77-117
:lines: 79-119

Please note that the base :class:`NeuralModule` class provides several protected methods that we used, \
with most important being:
Expand All @@ -62,13 +62,13 @@ Now we can simply create an instance and export its configuration by calling:

.. literalinclude:: ../../../../examples/start_here/module_custom_configuration.py
:language: python
:lines: 126-127,132-133
:lines: 128-129,134-135

And instantiate a second by loading that configuration:

.. literalinclude:: ../../../../examples/start_here/module_custom_configuration.py
:language: python
:lines: 135-137
:lines: 137-139

As a result we will see that the new object has set the status to the same value as the original one:

Expand Down