Skip to content

Commit

Permalink
fix entropy calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxun-zhang committed Mar 13, 2020
1 parent 713d962 commit c06a715
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/operator/quantization/calibrate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ std::vector<float> SmoothDistribution(const std::vector<float>& p, const float e
auto ret = p;
for (size_t i = 0; i < p.size(); i++) {
ret[i] += eps * is_zeros[i] - eps1 * is_nonzeros[i];
// check if ret[i] is larger than 0, otherwise invalid distribution
if (ret[i] <= 0)
return std::vector<float>();
}
return ret;
}
Expand Down

0 comments on commit c06a715

Please sign in to comment.