Multiple pipelines - training and evaluation (#250)
- introduce best practice for multiple pipelines - Implement evaluation pipeline - allow for using relative ckpt paths - general refactoring - update README.md
This commit is contained in:
1 parent
02d3b65aaa
commit
fe4e61edc1
25 files changed
+347
-185
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from tests.helpers.run_command import run_command
|
||||
from tests.helpers.runif import RunIf
|
||||
|
||||
@@ -8,22 +10,24 @@ A couple of sanity checks to make sure the model doesn't crash with different ru
|
||||
|
||||
def test_fast_dev_run():
|
||||
"""Test running for 1 train, val and test batch."""
|
||||
command = ["run.py", "++trainer.fast_dev_run=true"]
|
||||
command = ["train.py", "++trainer.fast_dev_run=true"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_cpu():
|
||||
"""Test running 1 epoch on CPU."""
|
||||
command = ["run.py", "++trainer.max_epochs=1", "++trainer.gpus=0"]
|
||||
command = ["train.py", "++trainer.max_epochs=1", "++trainer.gpus=0"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
# use RunIf to skip execution of some tests, e.g. when no gpus are available
|
||||
@RunIf(min_gpus=1)
|
||||
@pytest.mark.slow
|
||||
def test_gpu():
|
||||
"""Test running 1 epoch on GPU."""
|
||||
command = [
|
||||
"run.py",
|
||||
"train.py",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.gpus=1",
|
||||
]
|
||||
@@ -31,10 +35,11 @@ def test_gpu():
|
||||
|
||||
|
||||
@RunIf(min_gpus=1)
|
||||
@pytest.mark.slow
|
||||
def test_mixed_precision():
|
||||
"""Test running 1 epoch with pytorch native automatic mixed precision (AMP)."""
|
||||
command = [
|
||||
"run.py",
|
||||
"train.py",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.gpus=1",
|
||||
"++trainer.precision=16",
|
||||
@@ -42,22 +47,11 @@ def test_mixed_precision():
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_limit_batches():
|
||||
"""Test running 1 epoch on 25% of data."""
|
||||
command = [
|
||||
"run.py",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.limit_train_batches=0.25",
|
||||
"++trainer.limit_val_batches=0.25",
|
||||
"++trainer.limit_test_batches=0.25",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_double_validation_loop():
|
||||
"""Test running 1 epoch with validation loop twice per epoch."""
|
||||
command = [
|
||||
"run.py",
|
||||
"train.py",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.val_check_interval=0.5",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import pytest
|
||||
|
||||
from tests.helpers.run_command import run_command
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_debug_default():
|
||||
command = ["train.py", "debug=default"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_debug_limit_batches():
|
||||
command = ["train.py", "debug=limit_batches"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_debug_overfit():
|
||||
command = ["train.py", "debug=overfit"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_debug_profiler():
|
||||
command = ["train.py", "debug=profiler"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_debug_step():
|
||||
command = ["train.py", "debug=step"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_debug_test_only():
|
||||
command = ["train.py", "debug=test_only"]
|
||||
run_command(command)
|
||||
@@ -13,7 +13,7 @@ Use the following command to skip slow tests:
|
||||
@pytest.mark.slow
|
||||
def test_experiments():
|
||||
"""Test running all available experiment configs for 1 epoch."""
|
||||
command = ["run.py", "-m", "experiment=glob(*)", "++trainer.max_epochs=1"]
|
||||
command = ["train.py", "-m", "experiment=glob(*)", "++trainer.max_epochs=1"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def test_experiments():
|
||||
def test_default_sweep():
|
||||
"""Test default Hydra sweeper."""
|
||||
command = [
|
||||
"run.py",
|
||||
"train.py",
|
||||
"-m",
|
||||
"datamodule.batch_size=64,128",
|
||||
"model.lr=0.01,0.02",
|
||||
@@ -35,7 +35,7 @@ def test_default_sweep():
|
||||
def test_optuna_sweep():
|
||||
"""Test Optuna sweeper."""
|
||||
command = [
|
||||
"run.py",
|
||||
"train.py",
|
||||
"-m",
|
||||
"hparams_search=mnist_optuna",
|
||||
"trainer=default",
|
||||
|
||||
Reference in new issue
Block a user