Compacting Binary Neural Networks by Sparse Kernel Selection
Binary Neural Network (BNN) represents convolution weights with 1-bit values,
which enhances the efficiency of storage and computation. This paper is
motivated by a previously revealed phenomenon that the binary kernels in
successful BNNs are nearly power-law distributed: their values are mostly
clustered into a small number of codewords. This phenomenon encourages us to
compact typical BNNs and obtain further close performance through learning
non-repetitive kernels within a binary kernel subspace. Specifically, we regard
the binarization process as kernel grouping in terms of a binary codebook, and
our task lies in learning to select a smaller subset of codewords from the full
codebook. We then leverage the Gumbel-Sinkhorn technique to approximate the
codeword selection process, and develop the Permutation Straight-Through
Estimator (PSTE) that is able to not only optimize the selection process
end-to-end but also maintain the non-repetitive occupancy of selected
codewords. Experiments verify that our method reduces both the model size and
bit-wise computational costs, and achieves accuracy improvements compared with
state-of-the-art BNNs under comparable budgets.
Yikai Wang, Wenbing Huang, Yinpeng Dong, Fuchun Sun, Anbang Yao
# Compacting Binary Neural Networks by Sparse Kernel Selection

###### Abstract

Binary Neural Network (BNN) represents convolution weights with 1-bit values, which enhances the efficiency of storage and computation. This paper is motivated by a previously revealed phenomenon that the binary kernels in successful BNNs are nearly power-law distributed: their values are mostly clustered into a small number of codewords. This phenomenon encourages us to compact typical BNNs and obtain further close performance through learning non-repetitive kernels within a binary kernel subspace. Specifically, we regard the binarization process as kernel grouping in terms of a binary codebook, and our task lies in learning to select a smaller subset of codewords from the full codebook. We then leverage the Gumbel-Sinkhorn technique to approximate the codeword selection process, and develop the Permutation Straight-Through Estimator (PSTE) that is able to not only optimize the selection process end-to-end but also maintain the non-repetitive occupancy of selected codewords. Experiments verify that our method reduces both the model size and bit-wise computational costs, and achieves accuracy improvements compared with state-of-the-art BNNs under comparable budgets.

## 1 Introduction

It is crucial to design compact Deep Neural Networks (DNNs) which allow the model deployment on resource-constrained embedded devices, since most powerful DNNs including ResNets [12] and DenseNets [15] are storage costly with deep and rich building blocks piled up. Plenty of approaches have been proposed to compress DNNs, among which network quantization [17, 51, 53] is able to reduce memory footprints as well as accelerate the inference speed by converting full-precision weights to discrete values. Binary Neural Networks (BNNs) [3, 16] belong to the family of network quantization but they further construct the parameter representations to binary values (\(\pm 1\)). In this way, the model is largely compressed. More importantly, floating-point additions and multiplications in conventional DNNs are less required and mostly reduced to bit-wise operations that are well supported by fast inference accelerators [37], particularly when activations are binarized as well. To some extent, this makes BNNs more computationally efficient than other compression techniques,, network pruning [11, 13, 30] and switchable models [44, 49, 50].

Whilst a variety of methods are proposed to improve the performance of BNNs, seldom is there a focus on discussing how the learnt binary kernels are distributed in BNNs. A recent work SNN [45] demonstrates that, by choosing typical convolutional BNN models [32, 36, 37] well trained on ImageNet and displaying the distribution of the \(3\times 3\) kernels along all possible \(2^{3\times 3}\) binary values (_a.k.a._ codewords), these kernels nearly obey the power-law distribution: only a small portion of codewords are activated for the most time. Such a phenomenon is re-illustrated in Figure 1(b). This observation motivates SNN to restrict the size of the codebook by removing those hardly-selected codewords. As a result, SNN is able to compact BNN further since indexing the kernels with a smaller size of codebook results in a compression ratio of \(\log_{2}(n)/\log_{2}(N)\), where \(n\) and \(N\) are separately the sizes of the compact and full codebooks.

However, given that the size of codebook is limited (only \(512\)), the sub-codebook degenerates during training since codewords are likely to become repetitive. Therefore, we believe the clustering property of kernels can be further exploited during the training of BNNs. To do so, we reformulate the binary quantization process as a grouping task that selects, for each kernel, the nearest codeword from a binary sub-codebook which is obtained by selecting optimal codewords from the full one. To pursue an optimal solution and retain the non-repetitive occupancy of the selected codewords, we first convert the sub-codebook selection problem to a permutation learning task. However, learning the permutation matrix is non-differential since the permutation matrix is valued with only 0/1 entries. Inspired by the idea in [34], we introduce the Gumbel-Sinkhorn op
eration to generate a continuous and differential approximation of the permutation matrix. During training, we further develop Permutation Straight-Through Estimator (PSTE), a novel method that tunes the approximated permutation matrix end-to-end while maintaining the binary property of the selected codewords. The details are provided in SS 3.2 and SS 3.3. We further provide the complexity analysis in SS 3.4.

Extensive results on image classification and object detection demonstrate that our architecture noticeably reduces the model size as well as the computational burden. For example, by representing ResNet-18 with 0.56-bit per weight on ImageNet, our method brings in 214\(\times\) saving of bit-wise operations, and 58\(\times\) reduction of the model size. Though state-of-the-art BNNs have achieved remarkable compression efficiency, we believe that further compacting BNNs is still beneficial, by which we can adopt deeper, wider, and thus more expressive architectures without exceeding the complexity budget than BNNs. For example, our 0.56-bit ResNet-34 obtains 1.7% higher top-1 accuracy than the state-of-the-art BNN on ResNet-18, while its computational costs are lower and the storage costs are almost the same.

Existing methods [24, 25] (apart from SNN [45]) that also attempt to obtain more compact models than BNNs are quite different with ours as will be described in SS 2. One of the crucial points is that their codewords are sub-vectors from (flattened) convolution weights across multiple channels, whereas our each codeword corresponds to a complete kernel that maintains the spatial dimensions (weight and height) of a single channel. The reason why we formulate the codebook in this way stems from the observation in Figure 1(b), where the kernels are sparsely clustered. Differently, as shown in Figure 1(a), the codewords are nearly uniformly activated if the codebook is constructed from flattened sub-vectors, which could because the patterns of the input are spatially selective but channel-wise uniformly distributed. It is hence potential that our method may recover better expressivity of BNNs by following this natural characteristic. In addition, we optimize the codewords via non-repetitive selection from a fixed codebook, which rigorously ensures the dissimilarity between every two codewords and thus enables more capacity than the product quantization method used in [24], as compared in Figure 1(c)(d). On ImageNet with the same backbone, our method exceeds [24] and [25] by \(6.6\%\) and \(4.5\%\) top-1 accuracies, respectively.

## 2 Related Work

**BNNs.** Network quantization methods [7, 17, 51, 53] convert network weights to low-bit values and are appealing for resource-limited devices given the superiority in efficiency. As an extreme solution of quantization, BNNs [3, 3, 16, 37] represent weights and activations with 1-bit (\(\pm 1\)) values, bringing 32\(\times\) storage compression ratio and 58\(\times\) practical computational reduction on CPU as reported by [37]. BNNs usually adopt a non-differentiable sign function during the forward pass and the Straight-Through Estimator (STE) [3] for gradient back-propagation. Many attempts are proposed to narrow the performance gap between BNNs and their real-valued counterparts. XNOR-Net [37] adopts floating-point parameters as scaling factors to reduce the quantization error. Bi-Real [31] proposes to add ResNet-like shortcuts to reduce the information loss during binarization. ABC-Net [28] linearly combines multiple binary weight bases to further approximate full-precision weights. ReActNet [32] generalizes activation functions to capture the distribution reshape and shift. New architectures for BNNs can be searched [39] or designed [4] to further improve the trade-off between performance and efficiency.

**Compacting BNNs.** Our work focuses on an orthogonal venue and investigates how to compact BNNs further. Previously, SNN [45] reveals that binary kernels learnt at convolutional layers of a BNN model are likely to be distributed

Figure 1: Codebook distributions under different decomposition approaches. Statistics in both sub-figures are collected from the same BNN model (XNOR-Net [37] upon ResNet-18 [12]) well-trained on ImageNet [5]. In (a), each codeword is a flattened sub-vector (of size \(1\times 9\)). In (b), each codeword is a \(3\times 3\) convolution kernel. The codebook in either sub-figure consists of \(2^{9}=512\) different codewords. Upper tables provide the total percentages of the top-\(n\) most frequent codewords. In (c), we observe that the sub-codebook highly degenerates during training, since codewords tend to be repetitive when being updated independently. While in (d), the diversity of codewords preserves, which implies the superiority of our selection-based learning.
over kernel subsets. Based on this, SNN randomly samples layer-specific binary kernel subsets and refines them during training. However, the optimization of SNN is easy to attain repetitive binary kernels, _i.e_., degenerated subsets, leading to a noticeable performance drop compared with conventional BNN. Another method sharing a similar motivation with us is the fractional quantization (FleXOR) [25], which encrypts the sub-vectors of flattened weights to low-dimensional binary codes. Yet, FleXOR cannot track which weights share the same encrypted code, and thus it is needed to decrypt the compressed model back to the full BNN for inference. In our method, the reconstruction of the corresponding BNN is unnecessary, since the computation can be realized in the space of codewords, leading to further reduction of bit-wise computations as detailed in SS 3.4. Another research close to our paper is SLBF [24] that applies the idea of stacking low-dimensional filters [48] and the product quantization [19, 42, 9] to BNNs. Similar to [25], this method splits the (flattened) weights into sub-vectors as codewords along the channel direction. As already demonstrated in SS 1, our method leverages kernel-wise codebook creation by selection-based codeword optimization, yielding much lower quantization errors than [24, 25].

## 3 Sparse Kernel Selection

In this section, we introduce how to compact and accelerate BNN further by Sparse Kernel Selection, abbreviated as **Sparks**. Towards this goal, we first formulate the quantization process as grouping convolution kernels into a certain binary codebook. We then show that a more compact sub-codebook can be learnt end-to-end via Gumbel-Sinkhorn ranking. To enable the optimization of the ranking while keeping the binary property, we further propose the Permutation Straight-Through Estimator (PSTE) technique with the convergence analysis. Finally, we contrast the complexity of the model with BNN, and demonstrate that our method is able to not only compress BNN further but also accelerate the speed of BNN during inference.

### Binarization below 1-Bit

Prior to going further, we first provide the notations and necessary preliminaries used in our paper. Let \(\mathbf{W}\in\mathbb{R}^{C_{\text{out}}\times C_{\text{in}}\times K\times K}\) be the convolution weights, where \(C_{\text{out}}\) and \(C_{\text{in}}\) are the numbers of the output and input channels, respectively, and \(K\) is the kernel size. As discussed in SS 1, we are interested in the quantization for each specific kernel, denoted with a lowercase letter as \(\mathbf{w}\in\mathbb{R}^{K\times K}\). The quantization process aims to map full-precision weights to a smaller set of discrete finite values. Specifically, we conduct the function \(\mathrm{sign}\) for each kernel, resulting in \(\hat{\mathbf{w}}=\mathrm{sign}(\mathbf{w})\in\mathbb{B}\) where \(\mathbb{B}=\{-1,+1\}^{K\times K}\) is the set consisting of 1-bit per weight. In what follows, \(\mathbb{B}\) is called the (full) codebook, and each element in \(\mathbb{B}\) is a codeword.

