Restore Translation Using Equivariant Neural Networks
Invariance to spatial transformations such as translations and rotations is a
desirable property and a basic design principle for classification neural
networks. However, the commonly used convolutional neural networks (CNNs) are
actually very sensitive to even small translations. There exist vast works to
achieve exact or approximate transformation invariance by designing
transformation-invariant models or assessing the transformations. These works
usually make changes to the standard CNNs and harm the performance on standard
datasets. In this paper, rather than modifying the classifier, we propose a
pre-classifier restorer to recover translated (or even rotated) inputs to the
original ones which will be fed into any classifier for the same dataset. The
restorer is based on a theoretical result which gives a sufficient and
necessary condition for an affine operator to be translational equivariant on a
tensor space.
Yihan Wang, Lijia Yu, Xiao-Shan Gao
# Restore Translation Using Equivariant Neural Networks

###### Abstract

Invariance to spatial transformations such as translations and rotations is a desirable property and a basic design principle for classification neural networks. However, the commonly used convolutional neural networks (CNNs) are actually very sensitive to even small translations. There exist vast works to achieve exact or approximate transformation invariance by designing transformation-invariant models or assessing the transformations. These works usually make changes to the standard CNNs and harm the performance on standard datasets. In this paper, rather than modifying the classifier, we propose a pre-classifier restorer to recover translated (or even rotated) inputs to the original ones which will be fed into any classifier for the same dataset. The restorer is based on a theoretical result which gives a sufficient and necessary condition for an affine operator to be translational equivariant on a tensor space.

## 1 Introduction

Deep convolutional neural networks (CNNs) had outperformed humans in many computer vision tasks [9, 12]. One of the key ideas in designing the CNNs is that the convolution layer is equivariant with respect to translations, which was emphasized both in the earlier work [5] and the modern CNN [12]. However, the commonly used components, such as pooling [7] and dropout [19, 20], which help the network to extract features and generalize, actually make CNNs not equivariant to even small translations, as pointed out in [1, 3]. As a comprehensive evaluation, Figure 1 shows that two classification CNNs suffer the accuracy reductions of more than \(11\%\) and \(59\%\) respectively on CIFAR-10 and MNIST, when the inputs are horizontally and vertically translated at most 3 pixels.

Invariance to spatial transformations, including translations, rotations and scaling, is a desirable property for classification neural networks and the past few decades have witnessed thriving explorations on this topic. In general, there exist three ways to achieve exact or approximate invariance. The first is to design transformation-invariant neural network structures [2, 6, 8, 10, 15, 16, 18, 21]. The second is to assess and approximate transformations via a learnable module [4, 11] and then use the approximation to reduce the transformed inputs to "standard" ones. The third is data augmentation [1, 3, 17] by adding various transformations of the samples in the original dataset.

Those ad-hoc architectures to achieve invariance often bring extra parameters but harm the network performance on standard datasets. Moreover, the various designs with different purposes are not compatible with each other. Data augmentation is not a scalable method since the invariance that benefits from a certain augmentation protocol does not generalize to other transformations [1]. Including learnable modules such as the Spatial Transformer, all the three approaches require training the classifier from scratch and fail to endow existing trained networks with some invariance. It was indicated in [1] that "the problem of insuring invariance to small image transformations in neural networks while preserving high accuracy remains unsolved."
In this paper, rather than designing any in-classifier component to make the classifier invariant to some transformation, we propose a pre-classifier restorer to restore translated or rotated inputs to the original ones. The invariance is achieved by feeding the restored inputs into any following classifier. Our restorer depends only on the dataset instead the classifier. Namely, the training processes of the restore and classifier are separate and a restore is universal to any classifier trained on the same dataset.

