当前位置: 首页>>代码示例>>Python>>正文


Python observers.FileStorageObserver方法代码示例

本文整理汇总了Python中sacred.observers.FileStorageObserver方法的典型用法代码示例。如果您正苦于以下问题:Python observers.FileStorageObserver方法的具体用法?Python observers.FileStorageObserver怎么用?Python observers.FileStorageObserver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sacred.observers的用法示例。


在下文中一共展示了observers.FileStorageObserver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _clean_video_directory_structure

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def _clean_video_directory_structure(observer_obj):
    """
    A simple utility method to take saved videos within a Sacred run structure and clean
    up the file pathways, so that all videos are organized under a "videos" directory

    :param observer_obj: A Sacred FileStorageObserver object
    :return: None
    """
    basedir = observer_obj.dir
    video_files = glob.glob("{}/*.mp4".format(basedir))
    metadata_files = glob.glob("{}/*metadata.json".format(basedir))
    if len(video_files) == 0:
        return

    new_video_dir = os.path.join(basedir, "videos")
    os.mkdir(new_video_dir)
    new_video_metadata_dir = os.path.join(new_video_dir, "metadata")
    os.mkdir(new_video_metadata_dir)
    for video_file in video_files:
        base_file_name = os.path.basename(video_file)
        os.rename(video_file, os.path.join(new_video_dir, base_file_name))

    for metadata_file in metadata_files:
        base_file_name = os.path.basename(metadata_file)
        os.rename(metadata_file, os.path.join(new_video_metadata_dir, base_file_name)) 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:27,代码来源:score_agent.py

示例2: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "tsne_fit"))
    fit_model_ex.observers.append(observer)
    fit_model_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:fit_model.py

示例3: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "tsne"))
    tsne_ex.observers.append(observer)
    tsne_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:pipeline.py

示例4: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "tsne_visualize"))
    visualize_ex.observers.append(observer)
    visualize_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:visualize.py

示例5: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "generate_activations"))
    generate_activations_ex.observers.append(observer)
    generate_activations_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:generate_activations.py

示例6: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "density_fit"))
    fit_model_ex.observers.append(observer)
    fit_model_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:fit_density.py

示例7: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "score"))
    score_ex.observers.append(observer)
    score_ex.run_commandline()
    score_ex_logger.info("Sacred run completed, files stored at {}".format(observer.dir)) 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:7,代码来源:score_agent.py

示例8: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(os.path.join("data", "sacred", "visualize_score"))
    visualize_score_ex.observers.append(observer)
    visualize_score_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:scores.py

示例9: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "plot_noisy_observations"))
    plot_noisy_obs_exp.observers.append(observer)
    plot_noisy_obs_exp.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:noisy_observations.py

示例10: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "make_videos"))
    make_videos_ex.observers.append(observer)
    make_videos_ex.run_commandline()
    make_videos_logger.info("Sacred run completed, files stored at {}".format(observer.dir)) 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:7,代码来源:make_videos.py

示例11: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "train"))
    train_ex.observers.append(observer)
    train_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:train.py

示例12: train_rl

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def train_rl(base_config, tune_config, reporter):
    """Run a aprl.train experiment with specified config, logging to reporter.

    :param base_config: (dict) default config
    :param tune_config: (dict) overrides values in base_config
    :param reporter: (ray.tune.StatusReporter) Ray Tune internal logger."""
    common_worker.fix_sacred_capture()

    # train_ex is not pickleable, so we cannot close on it.
    # Instead, import inside the function.
    from aprl.train import train_ex

    config = dict(base_config)
    tune_config = common_worker.flatten_config(tune_config)
    common_worker.update(config, tune_config)
    tune_kv_str = "-".join([f"{k}={v}" for k, v in tune_config.items()])
    config["exp_name"] = config["exp_name"] + "-" + tune_kv_str

    output_format = ReporterOutputFormat(reporter)
    config["log_output_formats"] = [output_format]

    # We're breaking the Sacred interface by running an experiment from within another experiment.
    # This is the best thing we can do, since we need to run the experiment with varying configs.
    # Just be careful: this could easily break things.
    observer = observers.FileStorageObserver(osp.join("data", "sacred", "train"))

    train_ex.observers.append(observer)
    train_ex.run(config_updates=config)
    reporter(done=True, **output_format.last_kvs) 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:31,代码来源:train_worker.py

示例13: score_worker

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def score_worker(base_config, tune_config, reporter):
    """Run a aprl.score experiment with specified config, logging to reporter.

    :param base_config: (dict) default config
    :param tune_config: (dict) overrides values in base_config
    :param reporter: (ray.tune.StatusReporter) Ray Tune internal logger."""
    common_worker.fix_sacred_capture()

    # score_ex is not pickleable, so we cannot close on it.
    # Instead, import inside the function.
    from aprl.score_agent import score_ex

    config = dict(base_config)
    tune_config = common_worker.flatten_config(tune_config)
    common_worker.update(config, tune_config)

    # We're breaking the Sacred interface by running an experiment from within another experiment.
    # This is the best thing we can do, since we need to run the experiment with varying configs.
    # Just be careful: this could easily break things.
    observer = observers.FileStorageObserver(osp.join("data", "sacred", "score"))
    score_ex.observers.append(observer)
    run = score_ex.run(config_updates=config)
    index_keys = config.get("index_keys", [])

    idx = {
        k: v
        for k, v in config.items()
        if k.startswith("agent") or k == "env_name" or k in index_keys
    }

    reporter(done=True, score=run.result, idx=idx) 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:33,代码来源:score_worker.py

示例14: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "multi_score"))
    multi_score_ex.observers.append(observer)
    multi_score_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:score.py

示例15: main

# 需要导入模块: from sacred import observers [as 别名]
# 或者: from sacred.observers import FileStorageObserver [as 别名]
def main():
    observer = FileStorageObserver(osp.join("data", "sacred", "multi_train"))
    multi_train_ex.observers.append(observer)
    multi_train_ex.run_commandline() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:6,代码来源:train.py


注:本文中的sacred.observers.FileStorageObserver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。