summaryrefslogtreecommitdiff
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
commitcdf62de81862fbb354d8dbaf7a41e5119c146d04 (patch)
tree60aa243f1decbcc070519d3d878041c113d3b7a0
parentf8f499c69cba280894d1ddf974a9038ac2211fc6 (diff)
try 2
-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);
}