From bdd80d329ef72daa22199abead6518dda4b0b4d9 Mon Sep 17 00:00:00 2001 From: Leland McInnes Date: Fri, 5 Oct 2018 22:31:19 -0400 Subject: [PATCH] lobpcg for spectral; back to parallel --- umap/spectral.py | 20 +++++++++++++------- umap/umap_.py | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/umap/spectral.py b/umap/spectral.py index c91d739c..19c5efd6 100644 --- a/umap/spectral.py +++ b/umap/spectral.py @@ -254,14 +254,20 @@ def spectral_layout(data, graph, dim, random_state, metric="euclidean", metric_k k = dim + 1 num_lanczos_vectors = max(2 * k + 1, int(np.sqrt(graph.shape[0]))) try: - eigenvalues, eigenvectors = scipy.sparse.linalg.eigsh( + # eigenvalues, eigenvectors = scipy.sparse.linalg.eigsh( + # L, + # k, + # which="SM", + # ncv=num_lanczos_vectors, + # tol=1e-4, + # v0=np.ones(L.shape[0]), + # maxiter=graph.shape[0] * 5, + # ) + eigenvalues, eigenvectors = scipy.sparse.linalg.lobpcg( L, - k, - which="SM", - ncv=num_lanczos_vectors, - tol=1e-4, - v0=np.ones(L.shape[0]), - maxiter=graph.shape[0] * 5, + random_state.normal(size=(L.shape[0], k)), + largest=False, + tol=1e-4 ) order = np.argsort(eigenvalues)[1:k] return eigenvectors[:, order] diff --git a/umap/umap_.py b/umap/umap_.py index 466305e6..ed1da285 100644 --- a/umap/umap_.py +++ b/umap/umap_.py @@ -679,7 +679,7 @@ def rdist(x, y): return result -@numba.njit(fastmath=True) +@numba.njit(fastmath=True, parallel=True) def optimize_layout( head_embedding, tail_embedding,