Examples: using new API (#1056)

* using new API

* typo
This commit is contained in:
William Falcon
2020-03-05 19:31:57 -05:00
committed by GitHub
parent bb7356bcaa
commit 0ebfb78570
9 changed files with 16 additions and 17 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ Early stopping
Default behavior
----------------
By default early stopping will be enabled if `'val_loss'`
is found in `validation_end()` return dict. Otherwise
is found in `validation_epoch_end()` return dict. Otherwise
training will proceed with early stopping disabled.
Enable Early Stopping
@@ -16,7 +16,7 @@ There are two ways to enable early stopping.
.. code-block:: python
# A) Set early_stop_callback to True. Will look for 'val_loss'
# in validation_end() return dict. If it is not found an error is raised.
# in validation_epoch_end() return dict. If it is not found an error is raised.
trainer = Trainer(early_stop_callback=True)
# B) Or configure your own callback
+1 -1
View File
@@ -87,7 +87,7 @@ Here we show the validation loss in the progress bar
.. code-block:: python
def validation_end(self, outputs):
def validation_epoch_end(self, outputs):
loss = some_loss()
...
+2 -2
View File
@@ -603,7 +603,7 @@ sample split in the `train_dataloader` method.
loss = F.nll_loss(logits, y)
return {'val_loss': loss}
def validation_end(self, outputs):
def validation_epoch_end(self, outputs):
avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()
tensorboard_logs = {'val_loss': avg_loss}
return {'avg_val_loss': avg_loss, 'log': tensorboard_logs}
@@ -657,7 +657,7 @@ Just like the validation loop, we define exactly the same steps for testing:
loss = F.nll_loss(logits, y)
return {'val_loss': loss}
def test_end(self, outputs):
def test_epoch_end(self, outputs):
avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()
tensorboard_logs = {'val_loss': avg_loss}
return {'avg_val_loss': avg_loss, 'log': tensorboard_logs}