Permalink
Browse files

Updated PrimalMosekSOSVM

  • Loading branch information...
1 parent f253152 commit ff37c90b9d6c44100cc73e4e95259e29fdbc9cbb @lisitsyn lisitsyn committed Aug 21, 2012
@@ -36,7 +36,7 @@ def gen_data():
model = MulticlassModel(features, labels)
loss = HingeLoss()
-sosvm = PrimalMosekSOSVM(model, loss, labels, features)
+sosvm = PrimalMosekSOSVM(model, loss, labels)
sosvm.train()
out = sosvm.apply()
@@ -24,7 +24,7 @@
features = RealMatrixFeatures(data_dict['signal'].astype(float), 250, 500)
loss = HingeLoss()
model = HMSVMModel(features, labels, SMT_TWO_STATE, 4)
-sosvm = PrimalMosekSOSVM(model, loss, labels, features)
+sosvm = PrimalMosekSOSVM(model, loss, labels)
sosvm.train()
print sosvm.get_w()
predicted = sosvm.apply()
@@ -25,9 +25,8 @@ CPrimalMosekSOSVM::CPrimalMosekSOSVM()
CPrimalMosekSOSVM::CPrimalMosekSOSVM(
CStructuredModel* model,
CLossFunction* loss,
- CStructuredLabels* labs,
- CFeatures* features)
-: CLinearStructuredOutputMachine(model, loss, labs, features)
+ CStructuredLabels* labs)
+: CLinearStructuredOutputMachine(model, loss, labs)
{
}
@@ -42,6 +41,10 @@ CPrimalMosekSOSVM::~CPrimalMosekSOSVM()
bool CPrimalMosekSOSVM::train_machine(CFeatures* data)
{
+ if (data)
+ set_features(data);
+
+ CDotFeatures* model_features = get_features();
// Check that the scenary is correct to start with training
m_model->check_training_setup();
@@ -52,7 +55,7 @@ bool CPrimalMosekSOSVM::train_machine(CFeatures* data)
// Number of auxiliary constraints
int32_t num_aux_con = m_model->get_num_aux_con();
// Number of training examples
- int32_t N = m_features->get_num_vectors();
+ int32_t N = model_features->get_num_vectors();
// Interface with MOSEK
CMosek* mosek = new CMosek(0, M+num_aux+N);
@@ -188,7 +191,7 @@ bool CPrimalMosekSOSVM::train_machine(CFeatures* data)
// Free resources
SG_UNREF(results);
SG_UNREF(mosek);
-
+ SG_UNREF(model_features);
return true;
}
@@ -41,9 +41,8 @@ class CPrimalMosekSOSVM : public CLinearStructuredOutputMachine
* @param model structured model with application specific functions
* @param loss structured loss function
* @param labs structured labels
- * @param features features
*/
- CPrimalMosekSOSVM(CStructuredModel* model, CLossFunction* loss, CStructuredLabels* labs, CFeatures* features);
+ CPrimalMosekSOSVM(CStructuredModel* model, CLossFunction* loss, CStructuredLabels* labs);
/** destructor */
~CPrimalMosekSOSVM();
@@ -85,15 +85,6 @@ struct bmrm_return_value_T
/** Track of w_dist values in individual iterations */
SGVector< float64_t > hist_wdist;
-
- /** get hist Fp */
- SGVector<float64_t> get_hist_Fp() const { return hist_Fp; }
-
- /** get hist Fd */
- SGVector<float64_t> get_hist_Fd() const { return hist_Fd; }
-
- /** get hist wdist */
- SGVector<float64_t> get_hist_wdist() const { return hist_wdist; }
};
/** Linked list for cutting planes buffer management */

0 comments on commit ff37c90

Please sign in to comment.