Generally, the quantization can be rewritten as an optimization problem \(\hat{\mathbf{w}}=\mathrm{arg}\min_{\mathbf{u}\in\mathbb{B}}\|\mathbf{u}-\mathbf{w}\|_{2}\) that grouping each kernel \(\mathbf{w}\) to its nearest codeword in \(\mathbb{B}\), where \(\|\cdot\|_{2}\) denotes the \(\ell_{2}\) norm. We state this equivalence in the form below, and the proof is provided in Appendix.

**Property 1**: _We denote \(\mathbb{B}=\{-1,+1\}^{K\times K}\) as the codebook of binary kernels. For each \(\mathbf{w}\in\mathbb{R}^{K\times K}\), the binary kernel \(\hat{\mathbf{w}}\) can be derived by a grouping process:_

\[\hat{\mathbf{w}}=\mathrm{sign}(\mathbf{w})=\mathrm{arg}\min_{\mathbf{u}\in\mathbb{B}}\| \mathbf{u}-\mathbf{w}\|_{2}. \tag{1}\]

Since the codebook size \(|\mathbb{B}|=2^{K\times K}\), the memory complexity of BNN is equal to \(K\times K\). Given Equation 1, one may want to know if we can further reduce the complexity of BNN by, for example, sampling a smaller subset of the codebook \(\mathbb{B}\) to replace \(\mathbb{B}\) in Equation 1. This is also motivated by Figure 1(b) where the learnt kernels of BNNs are sparsely clustered into a small number of codewords. In this way, each kernel is represented below \(K^{2}\)-bits and thus averagely, each weight is represented less than 1-bit. We thus recast the grouping as

\[\hat{\mathbf{w}}=\operatorname*{arg}\min_{\mathbf{u}\in\mathbb{U}}\|\mathbf{u}-\mathbf{w}\|_{2 },\text{ s.t. }\mathbb{U}\subseteq\mathbb{B}. \tag{2}\]

We denote \(|\mathbb{U}|=n\) and \(|\mathbb{B}|=N\). By Equation 2, each binary kernel occupies \(\log_{2}(n)\) bits as it can be represented by an index in \(\{1,2,\cdots,n\}\). Thus we obtain a compression ratio of \(\log_{2}(n)/\log_{2}(N)\).

Different choice of the sub-codebook \(\mathbb{U}\) from \(\mathbb{B}\) potentially delivers different performance. How can we determine the proper selection we prefer? One possible solution is to optimize codewords and kernels simultaneously by making use of the product quantization method [42, 24]. Nevertheless, this method updates each codeword independently and is prone to deriving repetitive codewords if the optimization space is constrained (as values are limited to \(\pm 1\)). As a consequence, it will hinder the diversity of the codebook and limit the expressivity of the model, which will be verified in SS 4.2. Another straightforward method would be sampling the most frequent \(n\) codewords from a learnt target BNN (depicted in Figure 1(b)). Yet, such a solution is suboptimal since it solely depends on the weight distribution of the eventual model without the involvement of the specific training dynamics. In the following subsections, we will propose to tackle the sub-codebook selection via an end-to-end approach while retaining the non-repeatability of the codewords.

### Sub-Codebook Selection via Permutation

We learn a permutation of codewords in \(\mathbb{B}\) according to their effects on the target loss function, so that the selection of the first \(n\) codewords is able to optimize the final performance of the target task. The designed permutation learning keeps the binary property of the selected codewords.
For convenience, we index codewords in \(\mathbb{B}\) as a matrix column by column, formulated as \(\mathbf{B}=[\mathbf{u}_{1};\mathbf{u}_{2};\cdots;\mathbf{u}_{N}]\in\{\pm 1\}^{K^{2}\times N}\), where each codeword in \(\mathbb{B}\) is flattened to a \(K^{2}\)-dimensional vector. Similarly, we convert \(\mathbb{U}\) as \(\mathbf{U}=[\mathbf{u}_{s_{1}};\mathbf{u}_{s_{2}};\cdots,\mathbf{u}_{s_{n}}]\in\{\pm 1\}^{K^{2} \times n}\), where \(s_{i}\in\{1,2,\cdots,N\}\) is the index of the \(i\)-th selected codeword. We denote the selection matrix as \(\mathbf{V}\in\{0,1\}^{N\times n}\), then

\[\mathbf{U}=\mathbf{BV}, \tag{3}\]

where the entries of \(\mathbf{V}\) satisfy \(\mathbf{V}_{s_{i},i}=1\) for \(i=1,\cdots,n\) and are zeros otherwise. The selection by Equation 3 is permutation-dependent; in other words, if we permute the element of \(\mathbb{B}\), we may obtain different \(\mathbb{U}\). Hence, how to select \(\mathbb{U}\) becomes how to first permute \(\mathbb{B}\) and then output \(\mathbb{U}\) by Equation 3. We denote \(\mathbb{P}_{N}\) the set of \(N\)-dimensional permutation matrices: \(\mathbb{P}_{N}=\{\mathbf{P}\in\{0,1\}^{N\times N}\,|\,\mathbf{P}\mathbf{1}_{N}=\mathbf{1}_{N},\mathbf{P}^{\top}\mathbf{1}_{N}=\mathbf{1}_{N}\}\), where \(\mathbf{1}_{N}\) is an \(N\)-dimensional column vector of ones. The optimization problem in Equation 2 is transformed into

\[\hat{\mathbf{w}}=\operatorname*{arg\,min}_{\mathbf{u}\in\mathbb{U}}\|\mathbf{u}-\mathbf{w}\|_ {2},\text{ s.t. }\mathbf{U}=\mathbf{BPV},\mathbf{P}\in\mathbb{P}_{N}, \tag{4}\]

where \(\mathbf{V}\) is fixed as a certain initial selection.

Now, the goal is how to determine a proper permutation matrix \(\mathbf{P}\). Basically, we can design a neural network to output \(\mathbf{P}\), and then embed it into the off-the-shelf CNN for the downstream task. Unfortunately, this pipeline fails as the permutation matrix \(\mathbf{P}\) is discrete, whose values are occupied with 0 or 1, making the permutation network non-differentiable. Joining the recent advancement of permutation learning, we leverage the method proposed by [1] that approximates the permutation matrix by its continuous and differentiable relaxation--the Sinkhorn operator [41].

Given a matrix \(\mathbf{X}\in\mathbb{R}^{N\times N}(N=|\mathbb{B}|)\), the Sinkhorn operator over \(\mathcal{S}(\mathbf{X})\) is proceeded as follow,

\[\mathcal{S}^{0}(\mathbf{X}) =\exp(\mathbf{X}), \tag{5}\] \[\mathcal{S}^{k}(\mathbf{X}) =\mathcal{T}_{c}\left(\mathcal{T}_{r}(S^{k-1}(\mathbf{X}))\right),\] (6) \[\mathcal{S}(\mathbf{X}) =\lim_{k\rightarrow\infty}\mathcal{S}^{k}(\mathbf{X}), \tag{7}\]

where \(\mathcal{T}_{r}(\mathbf{X})=\mathbf{X}\oslash(\mathbf{X}\mathbf{1}_{N}\mathbf{1}_{N}^{\top})\) and \(\mathcal{T}_{c}(\mathbf{X})=\mathbf{X}\oslash(\mathbf{1}_{N}\mathbf{1}_{N}^{\top}\mathbf{X})\) are the row-wise and column-wise normalization operators, and \(\oslash\) denotes the element-wise division. For stability purpose, both normalization operators are calculated in the log domain in practice. The work by [41] proved that \(\mathcal{S}(\mathbf{X})\) belongs to the Birkhoff polytope--the set of doubly stochastic matrices.

Through adding a temperature \(\tau\), it can be proved that \(\lim_{\tau\to 0^{+}}\mathcal{S}(\mathbf{X}/\tau)=\operatorname*{arg\,max}_{\mathbf{P} \in\mathbb{P}_{N}}\|\mathbf{P}-\mathbf{X}\|_{2}\) holds almost surely [34]. It means we obtain an approximated permutation matrix \(\mathcal{S}^{k}(\mathbf{X})\) (that is closest to \(\mathbf{X}\)) with sufficiently large \(k\) and small \(\tau\). Inspired by [18], we also add a Gumbel noise to make the result follow the Gumbel-Matching distribution \(\mathcal{G}.\mathcal{M}.(\mathbf{X})\), namely, \(\mathcal{S}^{k}((\mathbf{X}+\epsilon)/\tau)\), where \(\epsilon\) is sampled from standard i.i.d. Gumbel distribution.

By substituting the Gumbel-Sinkhorn matrix into Equation 3, we characterize the sub-codebook selection as

\[\mathbf{U}=\mathbf{B}\mathcal{S}^{k}((\mathbf{X}+\epsilon)/\tau)\mathbf{V}, \tag{8}\]

where \(\mathbf{V}\) is fixed as a certain initial selection as mentioned, \(\mathbf{X}\) is regarded as a learnable parameter, \(k\) and \(\tau\) are hyperparameters. For \(\mathbf{V}\), we can simply let the entries to be zeros unless \(\mathbf{V}_{i,i}=1\), where \(i=1,\cdots,n\), which indicates selecting the first \(n\) columns from \(\mathbf{B}\mathcal{S}^{k}((\mathbf{X}+\epsilon)/\tau)\).

### Learning by PSTE

Recalling that both \(k\) and \(\tau\) are finitely valued, the Gumbel-Sinkhorn matrix \(\mathbf{P}_{\mathrm{GS}}=\mathcal{S}^{k}((\mathbf{X}+\epsilon)/\tau)\) is not strictly a permutation matrix with 0/1 entries. This will violate the binary property of \(\mathbf{U}\) by Equation 8, making the binarization of Equation 2 meaningless. To address this issue, we derive the exact permutation matrix \(\mathbf{P}_{\mathrm{real}}\) of \(\mathbf{P}_{\mathrm{GS}}\) by making use of the Hungarian algorithm [35] during the forward pass. By treating the \(\mathbf{P}_{\mathrm{GS}}\) as a reward matrix, deriving \(\mathbf{P}_{\mathrm{real}}\) becomes an assignment problem that can be solved by the Hungarian method in polynomial time. We summarize the forward update of the convolution kernel \(\mathbf{w}_{c}\in\mathbb{R}^{K^{2}}\) for each input and output channel as follow,

\[\mathbf{P}_{\mathrm{real}} =\mathrm{Hungarian}(\mathbf{P}_{\mathrm{GS}}), \tag{9}\] \[\mathbf{U} =\mathbf{B}\mathbf{P}_{\mathrm{real}}\mathbf{V},\] (10) \[\hat{\mathbf{w}}_{c} =\operatorname*{arg\,min}_{\mathbf{u}\in\mathbb{U}}\|\mathbf{u}-\mathbf{w}_{c} \|_{2}, \tag{11}\]

where \(\mathrm{Hungarian}(\cdot)\) denotes the Hungarian algorithm.

In the backward pass, we transfer the gradient of the exact permutation matrix directly to the Gumbel-Sinkhorn matrix. This is inspired by the Straight-Through Estimator (STE) technique [3] in previous literature. We call our method PSTE for its specification to permutation learning here. The backward pass is depicted below,

\[\mathbf{g}(\mathbf{w}_{c,i}) \approx\ \begin{cases}\mathbf{g}(\hat{\mathbf{w}}_{c,i}),&\text{if }\mathbf{w}_{c,i}\in(-1,1)\,,\\ 0,&\text{otherwise},\end{cases} \tag{12}\] \[\mathbf{g}(\mathbf{u}_{j}) =\sum_{c=1}^{C_{\mathrm{in}}\times C_{\mathrm{out}}}\mathbf{g}( \hat{\mathbf{w}}_{c})\cdot\mathbb{I}_{\mathbf{u}_{j}=\operatorname*{arg\,min}_{\mathbf{u }\in\mathbb{U}}\|\mathbf{u}-\mathbf{w}_{c}\|_{2}},\] (13) \[\mathbf{g}(\mathbf{P}_{\mathrm{real}}) =\ \mathbf{B}^{\top}\mathbf{g}(\mathbf{U})\mathbf{V}^{\top},\] (14) \[\mathbf{g}(\mathbf{P}_{\mathrm{GS}}) \approx\ \mathbf{g}(\mathbf{P}_{\mathrm{real}}), \tag{15}\]

where \(\mathbf{g}(\cdot)\) computes the gradient. \(\mathbf{w}_{c,i}\) and \(\hat{\mathbf{w}}_{c,i}\) denote the \(i\)-th entries of \(\mathbf{w}_{c}\) and \(\hat{\mathbf{w}}_{c}\), respectively, with \(i=1,2,\cdots,K^{2}\). \(\mathbb{I}_{\{\cdot\}}\) defines the indicator function. Particularly, Equation 12 follows the idea of STE and Equation 13
assigns the gradient of the binary weight to its nearest codeword. In practice, all forward and backward passes can be implemented by matrix/tensor operations, and thus our method is computationally friendly on GPUs.

An overall framework including the forward and backward processes is illustrated in Figure 2.

**Convergence analysis.** Besides using STE to update \(\mathbf{w}\) in Equation 12, we approximate the gradient of the Gumbel-Sinkhorn matrix \(\mathbf{P}_{\mathrm{GS}}\) with \(\mathbf{P}_{\mathrm{real}}\) in Equation 15, which, inevitably, will cause variations in training dynamics. Fortunately, we have the following theorem to guarantee the convergence for sufficiently large \(k\) and small \(\tau\).

**Lemma 1**: _For sufficiently large k and small \(\tau\), we define the entropy of a doubly-stochastic matrix \(\mathbf{P}\) as \(h(\mathbf{P})=-\sum_{i,j}P_{i,j}\log P_{i,j}\), and denote the rate of convergence for the Sinkhorn operator as \(r\left(0<r<1\right)\)1. There exists a convergence series \(s_{\tau}\) (\(s_{\tau}\to 0\) when \(\tau\to 0^{+}\)) that satisfies_

Footnote 1: The Sinkhorn operator has a rate of convergence \(r\) bounded by a value lower than \(1\) as proved by [22].

\[\|\mathbf{P}_{\mathrm{real}}-\mathbf{P}_{\mathrm{GS}}\|_{2}^{2}=\mathcal{O}\big{(}s_{ \tau}^{2}+r^{2k}\big{)}. \tag{16}\]

**Theorem 1**: _Assume that the training objective \(f\) w.r.t. \(\mathbf{P}_{\mathrm{GS}}\) is \(L\)-smooth, and the stochastic gradient of \(\mathbf{P}_{\mathrm{real}}\) is bounded by \(\mathbb{E}\|\mathbf{g}(\mathbf{P}_{\mathrm{real}})\|_{2}^{2}\leq\sigma^{2}\). Denote the rate of convergence for the Sinkhorn operator as \(r\left(0<r<1\right)\) and the stationary point as \(\mathbf{P}_{\mathrm{GS}}^{*}\). Let the learning rate of PSTE be \(\eta=\frac{c}{\sqrt{f}}\) with \(c=\sqrt{\frac{f(\mathbf{P}_{\mathrm{GS}}^{0})-f(\mathbf{P}_{\mathrm{GS}}^{*})}{L \sigma^{2}}}\). For a uniformly chosen \(\mathbf{u}\) from the iterates \(\{\mathbf{P}_{\mathrm{real}}^{0},\cdots,\mathbf{P}_{\mathrm{real}}^{T}\}\), concretely \(\mathbf{u}=\mathbf{P}_{\mathrm{real}}^{t}\) with the probability \(p_{t}=\frac{1}{T+1}\), it holds in expectation over the stochasticity and the selection of \(\mathbf{u}\) :_

\[\mathbb{E}\|\nabla f(\mathbf{u})\|_{2}^{2}=\mathcal{O}\left(\sigma\sqrt{\frac{f( \mathbf{P}_{\mathrm{GS}}^{0})-f(\mathbf{P}_{\mathrm{GS}}^{*})}{T/L}}+L^{2}\big{(}s_{ \tau}^{2}+r^{2k}\big{)}\right)\,. \tag{17}\]

Note that in Theorem 1, the objective function \(f\) could be a non-convex function, which accords with the case when using a neural network. Proofs for Lemma 1 and Theorem 1 are provided in Appendix.

### Complexity Analysis During Inference

**Storage**. We consider the convolutional layer with \(3\times 3\) kernels. In a conventional binary convolutional layer, the weights requires \(C_{\text{out}}\times C_{\text{in}}\times K\times K\) bits. For our method, we only store the sub-codebook \(\mathbb{U}\) and the index of each kernel by Equation 2. Storing \(\mathbb{U}\) needs \(n\times K\times K\) bits, where \(n=|\mathbb{U}|\). Since \(n\leq N=2^{K\times K}\ll C_{\text{out}}\times C_{\text{in}}\) for many popular CNNs (_e.g._, ResNets [12]), particularly if all layers share the same \(\mathbb{U}\) which is the case of our implementation, only the indexing process counts majorly. The indexing process needs \(\log_{2}(n)\) bits for a kernel, hence indexing all kernels takes \(C_{\text{out}}\times C_{\text{in}}\times\log_{2}(n)\). As a result, the ratio of storage saving by our method is \(\log_{2}(n)/(K\times K)=\log_{2}(n)/\log_{2}(N)\leq 1\) compared to a conventional BNN.

**Computation**. We adopt BOPs to measure the computational costs and follow the calculation method in [31, 32, 33, 37] where each BOP represents two bit-wise operations. In a conventional BNN, the convolution operation between the input feature maps (\(C_{\text{in}}\times H\times W\)) and weights (\(C_{\text{out}}\times C_{\text{in}}\times K\times K\)) takes \(\mathrm{BOPs}=H\times W\times C_{\text{in}}\times K^{2}\times C_{\text{out}}\), where \(H\) and \(W\) are the height and width of the feature map, respectively. For our method, the kernel grouping process implies that some weights will share the same value, which enables us to further reduce \(\mathrm{BOPs}\). To do so, we pre-calculate the convolutions between the input feature maps (\(C_{\text{in}}\times H\times W\)) and each codeword (\(K\times K\)). For facility, we reshape the codeword as \(1\times C_{\text{in}}\times K\times K\) by repeating the second dimension over \(C_{\text{in}}\) times. Then, the pre-convolution for all codewords gives rise to a tensor \(\mathcal{T}\) (\(n\times C_{\text{in}}\times H\times W\)) and costs \(\mathrm{BOPs}_{1}=H\times W\times C_{\text{in}}\times K^{2}\times n\). We reconstruct the convolution result between the input feature maps and the convolution weights given the pre-calculated tensor \(\mathcal{T}\). Specifically, for each output channel, we query indices of the input channels _w.r.t._\(\mathbb{U}\), collect feature maps from \(\mathcal{T}\) according to the indices, and sum the feature maps as the final result. This process consumes \(\mathrm{BOPs}_{2}=C_{\text{out}}\times(C_{\text{in}}\times H\times W-1)/2\). Therefore, Sparks needs \(\mathrm{BOPs}_{1}+\mathrm{BOPs}_{2}\) which is far less than \(\mathrm{BOPs}\) when \(K=3\), as \(n<C_{out}\) in general.

Figure 2: **Left:** A schematic overview of the optimization process. Full-precision weights are binarized by grouping to the nearest codeword of the sub-codebook \(\mathbb{U}\), which is obtained by Gumbel-Sinkhorn and optimized by PSTE. Forward and backward passes illustrate how the network calculates and updates. **Right**: Relationship of notations for a better understanding. The horizontal axis and vertical axis stand for the values of \(k\) and \(\tau\), respectively. Only parameters in the green region are actually calculated during training, while the others are only for the understanding purpose. All these parameters are NOT needed during inference.
## 4 Experiments

Our method is evaluated on two tasks: image classification and object detection (in Appendix). For image classification, we contrast the performance of our Sparks with state-of-the-art (SOTA) methods on CIFAR10 [23] and ImageNet (ILSVRC2012) [5] following the standard data splits.

**Implementation.** We follow the standard binarization in ReActNet [32] and perform a two-stage training. First, the network is trained from scratch with binarized activations and real-valued weights. Second, the network takes the weights from the first step and both weights and activations are binarized. As suggested by [31, 37], we keep the weights and activations in the first convolutional and the last fully-connected layers to be real-valued. More implementation details (_e.g._, learning rate, epoch) are in the Appendix.

We speed up our training twice by exploiting the symmetry of the binary kernels: for each codeword in the codebook \(\|\mathbb{B}\|\), its "opposite" term (with opposite signs) is also contained in \(\|\mathbb{B}\|\). Speed-up details are contained in Appendix. Hyper-parameters are \(k=10\) and \(\tau=10^{-2}\) by default.

On ImageNet, Sparks needs 30.2 hours to train ResNet-18 based on 8 V100s, and the BNN baseline [32] needs 24.5 hours. The computation overhead is acceptable. Training Sparks can be easily accelerated as presented in Appendix

Calculations of storage and BOPs savings are based on the measurements used in [31, 37]. Specifically, compared to full-precision convolutional layers with 32-bit weights, using 1-bit weights and activations gains up to a \(\sim\)32\(\times\) storage saving; in addition, the convolution operation could be implemented by the bit-wise xnor operation followed by a popcount operation, which leads to a \(\sim\)64\(\times\) computational saving. Throughout our results, we provide the amount of bit-wise parameters in all binarized layers as the storage.

### Comparisons with SOTA Methods

**Evaluation on CIFAR10.** Table 1 provides the performance comparisons with SOTA BNNs on CIFAR10. Moreover, SLBF [24] and FleXOR [25] that derive weights below 1-bit are re-implemented upon the same backbone (ReActNet) and same binarization settings (both weights and activations are binarized) as our method for a fair comparison. By setting \(n\) to 32, 64, and 128, we obtain networks of 0.56-bit, 0.67-bit, and 0.78-bit, respectively. Clearly, our approach is able to achieve accuracies close to standard BNNs with a much lower cost of storage and BOPs on both ResNet-18 and VGG-small. FleXOR also compacts BNNs but delivers no BOPs reduction. SLBF reduces both storage and BOPs but suffers from more accuracy drops as it conducts convolution in the space of multi-channel codewords, leading to much larger quantization errors, as previously described in Figure 1. Our Sparks remarkably outperforms SLBF and FleXOR under almost the same compression level of storage (_e.g._ for ResNet-18, our 0.56-bit gains accuracy 91.5%, while 0.60-bit FleXOR and 0.55-bit SLBF yield 89.8% and 89.3%, respectively), which verify the effectiveness of our proposed method.

**Evaluation on ImageNet.** In Table 2, we compare Sparks with SOTA methods upon ResNet-18 on ImageNet. Consistent with the results on CIFAR10, our method is able to achieve competitive classification accuracy compared to SOTA BNNs, with a dramatic drop in model size and computation time. Under comparable bit-widths, our 0.56-bit method exceeds 0.55-bit SLBF and 0.6-bit FleXOR by \(6.6\%\) and \(4.5\%\), respectively, with even fewer BOPs. Thanks to the remarkable benefit in model compression, we can apply our Sparks on wider and deeper models while staying the same complexity budget as BNNs. For example, in Table 3, we follow ABC-Net [28] and apply our

