From 3f7a1eda3d423f30dec7862d5a291beb2a57e720 Mon Sep 17 00:00:00 2001 From: wogong Date: Thu, 5 Sep 2019 16:44:37 +0800 Subject: [PATCH] add config init function, save to experiment's model root. --- experiments/svhn_mnist.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/experiments/svhn_mnist.py b/experiments/svhn_mnist.py index a545535..c053ad9 100644 --- a/experiments/svhn_mnist.py +++ b/experiments/svhn_mnist.py @@ -61,6 +61,12 @@ class Config(object): momentum = 0.9 weight_decay = 1e-6 + def __init__(self): + public_props = (name for name in dir(self) if not name.startswith('_')) + with open(self.config, 'w') as f: + for name in public_props: + f.write(name + ': ' + str(getattr(self, name)) + '\n') + params = Config() logger = SummaryWriter(params.model_root) device = torch.device("cuda:" + params.gpu_id if torch.cuda.is_available() else "cpu")