Change config to json

This commit is contained in:
Eren Golge
2018-01-22 08:20:20 -08:00
parent fd18e1cf34
commit 72e1357c80
4 changed files with 42 additions and 59 deletions
Binary file not shown.
+14 -1
View File
@@ -4,9 +4,22 @@ import glob
import time
import shutil
import datetime
import json
import numpy as np
class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
def load_config(config_path):
config = AttrDict()
config.update(json.load(open(config_path, "r")))
return config
def create_experiment_folder(root_path):
""" Create a folder with the current date and time """
date_str = datetime.datetime.now().strftime("%B-%d-%Y_%I:%M%p")
@@ -20,7 +33,7 @@ def remove_experiment_folder(experiment_path):
"""Check folder if there is a checkpoint, otherwise remove the folder"""
checkpoint_files = glob.glob(experiment_path+"/*.pth.tar")
if len(checkpoint_files) == 0:
if len(checkpoint_files) < 2:
shutil.rmtree(experiment_path)
print(" ! Run is removed from {}".format(experiment_path))
else: