Docsity

Approximating Large-Scale Matrix Multiplication and Low-Rank Matrix Approximation - Prof. , Study notes of Computer Science

Partial preview of the text

Download Approximating Large-Scale Matrix Multiplication and Low-Rank Matrix Approximation - Prof. and more Study notes Computer Science in PDF only on Docsity!

CSE 275 Matrix Computation

Ming-Hsuan Yang

Electrical Engineering and Computer Science University of California at Merced Merced, CA 95344 http://faculty.ucmerced.edu/mhyang

Lecture 22

Overview

Algorithms for Modern Massive Data Sets (MMDS): I (^) Explore algorithms for modeling and analyzing massive, high dimensional and nonlinear structured data I (^) Bring together computer scientists, computational and applied mathematicians, and practitioners Tools: numerical linear algebra, kernel methods, multilinear algebra, randomized algorithms, optimization, differential geometry, geometry and topology, etc. Organized by Gene Golub et al. in 2006 and 2008 Sponsored by NSF, Stanford and Yahoo Slides available at mmds.stanford.edu

Matrix factorization and applications

Treat each data point as a vector I (^) 2D image → 1D vector of intensity values I (^) 3D models → 1D vector of 3D coordinates I (^) Document → 1D vector of term frequency Massive data set High dimensional data Find a low dimensional representation using eigendecomposition See O’Leary’s slides

Low rank matrix approximation

SVD is great but computationally expensive for large scale problems Efficient randomized algorithms for low rank approximation with guaranteed error bounds CX algorithm [Drineas and Kanna FOCS 01]: randomly pick k columns Am×n ≈ Cm×k Xk×n CUR algorithm [Drineas and Kannan SODA 03]: randomly pick c columns and r rows

Am×n ≈ Cm×c Uc×r Rr ×n

Element-wise sampling [Achiloptas and McSherry STOC 01]

Am×n ≈ Sm×n, Sij =

Aij /pij , with probability pij 0 , with probability 1 − pij

See Kannan’s slides and Drineas’ slides.

Approximating matrix multiplication (cont’d)

In matrix notation

Am×nBn×p ≈ Cm×s Rs×p

Create C and R i.i.d. trials with replacement For t = 1 up to s, pick a column A(jt^ )^ and a row B(jt ) with probability

Pr (jt = i) =

‖A(i)‖ 2 ‖B(i)‖ 2 ∑n i=1 ‖A(i)‖^2 ‖B(i)‖^2

Include A(jt^ )/(spjt )^1 /^2 as a column of C and B(jt )/(spjt )^1 /^2 as a row of R

Approximating matrix multiplication (cont’d)

The input matrices are given in “sparse unordered representation,” e.g., their non-zero entries are presented as triples (i, j, Aij ) in any order The expectation of CR (element-wise) is AB The nonuniform sampling minimizes the variance of this estimator Easy to implement the sampling algorithm in two phases If the matrices are dense the algorithm runs in O(smp) time instead of O(nmp) time Require only O(sm + sp) memory space Does not tamper with the sparsity of the matrices For the above algorithm E (‖AB − CR‖ 2 ,F ) ≤

s

‖A‖F ‖B‖F

With probability at least 1 − δ ‖AB − CR‖ 2 ,F ≤

O(log(1/δ)) √ s

‖A‖F ‖B‖F

Approximating SVD in O(n) time

The complexity of computing SVD of a m by n matrix A is O(min(mn^2 , m^2 n)) (e.g., using Golub-Kahan algorithm) The top few singular vectors/values can be approximated faster using Lanczos/Arnoldi methods Let Ak be rank k approximation of A Ak is a matrix of rank k such that ‖A − Ak ‖ 2 ,F is minimized over all rank k matrices Approximate SVD in linear time O(m + n) I (^) sample c columns from A and rescale to form the m × c matrix C I (^) compute the m × k matrix Hk of the top k left singular vectors C Structural theorem: For any probabilities and number of columns ‖A − Hk H k> A‖^22 ,F ≤ ‖A − Ak ‖^22 ,F + 2