We split the whole restoration into two stages, transformation estimation and inverse transformation, see Figure 2. In the first stage, we expect that standard inputs lead to standard outputs and the outputs of translated inputs reflect the translations. Naturally, what we need is a strictly translation-equivariant neural network. In Section 3, we investigate at the theoretical aspect the sufficient and necessary condition to construct a strictly equivariant affine operator on a tensor space. The condition results in _the circular filters_, see Definition 3.5, as the fundamental module to a strictly translation-equivariant neural network. We give the canonical architecture of translation-equivariant networks, see Equation (2). In Section 4, details of the restorer are presented. We define a translation estimator, the core component of a restored, as a strictly translation-equivariant neural network that guarantees the first component of every output on a dataset to be the largest component, see Definition 4.1. For a translated input, due to the strict equivariance, the largest component of the output reflect the translation. Thus we can translate it inversely in the second stage and obtain the original image. Though the restorer is independent on the following classifier, it indeed depends on the dataset. Given a dataset satisfying some reasonable conditions, i.e. _an aperiodic finite dataset_, see Definition 4.2, we prove the existence of a translation estimator, i.e. a restored, with the canonical architecture for this dataset. Moreover, rotations can be viewed as translations by converting the Cartesian coordinates to polar coordinates and the rotation restorer arises in the similar way.

In Section 5, the experiments on MNIST, 3D-MNIST and CIFAR-10 show that our restorers not only visually restore the translated inputs but also largely eliminate the accuracy reduction phenomenon.

## 2 Related works

As generalization of convolutional neural networks, group-equivariant convolutional neural networks [2, 6] exploited symmetries to endow networks with invariance to some group actions, such as the combination of translations and rotations by certain angles. The warped convolutions [10] converted some other spatial transformations into translations and thus obtain equivariance to these spatial transformations. Scale-invariance [21, 8, 15]

Figure 1: The accuracy reduction after vertical and horizontal translations. The translation scope is [-3, 3] pixels. Left: LeNet-5 on MNIST; Right: VGG-16 on CIFAR-10.
was injected into networks by some ad-hoc components. Random transformations [16] of features maps were introduced in order to prevent the dependencies of network outputs on specific poses of inputs. Similarly, probabilistic max pooling [18] of the hidden units over the set of transformations improved the invariance of networks in unsupervised learning. Moreover, local covariant feature detecting methods [14, 22] were proposed to address the problem of extracting viewpoint invariant features from images.

Another approach to achieve invariance is "shiftable" down-sampling [13], in which any original pixel can be linearly interpolated from the pixels on the sampling grid. These "shiftable" down-sampling exists if and only if the sampling frequency is at least twice the highest frequency of the unsampled signal.

The Spatial Transformer [4, 11], as a learnable module, produces a predictive transformation for each input image and then spatially transforms the input to a canonical pose to simplify the inference in the subsequent layers. Our restorers give input-specific transformations as well and adjust the input to alleviate the poor invariance of the following classifiers. Although the Spatial Transformers and our restorer are both learnable modules, the training of the former depend not only on data but also on the subsequent layers, while the latter are independent of the subsequent classifiers.

## 3 Equivariant neural networks

Though objects in nature have continuous properties, once captured and converted to digital signals, there properties are represented by real tensors. In this section, we study the equivariance of operators on a tensor space.

### Equivariance in tensor space

Assume that a map \(\tilde{x}:\mathbb{R}^{d}\to\mathbb{D}\) stands for a property of some \(d\)-dimensional object where \(\mathbb{D}\subseteq\mathbb{R}\). Sampling \(\tilde{x}\) over a \((n_{1},n_{2},\cdots,n_{d})\)-grid results in a tensor \(x\) in a tensor space

\[\mathcal{H}\coloneqq\mathbb{D}^{n_{1}}\otimes\mathbb{D}^{n_{2}}\otimes\cdots \otimes\mathbb{D}^{n_{d}}. \tag{1}\]

We denote \([n]=[0,1,\ldots,n-1]\) for \(n\in\mathbb{Z}_{+}\) and assume \(k\operatorname{\text{mod}}n\in[n]\) for \(k\in\mathbb{Z}\). For an index \(I=(i_{1},i_{2},\cdots,i_{d})\in\prod_{i=1}^{d}[n_{i}]\) and \(x\in\mathcal{H}\), denote \(x[I]\) to be the element of \(x\) with subscript \((i_{1},i_{2},\cdots,i_{d})\). For convenience, we extend the index of \(\mathcal{H}\) to \(I=(i_{1},i_{2},\cdots,i_{d})\in\mathbb{Z}^{d}\) by defining

