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-06-14 18:21:08 +0400
committerJohn Langford <jl@hunch.net>2014-06-14 18:21:08 +0400
commit0c8da21c979951a36373ca0cb601d4c5bd056038 (patch)
tree9cceab038c0a8871c44aab5163142362d66f6fb5
parente14f36150f8195a98100230b16ed32779185bbe3 (diff)
shift wpp multiplication to setup_example
-rw-r--r--vowpalwabbit/parse_example.cc8
-rw-r--r--vowpalwabbit/parser.cc10
2 files changed, 8 insertions, 10 deletions
diff --git a/vowpalwabbit/parse_example.cc b/vowpalwabbit/parse_example.cc
index 4489908a..8af7df86 100644
--- a/vowpalwabbit/parse_example.cc
+++ b/vowpalwabbit/parse_example.cc
@@ -75,7 +75,6 @@ public:
float v;
parser* p;
example* ae;
- uint32_t weights_per_problem;
uint32_t* affix_features;
bool* spelling_features;
v_array<char> spelling;
@@ -129,7 +128,7 @@ public:
else
word_hash = channel_hash + anon++;
if(v == 0) return; //dont add 0 valued features to list of features
- feature f = {v,(uint32_t)word_hash * weights_per_problem};
+ feature f = {v,(uint32_t)word_hash };
ae->sum_feat_sq[index] += v*v;
ae->atomics[index].push_back(f);
if(audit){
@@ -154,7 +153,7 @@ public:
affix_name.begin = affix_name.end - len;
}
word_hash = p->hasher(affix_name,(uint32_t)channel_hash) * (affix_constant + (affix & 0xF) * quadratic_constant);
- feature f2 = { v, (uint32_t) word_hash * weights_per_problem };
+ feature f2 = { v, (uint32_t) word_hash };
ae->sum_feat_sq[affix_namespace] += v*v;
ae->atomics[affix_namespace].push_back(f2);
if (audit) {
@@ -189,7 +188,7 @@ public:
}
substring spelling_ss = { spelling.begin, spelling.end };
size_t word_hash = hashstring(spelling_ss, (uint32_t)channel_hash);
- feature f2 = { v, (uint32_t) word_hash * weights_per_problem };
+ feature f2 = { v, (uint32_t) word_hash };
ae->sum_feat_sq[spelling_namespace] += v*v;
ae->atomics[spelling_namespace].push_back(f2);
if (audit) {
@@ -313,7 +312,6 @@ public:
this->endLine = endLine;
this->p = all.p;
this->ae = ae;
- this->weights_per_problem = all.wpp;
this->affix_features = all.affix_features;
this->spelling_features = all.spelling_features;
this->base = NULL;
diff --git a/vowpalwabbit/parser.cc b/vowpalwabbit/parser.cc
index 82e0398b..46094375 100644
--- a/vowpalwabbit/parser.cc
+++ b/vowpalwabbit/parser.cc
@@ -784,21 +784,21 @@ void setup_example(vw& all, example* ae)
if (all.add_constant) {
//add constant feature
ae->indices.push_back(constant_namespace);
- feature temp = {1,(uint32_t) (constant * all.wpp)};
+ feature temp = {1,(uint32_t) constant};
ae->atomics[constant_namespace].push_back(temp);
ae->total_sum_feat_sq++;
}
- if(all.reg.stride_shift != 0) //make room for per-feature information.
+ uint32_t multiplier = all.wpp << all.reg.stride_shift;
+ if(multiplier != 1) //make room for per-feature information.
{
- uint32_t stride_shift = all.reg.stride_shift;
for (unsigned char* i = ae->indices.begin; i != ae->indices.end; i++)
for(feature* j = ae->atomics[*i].begin; j != ae->atomics[*i].end; j++)
- j->weight_index = (j->weight_index << stride_shift);
+ j->weight_index *= multiplier;
if (all.audit || all.hash_inv)
for (unsigned char* i = ae->indices.begin; i != ae->indices.end; i++)
for(audit_data* j = ae->audit_features[*i].begin; j != ae->audit_features[*i].end; j++)
- j->weight_index = (j->weight_index << stride_shift);
+ j->weight_index *= multiplier;
}
for (unsigned char* i = ae->indices.begin; i != ae->indices.end; i++)