spinningup 绘制曲线

地址 https://spinningup.openai.com/en/latest/user/plotting.html

下载 spinningup

git clone https://github.com/openai/spinningup.git

其实绘制曲线所需要的仅仅是 spiningup/spinup/utils/plot.py 这个文件。最好在 make_plots 函数的最后加一句来保存 pdf

def make_plots(all_logdirs, legend=None, xaxis=None, values=None, count=False,  
               font_scale=1.5, smooth=1, select=None, exclude=None, estimator='mean'):
    data = get_all_datasets(all_logdirs, legend, select, exclude)
    values = values if isinstance(values, list) else [values]
    condition = 'Condition2' if count else 'Condition1'
    estimator = getattr(np, estimator)      # choose what to show on main curve: mean? max? min?
    for value in values:
        plt.figure()
        plot_data(data, xaxis=xaxis, value=value, condition=condition, smooth=smooth, estimator=estimator)
    plt.show()
    plt.savefig('fig.pdf')

数据文件保存形式。

data/
    bench_ours/
        bench_ours-seed0/
        bench_ours-seed1/
        bench_ours-seed2/
        bench_ours-seed3/
        bench_ours-seed4/
    bench_others/
        bench_others-seed0/
        bench_others-seed1/
        bench_others-seed2/
        bench_others-seed3/
        bench_others-seed4/

每个 bench_ours-seed*/ 文件夹下有两个文件

bench_ours-seed0/
	progress.txt
	config.json

其中,config.json 应包含实验名称

{"exp_name": "ours"}

progress.txt 第一行是数据名称,第二行之后是数据。每列数据以 \t 分开

Updates	eplenmean	AverageEpRet	number of episodes	send data fps	send data interval	steps	total steps
0	17.94	-0.1197456899999999	113	414.0	4.946493625640869	2048	999424
1	16.93	-0.68175405	232	524.0	3.901179075241089	4096	999424
2	17.78	0.42339543	346	527.0	3.8832526206970215	6144	999424

做好以上准备后,可以画图了

pip install seaborn==0.8.1
python spinningup/spinup/utils/plot.py data/bench --xaxis 'Updates' --value 'AverageEpRet' --smooth=8

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值