\[x[I]=x[i_{1}\operatorname{\text{mod}}n_{1},\cdots,i_{d}\operatorname{\text{ mod}}n_{d}].\]

**Definition 3.1** (Translation).: _A translation \(T^{M}:\mathcal{H}\to\mathcal{H}\) with \(M\in\mathbb{Z}^{d}\) is an invertible linear operator such that for all \(I\in\mathbb{Z}^{d}\) and \(x\in\mathcal{H}\),_

\[T^{M}(x)[I]=x[I-M].\]

_The inverse of \(T^{M}\) is clearly \(T^{-M}\)._

**Definition 3.2** (Equivariance).: _A map \(w:\mathcal{H}\to\mathcal{H}\) is called equivariant with respect to translations if for all \(x\in\mathcal{H}\) and \(M\in\mathbb{Z}^{d}\),_

\[T^{M}(w(x))=w(T^{M}(x)).\]

**Definition 3.3** (Vectorization).: _A tensor \(x\) can be vectorized to \(X\in\overrightarrow{\mathcal{H}}=\mathbb{D}^{N}\) with \(N=n_{1}n_{2}\cdots n_{d}\) such that_

\[X(\delta(I))\coloneqq x[I],\]

_where \(\delta(I)\coloneqq(i_{1}\operatorname{\text{mod}}n_{1})n_{2}n_{3}\cdots n_{d }+(i_{2}\operatorname{\text{mod}}n_{2})n_{3}n_{4}\cdots n_{d}+\cdots+(i_{d} \operatorname{\text{mod}}n_{d})\), and we denote \(X=\overrightarrow{x}\). Moreover, the translation \(T^{M}\) is vectorized as \(T^{M}(X)\coloneqq\overrightarrow{T^{M}(x)}\)._
### Equivariant operators

When \(\mathbb{D}=\mathbb{R}\), the tensor space \(\mathcal{H}\) is a Hilbert space by defining the inner product as \(x\cdot z\coloneqq\overrightarrow{x}\cdot\overrightarrow{z}\) which is the inner product in vector space \(\overrightarrow{\mathcal{H}}\). In the rest of this section, we assume \(\mathbb{D}=\mathbb{R}\).

According to the Reize's representation theorem, there is a bijection between continuous linear operator space and tensor space. That is, a continuous linear operator \(v:\mathcal{H}\to\mathbb{R}\) can be viewed as a tensor \(v\in\mathcal{H}\) satisfying \(v(x)=v\cdot x\). Now we can translate \(v\) by \(T^{M}\) and obtain \(T^{M}(v):\mathcal{H}\to\mathbb{R}\) such that \(T^{M}(v)(x)=T^{M}(v)\cdot x\).

We consider a continuous linear operator \(w:\mathcal{H}\to\mathcal{H}\). For \(I\in\mathbb{Z}^{d}\) and \(x\in\mathcal{H}\), denote \(w_{I}(x)=w(x)[I]\). Then \(w_{I}:\mathcal{H}\to\mathbb{R}\) is a continuous linear operator. An _affine operator_\(\alpha:\mathcal{H}\to\mathcal{H}\) differs from a continuous linear operator \(w\) by a _bias tensor_\(c\) such that \(\alpha(x)=w(x)+c\) for all \(x\in\mathcal{H}\).

**Theorem 3.4**.: _Let \(\alpha(x)=w(x)+c:\mathcal{H}\to\mathcal{H}\) be an affine operator. Then, \(\alpha\) is equivariant with respect to translations if and only if for all \(M\in\mathbb{Z}^{d}\),_

\[w_{M}=T^{M}(w_{\mathbf{0}})\text{ and }c\propto\mathbf{1},\]

