log_sub_dirs = [name for name in os.listdir(os.path.join(root_dir, "logs")) if name.isdecimal()]
if log_sub_dirs and param.starting_iter==0:
log_sub_dir = str(max([int(name) for name in log_sub_dirs])+1)
elif log_sub_dirs and param.starting_iter > 0:
log_sub_dir = str(max([int(name) for name in log_sub_dirs if os.path.isdir(os.path.join(root_dir, "logs", name))]))
else:
log_sub_dir = "0"
writer = tf.summary.FileWriter(os.path.join(root_dir, "logs", log_sub_dir),