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:
authorJohn Langford <jl@hunch.net>2014-01-22 20:52:02 +0400
committerJohn Langford <jl@hunch.net>2014-01-22 20:52:02 +0400
commit77f7b64ea9cafa7e783823af173865745876c3fb (patch)
treef6ad581103e170e68f63cc43bd53040c564805da /vowpalwabbit/csoaa.cc
parenta0fcc75614751b4bb3e4235a218198646cf399d9 (diff)
conversion to &
Diffstat (limited to 'vowpalwabbit/csoaa.cc')
-rw-r--r--vowpalwabbit/csoaa.cc78
1 files changed, 39 insertions, 39 deletions
diff --git a/vowpalwabbit/csoaa.cc b/vowpalwabbit/csoaa.cc
index 957c0bb8..7b5ee444 100644
--- a/vowpalwabbit/csoaa.cc
+++ b/vowpalwabbit/csoaa.cc
@@ -206,7 +206,7 @@ namespace CSOAA {
}
}
- void print_update(vw& all, bool is_test, example *ec)
+ void print_update(vw& all, bool is_test, example& ec)
{
if (all.sd->weighted_examples >= all.sd->dump_interval && !all.quiet && !all.bfgs)
{
@@ -232,8 +232,8 @@ namespace CSOAA {
(long int)all.sd->example_number,
all.sd->weighted_examples,
label_buf,
- (long unsigned int)ec->final_prediction,
- (long unsigned int)ec->num_features);
+ (long unsigned int)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;
@@ -245,8 +245,8 @@ namespace CSOAA {
(long int)all.sd->example_number,
all.sd->weighted_examples,
label_buf,
- (long unsigned int)ec->final_prediction,
- (long unsigned int)ec->num_features);
+ (long unsigned int)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;
@@ -254,14 +254,14 @@ namespace CSOAA {
}
}
- void output_example(vw& all, example* ec)
+ void output_example(vw& all, example& ec)
{
- label* ld = (label*)ec->ld;
+ label* ld = (label*)ec.ld;
float loss = 0.;
if (!is_test_label(ld))
{//need to compute exact loss
- size_t pred = (size_t)ec->final_prediction;
+ size_t pred = (size_t)ec.final_prediction;
float chosen_loss = FLT_MAX;
float min = FLT_MAX;
@@ -277,11 +277,11 @@ namespace CSOAA {
loss = chosen_loss - min;
}
- 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->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 += loss;
all.sd->holdout_sum_loss_since_last_dump += loss;
all.sd->holdout_sum_loss_since_last_pass += loss;//since last pass
@@ -289,14 +289,14 @@ namespace CSOAA {
else
{
all.sd->weighted_examples += 1.;
- all.sd->total_features += ec->num_features;
+ all.sd->total_features += ec.num_features;
all.sd->sum_loss += loss;
all.sd->sum_loss_since_last_dump += loss;
all.sd->example_number++;
}
for (int* sink = all.final_prediction_sink.begin; sink != all.final_prediction_sink.end; sink++)
- all.print((int)*sink, ec->final_prediction, 0, ec->tag);
+ all.print((int)*sink, ec.final_prediction, 0, ec.tag);
if (all.raw_prediction > 0) {
string outputString;
@@ -307,10 +307,10 @@ namespace CSOAA {
outputStringStream << cl.weight_index << ':' << cl.partial_prediction;
}
//outputStringStream << endl;
- all.print_text(all.raw_prediction, outputStringStream.str(), ec->tag);
+ all.print_text(all.raw_prediction, outputStringStream.str(), ec.tag);
}
- print_update(all, is_test_label((label*)ec->ld), ec);
+ print_update(all, is_test_label((label*)ec.ld), ec);
}
template <bool is_learn>
@@ -355,10 +355,10 @@ namespace CSOAA {
ec.final_prediction = (float)prediction;
}
- void finish_example(vw& all, csoaa*, example* ec)
+ void finish_example(vw& all, csoaa*, example& ec)
{
output_example(all, ec);
- VW::finish_example(all, ec);
+ VW::finish_example(all, &ec);
}
learner* setup(vw& all, std::vector<std::string>&opts, po::variables_map& vm, po::variables_map& vm_file)
@@ -436,9 +436,9 @@ namespace LabelDict {
return true;
}
- bool ec_is_example_header(example*ec) // example headers look like "0:-1"
+ bool ec_is_example_header(example& ec) // example headers look like "0:-1"
{
- v_array<CSOAA::wclass> costs = ((CSOAA::label*)ec->ld)->costs;
+ v_array<CSOAA::wclass> costs = ((CSOAA::label*)ec.ld)->costs;
if (costs.size() != 1) return false;
if (costs[0].weight_index != 0) return false;
if (costs[0].x >= 0) return false;
@@ -685,7 +685,7 @@ namespace LabelDict {
isTest = true;
cerr << "warning: wap_ldf got mix of train/test data; assuming test" << endl;
}
- if (LabelDict::ec_is_example_header(l.ec_seq[k])) {
+ if (LabelDict::ec_is_example_header(*l.ec_seq[k])) {
cerr << "warning: example headers at position " << k << ": can only have in initial position!" << endl;
throw exception();
}
@@ -779,7 +779,7 @@ namespace LabelDict {
isTest = true;
cerr << "warning: ldf got mix of train/test data; assuming test" << endl;
}
- if (LabelDict::ec_is_example_header(l.ec_seq[k])) {
+ if (LabelDict::ec_is_example_header(*l.ec_seq[k])) {
cerr << "warning: example headers at position " << k << ": can only have in initial position!" << endl;
throw exception();
}
@@ -873,7 +873,7 @@ namespace LabelDict {
/////////////////////// check for headers
size_t K = l.ec_seq.size();
size_t start_K = 0;
- if (LabelDict::ec_is_example_header(l.ec_seq[0])) {
+ if (LabelDict::ec_is_example_header(*l.ec_seq[0])) {
start_K = 1;
for (size_t k=1; k<K; k++)
LabelDict::add_example_namespaces_from_example(*l.ec_seq[k], *l.ec_seq[0]);
@@ -890,21 +890,21 @@ namespace LabelDict {
}
- void output_example(vw& all, example* ec, bool&hit_loss)
+ void output_example(vw& all, example& ec, bool& hit_loss)
{
- label* ld = (label*)ec->ld;
+ label* ld = (label*)ec.ld;
v_array<CSOAA::wclass> costs = ld->costs;
- if (example_is_newline(*ec)) return;
+ if (example_is_newline(ec)) return;
if (LabelDict::ec_is_example_header(ec)) return;
- if (LabelDict::ec_is_label_definition(*ec)) return;
+ if (LabelDict::ec_is_label_definition(ec)) return;
- all.sd->total_features += ec->num_features;
+ all.sd->total_features += ec.num_features;
float loss = 0.;
- size_t final_pred = (size_t)ec->final_prediction;
+ size_t final_pred = (size_t)ec.final_prediction;
- if (!CSOAA::example_is_test(*ec)) {
+ if (!CSOAA::example_is_test(ec)) {
for (size_t j=0; j<costs.size(); j++) {
if (hit_loss) break;
if (final_pred == costs[j].weight_index) {
@@ -919,7 +919,7 @@ namespace LabelDict {
}
for (int* sink = all.final_prediction_sink.begin; sink != all.final_prediction_sink.end; sink++)
- all.print(*sink, ec->final_prediction, 0, ec->tag);
+ all.print(*sink, ec.final_prediction, 0, ec.tag);
if (all.raw_prediction > 0) {
string outputString;
@@ -929,11 +929,11 @@ namespace LabelDict {
outputStringStream << costs[i].weight_index << ':' << costs[i].partial_prediction;
}
//outputStringStream << endl;
- all.print_text(all.raw_prediction, outputStringStream.str(), ec->tag);
+ all.print_text(all.raw_prediction, outputStringStream.str(), ec.tag);
}
- CSOAA::print_update(all, CSOAA::example_is_test(*ec), ec);
+ CSOAA::print_update(all, CSOAA::example_is_test(ec), ec);
}
void output_example_seq(vw& all, ldf& l)
@@ -944,7 +944,7 @@ namespace LabelDict {
bool hit_loss = false;
for (example** ecc=l.ec_seq.begin; ecc!=l.ec_seq.end; ecc++)
- output_example(all, *ecc, hit_loss);
+ output_example(all, **ecc, hit_loss);
if (!l.is_singleline && (all.raw_prediction > 0))
all.print_text(all.raw_prediction, "", l.ec_seq[0]->tag);
@@ -1021,18 +1021,18 @@ namespace LabelDict {
}
*/
- void finish_singleline_example(vw& all, ldf*, example* ec)
+ void finish_singleline_example(vw& all, ldf*, example& ec)
{
- if (! LabelDict::ec_is_label_definition(*ec)) {
+ if (! LabelDict::ec_is_label_definition(ec)) {
all.sd->weighted_examples += 1;
all.sd->example_number++;
}
bool hit_loss = false;
output_example(all, ec, hit_loss);
- VW::finish_example(all, ec);
+ VW::finish_example(all, &ec);
}
- void finish_multiline_example(vw& all, ldf* l, example* ec)
+ void finish_multiline_example(vw& all, ldf* l, example& ec)
{
if (l->need_to_clear) {
if (l->ec_seq.size() > 0) {
@@ -1041,7 +1041,7 @@ namespace LabelDict {
}
clear_seq_and_finish_examples(all, *l);
l->need_to_clear = false;
- if (ec->in_use) VW::finish_example(all, ec);
+ if (ec.in_use) VW::finish_example(all, &ec);
}
}