国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python 隨機(jī)打亂 圖片和對應(yīng)的標(biāo)簽方法

2020-02-16 00:08:04
字體:
供稿:網(wǎng)友

如下所示:

# -*- coding: utf-8 -*- import osimport numpy as npimport pandas as pdimport h5pyimport pylabimport matplotlib.pyplot as plt  trainpath = str('C:/Users/49691/Desktop/數(shù)據(jù)集/train/')testpath = str('C:/Users/49691/Desktop/數(shù)據(jù)集/test/')n_tr = len(os.listdir(trainpath))print('num of training files: ', n_tr) train_labels = pd.read_csv('C:/Users/49691/Desktop/數(shù)據(jù)集/sample_submission.csv')train_labels.head() from skimage import io, transform  x = np.empty(shape=(n_tr, 224, 224, 3))y = np.empty(n_tr) labels = train_labels.invasive.valuesname = train_labels.name.values permutation=np.random.permutation(name.shape[0])print(permutation)print(labels[permutation])save_data = pd.DataFrame({'name':permutation,'invasive':labels[permutation]})save_data.to_csv('C:/Users/49691/Desktop/數(shù)據(jù)集/b.csv')  for k,v in enumerate(np.random.permutation(n_tr)): print(k,v) path = '{0}{1}.jpg'.format(trainpath, v) tr_im = io.imread(path) x[k] = transform.resize(tr_im, output_shape=(224, 224, 3)) y[k] = float(labels[v-1])

以上這篇python 隨機(jī)打亂 圖片和對應(yīng)的標(biāo)簽方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持武林站長站。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 土默特右旗| 琼结县| 弋阳县| 定远县| 肥城市| 深水埗区| 卫辉市| 祁阳县| 河曲县| 潞西市| 房产| 沅江市| 淳安县| 昌都县| 昌黎县| 玉树县| 沁阳市| 乌鲁木齐县| 蛟河市| 嫩江县| 无锡市| 卢湾区| 嘉兴市| 乌拉特后旗| 曲沃县| 宜州市| 阜新| 名山县| 普定县| 田东县| 资溪县| 庆安县| 安乡县| 金秀| 高碑店市| 怀柔区| 和平区| 正阳县| 济阳县| 南阳市| 高要市|