A FRAMEWORK FOR LEARNED C OUNT S KETCH
Anonymous authors
Paper under double-blind review
A BSTRACT
Sketching is a compression technique that can be applied to many problems to solve them quickly and approximately.
The matrices used to project data to smaller dimensions are called “sketches”.
In this work, we consider the problem of optimizing sketches to obtain low approximation error over a data distribution.
We introduce a general framework for “learning” and applying CountSketch , a type of sparse sketch.
The sketch optimization procedure has two stages: one for optimizing the placements of the sketch’s non-zero entries and another for optimizing their values.
Next, we provide a way to apply learned sketches that has worst-case guarantees for approximation error.
We instantiate this framework with three sketching applications: least-squares regression, low-rank approximation (LRA), and k -means clustering.
Our experiments demonstrate that our approach substantially decreases approximation error compared to classical and na¨ıvely learned sketches.
Finally, we investigate the theoretical aspects of our approach.
For regression and LRA, we show that our method obtains state-of-the art accuracy for ﬁxed time complexity.
For LRA, we prove that it is strictly better to include the ﬁrst optimization stage for two standard input distributions.
For k -means, we derive a more straightforward means of retaining approximation guarantees.
I NTRODUCTION
In recent years, we have seen the inﬂuence of machine learning extend far beyond the ﬁeld of artiﬁcial intelligence.
The underlying paradigm, which assumes that a given algorithm has an input distribution for which algorithm parameters can be optimized, has even been applied to classical algorithms. Examples of classical problems that have beneﬁtted from ML include cache eviction strategies, online algorithms for job scheduling, frequency estimation of data stream elements, and indexing strategies for data structures (Lykouris & Vassilvitskii, 2018; Purohit et al., 2018;
Hsu et al., 2019; Kraska et al., 2018).
This input distribution assumption is often realistic.
For example, many real-world applications use data streaming to track things like product purchasing statistics in real time.
Consecutively streamed datapoints are usually tightly correlated and closely ﬁt certain distributions.
We are interested in how this distributional paradigm can be applied to sketching, a data compression technique.
With the dramatic increase in the dimensions of data collected in the past decade, compression methods are more important than ever.
Thus, it is of practical interest to improve the accuracy and efﬁciency of sketching algorithms.
We study a sketching scheme in which the input matrix is compressed by multiplying it with a “sketch” matrix with a small dimension. This smaller, sketched input is then used to compute an approximate solution.
Typically, the sketch matrix and the approximation algorithm are designed to satisfy worst-case bounds on approximation error for arbitrary inputs.
With the ML perspective in mind, we examine if it is possible to construct sketches which also have low error in expectation over an input distribution. Essentially, we aim for the best of both worlds: good performance in practice with theoretical worst-case guarantees.
Further, we are interested in methods that work for multiple sketching applications.
Typically, sketching is very application-speciﬁc. The sketch construction and approximation algorithm are tailored to individual applications, like robust regression or clustering (Sarlos, 2006; Clarkson & Woodruff, 2009; 2014; 2017; Cohen et al., 2015; Makarychev et al., 2019). Instead, we consider three applications at once (regression, LRA, k -means) and propose generalizable methods, as well as extending previous application-speciﬁc work.
Our results.
At a high level, our work’s aim is to make sketch learning more effective , general , and ultimately, practical . We propose a framework for constructing and using learned CountSketch. We chose CountSketch because it is a sparse, input-independent sketch (Charikar et al., 2002).
Specifically, it has one non-zero entry ( ± 1 ) per column and does not need to be constructed anew for each input matrix it is applied to.
These qualities enable CountSketch to be applied quickly, since sparse matrix multiplication is fast and we can reuse the same CountSketch for different inputs.
Our “learned” CountSketch will retain this characteristic sparsity pattern and input-independence 1 , but its non-zero entries will range in R . We list our main contributions and follow this with a discussion.
• Two-stage sketch optimization : to ﬁrst place the non-zero entries and then learn their values.
• Theoretical worst-case guarantees, two ways : we derived a time-optimal method which applies to MRR, LRA, k -means, and more. We also proved a simpler method works for k -means. • SOTA experimental results : we showed the versatility of our method on 5 data sets with 3 types.
Our method dominated on the majority of experiments. • Theoretical analysis on the necessity of two stages
: we proved that including the ﬁrst stage is strictly better for LRA and two common input distributions. • Empirical demonstration of the necessity of two stages : showed that including the ﬁrst stage gives a 12 , 20% boost for MRR, LRA. Our sketch learning algorithm ﬁrst places the sparse non-zero entries using a greedy strategy, and then learns their values using gradient descent.
The resulting learned CountSketch is very different from the classical CountSketch: the non-zero entries no longer have random positions and ±values. As a result, the usual worst-case guarantees do not hold. We sought a way to obtain worst-case guarantees that was fast and reasonably general.
Our solution is a fast comparison step which performs an approximate evaluation of learned and classical sketches and takes the better of the two.
Importantly, we can run this step before the approximation algorithm without increasing its overall time complexity.
As such, this solution is time-optimal and applies to
MRR, LRA, k -means, and more. An alternate method was proposed by a previous work, but it was only proved for LRA (Indyk et al., 2019). This “sketch concatenation” method just involves sketching with the concatenation of a learned and a classical sketch.
Since it is somewhat simpler, we wanted to extend its applicability. In a novel theoretical result, we proved this works for k -means as well. We also ran a diverse set of experiments to demonstrate the versatility and practicality of our approach. We chose ﬁve data sets spanning three categories (image, text, and graph) to test our method on three applications (MRR, LRA, k -means).
Importantly, these experiments have real-world counterparts. For example, LRA and k -means can be used to compress images, applying SVD (LRA) to text data is the basis of a natural language processing technique, and LRA can be used to compute approximate max cuts on graph adjacency matrices. Ultimately, our method dominated on the vast majority of tests, giving a 31 , 70% improvement over classical CountSketch for MRR, LRA.
Finally, we conducted ablation study of the components of our algorithm. In another novel theoretical result, we proved that including the time-consuming ﬁrst optimization stage is strictly better than not to for LRA and two input distributions (spiked covariance and Zipﬁan). Empirically, this is case for all 3 applications.
Related work. In the last few years, there has been much work on leveraging ML to improve classical algorithms; we only mention a few examples here.
One related body of work is data-dependent dimensionality reduction, such as an approach for pair-wise/multi-wise similarity preservation for indexing big data (Wang et al., 2017) and a method for learning linear projections for general applications (Hegde et al., 2015).
We note that multiplying an input matrix on the left with a sparse sketch is equivalent to hashing its rows to a small number of bins.
Thus, we also ﬁnd connections with the body of work on learned hashes, most of which addresses the nearest neighbor search problem (see Wang et al.
for a survey).
However, in order to obtain approximation guarantees, our “hash function” (sparse sketch) must satisfy properties which these learned hashes usually do not, such as afﬁne (cid:15) -embedding
(Def. A.1).
In particular, we build off of the work of Indyk et al.
(2019), which introduced gradient descent optimization for the LRA application.
It also gave an LRA-speciﬁc method for worst-case guarantees.
We have surpassed the sketching performance and breadth of this work.
Namely, we introduce a sparsity pattern optimization step which is clearly crucial for sparse sketches. We also provide a more general method for worst-case guarantees and extend their method to k -means.
P RELIMINARIES
Our learned sketches have the sparsity pattern of the classical CountSketch.
The construction of this sketch is described below.
We also deﬁne afﬁne (cid:15) -embeddings, which is a class of sketches that includes CountSketch.
This (cid:15) -embedding property is desirable because it allows us to prove that certain sketching algorithms give (1 + (cid:15) ) -approximations.
Deﬁnition 2.1 (Classical CountSketch).
The CountSketch (abbreviated as CS) matrix S has one non-zero entry in each column with a random location and random value in {± 1 } .
Deﬁnition 2.2 (Afﬁne Embedding).
Given a pair of matrices A and B , a matrix S is an afﬁne (cid:15) -embedding
if for all X of the appropriate shape, (cid:107) S ( AX − B ) (cid:107) 2 F
= (1 ± (cid:15) )
(cid:107) AX − B (cid:107) 2 F .
Notation.
We denote the singular value decomposition (SVD) of A by A = U Σ V (cid:62) with orthogonal U, V and diagonal Σ .
Relatedly, the Moore-Penrose pseudo-inverse of A is A † =
V Σ − 1 U (cid:62) , where Σ − 1 is constructed by inverting the non-zero diagonal entries.
F RAMEWORK
We describe a framework for learned CountSketch that can be adopted by many different applications, including least-squares regression (MRR), low-rank approximation (LRA), and k -means clustering.
We will return to these applications in the next section. In this section, we ﬁrst describe how to optimize a CountSketch over a set of training samples.
Then, we explain how to use the learned CountSketch to achieve good expected performance with worst-case guarantees. By running a “fast comparison” step before the approximation algorithm, we can do this in optimal time.
S KETCH OPTIMIZATION
Most applications are optimization problems. That is, they are deﬁned by an objective function, L ( · ) .
For example, least-squares regression solves [Equation] given A ∈ R n × d , B ∈ R n × d (cid:48) . Of course, the optimal solution is a function of the inputs:
[Equation] However, in the sketching paradigm, we compute an approximately optimal solution as a function of the sketched (compressed) inputs. Taking CountSketch S ∈ R m × n for m (cid:28) n , we have: [Equation]
Our goal is to minimize the expected approximation error with respect to S , which is constrained to the set of CountSketch-sparse matrices ( CS ). However, this is simply equivalent to minimizing the objective value of the approximate solution. [Equation]
For ease of notation, we will deﬁne G ( · ) as a function which maps a sketch and inputs to an approximate solution. G ( · ) is deﬁned by the application-speciﬁc approximation algorithm. For MRR,
G ( S, ( A, B )) = ( SA ) † ( SB ) .
More generally, the sketch optimization objective is:
[Equation]
If the application is regression, we let A be ( A, B ) .
We will solve this constrained optimization in two stages.
For both stages, we approximate the expectation in empirical risk minimization (ERM) fashion.
That is, we approximate the expectation over the true distribution by averaging over a sampled batch of the training set.
Now, in the ﬁrst optimization stage, we compute positions for the CountSketch-sparse nonzero entries.
Then, in the second stage, we ﬁx the positions and optimize the nonzero values.
Stage 1: Placing the nonzero entries. We want to maintain the sparsity pattern of CS (one nonzero entry per column), but we are free to place that nonzero entry wherever we like for each column.
A na ¨ ıve method would be to evaluate the objective for the exponential number of full placements.
This is clearly intractable, so we consider a greedy alternative.
In essence, we construct the sketch one nonzero entry at a time, and we choose the location of the next entry by minimizing (3.1) over the discrete set of possibilities.
More precisely, we build the sketch S ∈ R m × n iteratively, placing one nonzero entry at a time.
For each nonzero entry, we consider m locations and 2 values for each location ( ± 1 ). We evaluate the sketch optimization objective (3.1) for all 2 m incremental updates to S and choose the minimizing update.
In the pseudo-code below, we iterate through the n columns of S , each of which contains a non-zero entry. Note that S w,j = S + w ( (cid:126)e j (cid:126)e i (cid:62) ) adds a single entry w to the i -th column, j -th row of the current, partially-constructed S .
Require:
A train =
{ A 1 , ..., A N } with A i ∈ R n × d ; sketch dimension m 1: initialize S
= O m × n 2: for i = 1 to n do : w ∗ , j ∗ = arg min w ∈{± 1 } ,j ∈ [ m ] (cid:80) A i ∈A train
5: end for For some applications it can be inefﬁcient to evaluate (3.1), since it requires computing the approximate solution. For MRR and LRA, the approximate solution has a closed form, but for k -means, it must be computed iteratively.
This is prohibitively expensive, since we perform many evaluations.
In this case, we recommend ﬁnding a surrogate L ( · ) with a closed-form solution, as we illustrate in later sections. Stage 2: Optimizing the nonzero values.
We now ﬁx the positions of the nonzero entries and optimize their values using gradient descent.
To ﬁx the positions, we represent S as just a vector of its nonzero entries, (cid:126)v ∈ R n . We will denote H ( (cid:126)v ) : R n → R m × n as the function which maps this concise representation of S to the full matrix.
H ( · ) depends on the positions computed in the last stage, which are ﬁxed. Now, we simply differentiate E A
∼D
[ L A ( G ( H ( (cid:126)v ) , A ))] (3.1) with respect to (cid:126)v .
Require:
A train =
{ A 1 , ..., A N } with A i ∈ R n × d ; H ( · ) from Alg. 1; learning rate α 1: for i = 1 to n iter do 2:
S =
O m × n 3: sample A batch from A train 4: (cid:126)v ← (cid:126)v − α (cid:32) (cid:80)
A ∈A batch ∂ L A ( G ( H ( (cid:126)v )) ,A ) ∂(cid:126)v (cid:33) 5: end for
L EARNED SKETCH WITH WORST - CASE GUARANTEES
We ﬁrst run a fast comparison between our learned sketch and a classical one and then run the approximation algorithm with the “winner”. This allows us to compute an approximate solution (to the applications we consider here; i.e., MRR and LRA) that does not perform worse than classical CountSketch.
In other words, our solution has the same worst-case guarantees as classical CountSketch.
The beneﬁt of this is that these guarantees hold for arbitrary inputs, so our method is protected from out-of-distribution inputs as well as in-distribution inputs which were not well-represented in the training data. More precisely, for a given input A , we quickly compute a rough estimate of the approximation errors for learned and classical CountSketches.
This rough estimate can be obtained by sketching.
We take the sketch with the better approximation error and use it to run the usual approximation algorithm. The choice to compute a rough estimate of the approximation error rather than the exact value is crucial here.
It allows us to append this fast comparison step without increasing the time complexity of the approximation algorithm.
Thus, the whole procedure is still time-optimal . Though this method is simple, an even simpler method exists for some applications.
Indyk et al.
proved that “sketch concatenation” (sketching with a classical sketch appended to the learned one) retains worst-case guarantees for LRA.
We prove that this also works for k -means clustering (Theorem 4.6).
Algorithm 3 L EARNED -S KETCH -A LGORITHM
Require: learned sketch S L ; classical sketch S C ; trade-off parameter β ; input data A 1: Deﬁne M L , M C such that L A ( G ( S L , A ))
= (cid:107) M L (cid:107) 2 F , L A ( G ( S C , A ))
= (cid:107) M C (cid:107) 2 F 2: S ← CountSketch ∈ R 1 β 2 × n , R ← CountSketch ∈ R 1 β 2 × d 3: ∆ L ← (cid:13)(cid:13) SM L R (cid:62) (cid:13)(cid:13) 2 F , ∆ C ← (cid:13)(cid:13) SM C R (cid:62) (cid:13)(cid:13) 2 F 4: if ∆ L ≤ ∆ C then 5: return G ( S L , A ) 6: end if 7: return G ( S C , A )
This algorithm can be used for applications that minimize a Frobenius norm.
In the MRR example, [Equation] so M L = A (cid:2) ( S L A ) † ( SB ) (cid:3) − B . Note that β is a parameter which trades off the precision of the approximation error estimate and the runtime of Algorithm 3.
I NSTANTIATIONS
For each of 3 problems (least-squares regression, low-rank approximation, k -means clustering), we deﬁne the problem’s objective, L A ( · ) , and the approximation algorithm, G ( · ) , which maps a sketch and inputs ( S, A ) to an approximate minimizer of L A ( · ) .
4. L EAST - SQUARES REGRESSION
We consider a generalized version of (cid:96) 2 regression called “multiple-response regression” (MRR).
Given a matrix of observations ( A ∈ R n × d , with n (cid:29) d ) and a matrix of corresponding values ( B ∈ R n × d (cid:48) , with n (cid:29) d (cid:48) ), the goal of MRR is to solve min X L ( A,B ) ( X ) =
min X (cid:107) AX − B (cid:107) 2 F
Approximation algorithm.
The algorithm is simply to sketch A, B with a sparse sketch S (e.g., CS) and compute the closed-form solution on SA, SB , which are small (Algorithm 4). Algorithm 4 S
(Sarlos, 2006; Clarkson & Woodruff, 2017)
Require: A ∈ R n × d , B ∈ R n × d (cid:48) , S ∈ R m × n 1: return: ( SA ) † ( SB )
Sketch optimization.
For both the greedy and gradient stages, we use the objective L ( A,B ) ( G ( S, ( A, B )))
= (cid:107) A ( SA ) + ( SB ) − B (cid:107) 2 F .
Learned sketch algorithm.
For ﬁxed accuracy, our learned sketch algorithm achieves stateof-the-art time complexity, besting the classical algorithm.
We prove an equivalent statement: the learned sketch algorithm yields better approximation error for ﬁxed time complexity.
(See
Lemma A.4 for the classical algorithm’s worst-case guarantee).
In the following theorem, we assume Alg.
3 uses a learned sketch which is an afﬁne β -embedding and also a classical sketch of the same size which is an afﬁne (cid:15) -embedding.
If β < (cid:15) , the above statement is true.
Theorem 4.1 (Learned sketching with guarantees for MRR).
Given a learned sparse sketching matrix S L ∈ R d 2 (cid:15) 2 × n which attains a (1 + γ ) -approximation for MRR on A ∈ R n × d , B ∈ R n × d (cid:48) ,
Alg. 3 gives a (1 + O ( β + min( γ, (cid:15) )))
-approximation for MRR on A in O (nnz( A )
+ nnz( B ) + d 5 d (cid:48) (cid:15) − 4 + dβ − 4 ) time where β is a trade-off parameter.
Remark 4.2.
By setting the trade-off parameter β − 4 = O ( (cid:15) − 4 d 4 d (cid:48) ) , Alg.
3 has the same asymptotic runtime as
the best (1 + (cid:15) ) -approximation algorithm of MRR with classical sparse embedding matrices. Moreover, Alg. 3 for MRR achieves a strictly better approximation bound (1 + O ( β + γ )) = (1 + o ( (cid:15) )) when γ = o ( (cid:15) ) . On the other hand, in the worst case scenario when the learned sketch performs poorly (i.e., γ = Ω( (cid:15) ) ) the approximation guarantee of Alg.remains (1 + O ( (cid:15) )) .
4. L OW - RANK APPROXIMATION
Given an input matrix A ∈ R n × d and a desired rank k , the goal of LRA is to solve
[Equation]
Approximation algorithm.
We consider the time-optimal (up to low order terms) approximation algorithm by Sarlos; Clarkson & Woodruff; Avron et al.
(Algorithm 5) with worst-case guarantees described in Lemma A.8. Algorithm 5 S al.
Require: A ∈ R n × d , S ∈ R m S × n , R ∈ R m R × d , S 2 ∈ R m S 2 × n , R 2 ∈ R m R 2 × d 1: U C (cid:2) T C T (cid:48) C (cid:3) ← S 2 AR (cid:62) , (cid:20) T (cid:62) D T (cid:48) (cid:62)
D (cid:21)
U (cid:62) D ← SAR
[Table]
with U C , U
[Table]
orthogonal
[Table]
← S [Table] AR (cid:62)
[Table] [Table] Z [Table]
L Z (cid:48) R
[Table]
[ U (cid:62) C GU D ]
[Table]
[Table]
Z L = (cid:2) Z (cid:48)
L T −(cid:62) D 0 (cid:3) , Z R = (cid:20) T [Equation]
1 C Z (cid:48) R(cid:21)
[Table]
Z = Z L Z R
[Table]
return: AR (cid:62) ZSA in form P n × k , Q k × d
Sketch optimization.
For the greedy stage, we optimize sketches S and R individually.
However, we do not use L A ( G (( S, R, S 2 , R 2 ) , A )) = (cid:107) X − A (cid:107) 2 F with X from Alg.
5 as the objective.
This is because the optimization for one sketch would then depend on the other sketches.
Instead, we use a proxy objective.
We observe that the proof that Alg. 5 is an (cid:15) -approximation uses the fact that the row space of SA and the column space of AR both contain a good rank- k approximation to A .
Thus, the proxy objectives for S and R are for k -rank approximation in the row/column space of SA / AR , respectively.
For example, the proxy objective for S is L A ( G ( S, A )) =
(cid:13)(cid:13)
[ AV ] k V (cid:62) − A
(cid:13)(cid:13) 2 F where V is from the SVD SA = U Σ V (cid:62) and [ · ] k takes the optimal k -rank approximation using truncated SVD.
The proxy objective for R is deﬁned analogously.
For the gradient stage, we optimize all four sketches ( S, R, S 2 , R 2 ) simultaneously using
L A ( G (( S, R, S 2 , R 2 ) , A ))
= (cid:107) X − A (cid:107) 2 F with X from Algorithm 5, since it can easily be implemented with differentiable functions.
Learned sketch algorithm.
Just like for regression (Section 4.1), we can prove that our learned sketch algorithm achieves a better accuracy than the classical one given the same runtime.
Theorem 4.3 (Low-Rank Approximation).
Given learned sparse sketching matrix S L ∈
R poly( k (cid:15) ) × n , R L ∈ R poly( k (cid:15) )
× d which attain a (1 + γ ) -approximation for LRA on A ∈ R n × d , Alg.gives a (1 + β + min( γ, (cid:15) )) -approximation for LRA on A in O (nnz( A ) + ( n + d ) poly( k(cid:15) ) + k 4 β 4 · poly( k(cid:15) )) time where β is a trade-off parameter.
Remark 4.4.
For (cid:15) (cid:29) k ( n + {+d ) − 4 , by setting the trade-off parameter β − 
 = O ( k+} ( n + d ) − 4 ) , Alg.has the same asymptotic runtime as
