def test_ealstm(self): config_file = Path("tests") / "test_config/test_config_ealstm.yml" cfg = read_config(config_file) # check that initialisation works model = EALSTM(cfg) # trainer object trainer = RegressionTrainer(cfg) trainer.initialize_training() trainer.train_and_validate() # tester object time_now = time.gmtime() expt_name = cfg["experiment_name"] run_dir = max([ p for p in Path("runs").glob( f"{expt_name}_{time_now.tm_mday:02}{time_now.tm_mon:02}*") ]) assert run_dir.exists() tester = Tester(cfg, run_dir) epoch = int( sorted(list( run_dir.glob("*.pt")))[-1].name.split("epoch")[-1].replace( ".pt", "")) tester.evaluate(epoch=epoch, save_results=True, metrics=cfg.get("metrics", [])) assert (run_dir / "test/model_epoch002/test_results.p").exists() # analysis object (-> csv) create_results_csv(run_dir=run_dir, epoch=epoch) assert (run_dir / f"results_{run_dir.name}_E002.csv").exists
def eval_run(args: dict): config_file = Path(args["run_dir"]) / "config.yml" config = read_config(config_file) start_evaluation(cfg=config, run_dir=Path(args["run_dir"]), epoch=args["epoch"])
def test_cudalstm(self): config_file = Path("tests") / "test_config/test_config.yml" cfg = read_config(config_file) model = CudaLSTM(cfg) # trainer object trainer = RegressionTrainer(cfg) trainer.initialize_training() trainer.train_and_validate()
def start_run(args: dict): config_file = Path(args["config_file"]) config = read_config(config_file) print(f"### Run configurations for {config['experiment_name']}") for key, val in config.items(): print(f"{key}: {val}") start_training(config)
def test_base(self): config_file = Path("tests") / "test_config/test_config.yml" cfg = read_config(config_file) model = BaseModel(cfg)
def test_base(self): config_file = Path("tests") / "test_config/test_config.yml" cfg = read_config(config_file) trainer = BaseTrainer(cfg)
def test_cudalstm(self): config_file = Path("tests") / "test_config/test_config.yml" cfg = read_config(config_file) trainer = RegressionTrainer(cfg)
all_dfs.append(valid_df) # get the obs (ONCE) obs = valid_df["obs"] # rename the sim (for all) all_dfs = [ df.rename(columns={ "sim": f"sim_E{epoch:03}" }).drop(columns="obs") for epoch, df in zip(epochs, all_dfs) ] # join all the simulations df = all_dfs[0] for d in all_dfs[1:]: df = df.join(d) df = df.join(obs) outfile = run_dir / f"all_{run_dir.name}_results.csv" print(f"** ALL Results written to: {outfile}") df.to_csv(outfile) if __name__ == "__main__": args = get_args() run_dir = Path(args["run_dir"]) assert run_dir.exists() config_file = run_dir / "config.yml" cfg = read_config(config_file) analyse_all_epochs(cfg, run_dir)