Skip to content

Commit

Permalink
Fixed get_w routine parameters in LinearMachine
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Sep 23, 2011
1 parent dd4e99f commit 9780d20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/shogun/classifier/svm/SVMLin.cpp
Expand Up @@ -100,10 +100,9 @@ bool CSVMLin::train_machine(CFeatures* data)
for (int32_t i=0; i<num_feat+1; i++)
Weights.vec[i]*=sgn;

set_w(Weights.vec, num_feat);
set_w(SGVector<float64_t>(Weights.vec, num_feat));
set_bias(Weights.vec[num_feat]);

SG_FREE(Weights.vec);
SG_FREE(Data.C);
SG_FREE(Outputs.vec);
train_labels.free_vector();
Expand Down
9 changes: 4 additions & 5 deletions src/shogun/machine/LinearMachine.h
Expand Up @@ -83,20 +83,19 @@ class CLinearMachine : public CMachine
*/
inline SGVector<float64_t> get_w()
{
return SGVector<float64_t>(w, w_dim);
return SGVector<float64_t>(w, w_dim, false);
}

/** set w
*
* @param src_w new w
* @param src_w_dim dimension of new w
*/
inline void set_w(float64_t* src_w, int32_t src_w_dim)
inline void set_w(SGVector<float64_t> src_w)
{
SG_FREE(w);
w=SG_MALLOC(float64_t, src_w_dim);
memcpy(w, src_w, size_t(src_w_dim)*sizeof(float64_t));
w_dim=src_w_dim;
w=src_w.vector;
w_dim=src_w.vlen;
}

/** set bias
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/ui/SGInterface.cpp
Expand Up @@ -4780,7 +4780,7 @@ bool CSGInterface::cmd_set_linear_classifier()
if (!c)
SG_ERROR("No Linear Classifier object available.\n");

c->set_w(w, len);
c->set_w(SGVector<float64_t>(w, len));
c->set_bias(bias);

SG_FREE(w);
Expand Down

0 comments on commit 9780d20

Please sign in to comment.