Saving a Model in OPENAI Baselines

ops/2024/10/24 7:22:01/
aidu_pl">

题意:在OPENAI Baselines中保存模型

问题背景:

Openai Baselines save the trained model with the following command,

OpenAI Baselines 使用以下命令保存训练好的模型:

python -m baselines.run --alg=ppo2 --env=PongNoFrameskip-v4 --num_timesteps=2e7 --save_path=~/models/pong_20M_ppo2

But the saved trained model is not in the form of,

但是保存的训练模型并不是以下形式:

.ckpt.meta
.ckpt.index
.ckpt.data
checkpoint

which it was in this form in the earlier versions. How can we save the model as .ckpt.meta, .ckpt.index, .ckpt.data and checkpoint format?

在早期版本中模型是以这种形式保存的。我们如何将模型保存为 .ckpt.meta、.ckpt.index、.ckpt.data 和检查点格式?

问题解决:

I've encountered the same problem and I've solved the problem by making a little adjustment to the baselines code.

“我遇到了同样的问题,并通过对 baselines 代码进行一些小调整解决了这个问题。”

There are two pairs of methods in baselines for saving and loading models(the save_state&load_state pair and the save_variables&loas_variables pair) and you can see it in baselines/common/tf_util.py(line325~line372).

baselines 中有两对用于保存和加载模型的方法(save_stateload_state 这一对,以及 save_variablesload_variables 这一对),你可以在 baselines/common/tf_util.py 文件的第 325 行到第 372 行看到这些方法。

For the latest version of baselines, the save_state&load_state pair which saves and loads models in the .ckpt.meta, .ckpt.index, .ckpt.data and checkpoint format has been abandoned, so you need to re-enable the save_state&load_state pair.

在最新版本的 baselines 中,save_stateload_state 这对用于以 .ckpt.meta、.ckpt.index、.ckpt.data 和检查点格式保存和加载模型的方法已被弃用,因此你需要重新启用 save_stateload_state 这对方法。

Take ppo2 for example, in baselines/ppo2/model.py, make the following replacement: in line 125, replace

“以 ppo2 为例,在 `baselines/ppo2/model.py` 文件中,进行以下替换:在第 125 行,将”

self.save = functools.partial(save_variables, sess=sess)
self.load = functools.partial(load_variables, sess=sess)

with  用以下语句替换

self.save = functools.partial(save_state, sess=sess)
self.load = functools.partial(load_state, sess=sess)

and in line 4, replace        将第4行的以下语句

from baselines.common.tf_util import get_session, save_variables, load_variables

with        用以下语句替换

from baselines.common.tf_util import get_session, save_state, load_state

this will replace the save_variables&loas_variables pair with the save_state&load_state pair.

“这将把 `save_variables` 和 `load_variables` 这对方法替换为 `save_state` 和 `load_state` 这对方法。”

hope this would help you.        希望对你有帮助.


http://www.ppmy.cn/ops/95336.html

相关文章

基于Spring Boot的装饰工程管理系统

TOC springboot176基于Spring Boot的装饰工程管理系统 第1章 绪论** 1.1 课题背景 二十一世纪互联网的出现,改变了几千年以来人们的生活,不仅仅是生活物资的丰富,还有精神层次的丰富。在互联网诞生之前,地域位置往往是人们思想…

瑞数6补环境的总结1

瑞数6补环境的总结1 大家好呀,我是你们的好兄弟【星云牛马】,今天给大家带来的是瑞数6的补环境的总结,补环境肯定是需要一些基础补环境知识的,所以建议没有基础的小伙伴可以加入学习群进行学习,有基础的伙伴加入交流起…

如何备份Linux整个系统

如何备份Linux整个系统 备份整个 Linux 系统是确保数据安全的重要步骤。你可以使用多种方法来实现这一目标,包括使用系统自带工具、第三方备份软件以及专业的备份解决方案。以下是几种常见的方法及其详细步骤: 1. 使用 rsync 进行增量备份 rsync 是一种常用的文件同步工具…

西安国际数字影像产业园作为一个数字创意孵化园的实际情况怎么样?

在科技飞速发展的今天,数字创意产业正迅速崛起,成为全球经济的新增长点。西安国际数字影像产业园作为中国西部数字创意产业的领军者,凭借其独特的优势和发展策略,迅速崭露头角,成为全国瞩目的焦点。那么,是…

Ai音频文件转文字工具 会议音频转文字 录音转文字提取工具 下载

工具基于Ai模型,进行语音音频转文字,进行文字提取,功能强大好用,识别准确率还不错 运行速度取决于音频文件的时长及电脑的性能,音频越长则需要的时间越长,耐心等待即可 使用视频示例如下: Ai语…

Java基础——注释

在开发中注释是必不可少的,帮助我们更好的标记阅读代码,下面介绍几种常用的注释方式。 一、注释种类 1. 单行注释 使用//一行代码来进行注释,只能注释一行内容 2. 多行注释 使用斜杠星号的方式 /*注释多行代码*/,注释多行代…

Unity协程WaitForSeconds在编辑器和WebGL表现不同问题的解决方法参考

最近做的一个效果让下面为了让下面这种图片生成一个翻页效果(使用ShaderGraph中的FlipBook节点),我通过携程来实现连续翻页。 先是定义一个Coroutine coroutine null; 然后在一定情况下执行coroutine StartCoroutine(KeepPrevie…

【Datawhale AI夏令营第四期】 魔搭-大模型应用开发方向笔记 Task02 精读BaseLine代码

【Datawhale AI夏令营第四期】 魔搭-大模型应用开发方向笔记 Task02 学习BaseLine代码 Task02学习链接: https://linklearner.com/activity/14/11/30 学习期间听了开营仪式,在老师的介绍下才发现跑完BaseLine以后学习手册还有后半部分的知识&#xff0c…