国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 林口县| 东方市| 修文县| 临西县| 武宣县| 静乐县| 女性| 葵青区| 盐源县| 珲春市| 松阳县| 唐河县| 宁远县| 印江| 正定县| 金湖县| 贵溪市| 唐山市| 乐昌市| 宜都市| 安吉县| 峨眉山市| 武夷山市| 南溪县| 舟山市| 潞西市| 利辛县| 塘沽区| 福建省| 枞阳县| 宝丰县| 永安市| 五寨县| 积石山| 大冶市| 星座| 互助| 江源县| 建宁县| 荔浦县| 新余市|