20 using namespace shogun;
22 CVowpalWabbit::CVowpalWabbit()
48 no_training = vw->no_training;
49 dump_interval = vw->dump_interval;
50 sum_loss_since_last_dump = 0.;
51 reg_name = vw->reg_name;
52 reg_dump_text = vw->reg_dump_text;
53 save_predictions = vw->save_predictions;
54 prediction_fd = vw->prediction_fd;
84 if (adaptive_learning)
115 reg_name = file_name;
116 reg_dump_text = is_text;
121 save_predictions =
true;
122 prediction_fd = open(file_name, O_CREAT|O_TRUNC|O_WRONLY, 0666);
123 if (prediction_fd < 0)
124 SG_SERROR(
"Unable to open prediction file %s for writing!\n", file_name)
146 const char* header_fmt =
"%-10s %-10s %8s %8s %10s %8s %8s\n";
151 "average",
"since",
"example",
"example",
152 "current",
"current",
"current");
154 "loss",
"last",
"counter",
"weight",
"label",
"predict",
"features");
167 if (example->
pass != current_pass)
170 current_pass = example->
pass;
178 output_example(example);
194 for (uint32_t i = 0; i < length; i++)
198 if (reg_name != NULL)
208 prediction = inline_l1_predict(ex);
210 prediction = inline_predict(ex);
225 update = (
env->
eta * exact_norm)/sum_abs_x;
257 dump_interval = exp(1.);
258 sum_loss_since_last_dump = 0.;
260 reg_dump_text =
true;
261 save_predictions =
false;
298 ex->
atomics[(int32_t)(i[1])], thread_mask,
336 if (ret < env->min_label)
342 void CVowpalWabbit::output_example(
VwExample* &example)
346 sum_loss_since_last_dump += example->
loss;
349 print_update(example);
354 if (save_predictions)
364 void CVowpalWabbit::print_update(
VwExample* &ex)
366 SG_SPRINT(
"%-10.6f %-10.6f %8lld %8.1f %8.4f %8.4f %8lu\n",
374 sum_loss_since_last_dump = 0.0;
384 int32_t num = sprintf(temp,
"%f", res);
386 t = write(f, temp, num);
390 if (tag.begin != tag.end)
393 t = write(f, temp, 1);
397 t = write(f, tag.begin, sizeof(
char)*tag.index());
398 if (t != (ssize_t) (sizeof(
char)*tag.index()))
403 t = write(f, temp, 1);
411 quiet=verbose==
false;
422 if (g == 0)
return 0.;
431 float32_t* w_vec = &weights[f->weight_index & thread_mask];
434 sum_abs_x += fabsf(f->x);
457 float32_t update2 = g * page_feature.
x * page_feature.
x;
460 float32_t* w_vec = &weights[(halfhash + elem->weight_index) & mask];
463 sum_abs_x += fabsf(elem->x);