_where \(\mathbf{0}\) is the zero vector in \(\mathbb{Z}^{d}\) and \(c\propto\mathbf{1}\) means that \(c\) is a constant tensor, that is, all of its entries are the same._

Proof of Theorem 3.4 is given in Appendix A. Recall that \(\overrightarrow{\mathcal{H}}=\mathbb{R}^{N}\) is the vectorization of \(\mathcal{H}\) and \(T^{M}\) also translates vectors in \(\overrightarrow{H}\). Each continuous linear operator on \(\mathcal{H}\) corresponds to a matrix in \(\mathbb{R}^{N\times N}\) and each bias operator corresponds to a vector in \(\mathbb{R}^{N}\). Now we consider the translation equivariance in vector space.

**Definition 3.5** (Circular filter).: _Let \(W=(W_{0},W_{1},\cdots,W_{N-1})^{T}\) be a matrix in \(\mathbb{R}^{N\times N}\). \(W\) is called a circular filter if \(W_{\delta(M)}=T^{M}(W_{0})\) for all \(M\in\mathbb{Z}^{d}\)._

As the vector version of Theorem 3.4, we have

**Corollary 3.6**.: _Let \(A:\mathbb{R}^{N}\to\mathbb{R}^{N}\) be an affine transformation such that_

\[A(X)=W\cdot X+C,\]

_in which \(W\in\mathbb{R}^{N\times N}\), \(C\in\mathbb{R}^{N}\). Then, \(A\) is equivariant with respect to translations in the sense that for all \(M\in\mathbb{Z}^{d}\)_

\[A(T^{M}(X))=T^{M}(A(X))\]

_if and only if \(W\) is a circular filter and \(C\propto\mathbf{1}\)._

This affine transformation is very similar to the commonly used convolutional layers [12, 5] in terms of shared parameters and the alike convolutional operation. But the strict equivariance calls for the same in-size and out-size, and circular convolutions, which are usually violated by CNNs.

### Equivariant neural networks

To compose a strictly translation-equivariant network, the spatial sizes of the input and output in each layer must be the same and thus down-samplings are not allowed. Though Corollary 3.6 provides the fundamental component of a strictly translation-equivariant network, different compositions of this component lead to various equivariant networks. Here we give the _canonical architecture_. We construct the strictly translation-equivariant network \(F\) with \(L\) layers as

\[F(X)=F_{L}\circ F_{L-1}\circ\cdots\circ F_{1}(X). \tag{2}\]
The \(l\)-the layer \(F_{l}\) has \(n_{l}\) channels and for an input \(X\in\mathbb{R}^{n_{l-1}\times N}\) we have

\[F_{l}(X)=\sigma(W[l]\cdot X+C[l])\in\mathbb{R}^{n_{l}\times N}, \tag{3}\]

where

\[W[l] =(W^{1}[l],\cdots,W^{n_{l}}[l])\in\mathbb{R}^{n_{l}\times n_{l-1} \times N\times N},\] \[C[l] =(C^{1}[l]\cdot\mathbf{1},\cdots,C^{n_{l}}[l]\cdot\mathbf{1}),\] \[W^{k}[l] =(W^{k,1}[l],\cdots,W^{k,n_{l-1}}[l])\in\mathbb{R}^{n_{l-1}\times N \times N},\] \[C^{k}[l] =(C^{k,1}[l],\cdots,C^{k,n_{l-1}}[l])\in\mathbb{R}^{n_{l-1}},\]

\(\sigma\) is the activation, \(W^{k,r}[l]\in\mathbb{R}^{N\times N}\) are circular filters, \(C^{k,r}[l]\in\mathbb{R}\) are constant biases for \(k=1,\cdots,n_{l}\) and \(r=1,\cdots,n_{l-1}\), the \(\cdot\) denotes the inner product and \(\mathbf{1}\) is the vector whose all components are 1.

## 4 Translation restorer

### Method

In Section 3.3, we propose a strictly equivariant neural network architecture (2) such that any translation on the input will be reflected on the output. Generally speaking, once the outputs of an equivariant network on a dataset have some spatial structure, this structure shifts consistently as the input shifts. Thus, the translation parameter of a shifted input can be solved from its output. Finally, we can restore the input via the inverse translation. Figure 2 shows how a restorer works.

