Compare commits

...
10 Commits
Author SHA1 Message Date
William Falcon b3a846c6cf release v0.4.3 2019-08-10 10:04:00 -04:00
William Falcon 73d08557ba fix accumulated grad norm fixes #87 (#88)
* Update trainer.py

* Update trainer.py

* Update trainer.py

* Update trainer.py

* Update trainer.py

* Update trainer.py

* Update trainer.py
2019-08-10 08:32:45 -04:00
Lorenzo Fabbri 09d4475cc7 Update Checkpointing.md (#83)
* Update Checkpointing.md

Modified import for ModelCheckpoint.

* Update Checkpointing.md
2019-08-09 15:02:36 -04:00
Rich Lewis dd0db4aba2 docs(trainer): fix gradient clipping entry (#85)
- replace copy and paste error
- write brief description
- add link to pytorch docs for specific clipping implementation
- add example configuration
2019-08-09 15:02:14 -04:00
William Falcon 018b8da50e Update issue templates 2019-08-08 14:30:55 -04:00
William Falcon 66c8ed0091 Update README.md 2019-08-08 14:27:47 -04:00
William Falcon 48f0cd0f63 release v0.4.2 2019-08-08 14:23:50 -04:00
William Falcon 0c584a6a13 updated support for 1.2.0 (#80) 2019-08-08 14:05:03 -04:00
William Falcon 44686f74d8 release v0.4.1 2019-08-08 13:08:25 -04:00
William Falcon 011a2f3dd7 release v0.4.1 2019-08-08 13:08:02 -04:00
6 changed files with 27 additions and 24 deletions
+4 -6
View File
@@ -7,6 +7,10 @@ assignees: ''
---
### Common bugs:
1. Tensorboard not showing in Jupyter-notebook see [issue 79](https://github.com/williamFalcon/pytorch-lightning/issues/79).
2. PyTorch 1.1.0 vs 1.2.0 support [see FAQ](https://github.com/williamFalcon/pytorch-lightning#faq)
**Describe the bug**
A clear and concise description of what the bug is.
@@ -28,11 +32,5 @@ If applicable, add screenshots to help explain your problem.
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
+4
View File
@@ -370,6 +370,10 @@ Nope.
**Are there plans to support virtualenv?**
Nope. Please use anaconda or miniconda.
**Which PyTorch versions do you support?**
Lightning 0.4.2+ supports PyTorch 1.2.0.
For PyTorch 1.1.0 install Lightning 0.4.0 with test-tube=0.6.7.6.
## Bleeding edge
If you can't wait for the next release, install the most up to date code with:
```bash
+3 -3
View File
@@ -1,11 +1,11 @@
Lightning can automate saving and loading checkpoints.
i Lightning can automate saving and loading checkpoints.
---
### Model saving
To enable checkpointing, define the checkpoint callback and give it to the trainer.
``` {.python}
from pytorch_lightning.utils.pt_callbacks import ModelCheckpoint
from pytorch_lightning.callbacks import ModelCheckpoint
checkpoint_callback = ModelCheckpoint(
filepath='/path/to/store/weights.ckpt',
@@ -65,4 +65,4 @@ for scheduler, lrs_state in zip(self.lr_schedulers, lr_schedulers):
# uses the model you passed into trainer
model.load_state_dict(checkpoint['state_dict'])
```
```
+7 -4
View File
@@ -28,15 +28,18 @@ trainer = Trainer(enable_early_stop=True)
```
---
#### Gradient Clipping
Use this to turn off early stopping and run training to the [max_epoch](#force-training-for-min-or-max-epochs)
#### Gradient Clipping
Gradient clipping may be enabled to avoid exploding gradients.
Specifically, this will [clip the gradient norm computed over all model parameters *together*](https://pytorch.org/docs/stable/nn.html#torch.nn.utils.clip_grad_norm_).
``` {.python}
# DEFAULT (ie: don't clip)
trainer = Trainer(gradient_clip=0)
# clip gradients with norm above 0.5
trainer = Trainer(gradient_clip=0.5)
```
---
#### Inspect gradient norms
Looking at grad norms can help you figure out where training might be going wrong.
+5 -7
View File
@@ -899,6 +899,9 @@ We recommend you switch to ddp if you want to use amp
self.__add_tqdm_metrics(model_specific_tqdm_metrics_dic)
# accumulate loss (if accumulate_grad_batches = 1 no effect)
loss = loss / self.accumulate_grad_batches
# backward pass
if self.use_amp:
# scale loss when using amp
@@ -918,12 +921,11 @@ We recommend you switch to ddp if you want to use amp
for param in model.parameters():
print(param.grad.float().sum())
# avoid memory leaks
# track total loss for logging (avoid mem leaks)
self.batch_loss_value += loss.item()
# gradient update with accumulated gradients
if (self.batch_nb + 1) % self.accumulate_grad_batches == 0:
# clip gradients
if self.gradient_clip > 0:
model = self.__get_model()
@@ -941,11 +943,7 @@ We recommend you switch to ddp if you want to use amp
# clear gradients
optimizer.zero_grad()
# queuing loss across batches blows it up proportionally...
# divide out the number accumulated
self.batch_loss_value = self.batch_loss_value / self.accumulate_grad_batches
# track loss
# calculate running loss for display
self.running_loss.append(self.batch_loss_value)
self.batch_loss_value = 0
self.avg_loss = np.mean(self.running_loss[-100:])
+4 -4
View File
@@ -9,12 +9,12 @@ from setuptools import setup, find_packages
# https://packaging.python.org/discussions/install-requires-vs-requirements /
# keep the meta-data here for simplicity in reading this file... it's not obvious
# what happens and to non-engineers they won't know to look in init...
# what happens and to non-engineers they won't know to look in init ...
# the goal of the project is simplicity for researchers, don't want to add too much
# engineer specific practices
setup(
name='pytorch-lightning',
version='0.4.0',
version='0.4.3',
description='The Keras for ML researchers using PyTorch',
author='William Falcon',
author_email='waf2107@columbia.edu',
@@ -29,9 +29,9 @@ setup(
keywords=['deep learning', 'pytorch', 'AI'],
python_requires='>=3.6',
install_requires=[
'torch==1.1.0',
'torch==1.2.0',
'tqdm',
'test-tube>=0.6.7.6',
'test-tube==0.6.8',
'pandas>=0.20.3',
],
classifiers=[