Skip to content

Commit

Permalink
Updated PrimalMosekSOSVM
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Aug 21, 2012
1 parent f253152 commit ff37c90
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/undocumented/python_modular/so_multiclass.py
Expand Up @@ -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()
Expand Down
Expand Up @@ -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()
Expand Down
13 changes: 8 additions & 5 deletions src/shogun/structure/PrimalMosekSOSVM.cpp
Expand Up @@ -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)
{
}

Expand All @@ -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();

Expand All @@ -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);
Expand Down Expand Up @@ -188,7 +191,7 @@ bool CPrimalMosekSOSVM::train_machine(CFeatures* data)
// Free resources
SG_UNREF(results);
SG_UNREF(mosek);

SG_UNREF(model_features);
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions src/shogun/structure/PrimalMosekSOSVM.h
Expand Up @@ -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();
Expand Down
9 changes: 0 additions & 9 deletions src/shogun/structure/libbmrm.h
Expand Up @@ -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 */
Expand Down

0 comments on commit ff37c90

Please sign in to comment.