The whole restoration process splits into two stages, translation estimation and inverse translation. We first define the translation estimator which outputs a consistent and special structure on a dataset.

**Definition 4.1**.: _Let \(\mathcal{D}\subset\mathbb{D}^{P\times N}\) be a dataset with \(P\) channels. Then a translation-equivariant network_

\[F:\mathbb{R}^{P\times N}\rightarrow\mathbb{R}^{N}\]

_is said to be a translation estimator for \(\mathcal{D}\) if_

\[F(X)[0]=\text{max}_{i=0}^{N-1}F(X)[i],\]

_where \(F(X)[i]\) is the \(i\)-th component of \(F(X)\)._

Figure 2: The pre-classifier translation restorer. For a shifted data \(T^{M}(x)\) as the input, the translation estimator obtains the translation \(M\) and restore the original data \(T^{-M}(T^{M}(x))=x\), which is feed into a pre-trained classifier.
Given such a translation estimator for dataset \(\mathcal{D}\) and a shifted input \(X^{\prime}=T^{M}(X)\) for some \(X\in\mathcal{D}\), we propagate \(X^{\prime}\) through \(F\) and get the output \(F(X^{\prime})\in\mathbb{R}^{N}\). Since the first component of \(F(X)\) is the largest, the location of the largest component of \(F(X^{\prime})\) is exactly the translation parameter:

\[\delta(M)=\text{argmax}_{i=0}^{N-1}F_{i}(X^{\prime}).\]

Then we can restore \(X=T^{-M}(X^{\prime})\) by inverse translation. The restored inputs can be feed to any classifier trained on the dataset \(\mathcal{D}\).

### Existence of the restorer

In this section, we show the existence of restorers, that is, the translation estimator. Note that our restorer is independent of the following classifier but dependent on the dataset. For translation, if a dataset contains both an image and a translated version of it, the estimator must be confused. We introduce aperiodic datasets to clarify such cases.

**Definition 4.2** (Aperiodic dataset).: _Let \(\mathcal{D}\subset\mathbb{D}^{P\times N}\) be a finite dataset with \(P\) channels. We call \(\mathcal{D}\) an aperiodic dataset if \(\mathbf{0}\notin\mathcal{D}\) and_

\[T^{M}(X)=X^{\prime}\iff M=\mathbf{0}\text{ and }X=X^{\prime},\]

_for \(M\in\mathbb{Z}^{d+1}\) and \(X,X^{\prime}\in\mathcal{D}\). Here \(d\) is the spatial dimension and \(M\) decides the translation in the channel dimension in addition._

Let \(\mathcal{D}\) be an aperiodic dataset. Given that \(\mathbb{D}=[2^{Q+1}]\) which is the case in image classification, we prove the existence of the translation estimator for such an aperiodic dataset. The proof consists of two steps. The data are first mapped to their binary decompositions through a translation-equivariant network as Equation (2) and then the existence of the translation-restorer in the form of Equation (2) is proved for binary data.

Let \(\mathbb{D}=[2^{Q+1}]\) and \(\mathbb{B}=\{0,1\}\). We denote \(\eta:\mathbb{D}\rightarrow\mathbb{B}^{Q}\) to be the binary decomposition, such as \(\eta(2)=(0,1,0)\) and \(\eta(3)=(1,0,1)\). We perform the binary decomposition on \(X\in\mathbb{D}^{P\times N}\) element-wisely and obtain \(\eta(X)\in\mathbb{B}^{G\times N}\), where \(G=PQ\) is the number of channels in binary representation. A dataset \(\mathcal{D}\subseteq\mathbb{D}^{P\times N}\) can be decomposed into \(\mathcal{B}\subset\mathbb{B}^{G\times N}\). Note that the dataset \(\mathcal{D}\) is aperiodic if and only if its binary decomposition \(\mathcal{B}\) is aperiodic.

