(self, C_train, C_test)
| 26 | |
| 27 | class Tester(object): |
| 28 | def __init__(self, C_train, C_test): |
| 29 | train_config = edict(C_train.config['common']) |
| 30 | ginfo = C_train.ginfo |
| 31 | config = train_config |
| 32 | |
| 33 | if C_test.config.get('common') is not None: |
| 34 | recursive_update(config, C_test.config.get('common')) |
| 35 | config = edict(config) |
| 36 | if 'out_dir' in config: |
| 37 | self.out_dir = config['out_dir']+'test_results/' |
| 38 | else: |
| 39 | self.out_dir = "./test_results/" |
| 40 | |
| 41 | if 'expname' in config: |
| 42 | self.tb_path = '{}events/{}'.format(self.out_dir, config['expname']) |
| 43 | self.ckpt_path = '{}checkpoints/{}'.format(self.out_dir, config['expname']) |
| 44 | self.logs_path = '{}logs/{}'.format(self.out_dir, config['expname']) |
| 45 | else: |
| 46 | save_path = config.get('save_path', os.path.dirname(os.path.abspath(C_train.config_file))) |
| 47 | self.save_path = save_path |
| 48 | self.tb_path = '{}/test_results/events'.format(save_path) |
| 49 | self.ckpt_path = '{}/test_results/checkpoints'.format(save_path) |
| 50 | self.logs_path = '{}/test_results/logs'.format(save_path) |
| 51 | if C_train.rank == 0: |
| 52 | os.makedirs(self.tb_path, exist_ok=True) |
| 53 | os.makedirs(self.ckpt_path, exist_ok=True) |
| 54 | os.makedirs(self.logs_path, exist_ok=True) |
| 55 | self.tb_logger = SummaryWriter(self.tb_path) |
| 56 | else: |
| 57 | while not os.path.exists(self.logs_path): |
| 58 | time.sleep(1) |
| 59 | |
| 60 | if ginfo.task_rank == 0: |
| 61 | self.logger = create_logger('global_logger', '{}/log_task_{}.txt'.format(self.logs_path, ginfo.task_id)) |
| 62 | |
| 63 | self.sync = config.get('sync', True) |
| 64 | self.C_train = C_train |
| 65 | self.C_test = C_test |
| 66 | self.config = config |
| 67 | self.ginfo = ginfo |
| 68 | |
| 69 | # change tensor .cuda |
| 70 | change_tensor_cuda() |
| 71 | |
| 72 | self.tmp = edict() |
| 73 | |
| 74 | ## random seed setting |
| 75 | rng = np.random.RandomState(self.config.get('random_seed', 0)) |
| 76 | self.randomseed_pool = rng.randint(999999, size=config.max_iter) |
| 77 | |
| 78 | def create_dataset(self): |
| 79 | ginfo = self.ginfo |
nothing calls this directly
no test coverage detected