def execute(): from tutils import trans_args, trans_init, load_yaml, dump_yaml import argparse parser = argparse.ArgumentParser() parser.add_argument("--config", default="ablation.yaml") args = trans_args(parser) logger, config = trans_init(args) ablation_trainer = AblationTrainer(logger, config) ablation_trainer.run()
def template(_file_name): from tutils import trans_args, trans_init, load_yaml, dump_yaml import argparse parser = argparse.ArgumentParser() parser.add_argument("--config", default="ablation.yaml") args = trans_args(parser) logger, config = trans_init(args) if config['ablation']['is']: # Check opts to do ablation ablation_trainer = AblationTrainer(logger, config) ablation_trainer.run_train() ablation_trainer.run_test()
def usage(): from tutils import trans_args, trans_init, print_dict args = trans_args() print(args) logger, config = trans_init(args) print(" ---------------------------------------------------------") print_dict(config) metriclogger = MetricLogger(logger=None) for data in metriclogger.log_every(range(20), print_freq=2, header="[trans]"): i = 0 metriclogger.update(**{"ind": i, "data": data}) results = metriclogger.return_final_dict()
**config['training']) if args.pretrain: model.load() model.cuda() else: trainer.fit(model, dataset) def test(self, logger, config, args): model = Learner(config, logger) epoch = args.epoch pth = tfilename(config['runs_dir'], f"model_epoch_{epoch}.pth") model.load(pth) model.cuda() tester_train = Tester(logger, config, mode="Train") tester_test = Tester(logger, config, mode="Test1+2") logger.info(f"Dataset Training") tester_train.test(model) logger.info(f"Dataset Test 1+2") tester_test.test(model) if __name__ == '__main__': parser = argparse.ArgumentParser() args = trans_args(parser) logger, config = trans_init(args) save_script(config['base']['runs_dir'], __file__) function_manager = FunctionManager() # getattr(function_manager, args.func)(logger, config, args) function_manager.run_function(logger, config, args)