Example #1
0
def create_hparams(default_params, hparams_file=None, hparams_str=None):
    hparams = HParams(**default_params)
    if hparams_file is not None:
        with open(hparams_file) as f:
            hparams.parse_json(f.read())
    if hparams_str is not None:
        hparams.parse(hparams_str)
    return hparams
Example #2
0
def load_hparams(model_dir, default_params):
    hparams_path = os.path.join(model_dir, HPARAMS_FILE)
    hparams = HParams(default_params)
    assert os.path.exists(hparams_path)
    with open(hparams_path) as f:
        return hparams.parse_json(f.read())