From 0cb86b6ebbcf0c7b468f8ece33c5364c3a8751c8 Mon Sep 17 00:00:00 2001
From: Guillaume HEUSCH <guillaume.heusch@idiap.ch>
Date: Fri, 19 Oct 2018 15:30:47 +0200
Subject: [PATCH] hack to prevent libSVM to crach

---
 bob/pad/base/algorithm/SVM.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/bob/pad/base/algorithm/SVM.py b/bob/pad/base/algorithm/SVM.py
index 9d72554..5c1498c 100644
--- a/bob/pad/base/algorithm/SVM.py
+++ b/bob/pad/base/algorithm/SVM.py
@@ -277,6 +277,12 @@ class SVM(Algorithm):
 
             machine = trainer.train(data)  # train the machine
 
+            # TODO: find a proper way to handle this - Guillaume HEUSCH, 08-08-2018
+            if machine.shape[0] != data[0].shape[1]:
+              data[0] += 1
+              data[1] += 1
+              machine = trainer.train(data)  # train the machine
+
             precision_cv = self.comp_prediction_precision(
                 machine, np.copy(real_cv), np.copy(attack_cv))
 
@@ -369,6 +375,12 @@ class SVM(Algorithm):
         del attack
 
         machine = trainer.train(data)  # train the machine
+        # TODO: find a proper way to handle this - Guillaume HEUSCH, 08-08-2018
+        if machine.shape[0] != data[0].shape[1]:
+            data[0] += 1
+            data[1] += 1
+            print("training again ...")
+            machine = trainer.train(data)  # train the machine
 
         if mean_std_norm_flag:
             machine.input_subtract = features_mean  # subtract the mean of train data
-- 
GitLab