mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-08-29 11:24:59 +08:00
* hparams as dict * hparams as dict * fixing * fixing * fixing * fixing * typing * typing * chnagelog * update set hparams * use setter * simplify * chnagelog * imports * pylint * typing * Update training_io.py * Update training_io.py * Update lightning.py * Update test_trainer.py * Update __init__.py * Update base.py * Update utils.py * Update test_trainer.py * Update training_io.py * Update test_trainer.py * Update test_trainer.py * Update test_trainer.py * Update test_trainer.py * Update callback_config.py * Update callback_config.py * Update test_trainer.py Co-authored-by: William Falcon <waf2107@columbia.edu>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""Models for testing."""
|
|
|
|
import torch
|
|
|
|
from .base import TestModelBase, DictHparamsModel
|
|
from .mixins import (
|
|
LightEmptyTestStep,
|
|
LightValidationStepMixin,
|
|
LightValidationMixin,
|
|
LightValidationStepMultipleDataloadersMixin,
|
|
LightValidationMultipleDataloadersMixin,
|
|
LightTestStepMixin,
|
|
LightTestMixin,
|
|
LightTestStepMultipleDataloadersMixin,
|
|
LightTestMultipleDataloadersMixin,
|
|
LightTestFitSingleTestDataloadersMixin,
|
|
LightTestFitMultipleTestDataloadersMixin,
|
|
LightValStepFitSingleDataloaderMixin,
|
|
LightValStepFitMultipleDataloadersMixin,
|
|
LightTrainDataloader,
|
|
LightTestDataloader,
|
|
)
|
|
|
|
|
|
class LightningTestModel(LightTrainDataloader,
|
|
LightValidationMixin,
|
|
LightTestMixin,
|
|
TestModelBase):
|
|
"""Most common test case. Validation and test dataloaders."""
|
|
|
|
def on_training_metrics(self, logs):
|
|
logs['some_tensor_to_test'] = torch.rand(1)
|
|
|
|
|
|
class LightningTestModelWithoutHyperparametersArg(LightningTestModel):
|
|
""" without hparams argument in constructor """
|
|
|
|
def __init__(self):
|
|
import tests.models.utils as tutils
|
|
|
|
# the user loads the hparams in some other way
|
|
hparams = tutils.get_hparams()
|
|
super().__init__(hparams)
|
|
|
|
|
|
class LightningTestModelWithUnusedHyperparametersArg(LightningTestModelWithoutHyperparametersArg):
|
|
""" has hparams argument in constructor but is not used """
|
|
|
|
def __init__(self, hparams):
|
|
super().__init__()
|