Permalink
Browse files

Merge pull request #3590 from abhinavrai44/dev

Modify src/shogun/classifier/ to implement CSignal in outer loops
  • Loading branch information...
2 parents 24884a1 + df26b1e commit 8d499866ac64d41043472a48c5103c2333072f89 @karlnapf karlnapf committed on GitHub Jan 10, 2017
@@ -11,6 +11,7 @@
#include <shogun/labels/Labels.h>
#include <shogun/mathematics/Math.h>
#include <shogun/labels/BinaryLabels.h>
+#include <shogun/lib/Signal.h>
using namespace shogun;
@@ -59,9 +60,11 @@ bool CAveragedPerceptron::train_machine(CFeatures* data)
for (int32_t i=0; i<num_feat; i++)
w[i]=1.0/num_feat;
+ CSignal::clear_cancel();
+
//loop till we either get everything classified right or reach max_iter
- while (!converged && iter<max_iter)
+ while (!(CSignal::cancel_computations()) && (!converged && iter<max_iter))
{
converged=true;
for (int32_t i=0; i<num_vec; i++)
@@ -12,6 +12,7 @@
#include <shogun/labels/Labels.h>
#include <shogun/labels/BinaryLabels.h>
#include <shogun/mathematics/Math.h>
+#include <shogun/lib/Signal.h>
using namespace shogun;
@@ -62,8 +63,10 @@ bool CPerceptron::train_machine(CFeatures* data)
w.vector[i]=1.0/num_feat;
}
+ CSignal::clear_cancel();
+
//loop till we either get everything classified right or reach max_iter
- while (!converged && iter<max_iter)
+ while (!(CSignal::cancel_computations()) && (!converged && iter<max_iter))
{
converged=true;
for (int32_t i=0; i<num_vec; i++)
@@ -17,6 +17,7 @@
#include <shogun/labels/MulticlassLabels.h>
#include <vector>
+#include <shogun/lib/Signal.h>
using namespace shogun;
@@ -369,7 +370,9 @@ bool CMKLMulticlass::train_machine(CFeatures* data)
int32_t numberofsilpiterations=0;
bool final=false;
- while (!final)
+ CSignal::clear_cancel();
+
+ while (!(CSignal::cancel_computations()) && !final)
{
//curweights.clear();
@@ -12,6 +12,7 @@
#include <shogun/io/SGIO.h>
#include <shogun/lib/common.h>
#include <shogun/mathematics/Math.h>
+#include <shogun/lib/Signal.h>
using namespace shogun;
@@ -78,6 +79,7 @@ bool CMPDSVM::train_machine(CFeatures* data)
bool primalcool;
bool dualcool;
+ CSignal::clear_cancel();
//if (nustop)
//etas[1] = 1;
@@ -94,7 +96,7 @@ bool CMPDSVM::train_machine(CFeatures* data)
}
// go ...
- while (niter++ < maxiter)
+ while (niter++ < maxiter && !CSignal::cancel_computations())
{
int32_t maxpidx=-1;
float64_t maxpviol = -1;
@@ -17,6 +17,7 @@
#include <shogun/labels/Labels.h>
#include <shogun/labels/BinaryLabels.h>
#include <shogun/mathematics/lapack.h>
+#include <shogun/lib/Signal.h>
//#define DEBUG_NEWTON
//#define V_NEWTON
@@ -48,6 +49,7 @@ CNewtonSVM::~CNewtonSVM()
bool CNewtonSVM::train_machine(CFeatures* data)
{
+ CSignal::clear_cancel();
ASSERT(m_labels)
ASSERT(m_labels->get_label_type() == LT_BINARY)
@@ -78,7 +80,7 @@ bool CNewtonSVM::train_machine(CFeatures* data)
float64_t obj, *grad=SG_MALLOC(float64_t, x_d+1);
float64_t t;
- while(1)
+ while(!CSignal::cancel_computations())
{
iter++;
@@ -16,6 +16,7 @@
#include <algorithm>
#include <shogun/classifier/vw/VowpalWabbit.h>
#include <fcntl.h>
+#include <shogun/lib/Signal.h>
using namespace std;
using namespace shogun;
@@ -158,8 +159,9 @@ bool CVowpalWabbit::train_machine(CFeatures* feat)
"loss", "last", "counter", "weight", "label", "predict", "features");
}
+ CSignal::clear_cancel();
features->start_parser();
- while (env->passes_complete < env->num_passes)
+ while (!(CSignal::cancel_computations()) && (env->passes_complete < env->num_passes))
{
while (features->get_next_example())
{

0 comments on commit 8d49986

Please sign in to comment.