\begin{table}
\begin{tabular}{l c c c c c c c c} \hline \hline Method & Bit-width & Accuracy & Storage & BOPs & Method & Bit-width & Accuracy & Storage & BOPs \\
**(ResNet-18)** & (W/A) & Top-1 (\%) & (Mbit) & (\(\times 10^{8}\)) & **(VGG-small)** & (W/A) & Top-1 (\%) & (Mbit) & (\(\times 10^{8}\)) \\ \hline Full-precision & 32/32 & 94.8 & 351.5(\(\times\)1) & 350.3(\(\times\)1) & Full-precision & 32/32 & 94.1 & 146.2(\(\times\)1) & 386.6(\(\times\)1) \\ \hline XNOR-Net [37] & \(1/1\) & 90.2 & 11.0(32\(\times\)) & 5.47(64\(\times\)) & XNOR-Net [37] & \(1/1\) & 89.8 & 4.57(32\(\times\)) & 6.03(64\(\times\)) \\ Bi-RealNet [31] & \(1/1\) & 90.2 & 11.0(32\(\times\)) & 5.47(64\(\times\)) & LAB [14] & \(1/1\) & 87.7 & 4.57(32\(\times\)) & 6.03(64\(\times\)) \\ RAD [6] & \(1/1\) & 90.5 & 11.0(32\(\times\)) & 5.47(64\(\times\)) & RAD [6] & \(1/1\) & 90.0 & 4.57(32\(\times\)) & 6.03(64\(\times\)) \\ IR-Net [36] & \(1/1\) & 91.5 & 11.0(32\(\times\)) & 5.47(64\(\times\)) & IR-Net [36] & \(1/1\) & 90.4 & 4.57(32\(\times\)) & 6.03(64\(\times\)) \\ RBNN [26] & \(1/1\) & 92.2 & 11.0(32\(\times\)) & 5.47(64\(\times\)) & RBNN [26] & \(1/1\) & 91.3 & 4.57(32\(\times\)) & 6.03(64\(\times\)) \\ ReActNet [32] & \(1/1\) & 92.3 & 11.0(32\(\times\)) & 5.47(64\(\times\)) & SLB [47] & \(1/1\) & 92.0 & 4.57(32\(\times\)) & 6.03(64\(\times\)) \\ \hline SLBF [24] & 0.55/1 & 89.3\(\pm\)0.5 & 60.5(58\(\times\)) & 2.94(119\(\times\)) & SLBF [24] & 0.53/1 & 89.4\(\pm\)0.4 & 2.42(60\(\times\)) & 3.17(122\(\times\)) \\ FleXOR [25] & 0.80/1 & 90.9\(\pm\)0.2 & 8.80(40\(\times\)) & 5.47(64\(\times\)) & FleXOR [25] & 0.80/1 & 90.6\(\pm\)0.1 & 3.66(40\(\times\)) & 6.03(64\(\times\)) \\ FleXOR [25] & 0.60/1 & 89.8\(\pm\)0.3 & 6.60(53\(\times\)) & 5.47(64\(\times\)) & FleXOR [25] & 0.60/1 & 89.2\(\pm\)0.2 & 2.74(53\(\times\)) & 6.03(64\(\times\)) \\ \hline Sparks (ours) & 0.78/1 & 92.2\(\pm\)0.1 & 8.57(41\(\times\)) & 3.96 (88\(\times\)) & Sparks (ours) & 0.78/1 & 91.7\(\pm\)0.2 & 3.55(41\(\times\)) & 3.46(112\(\times\)) \\ Sparks (ours) & 0.67/1 & 92.0\(\pm\)0.2 & 7.32(48\(\times\)) & 2.97(118\(\times\)) & Sparks (ours) & 0.67/1 & 91.6\(\pm\)0.1 & 3.05(48\(\times\)) & 1.94(199\(\times\)) \\ Sparks (ours) & 0.56/1 & 91.5\(\pm\)0.3 & 6.10(88\(\times\)) & 1.63(215\(\times\)) & Sparks (ours) & 0.56/1 & 91.3\(\pm\)0.3 & 2.54(88\(\times\)) & 1.13(342\(\times\)) \\ Sparks (ours) & 0.44/1 & 90.8\(\pm\)0.2 & 4.88(72\(\times\)) & 0.97(041\(\times\)) & Sparks (ours) & 0.44/1 & 90.8\(\pm\)0.3 & 2.03(72\(\times\)) & 0.74(522\(\times\)) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Comparisons of top-1 accuracies with state-of-the-art methods on the CIFAR10 dataset.
0.56-bit model on ResNet-18 by using three branches of convolutions and a single branch of activation, denoted as Sparks-wide; we also adopt 0.56-bit and 0.44-bit Sparks on ResNet-34 (almost twice in depth compared to ResNet-18), both denoted as Sparks-deep. We observe that all our variants surpass ReActNet-18 (currently the best ResNet-18-based BNN) with almost the same or even less cost in model complexity. Specifically, our 0.44-bit Sparks-deep defeats ReActNet-18 in accuracy with the least cost of complexity. To better visualize the trade-off between performance and efficiency, we contrast our models against existing methods with varying storage and BOPs in Figure 3. We leave the comparison with SNN [45] in Figure 4, since we re-implemented SNN under a fair two-stage pipeline, which improves the absolute accuracy of SNN by \(6.9\%\sim 8.1\%\).

### Ablation Studies

**Validity of Gumbel-Sinkhorn.** We test the advantage of applying the Gumbel-Sinkhorn technique to codewords selection. Three baselines to construct the sub-codebook are

\begin{table}
\begin{tabular}{l c c c c c} \hline \hline \multirow{2}{*}{Method} & Bit-width & \multicolumn{2}{c}{Accuracy (\%)} & Storage & BOPs \\  & (W/A) & Top-1 & Top-5 & (Mbit) & (\(\times 10^{9}\)) \\ \hline Full-precision & \(32/32\) & 69.6 & 89.2 & 351.5 & 107.2(1\(\times\)) \\ \hline BNN [16] & \(1/1\) & 42.2 & 69.2 & 11.0(32\(\times\)) & 1.70(63\(\times\)) \\ XNOR-Net [37] & \(1/1\) & 51.2 & 73.2 & 11.0(32\(\times\)) & 1.70(63\(\times\)) \\ Bi-RealNet [31] & \(1/1\) & 56.4 & 79.5 & 11.0(32\(\times\)) & 1.68(64\(\times\)) \\ IR-Net [36] & \(1/1\) & 58.1 & 80.0 & 11.0(32\(\times\)) & 1.68(64\(\times\)) \\ LNS [10] & \(1/1\) & 59.4 & 81.7 & 11.0(32\(\times\)) & 1.68(64\(\times\)) \\ RBNN [26] & \(1/1\) & 59.9 & 81.9 & 11.0(32\(\times\)) & 1.68(64\(\times\)) \\ Ensemble-BNN [52] & \((1/1)\)\(\times\)6 & 61.0 & - & 65.9(53\(\times\)) & 10.6(10\(\times\)) \\ ABC-Net [28] & \((1/1)\)\(\times\)5\({}^{2}\) & 65.0 & 85.9 & 274.5(1\(\times\)) & 42.5(2\(\times\)) \\ Real-to-Bin [33] & \(1/1\) & 65.4 & 86.2 & 11.0(32\(\times\)) & 1.68(64\(\times\)) \\ ReActNet [32] & \(1/1\) & 65.9 & 86.4 & 11.0(32\(\times\)) & 1.68(64\(\times\)) \\ \hline SLBF [24] & \(0.55/1\) & 57.7 & 80.2 & 6.05(58\(\times\)) & 0.92(117\(\times\)) \\ SLBF [24] & \(0.31/1\) & 52.5 & 76.1 & 3.41(103\(\times\)) & 0.98(110\(\times\)) \\ FlexOR [25] & \(0.80/1\) & 62.4 & 83.0 & 8.80(40\(\times\)) & 1.68(64\(\times\)) \\ FleXOR [25] & \(0.60/1\) & 59.8 & 81.9 & 6.60(53\(\times\)) & 1.68(64\(\times\)) \\ \hline Sparks (ours) & \(0.78/1\) & 65.5 & 86.2 & 8.57(41\(\times\)) & 1.22(88\(\times\)) \\ Sparks (ours) & \(0.67/1\) & 65.0 & 86.0 & 7.32(48\(\times\)) & 0.88(122\(\times\)) \\ Sparks (ours) & \(0.56/1\) & 64.3 & 85.6 & 6.10(88\(\times\)) & 0.50(214\(\times\)) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparisons of top-1 and top-5 accuracies with state-of-the-art methods on ImageNet based on ResNet-18. Calculation details for the storage and BOPs are provided in Appendix.

Figure 3: Trade-off between performance and complexity on ImageNet. For all methods, -18 indicates using ResNet-18 as the backbone, and -34 indicates ResNet-34. The symbol \(n\) is the sub-codebook size as defined in § 3.1; \(N_{in},N_{out},f_{1},f_{2}\) are hyper-parameters that control the complexity as defined in FleXOR [25] and SLBF [24].

\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline \multirow{2}{*}{Method} & \multirow{2}{*}{Backbone} & Bit-width & \multicolumn{2}{c}{Accuracy (\%)} & Storage & BOPs \\  & & (W/A) & Top-1 & Top-5 & (Mbit) & (\(\times 10^{9}\)) \\ \hline ReActNet [32] & ResNet-18 & \(1/1\) & 65.9 & 86.4 & 11.0 & 1.68 \\ \multirow{2}{*}{Sparks-wide} & ResNet-18 & \multirow{2}{*}{(\(0.56/1\))\(\times\)3} & **66.7** & **86.9** & 18.3 & **1.50** \\  & & & & & & \\ \multirow{2}{*}{Sparks-deep} & ResNet-34 & \(0.56/1\) & **67.6** & **87.5** & 11.7 & **0.96** \\  & ResNet-34 & \(0.44/1\) & **66.4** & **86.7** & **9.4** & **0.58** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Results when extending our Sparks to wider or deeper models.
considered: (1) Directly selecting the top-\(n\) frequent codewords from a learnt BNN (ReActNet-18). (2) Randomly selecting codewords. (3) Selecting codewords with an equal interval of indices, by setting \(s_{i}=\lfloor\frac{i}{n-1}\rfloor\times(N-1)+1\) in Equation 3. Figure 4 (Left) shows that these baselines are much inferior to ours, indicating the superiority of our permutation learning. We observe a severe performance cut-down at 0.56-bit of the third baseline, reflecting the unpredictable performance variation for naive selection methods.

**Comparison with product quantization.** Our proposed sub-codebook construction is related with but distinct from the product quantization [24, 42] in two aspects: (1) As already specified in Figure 1, we construct the codebook with kernel-wise codewords rather than channel-wise ones. (2) We learn to jointly select codewords from a fixed codebook instead of directly optimizing the codewords independently, which avoids the degeneration of the sub-codebook diversity. Figure 4 (Middle) illustrates the comparisons regarding these two aspects. We observe that using kernel-wise codewords largely outperforms using the channel-wise codewords, and the selection-based optimization consistently achieves better performance than the product quantization (such as SNN [45]) by a significant margin. In Figure 4 (Right), the diversity of codewords is severely degenerated when applying the product quantization, whereas our method preserves the diversity.

**Convergence**. Figure 5 displays the codewords selection process during training for 0.44-bit Sparks (ResNet-18) on ImageNet. The selection initially fluctuates but converges in the end. This explains the convergence of our algorithm, which complies with our derivations in Theorem 1.

**Practical inference on FPGA**. We utilize the hardware framework SystemC-TLM2 to model an FPGA. Our 0.56-bit Sparks achieves 1.167ms (ResNet-18) and 2.391ms (ResNet-34). The corresponding BNNs achieve 3.713ms and 7.806ms. Thus we have over three times acceleration.

