Skip to content

Commit fb4cde1

Browse files
author
Fabian Pedregosa
committed
Warm restart WIP
1 parent f59d23f commit fb4cde1

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

sklearn/svm/src/liblinear/linear.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ static void train_one(const problem *prob, const parameter *param, double *w, do
18471847
//
18481848
// Interface functions
18491849
//
1850-
model* train(const problem *prob, const parameter *param)
1850+
model* train(const problem *prob, const parameter *param, double * coefs)
18511851
{
18521852
int i,j;
18531853
int l = prob->l;
@@ -1909,7 +1909,10 @@ model* train(const problem *prob, const parameter *param)
19091909
// multi-class svm by Crammer and Singer
19101910
if(param->solver_type == MCSVM_CS)
19111911
{
1912-
model_->w=Malloc(double, n*nr_class);
1912+
if (coefs == NULL)
1913+
model_->w=Malloc(double, n*nr_class);
1914+
else
1915+
model_->w = coefs;
19131916
for(i=0;i<nr_class;i++)
19141917
for(j=start[i];j<start[i]+count[i];j++)
19151918
sub_prob.y[j] = i;
@@ -1920,8 +1923,10 @@ model* train(const problem *prob, const parameter *param)
19201923
{
19211924
if(nr_class == 2)
19221925
{
1923-
model_->w=Malloc(double, w_size);
1924-
1926+
if (coefs == NULL)
1927+
model_->w=Malloc(double, w_size);
1928+
else
1929+
model_->w = coefs;
19251930
int e0 = start[0]+count[0];
19261931
k=0;
19271932
for(; k<e0; k++)
@@ -1933,7 +1938,11 @@ model* train(const problem *prob, const parameter *param)
19331938
}
19341939
else
19351940
{
1936-
model_->w=Malloc(double, w_size*nr_class);
1941+
if (coefs == NULL)
1942+
model_->w=Malloc(double, w_size*nr_class);
1943+
else
1944+
model_->w = coefs;
1945+
19371946
double *w=Malloc(double, w_size);
19381947
for(i=0;i<nr_class;i++)
19391948
{

0 commit comments

Comments
 (0)