本文整理汇总了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))
示例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()
示例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()
示例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()
示例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()
示例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()
示例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))
示例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()
示例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()
示例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))
示例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()
示例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)
示例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)
示例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()
示例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()