diff options
author | Jacob Hofman <hofman@research-mm10.corp.sp1.yahoo.com> | 2010-12-23 21:39:41 +0300 |
---|---|---|
committer | Jacob Hofman <hofman@research-mm10.corp.sp1.yahoo.com> | 2010-12-23 21:39:41 +0300 |
commit | d10feaf53cee63e2884dd6e33f35afb90e1e04c9 (patch) | |
tree | c01641b7456ed076a80d688caef4a91499cd9253 /sparse_dense.cc | |
parent | c51a800b1930c648faf7d40dc776a4d38e33ce82 (diff) | |
parent | a9ced5d4c75375f5c1a4e4a2ca0020749dd3a358 (diff) |
matrix factorization uses new format for weight vector, checking for bugs
Diffstat (limited to 'sparse_dense.cc')
-rw-r--r-- | sparse_dense.cc | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/sparse_dense.cc b/sparse_dense.cc index 021ddfa7..456e8a7d 100644 --- a/sparse_dense.cc +++ b/sparse_dense.cc @@ -24,25 +24,19 @@ float sd_offset_add(weight* weights, size_t mask, feature* begin, feature* end, return ret; } -int print_bit = 0; - void sd_offset_update(weight* weights, size_t mask, feature* begin, feature* end, size_t offset, float update) { float mult = 1 - global.weight_decay; float new_weight; for (feature* f = begin; f!= end; f++) { new_weight = mult * weights[(f->weight_index + offset) & mask] + f->x * update; - - if (print_bit || (isnan(new_weight) || ((f->weight_index + offset) & mask) == 127659601)) { - cout << "mult " << mult << ", "; - cout << "index " << ((f->weight_index + offset) & mask) << ", "; - cout << "weight " << weights[(f->weight_index + offset) & mask] << ", "; - cout << "f->x " << f->x << ", "; - cout << "update " << update << endl; - - print_bit = !print_bit; - } - + /* + cout << "mult " << mult << ", "; + cout << "index " << ((f->weight_index + offset) & mask) << ", "; + cout << "weight " << weights[(f->weight_index + offset) & mask] << ", "; + cout << "f->x " << f->x << ", "; + cout << "update " << update << endl; + */ weights[(f->weight_index + offset) & mask] = new_weight; } } @@ -92,22 +86,22 @@ float offset_quad_predict(weight* weights, feature& page_feature, v_array<featur return (prediction*page_feature.x); } -void print_offset_audit_quad(weight* weights, audit_data& page_feature, v_array<audit_data> &offer_features, size_t mask, size_t offset) +void print_audit_quad(weight* weights, audit_data& page_feature, v_array<audit_data> &offer_features, size_t mask) { - size_t halfhash = quadratic_constant * page_feature.weight_index + offset; + size_t halfhash = quadratic_constant * page_feature.weight_index; for (audit_data* ele = offer_features.begin; ele != offer_features.end; ele++) cout << '\t' << page_feature.space << '^' << page_feature.feature << '^' - << ele->space << '^' << ele->feature << ':' << ((halfhash + ele->weight_index) & mask) + << ele->space << '^' << ele->feature << ':' << (((halfhash + ele->weight_index)/global.stride) & mask) << ':' << ele->x*page_feature.x << ':' << weights[(halfhash + ele->weight_index) & mask]; } -void print_offset_quad(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask, size_t offset) +void print_quad(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask) { - size_t halfhash = quadratic_constant * page_feature.weight_index + offset; + size_t halfhash = quadratic_constant * page_feature.weight_index; for (feature* ele = offer_features.begin; ele != offer_features.end; ele++) - cout << '\t' << ((halfhash + ele->weight_index) & mask) + cout << '\t' << (((halfhash + ele->weight_index)/global.stride) & mask) << ':' << (ele->x*page_feature.x) << ':' << weights[(halfhash + ele->weight_index) & mask]; } |