the best (1 + (cid:15) ) -approximation algorithm of LRA with classical sparse embedding matrices. Moreover, Alg. 3 for LRA achieves a strictly better approximation bound (1 + O ( β + γ )) = (1 + o ( (cid:15) )) when γ = o ( (cid:15) ) . On the other hand, in the worst case scenario when the learned sketches perform poorly (i.e., γ = Ω( (cid:15) ) ) the approximation guarantee of Alg.remains (1 + O ( (cid:15) )) .
Greedy stage offers strict improvement.
Finally, we prove for LRA that including the greedy stage is strictly better than not including it.
We can show this for two different natural distributions (spiked covariance and Zipﬁan).
The intuition is that the greedy algorithm separates heavy-norm rows (which are important “directions” in the row space) into different bins.
Theorem 4.5.
Consider a matrix A from either the spiked covariance or Zipﬁan distribution.
Let
S L denote a sparse sketch that Algorithm 1 has computed by iterating through indices in order of non-increasing row norms of A .
Let S C denote a CountSketch matrix.
Then, there is a ﬁxed η >such that min
[Table]
4. k - MEANS CLUSTERING
Let A ∈ R n × d represent a set of n points, A 1 , . . .
, A n ∈ R d .
In k -means clustering, the goal is to ﬁnd a partition of A 1 , ..., A n into k clusters C
= { C 1 , . . .
, C k } to
[Equation]
where µ i denotes the center of cluster C i .
Approximation algorithm.
First, compress A into AV , where V is from SVD SA = U Σ V (cid:62) and
S ∈ R O ( k 2 /(cid:15) 2 ) × n is a CountSketch.
Then, we use an approximation algorithm for k -means, such as Lloyd’s algorithm with a k -means++ initialization (Lloyd, 1982; Arthur & Vassilvitskii, 2007).
Solving with AV gives a (1+ (cid:15) ) -approximation (Cohen et al., 2015) and Lloyd’s gives an O (log( k )) approximation, so we have a (1 + (cid:15) )
O (log( k )) approximation overall.
Sketch optimization.
k -means is an interesting case study because it presents a challenge for both stages of optimization.
For the greedy stage, we observe that k -means does not have a closed form solution, which means that evaluating the objective requires a (relatively) time-consuming iterative process.
In the gradient stage, it is possible to differentiate through this iterative computation, but propagating the gradient through such a nested expression is time-consuming.
Thus, a proxy objective which is simple and quick to evaluate would be useful for both stages.
Cohen et al.
showed that we get a good k -means solution if A is projected to an approximate top singular vector space .
This suggests that a suitable proxy objective would be low-rank approximation: L A ( G ( S, A )) =
(cid:13)(cid:13)
[ AV ] k V (cid:62) − A
(cid:13)(cid:13) 2 F , like in Section 4.2.
We use this objective for both the greedy and gradient stages.
Learned sketch algorithm.
For k -means, we can use a different method to obtain worst-case guarantees.
We prove that by concatenating a classical sketch to our learned sketch, our sketched solution will be a (1 + O ( (cid:15) ))
-approximation.
Theorem 4.6 (Sketch monotonicity property for k -means).
For a given classical CountSketch
S C ∈ R O (poly( k/(cid:15) ))
× n , sketching with any extension of S C (i.e., by a learned sparse sketch S L ) yields a better approximate solution for k -means than sketching with S C itself.
E VALUATION
We implemented and compared the following sketches:
• Ours : a sparse sketch for which both the values and the positions of the non-zero entries have been optimized • GD only : a sparse sketch with optimized values and random positions for non-zero entries • Random : classical random CountSketch
We also consider two “na¨ıvely” learned sketches for LRA, which are computed on just one sample from the training set.
• Exact SVD : sketch as AV m , where V m contains the top m right singular vectors of random sample A i ∈
A train • Column sampling : sketch as AR , where R is computed from a randomly sampled A i ∈
A train .
Each column of R contains one entry. The location of this entry is sampled according to the squared column norms of A i ; the value of this entry is the inverse of the selected norm.
Data sets.
We used high-dimensional data sets of three different types (image, text, and graph) to test the performance and versatility of our method.
Note that the regression datasets are formed from the LRA/ k -means datasets by splitting each matrix into two parts
[Table] [Table] [Table]
https://
/dataset
Evaluation metric.
To evaluate the quality of a sketch S , we compute the difference between the objective value of the sketched solution and the optimal solution (with no sketching).
That is, the values in this section’s tables denote
[Equation]
averaged over 10 trials.
Analysis of results.
For least-squares regression and LRA, our method is the best.
It is significantly better than random, obtaining improvements of around 31% and 70% for MRR and LRA respectively compared to a classical sparse sketch.
For k -means, “Column Sampling” and “Exact SVD” dominated on several data sets.
However, we note that our method was always a close second and also, more importantly, the values for k -means were only trivially different ( < 1% ) between methods.
Ablation of greedy stage We ﬁnd empirically that including the greedy optimization stage is always better than not including it (compare the “Ours” vs. “SGD only” methods).
For regression,
LRA, and k -means, including this step offers around 12%, 20%, and < 1% improvement respectively.
We should note that for k -means, the values generally do not differ much between methods.
[Table] [Table]
[Table]
A A PPENDIX C ORRESPONDING TO S ECTION 4.1: L EAST -S QUARES R EGRESSION
Deﬁnition A.1 (Subspace Embedding).
Given an n × d matrix A , a matrix S is an afﬁne (cid:15) - embedding for (the column space of)
A if for x ∈ R d , (cid:107) SAx (cid:107)
= (1 ± (cid:15) )
(cid:107) Ax (cid:107) 22 .
The following result is shown in Clarkson & Woodruff (2017) and sharpened with Nelson & Nguy ˆ en (2013); Meng & Mahoney (2013).
Lemma A.2.
Given matrices A, B with n rows, a sparse embedding matrix (i.e., random CS) with
O (rank( A ) 2 /(cid:15) 2 ) rows is an afﬁne (cid:15) -embedding matrix with constant probability.
Moreover, the matrix product SA can be computed in O (nnz( A )) time, where nnz( A ) denotes the number of non-zero entries of matrix A .
Lemma A.3 (Clarkson & Woodruff (2017); Lemma 40).
Let A be an n × d matrix and let S ∈
R O ( 1 (cid:15) 2 ) × n be a randomly chosen sparse embedding matrix (i.e., random CS).
Then with constant probability, (cid:107) SA (cid:107) 2 F = (1 ± (cid:15) ) (cid:107) A (cid:107) 2 F .
Lemma A.4 (Sarlos (2006); Clarkson & Woodruff (2017)).
Given classical CountSketch S ∈ R m × n , S KETCH -R EGRESSION ( A, B, S ) returns a (1 + (cid:15) ) -approximation in time
O (nnz( A )
+ nnz( B ) + dd (cid:48) m {+
 + min( d+} 2 m, dm 2 )) .
