栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

标签shuffle

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

标签shuffle

载入数据

import numpy as np
import random

input1 = np.load('/root/whq/input/one_hot_1400/xf_p_n.npy')
input2 = np.load('/root/whq/input/one_hot_1400/gf_p_n.npy')
output_ = np.load('/root/whq/input/one_hot_1400/label_p_n_-1.npy')
output_0 = np.load('/root/whq/input/one_hot_1400/label_p_n_0.npy')

shuffle

all = list(zip(input1, input2, output_, output_0)) # 4元元组列表
random.shuffle(all)
input1, input2, output_, output_0 = zip(*all) # 按列拆开,每列->新元组

存为numpy格式

input1 = np.array(list(input1)) # 元组->list->numpy
input2 = np.array(list(input2))
output_ = np.array(list(output_))
output_0 = np.array(list(output_0))

np.save('/root/whq/input/one_hot_1400_shuffle/xf_id.npy', input1)
np.save('/root/whq/input/one_hot_1400_shuffle/gf_id.npy', input2)
np.save('/root/whq/input/one_hot_1400_shuffle/label_p_n_-1.npy', output_)
np.save('/root/whq/input/one_hot_1400_shuffle/label_p_n_0.npy', output_0)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/725568.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号