Skip to content

Commit

Permalink
replace 0 with eps
Browse files Browse the repository at this point in the history
  • Loading branch information
john-waczak committed Jul 7, 2024
1 parent cc9a62a commit 42fda52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/nmf-base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ function fit_kl!(nmf::NMFBase, X;

# 3. Check convergence
if i == 1
cost = kl_div(max.(nmf.W, 0.0), max.(nmf.H, 0.0), X)
cost = kl_div(max.(nmf.W, eps(eltype(WH))), max.(nmf.H, eps(eltype(WH))), X)
else
cost_prev = cost
cost = kl_div(max.(nmf.W, 0.0), max.(nmf.H, 0.0), X)
cost = kl_div(max.(nmf.W, eps(eltype(WH))), max.(nmf.H, eps(eltype(WH))), X)
# cost = kl_div(nmf.W, nmf.H, X)

diff= abs(cost - cost_prev)/min(abs(cost), abs(cost_prev))
Expand Down

0 comments on commit 42fda52

Please sign in to comment.