From e4e1d052dbf9ee641eab8b69d0f02af9ba4978f9 Mon Sep 17 00:00:00 2001 From: antononcube Date: Mon, 22 Nov 2021 12:21:54 -0500 Subject: [PATCH] fix:More robust normalization. --- NonNegativeMatrixFactorization.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NonNegativeMatrixFactorization.m b/NonNegativeMatrixFactorization.m index 9afebc37..ddda6244 100644 --- a/NonNegativeMatrixFactorization.m +++ b/NonNegativeMatrixFactorization.m @@ -332,7 +332,7 @@ Mathematica is (C) Copyright 1988-2013 Wolfram Research, Inc. Block[{d, S, SI}, d = Table[Norm[H[[i]]], {i, Length[H]}]; S = DiagonalMatrix[d]; - SI = DiagonalMatrix[1 / d]; + SI = DiagonalMatrix[Map[If[# != 0, 1 / #, 0]&, d]]; {W.S, SI.H} ];