# AutoShuffleNet: Learning Permutation Matrices via an Exact Lipschitz Continuous Penalty in Deep Convolutional Neural Networks

ShuffleNet is a state-of-the-art light weight convolutional neural network architecture. Its basic operations include group, channel-wise convolution and channel shuffling. However, channel shuffling is manually designed empirically. Mathematically, shuffling is a multiplication by a permutation matrix. In this paper, we propose to automate channel shuffling by learning permutation matrices in network training. We introduce an exact Lipschitz continuous non-convex penalty so that it can be incorporated in the stochastic gradient descent to approximate permutation at high precision. Exact permutations are obtained by simple rounding at the end of training and are used in inference. The resulting network, referred to as AutoShuffleNet, achieved improved classification accuracies on CIFAR-10 and ImageNet data sets. In addition, we found experimentally that the standard convex relaxation of permutation matrices into stochastic matrices leads to poor performance. We prove theoretically the exactness (error bounds) in recovering permutation matrices when our penalty function is zero (very small). We present examples of permutation optimization through graph matching and two-layer neural network models where the loss functions are calculated in closed analytical form. In the examples, convex relaxation failed to capture permutations whereas our penalty succeeded.

## Authors

• 7 publications
• 59 publications
• 13 publications
• 26 publications
• ### A Channel-Pruned and Weight-Binarized Convolutional Neural Network for Keyword Spotting

We study channel number reduction in combination with weight binarizatio...
09/12/2019 ∙ by Jiancheng Lyu, et al. ∙ 0

• ### DeepPermNet: Visual Permutation Learning

We present a principled approach to uncover the structure of visual data...
04/10/2017 ∙ by Rodrigo Santa Cruz, et al. ∙ 0

• ### Train faster, generalize better: Stability of stochastic gradient descent

