Skip to content

Commit

Permalink
Add a final projection when using nnscale to ensure A and B are exact…
Browse files Browse the repository at this point in the history
…ly normalized
  • Loading branch information
njericha committed Apr 5, 2024
1 parent a015836 commit 8479ff6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/matrixtensorfactorize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ function _nnmtf_proxgrad(
norm_grad = norm_grad[keep_slice]
dist_Ncone = dist_Ncone[keep_slice]

# If using nnscale, A and B may only be aproximatly normalized. So we need to project A
# and B to the simplex to ensure they are exactly normalized.
if projection == :nnscale
proj!(A; projection=:simplex, dims=1)
proj!(B; projection=:simplex, dims=to_dims(normalize))
end

# Rescale B back if Y was initialy scaled
# Only valid if we rescale fibres
if rescale_Y && normalize == :fibres
Expand Down

0 comments on commit 8479ff6

Please sign in to comment.