The following Lemma 4.3 demonstrates the existence of a translation-equivariant network which coincides with the binary decomposition \(\eta\) on \([2^{Q+1}]^{P\times N}\). Proof details are placed in Appendix B.

**Lemma 4.3**.: _Let \(\eta:[2^{Q+1}]\rightarrow\mathbb{B}\) be the binary decomposition. There exists a \((2Q+2)\)-layer network \(F\) in the form of Equation (2) with ReLU activations and width at most \((Q+1)N\) such that for \(X\in[2^{Q+1}]^{P\times N}\)_

\[F(X)=\eta(X).\]

The following Lemma 4.4 demonstrate the existence of a 2-layer translation restorer for an aperiodic binary dataset. Proof details are placed in Appendix C.

**Lemma 4.4**.: _Let \(\mathcal{B}=\{Z_{s}|s=1,2,\cdots,S\}\subset\mathbb{B}^{G\times N}\) be an aperiodic binary dataset. Then there exists a 2-layer network \(F\) in the form of Equation (2) with ReLU activations and width at most \(SN\) such that for all \(s=1,2,\cdots,S\),_

\[F(Z_{s})[0]=\text{max}_{i=0}^{N-1}F(Z_{s})[i].\]
Given a \((2Q+2)\)-layer network \(F^{\prime}\) obtained from Lemma 4.3 and a 2-layer network \(F^{\prime\prime}\) obtained from Lemma 4.4, we stack them and have \(F=F^{\prime\prime}\circ F^{\prime}\) which is exactly a translation restorer. We thus have proved the following theorem.

**Theorem 4.5**.: _Let \(\mathcal{D}=\{X_{s}|s=1,2,\cdots,S\}\subset[2^{Q+1}]^{P\times N}\) be an aperiodic dataset. Then there exists a network \(F:\mathbb{R}^{P\times N}\rightarrow\mathbb{R}^{N}\) in the form of Equation (2) with ReLU activations such that for \(s=1,2,\cdots,S\),_

\[F(X_{s})[0]=\text{max}_{i=0}^{N-1}F(X_{s})[i],\]

_of which the depth is at most \(2Q+4\) and the width is at most \(\max(SN,(Q+1)N)\). Namely, this network is a translation restorer for \(\mathcal{D}\)._

## 5 Experiments

The core component of the restorer is the translation estimator which outputs the translation parameter of the shifted inputs.

We use the architecture described in Equation (2) with \(L=6\), \(n_{l}=1\) for \(l=1,\cdots,L\) and ReLU activations. The training procedure aims at maximizing the first component of the outputs. Thus the max component of the output indicates the input shift. The experimental settings are given in Appendix D. We report four sets of experiments below.

Figure 3: The restoreers for MNIST and CIFAR-10.
### Translation restoration

We first focus on the performance of translation restoration. Experiments are conducted on MNIST, CIFAR-10, and 3D-MNIST.

2D Images.We train translation restorers for MNIST and CIFAR-10. MNIST images are resized to 32x32 and CIFAR-10 images are padded 4 blank pixels at the edges.

In Figure 3, the left column is the original images, the middle column is the randomly shifted images and the right column is the restored images. On both datasets, images are randomly shifted vertically and horizontally at most \(\frac{1}{4}\) of its size. The shift is a circular shift where pixels shifted out of the figure appear on the other end. We can see that the shifted images are disorganized but the restored images are very alike the original images.

To evaluate the restoration performance of pretrained restorers, we train classifiers and test them on randomly shifted images and restored ones and the results are given in Table 1. When images are not shifted, the restorers lead to only \(0.3\%\) and \(0.03\%\) accuracy reduction on two datasets. Nevertheless, even if the translation scope is 1, restorers improve the accuracy. Moreover, no matter how the images are shifted, the restorer can repair them to the same status and result in the same classification accuracy, namely \(98.58\%\) and \(88.18\%\), while the accuracies drop significantly without the restorer, and the larger the range of translation, the more obvious the restoration effect

