Skip to content

Commit

Permalink
Merge branch 'master' into feature/4525_decorated-hparams
Browse files Browse the repository at this point in the history
  • Loading branch information
tchaton authored Nov 13, 2020
2 parents 3ef3dab + baa8558 commit 1ce4676
Show file tree
Hide file tree
Showing 21 changed files with 219 additions and 60 deletions.
2 changes: 1 addition & 1 deletion dockers/tpu-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN \
# Install pytorch-lightning at the current PR, plus dependencies.
#pip install -r pytorch-lightning/requirements.txt --no-cache-dir && \
# drop Horovod
#python -c "fname = 'pytorch-lightning/requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] ; open(fname, 'w').writelines(lines)" && \
python -c "fname = 'pytorch-lightning/requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] ; open(fname, 'w').writelines(lines)" && \
pip install -r pytorch-lightning/requirements/devel.txt --no-cache-dir --upgrade-strategy only-if-needed

#RUN python -c "import pytorch_lightning as pl; print(pl.__version__)"
Expand Down
41 changes: 41 additions & 0 deletions docs/source/_templates/autosummary/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{ name | escape | underline }}

.. currentmodule:: {{ fullname }}

{% block functions %}
{% if functions %}
.. rubric:: Functions

.. autosummary::
:nosignatures:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: Classes

.. autosummary::
:nosignatures:
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions

.. autosummary::
:nosignatures:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

.. automodule:: {{ fullname }}
97 changes: 97 additions & 0 deletions docs/source/api_references.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
API References
==============

Core API
--------

.. currentmodule:: pytorch_lightning.core

.. autosummary::
:toctree: api
:nosignatures:

datamodule
decorators
hooks
lightning

Callbacks API
-------------

.. currentmodule:: pytorch_lightning.callbacks

.. autosummary::
:toctree: api
:nosignatures:

base
early_stopping
gpu_stats_monitor
gradient_accumulation_scheduler
lr_monitor
model_checkpoint
progress

Loggers API
-----------

.. currentmodule:: pytorch_lightning.loggers

.. autosummary::
:toctree: api
:nosignatures:

base
comet
csv_logs
mlflow
neptune
tensorboard
test_tube
wandb

Profiler API
------------

.. currentmodule:: pytorch_lightning.profiler

.. autosummary::
:toctree: api
:nosignatures:

profilers

Trainer API
-----------

.. currentmodule:: pytorch_lightning.trainer

.. autosummary::
:toctree: api
:nosignatures:

trainer

Tuner API
---------

.. currentmodule:: pytorch_lightning.tuner

.. autosummary::
:toctree: api
:nosignatures:

batch_size_scaling
lr_finder

Utilities API
-------------

.. currentmodule:: pytorch_lightning.utilities

.. autosummary::
:toctree: api
:nosignatures:

argparse_utils
seed
7 changes: 7 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ PyTorch Lightning Documentation
From PyTorch to PyTorch Lightning [Blog] <https://towardsdatascience.com/from-pytorch-to-pytorch-lightning-a-gentle-introduction-b371b7caaf09>
From PyTorch to PyTorch Lightning [Video] <https://www.youtube.com/watch?v=QHww1JH7IDU>

.. toctree::
:maxdepth: 2
:name: api
:caption: API References

api_references

.. toctree::
:maxdepth: 1
:name: Bolts
Expand Down
61 changes: 22 additions & 39 deletions docs/source/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,44 +293,27 @@ Supported Loggers

The following are loggers we support

Comet
=====

.. autoclass:: pytorch_lightning.loggers.comet.CometLogger
:noindex:

CSVLogger
=========

.. autoclass:: pytorch_lightning.loggers.csv_logs.CSVLogger
:noindex:

MLFlow
======

.. autoclass:: pytorch_lightning.loggers.mlflow.MLFlowLogger
:noindex:

Neptune
=======

.. autoclass:: pytorch_lightning.loggers.neptune.NeptuneLogger
:noindex:

Tensorboard
============

.. autoclass:: pytorch_lightning.loggers.tensorboard.TensorBoardLogger
:noindex:

Test-tube
=========

.. autoclass:: pytorch_lightning.loggers.test_tube.TestTubeLogger
:noindex:
.. note::
The following loggers will normally plot an additional chart (**global_step VS epoch**).

Weights and Biases
==================
.. note::
postfix ``_step`` and ``_epoch`` will be appended to the name you logged
if ``on_step`` and ``on_epoch`` are set to ``True`` in ``self.log()``.

