L EARNING P RECONDITIONER ON M ATRIX L IE G ROUP
Anonymous authors
Paper under double-blind review
A BSTRACT
We study two types of preconditioners and preconditioned stochastic gradient descent (SGD) methods in a uniﬁed framework.
We call the ﬁrst one the Newton type due to its close relationship to Newton method, and the second one the Fisher type as its preconditioner is closely related to the inverse of Fisher information matrix.
Both preconditioners can be derived from one framework, and efﬁciently learned on any matrix Lie groups designated by the user using natural or relative gradient descent.
Many existing preconditioners and methods are special cases of either the Newton type or the Fisher type ones.
Experimental results on relatively large scale machine learning problems are reported for performance study.
I NTRODUCTION
This paper investigates the use of preconditioner for accelerating gradient descent, especially in large scale machine learning problems.
Stochastic gradient descent (SGD) and its variations, e.g., momentum (Rumelhart et al., 1986; Nesterov, 1983), RMSProp and Adagrad (John et al., 2011),
Adam (Kingma & Ba, 2015), etc., are popular choices due to their simplicity and wide applicability.
These simple methods do not use well normalized step size, could converge slow, and might involve more controlling parameters requiring ﬁne tweaking.
Convex optimization is a well studied ﬁeld (Boyd & Vandenberghe, 2004).
Many off-the-shelf methods there, e.g., (nonlinear) conjugate gradient descent, quasi-Newton methods, Hessian-free optimizations, etc., can be applied to small and middle scale machine learning problems without much modiﬁcations.
However, these convex optimization methods may have difﬁculty in handling gradient noise and scaling up to problems with hundreds of millions of free parameters.
For a large family of machine learning problems, natural gradient with the Fisher information metric is equivalent to a preconditioned gradient using inverse of the Fisher information matrix as the preconditioner (Amari, 1998).
Natural gradient and its variations, e.g., Kronecker-factored approximate curvature (KFAC)
(Martens & Grosse, 2015) and the one in (Povey et al., 2015), all use such preconditioners.
Other less popular choices are the equilibrated preconditioner (Dauphin et al., 2015) and the one proposed in (Li, 2018).
Momentum or the heavy-ball method provides another independent way to accelerate converge (Nesterov, 1983;
Rumelhart et al., 1986).
Furthermore, momentum and preconditioner can be combined to further accelerate convergence as shown in Adam (Kingma & Ba, 2015).
This paper groups the above mentioned preconditioners and preconditioned SGD methods into two classes, the Newton type and the Fisher type.
The Newton type is closely related to the Newton method, and is suitable for general purpose optimizations.
The Fisher type preconditioner relates to the inverse of Fisher information matrix, and is limited to a large subclass of stochastic optimization problems where the Fish information metric can be well deﬁned.
Both preconditioners can be derived from one framework, and learned on any matrix Lie groups designated by the user with almost the same natural or relative gradient descent methods.
B ACKGROUND 2. N OTATIONS
We consider the minimization of cost function
[Equation]
where E z takes expectation over random variable zzz , (cid:96) is a loss function, and θθθ is the model parameter vector to be optimized.
For example, in a classiﬁcation problem, (cid:96) could be the cross entropy loss, zzz is a pair of input feature vector and class label, vector θθθ consists of all the trainable parameters in the classiﬁcation model, and E z takes average over all samples from the training data set.
By assuming second order differentiable model and loss, we could approximate (cid:96) ( θθθ,zzz ) as a quadratic function of θθθ within a trust region around θθθ , i.e., (cid:96) ( θθθ,zzz ) = bbb Tz θθθ + 0 .
5 θθθ T HHH z θθθ + a z , where a z is the sum of higher order approximation errors and constant term independent of θθθ , HHH z is a symmetric matrix, and subscript z in bbb z , HHH z and a z reminds us that these three terms depend on zzz .
Clearly, these three terms depend on θθθ as well.
We do not explicitly show this dependence to simplify our notations since we just consider parameter updates in the same trust region.
Now, we may rewrite (1) as
[Equation]
where bbb =
E z [ bbb z ] , HHH = E z [ HHH z ] , and a = E z [ a z ] .
We do not impose any assumption, e.g., positive deﬁniteness, on HHH except for being symmetric.
Thus, the quadratic surface in the trust region could be non-convex.
To simplify our notations, we no longer consider the higher order approximation errors included in a , and simply assume that f ( θθθ ) is a quadratic function of θθθ in the trust region.
2. P RECONDITIONER
Let us consider a certain iteration.
Preconditioned SGD updates θθθ as
[Equation]
where µ > 0 is the step size, ˆ f ( θθθ ) is an estimate of f ( θθθ ) obtained by replacing expectation with sample average, and positive deﬁnite matrix PPP could be a ﬁxed or adaptive preconditioner.
By letting θθθ (cid:48)
=
PPP − 0 .
5 θθθ , we can rewrite (3) as
[Equation]
where PPP − 0 .
5 denotes the principal square root of PPP .
Hence, (4) suggests that preconditioned SGD is equivalent to SGD in a transformed parameter domain.
Within the considered trust region, let us write the stochastic gradient, ∂ ˆ f ( θθθ ) /∂θθθ , explicitly as
[Equation]
where ˆ HHH and ˆ bbb are estimates of HHH and bbb , respectively.
Combining (5) and (3) gives the following linear system
[Equation]
for updating θθθ within the assumed trust region, where III is the identity matrix.
A properly determined
PPP could signiﬁcantly accelerate convergence of the locally linear system in (6).
We review a few facts shown in (Li, 2018) before introducing our main contributions.
Let δθθθ be a random perturbation of θθθ , and be small enough such that θθθ + δθθθ still resides in the same trust region.
Then, (5) suggests the following resultant perturbation of stochastic gradient,
[Equation]
where εεε accounts for the error due to replacing ˆ HHH with HHH .
Note that by deﬁnition, δ ˆ ggg is a random vector dependent on both zzz and δθθθ .
The preconditioner in (Li, 2018) is pursued by minimizing criterion
[Equation]
where subscript δθ in E z,δθ denotes taking expectation over δθθθ .
Under mild conditions, criterion (8) determines a unique positive deﬁnite PPP , which is optimal in the sense that it preconditions the stochastic gradient such that
[Equation]
which is comparable to relationship HHH − 1 δgggδggg
[Equation]
HHH
[Equation]
1 =
[Equation]
T , where δggg =
HHHδθθθ is the perturbation of noiseless gradient, and we assume that HHH is invertible, but not necessarily positive deﬁnite.
Clearly, this preconditioner is comparable to HHH − 1 .
Preconditioned SGD with this preconditioner inherits the scale-invariance property of Newton method, regardless of the amount of gradient noise.
Note that in the presence of gradient noise, the optimal PPP and PPP − 1 given by (9) are not unbiased estimates of HHH − 1 and HHH , respectively.
Actually, even if HHH is positive deﬁnite and available, HHH − 1 may not always be a good preconditioner when HHH is ill-conditioned since it could signiﬁcantly amplify the gradient noise along the directions of the eigenvectors of HHH associated with small eigenvalues, and lead to divergence.
More speciﬁcally, it is shown in (Li, 2018) that
HHH
[Equation]
E z,δθ [ δ ˆ gggδ
[Equation]
ggg T ] HHH
[Equation]
1 ≥ E δθ [ δθθθδθθθ T ] , where AAA ≥ BBB means that AAA − BBB is nonnegative deﬁnite.
T WO PRECONDITIONER ESTIMATION CRITERIA 3. T HE N EWTON TYPE CRITERION
Preconditioner estimation criterion (8) requires δθθθ to be small enough such that θθθ and θθθ + δθθθ reside in the same trust region.
In practice, numerical error might be an issue when handling small numbers with ﬂoating point arithmetic.
This concern becomes more grave with the popularity of single and even half precision math in large scale neural network training.
Luckily, (7) relates δ ˆ ggg to Hessianvector product, which can be efﬁciently evaluated with automatic differentiation software tools.
Let vvv be a random vector with the same dimension as θθθ .
Then, (5) suggests the following method for
Hessian-vector product evaluation,
[Equation]
Now, replacing ( δθθθ, δ ˆ ggg ) in (8) with ( vvv, ˆ HHHvvv ) leads to our following new preconditioner estimation criterion,
[Equation]
(11) where the subscript v in E z,v suggests taking expectation over vvv .
We no longer have the need to assume vvv to be an arbitrarily small vector.
It is important to note that this criterion only requires the Hessian-vector product.
The Hessian itself is not of interest.
We call (11) the Newton type preconditioner estimation criterion as the resultant preconditioned SGD method is closely related to the Newton method.
3. T HE F ISHER TYPE CRITERION
We consider the machine learning problems where the empirical Fisher information matrix can be well deﬁned by FFF =
E z
[Equation]
zzz
[Equation] T [Equation] Replacing ( δθθθ, δ ˆ ggg ) in (8) with ( vvv, ˆ ggg + λvvv ) leads to criterion
[Equation]
where ˆ ggg =
∂ ˆ f ( θθθ ) /∂θθθ is a shorthand for stochastic gradient, and λ ≥ 0 is a damping factor.
Clearly, vvv is independent of ˆ ggg .
Let us further assume that vvv is drawn from standard multivariate normal distribution N (000 ,III ) , i.e., E v [
vvv ] = 000 and E v [ vvvvvv T ]
= III .
Then, we could simplify c f ( PPP ) as
[Equation]
By letting the derivative of c f ( PPP ) with respect to PPP be zero, the optimal positive deﬁnite solution for c f ( PPP ) is readily shown to be
[Equation]
When ˆ ggg is a gradient estimation obtained by taking average over B independent samples, E z [ˆ ggg ˆ ggg T ] is related to the Fisher information matrix by
[Equation]
We call this preconditioner the Fisher type one due to its close relationship to the Fisher information matrix.
One can easily modify this preconditioner to obtain an unbiased estimation of FFF − 1 .
Let sss be an exponential moving average of ˆ ggg .
Then, after replacing the ˆ ggg in (14) with ˆ ggg − sss + sss/ √ B and setting λ = 0 , PPP 2 /B will be an unbiased estimation of FFF − 1 .
Generally, it might be acceptable to keep the bias term, ( B − 1) gg gg g g T /B , in (15) for two reasons: it is nonnegative deﬁnite and regularizes the inversion in (14); it vanishes when the parameters approach a stationary point.
Actually, the
Fisher information matrix could be singular for many commonly used models, e.g., ﬁnite mixture models, neural networks, hidden Markov models.
We might not be able to inverse FFF for these singular statistical models without using regularization or damping.
A Fisher type preconditioner with λ > 0 loses the scale-invariance property of a Newton type preconditioner.
Both PPP and PPP 2 can be useful preconditioners when the step size µ and damping factor λ are set properly.
3. P ROPERTIES OF THE N EWTON TYPE PRECONDITIONER
Following the ideas in (Li, 2018), we can show that (11) determines a unique positive deﬁnite preconditioner if and only if E v [ vvvvvv T ] is positive deﬁnite and { E v [ vvvvvv T ] } 0 .
5 E z,v [ ˆ HHHvvvvvv T ˆ HHH ] { E v [ vvvvvv T ] } 0 .has distinct eigenvalues.
Other minimum solutions of criterion (11) are either indeﬁnite or negative deﬁnite, and are not interested for our purpose.
The proof itself has limited novelty.
We omit it here.
Instead, let us consider the simplest case, where θθθ is a scalar parameter, to gain some intuitive understandings of criterion (11).
For scalar parameter, it is trivial to show that the optimal solutions minimizing (11) are
[Equation]
where ˆ HHH , HHH , PPP , and vvv are replaced with their plain lower case letters, and we have used the fact that
HHH − ˆ HHH and vvv are independent.
For gradient descent, we choose the positive solution, although the negative one gives the global minimum of (11).
With the positive preconditioner, eigenvalue of the locally linear system in (6) is
[Equation]
Now, it is clear that this optimal preconditioner damps the gradient noise when E z [( h − ˆ h ) 2 ] is large, and preconditions the locally linear system in (6) such that its eigenvalue has unitary amplitude when the gradient noise vanishes.
Convergence is ensured when a normalized step size, i.e., 0 < µ < 1 , is used.
For θθθ with higher dimensions, eigenvalues of the locally linear system in (6) is normalized into range [ − 1 , 1] as well, in a way similar to (17).
L EARNING PRECONDITIONERS ON MATRIX L IE GROUPS 4. L EARNING RULE FOR THE N EWTON TYPE PRECONDITIONER
Let us take the Newton type preconditioner as an example to derive its learning rule.
Learning rule for the Fisher type preconditioner is the same except for replacing the Hessian-vector product with stochastic gradient.
Here, Lie group always refers to the matrix Lie group.
It is inconvenient to optimize PPP directly as it must be a symmetric and positive deﬁnite matrix.
Instead, we represent the preconditioner as PPP =
QQQ T QQQ , and learn QQQ .
Now, QQQ must be a nonsingular matrix as both c n ( PPP ) and c f ( PPP ) diverge when PPP is singular.
Invertible matrices with the same dimension form a Lie group.
In practice, we are more interested in Lie groups with sparse representations.
Examples of such groups are given in the next section.
Let us consider a proper small perturbation of QQQ , δQQQ , such that QQQ + δQQQ still lives on the same Lie group.
The distance between
QQQ and QQQ + δQQQ can be naturally deﬁned as dist( QQQ,QQQ + δQQQ ) =
(cid:112) tr( δQQQQQQ − 1 QQQ − T δQQQ T ) (Amari, 1998).
Intuitively, this distance is larger for the same amount of perturbation when QQQ is more close to singular.
With the above tensor metric deﬁnition, natural gradient for learning QQQ has form
[Equation]
For example, when QQQ lives on the group of invertible upper triangular matrices, RRR is given by
[Equation]
where triu takes the upper triangular part of a matrix.
Another way to derive (18) is to let δQQQ =
E QQQ , and consider the derivative with respect to E , where E is a proper small matrix such that QQQ + E QQQ still lives on the same Lie group.
Gradient derived in this way is known as relative gradient (Cardoso &
Laheld, 1996).
For our preconditioner learning problem, relative gradient and natural gradient have the same form.
Now, QQQ can be updated using natural or relative gradient descent as
[Equation]
In practice, it is convenient to use the following learning rule with normalized step size,
[Equation] [Equation]
where 0 < µ 0 < 1 , and (cid:107) · (cid:107) takes the norm of a matrix.
One simple choice for matrix norm is the maximum absolute value of a matrix.
Note that natural gradient can take different forms.
One should not confuse the natural gradient on the Lie group derived from a tensor metric with the natural gradient for model parameter learning derived from a Fisher information metric.
4. S UMMARY OF THE N EWTON TYPE PRECONDITIONED SGD
One iteration of the Newton type preconditioned SGD consists of the following steps.
Evaluate stochastic gradient ˆ ggg .
Draw vvv from N (000 ,III ) , and evaluate Hessian-vector product
ˆ HHHvvv .
Update parameters with θθθ ← θθθ − µQQQ T QQQ ˆ ggg .
Update preconditioners with QQQ ← ( III − µ 0 ˆ RRR/ (cid:107) ˆ RRR (cid:107) ) QQQ .
The two step sizes, µ and µ 0 , are normalized.
They should take values in range [0 , 1] .
The speciﬁc form of ˆ RRR depends on the Lie group to be considered.
For example, for upper triangular QQQ , we have ˆ RRR =
2triu
[ QQQ ˆ HHHvvvvvv T ˆ HHH T QQQ T − QQQ − T vvvvvv T QQQ − 1 ] , where QQQ − T vvv can be efﬁciently calculated with back substitution.
4. S UMMARY OF THE F ISHER TYPE PRECONDITIONED SGD
We only need to replace ˆ H H Hv v v in the Newton type preconditioned SGD with ˆ g g g
+ λv v v to obtain the
Fisher type one.
Its one iteration consists of the following steps.
Evaluate stochastic gradient ˆ ggg .
Update parameters with θθθ ← θθθ − µQQQ T QQQ ˆ ggg .
Update preconditioners with QQQ ← ( III − µ 0 ˆ RRR/ (cid:107) ˆ RRR (cid:107) ) QQQ .
Only the step size for preconditioner updating is normalized.
There is no simple way to jointly determine the proper ranges for step size µ and damping factor λ .
Again, ˆ RRR may take different forms on different Lie groups.
For upper triangular QQQ , we have ˆ RRR =
2tiru
[ QQQ (ˆ ggg + λvvv )(ˆ ggg + λvvv ) T QQQ T −
QQQ − T vvvvvv T QQQ − 1 ] , where vvv ∼ N (000 ,III ) .
Here, it is important to note that the natural or relative gradient for c f ( PPP ) with the form given in (13) involves explicit matrix inversion.
However, matrix inversion can be avoided by using the c f ( PPP ) in (12), which includes vvv as an auxiliary variable.
It is highly recommended to avoid explicit matrix inversion for large QQQ .
4. V ARIATIONS OF PRECONDITIONED SGD
There are many ways to modify the above preconditioned SGD methods.
Since curvatures typically evolves slower than gradients, one can update the preconditioner less frequently to save average wall time per iteration.
Combining preconditioner and momentum may further accelerate convergence.
For recurrent neural network learning, we may need to clip the norm of preconditioned gradients to avoid excessively large parameter updates.
In general, preconditioned gradient clipping relates to the trust region method by
[Equation]
where Ω > 0 is a clipping threshold, comparable to the size of trust region.
Most importantly, we can choose different Lie groups for learning our preconditioners to achieve a good trade off between performance and complexity.
U SEFUL L IE GROUPS WITH SPARSE REPRESENTATIONS
In practice, we seldom consider the Lie group consisting of dense invertible matrices for preconditioner estimation when the problem size is large.
Lie groups with sparse structures are of more interests.
To begin with, let us recall a few facts about Lie group.
If AAA and BBB are two Lie groups, then AAA T , AAA ⊗ BBB , and AAA ⊕ BBB all are Lie groups, where ⊗ and ⊕ denote Kronecker product and direct sum, respectively.
Furthermore, for any matrix CCC with compatible dimensions, block matrix
[Equation]
still forms a Lie group.
We do not show proofs of the above statements here as they are no more than a few lines of algebraic operations.
These simple rules can be used to design many useful Lie groups for constructing sparse preconditioners.
We already know that invertible upper triangular matrices form a Lie group.
Here, we list a few useful ones with sparse representations.
5. D IAGONAL PRECONDITIONER
Diagonal matrices with the same dimension and positive diagonal entries form a Lie group with reducible representation.
Preconditioners learned on this group are called diagonal preconditioners.
5. K RONECKER PRODUCT PRECONDITIONER
For matrix parameter ΘΘΘ , we can ﬂatten ΘΘΘ into a vector, and precondition its gradient using a Kronecker product preconditioner with QQQ having form QQQ =
QQQ 2 ⊗ QQQ 1 .
Clearly, QQQ is a Lie group as long as QQQ 1 and QQQ 2 are two Lie groups.
Let us check its role in learning the following afﬁne transformation
[Equation]
where x x x is the input feature vector augmented with 1 , and y y y is the output feature vector.
After reverting the ﬂattened ΘΘΘ back to its matrix form, the preconditioned SGD learning rule for ΘΘΘ is
[Equation]
Similar to (4), we introduce coordinate transformation ΘΘΘ (cid:48)
=
QQQ − T 1 ΘΘΘ QQQ
[Equation]
1 2 , and rewrite (24) as
[Equation]
Correspondingly, the afﬁne transformation in (23) is rewritten as yyy (cid:48) =
ΘΘΘ (cid:48) xxx (cid:48) , where yyy (cid:48) =
QQQ − T 1 yyy and xxx (cid:48)
=
QQQ 2 xxx are the transformed input and output feature vectors, respectively.
Hence, the preconditioned SGD in (24) is equivalent to the SGD in (25) with transformed feature vectors xxx (cid:48) and yyy (cid:48) .
We know that feature whitening and normalization could signiﬁcantly accelerate convergence.
A
Kronecker product preconditioner plays a similar role in learning the afﬁne transformation in (23).
5. S CALING AND NORMALIZATION PRECONDITIONER
This is a special Kronecker product preconditioner by constraining QQQ 1 to be a diagonal matrix, and
QQQ 2 to be a sparse matrix where only its diagonal and last column can have nonzero values.
Note that
QQQ 2 with nonzero diagonal entries forms a Lie group.
Hence, QQQ =
QQQ 2 ⊗ QQQ 1 is a Lie group as well.
We call it a scaling and normalization preconditioner as it resembles a preconditioner that scales the output features and normalizes the input features.
Let us check the transformed features yyy (cid:48)
=
QQQ − T 1 yyy and xxx (cid:48)
=
QQQ 2 xxx .
It is clear that yyy (cid:48) is an element-wisely scaled version of yyy as QQQ 1 is a diagonal matrix.
To make xxx (cid:48) a “normalized” feature vector, xxx needs to be an input feature vector augmented with 1 .
Let us check a simple example to verify this point.
We consider an input vector with two features, and write down its normalized features explicitly as below,
[Equation]
(26) where m i and σ i are the mean and standard deviation of x i , respectively.
It is straightforward to show that the feature normalization operation in (26) forms a Lie group with four freedoms.
For the scaling-and-normalization preconditioner, we have no need to force the last diagonal entry of QQQ 2 to be 1 .
Hence, the group of feature normalization operation is a subgroup of QQQ 2 .
5. S CALING AND WHITENING PRECONDITIONER
This is another special Kronecker product preconditioner by constraining QQQ 1 to be a diagonal matrix, and QQQ 2 to be an upper triangular matrix with positive diagonal entries.
We call it a scaling-andwhitening preconditioner since it resembles a preconditioner that scales the output features and whitens the input features.
Again, the input feature vector xxx must be augmented with 1 such that the whitening operation forms a Lie group represented by upper triangular matrices with 1 being its last diagonal entry.
This is a subgroup of QQQ 2 as we have no need to ﬁx QQQ 2 ’s last diagonal entry to 1 .
It is not possible to enumerate all kinds of Lie groups suitable for constructing preconditioners.
For example, Kronecker product preconditioner with form QQQ =
QQQ 3 ⊗ QQQ 2 ⊗ QQQ 1 could be used for preconditioning gradients of a third order tensor.
The normalization and whitening groups are just two special cases of the groups with the form shown in (22), and there are numerous more choices having sparsities between that of these two.
Regardless of the detailed form of QQQ , all such preconditioners share the same form of learning rule shown in (21).
Without much tuning effort, they all can be efﬁciently learned using natural or relative gradient descent with normalized step size.
R ELATIONSHIP TO EXISTING METHODS 6. R ELATIONSHIP TO A DAGRAD , RMSP ROP AND A DAM
Adagrad, RMSProp and Adam all use Fisher type preconditioner living on the group of diagonal matrices with positive deﬁnite entries.
This is a simple group.
Optimal solution for c f ( PPP ) has closed-form solution PPP =
diag(1 (cid:11) (cid:112)
E z [ˆ ggg (cid:12) ˆ ggg ] + λ 2 ) , where (cid:12) and (cid:11) denote element wise multiplication and division, respectively.
In practice, simple exponential moving average is used to replace the expectation when using this preconditioner.
6. R ELATIONSHIP TO EQUILIBRATED SGD
For diagonal preconditioner, the optimal solution minimizing c n ( PPP ) has closed-form solution PPP = diag (cid:18)(cid:113) E v [ vvv (cid:12) vvv ] (cid:11) E z,v [ ˆ HHHvvv (cid:12) ˆ HHHvvv ] (cid:19) .
For vvv ∼ N (000 ,III ) , E v [ vvv (cid:12) vvv ] reduces to a vector with unit entries.
Then, this optimal solution gives the equilibration preconditioner in (Dauphin et al., 2015).
6. R ELATIONSHIP TO KFAC AND SIMILAR METHODS
The preconditioners considered in (Povey et al., 2015) and (Martens & Grosse, 2015) are closely related to the Fisher type Kronecker product preconditioners.
Since all these Kronecker product preconditioners approximate the same inverse of Fisher information matrix, we can hardly tell which one is theoretically better.
In practice, our method learns this type of preconditioner by minimizing criterion c f ( PPP ) using natural or relative gradient descent.
Compared with KFAC, one distinct advantage of our method is that explicit matrix inversion is avoided by introducing auxiliary vector vvv and using back substitution, while KFAC typically requires inversion of symmetric matrices.
On graphics processing units (GPU) and with large matrices, parallel back substitution and matrix multiplication have comparable complexities, and they can be several orders of magnitude faster than inversion of symmetric matrix.
Another advantage is that our method is derived from a uniﬁed framework.
There is no need to invent different preconditioner learning rules when we switch the Lie group representations.
6. R ELATIONSHIP TO BATCH NORMALIZATION
Batch normalization can be viewed as preconditioned SGD using a speciﬁc scaling-andnormalization preconditioner with constraint QQQ 1 = III and QQQ 2 from the feature normalization Lie group.
However, we should be aware that explicit input feature normalization is only empirically shown to accelerate convergence, and has little meaning in certain scenarios, e.g., recurrent neural network learning where features may not have any stationary ﬁrst and second order statistics.
Both the Newton and Fisher type preconditioned SGD methods provide a more general and principled approach to ﬁnd the optimal preconditioner, and apply to a broader range of applications.
Generally, a scaling-and-normalization preconditioner does not necessarily “normalize” the input features in the sense of mean removal and variance normalization.
[Figure]
E XPERIMENTAL RESULTS
We use the square root Fisher type preconditioners in the following experiments since they are less picky on the damping factor, and seem to be more numerically robust on large scale problems.
Still, as shown in our Pytorch implementation package, the original Fisher type preconditioners could perform better on small scale problems like the MNIST handwritten digit recognition task.
7. A PPLICATION TO MATHEMATICAL OPTIMIZATION
Let us consider the minimization of Rosenbrock function, f ( θθθ ) = 100( θ 2 − θ 21 )
+ (1 − θ 1 ) 2 , starting from initial guess θθθ = [ − 1 , 1] .
This is a well known benchmark problem for mathematical optimization.
The compared methods use ﬁxed step size.
For each method, the best step size is selected from sequence { . . .
For gradient descent, the best step size is 0 .
For momentum method, the moving average factor is 0 .
9 , and the best step size is 0 .
For Nesterov momentum, the best step size is 0 .
For preconditioned SGD, QQQ is initialized to 0 .
1 III and lives on the group of triangular matrices.
For the Fisher type method, we set λ = 0 .
1 , and step sizes 0 .
01 and 0 .
001 for preconditioner and parameter updates, respectively.
For the Newton type method, we set step sizes 0 .
2 and 0 .
5 for preconditioner and parameter updates, respectively.
Figure 1 summarizes the results.
The Newton type method performs the best, converging to the optimal solution using about 200 iterations.
The Fisher type method does not ﬁt into this problem, and performs poorly as expected.
Mathematical optimization is not our focus.
Still, this example shows that the Newton type preconditioned SGD works well for mathematical optimization.
7. I MAGE N ET EXPERIMENT
We consider the ImageNet ILSVRC2012 database for the image classiﬁcation task.
The well known
AlexNet is considered.
We follow the descriptions in (Alex et al., 2012) as closely as possible to set up our experiment.
One main difference is that we do not augment the training data.
Another big difference is that we use a modiﬁed local response normalization (LRN).
The LRN function from TensorFlow implementation is not second order differentiable.
We have to approximate the local energy used for LRN with a properly scaled global energy to facilitate Hessian-vector product evaluation.
Note that convolution can be rewritten as correlation between the ﬂattened input image patches and ﬁlter coefﬁcients.
In this way, we ﬁnd that there are eight matrices to be optimized in the AlexNet, and their shapes are: [96 , 11 × 11 × 3 + 1] , [256 , 5 × 5 × 96 + 1] , [384 , 3 × 3 × 256 + 1] , [384 , 3 × 3 × 384 + 1] , [256 , 3 × 3 × 384] , [4096 , 6 × 6 × 256 + 1] , [4096 , 4096 + 1] , and [1000 , 4096 + 1] .
We have tried diagonal and scaling-and-normalization preconditioners for each matrix.
Denser preconditioners, e.g., the Kronecker product one, require hundreds of millions parameters for representations, and are expensive to run on our platform.
Each compared method is trained with 40 epochs, mini-batch size 128 , step size µ for the ﬁrst 20 epochs, and 0 .
1 µ for the last 20 epochs.
We have compared several methods with multiple settings, and only report the ones with reasonably good results here.
For Adam, the initial step size is set to 0 .
For batch normalization, initial step size is 0 .
002 , and its moving average factors for momentum and statistics used for feature normalization are 0 .
9 and 0 . 99 , respectively.
The momentum method uses initial step size 0 .
002 , and moving average factor 0 .
9 for momentum.
Preconditioned SGD performs better with the scaling-and-normalization preconditioner.
Its QQQ is initialized to 0 .
1 III , and updated with normalized step size 0 .
For the Fisher type preconditioner, we set λ = 0 .
001 and initial step size 0 . 00005 .
For the Newton type preconditioner, its initial step size is 0 .
Figure 2 summarizes the
[Figure]
results.
Training loss for batch normalization is only for reference purpose as normalization alters the L2-regularization term.
Batch normalization does not perform well under this setup, maybe due to its conﬂict with certain settings like LRN and L2-regularization.
We see that the scalingand-normalization preconditioner does accelerate convergence, although it is super sparse.
The
Newton type preconditioned SGD performs the best, and achieves top-1 validation accuracy about 56% when using only one crop for testing, while the momentum method may require 90 epochs to achieve similar performance.
7. W ORD LEVEL LANGUAGE MODELING EXPERIMENT
We consider the world level language modeling problem with reference implementation available from https://github.com/pytorch/examples .
The Wikitext-2 database with 33278 tokens is considered.
The task is to predict the next token from history observations.
Our tested network consists of six layers, i.e., encoding layer, LSTM layer, dropout layer, LSTM layer, dropout layer, and decoding layer.
For each LSTM layer, we put all its coefﬁcients into a single matrix ΘΘΘ by deﬁning output and augmented input feature vectors as in   iii t fff t ggg t ooo t 
 = ΘΘΘ (cid:34) xxx
t hhh t − 1(cid:35) , ccc t = fff t ccc t − 1 + iii t ggg t , hhh t = ooo t tanh( ccc t ) , where t is a discrete time index, xxx is the input, hhh is the hidden state, and ccc is the cell state.
The encoding layer’s weight matrix is the transpose of that of the decoding layer.
Thus, we totally get three matrices to be optimized.
With hidden layer size 200 , shapes of these three matrices are [4 × 200 , 2 × 200 + 1] , [4 × 200 , 2 × 200 + 1] , and [33278 , 200 + 1] , respectively.
For all methods, the step size is reduced to one fourth of the current value whenever the current perplexity on validation set is larger than the best one ever found.
For SGD, the initial step size is 20 , and the gradient is clipped with threshold 0 .
The momentum method diverges easily without clipping.
We set momentum 0 .
9 , initial step size 1 , and clipping threshold 0 .
We set initial step size 0 .
005 and damping factor λ 2 = 10 − 12 for Adam and sparse Adam.
Sparse
Adam updates its moments and model parameters only when the corresponding stochastic gradients are not zeros.
We have tried diagonal, scaling-and-normalization and scaling-and-whitening preconditioners for each matrix.
The encoding (decoding) matrix is too large to consider KFAC like preconditioner.
The diagonal preconditioner performs the worst, and the other two have comparable performance.
For both types of preconditioned SGD, the clipping threshold for preconditioned gradient is 100 , the initial step size is 0 . 1 , and QQQ is initialized to III .
We set λ = 0 for the Fisher type preconditioned SGD.
With dropout rate 0 . 2 , the best three test perplexities are 100 . 7 by SGD, 103 .
9 by Newton type preconditioned SGD, and 105 . 8 by Fisher type preconditioned SGD.
With dropout rate 0 .
35 , the best three test perplexities are 100 .
7 by Newton type preconditioned SGD, 102 . 3 by SGD, and 103 .
7 by Fisher type preconditioned SGD.
Although SGD performs well on the test set, both types of preconditioned SGD have signiﬁcantly lower training losses than SGD with
[Figure]
either dropout rate.
Figure 3 summarizes the results when the dropout rate is 0 .
Methods involving momentum, including Adam and sparse Adam, perform poorly.
Note that our preconditioners preserve the sparsity property of gradients from the encoding and decoding layers (Appendix A). This saves considerable computations by avoiding update parameters with zero gradients.
Again, both preconditioners accelerate convergence signiﬁcantly despite their high sparsity.
7. C OMPUTATIONAL COMPLEXITY AND IMPLEMENTATION
Compared with SGD, the Fisher type preconditioned SGD adds limited computational complexity when sparse preconditioners are adopted.
The Newton type preconditioned SGD requires Hessianvector product, which typical has complexity comparable to that of gradient evaluation.
Thus, using
SGD as the base line, the Newton type preconditioned SGD approximately doubles the computational complexity per iteration, while the Fisher type SGD has similar complexity.
Wall time per iteration of preconditioned SGD highly depends on the implementations.
Ideally, the preconditioners and parameters could be updated in a parallel and asynchronous way such that SGD and preconditioned SGD have comparable wall time per iteration.
We have put our TensorFlow and Pytorch implementations on https://github.com/ lixilinx .
More experimental results comparing different preconditioners on diverse benchmark problems can be found there.
For the ImageNet experiment, all compared methods are implemented in Tensorﬂow, and require two days and a few hours to ﬁnish 40 epochs on a GeForce GTX
Ti GPU.
The word level language modeling experiment is implemented in Pytorch.
We have rewritten the word embedding function to enable second order derivative.
For this task, SGD and the
Fisher type preconditioned SGD have similar wall time per iteration, while the Newton type method requires about 80% more wall time per iteration than SGD when running on the same GPU.
C ONCLUSIONS
Two types of preconditioners and preconditioned SGD methods are studied.
The one requiring
Hessian-vector product for preconditioner estimation is suitable for general purpose optimization.
We call it the Newton type preconditioned SGD due to its close relationship to Newton method.
The other one only requires gradient for preconditioner estimation.
We call it the Fisher type preconditioned SGD as its preconditioner is closely related to the inverse of Fisher information matrix.
Both preconditioners can be efﬁciently learned using natural or relative gradient descent on any matrix
Lie groups designated by the user.
The Fisher type preconditioned SGD has lower computational complexity, but may require more tuning efforts on selecting its step size and damping factor.
The
Newton type preconditioned SGD has higher computational complexity, but is more user friendly due to its use of normalized step size and built-in gradient noise
damping ability.
Both preconditioners, even with very sparse representations, are shown to considerably accelerate convergence on relatively large scale problems.
A PPENDIX A: W HITENING - AND - SCALING PRECONDITIONER PRESERVES SPARSITY OF GRADIENT OF ENCODING MATRIX
We are to show that the scaling-and-whitening and whitening-and-scaling preconditioners preserve the sparsity property of gradients from the decoding and encoding layers in the word level language model considered in Experiment 3, respectively.
Clearly, we only need to show this for the encoding part.
Let
[Equation]
be a D × I word embedding matrix, where D is the embedding dimension, I is the number of tokens, and www i is the vector representation for the i th token.
Typically, only a whitening-and-scaling and more sparser preconditioners are affordable since I (cid:29) D > 1 .
Notably, for sufﬁciently large I , the whitening-and-scaling preconditioner could be sparser than the diagonal one.
Let us consider preconditioner
[Equation]
By (24), the preconditioned gradient is
[Equation]
where ˆ ggg i is the stochastic gradient for the i th word embedding vector.
Since I (cid:29) B , most of these ˆ ggg i ’s are zeros, where B is the batch size.
This preconditioner does not mix up gradients of different word embedding vectors.
Hence, the sparsity property is preserved.