k‖AA>^ − CC >‖F Algorithmic theorem: If pi = ‖A(i)‖^22 /‖A‖^2 F and c ≤ 4 η^2 k/ε^2 , then ‖A − Hk H> k A‖^22 ,F ≤ ‖A − Ak ‖^22 ,F + ε‖A‖^2 F

Example of randomized SVD

Compute the top k left singular vectors of matrix C and restore them in the 512-by-k matrix Hk

Original matrix A After sampling columns C Hk H k> A

CX matrix decomposition

Goal: Find Am×n ≈ Cmטc X˜c×n so that A − CX small in some norm One way to approach this is min X ∈IRc×n^

‖A − CX ‖F = ‖A − C (C †A)‖F

where C †^ is the pseudoinverse of C SVD of A: Ak = Uk Σk V (^) k> where Ak is of m × n, Uk of m × k, Σ of k × k, and V (^) k> of k × n Subspace sampling: Vk is an orthogonal matrix containing the top k left singular vectors of A The columns of Vk are orthonormal vectors, but the rows of Vk , denoted by (Vk )(i) are not orthonormal vectors Subspace sampling in O(SVDk (A)) time

∀i = 1, 2 ,... , n, pi =

‖(Vk )(i)‖^22 k

Relative error CX

Relative error CX decomposition I (^) compute the probabilities pi I (^) for each i = 1, 2 ,... , n, pick the i-th column of A with probability min(1, cpi ) I (^) let C be the matrix containing the sampled columns

Theorem

For any k, let Ak be the best rank k approximation to A. In O(SVDk (A)) we can compute pi such that if c = O(k log k/ε^2 ) then with probability at least 1 − δ minX ∈IRc×n ‖A − CX ‖F = ‖A − CC †A‖F ≤ (1 + ε)‖A − Ak ‖F

The CUR decomposition

Sampling columns for C : use CX algorithm to sample columns of A I (^) C has ˜c columns in expectation C = UC ΣC V (^) C> m × ˜c m × ρ ρ × ρ ρ × ˜c I (^) UC is the orthogonal matrix containing the left singular vectors of C and ρ is the rank of C I (^) Let (UC )(i) denote the i-th row of U Sampling rows for R: I (^) subspace sampling in O(c^2 m) time with probability qi

∀i = 1, 2 ,... , m qi =

‖(UC )(i)‖^22 ρ I (^) R has ˜r rows in expectation Compute U: I (^) Let W be the intersection of C and R I (^) Let U be a rescaled pseudoinverse of W

The CUR decomposition (cont’d)

Put together

A ≈ CUR

A ≈ C

([

D W

]†

D

R

m × n m × ˜c ˜r × ˜c ˜r × n

where D is a diagonal rescaling matrix and

U = (DW )†D

Theorem

Given C , in O(c^2 m) time, one can compute qi such that

‖A − CUR‖F ≤ (1 + ε)‖A − C (C †A)‖F

holds with probability at least 1 − δ if r = O(c log c/ε^2 ) rows

Element-wise sampling

Main idea: I (^) to approximate matrix A, keep a few elements of the matrix (instead of sampling rows or columns) and zero out the remaining elements I (^) compute a rank k approximation to this sparse matrix (using Lanczos methods) Create the matrix S from A such that

Sij =

Aij /pij with probability pij 0 with probability 1 − pij

It can be shown that ‖A − S‖ 2 is bounded and the singular values of S and A are close Under additional assumptions the top k left singular vectors of S span a subspace that is close to the subspace spanned by the top k left singular vectors of A

Element-wise sampling (cont’d)

Approximating singular values fast: I (^) zero out a large number of elements of A, and scale the remaining ones appropriately I (^) compute the singular values of the resulting sparse matrix using iterative methods I (^) good choice for pij = sA

(^2) ij P i,j A^2 ij^ where^ s^ denotes the expected number of elements that we seek to keep in S I (^) Note each element is kept or discarded independently of the others Similar ideas that has been used to I (^) explain the success of Latent Semantic Indexing I (^) design recommendation systems I (^) speed up kernel computation