.. autoclass:: pytorch_lightning.loggers.wandb.WandbLogger
:noindex:
.. note::
Depending on the loggers you use, there might be some additional charts.

.. currentmodule:: pytorch_lightning.loggers

.. autosummary::
:toctree: generated
:nosignatures:
:template: classtemplate.rst

CometLogger
CSVLogger
MLFlowLogger
NeptuneLogger
TensorBoardLogger
TestTubeLogger
WandbLogger
2 changes: 1 addition & 1 deletion pytorch_lightning/callbacks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

r"""
Subclass this class and override any of the relevant hooks
Abstract base class used to build new callbacks.
"""

Expand Down
2 changes: 2 additions & 0 deletions pytorch_lightning/core/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""LightningDataModule for loading DataLoaders with ease."""

import functools
import inspect
from abc import abstractmethod
Expand Down
2 changes: 2 additions & 0 deletions pytorch_lightning/core/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Decorator for LightningModule methods."""

from functools import wraps
from typing import Callable

Expand Down
5 changes: 5 additions & 0 deletions pytorch_lightning/core/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Various hooks to be used in the Lightning code."""

from typing import Any, Dict, List, Union

import torch
Expand All @@ -28,6 +30,7 @@


class ModelHooks:
"""Hooks to be used in LightningModule."""
def setup(self, stage: str):
"""
Called at the beginning of fit and test.
Expand Down Expand Up @@ -297,6 +300,7 @@ def on_after_backward(self):


class DataHooks:
"""Hooks to be used with LightningDataModule."""
def prepare_data(self) -> None:
"""
Use this to download and prepare data.
Expand Down Expand Up @@ -556,6 +560,7 @@ def transfer_batch_to_device(self, batch, device)


class CheckpointHooks:
"""Hooks to be used with Checkpointing."""
def on_load_checkpoint(self, checkpoint: Dict[str, Any]) -> None:
r"""
Called by Lightning to restore your model.
Expand Down
3 changes: 3 additions & 0 deletions pytorch_lightning/core/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""nn.Module with additional great features."""

import os
import tempfile
import collections
Expand Down
2 changes: 2 additions & 0 deletions pytorch_lightning/core/step_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""[Train, Eval]Result for easier logging, checkpointing, early stopping, epoch-wise reduction."""

import numbers
from copy import copy
from typing import Optional, Dict, Union, Sequence, Callable, MutableMapping, Any, List, Tuple, Iterable
Expand Down
2 changes: 2 additions & 0 deletions pytorch_lightning/loggers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Abstract base class used to build new loggers."""

import argparse
import functools
import operator
Expand Down
8 changes: 5 additions & 3 deletions pytorch_lightning/loggers/comet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

"""
Comet
-----
Comet Logger
------------
"""

import os
Expand Down Expand Up @@ -53,7 +53,9 @@

class CometLogger(LightningLoggerBase):
r"""
Log using `Comet.ml <https://www.comet.ml>`_. Install it with pip:
Log using `Comet.ml <https://www.comet.ml>`_.
Install it with pip:
.. code-block:: bash
Expand Down
5 changes: 3 additions & 2 deletions pytorch_lightning/loggers/csv_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ def save(self) -> None:

class CSVLogger(LightningLoggerBase):
r"""
Log to local file system in yaml and CSV format. Logs are saved to
``os.path.join(save_dir, name, version)``.
Log to local file system in yaml and CSV format.
Logs are saved to ``os.path.join(save_dir, name, version)``.
Example:
>>> from pytorch_lightning import Trainer
Expand Down
8 changes: 5 additions & 3 deletions pytorch_lightning/loggers/mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

"""
MLflow
------
MLflow Logger
-------------
"""
import re
import warnings
Expand All @@ -39,7 +39,9 @@

class MLFlowLogger(LightningLoggerBase):
"""
Log using `MLflow <https://mlflow.org>`_. Install it with pip:
Log using `MLflow <https://mlflow.org>`_.
Install it with pip:
.. code-block:: bash
Expand Down
8 changes: 5 additions & 3 deletions pytorch_lightning/loggers/neptune.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

"""
Neptune
-------
Neptune Logger
--------------
"""
from argparse import Namespace
from typing import Any, Dict, Iterable, List, Optional, Union
Expand All @@ -36,7 +36,9 @@

class NeptuneLogger(LightningLoggerBase):
r"""
Log using `Neptune <https://neptune.ai>`_. Install it with pip:
Log using `Neptune <https://neptune.ai>`_.
Install it with pip:
.. code-block:: bash
Expand Down
Loading

0 comments on commit 1ce4676

Please sign in to comment.