Skip to content

Instantly share code, notes, and snippets.

@Akaame
Last active February 4, 2018 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akaame/893a09f77c1fd1b2efbee7d4f6591416 to your computer and use it in GitHub Desktop.
Save Akaame/893a09f77c1fd1b2efbee7d4f6591416 to your computer and use it in GitHub Desktop.
import numpy as np
from glob import glob
from keras.utils import to_categorical
file_list = glob("features/*.npy")
trainX = []
trainY = []
idx = 0
category_dict = {}
for filename in file_list:
base = filename.split('.')[0].split('/')[1].lower()
data = np.load(filename).T
# her bir feature icin 6521'e 100 olacak
# 6500'ye 20 olacak sekilde degistirelim
surplus = data.shape[0] % 100
data = data[:-surplus,:]
data = np.reshape(data,[-1,100,1])
# Sekil: 6500, 100, 1
#### Onemli
# Bu satir satir veriyi 2D CNN'e uygun hale getirmemiz gerekiyor
# 6500'e 100'luk bir matrisi 100'e 100'luk 65 matris yapabilirsiniz.
# Ama bu hem veri kumenizi kucultur. Hem de matrisler arasindaki
# zamansal(temporal) iliskiyi kaybetmis olursunuz.""
datax = []
for i in np.arange(0,data.shape[0]-100,20):
datax.append(data[i:i+100]) # Cozum ust uste binmis imgeler olusturmak
datax = np.array(datax)
####
trainX.append(datax)
trainY.extend([idx]*datax.shape[0])
category_dict[idx] = filename
idx+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment