summaryrefslogtreecommitdiff
path: root/training
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-03-17 22:53:19 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2011-03-17 22:53:19 -0400
commit4482fe7a82e3f9a197bf65d60635885c4bfab195 (patch)
tree474316454796062afe622d10e5a2319b0fc238cd /training
parent7079e3685def6f231ecf9f0c3f31b5c03a46d858 (diff)
try 2
Diffstat (limited to 'training')
-rw-r--r--training/online_optimizer.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/training/online_optimizer.h b/training/online_optimizer.h
index 61d62a37..28d89344 100644
--- a/training/online_optimizer.h
+++ b/training/online_optimizer.h
@@ -92,7 +92,11 @@ class CumulativeL1OnlineOptimizer : public OnlineOptimizer {
void ResetEpochImpl() { u_ = 0; }
void UpdateWeightsImpl(const double& eta, const SparseVector<double>& approx_g, int max_feat, SparseVector<double>* weights) {
u_ += eta * C_ / N_;
- (*weights) += eta * approx_g;
+ for (SparseVector<double>::const_iterator it = approx_g.begin();
+ it != approx_g.end(); ++it) {
+ if (frozen_.count(it->first) == 0)
+ weights->add_value(it->first, eta * it->second);
+ }
for (int i = 1; i < max_feat; ++i)
if (frozen_.count(i) == 0) ApplyPenalty(i, weights);
}