The Fast Convergence of Incremental PCA
Akshay Balsubramani, Sanjoy Dasgupta, Yoav Freund
Introduction
Here is a “learning rate” that is typically proportional to .
while .
If denote the top two eigenvalues of , then .
There are also other incremental estimators for which convergence has not been established; see, for instance, and .
In this paper, we analyze the rate of convergence of the Krasulina and Oja estimators. They can be treated in a common framework, as stochastic approximation algorithms for maximizing the Rayleigh quotient
The maximum value of this function is , and is achieved at (or any nonzero multiple thereof). The gradient is
Recently, there has been a lot of work on rates of convergence for stochastic gradient descent (for instance, ), but this has typically been limited to convex cost functions. These results do not apply to the non-convex Rayleigh quotient, except at the very end, when the system is near convergence. Most of our analysis focuses on the buildup to this finale.
We measure the quality of the solution at time using the potential function
Set starting time. Set the clock to time .
Update step. Perform either the Krasulina or Oja update, with .
The first step is similar to using a learning rate of the form , as is often done in stochastic gradient descent implementations . We have adopted it because the initial sequence of updates is highly noisy: during this phase moves around wildly, and cannot be shown to make progress. It becomes better behaved when the step size becomes smaller, that is to say when gets larger than some suitable . By setting the start time to , we can simply fast-forward the analysis to this moment.
2 Initialization
One possible initialization is to set to the first data point that arrives, or to the average of a few data points. This seems sensible enough, but can fail dramatically in some situations.
Here is an example. Suppose can take on just possible values: , where the are coordinate directions and is a small constant. Suppose further that the distribution of is specified by a single positive number :
Then has mean zero and covariance . We will assume that and are chosen so that ; in our notation, the top eigenvalues are then and , and the target vector is .
If is ever orthogonal to some , it will remain so forever. This is because both the Krasulina and Oja updates have the following properties:
If is initialized to a random data point, then with probability , it will be assigned to some with , and will converge to a multiple of that same rather than to . Likewise, if it is initialized to the average of data points, then with constant probability it will be orthogonal to and remain so always.
Setting to a random unit vector avoids this problem. However, there are doubtless cases, for instance when the data has intrinsic dimension , in which a better initializer is possible.
3 The setting of the learning rate
In order to get a sense of what rates of convergence we might expect, let’s return to the example of a random vector with possible values. In the Oja update , we can ignore normalization if we are merely interested in the progress of the potential function . Since the correspond to coordinate directions, each update changes just one coordinate of :
Recall that we initialize to a random vector from the unit sphere. For simplicity, let’s just suppose that and that this initial value is the all-ones vector (again, we don’t have to worry about normalization). On each iteration the first coordinate is updated with probability exactly , and thus
since . Likewise, for ,
If all goes according to expectation, then at time ,
(This is all very rough, but can be made precise by obtaining concentration bounds for .) From this, we can see that it is not possible to achieve a rate unless . Therefore, we will assume this when stating our final results, although most of our analysis is in terms of general . An interesting practical question, to which we do not have an answer, is how one would empirically set without prior knowledge of the eigenvalue gap.
4 Nested sample spaces
For , let denote the sigma-field of all outcomes up to and including time : . We start by showing that
To deal with this, we divide the analysis into epochs: the first takes from to , the second from to , and so on until finally drops below . We use martingale large deviation bounds to bound the length of each epoch, and also to argue that does not regress. In particular, we establish a sequence of times such that (with high probability)
The analysis of each epoch uses martingale arguments, but at the same time, assumes that remains bounded above. Combining the two requires a careful specification of the sample space at each step. Let denote the sample space of all realizations , and the probability distribution on these sequences. For any , we define a nested sequence of spaces such that each is -measurable, has probability , and moreover consists exclusively of realizations that satisfy the constraints (1) up to and including time . We can then build martingale arguments by restricting attention to when computing the conditional expectations of quantities at time .
5 Main result
There is a constant such that .
The eigenvalues of satisfy .
The step sizes are of the form .
Under these conditions, we get the following rate of convergence for the Krasulina update.
There are absolute constants and for which the following holds. Pick any , and any . Set the step sizes to , where , and set the starting time to . Then there is a nested sequence of subsets of the sample space such that for any , we have:
The result above also holds for the Oja update up to absolute constants.
6 Related work
There is an extensive line of work analyzing PCA from the statistical perspective, in which the convergence of various estimators is characterized under certain conditions, including generative models of the data and various assumptions on the covariance matrix spectrum and eigenvalue spacing . Such works do provide finite-sample guarantees, but they apply only to the batch case and/or are computationally intensive, rather than considering an efficient incremental algorithm.
Among incremental algorithms, the work of Warmuth and Kuzmin describes and analyzes worst-case online PCA, using an experts-setting algorithm with a super-quadratic per-iteration cost. More efficient general-purpose incremental PCA algorithms have lacked finite-sample analyses . There have been recent attempts to remedy this situation by relaxing the nonconvexity inherent in the problem or making generative assumptions . The present paper directly analyzes the oldest known incremental PCA algorithms under relatively mild assumptions.
Outline of proof
We now sketch the proof of Theorem 1.1; almost all the details are relegated to the appendix.
Recall that for , we take to be the sigma-field of all outcomes up to and including time , that is, .
We first bound the expected improvement in in each step of the Krasulina or Oja algorithms.
For any , we can write , where
and where is a -measurable random variable with the following properties:
The theorem follows from Lemmas A.4 and A.5 in the appendix. Its characterization of the two estimators is almost identical, and for simplicity we will henceforth deal only with Krasulina’s estimator. All the subsequent results hold also for Oja’s method, up to constants.
We know from Theorem 2.1 that , where is non-stochastic and is a quantity of positive expected value. Thus, in expectation, and modulo a small additive term, decreases monotonically. However, the amount of decrease at the th time step can be arbitrarily small when is close to 1. Thus, we need to show that is eventually bounded away from 1, i.e. there exists some and some time such that for any , we have .
To prove this, we start with a simple recurrence for the moment-generating function of .
Consider a filtration and random variables such that there are two sequences of nonnegative constants, and , for which:
Each takes values in an interval of length .
This relation shows how to define a supermartingale based on , from which we can derive a large deviation bound on .
In order to apply this to the sequence , we need to first calculate the moment-generating function of its starting value .
Putting these pieces together yields Theorem 2.2.
3 Intermediate epochs of improvement
We have seen that, for suitable and , it is likely that for all . We now define a series of epochs in which successively doubles, until finally drops below .
To do this, we specify intermediate goals , where and , with the intention that:
Of course, this can only hold with a certain probability.
Let denote the sample space of all realizations , and the probability distribution on these sequences. We will show that, for a certain choice of , all constraints (2) can be met by excluding just a small portion of .
We consider a specific realization to be good if it satisfies (2). Call this set :
For technical reasons, we also need to look at realizations that are good up to time . Specifically, for each , define
Crucially, this is -measurable. Also note that .
Assume that , where and . Pick any and select a schedule that satisfies the conditions
as well as . Then .
The first step towards proving this theorem is bounding the moment-generating function of in terms of that of .
Suppose . Suppose also that , where . Then for any ,
A repeated application of Lemmas 2.7 and 2.8 yields the following.
Suppose that conditions (3) hold. Then for and any ,
Now that we have bounds on the moment-generating functions of intermediate , we can apply martingale deviation bounds, as in Lemma 2.4, to obtain the following, from which Theorem 2.6 ensues.
Assume conditions (3) hold. Pick any , and set . Then
4 The final epoch
Recall the definition of the intermediate goals in (2), (3). The final epoch is the period , at which point . The following consequence of Lemmas A.4 and 2.8 captures the rate at which decreases during this phase.
where and .
By solving this recurrence relation, and piecing together the various epochs, we get the overall convergence result of Theorem 1.1.
Note that Lemma 2.11 closely resembles the recurrence relation followed by the squared distance from the optimum of stochastic gradient descent (SGD) on a strongly convex function . As , the incremental PCA algorithms we study have convergence rates of the same form as SGD in this scenario.
Experiments
When performing PCA in practice with massive and a large/growing dataset, an incremental method like that of Krasulina or Oja remains practically viable, even as quadratic-time and -memory algorithms become increasingly impractical. Arora et al. have a more complete discussion of the empirical necessity of incremental PCA algorithms, including a version of Oja’s method which is shown to be extremely competitive in practice.
Since the efficiency benefits of these types of algorithms are well understood, we now instead focus on the effect of the learning rate on the performance of Oja’s algorithm (results for Krasulina’s are extremely similar). We use the CMU PIE faces , consisting of 11554 images of size , as a prototypical example of a dataset with most of its variance captured by a few PCs, as shown in Fig. 1. We set .
We expect from Theorem 1.1 and the discussion in the introduction that varying (the constant in the learning rate) will influence the overall rate of convergence. In particular, if is low, then halving it can be expected to halve the exponent of , and the slope of the log-log convergence graph (ref. the remark after Thm. 1.1). This is exactly what occurs in practice, as illustrated in Fig. 2. The dotted line in that figure is a convergence rate of , drawn as a guide.
Open problems
Several fundamental questions remain unanswered. First, the convergence rates of the two incremental schemes depend on the multiplier in the learning rate . If it is too low, convergence will be slower than . If it is too high, the constant in the rate of convergence will be large. Is there a simple and practical scheme for setting ?
where the second step orthonormalizes the columns, for instance by Gram-Schmidt. It would be interesting to characterize the rate of convergence of this scheme.
Finally, our analysis applies to a modified procedure in which the starting time is artificially set to a large constant. This seems unnecessary in practice, and it would be useful to extend the analysis to the case where .
The authors are grateful to the National Science Foundation for support under grant IIS-1162581.
References
Appendix A Expected per-step change in potential
.
For (a), let denote the component of orthogonal to . Then
For (b), note from the previous formulation that .
For (d), we use . ∎
We now check that grows in expectation with each iteration.
.
Part (a) follows directly from the update rule:
In order to use Lemma A.2 to bound the change in potential , we need to relate to the quantity .
For any , we have .
It is easiest to think of in the eigenbasis of : the component of in direction is , and the orthogonal component is . Then
We can now explicitly bound the expected change in in each iteration.
For any , we can write , where and where
is a -measurable random variable with the following properties:
which is . The conditional expectation of can be determined from Lemma A.2(b):
and this can be lower-bounded using Lemma A.3.
Finally, we need to determine the range of possible values of . By expanding , we get
Since , we see that must lie in the range . ∎
A.2 The change in potential of the Oja update
Since our bounds are on the potential function , which is insensitive to the length of , we can skip the normalization, and instead just consider the update rule
The final bounds, as well as many of the intermediate results, are almost exactly the same as for Krasulina’s estimator. Here is the analogue of Lemma A.4.
For any , we can write , where is the same as in Lemma A.4 and .
where we have used . Combining these,
where the final step involves some extra algebra that we have omitted. The lemma now follows by invoking . ∎
B.2 Proof of Lemma 2.4
B.3 Proof of Lemma 2.5
It is well known that can be chosen by picking values independently from the standard normal distribution and then setting . Therefore,
where is drawn from a chi-squared distribution with degrees of freedom and is drawn independently from a chi-squared distribution with one degree of freedom. This characterization implies that follows the distribution: specifically, for any ,
The moment-generating function of this distribution is
There isn’t a closed form for this, but an upper bound on the integral can be obtained. Assuming ,
where the second step uses a change of variable , and the fourth uses the definition of the gamma function. To finish up, we use the inequality (Lemma B.1) to get
The following inequality is doubtless standard; we give a short proof here because we are unable to find a reference.
B.4 Proof of Theorem 2.2
To make this , it suffices to take , whereupon Lemma 2.4 yields
where the last step uses Lemma 2.5. The result follows by taking .
Appendix C Intermediate epochs of improvement
For any , we have . Taking expectations over , we get the lemma.
C.2 Proof of Lemma 2.8
Let be the largest index such that . Then
Thus the expected value of over is at most the expected value over .
C.3 Proof of Lemma 2.9
Define and . By Lemmas 2.7 and 2.8, for ,
By applying these inequalities repeatedly, for shrinking to (and shrinking as well), we get
since for all . We then use the summations
To prove Lemma 2.9, we note that under conditions (3),
We have used the fact that for . The rest follows by applying Lemma C.1 with .
C.4 Proof of Lemma 2.10
Pick any . We will mimic the reasoning of Theorem 2.2, being careful to define martingales only on the restricted space and with starting time . Then
To finish, we pick . The lower bound on is also a lower bound on , and implies that , whereupon
Appendix D The final epoch
For realizations , we have and thus the right-hand side of the above expression is at most . Using the fact that is -measurable, and taking expectations over ,
as claimed. The last step uses Lemma 2.8.
D.2 Proof of Theorem 1.1
Define epochs that satisfy the conditions of Theorem 2.6, with , and with whenever possible. Then and
By Theorem 2.6, with probability , we have for all . More precisely, for all .
for and . By the case of Lemma D.1,
which upon further simplification yields the bound of Theorem 1.1 for .
Consider a nonnegative sequence , such that for some constants and for all ,
Then, writing the zeta function ,
Recursively applying the given recurrence for yields
We finish by bounding the summation of by a definite integral, to get: