1 Star 0 Fork 0

焦建军/good_robot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
subsample_gr_data.py 898 Bytes
一键复制 编辑 原始数据 按行查看 历史
esteng 提交于 2021-05-28 10:44 . analysis experiments
import pathlib
import numpy as np
import pickle as pkl
original = pathlib.Path("/srv/local1/estengel/gr_data")
out_dir = pathlib.Path("/srv/local1/estengel/gr_subsets")
for perc in [10, 20, 30, 40, 50, 60, 70, 80, 90]:
for pkl_name in original.glob("*/*.pkl"):
with open(pkl_name, 'rb') as f1:
data = pkl.load(f1)
data_len = len(data)
perc_float = perc/100
subset_n = int(data_len * perc_float)
subset_idxs = np.random.choice(data_len, size = subset_n, replace=False)
subset_data = [data[idx] for idx in subset_idxs]
out_name = out_dir.joinpath(f"{perc}")
parent_name = pkl_name.parent.name
out_name = out_name.joinpath(parent_name).joinpath("with_actions.pkl")
out_name.parent.mkdir(parents=True)
with open(out_name, "wb") as f1:
pkl.dump(subset_data, f1)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jiaojianjun-com/good_robot.git
git@gitee.com:jiaojianjun-com/good_robot.git
jiaojianjun-com
good_robot
good_robot
master

搜索帮助