This commit is contained in:
William Falcon
2019-10-19 00:39:45 +02:00
committed by GitHub
parent 6111edaf82
commit c1bbc2158f
2 changed files with 36 additions and 7 deletions
@@ -143,10 +143,15 @@ def training_step(self, batch, batch_nb):
out = self.forward(x)
loss = self.loss(out, x)
logger_logs = {'training_loss': loss} # optional (MUST ALL BE TENSORS)
# if using TestTubeLogger or TensorboardLogger you can nest scalars
logger_logs = {'losses': logger_logs} # optional (MUST ALL BE TENSORS)
output = {
'loss': loss, # required
'progress_bar': {'training_loss': loss}, # optional (MUST ALL BE TENSORS)
'log': {'training_loss': loss} # optional (MUST ALL BE TENSORS)
'log': logger_logs
}
# return a dict
+30 -6
View File
@@ -33,7 +33,10 @@ Lightning supports several common experiment tracking frameworks out of the box
---
#### Test tube
Log using [test tube](https://williamfalcon.github.io/test-tube/).
Log using [test tube](https://williamfalcon.github.io/test-tube/). Test tube logger is
a strict subclass of [PyTorch SummaryWriter](https://pytorch.org/docs/stable/tensorboard.html), refer to their
documentation for all supported operations. The TestTubeLogger adds a nicer folder structure
to manage experiments and snapshots all hyperparameters you pass to a LightningModule.
```{.python}
from pytorch_lightning.logging import TestTubeLogger
@@ -46,6 +49,16 @@ tt_logger = TestTubeLogger(
trainer = Trainer(logger=tt_logger)
```
Use the logger anywhere in you LightningModule as follows:
```python
def train_step(...):
# example
self.logger.experiment.whatever_method_summary_writer_supports(...)
def any_lightning_module_function_or_hook(...):
self.logger.experiment.add_histogram(...)
```
---
#### MLFlow
@@ -60,6 +73,16 @@ mlf_logger = MLFlowLogger(
trainer = Trainer(logger=mlf_logger)
```
Use the logger anywhere in you LightningModule as follows:
```python
def train_step(...):
# example
self.logger.experiment.whatever_ml_flow_supports(...)
def any_lightning_module_function_or_hook(...):
self.logger.experiment.whatever_ml_flow_supports(...)
```
---
#### Custom logger
@@ -101,13 +124,14 @@ a pull request to add it to Lighting!
#### Using loggers
You can call the logger anywhere from your LightningModule by doing:
```python
self.logger
# add an image if using TestTubeLogger
self.logger.experiment.add_image(...)
def train_step(...):
# example
self.logger.experiment.whatever_method_summary_writer_supports(...)
def any_lightning_module_function_or_hook(...):
self.logger.experiment.add_histogram(...)
```
#### Display metrics in progress bar
``` {.python}
# DEFAULT