comparison scripts/map_and_average.py @ 62:4425a4918102 branch-tests

fixed indices for feature components
author Maria Panteli <m.x.panteli@gmail.com>
date Thu, 21 Sep 2017 17:35:07 +0100
parents d118b6ca8370
children
comparison
equal deleted inserted replaced
61:ac3fcd42e7bd 62:4425a4918102
69 ''' 69 '''
70 trainset = load_data_from_pickle(INPUT_FILES[0]) 70 trainset = load_data_from_pickle(INPUT_FILES[0])
71 valset = load_data_from_pickle(INPUT_FILES[1]) 71 valset = load_data_from_pickle(INPUT_FILES[1])
72 testset = load_data_from_pickle(INPUT_FILES[2]) 72 testset = load_data_from_pickle(INPUT_FILES[2])
73 return trainset, valset, testset 73 return trainset, valset, testset
74
75
76 def limit_to_n_seconds(dataset, n_sec=30.0, win_sec=8.0):
77 X, Y, Yaudio = dataset
78 uniq_audio, uniq_counts = np.unique(Yaudio, return_counts=True)
79 frame_sr = 2.0
80 max_n_frames = np.int(np.floor((n_sec - win_sec) * frame_sr))
81 X_new, Y_new, Yaudio_new = [], [], []
82 for audio in uniq_audio:
83 idx = np.where(Yaudio==audio)[0]
84 if len(idx) > max_n_frames:
85 idx = idx[:max_n_frames]
86 X_new.append(X[idx, :])
87 Y_new.append(Y[idx])
88 Yaudio_new.append(Yaudio[idx])
89 return [np.concatenate(X_new), np.concatenate(Y_new), np.concatenate(Yaudio_new)]
74 90
75 91
76 def get_feat_inds(n_dim=840): 92 def get_feat_inds(n_dim=840):
77 '''assume frame with 840 features and return indices for each feature 93 '''assume frame with 840 features and return indices for each feature
78 ''' 94 '''