We show that parametric models trained by a stochastic gradient method (...
09/03/2015 ∙ by Moritz Hardt, et al. ∙ 0

• ### Learning Permutations with Sinkhorn Policy Gradient

Many problems at the intersection of combinatorics and computer science ...
05/18/2018 ∙ by Patrick Emami, et al. ∙ 0

• ### Tighter Lifting-Free Convex Relaxations for Quadratic Matching Problems

In this work we study convex relaxations of quadratic optimisation probl...
11/29/2017 ∙ by Florian Bernard, et al. ∙ 0

• ### Graph Matching: Relax at Your Own Risk

Graph matching---aligning a pair of graphs to minimize their edge disagr...
05/13/2014 ∙ by Vince Lyzinski, et al. ∙ 0

• ### Reparameterizing the Birkhoff Polytope for Variational Permutation Inference

Many matching, tracking, sorting, and ranking problems require probabili...
10/26/2017 ∙ by Scott W. Linderman, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Light convolutional deep neural networks (LCNN) are attractive in resource limited conditions for delivering high performance at low costs. Some of the state-of-the-art LCNNs in computer vision are ShuffleNet (

[20], [13]), IGC (Interleaved Group Convolutions, [19]) and IGCV3 (Interleaved Low-Rank Group Convolutions,[15]). A noticeable feature in the design is the presence of permutations for channel shuffling in between separable convolutions. The permutations are hand-crafted by designers outside of network training however. A natural question is whether the permutations can be learned like network weights so that they are optimized based on training data. An immediate difficulty is that unlike weights, permutations are highly discrete and incompatible with the stochastic gradient descent (SGD) methodology that is continuous in nature. To overcome this challenge, we introduce an exact Lipschitz continuous non-convex penalty so that it can be incorporated in SGD to approximate permutation at high precision. Consequently, exact permutations are obtained by simple rounding at the end of network training with negligible drop of classification accuracy. To be specific, we shall work with ShuffleNet architecture ([20], [13]). Our approach extends readily to other LCNNs.

Related Work. Permutation optimization is a long standing problem arising in operations research, graph matching among other applications [7, 3]. Well-known examples are linear and quadratic assignment problems [16]. Graph matching is a special case of quadratic assignment problem, and can be formulated over permutation matrices as: , where and are the adjacency matrices of graphs with vertices, and is the Frobenius norm. A popular way to handle is to relax it to the Birkhoff polytope , the convex hull of , leading to a convex relaxation. The problem may still be non-convex due to the objective function. The explicit realization of is the set of doubly stochastic matrices , where . An approximate yet simpler way to treat is through the classical first order matrix scaling algorithm e.g. the Sinkhorn method [14]. Though in principle such algorithm converges, the cost can be quite high when iterating many times, which causes a bottleneck effect [11]. A non-convex and more compact relaxation of is by a sorting network [11] which maps the box into a manifold that sits inside and contains . Yet another method is path following algorithm [18] which seeks solutions under concave relaxations of

by solving a linear interpolation of convex-concave problems (starting from the convex relaxation). None of the existing relaxations are exact.

Contribution. Our non-convex relaxation is a combination of matrix penalty function and . The (the difference of and

norms) has been proposed and found effective in selecting sparse vectors under nearly degenerate linear constraints

[5, 17]. The matrix version is simply a sum of over all row and column vectors. We prove that the penalty is zero when applied to a matrix in if and only if the matrix is a permutation matrix. Thanks to the constraint, the penalty function is Lipschitz continuous (almost everywhere differentiable). This allows the penalty to be integrated directly into SGD for learning permutation in LCNNs. As shown in our experiments on CIFAR-10 and Imagenet data sets, the closeness to turns out to be remarkably small at the end of network training so that a simple rounding has negligible effect on the validation accuracy. We also found that convex relaxation by fails to capture good permutations for LCNNs. To our best knowledge, this is the first time permutations have been successfully learned on deep CNNs to improve hand-crafted permutations.

Outline. In section 2, we introduce our exact permutation penalty, and prove the closeness to permutation matrices when the penalty values are small as observed in the experiments. We also present the training algorithm combining thresholding and matrix scaling to approximate projection onto for SGD. In section 3, we analyze three permutation optimization problems to show the necessity of our penalty. In a 2-layer neural network regression model with short cut (identify map), convex relaxation does not give the optimal permutation even with additional rounding while our penalty can. In section 4, we show experimental results on consistent improvement of auto-shuffle over hand-crafted shuffle on both CIFAR-10 and Imagenet data sets. Conclusion is in section 5.

## 2 Permutation, Matrix ℓ1−2 Penalty and Exact Relaxation

The channel shuffle operation in ShuffleNet [20, 13] can be represented as multiplying the feature map in the channel dimension by a permutation matrix . The permutation matrix is a square binary matrix with exactly one entry of one in each row and each column and zeros elsewhere. In the ShuffleNet architecture [20, 13], is preset by the designers and will be called “manual”. In this work, we propose to learn an automated permutation matrix through network training, hence removing the human factor in its selection towards a more optimized shuffle. Since permutation is discrete in nature and too costly to enumerate, we propose to approach it by adding a matrix generalization of the penalty [5, 17] to the network loss function in the stochastic gradient descent (SGD) based training.

Specifically for , the proposed continuous matrix penalty function is

 (1)

in conjunction with the doubly stochastic constraint:

 mij≥0,∀(i,j);N∑i=1mij=1,∀j;N∑j=1mij=1,∀i. (2)
###### Remark 1.

When the constraints in (2) hold, and in can be removed. However, in actual computation, the two equality constraints of (2) only hold approximately, so the full expression in (1) is necessary.

###### Remark 2.

Thanks to (2), we see that the penalty function is actually Lipschitz continuous in as , , and , .

###### Theorem 1.

A square matrix is a permutation matrix if and only if , and the doubly stochastic constraint (2) holds.

###### Proof.

() Since a permutation matrix consists of columns (rows) with exactly one entry of 1 and the rest being zeros, each term inside the outer sum of equals zero, and clearly (2) holds.

() By the Cauchy-Schwarz inequality,

 (N∑j=1∣∣mij∣∣)−(N∑j=1m2ij)1/2≥0,∀i,

with equality if and only if the row-wise cardinalty is 1:

 |{j:mij≠0}|=1,∀i. (3)

This is because the mixed product terms like () in must all be zero to match . This only happens when equation (3) is true. Likewise,

 N∑i=1∣∣mij∣∣−(N∑i=1m2ij)1/2≥0,∀j,

with equality if and only if . In view of (2), is a permutation matrix. ∎

The non-negative constraint in (2) is maintained throughout SGD by thresholding . The normalization conditions in (2) are implemented sequentially once in SGD iteration. Hence they are not strictly enforced. In theory, if the column normalization (divide each column by its sum) and row normalization (divide each row by its sum) are iterated sufficiently many times, the resulting matrices converge to (2). This is known as the Sinkhorn process or RAS method [14], which is a first order method to approximately solve the so called matrix scaling problem (MSP). Simply state, the MSP for a given non-negative real matrix is to scale its rows and columns (i.e. multiply each by a non-negative constant) to realize the prescribed row sums and column sums. The approximate MSP is: given tolerance , find positive diagonal matrices and such that For a historical account of MSP and a summary of various algorithms to date, see [2] and Table 1 therein. The RAS method is an alternate minimization procedure with convergence guarantees. Each iteration of the RAS method costs complexity , being the number of non-zero entries in . If the entries of are polynomially bounded (which is the case during network training due to the continuous nature of SGD), the RAS method converges in iterations [6], giving total complexity , where tilde hides logarithmic factors in and . Improvements of complexity bounds via minimizing the log of capacity and higher order methods can be found in [2]. However for our study, the first order method [14] suffices for two reasons. One is that it is computationally low cost, the other is that the error in the matrix scaling step can be compensated in network weight adjustment during SGD. In fact, we did not find much benefit to iterate RAS method more than once in terms of enhancing validation accuracy. This is quite different from solving MAP as a stand alone task.

The multiplication by can be embedded in the network as a convolution layer with initialized as absolute value of a random Gaussian matrix. After each weight update, we threshold the weights to , normalize rows to unit lengths, then repeat on columns. Let be the network loss function. The training minimizes the objective function:

 f=f(w,M):=L(w)+λJ∑j=1P(Mj), (4)

where is the total number of “channel shuffles” ’s abbreviated as , is the network weight, a positive parameter. The training algorithm is summarized in Algorithm 1. The term in the penalty function has standard sub-gradient, and the term is differentiable away from zero, which is guaranteed in the algorithm 1 due to continuity of SGD and the normalization in columns and rows. is chosen to be or so as to balance the contributions of the two terms in (4) and drive close to .

We shall see that the penalty indeed gets smaller and smaller during training. Here we show a theoretical bound on the distance to when is small and (2) holds approximately.

###### Theorem 2.

Let the dimension of a non-negative square matrix be fixed. If , , and the doubly stochastic constraints are satisfied to , then there exists a permutation matrix such that .

###### Proof.

It follows from that

 (N∑j=1∣∣mij∣∣)−(N∑j=1m2ij)1/2=O(ϵ),∀i,

implying that:

 |mijmij′|=O(ϵ),∀j≠j′,∀i. (5)

On the other hand for :

 N∑j=1mij=1+O(ϵ). (6)

Let , at any . It follows from (6) that

 |mij∗|≥1/N+O(ϵ),

and from (5) that

 mij′=O(ϵ),∀j′≠j∗.

Hence each row of is close to a unit coordinate vector, with one entry near 1 and the rest near 0. Similarly from , and , we deduce that each column of is close to a unit coordinate vector, with one entry near 1 and the rest near 0. Combining the two pieces of information above, we conclude that is close to a permutation matrix. ∎

The learned non-negative matrix will be called a relaxed shuffle and will be rounded to the nearest permutation matrix to produce a final auto shuffle. Strictly speaking, this “rounding” involves finding the orthogonal projection to the set of permutation matrices, a problem called the linear assignment problem (LAP), see [1]

and references therein. The LAP can be formulated as a linear program over the doubly stochastic matrices or constraints (

2), and is solvable in polynomial time [1]. As we shall see later in Table 3, the relaxed shuffle comes amazingly close to an exact permutation in network learning. Hence, it turns out unnecessary to solve LAP exactly, indeed a simple rounding will do. AutoShuffleNet units adapted from ShuffleNet v1 [20] and ShuffleNet v2 [13] are illustrated in Figs. 2-2.

## 3 Permutation Problems Unsolvable by Convex Relaxation

The doubly stochastic matrix condition (

2) is a popular convex relaxation of permutation. However, it is not powerful enough to enable auto-shuffle learning as we shall see later. In this section, we present examples from permutation optimization to show the limitation of convex relaxation (2), and how our proposed penalty (1) can strength (2) to retrieve permutation matrices.

Let us recall the graph matching (GM) problem, see [16, 11, 1, 12, 18] and references therein. The goal is to align the vertices of two graphs to minimizes the number of edge disagreements. Given a pair of -vertex graphs and , with respective adjacency matrices and , the GM problem is to find a permutation matrix to minimize . Let be the set of all permutation matrices, solve

 Q∗:=argminQ∈Π∥AQ−QB∥2F. (7)

By algebraic identity:

 ∥AQ−QB∥2F= trace{(AQ−QB)T(AQ−QB)} = trace(ATA)+trace(BTB)−2trace(AQBTQT),

the GM problem (7) is same as:

 Q∗=argminQ∈Πtrace((−A)QBTQT), (8)

a quadratic assignment problem (QAP). The general QAP for two real square matrices and is [16, 11]:

 Q∗=argminQ∈Πtrace(AQBTQT). (9)

The convex relaxed GM is:

 Q∗:=argminQ∈DN∥AQ−QB∥2F. (10)

As an instance of general QAP, let us consider problem (7) in case for two real matrices:

 A=[abcd],B=[a′b′c′d′].

If , then:

 Q=[q1−q1−qq],q∈[0,1];

and equals ( ):

 [(a−a′)q+(b−c′)q′(b−b′)q+(a−d′)q′(c−c′)q+(d−a′)q′(d−d′)q+(c−b′)q′].

Example 1: We show that by selecting:

 A=[1231],B=[0231].
 AQ−QB=[2q−101−q1−q],
 ∥AQ−QB∥2F=(2q−1)2+2(1−q)2=6q2−8q+3,

which is convex on and has minimum at . The convex relaxed matrix solution is:

 Q∗=[2/31/31/32/3],

however, the permutation matrix solution to GM problem (7) is the identity matrix at .

In the spirit of objective function (4), let us minimize:

 ∥AQ−QB∥2F+λP(Q),

or equivalently minimize (after skipping some additive constants in ):

 F=F(q):=6q2−8q+2−4λ(q2+(1−q)2)1/2.

An illustration of is shown in Fig. 3. The minimal point moves from the interior of the interval when (dashed line, top curve) to the end point 1 as increases to 1 (line-star, middle curve) and remains there as further increases to 2 (line-circle, bottom curve). So for , is recovered with our proposed penalty. ∎

Example 2: Consider the adjacent matrix () of an un-directed graph of 2 nodes and 1 edge (with a loop at node 1). An edge adds 1 and a loop adds 2 to an adjacent matrix.

 A=[2110],B=[0110].

Then:

 AQ−QB=[2q2(1−q)00],
 ∥AQ−QB∥2F=4[q2+(1−q)2].

So . The regularized objective function (modulo additive constants) is:

 F=4[q2+(1−q)2]−4λ(q2+(1−q)2)1/2,

with . In view of:

 F′/4=(2q−1)[2−λ/(q2+(1−q)2)1/2],

two possible interior critical points are:

 q=1/2orq2+(1−q)2=λ2/4. (11)

Since , if , the second equality in (11) is ruled out. Comparing with , we see that the global minimal point does not occur at if

 1−√2λ>2−2λorλ>1/(2−√2)≈1.7071.

Hence if , minimizing recovers . ∎

In Fig. 4, we show that two minimal points of occur in the interior of when , and transition to , at . When , or , the second equality in (11) cannot hold, becomes convex with a unique minimal point at .

###### Remark 3.

We refer to [12] on certain correlated random Bernoulli graphs where . On the other hand, there is a class of friendly graphs [1] where . Existing techniques to improve convex relaxation on GM and QAP include approximate quadratic programming, sorting networks and path following based homotopy methods [16, 11, 18]. Our proposed penalty (1)-(2) appears more direct and generic. A detailed comparison will be left for a future study.

###### Remark 4.

In example 1 above, if the convex relaxed is rounded up to 1, then . In example 2 (Fig. 4), the two interior minimal points at , after rounding down (up), become zero or one. So convex relaxation with the help of rounding still recovers the exact permutation. We show in example 3 below that convex relaxation still fails after rounding (to 1 if the number is above 1/2, to 0 if the number is below 1/2).

Example 3: We consider the two-layer neural network model with one hidden layer [10]. Given , the forward model is the following function:

 fm(x,W)=∥ϕ((mI+W)x)∥1,

where

is the ReLU activation function,

is the input random vector drawn from a probability distribution,

is the weight matrix, is the identity matrix. Consider a two-layer teacher network with weight matrix

 W∗=[abcd],a,b,c,d≥0.

We train the student network with doubly stochastic constraint on using the loss:

 L(W)=Ex[fm(x,W)−fm(x,W∗)]2.

Let ,

 W=[p1−p1−pp].

We write the loss function as

 \lm(p):= L(W) = Ex[ϕ((m+p)x1+(1−p)x2)+ϕ((1−p)x1+(m+p)px2) −ϕ(ax1+bx2)−ϕ(cx1+dx2)]2 = Exϕ((m+p)x1+(1−p)x2)2+Exϕ((1−p)x1+(m+p)x2)2 −2Gm(p,a,b)−2Gm(p,c,d)+Ex[ϕ(ax1+bx2)+ϕ(cx1+dx2)]2, (12)

where for , is defined as

 Ex[ϕ((m+p)x1+(1−p)x2)ϕ(sx1+tx2)+ϕ((1−p)x1+(m+p)x2)ϕ(sx1+tx2)].

Define then and

 Gm(p,s,t)=I(m+p,1−p,s,t)+I(1−p,m+p,s,t).

For simplicity, let

obey uniform distribution on

. For , , , equals

 ⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩23(qs+rt)+q2(qt−3rs)24r2+s2(3qt−rs)24t2,q

We have

 Exϕ((m+p)x1+(1−p)x2)2 =Exϕ((1−p)x1+(m+p)x2)2 =23[(m+p)2+(1−p)2], (14)
 Ex[ϕ((m+p)x1+(1−p)x2)ϕ((1−p)x1+(m+p)x2)]=(m+1)33θm(p)+(m+p)412θm(p)2, (15)

where . The last term in (12) is a constant:

 Ex[ϕ(ax1+bx2)+ϕ(cx1+dx2)]2=23(a2+b2+c2+d2)+2I(a,b,c,d). (16)

Consider a special case when , , and . By (14)-(16), the loss function equals

Let When , , Fig. 5 (top left) shows has minimal points in the interior of . A permutation matrix that minimizes can be achieved by rounding the minimal points. However, when , , (Fig. 5, top right), rounding the interior minimal point of gives the wrong permutation matrix at . At , the regularization selects the correct permutation matrix.

###### Remark 5.

If obeys the unit Gaussian distribution as in [10], the functions are more complicated analytically, however their plots resemble those for uniformly distributed , see Fig. 6.

## 4 Experiments

We relax the shuffle units in ShuffleNet v1 [20] and ShuffleNet v2 [13] and perform experiments on CIFAR-10 [8] and ImageNet [4, 9] classification datasets. The accuracy results of auto shuffles are evaluated after the relaxed shuffles are rounded.

On CIFAR-10 dataset, we set the penalty parameter . All experiments are randomly initialized with learning rate linearly decaying from . We train each network for epochs. We set weight-decay , momentum and batch size . The experiments are carried out on a machine with single Nvidia GeForce GTX 1080 Ti GPU. In Table 1, we see that auto shuffle consistently improves by as much as 1% on manual shuffle in both v1 and v2 models of ShuffleNet.

On ImageNet dataset, we set the penalty parameter . For each experiment, the training process includes two training cycles: the first cycle is randomly initialized with learning rate starting at and the second one is resumed from the first one with learning rate starting at . Each cycle consists of epochs and the learning rate decays linearly. We set weight-decay , momentum and batch size . The experiments are carried out on a machine with 4 Nvidia GeForce GTX 1080 Ti GPUs. In Table 2, we see that auto shuffle again consistently improves on manual shuffle for both v1 and v2 models.

The permutation matrix of the first shuffle unit in ShuffleNet v1 (g=3) is a matrix of size , which can be visualized in Fig. 7 (manual, left) along with an auto shuffle (right). The dots (blanks) denote locations of 1’s (0’s). The auto shuffle looks disordered while the manual shuffle is ordered. However, the inference cost of auto shuffle is comparable to manual shuffle since the shuffle is fixed and stored after training.

The accuracy drop due to rounding to produce auto shuffle from relaxed shuffle is indicated by relative error in Table 3. On CIFAR-10 dataset, negligible drop is observed for ShuffleNet v1. Interestingly, rounding even gained accuracy for ShuffleNet v1 on ImageNet dataset.

The penalty of ShuffleNet v1 (g=3) is plotted in Fig. 8. As the penalty decays, the validation accuracy of auto shuffle (after rounding) becomes closer to relaxed shuffle (before rounding), see Fig. 9.

To demonstrate the significance of the regularization, we also tested auto shuffle with various on ShuffleNet v1 (g=3). Table 4 shows that the accuracy drops much after the relaxed shuffle is rounded. We plot the stochastic matrix of the first shuffle unit of the network at and respectively in Fig. 10. The penalty is large when is relatively small, indicating that the stochastic matrices learned are not close to optimal permutation matrices.

## 5 Conclusion

We introduced a novel, exact and Lipschitz continuous relaxation for permutation and learning channel shuffling in ShuffleNet. We showed through a regression problem of a 2-layer neural network with short cut that convex relaxation fails even with additional rounding while our relaxation is precise. We plan to extend our work to auto-shuffling of other LCNNs and hard permutation problems in the future.

## 6 Acknowledgement

The work was partially supported by NSF grant IIS-1632935.