Different ArchitecturesOur proposed restorer is an independent module that can be placed before any classifier. It is scalable to different architectures the subsequent classifier uses.

In Table 2, we evaluate the restoration performance on popular architectures including VGG-16, ResNet-18, DenseNet-121, and MobileNet v2. Translated images (w/Trans.) are randomly shifted within scope 4 in both vertical and horizontal directions. The reduction of accuracy on original images is no more than \(0.04\%\) and the restorer improves the accuracy on shifted images by \(1.66\%\sim 6.02\%\).

\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline  & Res.\textbackslash\)Trans. & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline \multirow{3}{*}{MNIST} & w/o & 98.89 & 98.21 & 95.41 & 87.07 & 76.61 & 62.9 & 51.33 & 41.1 & 35.7 \\  & w/ & 98.59 & 98.59 & 98.59 & 98.59 & 98.59 & 98.59 & 98.59 & 98.59 & 98.59 \\  & Effect & -0.3 & +0.38 & +3.18 & +11.52 & +21.98 & +35.69 & +47.26 & +57.49 & +62.89 \\ \hline \multirow{3}{*}{CIFAR-10} & w/o & 88.21 & 86.58 & 85.9 & 83.65 & 82.16 & 80.46 & 79.37 & 77.71 & 76.01 \\  & w/ & 88.18 & 88.18 & 88.18 & 88.18 & 88.18 & 88.18 & 88.18 & 88.18 & 88.18 \\ \cline{1-1}  & Effect & -0.03 & +1.6 & +2.28 & +4.53 & +6.02 & +7.72 & +8.81 & +10.47 & +12.17 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Restoration performance on MNIST and CIFAR-10. Images are randomly shifted within the translation scope ranging from 0 to 8 in both vertical and horizontal directions. We use LeNet-5 on MNIST and ResNet-18 on CIFAR-10. ”Res.” and ”Trans.” stand for restorer and translation respectively.

\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline  & \multicolumn{2}{c}{VGG-16} & \multicolumn{2}{c}{ResNet-18} & \multicolumn{2}{c}{DenseNet-121} & \multicolumn{2}{c}{MobileNet v2} \\ Res.\textbackslash\)Trans. & w/o & w/ & w/o & w/ & w/o & w/ & w/o & w/ \\ \hline w/o & 89.27 & 83.40 & 88.21 & 82.16 & 92.14 & 90.46 & 88.10 & 83.36 \\ w/ & 89.23 & 89.23 & 88.18 & 88.18 & 92.12 & 92.12 & 88.09 & 88.09 \\ Effect & -0.04 & +5.83 & -0.03 & +6.02 & -0.02 & +1.66 & -0.01 & +4.73 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Restoration performance on different architectures and CIFAR-10.
Translation Augmentation.Training with translation augmentation is another approach to improving the translational invariance of a model. However, translation augmentation is limited in a certain scope and thus cannot ensure the effectiveness for test images shifted out of the scope.

In Figure 4, we compare the restoration performance on models not trained with translation augmentation (dash lines) and models trained with translation augmentation (solid lines). The augmentation scope is \(10\%\) of the image size, that is, 3 pixels for MNIST and 4 pixels for CIFAR-10. Translation augmentation indeed improves the translational invariance of the classifier on images shifted in the augmentation scope. However, when the shift is beyond the augmentation scope, the accuracy begins to degrade. In such a case, the pre-classifier restorer is still able to calibrate the shift and improve the accuracy of the classifier trained with augmentation.

3D Voxelization Images.3D-MNIST contains 3D point clouds generated from images of MNIST. The voxelization of the point clouds contains grayscale 3D tensors.

Figure 5 visualizes the restoration on 3D-MNIST. In the middle of each subfigure, the 3-dimensional digit is shifted in a fixed direction. This fixed direction is detected by the translation estimator and the restored digit is shown on the right.

Figure 4: Restoration performance on classifiers trained with or without translation augmentations. The models are LeNet-5 for MNIST and VGG-16 for CIFAR-10. ”res.” and ”aug” stand for restorer and augmentation, respectively.

