\section{Revisiting Gating Mechanisms from A Frequency View} \label{sec:analysis} % \begin{wrapfigure}{r}{0.4\textwidth} % \centering % \includegraphics[width=1.0\linewidth]{imgs/variants1.png} % %\includegraphics[width=0.8\linewidth]{egfigure.eps} % \vspace{-3mm} % \caption{Block design of different variants of ResNet18 where $\odot$ represents the element-wise product and $\sigma$ means the activation function. % In this paper, we investigate GLUs using ReLU6 and GELU as activation functions where corresponding variants can be named as Res18-Gate-ReLU6/GELU. % %Base on the activation function used in Res18-Gate, % %the variant can be named as Res18-Gate-ReLU or Res18-Gate-GELU. % } % \label{fig-variants} % \end{wrapfigure} %To better understand how gating mechanisms work, this paper investigates the behavior of a convolutional neural net168 work (CNN) in classification tasks from a frequency perspective. % \paragraph{Frequency Decomposition.} % To examine spectral characteristics, we first transform the input image $x$ into the frequency domain. Let % \begin{equation} % z = \mathcal{F}(x), % \end{equation} % where $\mathcal{F}(\cdot)$ denotes the two-dimensional discrete Fourier transform (DFT). % We partition the spectrum into two complementary components based on a predefined cutoff radius $r$. Specifically, the frequency representation $z$ is decomposed into a low-frequency part $z_l$ and a high-frequency part $z_h$, satisfying % \begin{equation} % z = z_l + z_h, \quad (z_l, z_h) = \Theta(z; r), % \end{equation} % where $\Theta(\cdot; r)$ represents a radial masking operator that separates spectral coefficients according to their distance from the origin in the frequency plane. % In this formulation, coefficients located within radius $r$ are assigned to $z_l$, while those outside the radius are assigned to $z_h$. This decomposition enables us to analyze model behaviors under controlled spectral partitions. We begin by defining the components associated with different frequency bands and outlining the details of our experimental setup. With decomposing the raw data $\mathbf{z}$ into the high-frequency part $\mathbf{z}_h$ and the low-frequency part $\mathbf{z}_l$ where $ \mathbf{z} = \mathbf{z}_h + \mathbf{z}_l$. We partition the spectrum into two complementary components based on a predefined cutoff radius $r$. Specifically, the frequency representation $z$ is decomposed into a low-frequency part $z_l$ and a high-frequency part $z_h$, satisfying \begin{equation} \label{decompose} z = z_l + z_h, \quad (z_l, z_h) = \Theta(z; r), \end{equation} where $\Theta(\cdot; r)$ represents a radial masking operator that separates spectral coefficients according to their distance from the origin in the frequency plane. In this formulation, coefficients located within radius $r$ are assigned to $z_l$, while those outside the radius are assigned to $z_h$. This decomposition enables us to analyze model behaviors under controlled spectral partitions. % Denoting a threshold $r$ and an image $\mathbf{x}$, we have the following equations: % \begin{equation} % \label{decompose} % \mathbf{z}=\mathcal{F}(\mathbf{x}), \quad \mathbf{z}_{h}, \mathbf{z}_{l} =\theta(\mathbf{z} ; r). % \end{equation} % Here, $\mathbf{z}=\mathcal{F}(\mathbf{x})$ represents the two-dimensional discrete Fourier transform of the input $\mathbf{x}$. % % The operator $\theta(\cdot; r)$ applies a radial cutoff that partitions $\mathbf{z}$ into low- and high-frequency components, controlled by the radius parameter $r$. % where $\mathbf{z}=\mathcal{F}\left(\mathbf{x}\right)$ is the 2D Discrete Fourier Transform of $\mathbf{x}$ and $\theta(ยท; r)$ denotes a thresholding function that separates % the low and high frequency components from $z$ according % to a hyperparameter, radius $r$. We select three vision backbones including ResNet-18 \cite{he2016deep}, MobileNetv2 \cite{sandler2018mobilenetv2} and EfficientFormer-v2 \cite{li2023rethinking} as representations to demonstrate the drawbacks of the CNN networks and transformer-based architectures on capturing the high frequency information and how the gating mechanism improve the capability of learning high-frequency components. Modifications to the network blocks of ResNet-18 are depicted in Fig. \ref{fig-variants}. %All networks are trained on the CIFAR-10 dataset using CrossEntropyLoss, with the SGD optimizer set to a learning rate of $0.1$, implemented in PyTorch \cite{paszke2019pytorch}. %All experiments in this section utilize ResNet18 \cite{he2016deep} as the backbone, implemented in PyTorch \cite{paszke2019pytorch}. Modifications to the network blocks are depicted in Fig. \ref{fig-variants}. %To deliver a better comparison on high-frequency, the decompositions are also used in the training. We evaluate the classification performance on different frequency components of the input images at each training epoch. %Since directly classifying the high-frequency components is hard, the model is also trained with different frequency components. Changes in accuracy over time provide insights into the learning dynamics within the frequency domain \cite{wang2020high}. To avoid the occasionality, we calculated the average over three training runs. %We begin by defining the components associated with different frequency bands and outlining the details of our experimental setup. %The classification accuracy on the original data across different models remains comparable. We think analyzing training dynamics becomes more reliable when networks exhibit similar overall performance. %All related experiments in this section employ the ResNet18 as the backbone based on PyTorch[]. Different modification on the block can be found in Fig.XX. We train the network on CIFAR-10 with a CrossEntropyLoss and use the Adam as the optimizer with a learning rate of 1e-4. %We test of classifying different frequency components of input images which is defined in Eq. \ref{decompose} for each epoch. The change accuracy can indicate the learning dynamic in the frequency domain []. %Notably, the accuracy of classifying on raw data across different models are close. The study of the training dynamic is more reliable under networks with the similar overall performance. %XXX the overall performance of different models are close. It is important to study \begin{figure*} \centering \includegraphics[width=1.0\textwidth]{imgs/res18_r_10.png} %\caption{Comparison among Res18, Res18-Ewp. Res18-Gate-ReLU and Res18-Gate-GELU.} \vspace{-2mm} \caption{Comparison among Res18, Res18-Ewp, Res18-Gate-ReLU6 and Res18-Gate-GELU. The $r$ represents the threshold of determining the boundary between low-frequency and high-frequency. We plot the learning curves of Resnet18 and its variants for $100$ epochs, together plotted with the accuracy of different frequency components $\mathbf{z}_i$. We set $r$ to $10$. All curves of $\mathbf{z}$ are from the test set. The legends can be found in the top of the figure. We also provide more results with different $r$ and different settings in the appendix. } \label{bpgg_resnet} \end{figure*} \subsection{Effect of Element-wise Product} Inspired by the \textit{convolution theorem}, we first give an insight into why element-wise product can encourage NNs to learn on various frequency components from a frequency view. The convolution theorem states that for two functions $u(x)$ and $v(x)$ with Fourier transforms $U$ and $V$, \begin{equation} (u \cdot v)(x) = \mathcal{F}^{-1}(U \ast V), \end{equation} where $\cdot$ and $\ast$ denote element-wise multiplication and convolution respectively, and $\mathcal{F}$ is the Fourier transform operator defined as $\mathcal{F}[f(t)] = F(\omega) = \int_{-\infty}^{+\infty} f(t)e^{-j\omega t}\,dt$. This indicates that element-wise multiplication in the spatial domain corresponds to convolution in the frequency domain. To see its implication more clearly, consider the simplest situation: the self-convolution of a function. If the support set of $\mathcal{F}(\omega)$ is $[-\Omega, \Omega]$, then the support set of $\mathcal{F}\ast \mathcal{F}(\omega)$ will expand to $[-2\Omega, 2\Omega]$. In other words, self-convolution broadens the frequency spectrum. With this enriched frequency content, neural networks have more opportunities to capture and learn from both high-frequency and low-frequency components. % Inspired by the \textit{convolution theorem}, we first give a theoretical insight of why element-wise product can encourage NNs to learn on various frequency components from a frequency view. % %we reveal how the element-wise multiplication works from a frequency view. % \begin{theorem}[\textit{Convolution Theorem}] % \label{conv} % Consider two functions $u(x)$ and $v(x)$ with their Fourier transforms $U$ and $V$: % $${(u\cdot v)}(x) = \mathcal{F}^{-1}(U\ast V),$$ % \end{theorem} % where $\cdot$ and $\ast$ means the element-wise product and convolution respectively. $\mathcal{F}$ refers to the Fourier transform operator where $\mathcal{F}[f(t)] = F(\omega) =\int_{-\infty}^{+\infty}f(t)e^{-j\omega t}dt$. % The convolution theorem indicates that the element-wise multiplication in the spatial domain equals to the convolution operation in the frequency domain. Let's consider the simplest situation which is the self-convolution of a function. Denoting the support set of $\mathcal{F}(\omega)$ is $[-\Omega, \Omega]$, the support set of $\mathcal{F}\ast \mathcal{F}(\omega)$ will be $[-2\Omega, 2\Omega]$. % It means that self-convolution resulting in a broader frequency spectrum. With richer frequency information, NNs have more chances to % learn both high-frequency and low-frequency components. %To verify this insight, we conduct experiments on the Res18 and Res18-Ewp to find the effect of element-wise product. %As shown in Fig. \ref{bp}, the accuracy curve of Res18-Ewp %visibly surpass that of Res18 for decomposed parts in ranges of $(0, r_1)$ and early epochs in ranges of $(r_1, r_2)$. %The results demonstrate that broader spectral ranges enable the network to learn faster and better across multiple frequency components. Empirically, it is usually the lower-frequency components. %For example, for $\mathbf{z}_i \in (0, r_1)$) and $\mathbf{z}_i \in (r_1, r_2)$ before epoch $60$, the accuracy curve of Res18-Ewp is visibly above that of Res18. %From the performance on very high-frequency components (for $\mathbf{z}_i \in (r_3, +\infty)$), it is evident that neural networks face challenges in directly classifying these components, which are nearly imperceptible to the human eye. %The accuracy for very high-frequency components, such as those for $\mathbf{z_i} \in (r_e, +\infty)$, remains consistent and is similar to that of random selection, indicating that these high-frequency components are challenging for the network to learn effectively. %However, examining the accuracy curve for components within the range $(r_2, r_3)$ reveals a significant drop in accuracy growth after $40$ epochs compared to the base model. %From the performance on higher-frequency components, we can observe that it is challenging for NNs to classify those components directly which is almost imperceptible to human. %It proves that the boarder spectral ranges encourage the network learn faster on multi frequency components, especially of some lower frequencies. The accuracy of very high-frequency e.g. for $\mathbf{z_i} \in (r_e, +\infty)$ shows consistent performance which is same the random selection. That indicates thar very high-frequency components are not be learned easily. %However, looking at the curve of components in the range of $(r_2, r_3)$, we can find the growth of accuracy is apparently dropped significantly after the $40$ epochs compared to that of base model. For the accuracy under $20\%$, we regard it as the random selection which means NNs almost cannot learn anything form that frequency range. %It indicates that although element-wise product can encourage the model learn faster on some frequency components, newly introduced high-frequencies can become the noise to disturb the effective learning on high-frequencies. %Therefore, the activation layer is necessary to regulate the newly generated frequencies, minimizing the impact of high-frequency noise. \subsection{How Activation Function Works?} \label{act_analysis} % We begin with a brief mathematical analysis illustrating how the differential properties of activation functions influence the frequency characteristics of GLUs. The \textit{differential properties of the Fourier transform} state that if a function $f(t)$ is continuous in $(-\infty, +\infty)$, then We begin by analyzing how an activation function's smoothness influences the frequency characteristics of the features it produces. There is a well-established principle in Fourier analysis that connects a function's smoothness to the decay rate of its Fourier transform's magnitude. For a function $f(t)$ that is sufficiently smooth (i.e., its $n$-th derivative $f^{(n)}(t)$ exists and is continuous), the magnitude of its Fourier transform, $|F(\omega)|$, is bounded and decays at a rate proportional to $1/|\omega|^n$ for large $\omega$. This is a direct consequence of the differentiation property of the Fourier transform: % \begin{equation} % \mathcal{F}[f^{\prime}(t)] = j\omega F(\omega), % \end{equation} % where the notation is consistent with convolution theorem. More generally, if the $n$-th derivative $f^{(n)}(t)$ exists and is continuous, we have \begin{equation} \label{n-dif} \mathcal{F}[f^{(n)}(t)] = (j\omega)^n F(\omega), \end{equation} This property implies that the smoother a function is (i.e., the more continuous derivatives it has), the more rapidly its high-frequency components decay. Conversely, functions with discontinuities or sharp "corners" where derivatives are undefined (such as the kink in ReLU-like activations) are known to possess significant high-frequency energy. These sharp features require a broad spectrum of high-frequency sinusoids to be accurately represented. This leads to a Fourier transform that decays much more slowly. For example, a function with a simple discontinuity will have a spectrum that decays only at a rate of $1/|\omega|$. Therefore, we hypothesize that non-smooth activation functions will encourage the network to retain and utilize more high-frequency information compared to their smooth counterparts like GELU and Swish, which is infinitely differentiable. % which can be easily proved by mathematical induction. From Eq.~\ref{n-dif}, we can deduce that $|F(\omega)| \leq \frac{C}{|\omega|^n}$, where $C$ is a sufficiently large constant. This implies that if higher-order derivatives exist and are continuous, the high-frequency components of the Fourier transform decay more rapidly at a rate of $|\omega|^n$. Conversely, if higher-order derivatives do not exist or are discontinuous, the decay of the high-frequency components slows down. % Notably, for smooth activations such as $\operatorname{GELU}(x)=x \cdot \frac{1}{2}[1+\operatorname{erf}(x / \sqrt{2})]$, the function is infinitely differentiable across the entire real domain, with all orders of derivatives continuous and finite. This continuity and boundedness of higher-order derivatives cause the high-frequency components of the Fourier transform to decay quickly, leading to fewer retained high-frequency components. To validate this hypothesis, we conduct an experiment to compare the frequency learning of a representative smooth activation (GELU) against a non-smooth one (ReLU6) within a ResNet18 architecture. As shown in Fig. \ref{bpgg_resnet}, the model using the non-smooth ReLU6 activation consistently outperforms the GELU variant in learning from high-frequency components across different thresholds. This result supports our hypothesis, illustrating a clear practical difference between these two activation types. The superior performance of ReLU6 on high-frequency data suggests that the slow spectral decay associated with non-smooth functions can be beneficial for tasks requiring fine-grained detail. Conversely, the GELU variant shows a stronger relative performance on low-frequency components, indicating its suitability for capturing broad, structural patterns. While a more exhaustive study is needed, this experiment provides clear evidence for the link between activation smoothness and a model's spectral learning preferences. %To validate the above theoretical insights, we conduct experiments on ResNet18 and its variants to examine the impact of gating mechanisms and activation smoothness on frequency learning. As shown in Fig.~\ref{freq_comparison}, the testing curves of the model employing non-smooth activation functions (ReLU6) visibly surpass those of other models under different thresholds, demonstrating superior performance in learning from high-frequency components. This supports the hypothesis that reduced smoothness in the activation function enhances the model's ability to retain high-frequency information. Conversely, the variant using GELU exhibits stronger performance on low-frequency components, reflecting the advantage of smooth activations in modeling low-frequency signals. %As shown in Fig.X, we apply the full gating structure in the ResNet18. % In this paper, we mainly focus on three activation functions ReLU6, GELU and ReLU6 which are mostly used in the current lightweight models % based on their properties. % \begin{itemize} % \item Smooth activation: Smooth function means the differential coefficient is continues like GELU and Swish. This type of functions usually tends to produce lower frequency components. % \item Non-smooth activation: Functions like ReLU and ReLU6 have discontinuous derivatives, which can introduce more high-frequency components in gating mechanisms. % \end{itemize} % Specially, we select GELU and ReLU as representations to reveal how two kinds of activation functions control the new generated frequencies differently. % %\subsubsection{Theoretical Demonstrations} % We begin with a brief mathematical analysis illustrating how the differential properties of activation functions influence the frequency characteristics of GLUs. % \begin{theorem}[\textit{Differential Properties of the Fourier Transform}] % \label{dpft} % If a function $f(t)$ is continues in $(-\infty, +\infty)$, then % $$\mathcal{F}[f^{\prime}(t)] = j\omega {F}[\omega] $$ % \end{theorem} % % \begin{equation} % % \mathcal{F}\left[f^{\prime}(t)\right]=\int_{-\infty}^{+\infty} f^{\prime}(t) e^{-j \omega t} dt % % =\left.f(t) e^{-j \omega t}\right|_{-\infty} ^{+\infty}+j \omega \int_{-\infty}^{+\infty} f(t) e^{-j \omega t} d t % % =j \omega \mathcal{F}[f(t)] % % \end{equation} % The definitions of the symbols are same to Theorem \ref{conv}. % \begin{lemma} % If $f^{(n)}(t)$ is continues in $(-\infty, +\infty)$, then % \begin{equation} % \label{n-dif} % \mathcal{F}[f^{(n)}(t)] = (j\omega)^n {F}[\omega], % \end{equation} % \end{lemma} % \noindent where $f^{(n)}(t)$ represents the $n$-th derivative of $f(t)$. % The proof of Lemma \ref{n-dif} can be easily obtained by the mathematical induction based on Theorem \ref{dpft}. % From Eq. \ref{n-dif}, we can find that $|F(\omega)|\leq \frac{C}{|\omega|^n}$ where $C $ is a sufficiently large constant. % It indicates that if higher-order derivatives exist and are continuous, the high-frequency components of the Fourier transform decay more quickly with a rate of $|\omega|^n$. % Conversely, if higher-order derivatives do not exist or are discontinuous, the decay of the high-frequency components of the Fourier transform slows down. % Notably, for the smooth activation like $\operatorname{GELU}(x)=x \cdot \frac{1}{2}[1+\operatorname{erf}(x / \sqrt{2})]$, it is infinitely differentiable across the entire real domain, with all orders of derivatives being continuous and finite. % The continuity and finite values of higher-order derivatives cause the high-frequency components of the Fourier transform to decay quickly, resulting in fewer high-frequency components. % %On the other hand, discontinuity of higher-order derivatives can lead to generating more high-frequencies. Non-smooth activation may encourage remaining more higher frequency components in the gating mechanism. % %As shown in Fig. \ref{gp}, compared to the model without activation, the complete gating unit (using ReLU) learns better in higher frequency components compared to Res18-Ewp, like in $\mathbf{z}_i \in (r_2, r_3)$. It effectively avoids the disturbance of high-frequency noise. % %Moreover, we have conducted contrast experiments of using different kinds of activation functions. % To validate the above theoretical insights, we conduct experiments on ResNet18 and its variants to examine the impact of gating mechanisms and activation smoothness on frequency learning. % As shown in Fig.~\ref{freq_comparison}, the testing curves of the model employing non-smooth activation functions (ReLU6) shows % visibly surpass above the other models with different thresholds. % It demonstrate superior performance in learning from high-frequency components. % %As shown in Fig.~\ref{freq_comparison}, the testing curves of the model using the non-smooth activation function (ReLU6) clearly surpass those of the other models, demonstrating superior performance in capturing high-frequency components. % This supports the hypothesis that reduced smoothness in the activation function enhances the model's ability to retain high-frequency information. % Conversely, the variant using GELU exhibits stronger performance on low-frequency components, reflecting the strength of smooth activations in modeling low-frequency signals. % Furthermore, we observe that improvements in overall classification accuracy closely align with enhanced capability in capturing high-frequency information, underscoring the critical role of frequency-aware design in improving model performance. % Also, the performance of Res18-Gate-GELU on $(r_2, r_3)$ which is under $20\%$ also indicates the low-frequency bias for the smooth activation function. % Meanwhile, both models show similar learning curve for the lower-frequencies which might be caused by the fast % convergence of the model training. % Additionally, as shown in Fig. \ref{bpgg}, GELU and ReLU demonstrate their superiority among the variants in capturing low-frequency and high-frequency components, respectively. % It indicates that the model with a complete gating unit can better capture the information for various ranges of frequency based on their properties. % Also, the improvement of the overall accuracy aligns with their performance on increasing capturing the high-frequency information. %\subsubsubsection{D} %\noindent{\bf Discussions.} Different datasets and training strategies may lead to different dynamics which has been addressed in \cite{wang2020high, tang2022defects}. %For the small dataset, the convergence is faster which means NNs can easily capture some certain frequency components and then learning from other frequency components becomes very slow. %Therefore, the generated high-frequency noise has a greater impact on disturbing the learning from high-frequencies. %We will show more evidences and discussions of the difference between various activation functions in ablation studies on a larger dataset. %Moreover, from the performance on very high-frequency components (for $\mathbf{z}_i \in (r_3, +\infty)$), it is evident that neural networks face challenges in directly classifying these components, which are nearly imperceptible to the human eye. %However, NNs can be sensitive to the perturbation of high-frequency noise \cite{yin2019fourier}. This is also an interesting topic of revealing the robustness of NNs, but it is beyond the scope of this article. %For the point production only model, %we conduct experiments on recording the changes of the accuracy