Beispiel #1
0
    def test16_retrain_average(self):
        shutil.rmtree(OUTPUT_DIR, ignore_errors=True)

        args = [
            "--data-dir",
            DATA_BIN,
            "--output-dir",
            OUTPUT_DIR,
            "--model-dir",
            MODEL_DIR,
            "--tags",
            "CLI_tests",
            "--lr",
            "0.3",
            "--epochs",
            "5",
            "--log-every",
            "10",
            "--new-classes",
            "IN:GET_LOCATION,IN:GET_LOCATION_HOME,SL:POINT_ON_MAP,SL:CATEGORY_LOCATION",
            "--batch-size",
            "16",
            "--no-lr-scheduler",
            "--average-checkpoints",
            "--new-model-weight",
            "1",
        ]

        args = retrain.parse_args(args)
        retrain.main(args)
Beispiel #2
0
    def test18_retrain_weight_consolidation(self):
        shutil.rmtree(OUTPUT_DIR, ignore_errors=True)

        args = [
            "--data-dir",
            DATA_BIN,
            "--output-dir",
            OUTPUT_DIR,
            "--model-dir",
            MODEL_DIR,
            "--tags",
            "CLI_tests",
            "--lr",
            "0.3",
            "--epochs",
            "5",
            "--log-every",
            "10",
            "--new-classes",
            "IN:GET_LOCATION,IN:GET_LOCATION_HOME,SL:POINT_ON_MAP,SL:CATEGORY_LOCATION",
            "--batch-size",
            "16",
            "--weight-consolidation",
            "0.1",
        ]

        args = retrain.parse_args(args)
        retrain.main(args)
Beispiel #3
0
    def test15_retrain_simple_no_sched(self):
        shutil.rmtree(OUTPUT_DIR, ignore_errors=True)

        args = [
            "--data-dir",
            DATA_BIN,
            "--output-dir",
            OUTPUT_DIR,
            "--model-dir",
            MODEL_DIR,
            "--tags",
            "CLI_tests",
            "--lr",
            "0.3",
            "--epochs",
            "1",
            "--log-every",
            "10",
            "--new-classes",
            "IN:GET_LOCATION,IN:GET_LOCATION_HOME,SL:POINT_ON_MAP,SL:CATEGORY_LOCATION",
            "--batch-size",
            "16",
            "--no-lr-scheduler",
        ]

        args = retrain.parse_args(args)
        retrain_simple.check_args(args)
        args = retrain_simple.set_default_args(args)

        retrain_simple.main(args)
Beispiel #4
0
    def test14_retrain_limit_iters(self):
        shutil.rmtree(OUTPUT_DIR, ignore_errors=True)

        args = [
            "--data-dir",
            DATA_BIN,
            "--output-dir",
            OUTPUT_DIR,
            "--model-dir",
            MODEL_DIR,
            "--tags",
            "CLI_tests",
            "--epochs",
            "1",
            "--min-steps",
            "3",
            "--max-steps",
            "10",
            "--new-classes",
            "IN:GET_LOCATION,IN:GET_LOCATION_HOME,SL:POINT_ON_MAP,SL:CATEGORY_LOCATION",
            "--label-smoothing",
            "0.18",
        ]

        args = retrain.parse_args(args)
        retrain.main(args)
Beispiel #5
0
    def test06_retrain_old_data001_merge(self):
        shutil.rmtree(OUTPUT_DIR, ignore_errors=True)

        args = [
            "--data-dir",
            DATA_BIN,
            "--output-dir",
            OUTPUT_DIR,
            "--model-dir",
            MODEL_DIR,
            "--tags",
            "CLI_tests",
            "--epochs",
            "1",
            "--new-classes",
            "IN:GET_LOCATION,IN:GET_LOCATION_HOME,SL:POINT_ON_MAP,SL:CATEGORY_LOCATION",
            "--old-data-amount",
            "0.01",
            "--early-stopping",
            "16",
            "--old-data-sampling-method",
            "merge_subset",
        ]

        args = retrain.parse_args(args)
        retrain.main(args)
Beispiel #6
0
    def test05_retrain_noargs(self):
        shutil.rmtree(OUTPUT_DIR, ignore_errors=True)

        args = [
            "--data-dir",
            DATA_BIN,
            "--output-dir",
            OUTPUT_DIR,
            "--model-dir",
            MODEL_DIR,
            "--tags",
            "CLI_tests",
            "--epochs",
            f"{EPOCHS}",
            "--new-classes",
            "IN:GET_LOCATION,IN:GET_LOCATION_HOME,SL:POINT_ON_MAP,SL:CATEGORY_LOCATION",
        ]

        args = retrain.parse_args(args)
        retrain.main(args)
    logger.info(description)
    wandb_logger.log_metrics({
        **final_metrics["means"],
        **final_metrics["stdevs"]
    })

    # Compute RI and RD
    class_weights = eval_dataset.get_class_frequencies(schema_tokenizer)
    class_weights = {
        f"cls/eval_{cls}_tree_path_f1": p
        for cls, p in class_weights.items()
    }

    finetuning_metrics = cli_utils.evaluate_finetuning_procedure(
        pretrain_metrics, final_metrics, class_weights)
    wandb_logger.log_metrics(finetuning_metrics)

    wandb_logger.close()

    if args.clean_output:
        shutil.rmtree(args.output_dir)


if __name__ == "__main__":
    args = cli_retrain.parse_args()
    check_args(args)
    args = set_default_args(args)

    main(args)