Skip to content

Instantly share code, notes, and snippets.

@Akaame Akaame/ecs50_2dprepro.py
Last active Feb 4, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.