Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'vowpalwabbit/simple_label.cc')
-rw-r--r--vowpalwabbit/simple_label.cc51
1 files changed, 26 insertions, 25 deletions
diff --git a/vowpalwabbit/simple_label.cc b/vowpalwabbit/simple_label.cc
index 5b4a3073..d3646ec9 100644
--- a/vowpalwabbit/simple_label.cc
+++ b/vowpalwabbit/simple_label.cc
@@ -118,7 +118,7 @@ float get_active_coin_bias(float k, float l, float g, float c0)
return b*rs*rs;
}
-float query_decision(vw& all, example* ec, float k)
+float query_decision(vw& all, example& ec, float k)
{
float bias, avg_loss, weighted_queries;
if (k<=1.)
@@ -126,7 +126,7 @@ float query_decision(vw& all, example* ec, float k)
else{
weighted_queries = (float)(all.initial_t + all.sd->weighted_examples - all.sd->weighted_unlabeled_examples);
avg_loss = (float)(all.sd->sum_loss/k + sqrt((1.+0.5*log(k))/(weighted_queries+0.0001)));
- bias = get_active_coin_bias(k, avg_loss, ec->revert_weight/k, all.active_c0);
+ bias = get_active_coin_bias(k, avg_loss, ec.revert_weight/k, all.active_c0);
}
if(frand48()<bias)
return 1.f/bias;
@@ -134,11 +134,11 @@ float query_decision(vw& all, example* ec, float k)
return -1.;
}
-void print_update(vw& all, example *ec)
+void print_update(vw& all, example& ec)
{
if (all.sd->weighted_examples >= all.sd->dump_interval && !all.quiet && !all.bfgs)
{
- label_data* ld = (label_data*) ec->ld;
+ label_data* ld = (label_data*) ec.ld;
char label_buf[32];
if (ld->label == FLT_MAX)
strcpy(label_buf," unknown");
@@ -160,8 +160,8 @@ void print_update(vw& all, example *ec)
(long int)all.sd->example_number,
all.sd->weighted_examples,
label_buf,
- ec->final_prediction,
- (long unsigned int)ec->num_features);
+ ec.final_prediction,
+ (long unsigned int)ec.num_features);
all.sd->weighted_holdout_examples_since_last_dump = 0.;
all.sd->holdout_sum_loss_since_last_dump = 0.0;
@@ -173,39 +173,40 @@ void print_update(vw& all, example *ec)
(long int)all.sd->example_number,
all.sd->weighted_examples,
label_buf,
- ec->final_prediction,
- (long unsigned int)ec->num_features);
+ ec.final_prediction,
+ (long unsigned int)ec.num_features);
all.sd->sum_loss_since_last_dump = 0.0;
all.sd->old_weighted_examples = all.sd->weighted_examples;
VW::update_dump_interval(all);
+ fflush(stderr);
}
}
-void output_and_account_example(vw& all, example* ec)
+void output_and_account_example(vw& all, example& ec)
{
- label_data* ld = (label_data*)ec->ld;
+ label_data* ld = (label_data*)ec.ld;
- if(ec->test_only)
+ if(ec.test_only)
{
- all.sd->weighted_holdout_examples += ec->global_weight;//test weight seen
- all.sd->weighted_holdout_examples_since_last_dump += ec->global_weight;
- all.sd->weighted_holdout_examples_since_last_pass += ec->global_weight;
- all.sd->holdout_sum_loss += ec->loss;
- all.sd->holdout_sum_loss_since_last_dump += ec->loss;
- all.sd->holdout_sum_loss_since_last_pass += ec->loss;//since last pass
+ all.sd->weighted_holdout_examples += ec.global_weight;//test weight seen
+ all.sd->weighted_holdout_examples_since_last_dump += ec.global_weight;
+ all.sd->weighted_holdout_examples_since_last_pass += ec.global_weight;
+ all.sd->holdout_sum_loss += ec.loss;
+ all.sd->holdout_sum_loss_since_last_dump += ec.loss;
+ all.sd->holdout_sum_loss_since_last_pass += ec.loss;//since last pass
}
else
{
if (ld->label != FLT_MAX)
all.sd->weighted_labels += ld->label * ld->weight;
all.sd->weighted_examples += ld->weight;
- all.sd->sum_loss += ec->loss;
- all.sd->sum_loss_since_last_dump += ec->loss;
- all.sd->total_features += ec->num_features;
+ all.sd->sum_loss += ec.loss;
+ all.sd->sum_loss_since_last_dump += ec.loss;
+ all.sd->total_features += ec.num_features;
all.sd->example_number++;
}
- all.print(all.raw_prediction, ec->partial_prediction, -1, ec->tag);
+ all.print(all.raw_prediction, ec.partial_prediction, -1, ec.tag);
float ai=-1;
if(all.active && ld->label == FLT_MAX)
@@ -218,18 +219,18 @@ void output_and_account_example(vw& all, example* ec)
if(all.active && all.lda == 0)
active_print_result(f, ec->final_prediction, ai, ec->tag);
else if (all.lda > 0)
- print_lda_result(all, f,ec->topic_predictions.begin,0.,ec->tag);
+ print_lda_result(all, f,ec.topic_predictions.begin,0.,ec.tag);
else
- all.print(f, ec->final_prediction, 0, ec->tag);
+ all.print(f, ec.final_prediction, 0, ec.tag);
}
print_update(all, ec);
}
-void return_simple_example(vw& all, void*, example* ec)
+void return_simple_example(vw& all, void*, example& ec)
{
output_and_account_example(all, ec);
- VW::finish_example(all,ec);
+ VW::finish_example(all,&ec);
}
bool summarize_holdout_set(vw& all, size_t& no_win_counter)