Skip to content

Commit

Permalink
Fix to bug 1729: no bias regularization for BFGS not working (#1794)
Browse files Browse the repository at this point in the history
* fix to bug 1729

* fix to bug 1729
  • Loading branch information
pavithraks authored Mar 20, 2019
1 parent 4c8d6d2 commit 5a8c495
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions vowpalwabbit/bfgs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,18 +457,19 @@ double add_regularization(vw& all, bfgs& b, float regularization, T& weights)
}

// if we're not regularizing the intercept term, then subtract it off from the result above
// when accessing weights[constant], always use weights.strided_index(constant)
if (all.no_bias)
{
if (b.regularizers == nullptr)
{
(&weights[constant])[W_GT] -= regularization * weights[constant];
ret -= 0.5 * regularization * (weights[constant]) * (weights[constant]);
(&weights.strided_index(constant))[W_GT] -= regularization * (weights.strided_index(constant));
ret -= 0.5 * regularization * (weights.strided_index(constant)) * (weights.strided_index(constant));
}
else
{
uint64_t i = constant >> weights.stride_shift();
weight delta_weight = weights[constant] - b.regularizers[2 * i + 1];
(&weights[constant])[W_GT] -= b.regularizers[2 * i] * delta_weight;
weight delta_weight = (weights.strided_index(constant)) - b.regularizers[2 * i + 1];
(&weights.strided_index(constant))[W_GT] -= b.regularizers[2 * i] * delta_weight;
ret -= 0.5 * b.regularizers[2 * i] * delta_weight * delta_weight;
}
}
Expand Down

0 comments on commit 5a8c495

Please sign in to comment.