Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merged old changes from local svn repo into git repo

  • Loading branch information...
commit e6cec423b06a5db5eb69828ce8e0187f68f8a97e 1 parent c735498
@cwidmer cwidmer authored
View
14 src/libshogun/classifier/svm/DomainAdaptationSVM.cpp
@@ -1,11 +1,11 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
- * Written (W) 2007-2009 Christian Widmer
- * Copyright (C) 2007-2009 Max-Planck-Society
+ * Written (W) 2007-2011 Christian Widmer
+ * Copyright (C) 2007-2011 Max-Planck-Society
*/
#include "lib/config.h"
@@ -102,7 +102,7 @@ bool CDomainAdaptationSVM::train(CFeatures* data)
// pre-compute linear term
for (int32_t i=0; i<num_training_points; i++)
{
- lin_term[i] = (- B*(get_label(i) * parent_svm_out->get_label(i)))*train_factor - 1.0;
+ lin_term[i] = train_factor * B * get_label(i) * parent_svm_out->get_label(i) - 1.0;
}
//set linear term for QP
@@ -171,9 +171,9 @@ CLabels* CDomainAdaptationSVM::classify(CFeatures* data)
void CDomainAdaptationSVM::init()
{
- presvm=NULL;
- B=0;
- train_factor=1.0;
+ presvm = NULL;
+ B = 0;
+ train_factor = 1.0;
m_parameters->add((CSGObject**) &presvm, "presvm",
"SVM to regularize against.");
View
10 src/libshogun/classifier/svm/DomainAdaptationSVM.h
@@ -1,11 +1,11 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
- * Written (W) 2007-2009 Christian Widmer
- * Copyright (C) 2007-2009 Max-Planck-Society
+ * Written (W) 2007-2011 Christian Widmer
+ * Copyright (C) 2007-2011 Max-Planck-Society
*/
#ifdef USE_SVMLIGHT
@@ -21,7 +21,7 @@
namespace shogun
{
-/** @brief class DomainAdaptiveSVM */
+/** @brief class DomainAdaptationSVM */
class CDomainAdaptationSVM : public CSVMLight
{
public:
@@ -122,5 +122,3 @@ class CDomainAdaptationSVM : public CSVMLight
};
}
#endif
-
-#endif //USE_SVMLIGHT
View
17 src/libshogun/classifier/svm/DomainAdaptationSVMLinear.cpp
@@ -1,11 +1,11 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
- * Written (W) 2007-2010 Christian Widmer
- * Copyright (C) 2007-2010 Max-Planck-Society
+ * Written (W) 2007-2011 Christian Widmer
+ * Copyright (C) 2007-2011 Max-Planck-Society
*/
#include "lib/config.h"
@@ -54,9 +54,9 @@ void CDomainAdaptationSVMLinear::init(CLinearClassifier* pre_svm, float64_t B_pa
pre_svm->set_bias(0.0);
}
- this->presvm=pre_svm;
- this->B=B_param;
- this->train_factor=1.0;
+ this->presvm = pre_svm;
+ this->B = B_param;
+ this->train_factor = 1.0;
set_liblinear_solver_type(L2R_L1LOSS_SVC_DUAL);
@@ -116,6 +116,8 @@ bool CDomainAdaptationSVMLinear::train(CDotFeatures* train_data)
if (presvm)
{
+ ASSERT(presvm->bias == 0.0);
+
// bias of parent SVM was set to zero in constructor, already contains B
CLabels* parent_svm_out = presvm->classify(tmp_data);
@@ -124,7 +126,7 @@ bool CDomainAdaptationSVMLinear::train(CDotFeatures* train_data)
// pre-compute linear term
for (int32_t i=0; i!=num_training_points; i++)
{
- lin_term[i] = (- B*(get_label(i) * parent_svm_out->get_label(i)))*train_factor - 1.0;
+ lin_term[i] = train_factor * B * get_label(i) * parent_svm_out->get_label(i) - 1.0;
}
// set linear term for QP
@@ -133,6 +135,7 @@ bool CDomainAdaptationSVMLinear::train(CDotFeatures* train_data)
}
/*
+ // warm-start liblinear
//TODO test this code, measure speed-ups
//presvm w stored in presvm
float64_t* tmp_w;
View
8 src/libshogun/classifier/svm/DomainAdaptationSVMLinear.h
@@ -1,11 +1,11 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
- * Written (W) 2007-2010 Christian Widmer
- * Copyright (C) 2007-2010 Max-Planck-Society
+ * Written (W) 2007-2011 Christian Widmer
+ * Copyright (C) 2007-2011 Max-Planck-Society
*/
#ifndef _DomainAdaptation_SVM_LINEAR_H___
@@ -21,7 +21,7 @@ namespace shogun
#ifdef HAVE_LAPACK
-/** @brief class DomainAdaptiveSVMLinear */
+/** @brief class DomainAdaptationSVMLinear */
class CDomainAdaptationSVMLinear : public CLibLinear
{
Please sign in to comment.
Something went wrong with that request. Please try again.