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;
250 dump_interval = exp(1.);
251 sum_loss_since_last_dump = 0.;
253 reg_dump_text =
true;
254 save_predictions =
false;
291 ex->
atomics[(int32_t)(i[1])], thread_mask,
329 if (ret < env->min_label)
335 void CVowpalWabbit::output_example(
VwExample* &example)
339 sum_loss_since_last_dump += example->
loss;
342 print_update(example);
347 if (save_predictions)
357 void CVowpalWabbit::print_update(
VwExample* &ex)
359 SG_SPRINT(
"%-10.6f %-10.6f %8lld %8.1f %8.4f %8.4f %8lu\n",
367 sum_loss_since_last_dump = 0.0;
377 int32_t num = sprintf(temp,
"%f", res);
379 t = write(f, temp, num);
386 t = write(f, temp, 1);
390 t = write(f, tag.
begin,
sizeof(
char)*tag.
index());
391 if (t != (ssize_t) (
sizeof(char)*tag.
index()))
396 t = write(f, temp, 1);
402 void CVowpalWabbit::set_verbose(
bool verbose)
404 quiet=verbose==
false;
415 if (g == 0)
return 0.;
424 float32_t* w_vec = &weights[f->weight_index & thread_mask];
427 sum_abs_x += fabsf(f->x);
450 float32_t update2 = g * page_feature.
x * page_feature.
x;
453 float32_t* w_vec = &weights[(halfhash + elem->weight_index) & mask];
456 sum_abs_x += fabsf(elem->x);