update the experiments
authorMart Lubbers <mart@martlubbers.net>
Tue, 25 Apr 2017 17:47:08 +0000 (19:47 +0200)
committerMart Lubbers <mart@martlubbers.net>
Tue, 25 Apr 2017 17:47:08 +0000 (19:47 +0200)
experiments.py

index 708f0ee..adf76b1 100644 (file)
@@ -62,7 +62,7 @@ def features_from_wav(tg, wavp, typ='mfcc', winlen=0.025, winstep=0.01):
         i += 1
     return (data, labels)
 
-def run(typ, winlen, winstep, modelfun):
+def run(typ, winlen, winstep, modelfun, modelname):
     datas = []
     labels = []
 
@@ -91,7 +91,9 @@ def run(typ, winlen, winstep, modelfun):
             verbose=0)
 
     #Test
-    return model.evaluate(testdata, testlabels, batch_size=32, verbose=0)
+    loss, acc = model.evaluate(testdata, testlabels, batch_size=32, verbose=0)
+    print('{}\t{}\t{}\t{}\t{}\n'.format(
+        winlen, winstep, modelname, loss, acc))
 
 def simplemodel(d):
     model = Sequential()
@@ -114,10 +116,7 @@ def bottlemodel(d):
     return model
 
 if __name__ == '__main__':
-    #print(run('mfcc', 0.025, 0.01, simplemodel))
-    #print(run('mfcc', 0.1, 0.04, simplemodel))
-    #print(run('mfcc', 0.2, 0.08, simplemodel))
-
-    print(run('mfcc', 0.025, 0.01, bottlemodel))
-    print(run('mfcc', 0.1, 0.04, bottlemodel))
-    print(run('mfcc', 0.2, 0.08, bottlemodel))
+    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)