values refill(X) for t in range(self.max_iter): # update threshold in each iteration thresh = self.alpha * (1 - t / self.max_iter) # apply SVD U, S, V = np.linalg.svd(X, full_matrices=False) # apply soft thresholding function to singular values S = soft_thresh(S, thresh) S = np.diag(S) # reconstruct X X = U.dot(S).dot(V) refill(X) return X