Created
February 21, 2017 12:19
-
-
Save danielperezr88/dfe55e5ca696ff9b74a73732fd59c71d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/nmf.py b/nmf.py | |
index dda116c..1cf6bd8 100644 | |
--- a/nmf.py | |
+++ b/nmf.py | |
@@ -74,7 +74,7 @@ def _safe_compute_error(X, W, H): | |
norm_X = np.dot(X.data, X.data) | |
norm_WH = trace_dot(np.dot(np.dot(W.T, W), H), H) | |
cross_prod = trace_dot((X * H.T), W) | |
- error = sqrt(norm_X + norm_WH - 2. * cross_prod) | |
+ error = sqrt(np.max([0, norm_X + norm_WH - 2. * cross_prod])) | |
return error | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment