Esempio n. 1
0
def local_experiment(args: Namespace) -> None:
    try:
        from determined import experimental, load
    except ImportError as e:
        print("--local requires that the `determined` package is installed.")
        raise e

    if not args.test_mode:
        raise NotImplementedError(
            "Local training mode (--local mode without --test mode) is not yet supported. Please "
            "try local test mode by adding the --test flag or cluster training mode by removing "
            "the --local flag.")

    experiment_config = _parse_config_file_or_exit(args.config_file)

    # Python typically initializes sys.path[0] as the empty string when
    # invoked interactively, which directs Python to search modules in the
    # current directory first. However, this is _not_ happening when this
    # Python function is invoked via the cli. We add it manually here so
    # that test_one_batch can import the entrypoint by changing the
    # directory to model_def.
    #
    # Reference: https://docs.python.org/3/library/sys.html#sys.path

    with experimental._local_execution_manager(args.model_def.resolve()):
        trial_class = load.load_trial_implementation(
            experiment_config["entrypoint"])
        sys.path = [""] + sys.path
        experimental.test_one_batch(trial_class=trial_class,
                                    config=experiment_config)
Esempio n. 2
0
def test_test_one_batch() -> None:
    with experimental._local_execution_manager(
            pathlib.Path(pytorch_xor_model.__file__).parent):
        experimental.test_one_batch(
            trial_class=pytorch_xor_model.XORTrial,
            config={
                "hyperparameters": {
                    "hidden_size": 2,
                    "learning_rate": 0.5,
                    "global_batch_size": 4
                }
            },
        )