Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make evaluate private #1260

Merged
merged 2 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Changed

-
- Made `evalaute` method private >> `Trainer._evaluate(...)`. ([#1260](https://github.com/PyTorchLightning/pytorch-lightning/pull/1260))

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions pytorch_lightning/trainer/evaluation_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def reset_test_dataloader(self, *args):
def reset_val_dataloader(self, *args):
"""Warning: this is just empty shell for code implemented in other class."""

def evaluate(self, model: LightningModule, dataloaders, max_batches: int, test_mode: bool = False):
def _evaluate(self, model: LightningModule, dataloaders, max_batches: int, test_mode: bool = False):
"""Run evaluation code.

Args:
Expand Down Expand Up @@ -365,7 +365,7 @@ def run_evaluation(self, test_mode: bool = False):
setattr(self, f'{"test" if test_mode else "val"}_progress_bar', pbar)

# run evaluation
eval_results = self.evaluate(self.model, dataloaders, max_batches, test_mode)
eval_results = self._evaluate(self.model, dataloaders, max_batches, test_mode)
_, prog_bar_metrics, log_metrics, callback_metrics, _ = self.process_output(
eval_results)

Expand Down
8 changes: 4 additions & 4 deletions pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,10 @@ def run_pretrain_routine(self, model: LightningModule):
# dummy validation progress bar
self.val_progress_bar = tqdm(disable=True)

eval_results = self.evaluate(model,
self.val_dataloaders,
self.num_sanity_val_steps,
False)
eval_results = self._evaluate(model,
self.val_dataloaders,
self.num_sanity_val_steps,
False)
_, _, _, callback_metrics, _ = self.process_output(eval_results)

# close progress bars
Expand Down
4 changes: 2 additions & 2 deletions tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_tbd_remove_in_v1_0_0_model_hooks():

trainer = Trainer(logger=False)
# TODO: why `dataloder` is required if it is not used
result = trainer.evaluate(model, dataloaders=[[None]], max_batches=1)
result = trainer._evaluate(model, dataloaders=[[None]], max_batches=1)
assert result == {'val_loss': 0.6}

model = ModelVer0_7(hparams)
Expand All @@ -106,5 +106,5 @@ def test_tbd_remove_in_v1_0_0_model_hooks():

trainer = Trainer(logger=False)
# TODO: why `dataloder` is required if it is not used
result = trainer.evaluate(model, dataloaders=[[None]], max_batches=1)
result = trainer._evaluate(model, dataloaders=[[None]], max_batches=1)
assert result == {'val_loss': 0.7}