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

glossary #999

Merged
merged 4 commits into from Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conf.py
Expand Up @@ -50,6 +50,7 @@
*[p.stem for p in (HERE / "extensions").glob("*.py")],
"sphinx_copybutton",
"sphinx_gallery.load_style",
"sphinx_tabs.tabs",
]

# nbsphinx specific settings
Expand Down
40 changes: 40 additions & 0 deletions docs/user_guide/developer.rst
Expand Up @@ -19,3 +19,43 @@ Model development tutorials
notebooks/module_user_guide
notebooks/model_user_guide


Glossary
--------

.. tabs::

.. tab:: Model

A model class is a user-facing object that contains the module as an attribute (i.e., ``self.module``).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A model class is a user-facing object that contains the module as an attribute (i.e., ``self.module``).
A Model class inherits :class:`~scvi.model.base.BaseModelClass` and is the user-facing object for interacting with a Module.

The model has a `train` method that learns the parameters of the module, and also contains methods
for users to retrieve information from the module, like the latent representation of cells in a VAE.
Conventionally, the post-inference model methods should not store data into the AnnData object, but
instead return "standard" Python objects, like numpy arrays or pandas dataframes.

Comment on lines +31 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The model has a `train` method that learns the parameters of the module, and also contains methods
for users to retrieve information from the module, like the latent representation of cells in a VAE.
Conventionally, the post-inference model methods should not store data into the AnnData object, but
instead return "standard" Python objects, like numpy arrays or pandas dataframes.
The Model has a `train` method that learns the parameters of the Module, and also contains methods
for users to retrieve information from the Module, like the latent representation of cells in a VAE.
Conventionally, a Model's post-inference methods should not store data into the AnnData object, but
instead return "standard" Python objects, like a numpy array or a pandas DataFrame.

.. tab:: Module

A module is the lower-level object that defines a generative model and inference scheme. A module will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A module is the lower-level object that defines a generative model and inference scheme. A module will
A Module is the lower-level object that defines a generative model and inference scheme. A Module will

either inherit :class:`~scvi.module.base.BaseModuleClass` or :class:`~scvi.module.base.PyroBaseModuleClass`.
Consequently, a module can either be implemented with PyTorch alone, or Pyro. In the PyTorch only case, the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Consequently, a module can either be implemented with PyTorch alone, or Pyro. In the PyTorch only case, the
Consequently, a Module can either be implemented with PyTorch alone, or Pyro. In the PyTorch only case, the

generative process and inference scheme are implemented respectively in the `generative` and `inference` methods,
while the `loss` method computes the, e.g, ELBO in the case of variational inference.
adamgayoso marked this conversation as resolved.
Show resolved Hide resolved

.. tabs::

.. tab:: TrainingPlan


The training plan is a PyTorch Lightning Module that is initializd with a scvi-tools module object.
Copy link
Contributor

@galenxing galenxing Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The training plan is a PyTorch Lightning Module that is initializd with a scvi-tools module object.
The TrainingPlan is a PyTorchLightning Module that is initialized with a scvi-tools Module object.

It configures the optimizers, defines the training step and validation step, and computes metrics to be
recorded during training. The training step and validation step are functions that take data, run it through
the model and return the loss, which will then be used to optimize the model parameters in the Trainer.
Overall, training plans can be used to develop complex inference schemes on top of modules.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Overall, training plans can be used to develop complex inference schemes on top of modules.
Overall, child classes of TrainingPlan can be used to develop complex inference schemes on top of modules.



.. tab:: Trainer

The :class:`~scvi.train.Trainer` is a lightweight wrapper of the PyTorch Lightning Trainer. It takes as input
the training plan, a training data loader, and a validation dataloader. It performs the actual training loop, in
which parameters are optimized, as well as the validation loop to monitor metrics. It automatically handles moving
data to the correct device (CPU/GPU).
2 changes: 2 additions & 0 deletions pyproject.toml
Expand Up @@ -64,6 +64,7 @@ scikit-misc = {version = ">=0.1.3", optional = true}
sphinx = {version = ">=3.4", optional = true}
sphinx-autodoc-typehints = {version = "*", optional = true}
sphinx-gallery = {version = ">0.6", optional = true}
sphinx-tabs = {version = "*", optional = true}
sphinx_copybutton = {version = "*", optional = true}
torch = ">=1.7.1"
tqdm = ">=4.56.0"
Expand All @@ -82,6 +83,7 @@ docs = [
"sphinx-autodoc-typehints",
"sphinx_copybutton",
"sphinx_gallery",
"sphinx-tabs",
]
tutorials = ["scanpy", "leidenalg", "python-igraph", "loompy", "scikit-misc"]

Expand Down