fix: fix indexing of labels in mfcc json
This commit is contained in:
parent
f022291ced
commit
61e5c74cde
@ -675,7 +675,7 @@ class DL_data_handler:
|
|||||||
mfcc_frame_list.append(mfcc.shape[0])
|
mfcc_frame_list.append(mfcc.shape[0])
|
||||||
|
|
||||||
#data["mfcc"].append(mfcc.tolist())
|
#data["mfcc"].append(mfcc.tolist())
|
||||||
data["labels"].append(key)
|
data["labels"].append(key-1)
|
||||||
print("sample:{} is done".format(i+1))
|
print("sample:{} is done".format(i+1))
|
||||||
|
|
||||||
minimum = min(mfcc_frame_list)
|
minimum = min(mfcc_frame_list)
|
||||||
@ -711,7 +711,7 @@ class DL_data_handler:
|
|||||||
# process all samples per subject
|
# process all samples per subject
|
||||||
for i, sample in enumerate(value):
|
for i, sample in enumerate(value):
|
||||||
|
|
||||||
data["labels"].append(key)
|
data["labels"].append(key-1)
|
||||||
data["mfcc"].append(sample)
|
data["mfcc"].append(sample)
|
||||||
print("sample:{} is done".format(i+1))
|
print("sample:{} is done".format(i+1))
|
||||||
#print(np.array(mfcc_data).shape)
|
#print(np.array(mfcc_data).shape)
|
||||||
|
@ -17,13 +17,12 @@ def load_data(data_path):
|
|||||||
data = json.load(fp)
|
data = json.load(fp)
|
||||||
|
|
||||||
# convert lists to numpy arraysls
|
# convert lists to numpy arraysls
|
||||||
#print('\n', data['mfcc'], '\n')
|
|
||||||
X = np.array(data['mfcc'])
|
X = np.array(data['mfcc'])
|
||||||
|
X = X.reshape(X.shape[0], 1, X.shape[1])
|
||||||
print(X.shape)
|
print(X.shape)
|
||||||
#print((len(X), len(X[0]), len(X[0][0])))
|
|
||||||
#print((len(X), len(X[5]), len(X[5][0])))
|
|
||||||
|
|
||||||
y = np.array(data["labels"])
|
y = np.array(data["labels"])
|
||||||
|
y = y.reshape(y.shape[0], 1)
|
||||||
print(y.shape)
|
print(y.shape)
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +108,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
print(X_train.shape[1], X_train.shape[2])
|
print(X_train.shape[1], X_train.shape[2])
|
||||||
# create network
|
# create network
|
||||||
input_shape = (X_train.shape[1], X_train.shape[2]) # 18, 13
|
|
||||||
|
input_shape = (X_train.shape[1], X_train.shape[2]) # 1, 208
|
||||||
model = build_model(input_shape)
|
model = build_model(input_shape)
|
||||||
|
|
||||||
# compile model
|
# compile model
|
||||||
@ -121,7 +121,7 @@ if __name__ == "__main__":
|
|||||||
model.summary()
|
model.summary()
|
||||||
|
|
||||||
# train model
|
# train model
|
||||||
history = model.fit(X_train, y_train, validation_data=(X_validation, y_validation), batch_size=100, epochs=30)
|
history = model.fit(X_train, y_train, validation_data=(X_validation, y_validation), batch_size=128, epochs=30)
|
||||||
|
|
||||||
# plot accuracy/error for training and validation
|
# plot accuracy/error for training and validation
|
||||||
plot_history(history)
|
plot_history(history)
|
||||||
@ -131,3 +131,4 @@ if __name__ == "__main__":
|
|||||||
print('\nTest accuracy:', test_acc)
|
print('\nTest accuracy:', test_acc)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ def main():
|
|||||||
csv_handler.load_data('soft')
|
csv_handler.load_data('soft')
|
||||||
dl_data_handler = DL_data_handler(csv_handler)
|
dl_data_handler = DL_data_handler(csv_handler)
|
||||||
dl_data_handler.store_mfcc_samples()
|
dl_data_handler.store_mfcc_samples()
|
||||||
dl_data_handler.save_json_reg()
|
dl_data_handler.save_json_mfcc()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
dict = dl_data_handler.get_mfcc_samples_dict()
|
dict = dl_data_handler.get_mfcc_samples_dict()
|
||||||
|
Binary file not shown.
1576
mfcc_data.json
1576
mfcc_data.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user