Proof: Since S is an afﬁne (cid:15) -embedding matrix of A, B , then
[Equation]
Next, by the normal equations, ( SA ) + ( SB ) is a minimizer of min X (cid:107) SAX − SB (cid:107) 2 F and is a (1 + 3 (cid:15) )
-approximate solution of min X (cid:107) AX − B (cid:107) 2 F .
To bound the runtime, note that since S is a CountSketch we can compute SA and SB in time
O (nnz( A ) + nnz( B )) and reduce the problem to an instance of multiple-response regression with m rows.
Then, we can solve the reduced size problem in time O ( dd (cid:48) m 2 + min( d 2 m, dm 2 )) :
O (min( dm 2 , d 2 m )) to compute ( SA ) + and O ( dd (cid:48) m 2 ) to compute ( SA ) + ( SB ) .
(cid:3)
Proof of Theorem 4.1.
By Lemma A.2, a random CS S O with O ( d 2 (cid:15) 2 ) rows is an afﬁne (cid:15) -embedding matrix of A, B with constant probability.
Next, let X L and X O be respectively the solutions returned by S KETCH -R EGRESSION ( A, B, S L ) and S KETCH -R EGRESSION ( A, B, S O ) .
By Lemma A.4, with constant probability,
[Equation]
Together with the assumption that the solution constructed from S L , which is denoted as X L , over A train is a γ -approximate solution,
[Equation]
Hence, it only remains to compute the minimum of (cid:107) AX L − B (cid:107) 2 F and (cid:107) AX O − B (cid:107) 2 F efﬁciently.
Note that it takes Ω( n · d · d (cid:48) ) to compute these values exactly .
However, for our purpose it sufﬁces to compare (1 + β ) -estimates of these values and return the minimum of the estimates.
To achieve this, we use two applications of Lemma A.3 with R (cid:62)
∈
R O ( [Equation]
2 ) × d (cid:48) , S ∈ R O ( [Equation] 2 ) × n .
For any X (cid:48) (in particular, both X O and X L ), with constant probability,
[Equation]
Let Γ L and Γ O respectively denote AX L − B and AX O − B and let Γ M = arg min( (cid:107) S Γ L R (cid:107) F , (cid:107) S Γ O R (cid:107) F ) .
By Eq.
(A.2) and union bound over of X O and X L , with constant probability,
[Equation]
Runtime Analysis.
By Lemma A.4, X O an X L can be computed in O (nnz( A )
+ nnz( B ) + d 5 d (cid:48) (cid:15) − 4 ) time.
Next, the time to compute ∆ L and ∆ O is
[Equation]
where X is either X O or X L and we use that fact that nnz( X ) ≤ d · d (cid:48) (i.e., the total number of cells in X ).
Thus, the total runtime of Algorithm 3 is O (nnz( A )
+ nnz( B ) + d 5 d (cid:48) (cid:15) − 4 + dβ − 4 ) .
(cid:3)
Theorem A.5 (Least Squares Regression).
Suppose there exists a learned, sparse, subspace embedding matrix S L computed over A train with poly( d(cid:15) ) rows that attains a β -approximation over
A test .
Then, there exists an algorithm that runs in time O
(nnz( A ) + poly( d/(cid:15) ))
that outputs a (1 + min( β, (cid:15) ))
-approximation to the least squares regression problem.
Proof: Note that to solve min x ∈ R d (cid:107)
Ax − b (cid:107) 2 , given a sparse embedding matrix S ∈ R m × n for the columns of A together with the vector b , the problem can be solved within (1 + (cid:15) )
-approximation in time nnz
( A ) + poly( d/(cid:15) )
(e.g., see Theorem 2.14 Woodruff (2014)).
The proof outline is similar to the proof of Theorem 4.1.
First, we compute solutions x L , x O ∈ R d to the given instance using respectively a learned sketching matrix S L and a learning-free sketching algorithm.
Then, we compare (cid:107)
Ax L − b (cid:107) 2 and (cid:107) Ax O − b (cid:107) 2 and report the better.
Note that since x L , x O are vectors, unlike the case of MRR, the naive comparison (i.e., without applying any sketching matrices) takes nnz( A ) .
Hence, the algorithm runs in time nnz
( A ) + poly( d/(cid:15) ) and returns a (1 + min( (cid:15), β ))
-approximate solution of the least squares regression problem.
Moreover, we can employ the best known sketching techniques for the least squares regression problem and achieve the dependence d/(cid:15) 2 in the running time (e.g., see Section 2.5 of Woodruff (2014)).
(cid:3)
A. C ORRESPONDING TO S ECTION 4.2: L OW - RANK APPROXIMATION
Lemma A.6.
Suppose that S ∈ R m S × n and R ∈ R m R ×
d are sparse afﬁne (cid:15) -embedding matrices for ( A (cid:62) , A ) and (( SA ) (cid:62) , A (cid:62) ) .
Then,
[Equation]
Proof: Consider the following multiple-response regression problem:
[Equation]
Note that since X =
I k is a feasible solution to Eq.
(A.3), min rank-
k X [Equation] A k X
[Equation] A [Equation] (cid:107)
A k − A (cid:107) 2 F .
Let S ∈ R m S × n be a sketching matrix that satisﬁes the condition of Lemma A. for A :
= A k and B := A .
By the normal equations, the rank- k minimizer of (cid:107) SA k X − SA (cid:107) 2 F is ( SA k ) + SA .
Hence,
[Equation]
which in particular shows that a (1 + (cid:15) ) rank- k approximation of A exists in the row space of SA .
In other words,
[Equation]
Next, let
R ∈ R m R ×
d be a sketching matrix that satisﬁes the condition of Lemma A.9 for A := ( SA ) (cid:62) and B :=
A (cid:62) .
Let Y denote the rank- k minimizer of (cid:13)(cid:13) R ( SA ) (cid:62) X
(cid:62) − RA (cid:62) (cid:13)(cid:13) 2 F .
Hence,
[Equation]
SA
[Equation]
Note that by the normal equations, again rowsp( Y (cid:62) ) ⊆ rowsp( RA (cid:62) ) and we can write Y =
AR (cid:62) Z where rank( Z ) = k .
Thus,
[Equation]
Lemma A.7 (Avron et al.
; Lemma 27).
For C ∈ R p × m (cid:48) , D ∈ R m × p (cid:48) , G ∈ R p × p (cid:48) , the following problem
[Equation]
can be solved in O ( pm (cid:48)
r C + p (cid:48)
mr D + pp (cid:48)
( r D + r C )) time, where r C = rank( C ) ≤ min { m (cid:48) , p } and r D = rank( D )
≤ min { m, p (cid:48) } .
Proof: Let U C and U (cid:62) D be orthogonal bases for colsp( C ) and rowsp( D ) , respectively, so that for each Z , CZD = U C Z (cid:48) U (cid:62) D for some Z (cid:48) .
Let P C and P D be the projection matrices onto the subspaces spanned by the rows of C (cid:62) and D (cid:62) , respectively: P C =
U C U (cid:62) C and P D =
U D U (cid:62) D .
Then by the Pythagorean theorem,
[Equation]
where the ﬁrst equality holds since P C U C
= U C
and
U (cid:62) D P D
= U (cid:62) D and the second equality follows from the Pythagorean theorem.
Hence,
[Equation]
Moreover,
[Equation]
where the ﬁrst equality holds since U (cid:62)
C U C
=
I and U (cid:62)
D U D
=
I , and the second equality holds since
U C and U (cid:62) D are orthonormal.
Hence,
[Equation]
Next, we can ﬁnd Z
=
[ U (cid:62) C GU D ] k by computing the SVD of U (cid:62) C GU D in form of Z L Z R where
Z L ∈ R m (cid:48) × k and Z R ∈ R k × m .
Runtime analysis.
We can compute U C and U D by the Gram-Schmidt process in time
O
( pm (cid:48)
r C + p (cid:48)
mr D ) , and U (cid:62) C GU D in time O (min { r C p (cid:48)
( p + r D ) , r D p ( p (cid:48)
+ r C ) } ) .
Finally, the time to compute
Z (i.e., an SVD computation of U (cid:62) C GU D ) is O
( r C r D · min { r C , r D } ) .
Since r C ≤ min { p, m (cid:48) } and r D ≤ min { p (cid:48) , m } , the total runtime to minimize Z in Eq.
(A.7) is O
( pm (cid:48)
r C + p (cid:48)
mr D + pp (cid:48)
( r C + r D )) .
(cid:3)
Lemma A.8.
Let S ∈ R poly( k/(cid:15) ) × d , R ∈ R poly [Equation]
k/ [Equation] ) × d be CS matrices such that [Equation]
Moreover, let S 2 ∈ R k 2 β 2 × n , and R 2 ∈ R k 2 β 2 ×
d be CS matrices. Then, Algorithm 5 runs in
O (nnz( A ) + ( n + d ) poly( k/(cid:15) )) time and with constant probability gives a (1 + O ( β + γ )) - approximate rank- k approximation of A .
Proof: The algorithm ﬁrst computes C = S 2 AR (cid:62) , D = SAR (cid:62) 2 , G = S 2 AR (cid:62) 2 which can be done in time O
(nnz( A )) .
As an example, we bound the time to compute C = S 2 AR .
Note that since S 2 is a CS, S 2 A can be computed in O (nnz( A )) time and the number of non-zero entries in the resulting matrix is at most nnz( A ) .
Hence, since R is a CS as well, C can be computed in time O
(nnz( A ) + nnz( S 2 A ))
=
O (nnz( A )) .
Then, it takes an extra poly( k/(cid:15) ) · k 2 β 2 time to store C, D and G in matrix form.
Next, as we showed in Lemma A.7, the time to compute Z in Algorithm 5 is O ( k 4 β 4 · poly( k/(cid:15) )) .
Finally, it takes ( n + d ) poly( k/(cid:15) ) time to compute Q = AR (cid:62) Z L and P = Z R SA and return the solution in the form of P n × k Q k × d .
Hence, the total runtime is O (nnz( A ) + ( n + d ) poly( k/(cid:15) )
+ k 4 β 4 · poly( k/(cid:15) )) .
The approximation guarantee follows from Eq.
(A.8) and the fact that S 2 and R 2 are respectively afﬁne β -embedding matrices of AR (cid:62) and SA (see Lemma A.2).
(cid:3)
Lemma A.9 (Avron et al.
; Lemma 25).
Suppose that A ∈ R n × d and B ∈ R n × d (cid:48) .
Moreover, let S be an oblivious sparse afﬁne (cid:15) -embedding matrix (i.e., a random CS) with (rank( A ) 2 /(cid:15) 2 ) rows.
Then with constant probability, ˜ X = arg min rank- k X (cid:107) SAX − SB (cid:107) 2 F , satisﬁes (cid:13)(cid:13)(cid:13) A ˜ X − B (cid:13)(cid:13)(cid:13) 2 F ≤ (1 + (cid:15) ) min rank
[Equation]
In other words, in O (nnz( A ) + nnz( B ))
+ ( d + d (cid:48) )
(rank( A ) 2 /(cid:15) 2 ) time, we can reduce the problem to a smaller (multi-response regression) problem with (rank( A ) 2 /(cid:15) 2 ) rows whose optimal solution is a (1 + (cid:15) ) -approximate solution to the original problem.
Proof of Theorem 4.3.
Let S O and R O be CountSketch matrices of size poly( k/(cid:15) ) × n and poly( k/(cid:15) )
× d .
Note that since rank( A k ) =
k and rank(( S O A ) (cid:62) ) ≤ poly( k/(cid:15) ) , S O and R O are respectively afﬁne (cid:15) -embedding matrices of ( A k , A ) and (( S O A ) (cid:62) ,
A (cid:62) ) .
Then, by an application of Lemma A.
[Equation]
Similarly, by the assumption that S L and R L ﬁnds a (1 + γ ) -approximate solution of LRA over matrices A ∈
A test , then
[Equation]
Next, let ( P L , Q L ) and ( P O , Q O ) be respectively the rank- k approximations of A in factored form using ( S L , R L ) and ( S O , R O )
(see Algorithm 5).
Then, Eq.
(A.10) together with Eq.
(A.9) implies that
[Equation]
A [Equation] [Equation] Hence, it only remains to compute the minimum of (cid:107) P L Q L − A (cid:107) 2 F and (cid:107) P O Q
O − A (cid:107) 2 F efﬁciently
and we proceed similarly to the proof of Theorem 4.1.
We use two applications of Lemma A. with R (cid:62)
∈
R O ( 1 β 2 ) × d , S ∈ R O ( 1 β 2 ) × n . Let Γ L = P L Q L − A , Γ O = P O Q O − A and Γ M = arg min( (cid:107) S Γ L R (cid:107) F , (cid:107) S Γ O R (cid:107) F ) .
Hence,
[Equation]
(cid:66) by Lemma A.
[Equation]
(cid:66) by Lemma A. [Equation] [Equation] A
[Equation]
A
[Equation]
F (cid:66) by Eq.
(A.11)
Runtime analysis.
By Lemma A.8, Algorithm 5 computes P L , Q L and P O , Q O in O (nnz( A )
+ ( n + d ) poly( k(cid:15) )
+ k 4 β 4 · poly( k(cid:15) )) .
Next, it takes O (nnz( A ) + ( n + d ) · k + kβ 4 ) to compute ∆ L and ∆ O .
As an example, we bound the amount of time required to compute SP L Q L R − SAR corresponding to ∆ L .
Since S and R are sparse sketching matrices, SP L , Q L R and SAR can be computed in nnz( SP L ) + nnz( Q L R ) + nnz( A ) .
Since SP L and Q L R are respectively of size 1 β 2 ×
k
and k × 1 β 2 , in total it takes O (nnz( A )+ kβ 2 ) to compute these three matrices.
Then, we can compute SP L Q L R and (cid:107)
SP L Q L RSAR (cid:107) F in time
O ( kβ 4 ) .
Hence, the total runtime of Algorithm 3 for LRA is O (nnz( A )+( n + d ) · poly( k(cid:15) )
+ k 4 β 4 · poly( k(cid:15) )) .
(cid:3)
A. C ORRESPONDING TO S ECTION 4.3: k - MEANS
We restate notation and the main result below for ease of reference.
Notation.
We deﬁne A m as the optimal rank- m approximation of A formed by truncated SVD:
A m =
U m Σ m V (cid:62) m .
Given a matrix U with orthogonal columns, let π U ( A ) = AUU (cid:62) , which is the projection of the rows of A onto col ( U ) .
Let C U be the optimal k -means partition of π U ( A ) .
Further, we let µ C U,i denote the i -th cluster’s center in the optimal k -means clustering on π U ( A ) .
We denote dist 2 ( A, µ ) as the k -means loss given cluster centers (and their corresponding partition):
[Equation]
Likewise, cost ( C ) is the k -means loss given a partition:
[Equation]
Deﬁnition A.10 (Projection-cost preserving sketch).
˜
A is a projection-cost preserving sketch of
A if for any low rank projection matrix P and c not dependent on P :
[Equation]
Theorem (4.6: Sketch monotonicity property for k -means).
Assume we have A ∈ R n × d .
We also have random CountSketch S ∈ R O (poly( k/(cid:15) ))
× n and deﬁne
U ∈ R d × O (poly( k/(cid:15) )) with orthogonal columns such that colsp( U ) =
rowsp( SA ) .
Then, any extension of S to S (cid:48) (for example, concatenation with a learned CountSketch S L ) yields a better approximate k -means approximation.
Speciﬁcally, deﬁne W with orthogonal columns such that col ( W ) = row ( S (cid:48)
A ) .
Let C ∗ denote the optimal partition of A , C U denote the optimal partition of π U ( A ) , and C W denote the optimal partition of π W ( A ) .
Then
[Equation]
Proof:
[Equation]
≤ (cid:88) i ∈ [ k ] (cid:88) j ∈ C U,i (cid:107) A j − π W ( A j ) (cid:107) 2 + (cid:13)(cid:13) π W ( A j ) − µ C U,i (cid:13)(cid:13)(A.13) = (cid:88)
i ∈ [ k ] (cid:88) j ∈ C U,i (cid:13)(cid:13) A j − µ C U,i (cid:13)(cid:13)(A.14) ≤ (1 + (cid:15) )
(cid:88) i ∈ k min µ i (cid:88)
j ∈ C U,i (cid:107)
A j − µ i (cid:107)(A.15) =
(1 + (cid:15) ) cost ( C U ) ≤ (1 + O ( (cid:15) ))
cost ( C ∗ ) (cid:3) (A.
µ C W ∈ colsp(
W so we can apply the Pythagorean Theorem. A.13): ( µ C W , C W ) is an optimal k -
means
clustering of the projected points π W ( A ) A.14): µ C U ∈ colsp( U ) ⊂ colsp( W ) , so we can
apply the Pythagorean Theorem. (A.15): We apply Corollary A.
Remark A.11.
Our result shows that the “sketch monotonicity” property holds for sketching matrices that provide strong coresets for k -means clustering.
Besides strong coresets, an alternate approach to showing that the clustering objective is approximately preserved on sketched inputs is to show a weaker property: the clustering cost is preserved for all possible partitions of the points into k groups Makarychev et al.
While the dimension reduction mappings satisfying strong coresets require poly( k/(cid:15) ) dimensions, Makarychev et al.
(2019) shows that O (log k/(cid:15) 2 ) dimensions sufﬁce to satisfy this “partition” guarantee.
An interesting question for further research is if the sketch monotonicity guarantee also applies to the construction of Makarychev et al.
Corollary A.12.
Assume we have A ∈ R n × d , j ∈ Z + , (cid:15) > 0 .
Deﬁne m = min( O (poly( j/(cid:15) )) , d ) .
Let ˜ A m be a (1 + (cid:15) ) -approximation to A m of the form ˜
A m =
AV V (cid:62) where SA = U Σ V (cid:62) for
CountSketch S ∈ R m × n .
Let X ∈ R
d
× j be a matrix whose columns are orthonormal, and let
Y ∈ R d × ( d − j ) be a matrix with orthonormal columns that spans the orthogonal complement of colsp ( X ) .
Then
[Equation]
Proof:
[Equation]
(A.16)
Note that rank( X ) =
j , so rank( A ( I − V V (cid:62) )
XX (cid:62) )
=
j .
We use this fact to bound the Frobenius norm by the operator norm.
(A.17) Using the fact that XX (cid:62) is a projection.
(A.18) Using Lemma 18 from Cohen et al.
(2015), where A j is the optimal rank- j approximation to A .
We can apply this lemma because CountSketch is one of the eligible types of random projection matrices.
(A.19)Letting σ i be the singular values of A .
(A.20) (cid:80) min( n,d ) i = j
[Equation] AY [Equation] 2 F for Y ∈ R d × ( d − j ) with orthonormal columns.
Theorem A.13.
Assume we have A ∈ R n × d , j ∈ Z + , (cid:15) ∈
Deﬁne m = min( O (poly( j/(cid:15) )) , d ) .
Let ˜ A m be
a (1 + (cid:15) ) -approximation to A m of the form ˜
A m =
AV V (cid:62) where
SA = U Σ V (cid:62) for CountSketch S ∈ R m × n .
Then, for any non-empty set µ contained in a j -dimensional subspace, we have:
[Equation]
Proof: We follow the proof of Theorem 22 in Feldman et al.
but substitute different analyses in place of Corollaries 16 and 20.
The result of Feldman et al.
(2013) involves the best rank- m approximation of A , A m ; we will show it for the approximate rank- m approximation, ˜
A m .
Deﬁne X ∈ R d × j with orthonormal columns such that colsp( X ) = span( µ ) .
Likewise, deﬁne
Y ∈ R d × ( d − j ) with orthonormal columns such that colsp( Y ) =
span( µ ) ⊥ .
By the Pythagorean theorem:
[Equation]
and
[Equation]
(A. [Equation]
Hence,
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table] [Equation] [Table] [Equation]
[Table]
[Equation] [Table] [Equation] [Table]
[Equation] [Table] [Equation] [Table]
[Equation]
Used (A.21)
[Equation]
A.24) (A.22)
Triangle inequality.
(A.23) Take (cid:15) in Theorem 16 from Cohen et al. (2015) as (cid:15) 2 / 8 .
This theorem implies that ˜
A m is a projection-cost preserving sketch with the c term as (cid:13)(cid:13)(cid:13)
A − ˜
A m (cid:13)(cid:13)(cid:13) 2 F .
Speciﬁcally, it says AV is a project-cost preserving sketch, which means ˜
A m =
AV V (cid:62) is too: V has orthonormal columns so [Equation] I
[Equation]
By Corollary A.12,
[Equation]
Since µ ∈ rowsp( X ) , we have (cid:107) AY (cid:107) 2 F ≤ dist 2 ( A, µ ) .
Using Corollary 21 from Feldman et al.
(2013) while taking (cid:15) as (cid:15)/ 4 , A as ˜
A m XX T , and B as AXX T yields | dist 2 ( ˜ A m XX T , µ ) − dist 2 ( AXX T , µ ) | ≤ (cid:15) 4 · dist 2 ( AXX T , µ )+(1+4 (cid:15) ) · (cid:13)(cid:13)(cid:13) ˜
A m XX T − AXX T (cid:13)(cid:13)(cid:13) 2 F
By A.21, dist 2 ( AXX T , µ ) ≤ dist 2 ( A, µ ) .
Finally, we combining the last two inequalities with (A.24):
[Equation]
where in the last inequality we used the assumption (cid:15) ≤ 1 .
[Equation]
Corollary A.14.
Assume we have A ∈ R n × d and CountSketch S ∈ R O (poly( k/(cid:15) ))
× n .
Then, deﬁne
U ∈ R
d
× O (poly( k/(cid:15) )) with orthogonal columns spanning row ( SA ) .
Also deﬁne A U
=
π U ( A ) and µ U as the set of optimal cluster centers found on A U .
Now, assume (cid:15) ∈ (0 , 1 / 3] .
Then, µ U is a (1 + (cid:15) ) -approximation to the optimal k -means clustering of A .
That is, deﬁning µ ∗ U as the cluster centers which minimize the cost of partition C U on A , we have:
[Equation]
Proof: By using (cid:15) 3 in Theorem A.13 with j as k ,
[Equation]
which implies that
[Equation]
Likewise, by Theorem A.13 on A U and µ ∗ U (and taking j as k ), [Equation] [Equation] A, µ
[Equation]
which implies that
[Equation]
[Equation]
By (A.25) and (A.26) together, we have:
[Equation]
Now, 1+ (cid:15)/ 3 1 − (cid:15)/ 3 ≤ 1 + (cid:15) , so we have dist 2 ( A, µ U ) ≤ (1 + (cid:15) ) dist 2 ( A, µ ∗ U ) .
(cid:3)
B S PECTRAL N ORM G UARANTEE FOR Z IPFIAN M ATRICES
In this section, we show that if the singular values of the input matrix A follow a Zipﬁan distribution (i.e., σ i ∝ i − α for a constant α ), we can ﬁnd a (1 + (cid:15) )
rank-
k approximation of A with respect to the spectral norm.
A key theorem in this section is the following.
Theorem B.1 (Cohen et al.
(2015), Theorem 27).
Given an input matrix A ∈ R n × d , there exists an algorithm that runs in O (nnz( A )+( n + d ) poly( k/(cid:15) )) and returns a projection matrix P =
QQ (cid:62) such that with constant probability the following holds:
[Equation]
Next, we prove the main claim in this section.
There are various ways to prove this, using, for example, a bound on the s table rank of A ; we give the following short proof for completeness.
Theorem B.2.
Given a matrix A ∈ R n × d whose singular values follow a Zipﬁan distribution (i.e., σ i ∝ i − α ) with a constant α ≥ 1 / 2 , there exists an algorithm that computes a rank- k matrix B (in factored form) such that (cid:107) A − B (cid:107) 22 ≤ (1 + (cid:15) )
(cid:107) A − A k (cid:107) 22 .
Proof: Note that since the singular values of A follow a Zipﬁan distribution with parameter α , for any value of k , [Equation]
[Equation]
By an application of Theorem B.1, we can compute a matrix B in a factored form in time
O (nnz( A ) + ( n + d ) poly( k/(cid:15) ))
such that with constant probability,
[Equation]
C G REEDY I NITIALIZATION
In this section, we analyze the performance of the greedy algorithm on the two distributions mentioned in Theorem 4.5.
Preliminaries and Notation.
Left-multiplying A by CountSketch S ∈ R m × n is equivalent to hashing the rows of A to m bins with coefﬁcients in {− 1 , 1 } .
The greedy algorithm proceeds through the rows of A (in some order) and decides which bin to hash to, denoting this by adding an entry to S .
We will denote the bins as b i and their summed contents as w i .
C. S PIKED COVARIANCE MODEL WITH SPARSE LEFT SINGULAR VECTORS .
To recap, every matrix A ∈ R n × d from the distribution A sp ( s, (cid:96) ) has s < k “heavy” rows ( A
r 1 , · · · , A r s ) of norm (cid:96) > 1 .
The indices of the heavy rows can be arbitrary, but must be the same for all members of the distribution and are unknown to the algorithm.
The remaining rows (called “light” rows) have unit norm.
In other words: let R = { r 1 , . . .
, r s } .
For all rows A i , i ∈ [ n ] :
[Equation]
where v i is a uniformly random unit vector.
We also assume that S r , S g ∈ R k × n and non-increasing row norm ordering for the greedy algorithm.
Proof sketch.
First, we show that the greedy algorithm using a non-increasing row norm ordering will isolate heavy rows (i.e., each is alone in a bin).
Then, we conclude by showing that this yields a better k -rank approximation error when d is sufﬁciently large compared to n .
We begin with some preliminary observations that will be of use later.
It is well known that a set of uniformly random vectors are (cid:15) -almost orthogonal (i.e., the magnitudes of their pairwise inner products are at most (cid:15) ).
Observation C.1.
Let v 1 , · · · , v n ∈ R
d be a set of random unit vectors.
Then with high probability |(cid:104) [Equation] i , [Equation]
We deﬁne (cid:15) = [Equation] (cid:113) log nd .
Observation C.2.
Let u 1 , · · · , u t be a set of vectors such that for each pair of i < j ≤ t , |(cid:104) u i (cid:107) u i (cid:107) , u j (cid:107) u j (cid:107) (cid:105)| ≤ (cid:15) , and g i , · · · , g j ∈ {− 1 , 1 } .
Then, t (cid:88) i = (cid:107) u i (cid:107) 22 − 2 (cid:15) (cid:88) i<j ≤ t (cid:107) u i (cid:107) 2 (cid:107) u j (cid:107) 2 ≤ (cid:13) (cid:13) (cid:13)(cid:13)(cid:13) t (cid:88) i = g
i u i (cid:13) (cid:13) (cid:13)(cid:13)(cid:13)  ≤ t (cid:88) i = (cid:107) u i (cid:107) 22 + 2 (cid:15) (cid:88) i<j ≤ t (cid:107) u i (cid:107) 2 (cid:107) u j (cid:107)(C.1)
Next, a straightforward consequence of (cid:15) -almost orthogonality is that we can ﬁnd a QR-factorization of the matrix of such vectors where R (an upper diagonal matrix) has diagonal entries close to 1 and entries above the diagonal are close to 0 .
Lemma C.3.
Let u 1 , ·
· · , u t ∈ R
d be a set of unit vectors such that for any pair of i < j ≤ t , |(cid:104) u i , u j (cid:105)| ≤ (cid:15) where (cid:15)
=
O ( t − 2 ) .
There exists an orthonormal basis e 1 , · · · , e t for the subspace spanned by u 1 , · · · , u t such that for each i ≤ t , u i = (cid:80) ij =1 a i,j e j where a 2 i,i ≥ 1 − (cid:80) i − 1 j =1 j 2 · (cid:15)and for each j < i , a 2 i,j ≤ j 2 (cid:15) 2 .
Proof: We follow the Gram-Schmidt process to construct the orthonormal basis e 1 , · · · , e t of the space spanned by u 1 , · · · , u t .
by ﬁrst setting e 1 = u 1 and then processing u 2 , · · · , u t , one by one.
The proof is by induction.
We show that once the ﬁrst j vectors u 1 , · · · , u j are processed the statement of the lemma holds for these vectors.
Note that the base case of the induction trivially holds as u 1 = e 1 .
Next, suppose that the induction hypothesis holds for the ﬁrst (cid:96) vectors u 1 , · · · , u (cid:96) .
Claim C.4.
For each j ≤ (cid:96) , a 2 (cid:96) +1 ,j ≤ j 2 (cid:15) 2 .
Proof: The proof of the claim is itself by induction.
Note that, for j = 1 and using the fact that |(cid:104) u 1 , u (cid:96) +1 (cid:105)| ≤ (cid:15) , the statement holds and a 2 (cid:96) +1 , 1 ≤ (cid:15) 2 .
Next, suppose that the statement holds for all j ≤ i < (cid:96) , then by |(cid:104)
u
i +1 , u (cid:96) +1 (cid:105)| ≤ (cid:15) , | a (cid:96) +1 ,i +1 | ≤ ( |(cid:104) u (cid:96) +1 ,
u i +
|
+ i (cid:88)
j = | a (cid:96) +1 ,j | · | a i +1 ,j | ) / | a
i +1 ,i +1 | ≤ ( (cid:15) + i (cid:88)
j = j 2 (cid:15) 2 ) /
| a
i +1 ,i +1 | (cid:66) by induction hypothesis on a (cid:96) +1 ,j for j ≤ i ≤ ( (cid:15)
+ i (cid:88)
j = j 2 (cid:15) 2 ) /
(1 − i (cid:88)
j = j 2 · (cid:15) 2 ) 1 /(cid:66) by induction hypothesis on a
i +1 ,
i + ≤ ( (cid:15) + i (cid:88)
j = j 2 (cid:15) 2 ) · (1 − i (cid:88)
j = j 2 · (cid:15) 2 ) 1 / 2 · (1 + 2 · i (cid:88)
j = j 2 (cid:15) 2 ) ≤ ( (cid:15) + i (cid:88)
j = j 2 (cid:15) 2 ) · (1 + 2 · i (cid:88)
j = j 2 (cid:15) 2 ) ≤ (cid:15) (( i (cid:88)
j = j 2 (cid:15) ) · (1 + 4 (cid:15) · i (cid:88)
j = j 2 (cid:15) ) + 1) ≤ (cid:15) ( i + 1) (cid:66) by (cid:15)
=
O ( t − 2 ) (cid:3)
Finally, since (cid:107) u (cid:96) +1 (cid:107) 22 = 1 , a [Equation] ≥ [Equation]
− [Equation] [Equation]
Corollary C.5.
Suppose that (cid:15) =
O ( t − 2 ) .
There exists an orthonormal basis e 1 , · · · , e t for the space spanned by the randomly picked vectors v 1 , · · · , v t , of unit norm, so that for each i , v i = (cid:80) ij =1 a i,j e j where a 2 i,i ≥ 1 − (cid:80) i − 1 j =1 j 2 · (cid:15) 2 and for each j < i , a 2 i,j ≤ j 2 · (cid:15) 2 .
Proof: The proof follows from Lemma C.3 and the fact that the set of vectors v 1 , · · · , v t are (cid:15) -almost orthogonal (by Observation C.1).
[Equation]
The ﬁrst main step is to show that the greedy algorithm (with non-increasing row norm ordering) will isolate rows into their own bins until all bins are ﬁlled.
In particular, this means that the heavy rows (the ﬁrst to be processed) will all be isolated.
We note that because we set rank( SA )
=
k , the k -rank approximation cost is the simpliﬁed expression (cid:13)(cid:13) AV V (cid:62) − A (cid:13)(cid:13) 2 F , where U Σ V (cid:62) =
SA , rather than (cid:13)(cid:13)
[ AV ] k V (cid:62) − A
(cid:13)(cid:13) 2 F .
This is just the projection cost onto row ( SA ) .
Also, we observe that minimizing this projection cost is the same as maximizing the sum of squared projection coefﬁcients: [Equation] [Table] [Equation]
[Equation]
In the following sections, we will prove that our greedy algorithm makes certain choices by showing that these choices maximize the sum of squared projection coefﬁcients.
Lemma C.6.
For any matrix A or batch of matrices A , at the end of iteration k , the learned CountSketch matrix S maps each row to an isolated bin.
In particular, heavy rows are mapped to isolated bins.
Proof: For any iteration i ≤ k , we consider the choice of assigning A i to an empty bin versus an occupied bin.
Without loss of generality, let this occupied bin be b i − 1 , which already contains A i − 1 .
We consider the difference in cost for empty versus occupied.
We will do this cost comparison for
A j with j ≤ i − 2 , j ≥ i + 1 , and ﬁnally, j ∈ { i − 1 , i } .
First, we let { e 1 , . . .
, e i } be an orthonormal basis for { A 1 , . . .
, A i } such that for each r ≤
i , A r = (cid:80) rj =1 a r,j e j where a r,r > 0 .
This exists by Lemma C.3.
Let { e 1 , . . .
, e i − 2 , e } be an orthonormal basis for { A 1 , . . .
A
i +2 , A
i − 1 ±
A i } .
Now, e = c
e
i − 1 + c 1 e i for some c 0 , c 1 because ( A i − 1 ±
A i ) − proj { e 1 ,...,e i − 2 } ( A i − 1 ±
A i ) ∈ span( e i − 1 , e i ) .
We note that c 2 0 + c 2 1 = 1 because we let e be a unit vector.
We can ﬁnd c 0 , c 1 to be:
[Equation]
j ≤ i − 2 : The cost is zero for both cases because A j ∈ span( { e 1 , . . .
, e i − 2 } ) .
j ≥ i + 1 : We compare the rewards (sum of squared projection coefﬁcients) and ﬁnd that { e 1 , . . .
, e i − 2 , e } is no better than { e 1 , . . .
, e i } .
[Equation]
j ∈ { i − 1 , i } : We compute the sum of squared projection coefﬁcients of A
i − 1 and A i onto e :
[Equation]
On the other hand, the sum of squared projection coefﬁcients of A i − 1 and A i onto e i − 1 ∪ e i is:
[Equation]
Hence, the difference between the sum of squared projections of A
i − 1 and A i onto e and e i − 1 ∪ e
i is ((C.4) - (C.3))
[Equation]
Thus, we ﬁnd that { e 1 , . . .
, e i } is a strictly better basis than { e 1 , . . .
, e i − 2 , e } .
This means the greedy algorithm will choose to place A i in an empty bin.
[Equation]
Next, we show that none of the rows left to be processed (all light rows) will be assigned to the same bin as a heavy row.
The main proof idea is to compare the cost of “colliding” with a heavy row to the cost of “avoiding” the heavy rows.
Speciﬁcally, we compare the decrease (before and after bin assignment of a light row) in the sum of squared projection coefﬁcients, lower-bounding it in the former case and upper-bounding it in the latter.
We introduce some results that will be used in Lemma C.10.
Claim C.7.
Let A k + r , r ∈
[1 , . . . , n − k ] be a light row not yet processed by the greedy algorithm.
Let { e 1 , . . .
, e k } be the Gram-Schmidt basis for the current { w 1 , . . .
, w k } .
Let β
= O ( n − 1 k − 3 ) upper bound the inner products of normalized A k + r , w 1 , . . .
, w k .
Then, for any bin i , (cid:104) e i , A k + r (cid:105) 2 ≤ β 2 · k 2 .
Proof: This is a straightforward application of Lemma C.3.
From that, we have (cid:104)
A k + r , e i (cid:105) 2 ≤ i 2 β 2 , for i ∈ [1 , . . .
, k ] , which means (cid:104)
A k + r , e i (cid:105) 2 ≤ k 2 β 2 .
(cid:3)
Claim C.8.
Let A k
+ r be a light row that has been processed by the greedy algorithm.
Let { e 1 , . . .
, e k } be the Gram-Schmidt basis for the current { w 1 , . . .
, w k } .
If A k + r is assigned to bin b k − 1 (w.l.o.g.), the squared projection coefﬁcient of A k + r onto e i , i (cid:54) =
k − 1 is at most 4 β 2 · k 2 , where β
= O ( n − 1 k − 3 ) upper bounds the inner products of normalized A k + r , w 1 , · · · , w k .
Proof: Without loss of generality, it sufﬁces to bound the squared projection of A k + r onto the direction of w k that is orthogonal to the subspace spanned by w 1 , · · · , w k − 1 .
Let e 1 , · · · , e k be an orthonormal basis of w 1 , · · · , w k guaranteed by Lemma C.3.
Next, we expand the orthonormal basis to include e k +1 so that we can write the normalized vector of A k + r as v k + r = (cid:80) k
+1 j =1 b j e j .
By a similar approach to the proof of Lemma C.3, for each j ≤ k − 2 , b j ≤ β 2 j 2 .
Next, since |(cid:104) w k , v k + [Equation] | ≤ β ,
[Equation]
similar to the proof of Lemma C.
< 2 β · k
Hence, the squared projection of A k + r onto e k is at most 4 β 2 · k 2 ·(cid:107)
A k + r (cid:107) 22 .
We assumed (cid:107)
A k + r (cid:107) .
(cid:3)
Claim C.9.
We assume that the absolute values of the inner products of vectors in v 1 , · · · , v n are at most (cid:15) < 1 / ( n 2 (cid:80)
A i ∈ b (cid:107)
A i (cid:107) 2 ) and the absolute values of the inner products of the normalized vectors of w 1 , · · · , w k are at most β
= O ( n − 3 k − 32 ) .
Suppose that bin b contains the row A k + r .
Then, the squared projection of A k + r onto the direction of w orthogonal to span( { w 1 , · · · , w k } \ { w } ) is at most (cid:107)
A k + r (cid:107) 42 (cid:107) w (cid:107)+ O ( n − 2 ) and is at least (cid:107)
A k + r (cid:107) 42 (cid:107) w (cid:107)− O ( n − 2 ) .
Proof: Without loss of generality, we assume that A k + r is mapped to b k ; w = w k .
First, we provide an upper and a lower bound for |(cid:104) v k + r , w k (cid:105)| where for each i ≤ k , we let w i =
w i (cid:107) w i (cid:107) 2 denote the normalized vector of w i .
Recall that by deﬁnition v k + r =
A k + r (cid:107)
A k + r (cid:107) 2 .
|(cid:104) w k , v k + r (cid:105)| ≤ (cid:107)
A k + r (cid:107) 2 + (cid:80)
A
i ∈
b k (cid:15) (cid:107)
A i (cid:107)(cid:107) w k (cid:107)≤ (cid:107)
A k + r (cid:107) 2 + n −(cid:107) w k (cid:107)(cid:66) by (cid:15) < n −(cid:80)
A i ∈
b k (cid:107) A i (cid:107)≤ (cid:107)
A k + r (cid:107)(cid:107) w k (cid:107) 2 + n −(cid:66) (cid:107) w k (cid:107) 2 ≥(C.5)
[Equation]
Now [Equation]
let { e [Equation] [Equation] e k } be an orthonormal basis for the subspace spanned by { w 1 , · · · , w k } guaranteed by Lemma C.3.
Next [Equation] we expand the orthonormal basis to include e k +1 so that we can write v k + r = (cid:80)
k +1 j =1 b j e j .
By a similar approach to the proof of Lemma C.3, we can show that for each j ≤ k − 1 , b 2 j ≤ β 2 j 2 .
Moreover,
[Equation]
by Lemma C.
[Equation]
β 2 · j 2 ) (cid:66) by (C.5) < β · k + (cid:112) 1 − β 2 k 3 · ( n − 2 + (cid:107)
A k + r (cid:107)(cid:107) w k (cid:107) 2 ) (cid:66) similar to the proof of Lemma C.
≤ O ( n − 2 ) + (1 + O ( n − 2 ))
(cid:107) A k + r (cid:107) 2 (cid:107) w k
(cid:107)(cid:66) by β
= O ( n − 3 k − 32 ) ≤ (cid:107)
A k + r (cid:107)(cid:107) w k (cid:107)
+ O ( n − 2 ) (cid:66) (cid:107)
A k + r (cid:107)(cid:107) w k (cid:107) 2 ≤and, | b k | ≥ |(cid:104) w k , e k
(cid:105)| · ( |(cid:104) w k , v k + r (cid:105)| − k − 1 (cid:88)
j
= | b j · (cid:104) w k , e j (cid:105)| ) ≥ |(cid:104) w k , v k + r (cid:105)| − k − 1 (cid:88)
j = β 2 · j(cid:66) since |(cid:104) w k , e k (cid:105)| ≤≥ (cid:107)
A k + r (cid:107)(cid:107) w k (cid:107) 2 − n − 2 − k − 1 (cid:88)
j = β 2 · j(cid:66) by (C.6) ≥ (cid:107)
A k + r (cid:107)(cid:107) w k (cid:107) 2 − O ( n − 2 ) (cid:66) by β
= O ( n − 3 k − 32 )
Hence, the squared projection of A k + r onto e k is at most (cid:107)
A k + r (cid:107) 42 (cid:107) w k (cid:107)
+ O ( n − 2 ) and is at least (cid:107)
A k + r (cid:107) 42 (cid:107) w k (cid:107) 22 −
O ( n − 2 ) .
(cid:3)
Now, we show that at the end of the algorithm no light row will be assigned to the bins that contain heavy rows.
Lemma C.10.
We assume that the absolute values of the inner products of vectors in v 1 , · · · , v n are at most (cid:15) < min { n − 2 k − 53 , ( n (cid:80) A i ∈ w (cid:107)
A i (cid:107) 2 ) − 1 } .
At each iteration k + r , the greedy algorithm will assign the light row
A k + r to a bin that does not contain a heavy row.
Proof: The proof is by induction.
Lemma C.6 implies that no light row has been mapped to a bin that contains a heavy row for the ﬁrst k iterations.
Next, we assume that this holds for the ﬁrst k + r − 1 iterations and show that is also must hold for the ( k + r ) -th iteration.
To this end, we compare the sum of squared projection coefﬁcients when A k + r avoids and collides with a heavy row.
First, we upper bound β = max i (cid:54) =
j ≤ k |(cid:104) w i , w j (cid:105)| / ( (cid:107)
w i (cid:107) 2 (cid:107) w j (cid:107) 2 ) .
Let c i and c j respectively denote the number of rows assigned to b i and b j .
[Equation]
[Table]
[Equation]
If A k + r is assigned to a bin that contains c light rows and no heavy rows.
In this case, the projection loss of the heavy rows A 1 , · · · , A s onto row ( SA ) remains zero.
Thus, we only need to bound the change in the sum of squared projection coefﬁcients of the light rows before and after iteration k + r .
Without loss of generality, let w k denote the bin that contains A k + r .
Since S k −= span( { w 1 , · · · , w k − 1 } ) has not changed, we only need to bound the difference in cost between projecting onto the component of w k − A k + r orthogonal to S k − 1 and the component of w k orthogonal to S k − 1 , respectively denoted as e k and e k .
I.
By Claim C.7, for the light rows that are not yet processed (i.e., A j for j > k + r ), the squared projection of each onto e k is at most β 2 k 2 .
Hence, the total decrease in the squared projection is at most ( n − k − r ) · β 2 k 2 .
II
By Claim C.8, for the processed light rows that are not mapped to the last bin, the squared projection of each onto e k is at most 4 β 2 k 2 .
Hence, the total decrease in the squared projection cost is at most ( r − 1) · 4 β 2 k 2 .
III.
For each row A i (cid:54) =
A k + r that is mapped to the last bin, by Claim C and the fact (cid:107) A
i (cid:107) 
 = (cid:107) A i
