commit d20bc216b29903a6fa9e7a98b79349b02b4f5a2e
parent 1f2dd395d6133edb3375e836d93ad919b5020e28
Author: Étienne Simon <esimon@esimon.eu>
Date:   Mon,  5 May 2014 13:14:00 +0200
Do not fork to train a single model
Diffstat:
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/meta_model.py b/meta_model.py
@@ -63,11 +63,14 @@ class Meta_model(object):
 
     def train(self):
         """ Train the model. """
-        threads = [ threading.Thread(target=model.train, args=()) for model in self.models ]
-        for (model, thread) in zip(self.models, threads):
-            log('# Starting thread for model {0}\n'.format(model.tag))
-            thread.start()
-        log('# Waiting for children to join\n')
-        for thread in threads:
-            thread.join()
-        log('# All children joined\n')
+        if len(self.models)==1:
+            self.models[0].train()
+        else:
+            threads = [ threading.Thread(target=model.train, args=()) for model in self.models ]
+            for (model, thread) in zip(self.models, threads):
+                log('# Starting thread for model {0}\n'.format(model.tag))
+                thread.start()
+            log('# Waiting for children to join\n')
+            for thread in threads:
+                thread.join()
+            log('# All children joined\n')