Computational Physics, Python, Linear Algebra, Svd, Code.
H): R = W@H-M return R@H.T + penalty(W, mu)*lam, W.T@R + penalty(H, mu)*lam # dW, dH def penalty(M, mu): return np.where(M>=mu,0, np.min(M - mu, 0)) def upd(M, W, H, lr): dW,dH = grads(M,W,H) W -= lr*dW; H -= lr*dH def report(M,W,H): print(np.linalg.norm(M-W@H), W.min(), H.min(), (W<0).sum(),