Skip to content

Commit

Permalink
[src] (minor) Added missing SetZero() to NaturalGradientAffineCompone…
Browse files Browse the repository at this point in the history
…nt::Scale() if scale==0.0 (#1522)
  • Loading branch information
freewym authored and danpovey committed Mar 31, 2017
1 parent 13d300f commit e9d7993
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/nnet3/nnet-simple-component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2798,11 +2798,19 @@ void NaturalGradientAffineComponent::ZeroStats() {
}

void NaturalGradientAffineComponent::Scale(BaseFloat scale) {
update_count_ *= scale;
max_change_scale_stats_ *= scale;
active_scaling_count_ *= scale;
linear_params_.Scale(scale);
bias_params_.Scale(scale);
if (scale == 0.0) {
update_count_ = 0.0;
max_change_scale_stats_ = 0.0;
active_scaling_count_ = 0.0;
linear_params_.SetZero();
bias_params_.SetZero();
} else {
update_count_ *= scale;
max_change_scale_stats_ *= scale;
active_scaling_count_ *= scale;
linear_params_.Scale(scale);
bias_params_.Scale(scale);
}
}

void NaturalGradientAffineComponent::Add(BaseFloat alpha, const Component &other_in) {
Expand Down

0 comments on commit e9d7993

Please sign in to comment.