From: Mart Lubbers Date: Sun, 30 Apr 2017 17:24:43 +0000 (+0200) Subject: update X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=3c75bac3c3b5cde96d443fd32c6e47e23cd8dbfc;p=asr1617data.git update --- diff --git a/.gitignore b/.gitignore index 2e8dbe8..2146a79 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ model.* model.* test.txt train.txt +*.hdf5 +*.json diff --git a/experiments.py b/experiments.py index 989643e..699c68c 100644 --- a/experiments.py +++ b/experiments.py @@ -1,18 +1,17 @@ -import sys import pympi -import random import glob import re import os # mfcc -from python_speech_features import mfcc, fbank, logfbank +from python_speech_features import mfcc, logfbank import scipy.io.wavfile as wav import numpy as np -#keras +# keras from keras.models import Sequential from keras.layers import Dense, Dropout # , Activation +from keras import backend # Testset ratio testset = 0.10 @@ -97,6 +96,7 @@ def run(typ, winlen, winstep, modelfun, modelname): verbose=verbosity) print('{}\t{}\t{}\t{}\t{}\n'.format( winlen, winstep, modelname, loss, acc)) + return model def simplemodel(d): model = Sequential() @@ -122,6 +122,11 @@ def bottlemodel(d): if __name__ == '__main__': print('winlen\twinstep\tmodel\tloss\taccuracy\n') - for winlen, winstep in ((0.025, 0.01), (0.1, 0.04), (0.2, 0.08)): - for name, model in (('simple', simplemodel), ('bottle', bottlemodel)): - run('mfcc', winlen, winstep, model, name) + with backend.get_session(): + for winlen, winstep in ((0.025, 0.01), (0.1, 0.04), (0.2, 0.08)): + for name, model in (('simple', simplemodel), ('bottle', bottlemodel)): + m = run('mfcc', winlen, winstep, model, name) + fproot = 'model_{}_{}_{}.json'.format(winlen, winstep, name) + with open('{}.json'.format(fproot), 'w') as f: + f.write(m.to_json()) + m.save_weights('{}.hdf5'.format(fproot))