製作雲圖數據集

import pickle
import numpy as np
import random
#讀取採集的背景數據,數據形式爲Nonex28x28x4
others = np.load('/home/xm/桌面/make_dataset/others.npy')
index_1 = random.sample(list(range(others.shape[0])),others.shape[0])
others = others[index_1]
others = others[:5000]
#讀取採集的薄雲數據,數據形式爲Nonex28x28x4
thin = np.load('/home/xm/桌面/make_dataset/thin_cloud.npy')
index_2 = random.sample(list(range(thin.shape[0])),thin.shape[0])
thin = thin[index_2]
thin = thin[:5000]
thin = np.load('/home/xm/桌面/make_dataset/thin_cloud.npy')
index_2 = random.sample(list(range(thin.shape[0])),thin.shape[0])
thin = thin[index_2]
thin = thin[:5000]
#讀取採集的厚雲數據,數據形式爲Nonex28x28x4
thick = np.load('/home/xm/桌面/make_dataset/thick_cloud.npy')
index_3 = random.sample(list(range(thick.shape[0])),thick.shape[0])
thick = thick[index_3]
thick = thick[:5000]
#讀取採集的雪數據,數據形式爲Nonex28x28x4
snow = np.load('/home/xm/桌面/make_dataset/snow.npy')
index_4 = random.sample(list(range(snow.shape[0])),snow.shape[0])
snow = snow[index_4]
snow = snow[:5000]
#將讀取的數據拼接起來,數據形式爲Nonex28x28x4
total_data = np.concatenate((others,thin,thick,snow),axis=0)
#製作各個類型雲圖的數據標籤
others_label = np.zeros([5000,1])
thin_label   = np.ones([5000,1])
thick_label  = np.ones([5000,1])*2
total_label  = np.concatenate((others_label,thin_label,thick_label,snow_label),axis=0)
index = random.sample(list(range(total_data.shape[0])),total_data.shape[0])
all_data = total_data[index]
all_label = total_label[index]
#分別製作訓練數據集,測試數據集
train_data = all_data[:16000]
test_data = all_data[16000:]
train_label = all_label[:16000]
test_label = all_label[16000:]
dataset = train_data,train_label,test_data,test_label
np.save('/home/xm/桌面/dataset11000.npy',dataset)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章