Footnote 2: [https://www.accellera.org/community/systemc/about-systemc-tlm](https://www.accellera.org/community/systemc/about-systemc-tlm)

## 5 Conclusion

We propose a novel method named Sparse Kernel Selection (Sparks), which devises below 1-bit models by grouping kernels into a selected sub-codebook. The selection process is learnt end-to-end with Permutation Straight-Through Estimator (PSTE). Experiments show that our method is applicable for general tasks including image classification and object detection. One potential limitation of our research lies in that model compression requires the access of model parameters, leading to the risk of unprotected privacy.

## Acknowledgement

This work is funded by the Sino-German Collaborative Research Project Crossmodal Learning (NSFC 62061136001/DFG TRR169). W. Huang, F. Sun, and A. Yao are corresponding authors. Part of this work was done when the first author was an intern at Intel Labs China. Y. Wang and Y. Dong are supported by the Shuium Tsinghua Scholar Program.

Figure 4: Ablation studies on ImageNet with ResNet-18. All experiments adopt the same baseline for a fair comparison. **Left**: comparisons of different methods to select codewords. **Middle:** kernel-wise vs channel-wise codewords, and selection-based vs product-quantization(quant)-based learning. Note that “Product-quant, kernel-wise” refers to our implementation of SNN [45] under a fair two-stage training framework for improved performance. **Right:** sub-codebook degeneration when learning codewords with product-quantization.

Figure 5: Codewords selection during training where \(n=16\). We have visualized the final selected 16 codewords at the top of the figure, where light gray indicates \(-1\) and dark gray indicates \(+1\).
## Appendix A Proofs of Our Statements

**Property 1**: _We denote \(\mathbb{B}=\{-1,+1\}^{K\times K}\) as the dictionary of binary kernels. For each \(\mathbf{w}\in\mathbb{R}^{K\times K}\), the binary kernel \(\hat{\mathbf{w}}\) can be derived by a grouping process:_

\[\hat{\mathbf{w}}=\operatorname{sign}(\mathbf{w})=\operatorname*{arg\,min}_{\mathbf{u}\in \mathbb{B}}\|\mathbf{u}-\mathbf{w}\|_{2}.\]

Proof.We denote \(w(k_{1},k_{2})\) the entry of \(\mathbf{w}\) in the \(k_{1}\)-th row and \(k_{2}\)-th column, and similar denotation follows for \(\mathbf{u}\). We have,

\[\operatorname*{arg\,min}_{\mathbf{u}\in\mathbb{B}}\|\mathbf{u}-\mathbf{w}\|_ {2}^{2} =\operatorname*{arg\,min}_{\mathbf{u}\in\mathbb{B}}\sum_{k_{1},k_{2} }|u(k_{1},k_{2})-w(k_{1},k_{2})|^{2}\] \[=\{\operatorname*{arg\,min}_{u(k_{1},k_{2})\in\{-1,+1\}}|u(k_{1},k_{2})-w(k_{1},k_{2})|^{2}\}_{k_{1},k_{2}}\] \[=\{\operatorname{sign}(w(k_{1},k_{2}))\}_{k_{1},k_{2}}\] \[=\operatorname{sign}(\mathbf{w}),\]

which concludes the proof. \(\square\)

Before the proofs for the lemma and theorem, in Figure 6, we provide the relationship of notations that are adopted in the main paper to facilitate the understanding of our permutation learning process.

**Lemma 1**: _For sufficiently large \(k\) and small \(\tau\), we define the entropy of a doubly-stochastic matrix \(\mathbf{P}\) as \(h(\mathbf{P})=-\sum_{i,j}P_{i,j}\log P_{i,j}\), and denote the rate of convergence for the Sinkhorn operator as \(r\left(0<r<1\right)\)3. There exists a convergence series \(s_{\tau}\) (\(s_{\tau}\to 0\) when \(\tau\to 0^{+}\)) that satisfies_

Footnote 3: The Sinkhorn operator has a rate of convergence \(r\) bounded by a value lower than 1 as proved by [22].

\[\|\mathbf{P}_{\mathrm{real}}-\mathbf{P}_{\mathrm{GS}}\|_{2}^{2}=\mathcal{O}\big{(}s_{ \tau}^{2}+r^{2k}\big{)}. \tag{18}\]

Proof.Let \(\mathbf{X}_{\tau}=\mathbf{X}/\tau\) and \(\mathbf{X}_{0}=\lim_{\tau\to 0^{+}}\mathbf{X}_{\tau}\). In addition, follow the definitions in Equation 5, we denote \(\mathcal{S}^{k}(\cdot)\) the \(k\)-th iteration of the Sinkhorn output and \(\mathcal{S}(\cdot)=\lim_{k\to\infty}\mathcal{S}^{k}(\cdot)\).

As proved by [22], the Sinkhorn operator has a rate of convergence \(r\left(0<r<1\right)\) with respect to \(k\), where \(r\) always exists and is bounded by a value lower than 1. There is

\[\|\mathcal{S}^{k}(\mathbf{X}_{\tau})-\mathcal{S}(\mathbf{X}_{\tau})\|_{2}\leq r\| \mathcal{S}^{k-1}(\mathbf{X}_{\tau})-\mathcal{S}(\mathbf{X}_{\tau})\|_{2}\leq,\cdots, \leq r^{k-1}\|\mathcal{S}^{1}(\mathbf{X}_{\tau})-\mathcal{S}(\mathbf{X}_{\tau})\|_{2}.\]

By the definition of \(\mathcal{S}^{k}(\mathbf{X}_{\tau})\) in Equation 5, the values of \(\mathcal{S}^{k}(\mathbf{X}_{\tau})\) are located in \([0,1]\) for all \(k\geq 1\). In addition, \(\mathcal{S}(\mathbf{X}_{\tau})\) is a \(0/1\) matrix with exactly \(N\) ones, where \(N\) is the dimension. Therefore, \(\|\mathcal{S}^{1}(\mathbf{X}_{\tau})-\mathcal{S}(\mathbf{X}_{\tau})\|_{2}^{2}\) is well bounded and thus we obtain

\[\|\mathcal{S}^{k}(\mathbf{X}_{\tau})-\mathcal{S}(\mathbf{X}_{\tau})\|_{2}\leq C_{1}r^ {k},\]

Figure 6: Relationship of notations for a better understanding. The horizontal axis and vertical axis stand for the values of \(k\) and \(\tau\), respectively. The Gumbel noise \(\epsilon\) is omitted here. Only parameters in the green region are actually calculated during training, while the others are only for the understanding purpose. All these parameters are NOT needed during inference. Starting from a learnable matrix \(\mathbf{X}\), we adopt a temperature \(\tau\) and calculate \(\mathcal{S}^{0}(\mathbf{X}/\tau)\). We then perform the Sinkhorn operation for \(k\) iterations to further obtain \(\mathbf{P}_{\mathrm{GS}}=\mathcal{S}^{k}(\mathbf{X}/\tau)\). We apply the Hungarian algorithm to further obtain \(\mathbf{P}_{\mathrm{real}}\). For sufficiently large \(k\) and small \(\tau\), \(\mathbf{P}_{\mathrm{real}}\) equals the ideal permutation matrix.
where \(C_{1}>0\) is a constant.

As mentioned in Equation 4, \(\mathcal{S}(\mathbf{X}_{\tau})\) must be a doubly-stochastic matrix [41]. According to Lemma 3 in [34], if denoting \(f_{0}(\cdot)=\left\langle\cdot,\mathbf{X}\right\rangle_{F}\), there is \(|f_{0}(\mathcal{S}(\mathbf{X}_{0}))-f_{0}(\mathcal{S}(\mathbf{X}_{\tau}))|\leq\tau(h( \mathcal{S}(\mathbf{X}_{\tau}))-h(\mathcal{S}(\mathbf{X}_{0})))=\tau h(\mathcal{S}(\bm {X}_{\tau}))\leq\tau\max_{\mathbf{P}\in\mathcal{B}_{N}}(h(\mathbf{P}))\), where \(\mathcal{B}_{N}\) denotes the the set of doubly stochastic matrices of dimension \(N\).

As proved by Lemma 3 in [34], \(|f_{0}(\mathcal{S}(\mathbf{X}_{0}))-f_{0}(\mathcal{S}(\mathbf{X}_{\tau}))|\leq\tau\max _{\mathbf{P}\in\mathcal{B}_{N}}(h(\mathbf{P}))\) implies the convergence of \(\mathcal{S}(\mathbf{X}_{\tau})\) to \(\mathcal{S}(\mathbf{X}_{0})\) and there exists a convergence series \(s_{\tau}\) (\(s_{\tau}\to 0\) when \(\tau\to 0^{+}\)), satisfying \(\|\mathcal{S}(\mathbf{X}_{0})-\mathcal{S}(\mathbf{X}_{\tau})\|_{2}\leq C_{2}s_{\tau}\), where \(C_{2}>0\) is a constant.

Based on the triangle inequality, there is

\[\|\mathcal{S}(\mathbf{X}_{0})-\mathcal{S}^{k}(\mathbf{X}_{\tau})\|_{2}^{2}\leq(C_{2}s _{\tau}+C_{1}r^{k})^{2}\leq 2C_{2}^{2}s_{\tau}^{2}+2C_{1}^{2}r^{2k}.\]

As mentioned in SS 3.3, there is \(\mathbf{P}_{\rm GS}=\mathcal{S}^{k}(\mathbf{X}_{\tau})\) if we omit the noise term. Given the convergence property, for sufficiently large \(k\) and small \(\tau\), the Hungarian algorithm output \(\mathbf{P}_{\rm real}\) equals to the real permutation, _i.e._\(\mathbf{P}_{\rm real}=\mathcal{S}(\mathbf{X}_{0})\). In summary, we have

\[\|\mathbf{P}_{\rm real}-\mathbf{P}_{\rm GS}\|_{2}^{2}=\mathcal{O}\big{(}s_{\tau}^{2}+r ^{2k}\big{)},\]

which concludes the proof. 

With the help of Lemma 1 and the inspiration of error-feedback framework [20], we now provide the detailed proof for Theorem 1.

**Theorem 1**: _Assume that the training objective \(f\) w.r.t. \(\mathbf{P}_{\rm GS}\) is \(L\)-smooth, and the stochastic gradient of \(\mathbf{P}_{\rm real}\) is bounded by \(\mathbb{E}\|\mathbf{g}(\mathbf{P}_{\rm real})\|_{2}^{2}\leq\sigma^{2}\). Denote the rate of convergence for the Sinkhorn operator as \(r\left(0<r<1\right)\) and the stationary point as \(\mathbf{P}_{\rm GS}^{t}\). Let the learning rate of PSTE be \(\eta=\frac{c}{\sqrt{T}}\) with \(c=\sqrt{\frac{f\left(\mathbf{P}_{\rm GS}^{0}\right)-f\left(\mathbf{P}_{\rm GS}^{t} \right)}{L\sigma^{2}}}\). For a uniformly chosen \(\mathbf{u}\) from the iterates \(\{\mathbf{P}_{\rm real}^{0},\cdots,\mathbf{P}_{\rm real}^{T}\}\), concretely \(\mathbf{u}=\mathbf{P}_{\rm real}^{t}\) with the probability \(p_{t}=\frac{1}{T+1}\), it holds in expectation over the stochasticity and the selection of \(\mathbf{u}\) :_

\[\mathbb{E}\|\nabla f(\mathbf{u})\|_{2}^{2}=\mathcal{O}\left(\sigma\sqrt{\frac{f( \mathbf{P}_{\rm GS}^{0})-f(\mathbf{P}_{\rm GS}^{t})}{T/L}}+L^{2}\big{(}s_{\tau}^{2}+r^ {2k}\big{)}\right)\,. \tag{19}\]

**Proof.** Since the objective function \(f\) is \(L\)-smooth, \(\mathbf{g}(\mathbf{P}_{\rm GS})=\mathbf{g}(\mathbf{P}_{\rm real})\) in our PSTE, and \(\mathbf{P}_{\rm GS}^{t+1}=\mathbf{P}_{\rm GS}^{t}-\eta\mathbf{g}(\mathbf{P}_{\rm real}^{t})\), we can obtain the following derivations,

\[f(\mathbf{P}_{\rm GS}^{t+1}) \leq f(\mathbf{P}_{\rm GS}^{t})+\big{\langle}\mathbf{P}_{\rm GS}^{t+1}- \mathbf{P}_{\rm GS}^{t},\nabla f(\mathbf{P}_{\rm GS}^{t})\big{\rangle}+\frac{L}{2}\| \mathbf{P}_{\rm GS}^{t+1}-\mathbf{P}_{\rm GS}^{t}\|_{2}^{2}\] \[=f(\mathbf{P}_{\rm GS}^{t})-\eta\langle\mathbf{g}(\mathbf{P}_{\rm real}^{t }),\nabla f(\mathbf{P}_{\rm GS}^{t})\rangle+\frac{L\eta^{2}}{2}\|\mathbf{g}(\mathbf{P} _{\rm real}^{t})\|_{2}^{2}\,.\]

We use \(\mathbb{E}\) to represent the expectation with respect to the stochasticity. Based on the bound of the stochastic gradient, _i.e._\(\mathbb{E}\|\mathbf{g}(\mathbf{P}_{\rm real}^{t})\|_{2}^{2}\leq\sigma^{2}\), and a natural property \(\langle\mathbf{x},\mathbf{y}\rangle\leq\frac{1}{2}\|\mathbf{x}\|_{2}^{2}+ \frac{1}{2}\|\mathbf{y}\|_{2}^{2}\), it holds that,

\[\mathbb{E}\left[f(\mathbf{P}_{\rm GS}^{t+1}|\mathbf{P}_{\rm GS}^{t})\right] \leq f(\mathbf{P}_{\rm GS}^{t})-\eta\big{\langle}\mathbb{E}\big{[} \mathbf{g}(\mathbf{P}_{\rm real}^{t})\big{]},\nabla f(\mathbf{P}_{\rm GS}^{t})\big{\rangle} +\frac{L\eta^{2}}{2}\mathbb{E}\|\mathbf{g}(\mathbf{P}_{\rm real}^{t})\|_{2}^{2}\] \[\leq f(\mathbf{P}_{\rm GS}^{t})-\eta\big{\langle}\nabla f(\mathbf{P}_{\rm real }^{t}),\nabla f(\mathbf{P}_{\rm GS}^{t})\big{\rangle}+\frac{L\eta^{2}\sigma^{2}}{2}\] \[=f(\mathbf{P}_{\rm GS}^{t})-\eta\big{\langle}\nabla f(\mathbf{P}_{\rm real }^{t}),\nabla f(\mathbf{P}_{\rm real}^{t})\big{\rangle}+\frac{L\eta^{2}\sigma^{2}}{2}+ \eta\big{\langle}\nabla f(\mathbf{P}_{\rm real}^{t}),\nabla f(\mathbf{P}_{\rm real}^{t})- \nabla f(\mathbf{P}_{\rm GS}^{t})\big{\rangle}\] \[\leq f(\mathbf{P}_{\rm GS}^{t})-\eta\|\nabla f(\mathbf{P}_{\rm real}^{t})\|_ {2}^{2}+\frac{L\eta^{2}\sigma^{2}}{2}+\frac{\eta^{2}}{2}\|\nabla f(\mathbf{P}_{\rm real }^{t})\|_{2}^{2}+\frac{\eta}{2}\|\nabla f(\mathbf{P}_{\rm real}^{t})-\nabla f(\mathbf{P} _{\rm GS}^{t})\|_{2}^{2}\] \[\leq f(\mathbf{P}_{\rm GS}^{t})-\frac{\eta}{2}\|\nabla f(\mathbf{P}_{\rm real }^{t})\|_{2}^{2}+\frac{L\eta^{2}\sigma^{2}}{2}+\frac{\eta L^{2}}{2}\|\mathbf{P}_{ \rm real}^{t}-\mathbf{P}_{\rm GS}^{t}\|_{2}^{2}\,.\]

With Lemma 1,

\[\mathbb{E}\left[f(\mathbf{P}_{\rm GS}^{t+1}|\mathbf{P}_{\rm GS}^{t})\right]\leq f(\mathbf{P} _{\rm GS}^{t})-\frac{\eta}{2}\|\nabla f(\mathbf{P}_{\rm real}^{t})\|_{2}^{2}+ \frac{L\eta^{2}\sigma^{2}}{2}+\frac{\eta L^{2}}{2}\big{(}C_{1}s_{\tau}^{2}+C_{2 }r^{2k}\big{)}\,,\]

where \(C_{1}>0\) and \(C_{2}>0\) are constants.

By rearranging the orders and further applying the expectation on \(\mathbf{P}_{\rm GS}^{t}\),

\[\mathbb{E}\|\nabla f(\mathbf{P}_{\rm real}^{t})\|_{2}^{2}\leq\frac{2}{\eta}\big{(} \mathbb{E}\left[f(\mathbf{P}_{\rm GS}^{t})\right]-\mathbb{E}\left[f(\mathbf{P}_{\rm GS }^{t+1})\right]\big{)}+L\eta\sigma^{2}+L^{2}\big{(}C_{1}s_{\tau}^{2}+C_{2}r^{2k} \big{)}\,.\]
Summing over \(t=0,1,\cdots,T\),

\[\sum_{t=0}^{T}\mathbb{E}\|\nabla f(\mathbf{P}_{\rm real}^{t})\|_{2}^{2} \leq\frac{2}{\eta}\sum_{t=0}^{T}\big{(}\,\mathbb{E}\left[f(\mathbf{P}_ {\rm GS}^{t})\right]-\mathbb{E}\left[f(\mathbf{P}_{\rm GS}^{t+1})\right]\big{)}+L \eta\sigma^{2}+L^{2}\sum_{t=0}^{T}\left(C_{1}s_{\tau}^{2}+C_{2}r^{2k}\right)\] \[\leq\frac{2}{\eta}\big{(}f(\mathbf{P}_{\rm GS}^{0})-f(\mathbf{P}_{\rm GS}^ {*})\big{)}+(T+1)L\eta\sigma^{2}+L^{2}\sum_{t=0}^{T}\left(C_{1}s_{\tau}^{2}+C_{ 2}r^{2k}\right).\]

For a uniformly chosen \(\mathbf{u}\) from the iterates \(\{\mathbf{P}_{\rm real}^{0},\cdots,\mathbf{P}_{\rm real}^{T}\}\), concretely \(\mathbf{u}=\mathbf{P}_{\rm real}^{t}\) with the probability \(p_{t}=\frac{1}{T+1}\). Divide the inequation by \(T+1\), and extend \(\mathbb{E}\) to represent the expectation over the stochasticity and the selection of \(\mathbf{u}\), there is

\[\mathbb{E}\|\nabla f(\mathbf{u})\|_{2}^{2}\leq\frac{2}{\eta(T+1)} \big{(}f(\mathbf{P}_{\rm GS}^{0})-f(\mathbf{P}_{\rm GS}^{*})\big{)}+L\eta\sigma^{2}+L^ {2}\big{(}C_{1}s_{\tau}^{2}+C_{2}r^{2k}\big{)}\,.\]

Substituting the learning rate \(\eta\), we finally obtain

\[\mathbb{E}\|\nabla f(\mathbf{u})\|_{2}^{2} \leq\frac{2\sigma\sqrt{LT}}{T+1}\sqrt{f(\mathbf{P}_{\rm GS}^{0})-f( \mathbf{P}_{\rm GS}^{*})}+\frac{\sigma\sqrt{L}}{\sqrt{T}}\sqrt{f(\mathbf{P}_{\rm GS}^ {0})-f(\mathbf{P}_{\rm GS}^{*})}+L^{2}\big{(}C_{1}s_{\tau}^{2}+C_{2}r^{2k}\big{)}\,.\] \[\leq 3\sigma\sqrt{\frac{f(\mathbf{P}_{\rm GS}^{0})-f(\mathbf{P}_{\rm GS}^ {*})}{T/L}}+L^{2}\big{(}C_{1}s_{\tau}^{2}+C_{2}r^{2k}\big{)}\,,\]

Therefore,

\[\mathbb{E}\|\nabla f(\mathbf{u})\|_{2}^{2}=\mathcal{O}\left(\sigma \sqrt{\frac{f(\mathbf{P}_{\rm GS}^{0})-f(\mathbf{P}_{\rm GS}^{*})}{T/L}}+L^{2}\big{(} s_{\tau}^{2}+r^{2k}\big{)}\right)\,,\]

which concludes the proof. \(\Box\)

## Appendix B Experiment Details and Analysis

### Implementation Details

**Implementation of ImageNet training.** We follow the two-step scheme (as detailed in SS 4) and the training settings in [32]. Specifically, for each step, the model is trained for 640k training iterations with batch size 512. We adopt the Adam optimizer [21] and set the initial learning rate to \(10^{-3}\). Weight decay rates in the first and second steps are \(10^{-5}\) and \(0\), respectively. For experiments on ImageNet, models are trained with 8 V100 GPUs. We follow the training settings and data augmentation strategies in [32].

**Implementation of CIFAR10 training.** For experiments on CIFAR10, each experiment is performed on a single V100 GPU. We train the network with 256 epochs in each step. We set the batch size to 256 and use an Adam optimizer [21]. The learning rate is initialized to \(5\times 10^{-4}\) and is updated by a linear learning rate decay scheduler. Results of our method on CIFAR10 are averaged over three runs.

**Implementation of selection and ablation studies.** We further detail our implementation of the codeword selection process based on Figure 4 (Middle), where we provide four experiment settings including using kernel-wise/channel-wise codewords, and selection-based/product-quantization-based learning. Implementation details for these four experiments (labeled as (a)-(d), respectively) are described as follows.

Figure 7: A supplement to Figure 1 by ranking codewords _w.r.t._ the frequency. It shows that the ranked codewords in (b) nearly follow the power-law distribution.
* _Selection, kernel-wise (our proposed method):_ each codeword is a \(3\times 3\) convolutional kernel with values being \(\pm 1\). We constantly keep the \(1^{\text{st}}\) (all \(-1\)s) and \(512^{\text{th}}\) (all \(+1\)s) codewords in the sub-codebook, as these two codewords take a large proportion. We divide the remaining 510 codewords into two halves (\(1^{\text{st}}\) half: from index 2 to 256; \(2^{\text{nd}}\) half: from index 257 to 511). Obviously, each codeword in one half has a corresponding codeword with opposite signs in another half. This technique speeds up the selection process without noticeably affecting the performance.
* _Selection, channel-wise:_ each codeword is a \(1\times 9\) sub-vector with values being \(\pm 1\), and codewords are obtained from flattened convolutional weights. We follow the speed up strategy in (a) by dividing codewords into two parts. Unlike (a), we do not constantly send the \(1^{\text{st}}\) (all \(-1\)s) and \(512^{\text{th}}\) (all \(+1\)s) codewords to the sub-codebook, since this process does not bring improvements for the channel-wise setting.
* _Product quantization, kernel-wise:_ we follow the common method of product quantization [42, 24] to learn real-valued codewords. Before training, we randomly initialize \(2^{n}\) different \(3\times 3\) real-valued codewords, with their values being \(\pm 1.0\). During training, in the forward pass, we obtain the binary codewords by applying the \(\operatorname{sign}\) function on the real-valued codewords. In the backward pass, the Straight-Through Estimator technique is adopted which copies the gradients of binary codebooks to real-valued codebooks.
* _Product quantization, channel-wise:_ the learning process follows (c), yet each codeword is a \(1\times 9\) sub-vector across multiple channels, obtained from flattened convolutional weights.

**Storage and BOPs calculation.** In Table 4, we provide details of how storages and BOPs in Table 2 are calculated. The calculation follows the analysis described in SS 3.4.

### Additional Experiment Analysis

**Power-law property.** Figure 7 illustrates the distributions when ranking codewords in Figure 1 according to the codeword frequency. It shows that in Figure 7(b), codewords nearly obey the power-law distribution.

**Codewords selection and overlaps.** In Figure 8, we further compare the codewords learning processes for the four settings in Figure 4 (Middle). As a supplement to Figure 4 (Right), Figure 9 provides the change of sub-codebooks during training of the four experiment settings (a)-(d). As codewords in (c) and (d) tend to overlap during training, the diversity is severely affected. In addition, we also conduct experiments that at each step or every several steps, we replenish the sub-codebook with random different codewords so that the sub-codebook size recovers to \(2^{n}\), but the performance is very close to directly selecting codewords at random (as already shown in Figure 4 (Left), randomly selection achieves low performance).

**Acceleration of training.** We consider two approaches that can accelerate the training process on large datasets (_e.g._ ImageNet), without causing much detriment to the performance. (1) We conduct permutation learning only in the first \(30\times 10^{3}\) training steps, and fix the selected codewords for the later training. (2) We obtain the sub-codebook by pretraining on a small dataset like CIFAR10, and directly adopt the sub-codebook for ImageNet without further permutation learning. Compared with the results of our Sparks reported in Table 4. Calculation details for the storage and BOPs as reported in Table 2. Networks are evaluated on ImageNet with ResNet-18.

\begin{table}
\begin{tabular}{c c c c c c c c c c c c c c c c c c c} \hline \hline \multirow{2}{*}{layer-name} & \multirow{2}{*}{input-w} & \multirow{2}{*}{input-h} & \multirow{2}{*}{input-c} & \multirow{2}{*}{output-w} & \multirow{2}{*}{output-h} & \multirow{2}{*}{output-c} & \multirow{2}{*}{kernel-h} & \multicolumn{4}{c}{Storage (bit)} & \multicolumn{4}{c}{BOPs} \\  & & & & & & & & & & & & & & & & & & \\  & & & & & & & & & & & & & & & & & & \\ \hline A & B & C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q \\ \hline conv1 & 224 & 224 & 3 & 112 & 112 & 64 & 7 & 7 & - & - & - & - & - & - & - & - & - \\ conv2-1a & 56 & 56 & 64 & 56 & 56 & 64 & 3 & 3 & 36864 & 28672 & 24576 & 20480 & 11505054 & 15605504 & 115065504 & 64225248 \\ conv2-1b & 56 & 56 & 56 & 64 & 56 & 56 & 64 & 3 & 3 & 36864 & 28672 & 24576 & 24080 & 1151505054 & 115605054 & 115605054 & 64225248 \\ conv2-2b & 56 & 56 & 56 & 64 & 56 & 56 & 64 & 3 & 3 & 36864 & 28672 & 24576 & 24576 & 24080 & 1151505054 & 115605054 & 115605054 & 64225248 \\ conv2-2b & 56 & 56 & 56 & 64 & 56 & 56 & 64 & 3 & 3 & 3 & 36864 & 28672 & 24576 & 24576 & 24080 & 11515054 & 15605054 & 115605054 & 64225248 \\ conv3-1a & 56 & 56 & 56 & 64 & 28 & 28 & 128 & 3 & 3 & 3 & 373728 & 57344 & 49152 & 40960 & 57802752 & 57802752 & 3112576 & 17661888 \\ conv3-1b & 28 & 28 & 128 & 28 & 28 & 28 & 128 & 3 & 3 & 147456 & 114688 & 98304 & 98120 & 115605054 & 115605054 & 64225216 & 3532840 \\ conv3-2a & 28 & 28 & 28 & 128 & 28 & 28 & 28 & 3 & 3 & 147456 & 114688 & 98304 & 9120 & 115605054 & 115605054 & 64222516 & 3532840 \\ conv3-2b & 28 & 28 & 28 & 128 & 28 & 28 & 28 & 3 & 3 & 147456 & 114688 & 98304 & 9120 & 115605054 & 115605054 & 64225216 & 3532840 \\ conv4-1a & 28 & 28 & 128 & 128 & 28 & 28 & 28 & 3 & 3 & 147456 & 114688 & 98304 & 81920 & 115605054 & 115605054 & 64225216 & 3532840 \\ conv4-1a & 28 & 28 & 128 & 128 & 14 & 14 & 256 & 3 & 3 & 294912 & 2229376 & 196608 & 1638040 & 5702732 & 3112512162 & 17661340 & 10346340 \\ conv4-1b & 14 & 14 & 256 & 14 & 14 & 256 & 3 & 3 & 589824 & 458752 & 3932126 & 2768015054 & 64225152 & 35327767 & 2087088 \\ conv4-2a & 14 & 14 & 256 & 14 & 14 & 256 & 3 & 3 & 589824 & 458752 & 3932126 & 23768015 & 151605054 & 64225152 & 3532776 & 20873088 \\ conv5-1b & 14 & 14 & 256 & 7 & 7 & 512 & 3 & 3 & 1179648 & 971504 & 7864235 & 655607 & 75082752 & 176696 & 10463452 & 6552860 \\ conv5-1b & 7 & 7 & 512 & 7 & 7 & 512 & 3 & 3 & 2352926 & 1835008 & 1572864 & 1310720 & 115050504 & 5332648 & 20872960 & 13647616 \\ conv5-2b & 7 & 7 & 512 & 7 & 7 & 512 & 3 & 3 & 2359266 & 1835008 & 1572864 & 1310720 & 115050504 & 5332648 & 20872960 & 13647616 \\ fc100 & 1 & 512 & 1 & 1 & 1000 & - & - & - & - & - & - & & & & & & & & & & & \\ \hline \multicolumn{12}{c}{} & \multirow{2}{*}{**Total**} & & \multicolumn{4}{c}{10988472} & \multirow{2}{*}{8544256} & \multirow{2}{*}{73326348} & \multirow{2}{*}{6
Figure 8: Comparison of codewords learning processes when using kernel-wise/channel-wise codewords and selection-based/product-quantization-based learning. The corresponding experimental results are already provided in Figure 4 (Middle). All experiments are based on 0.44-bit settings with \(n=16\), and are performed on ImageNet upon ResNet-18. We observe that, when both using selection-based learning, kernel-wise codewords in (a) converge much faster (within \(25\times 10^{3}\) steps) than channel-wise codewords in (b); codewords with product-quantization-based learning in (c) and (d) also converge slower than (a), and are likely to overlap during training which degenerates the codebook diversity.

Figure 9: Numbers of different codewords when using selection-based/product-quantization-based learning, as a supplement to Figure 4 (Right). (a)-(d) correspond to the experiments in Figure 4 (Right) and Figure 8. Experiments are performed on ImageNet upon ResNet-18. We provide four settings, including 0.78-bit, 0.67-bit, 0.56-bit and 0.44-bit, with \(n=\) 128, 64, 32 and 16, respectively. We observe that the sub-codebook highly degenerates during training in (c) and (d), since codewords tend to be repetitive when being updated independently. While in (a) and (b), the diversity of codewords preserves, which implies the superiority of our selection-based learning.
Table 2, the performance does not decrease when using the acceleration approach (1), and decreases slightly (\(-0.4\)%, \(-0.6\)%, and \(-1.1\)% for 0.78-bit, 0.67-bit, and 0.56-bit, respectively) when using the approach (2).

**Sensitivity analysis of hyper-parameters.** In Figure 10, we compare the accuracy with different hyper-parameter settings for \(k\) and \(\tau\) in Equation 8. In the PSTE optimization, \(k\) is the iteration number and \(\tau\) is the temperature. Experiments are performed with ResNet-18 and VGG-small on CIFAR10. We observe that both hyper-parameters are insensitive around their default settings \(k=10\) and \(\tau=10^{-2}\). The parameter \(k\) is quite easy to choose since results are stable when \(k=5\sim 20\). In addition, regarding two extreme cases, setting \(\tau\) too small (_e.g._\(10^{-4}\)) will hinder the smoothness of gradient back-propagation, and assigning a too large value (_e.g._\(1\)) will enlarge the permutation approximation error, both of which may cause detriment to the final performance. Luckily, according to Figure 10, the performance is stable when changing \(\tau\) by \(10\) or \(1/10\) times around the default value, implying the high stability of our method.

**About top-n most frequent codewords:** In Figure 4, we compare sampling top-n most frequent codewords and our method. We display an example of \(0.44\)-bit top-n codewords here: \(\textbf{\hat{\emph{\emph{\emph{\emph{\emph{\emph{\emph{\emph{\emph{\emph{\emph{ \emph{\emph{\emph{ \emph{ }}}}}}{}}{}}{}}{}}}}}\) **It shows the top-n codewords tend to choose adjacent codewords more frequently, which could hinder the diversity of the codebook. By contrast, as shown in Figure 5, our learned \(0.44\)-bit method outputs diverse codewords, yielding better performance particularly at \(0.56\)-bit from 61.7 to 64.3.

**A two-step recipe with product quantization.** Given the purpose of attaining a compact BNN, we also conduct an intuitive two-step baseline method: at first, load parameters of a standard BNN (ReActNet-18, from the open-sourced model) as the pre-trained model; then perform product quantization on the binary weights to compress the BNN. By this method, we achieve 59.1% accuracy on ImageNet under 0.56-bit, and the sub-codebook degeneration still exists. Such result is much inferior to our Sparks under 0.56-bit (64.3%).

**Symbol table.** We list the definition and usage important symbols in Table 5.

**Whether indexing process hinders valid acceleration:** No, the indexing process of binary kernels does not hinder valid acceleration. (1) Indexing \(n\) codewords is very cheap, _e.g._, only \(32\) codewords for our \(0.56\)-bit model (\(<0.5\) nanosecond on our FPGA). (2) Indexing \(3\times 3\) pre-calculated results (\(3\times 3\) codeword \(\sqrt[6]{3}\times 3\) feature region, see SS 3.4) is also negligible based on our implementation with a

Figure 10: Sensitivity analysis for hyper-parameters including the iteration number \(k\) and the temperature \(\tau\), as adopted in Equation 8 and also clearly illustrated in Figure 6. Experiments are conducted on the CIFAR10 dataset with 0.56-bit ResNet-18 and VGG-small, respectively. Results are averaged over three runs with different random seeds. Both hyper-parameters are insensitive around the default values \(k=10\) and \(\tau=10^{-2}\).

\begin{table}
\begin{tabular}{l l} \hline \hline Symbol & Definition and Usage \\ \hline \(\boldsymbol{w}\in\mathbb{R}^{K\times K}\) & Convolutional kernel with the kernel size \(K\). \\ \(\hat{\boldsymbol{w}}\in\{-1,+1\}^{K\times K}\) & Selected binary kernel for \(\boldsymbol{w}\). There is \(\hat{\boldsymbol{w}}\in\) sub-codebook \(\mathbb{U}\subseteq\) codebook \(\mathbb{B}=\{-1,+1\}^{K\times K}\). \\ \(N\in\mathbb{Z}^{+}\) & \(N=|\mathbb{B}|\), the codebook size, \(N=512\) when \(K=3\). \\ \(n\in\mathbb{Z}^{+}\) & \(n=|\mathbb{U}|\), the sub-codebook size, _e.g._, for \(0.56\)-bit Sparks, \(n=32\). \\ \(\boldsymbol{B}\in\{\pm 1\}^{K^{2}\times N}\) & Column by column indexing from \(|\mathbb{B}|\). \\ \(\boldsymbol{U}\in\{\pm 1\}^{K^{2}\times n}\) & Column by column indexing from \(|\mathbb{U}|\). \\ \(\boldsymbol{V}\in\{0,1\}^{N\times n}\) & A pre-defined selection matrix. \\ \(k\in\mathbb{Z}^{+}\) & The number of iteration to approximate the permutation matrix in Equation 8. \\ \(\tau\in\mathbb{R}^{+}\) & A small temperature to approximate the permutation matrix in Equation 8. \\ \(\boldsymbol{X}\in\mathbb{R}^{N\times N}\) & A randomly initialized, learnable matrix. \\ \(\boldsymbol{P}_{\mathrm{GS}}\in\mathbb{R}^{N\times N}\) & \(\boldsymbol{P}_{\mathrm{GS}}=\boldsymbol{S}^{k}((\boldsymbol{X}+\epsilon)/\tau)\), the approximated permutation matrix for propagation, not a \(0/1\) matrix. \\ \(\boldsymbol{P}_{\mathrm{real}}\in\{0,1\}^{N\times N}\) & \(\boldsymbol{P}_{\mathrm{real}}=\mathrm{Hungarian}(\boldsymbol{P}_{\mathrm{GS}})\), the outputted permutation matrix, a doubly stochastic \(0/1\) matrix. \\ \hline \hline \end{tabular}
\end{table}
Table 5: The definition and usage of important symbols.
Lookup Table (LUT) that stores \(3\times 3\) pre-calculated results: The practical LUT size, instead of \(n\times C_{\text{in}}\times H\times W\) by dividing input feature maps into \(1\times 3\times 3\) slices, and sending only one slice to a Processing Engine (PE) at each clock cycle. This leads to very low latency for the lookup process, _e.g_., LUT size is \(32\) for our \(0.56\)-bit model (\(<0.5\) nanosecond for indexing), which is easily implemented in the current clock cycle.

## Appendix C Object Detection

### Implementation

We evaluate our method for object detection on two benchmark datasets: PASCAL VOC [8] and COCO [27]. We follow the standard data split settings [46]. Regarding the PASCAL VOC dataset, we train our model on both the VOC 2007 and VOC 2012 trainval sets, which together contain about 16k natural images of 20 different categories in total. We evaluate the performance on VOC 2007 test set that is composed of about 5k images. COCO dataset (2014 object detection track) is a large-scale dataset that collects images from 80 different categories. We train our model with 80k training images as well as 35k images sampled from the validation set (denoted as trainval35k [2]), and carry out evaluations on the remaining 5k images in the validation set (minival [2]).

We follow BiDet [46] for the basic training settings including parameters and data augmentation methods. Specifically, we train 50 epochs in total with batch size 32 and the Adam optimizer. We initialize the learning rate to \(10^{-3}\) which decays by multiplying 0.1 at the 6\({}^{\text{th}}\) and 10\({}^{\text{th}}\) epoch. We consider two typical architectures including SSD300 [29] (with VGG-16 [40]) and Faster R-CNN [38] (with ResNet-18 [12]) to verify the effectiveness and generalization of our method.

\begin{table}
\begin{tabular}{l c c c c|l c c c c} \hline \hline Method & Bit-width & mAP & Storage & BOPs & Method & Bit-width & mAP & Storage & BOPs \\
**(SSD300)** & (W/A) & (\%) & Saving & Saving & **(Faster R-CNN)** & (W/A) & (\%) & Saving & Saving \\ \hline Full-precision & \(32/32\) & 72.4 & \(1\times\) & \(1\times\) & Full-precision & \(32/32\) & 74.5 & \(1\times\) & \(1\times\) \\ \hline BNN [16] & \(1/1\) & 42.0 & \(32\times\) & 64\(\times\) & BNN [16] & \(1/1\) & 35.6 & \(32\times\) & 64\(\times\) \\ XNOR-Net [37] & \(1/1\) & 50.2 & \(32\times\) & 64\(\times\) & XNOR-Net [37] & \(1/1\) & 48.4 & \(32\times\) & 64\(\times\) \\ Bi-RealNet [31] & \(1/1\) & 63.8 & \(32\times\) & 64\(\times\) & Bi-RealNet [31] & \(1/1\) & 58.2 & \(32\times\) & 64\(\times\) \\ BiDet [46] & \(1/1\) & 66.0 & \(32\times\) & 64\(\times\) & BiDet [46] & \(1/1\) & 59.5 & \(32\times\) & 64\(\times\) \\ \hline Sparks (ours) & \(0.78/1\) & 65.2 & \(41.0\times\) & 108\(\times\) & Sparks (ours) & \(0.78/1\) & 58.9 & \(41.0\times\) & 88\(\times\) \\ Sparks (ours) & \(0.56/1\) & 64.3 & \(57.1\times\) & 285\(\times\) & Sparks (ours) & \(0.56/1\) & 57.7 & \(57.1\times\) & 214\(\times\) \\ \hline Sparks* (ours) & \(0.78/1\) & 68.9 & \(41.0\times\) & 108\(\times\) & Sparks* (ours) & \(0.78/1\) & 66.2 & \(41.0\times\) & 88\(\times\) \\ Sparks* (ours) & \(0.56/1\) & 68.0 & \(57.1\times\) & 285\(\times\) & Sparks* (ours) & \(0.56/1\) & 65.5 & \(57.1\times\) & 214\(\times\) \\ \hline \hline \end{tabular}
\end{table}
Table 6: Performance comparisons with object detection methods on the PASCAL VOC dataset. Sparks\({}^{*}\) indicates using the two-step training method and the generalized Sign/PReLU functions (as adopted in [32] for image classification).

\begin{table}
\begin{tabular}{l c c c c c c c c c c c} \hline \hline Method & Bit-width & mAP & AP\({}_{50}\) & AP\({}_{75}\) & AP\({}_{s}\) & AP\({}_{m}\) & AP\({}_{l}\) & Method & Bit-width & mAP & AP\({}_{50}\) & AP\({}_{75}\) & AP\({}_{s}\) & AP\({}_{m}\) & AP\({}_{l}\) \\
**(SSD300)** & (W/A) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) \\ \hline Full-precision & \(32/32\) & 23.2 & 41.2 & 23.4 & 8.6 & 23.2 & 39.6 & Full-precision & \(32/32\) & 26.0 & 44.8 & 27.2 & 10.0 & 28.9 & 39.7 \\ \hline BNN [16] & \(1/1\) & 6.2 & 15.9 & 3.8 & 2.4 & 10.0 & 9.9 & BNN [16] & \(1/1\) & 5.6 & 14.3 & 2.6 & 2.0 & 8.5 & 9.3 \\ XNOR-Net [37] & \(1/1\) & 8.1 & 19.5 & 5.6 & 2.6 & 8.3 & 13.3 & XNOR-Net [37] & \(1/1\) & 10.4 & 21.6 & 8.8 & 2.7 & 11.8 & 15.9 \\ Bi-RealNet [31] & \(1/1\) & 11.2 & 26.0 & 8.3 & 3.1 & 12.0 & 18.3 & Bi-RealNet [31] & \(1/1\) & 14.4 & 29.0 & 13.4 & 3.7 & 15.4 & 24.1 \\ BiDet [46] & \(1/1\) & 13.2 & 28.3 & 10.5 & 5.1 & 14.3 & 20.5 & BiDet [46] & \(1/1\) & 15.7 & 31.0 & 14.4 & 4.9 & 16.7 & 25.4 \\ \hline Sparks (ours) & \(0.78/1\) & 13.4 & 28.6 & 10.6 & 5.3 & 14.5 & 20.8 & Sparks (ours) & \(0.78/1\) & 15.6 & 30.7 & 14.0 & 4.7 & 16.5 & 25.1 \\ Sparks (ours) & \(0.56/1\) & 12.5 & 27.7 & 10.0 & 4.9 & 14.1 & 19.6 & Sparks (ours) & \(0.56/1\) & 14.9 & 29.9 & 13.6 & 4.1 & 15.7 & 24.5 \\ \hline Sparks\({}^{*}\) (ours) & \(0.78/1\) & 18.6 & 35.7 & 17.4 & 7.1 & 19.3 & 31.0 & Sparks\({}^{*}\) (ours) & \(0.78/1\) & 21.2 & 37.5 & 18.2 & 7.8 & 22.6 & 31.7 \\ Sparks\({}^{*}\) (ours) & \(0.56/1\) & 17.6 & 33.9 & 17.0 & 6.6 & 18.1 & 29.4 & Sparks\({}^{*}\) (ours) & \(0.56/1\) & 20.0 & 36.8 & 17.4 & 7.0 & 20.2 & 30.5 \\ \hline \hline \end{tabular}
\end{table}
Table 7: Performance comparisons with object detection methods on the COCO dataset. Sparks\({}^{*}\) indicates using the two-step training method and the generalized Sign/PReLU functions (as adopted in [32] for image classification).
### Results

**Evaluation on PASCAL VOC.** We contrast Sparks against SOTA detection binarization methods including the standard BNN [16], Bi-RealNet [31], XNOR-Net [37] and BiDet [46] in Table 6. We implement two different versions of Sparks including 0.56-bit and 0.78-bit. Compared with BiDet, our 0.56-bit method obtains about model compression by twice (0.56 vs 1) and computation acceleration by more than 3 times (_e.g._ 285 vs 64 on VGG16+SSD300). Besides, by adopting the two-step training scheme and the generalized Sign/PReLU functions, our methods achieve new records on 1-bit object detection.

**Evaluation on COCO.** To further assess the proposed method on a larger and more challenging dataset, we conduct experiments on COCO. Comparisons with SOTA methods are provided in Table 7. Following the standard COCO evaluation metrics, we report the average mAP over different IoU thresholds from 0.5 to 0.95, the APs at particular thresholds: AP\({}_{50}\) and AP\({}_{75}\), and the scale-aware metrics: AP\({}_{s}\), AP\({}_{m}\) and AP\({}_{l}\). The benefits of Sparks are still observed, namely, clearly saving in complexity. Results with SSD300 indicate that our 0.78-bit Sparks even defeats BiDet in terms of all evaluation metrics. We speculate that Sparks reduces information redundancy by selecting essential codewords, and thus eliminates some of the false positives. In addition, our method performs stably for both the one-stage SSD300 and the two-stage Faster R-CNN, implying its robustness on different backbones. In addition, results of Sparks\({}^{*}\) indicate that our method also has compatibility with the two-step training scheme and the generalized functions.

## Appendix D Discussion and Limitation

In this research, we propose Sparks that largely enhances both the storage and computation efficiencies of BNNs. Our work is motivated by that kernel-wise codewords are highly clustered. For this reason, we propose a novel selection-based approach for kernel-wise sub-codebook learning instead of previously used channel-wise product quantization. By extending our Sparks with more layers or other blocks, the performance could surpass the standard BNN model with still fewer parameters and BOPs. This provides us with a new research line of training lighter and better BNN models. As an open-sourced research on well-used benchmarks, our method does not raise ethical concerns. However, one should notice that compressing a model needs to access the model parameters which might need further protection methods for the model privacy.
