Ejemplo n.º 1
0
def test_Config_multi_output_levels(levels):
    levels_set = list(set(levels))
    str_levels = ",".join(str(s) for s in levels_set)
    parser = argparse.ArgumentParser()
    Config.register_parser(parser)
    args = parser.parse_args(["--multi-output", "--levels", str_levels])
    config = Config.from_args(args)
    assert config.target.levels == levels_set
Ejemplo n.º 2
0
def test_Config_register_parser(args, loss_cls):
    parser = argparse.ArgumentParser()
    Config.register_parser(parser)
    args = parser.parse_args(args)
    config = Config.from_args(args)
    assert isinstance(config, Config)
    assert isinstance(config.target, loss_cls)

    if args.relative_humidity:
        assert config.relative_humidity
    else:
        assert not config.relative_humidity
Ejemplo n.º 3
0
    id_ = pathlib.Path(os.getcwd()).name

    with tf.summary.create_file_writer(f"data/emulator/{id_}").as_default():
        emulator.batch_fit(train_dataset.shuffle(100_000),
                           validation_data=test_dataset)

    train_scores = emulator.score(train_dataset)
    test_scores = emulator.score(test_dataset)

    if config.output_path:
        os.makedirs(config.output_path, exist_ok=True)

    with open(os.path.join(config.output_path, "scores.json"), "w") as f:
        json.dump({"train": train_scores, "test": test_scores}, f)

    emulator.dump(os.path.join(config.output_path, "model"))

    if config.wandb_logger:
        model = wandb.Artifact(f"model", type="model")
        model.add_dir(os.path.join(config.output_path, "model"))
        wandb.log_artifact(model)


if __name__ == "__main__":
    parser = get_parser()
    args = parser.parse_args()
    config = Config.from_args(args)
    print(config)
    main(config)