[Equation] 22 = 1 , the
squared projection of A i onto e
k
is
at most
[Equation]
k
[Equation]
A
[Equation]
+ O
[Equation]
n
[Equation]
) and the squared projection of A i onto e k is at least (cid:107)
[Equation]
[Equation]
Moreover, the squared projection of A k + r onto e k compared to e k increases by at least
[Equation]
Hence, the total squared projection of the rows in the bin b k decreases by at least:
[Equation]
Observation C
[Equation]
Hence, summing up the bounds in items I to III above, the total decrease in the sum of squared projection coefﬁcients is at most O ( n − 1 ) . If A k + r is assigned
to
a bin that contains a heavy row
Without loss of generality , we can assume that
A
k
+ r is mapped to b k that contains the heavy row A s
In this case, the distance of heavy rows A 1 , · · · , A s − 1 onto the space spanned by the rows of SA is zero
Next, we bound the amount of change in the squared distance of A s and light rows onto the space spanned by the rows of SA
Note that the ( k − 1) -dimensional space corresponding to w 1 , · · · , w k − 1 has not changed.
Hence, we only need to bound the decrease in the projection distance of A k + r onto e k compared to e k (where e k , e k are deﬁned similarly as in the last part).
For the light rows other than A k + r , the squared projection of each onto e k is at most β 2 k 2 .
Hence, the total increase in the squared projection of light rows onto e k is at most ( n − k ) · β 2 k 2 =
O ( n − 1 ) .
[Table] [Equation]
Hence, in this case
[Equation]
the total decrease in the squared projection is at least [Equation] Thus
[Equation]
for a sufﬁciently large value of (cid:96) [Equation] the greedy algorithm will assign A k + r to a bin that only contains light rows.
This completes the inductive proof and in particular implies that at the end of the algorithm, heavy rows are assigned to isolated bins.
[Equation]
Corollary C.11.
The approximation loss of the best rank- k approximate solution in the rowspace
S g A for A ∼ A sp ( s, (cid:96) ) where A ∈ R n × d for d = Ω( n 4 k 4 log n ) and S g is the CountSketch constructed by the greedy algorithm with non-increasing order is at most n − s .
Proof: First, we need to show that absolute values of the inner products of vectors in v 1 , · · · , v n is at most (cid:15) < min { n − 2 k − 2 , ( n (cid:80)
A
i ∈ w (cid:107) A i (cid:107) 2 ) − 1 } so that we can apply Lemma C.10.
To show this, note that by Observation C.1, (cid:15) ≤ 2 (cid:113) log nd ≤ n − 2 k − 2 since d = Ω( n 4 k 4 log n ) .
The proof follows from Lemma C.6 and Lemma C.10.
Since all heavy rows are mapped to isolated bins, the projection loss of the light rows is at most n − s .
(cid:3)
Next, we bound the Frobenius norm error of the best rank- k -approximation solution constructed by the standard CountSketch with a randomly chosen sparsity pattern.
Lemma C.12.
Let s = αk where 0 .
7 < α < 1 .
The expected squared loss of the best rank- k approximate solution in the rowspace S r A for A ∈ R n × d ∼ A sp ( s, (cid:96) ) where d = Ω( n 6 (cid:96) 2 ) and S r is the sparsity pattern of CountSketch is chosen uniformly at random is at least n + (cid:96)k 4 e − (1+ α ) k − n − O
Proof: We can interpret the randomized construction of the CountSketch as a “balls and bins” experiment.
In particular, considering the heavy rows, we compute the expected number of bins (i.e., rows in S r A ) that contain a heavy row.
Note that the expected number of rows in S r A that do not contain any heavy row is k · (1 − 1 k ) s ≥ k · e − sk − 1 .
Hence, the number of rows in S r A that contain a heavy row of A is at most k (1 − e − s k − 1 ) .
Thus, at least s − k (1 − e − s k − 1 ) heavy rows are not mapped to an isolated bin (i.e., they collide with some other heavy rows).
Then, it is straightforward to show that the squared loss of each such row is at least (cid:96) − n − O (1) .
Claim C.13.
Suppose that heavy rows A r 1 , · · · , A r c are mapped to the same bin via a CountSketch
S .
Then, the total squared distances of these rows from the subspace spanned by SA is at least ( c − 1) (cid:96) − O ( n − 1 ) .
Proof: Let b denote the bin that contains the rows A r 1 , · · · , A r c and suppose that it has c (cid:48) light rows as well.
Note that by Claim C.8 and Claim C.9, the squared projection of each row A r i onto the subspace spanned by the k bins is at most
[Equation]
Hence, the total squared loss of these c heavy rows is at least c(cid:96) − c · ( (cid:96)c + O ( n − 1 )) ≥ ( c − 1) (cid:96) −
O ( n − 1 ) .
(cid:3)
Hence, the expected total squared loss of heavy rows is at least:
[Equation]
(cid:66) s
= α · ( k − 1) where 0 .
7 < α <
[Equation]
(cid:66) [Equation] [Equation] Next, we compute a lower bound on the expected squared loss of the light rows.
Note that Claim C. and Claim C.9 imply that when a light row collides with other rows, its contribution to the total squared loss (which the loss accounts for the amount it decreases from the squared projection of the other rows in the bin as well) is at least 1 − O ( n − 1 ) .
Hence, the expected total squared loss of the light rows is at least:
[Equation]
Hence, the expected squared loss of a CountSketch whose sparsity is picked at random is at least
[Equation]
Corollary C.14.
Let s
= α ( k − 1)
where 0 .
7 < α < 1 and let (cid:96) ≥ (4 e +1) n αk .
Let S g be the
CountSketch whose sparsity pattern is learned over a training set drawn from A sp via the greedy approach.
Let S r be a CountSketch whose sparsity pattern is picked uniformly at random.
Then, for an n × d matrix A ∼ A sp where d = Ω( n 6 (cid:96) 2 ) , the expected loss of the best rank- k approximation of A returned by S r is worse than the approximation loss of the best rank- k approximation of A returned by S g by at least a constant factor.
Proof:
[Equation]
[Equation]
[Table]
[Equation]
Each matrix A ∈ R n × d ∼ A zipf has rows which are uniformly random and orthogonal.
Each A has 2 i +1 rows of squared norm n 2 / 2 2 i for i ∈ [1 , . . . , O (log( n ))] . We also assume that each row has the same squared norm for all members of A zipf .
In this section, the s rows with largest norm are called the heavy rows and the remaining are the light rows.
For convenience, we number the heavy rows 1 − s ; however, the heavy rows can appear at any indices, as long as any row of a given index has the same norm for all members of A zipf .
Also, we assume that s ≤ k/ 2 and, for simplicity, s = (cid:80) h s i
=
1 2 i +1 for some h s ∈ Z + .
That means the minimum squared norm of a heavy row is n 2 / 2 2 h s and the maximum squared norm of a light row is n 2 / 2 2 h s +2 .
The analysis of the greedy algorithm ordered by non-increasing row norms on this family of matrices is similar to our analysis for the spiked covariance model.
Here we analyze the case in which rows are orthogonal.
By continuity, if the rows are close enough to being orthogonal, all decisions made by the greedy algorithm will be the same.
As a ﬁrst step, by Lemma C.6, at the end of iteration k the ﬁrst k rows are assigned to different bins.
Then, via a similar inductive proof, we show that none of the light rows are mapped to a bin that contains one of the top s heavy rows.
Lemma C.15.
At each iteration k + r , the greedy algorithm picks the position of the non-zero value in the ( k + r ) -th column of the CountSketch matrix S so that the light row A k + r is mapped to a bin that does not contain any of top s heavy rows.
Proof: We prove the statement by induction.
The base case r = 0 trivially holds as the ﬁrst k rows are assigned to distinct bins.
Next we assume that in none of the ﬁrst k + r − 1 iterations a light row is assigned to a bin that contains a heavy row.
Now, we consider the following cases:
If A k + r is assigned to a bin that only contains light rows.
Without loss of generality we can assume that A k + r is assigned to b k .
Since the vectors are orthogonal, we only need to bound the difference
in the projection of A k + r and the light rows that are assigned to b k onto the direction of w k before and
after adding
A k + r
to
b k . In this case, the total squared loss corresponding to rows in b k and A k + r before
and after adding
A k +1 are
respectively before adding A k + r to b k : (cid:107) A k + r (cid:107) 22 + (cid:88)
A
[Table]
∈ b k
[Table]
A j (cid:107) 22 −
[Table]
k
[Table]
j
[Table]
) after adding A k + r to b k : (cid:107) A k + r (cid:107) 22 +
[Table]
[Table]
Thus the amount of increase in the squared loss is
[Equation] [Equation]
If A k + r is assigned to a bin that contains a heavy row.
Without loss of generality and by the induction hypothesis, we assume that A k + r is assigned to a bin b that only contains a heavy row A j .
Since the rows are orthogonal, we only need to bound the difference in the projection of A k + r and A j
In this case, the total squared loss corresponding to A j and A k + r before and after adding A k +
to b are respectively before adding A k + r to b k : (cid:107) A k + r (cid:107)after adding A k + r to b k : (cid:107)
A k + r (cid:107)[-
-]
[Equation]
A [-k + r (cid:107) 
-]j [Equation]
− [Equation]
r
[Equation]
Thus, the amount of increase in the squared loss is
[Equation]
Then (C.8) is larger than (C.7) if (cid:107) A j (cid:107) 22 ≥ (cid:80)
[Equation]
i
[Equation]
Next, we show that at every inductive iteration, there exists a bin b which only contains light rows and whose squared norm is smaller than the squared norm of any heavy row.
For each value m , deﬁne h m so that m =
(cid:80)
h m i =1
i +
= 2 h m +2 − 2 .
Recall that all heavy rows have squared norm at least n 2 2 2 hs .
There must be a bin b that only contains light rows and has squared norm at most [Equation] k [Equation]
2 and k > 2 h k
[Equation]
Hence, the greedy algorithm will map A k + r to a bin that only contains light rows.
[Equation]
Corollary C.16.
The squared loss of the best rank- k approximate solution in the rowspace of S g A for A ∈ R n × d ∼ A zipf where A ∈ R n × d and S g is the CountSketch constructed by the greedy algorithm with non-increasing order, is <
[Equation]
Proof: At the end of iteration k , the total squared loss is (cid:80) h n i = h
k
+1
i +1 · n 2 2 2 i .
After that, in each iteration k + r , by (C.7), the squared loss increases by at most (cid:107)
A k + r (cid:107) 22 .
Hence, the total squared loss in the solution returned by S g is at most
[Equation]
Next, we bound the squared loss of the best rank- k -approximate solution constructed by the standard
CountSketch with a randomly chosen sparsity pattern.
Observation C.17.
Let us assume that the orthogonal rows A r 1 , · · · , A r c are mapped to same bin and for each
i ≤ c , (cid:107) A r 1 (cid:107) 22 ≥ (cid:107)
A r i (cid:107) 22 .
Then, the total squared loss of A r 1 , · · · , A r c after projecting onto A r 1 ± · · · ± A r c is at least (cid:107) A r 2 (cid:107) 22 + · · · + (cid:107)
A r c (cid:107) 22 .
Proof: Note that since A r 1 , · · · , A r c are orthogonal, for each i ≤ c , the squared projection of A r i onto A r 1 ± · · · ± A r c is (cid:107)
A r i (cid:107) 42 / (cid:80) cj =1 (cid:13)(cid:13)
A r j (cid:13)(cid:13) 2 2 .
Hence, the sum of squared projection coefﬁcients of A r 1 , · · · , A r c onto A r 1 ± · · · ± A r c is
[Equation]
Hence, the total projection loss of A r 1 , · · · , A r c onto A r 1 ± · · · ± A r c is at least
[Equation]
In particular, Observation C.17 implies that whenever two rows are mapped into a same bin, the squared norm of the row with smaller norm fully contributes to the total squared loss of the solution.
Lemma C.18.
For k > 2 10 − 2 , the expected squared loss of the best rank- k approximate solution in the rowspace of S r A for A n × d ∼ A zipf , where S r is the sparsity pattern of a CountSketch chosen uniformly at random, is at least 1 .
095 n 2 2 hk − 2 .
Proof: In light of Observation C.17, we need to compute the expected number of collision between rows with “large” norm.
We can interpret the randomized construction of the CountSketch as a “balls and bins” experiment.
For each 0 ≤ j ≤ h k , let A j denote the set of rows with squared norm n 2 2
( hk − j ) and let A >j = (cid:83)
j<i ≤ h k A i .
Note that for each j , |A
j | = 2 h k − j +1 and |A >j | = (cid:80)
h
k
i
=
j +1
h k − i +1 =
(cid:80)
h k − j i =1 2 i = 2(
h k − j − 1) .
Moreover, note that k = 2(
h k
+1 − 1) .
Next, for a row A r in A j ( 0 ≤ j < h k ), we compute the probability that at least one row in A >j collide with A r .
Pr [ at least one row in A >j collide with A r ] = (
[Equation]
{+since 2 h k − j −
+}
h k +1 − 1 > 2 − j −
Hence, by Observation C.17, the contribution of rows in A j to the total squared loss is at least
[Equation]
Thus, the contribution of rows with “large” squared norm, i.e., A > 0 , to the total squared loss is at least
[Equation]
Corollary C.19.
Let S g be a CountSketch whose sparsity pattern is learned over a training set drawn from A sp via the greedy approach.
Let S r be a CountSketch whose sparsity pattern is picked uniformly at random.
Then, for an n × d matrix A ∼ A zipf , for a sufﬁciently large value of k , the expected loss of the best rank- k approximation of A returned by S r is worse than the approximation loss of the best rank- k approximation of A returned by S g by at least a constant factor.
Proof: The proof follows from Lemma C.18 and Corollary C.16.
[Equation]
Remark C.20.
We have provided evidence that the greedy algorithm that examines the rows of A according to a non-increasing order of their norms (i.e., greedy with non-increasing order ) results in a better rank- k solution compared to the CountSketch whose sparsity pattern is chosen at random.
However, still other implementations of the greedy algorithm may result in a better solution compared to the greedy with non-increasing order.
To give an example, in the following simple instance the greedy algorithm that check the rows of A in a random order (i.e., greedy with random order ) achieves a rank- k solution whose cost is a constant factor better than the solution returned by the greedy with non-increasing order.
Let A be a matrix with four orthogonal rows u, u, v, w where (cid:107) u (cid:107) 2 = 1 and (cid:107) v (cid:107)
= (cid:107) w (cid:107) 2 = 1 + (cid:15) and suppose that the goal is to compute a rank - 2 approximation of A .
Note that in the greedy with non-decreasing order, v and w will be assigned to different bins and by a simple calculation we can show that the copies of u also will be assigned to different bins.
Hence, the squared loss in the computed rank - 2 solution is 1 + (1+ (cid:15) )
2 2+(1+ (cid:15) ) 2 .
However, the optimal solution will assign v and w to one bin and the two copies of u to the other bin which results in the squared loss of (1 + (cid:15) ) 2 which is a constant factor smaller than the solution returned by the greedy with non-increasing order for sufﬁciently small values of (cid:15) .
On the other hand, in the greedy algorithm with random order, with a constant probability ( 13 + 18 ), the computed solution is the same as the optimal solution.
Otherwise, the greedy algorithm a with random order returns the same solution as the greedy algorithm with a non-increasing order.
Hence, in expectation, the solution returned by the greedy with random order is better than the solution returned by the greedy algorithm with non-increasing order by a constant factor.
D E XPERIMENTS - A PPENDIX D. B ASELINES
We comment on two of our baselines:
• Exact SVD :
In the canonical, learning-free sketching setting (i
e., any matrix is equally probable), sketching using the top m singular vectors yields a (1 + (cid:15) ) -approximation for both LRA and k -means Cohen et al.
• Column sampling :
In the canonical, learning-free sketching setting, sketching via column sampling yields a (1 + (cid:15) ) -approximation for k -means Cohen et al. (2015).
D. E XPERIMENTAL PARAMETERS
For the tables in Section 5, we describe experimental parameters.
First, we provide some general implementation details.
We implemented both the greedy (Algorithm 1) and stochastic gradient descent (Algorithm 2) algorithms in PyTorch.
In the ﬁrst case, PyTorch allowed us to harness GPUs to speed up computation on large matrices.
We used several Nvidia GeForce GTX 1080 Ti machines.
In the second case,
PyTorch allowed us to effortlessly compute numerical gradients for each task’s objective function.
Speciﬁcally, PyTorch provides automatic differentiation, which is implemented by backpropagation through chained differentiable operators.
There are also two points of note in the greedy algorithm implementation.
First, we noticed that for
MRR and LRA, each iteration required computing the SVD for many rank- 1 updates of the current
S .
Instead of computing the SVD from scratch for each of these variants, we ﬁrst computed the
SVD of S and then used fast rank- 1 SVD updates Brand (2006).
This greatly improved the runtime of Algorithm 1.
Second, we decided to set D w (the set of candidate row weights) to 10 samples in [ − 2 , 2] because we noticed most weights were in this range after running Algorithm 2.
D. R UNNING TIME
We examine the runtimes of our various sketching algorithms.
In Table D.1, the times are obtained for the LRA task with k = 30 , m = 60 on the logo data set.
However, similar trends should be expected for other combinations of task, task parameters, and data sets.
We deﬁne the inference runtime as the time to apply the sketching algorithm.
The training runtime is the time to train a sketch on A train and only applies to learned sketches.
Generally, the long training times are not problematic because training is only done once and can be completed ofﬂine.
On the other hand, the inference runtime should be as fast as possible.
Note that inference was timed using 1 matrix from A test on an Nvidia Geforce GTX 1080 Ti GPU.
The values were averaged over 10 trials.
We observe that sparse sketches (such as the ones used in GD only and Ours ) have much lower inference runtimes than the dense sketches of exact SVD .
[Table]