added min accuracy to models test

This commit is contained in:
William Falcon
2019-07-24 08:53:00 -04:00
parent 6ad542e2b6
commit 5f810275c9
2 changed files with 24 additions and 1 deletions
+8
View File
@@ -264,6 +264,14 @@ class Trainer(TrainerIO):
return tqdm_dic
@property
def tng_tqdm_dic(self):
"""
Read-only for tqdm metrics
:return:
"""
return self.__tng_tqdm_dic
def __layout_bookeeping(self):
# training bookeeping
self.total_batch_nb = 0
+16 -1
View File
@@ -3,10 +3,15 @@ from pytorch_lightning import Trainer
from pytorch_lightning.examples.new_project_templates.lightning_module_template import LightningTemplateModel
from argparse import Namespace
from test_tube import Experiment
import numpy as np
import warnings
import torch
import os
SEED = 2334
torch.manual_seed(SEED)
np.random.seed(SEED)
def get_model():
root_dir = os.path.dirname(os.path.realpath(__file__))
@@ -26,6 +31,10 @@ def get_exp():
exp = Experiment(debug=True)
return exp
def assert_ok_acc(trainer):
# this model should get 0.80+ acc
assert trainer.tng_tqdm_dic['val_acc'] > 0.80
def test_cpu_model():
model = get_model()
@@ -38,10 +47,11 @@ def test_cpu_model():
result = trainer.fit(model)
metrics = result.__tng_tqdm_dic
metrics = trainer.tng_tqdm_dic
print(metrics)
assert result == 1
assert_ok_acc(trainer)
def test_single_gpu_model():
@@ -66,6 +76,7 @@ def test_single_gpu_model():
result = trainer.fit(model)
assert result == 1
assert_ok_acc(trainer)
def test_multi_gpu_model_dp():
@@ -93,6 +104,7 @@ def test_multi_gpu_model_dp():
result = trainer.fit(model)
assert result == 1
assert_ok_acc(trainer)
def test_multi_gpu_model_ddp():
@@ -121,6 +133,7 @@ def test_multi_gpu_model_ddp():
result = trainer.fit(model)
assert result == 1
assert_ok_acc(trainer)
def test_amp_gpu_ddp():
@@ -150,6 +163,7 @@ def test_amp_gpu_ddp():
result = trainer.fit(model)
assert result == 1
assert_ok_acc(trainer)
def test_amp_gpu_dp():
@@ -179,6 +193,7 @@ def test_amp_gpu_dp():
result = trainer.fit(model)
assert result == 1
assert_ok_acc(trainer)
if __name__ == '__main__':