Figure 5: The restored on 3D-MNIST. In each sub-figure, the left is the original digit, the middle is shifted digit, and the right is the restored digit.
### Rotation restoration

Rotation can be regarded as a kind of translation. The Euclidean space \(\mathbb{R}^{d+1}\) can be characterized by polar coordinates

\[(\phi_{1},\cdots,\phi_{d-1},\phi_{d},r)\in[0,\pi]\times\cdots\times[0,\pi] \times[0,2\pi)\times\mathbb{R}^{+}.\]

We can sample a property map, defined in Section 3.1, \(\tilde{x}:\mathbb{R}^{d+1}\rightarrow\mathbb{R}\) over a \((n_{1},n_{2},\cdots,n_{d+1})\)-grid along the polar axes and obtain a tensor \(x\) such that for given \(R>0\) and \(0<a<1\)

\[x(I)=\tilde{x}(\frac{\pi i_{1}}{n_{1}-1},\cdots,\frac{\pi i_{d-1}}{n_{d-1}-1}, \frac{2\pi i_{d}}{n_{d}},Ra^{i_{d+1}}),\]

where \(I=(i_{1},i_{2},\cdots,i_{d+1})\in\prod_{i=1}^{d+1}[n_{i}]\). The last index \(Ra^{i_{d+1}}\) can be replaced with \(\frac{i_{d+1}R}{n_{d+1}}\). Note that the vectorization \(X\) is in \(\mathbb{D}^{n_{d+1}\times N}\) with \(N=n_{1}n_{2}\cdots n_{d}.\) Since we only care about the rotation, i.e. the translation \(T^{M}\) on the first \(d\) components of \(I\), the space \(\mathbb{D}^{n_{d+1}\times N}\) is viewed as an \(n_{d+1}\)-channel vector space. Thus, we can treat rotation as translation and leverage the method discussed above to restore rotated inputs.

Visualization.We experiment with the rotation restoration on MNIST. Since the transfer from Cartesian coordinates to polar coordinates requires high resolution, we first resize the images to \(224\times 224\) pixels. Other settings are similar to the aforementioned experiments.

Figure 6 visualizes the rotation restoration. We can tell from it that most rotated images are restored correctly, though some of them are not restored to the original images. The rotated digit 9 in the top row is more like an erect digit 6 than the original one and the restorer just leaves it alone. The reason why rotation restoration is not as perfect as translation restoration is that the dataset is not aperiodic with respect to rotations. On the one hand, some digits seem like the rotated version of other digits, such as 6 and 9. On the other hand, even in a certain digit class, images vary in digit poses. For example, a rotated digit 0 is similar to an erect one.

Note that the group-equivariant CNNs in [2, 6] can only deal with rotations by certain angles such as \(90^{\circ}\), \(180^{\circ}\), and \(270^{\circ}\). On the other hand, our approach can deal with rotations from more angles.

Figure 6: The rotation restoration on the first 24 images in the test set of MNIST. The left column of each subfigure is the original images and the right is the restored images. In the middle column of each subfigure, the images are rotated \(40^{\circ},90^{\circ}\) and \(150^{\circ}\) respectively.
Conclusion

This paper contributes to the equivalent neural networks in two aspects. Theoretically, we give the sufficient and necessary conditions for an affine operator \(Wx+b\) to be translational equivariant, that is, \(Wx+b\) is translational equivariant on a tensor space if and only if \(W\) has the high dimensional convolution structure and \(b\) is a constant tensor. It is well known that if \(W\) has the convolution structure, then \(Wx\) is equivariant to translations [5, 9], and this is one of the basic principles behind the design of CNNs. Our work gives new insights into the convolutional structure used in CNNs in that, the convolution structure is also the necessary condition and hence the most general structure for translational equivariance. Practically, we propose the translational restorer to recover the original images from the translated or rotated ones. The restorer can be combined with any classifier to alleviate the performance reduction problem for translated or rotated images. As a limitation, training a restorer on a large dataset such as the ImageNet is still computationally difficult.
