binary test output in working state

This commit is contained in:
Steffen 2021-03-28 11:49:17 +02:00
parent 76eb567eed
commit 7c88602776
2 changed files with 7 additions and 6 deletions

10
main.py
View File

@ -76,11 +76,11 @@ def run_lightning_loop(h_params :Namespace, data_class, model_class, seed=69, ad
trainer.fit(model, datamodule)
trainer.save_checkpoint(logger.save_dir / 'last_weights.ckpt')
try:
trainer.test(model=model, datamodule=datamodule)
except:
print('Test did not Suceed!')
pass
trainer.test(model=model, datamodule=datamodule)
#except:
# print('Test did not Suceed!')
# pass
logger.log_metrics(score_callback.best_scores, step=trainer.global_step+1)

View File

@ -163,7 +163,8 @@ class TestMixin:
enumerate(['background', 'chimpanze', 'geunon', 'mandrille', 'redcap'])}
else:
pred = torch.stack([x.mean(dim=0) if x.shape[0] > 1 else x for x in sorted_y.values()]).squeeze()
class_names = {val: key for val, key in ['negative', 'positive']}
pred = torch.where(pred > 0.5, 1, 0)
class_names = {val: key for val, key in enumerate(['negative', 'positive'])}
df = pd.DataFrame(data=dict(filename=[Path(x).name for x in sorted_y.keys()],