Skip to content

Commit

Permalink
make gd and bfgs work after moving loss to simple_label
Browse files Browse the repository at this point in the history
pierce1987 committed Aug 30, 2013
1 parent a8414fb commit 2363cd6
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion vowpalwabbit/bfgs.cc
Original file line number Diff line number Diff line change
@@ -784,7 +784,6 @@ void learn(void* d, example* ec)
label_data* ld = (label_data*)ec->ld;
ec->final_prediction = bfgs_predict(*all,ec);
ec->loss = all->loss->getLoss(all->sd, ec->final_prediction, ld->label) * ld->weight;
all->sd->holdout_sum_loss_since_last_pass += ec->loss;
}
else if (test_example(ec))
ec->final_prediction = bfgs_predict(*all,ec);//w[0]
13 changes: 4 additions & 9 deletions vowpalwabbit/gd.cc
Original file line number Diff line number Diff line change
@@ -556,16 +556,11 @@ float compute_norm(vw& all, example* &ec)
t = ec->example_t;

ec->eta_round = 0;
if (ec->test_only)//if this is a holdout example
{
ec->loss = all.loss->getLoss(all.sd, ec->final_prediction, ld->label) * ld->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)

ec->loss = all.loss->getLoss(all.sd, ec->final_prediction, ld->label) * ld->weight;

if (ld->label != FLT_MAX && !ec->test_only)
{
ec->loss = all.loss->getLoss(all.sd, ec->final_prediction, ld->label) * ld->weight;
if (all.training && ec->loss > 0.)
{
float eta_t;
4 changes: 4 additions & 0 deletions vowpalwabbit/simple_label.cc
Original file line number Diff line number Diff line change
@@ -183,6 +183,10 @@ void output_and_account_example(vw& all, example* ec)
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
{

0 comments on commit 2363cd6

Please sign in to comment.