Skip to content

Commit a59f351

Browse files
committed
updated readme
1 parent 5e41159 commit a59f351

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ class CoolSystem(pl.LightningModule):
9393
# REQUIRED
9494
x, y = batch
9595
y_hat = self.forward(x)
96-
return {'loss': F.cross_entropy(y_hat, y)}
96+
loss = F.cross_entropy(y_hat, y)
97+
tensorboard_logs = {'train_loss': loss}
98+
return {'loss': loss, 'log': tensorboard_logs}
9799

98100
def validation_step(self, batch, batch_nb):
99101
# OPTIONAL
@@ -104,7 +106,8 @@ class CoolSystem(pl.LightningModule):
104106
def validation_end(self, outputs):
105107
# OPTIONAL
106108
avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()
107-
return {'avg_val_loss': avg_loss}
109+
tensorboard_logs = {'val_loss': avg_loss}
110+
return {'avg_val_loss': avg_loss, 'log': tensorboard_logs}
108111

109112
def configure_optimizers(self):
110113
# REQUIRED
@@ -138,30 +141,27 @@ trainer = Trainer()
138141
trainer.fit(model)
139142
```
140143

141-
Or with tensorboard logger and some options turned on such as multi-gpu, etc...
142-
```python
143-
from test_tube import Experiment
144-
145-
# PyTorch summarywriter with a few bells and whistles
146-
exp = Experiment(save_dir=os.getcwd())
144+
Trainer sets up a tensorboard logger, early stopping and checkpointing by default (you can modify all of them or
145+
use something other than tensorboard).
147146

147+
Here are more advanced examples
148+
```python
148149
# train on cpu using only 10% of the data (for demo purposes)
149-
# pass in experiment for automatic tensorboard logging.
150-
trainer = Trainer(experiment=exp, max_nb_epochs=1, train_percent_check=0.1)
150+
trainer = Trainer(max_nb_epochs=1, train_percent_check=0.1)
151151

152152
# train on 4 gpus (lightning chooses GPUs for you)
153-
# trainer = Trainer(experiment=exp, max_nb_epochs=1, gpus=4)
153+
# trainer = Trainer(max_nb_epochs=1, gpus=4)
154154

155155
# train on 4 gpus (you choose GPUs)
156-
# trainer = Trainer(experiment=exp, max_nb_epochs=1, gpus=[0, 1, 3, 7])
156+
# trainer = Trainer(max_nb_epochs=1, gpus=[0, 1, 3, 7])
157157

158158
# train on 32 gpus across 4 nodes (make sure to submit appropriate SLURM job)
159-
# trainer = Trainer(experiment=exp, max_nb_epochs=1, gpus=8, nb_gpu_nodes=4)
159+
# trainer = Trainer(max_nb_epochs=1, gpus=8, nb_gpu_nodes=4)
160160

161161
# train (1 epoch only here for demo)
162162
trainer.fit(model)
163163

164-
# view tensorflow logs
164+
# view tensorboard logs
165165
print('View tensorboard logs by running\ntensorboard --logdir %s' % os.getcwd())
166166
print('and going to http://localhost:6006 on your browser')
167167
```
@@ -176,7 +176,7 @@ trainer.test()
176176
Everything in gray!
177177
You define the blue parts using the LightningModule interface:
178178

179-
![Ouverview](./docs/source/_static/overview_flat.jpg)
179+
![Overview](./docs/source/_static/overview_flat.jpg)
180180

181181
```python
182182
# what to do in the training loop
@@ -251,12 +251,13 @@ def validation_end(self, outputs):
251251

252252
val_loss_mean /= len(outputs)
253253
val_acc_mean /= len(outputs)
254-
tqdm_dict = {'val_loss': val_loss_mean.item(), 'val_acc': val_acc_mean.item()}
255-
return tqdm_dict
254+
logs = {'val_loss': val_loss_mean.item(), 'val_acc': val_acc_mean.item()}
255+
result = {'log': logs}
256+
return result
256257
```
257258

258259
## Tensorboard
259-
Lightning is fully integrated with tensorboard.
260+
Lightning is fully integrated with tensorboard, MLFlow and supports any logging module.
260261

261262
![tensorboard-support](./docs/source/_static/tf_loss.png)
262263

0 commit comments

Comments
 (0)