mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-12 12:40:20 +08:00
dataloaders with fast_dev_run (#1787)
* dataloaders with fast_dev_run * dataloaders with fast_dev_run * dataloaders with fast_dev_run * fix * pep 8
This commit is contained in:
@@ -173,7 +173,7 @@ class GAN(LightningModule):
|
||||
# log sampled images
|
||||
sample_imgs = self(z)
|
||||
grid = torchvision.utils.make_grid(sample_imgs)
|
||||
self.logger.experiment.add_image(f'generated_images', grid, self.current_epoch)
|
||||
self.logger.experiment.add_image('generated_images', grid, self.current_epoch)
|
||||
|
||||
|
||||
def main(hparams):
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.saving import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`model_saving` module has been renamed to `saving` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.saving import * # noqa: F403
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.lightning import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`root_module` module has been renamed to `lightning` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.lightning import * # noqa: F403
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.loggers import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`logging` package has been renamed to `loggers` since v0.7.0"
|
||||
" The deprecated package name will be removed in v0.9.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.loggers import * # noqa: F403
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.loggers.comet import CometLogger # noqa: F403
|
||||
|
||||
rank_zero_warn("`logging.comet` module has been renamed to `loggers.comet` since v0.7.0."
|
||||
" The deprecated module name will be removed in v0.9.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.loggers.comet import CometLogger # noqa: F403
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.loggers.mlflow import MLFlowLogger # noqa: F403
|
||||
|
||||
rank_zero_warn("`logging.mlflow` module has been renamed to `loggers.mlflow` since v0.7.0."
|
||||
" The deprecated module name will be removed in v0.9.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.loggers.mlflow import MLFlowLogger # noqa: F403
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.loggers.neptune import NeptuneLogger # noqa: F403
|
||||
|
||||
rank_zero_warn("`logging.neptune` module has been renamed to `loggers.neptune` since v0.7.0."
|
||||
" The deprecated module name will be removed in v0.9.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.loggers.neptune import NeptuneLogger # noqa: F403
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.loggers.test_tube import TestTubeLogger # noqa: F403
|
||||
|
||||
rank_zero_warn("`logging.test_tube` module has been renamed to `loggers.test_tube` since v0.7.0."
|
||||
" The deprecated module name will be removed in v0.9.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.loggers.test_tube import TestTubeLogger # noqa: F403
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.loggers.wandb import WandbLogger # noqa: F403
|
||||
|
||||
rank_zero_warn("`logging.wandb` module has been renamed to `loggers.wandb` since v0.7.0."
|
||||
" The deprecated module name will be removed in v0.9.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.loggers.wandb import WandbLogger # noqa: F403
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.overrides.data_parallel import ( # noqa: F402
|
||||
get_a_var, parallel_apply, LightningDataParallel, LightningDistributedDataParallel)
|
||||
|
||||
rank_zero_warn("`override_data_parallel` module has been renamed to `data_parallel` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.overrides.data_parallel import ( # noqa: F402
|
||||
get_a_var, parallel_apply, LightningDataParallel, LightningDistributedDataParallel)
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.decorators import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`root_module.decorators` module has been renamed to `core.decorators` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.decorators import * # noqa: F403
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.grads import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`root_module.grads` module has been renamed to `core.grads` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.grads import * # noqa: F403
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.hooks import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`root_module.hooks` module has been renamed to `core.hooks` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.hooks import * # noqa: F403
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.memory import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`root_module.memory` module has been renamed to `core.memory` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.memory import * # noqa: F403
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.saving import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`root_module.model_saving` module has been renamed to `core.saving` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.saving import * # noqa: F403
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"""
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_warn
|
||||
from pytorch_lightning.core.lightning import * # noqa: F403
|
||||
|
||||
rank_zero_warn("`root_module.root_module` module has been renamed to `core.lightning` since v0.6.0."
|
||||
" The deprecated module name will be removed in v0.8.0.", DeprecationWarning)
|
||||
|
||||
from pytorch_lightning.core.lightning import * # noqa: F403
|
||||
|
||||
@@ -90,7 +90,7 @@ class TrainerOptimizersMixin(ABC):
|
||||
for scheduler in schedulers:
|
||||
if isinstance(scheduler, dict):
|
||||
if 'scheduler' not in scheduler:
|
||||
raise ValueError(f'Lr scheduler should have key `scheduler`',
|
||||
raise ValueError('Lr scheduler should have key `scheduler`',
|
||||
' with item being a lr scheduler')
|
||||
scheduler['reduce_on_plateau'] = isinstance(
|
||||
scheduler['scheduler'], optim.lr_scheduler.ReduceLROnPlateau)
|
||||
|
||||
@@ -136,7 +136,7 @@ class TrainerTrainingTricksMixin(ABC):
|
||||
raise MisconfigurationException(f'Field {batch_arg_name} not found in `model.hparams`')
|
||||
|
||||
if hasattr(model.train_dataloader, 'patch_loader_code'):
|
||||
raise MisconfigurationException(f'The batch scaling feature cannot be used with dataloaders'
|
||||
raise MisconfigurationException('The batch scaling feature cannot be used with dataloaders'
|
||||
' passed directly to `.fit()`. Please disable the feature or'
|
||||
' incorporate the dataloader into the model.')
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import tests.base.utils as tutils
|
||||
def test_training_epoch_end_metrics_collection(tmpdir):
|
||||
""" Test that progress bar metrics also get collected at the end of an epoch. """
|
||||
num_epochs = 3
|
||||
|
||||
class CurrentModel(EvalModelTemplate):
|
||||
|
||||
def training_step(self, *args, **kwargs):
|
||||
|
||||
@@ -11,6 +11,42 @@ from pytorch_lightning.utilities.exceptions import MisconfigurationException
|
||||
from tests.base import EvalModelTemplate
|
||||
|
||||
|
||||
def test_fit_train_loader_only(tmpdir):
|
||||
|
||||
model = EvalModelTemplate()
|
||||
train_dataloader = model.train_dataloader()
|
||||
|
||||
model.train_dataloader = None
|
||||
model.val_dataloader = None
|
||||
model.test_dataloader = None
|
||||
|
||||
model.validation_step = None
|
||||
model.validation_epoch_end = None
|
||||
|
||||
model.test_step = None
|
||||
model.test_epoch_end = None
|
||||
|
||||
trainer = Trainer(fast_dev_run=True, default_root_dir=tmpdir)
|
||||
trainer.fit(model, train_dataloader=train_dataloader)
|
||||
|
||||
|
||||
def test_fit_val_loader_only(tmpdir):
|
||||
|
||||
model = EvalModelTemplate()
|
||||
train_dataloader = model.train_dataloader()
|
||||
val_dataloader = model.val_dataloader()
|
||||
|
||||
model.train_dataloader = None
|
||||
model.val_dataloader = None
|
||||
model.test_dataloader = None
|
||||
|
||||
model.test_step = None
|
||||
model.test_epoch_end = None
|
||||
|
||||
trainer = Trainer(fast_dev_run=True, default_root_dir=tmpdir)
|
||||
trainer.fit(model, train_dataloader=train_dataloader, val_dataloaders=val_dataloader)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dataloader_options", [
|
||||
dict(train_percent_check=-0.1),
|
||||
dict(train_percent_check=1.1),
|
||||
|
||||
Reference in New Issue
Block a user