id
stringlengths 10
10
| title
stringlengths 26
192
| abstract
stringlengths 172
1.92k
| authors
stringlengths 7
591
| published_date
stringlengths 20
20
| link
stringlengths 33
33
| markdown
stringlengths 269
344k
|
---|---|---|---|---|---|---|
2308.01125 | Stereo Visual Odometry with Deep Learning-Based Point and Line Feature
Matching using an Attention Graph Neural Network | Robust feature matching forms the backbone for most Visual Simultaneous
Localization and Mapping (vSLAM), visual odometry, 3D reconstruction, and
Structure from Motion (SfM) algorithms. However, recovering feature matches
from texture-poor scenes is a major challenge and still remains an open area of
research. In this paper, we present a Stereo Visual Odometry (StereoVO)
technique based on point and line features which uses a novel feature-matching
mechanism based on an Attention Graph Neural Network that is designed to
perform well even under adverse weather conditions such as fog, haze, rain, and
snow, and dynamic lighting conditions such as nighttime illumination and glare
scenarios. We perform experiments on multiple real and synthetic datasets to
validate the ability of our method to perform StereoVO under low visibility
weather and lighting conditions through robust point and line matches. The
results demonstrate that our method achieves more line feature matches than
state-of-the-art line matching algorithms, which when complemented with point
feature matches perform consistently well in adverse weather and dynamic
lighting conditions. | Shenbagaraj Kannapiran, Nalin Bendapudi, Ming-Yuan Yu, Devarth Parikh, Spring Berman, Ankit Vora, Gaurav Pandey | 2023-08-02T13:09:12Z | http://arxiv.org/abs/2308.01125v1 | Stereo Visual Odometry with Deep Learning-Based Point and Line Feature Matching using an Attention Graph Neural Network
###### Abstract
Robust feature matching forms the backbone for most Visual Simultaneous Localization and Mapping (vSLAM), visual odometry, 3D reconstruction, and Structure from Motion (SfM) algorithms. However, recovering feature matches from texture-poor scenes is a major challenge and still remains an open area of research. In this paper, we present a Stereo Visual Odometry (StereoVO) technique based on point and line features which uses a novel feature-matching mechanism based on an Attention Graph Neural Network that is designed to perform well even under adverse weather conditions such as fog, haze, rain, and snow, and dynamic lighting conditions such as nighttime illumination and glare scenarios. We perform experiments on multiple real and synthetic datasets to validate our method's ability to perform StereoVO under low-visibility weather and lighting conditions through robust point and line matches. The results demonstrate that our method achieves more line feature matches than state-of-the-art line-matching algorithms, which when complemented with point feature matches perform consistently well in adverse weather and dynamic lighting conditions.
## I Introduction
With the advances in development and deployment of self-driving vehicles and mobile robots, there is a growing need for high-resolution, accurate visual odometry algorithms that can be deployed on low-cost camera sensors. Although existing localization algorithms perform well under ideal conditions, they usually tend to fail or under-perform in adverse weather conditions such as fog, rain, and snow and in dynamic lighting conditions such as glare and nighttime illumination. The development of visual odometry algorithms that perform effectively under such conditions remains an open area of research.
Existing vision-based localization algorithms rely primarily on conventional point features, such as SIFT [3], SURF [4], and ORB [5], or learning-based point features, such as SuperPoint [6] and LIFT [7], to perform temporal feature matching or learn alternate representations using monocular camera(s) [8, 9] and obtain camera pose estimates. However, point features become unreliable in the adverse conditions mentioned above. To overcome this, we develop a visual odometry technique that includes line segment features in addition to point features (see example application in Fig. 1). In foggy scenes where conventional point features like ORB and SIFT are unable to detect enough features, learning-based feature detectors like SuperPoint perform well. Line feature detectors such as SOLD2 [10] and L2D2 [11] also perform well in such scenarios. However, most point feature detectors, including ORB, SIFT, and SuperPoint, tend to demonstrate poor performance in nighttime scenarios. In comparison, the line features detected by state-of-the-art line detectors such as SOLD2 and L2D2 tend to remain consistent in scenes with low illumination, thereby indicating the need to leverage line features for nighttime conditions.
Fig. 1: Grayscale images of (a) a clear-sky scenario from the Ford AV dataset [1]; (b) a nighttime scenario from the Oxford Car dataset [2]. Rows 1 and 3 show point matches between frames \(i\) and \(i+1\); rows 2 and 4 show line matches between frames \(i\) and \(i+1\). Point and line matches were generated by the method presented in this paper (Method 2 in Section IV).
Given the importance of line features, the next step in integrating line features with the visual odometry framework is to perform feature-matching for line features. Existing techniques either utilize line-based descriptors or apply point descriptors to points sampled from detected lines. Both types of techniques rely on visual descriptors, which tend to fail in texture-poor scenes, justifying the need for a line-matching solution that is constrained by the positions of line features and visual cues. Position-constrained line-matching ensures the prevention of line feature mismatches, particularly in scenes where point features are sparse or similar structures appear repeatedly, such as trusses of a bridge and windows in urban high-rises.
Apart from vision-based sensors, inertial sensors such as Inertial Measurement Units (IMUs) can be used to aid the system to perform Visual-Inertial Odometry (VIO), which yields better accuracy. However, we restricted our focus to just vision-based systems to showcase our method's capabilities without the aid of other such sensors. We developed our method with the goal of easily integrating it into a standard self-driving research vehicle for real-time deployment, and hence we assume that our visual-odometry based pose estimate will ultimately be fused with GNSS (Global Navigation Satellite System) and IMU-based pose estimates in an extended Kalman filter-based framework to provide more accurate pose estimates.
Our contributions can be summarized as follows:
* We developed a novel line-matching technique using an Attention Graph Neural Network that is capable of acquiring robust line matches in feature-poor scenarios by sampling and detecting self-supervised learning-based point features along the lines with encoded position constraints.
* We integrated point features and fine-tuned line features in a Stereo Visual Odometry framework to maintain consistent performance in adverse weather and dynamic lighting conditions and compared the performance of our method to that of state-of-the-art point and line feature matching techniques.
We discuss related work in Section II, give a technical description of our approach in Section III, and describe experiments and results in Section IV. Section V concludes the paper and provides an outlook on future work.
## II Related Work
In this section, we give an overview of previous work related to visual odometry, graph matching, point feature matching, and line matching. Given the amount of prior research, particularly in the visual odometry field (e.g., [12, 13, 14]), a compilation of all existing visual odometry algorithms is beyond the scope of this paper. Visual odometry (VO) techniques are usually classified as either direct VO or feature-based VO. Feature-based solutions are primarily used for their reliability, high accuracy, and robustness, and will therefore be the focus of this paper.
### _Point feature detection and matching_
Point feature detection lies at the heart of most vision-based algorithms. The paper [15] presents a comprehensive survey of different classical feature detectors such as SIFT, ORB, and SURF and learning-based detectors such as LF-Net [16] and SuperPoint and compares their performance on three evaluation tasks in terms of robustness, repeatability, and accuracy. Classical feature-matching techniques usually involve finding descriptors, matching them using a nearest neighbor search, and finally removing outliers to obtain robust matches. Over time, researchers moved towards developing more robust and accurate feature detectors and descriptors to improve matching. Then graph neural network (GNN)-based matching systems such as SuperGlue [17] were developed, which outperformed all existing feature matching techniques by using an attentional GNN. The attention mechanism enables the GNN to selectively focus on the most relevant features (i.e., nodes and edges) when comparing two graphs, which improves the accuracy of feature matching and its robustness to noisy or incomplete graphs. For this reason, we used SuperGlue for point feature matching in our Stereo Visual Odometry framework.
### _Line feature detection and matching_
Line feature detection and matching is a well-researched topic. Classical line detector algorithms rely on geometric constraints to extract lines and find correspondences. Similarly, line segment descriptors can be constructed from the appearance of a neighborhood of the detected line, without resorting to any other photometric or geometric constraints such as the mean-standard deviation line descriptor (MLSD) [18], which constructs the line descriptors by computing the mean and variance of the gradients of pixels in the neighboring region of a line segment. The work [19] proposes a Line Band Descriptor (LBD) that computes gradient histograms over bands for improved robustness and efficiency. Recent advancements in learning-based line segment descriptors, e.g., LLD [20] and DLD [21], demonstrate excellent performance with the use of a convolutional neural network (CNN) to learn the line descriptors. In [11], the authors propose a novel line segment detector and descriptor, Learnable Line Detector and Descriptor (L2D2), which enables efficient extraction and matching of 2D lines via the angular distance of 128-dimensional unit descriptor vectors. The paper [22] presents a novel Graph Convolutional Network-based line segment matching technique that learns local line segment descriptors through end-to-end training.
In [10], the authors propose SOLD2, a self-supervised learning-based line detector that is similar to SuperPoint and does not require any annotation, enabling the system to generalize to multiple scenarios. For this reason, we chose SOLD2's line detector module as a baseline for our method. SOLD2 also includes a line-matching algorithm to enable occlusion awareness. However, unlike SuperGlue, SOLD2's matching algorithm does not take advantage of the position information of the features, which is critical in scenes that
contain repetitive structures such as windows in urban high-rises.
### _Visual SLAM / Odometry with point and line features_
As described in [23, 24], visual SLAM methods that incorporate both point and line features have been developed to improve localization accuracy and computational efficiency over conventional point-based approaches in challenging scenarios, making the VO pipeline more comprehensive and robust to real-world conditions. One example is the visual-inertial SLAM method in [25], which includes several enhancements in line detection and an optical flow-based line feature tracker. Another is the line classification methodology for a Visual Inertial Odometry system that is presented in [26], which exploits the distinctive characteristics of structural (parallel) and non-structural (non-parallel) line features to develop a two-parameter line feature representation, leading to more efficient SLAM computations. However, despite the benefits afforded by using both point and line features, these visual SLAM techniques often exhibit poor performance in scenarios with repeated, similar-looking point and line features, such as those found in traffic environments (e.g., building facades, pedestrian crosswalks). The design of our StereoVO technique was motivated in part by this limitation.
## III StereoVO WITH POINTS AND LINES
Our proposed StereoVO framework is developed to perform well in texture-poor scenarios and relies on tracking a set of point and line correspondences. The framework is based on the SuperGlue [17] network, with an additional constraint (constraint (3) in Section III-B) that greatly improves performance. We first provide a overview of the StereoVO framework, followed by the notation and definitions that we use in our Attention Graph Neural Network architecture. This is followed by a description of the Optimal Matching layer for both point and line features, and a brief summary of how to obtain pose estimates from the point and line correspondences.
### _Overview_
An outline of the proposed StereoVO framework is shown in Fig. 2. The stereo images obtained from the camera are initially undistorted. The left camera image is used to obtain point and line matches, and the right camera image is used to obtain 3D points and 3D line estimates from disparity maps generated using the stereo images.
To improve the accuracy of StereoVO, the left camera image is pre-processed using a semantic segmentation algorithm to remove dynamic objects, such as cars and pedestrians, thereby generating a mask that highlights static features in the scene. In StereoVO, focusing on stable features improves the reliability, precision, and robustness of the camera pose estimates. We employ SegFormer [27], a state-of-the-art semantic segmentation algorithm, out of the box to mask the classes of interest.
In the next step, we perform point and line segment feature detection on the masked input images. Since our goal is to implement the framework on a full-size autonomous vehicle and ensure that it is capable of performing well under adverse weather and dynamic lighting conditions, we tested a variety of point feature detectors, including SIFT, ORB, and LIFT, in example scenarios with such conditions and chose SuperPoint since it outperformed the others. SuperPoint is a CNN-based self-supervised framework that is trained on the MS-COCO dataset [28] and performs real-time point feature detection out of the box without any fine-tuning.
We selected SOLD2 for line feature matching, since it has a similar CNN architecture to SuperPoint. To improve the performance of SOLD2 in low-light conditions and other adverse weather conditions, we fine-tuned the network on synthetic data generated using the CARLA driving simulator [29]. Since SOLD2 performs well in ideal daytime conditions, we used the line features detected by SOLD2 as ground truth and changed weather and lighting conditions for the same scenes in CARLA to generate multi-weather and lighting-augmented data. The SOLD2 algorithm also performs line matching by sampling lines and performing feature matching between the samples to aid in occlusion awareness. However, this results in incorrect matches in feature-poor scenarios. To overcome this, we introduced position constraints on the line features by sampling points along the lines, using SuperPoint to detect point features from these sets of sampled points, and encoding the point
Fig. 2: Outline of the proposed Stereo Visual Odometry framework.
features with keypoint position awareness. This is explained further in the next sections. Both the point and line feature detection networks are designed to function effectively across various datasets without being overly reliant on specific training data. Their generalizability enables them to detect point and line features in diverse contexts and domains, making them versatile tools for a wide range of applications. Figure 3 provides additional details of the framework.
### _Notation and definitions_
Consider a pair of images labeled \(A\) and \(B\). Each image \(\alpha\in\{A,B\}\) has \(L_{\alpha}\) line features, indexed by set \(\mathcal{L}_{\alpha}\subset\mathbb{Z}_{+}\), and \(P_{\alpha}\) point features, indexed by set \(\mathcal{P}_{\alpha}\subset\mathbb{Z}_{+}\) and referred to as _P-point features_. The pixels comprising the line features are extracted using SOLD2 line feature extractor, and SuperPoint is used to detect \(Q_{\alpha}\) point features from these pixels, indexed by set \(\mathcal{Q}_{\alpha}\subset\mathbb{Z}_{+}\) and referred to as _L-point features_. Each point feature is associated with a position \(\mathbf{p}\) and a visual descriptor vector \(\mathbf{d}\). The feature position is defined as \(\mathbf{p}=[u\ v\ c]^{T}\), where \(u\) and \(v\) are the pixel coordinates of the point and \(c\) is the descriptor detection confidence. We will use the notation \((\mathbf{p}_{p})_{i}^{\alpha}\) to indicate the position of P-point feature \(i\in\mathcal{P}_{\alpha}\) in image \(\alpha\) and \((\mathbf{p}_{l})_{i}^{\alpha}\) to indicate the position of L-point feature \(i\in\mathcal{Q}_{\alpha}\) in image \(\alpha\). We define the visual descriptors \((\mathbf{d}_{p})_{i}^{\alpha}\), \((\mathbf{d}_{l})_{i}^{\alpha}\) similarly. The subscript \(x\) will refer to either \(p\) or \(l\).
The representation \((\mathbf{y}_{x})_{i}^{\alpha}\), \(x\in\{p,l\}\), for each keypoint \(i\) in image \(\alpha\) is a high-dimensional vector that encodes the keypoint's position and visual descriptor. The keypoint position is embedded into \((\mathbf{y}_{x})_{i}^{\alpha}\) as follows using a multi-layer perceptron (MLP), similar to the SuperGlue architecture:
\[(\mathbf{y}_{x})_{i}^{\alpha}=(\mathbf{d}_{x})_{i}^{\alpha}+MLP_{encoder}( \mathbf{p}_{x})_{i}^{\alpha} \tag{1}\]
Our framework enforces the following constraints. (1) Any P-point feature from one image has exactly one match to a P-point feature in the other image; similarly for L-point features. (2) All P-point features and L-point features that are occluded or undetected will be unmatched. (3) A line feature \(l_{a}\in\mathcal{L}_{A}\) in image \(A\) is matched to a line feature \(l_{b}\in\mathcal{L}_{B}\) in image \(B\) if most of the L-point features on \(l_{a}\) are matched to L-point features on \(l_{b}\).
### _Attention Graph Neural Network_
An Attention Graph Neural Network (GNN) forms the first layer of the architecture. The network encodes both the positions and visual descriptors of the keypoints, which ultimately improves the performance of the network over a conventional graph neural network. The position constraints increase line-matching robustness and ensure that incorrect line matches do not occur in cases where images contain repetitive structures, such as windows in high-rise buildings. We developed separate GNNs for point and line feature matching, one with nodes defined as the P-point features and the other with nodes defined as the L-point features. Each GNN has a different set of losses and weights, since the networks compute different estimates of the geometric and photometric cues.
As in the SuperGlue architecture, aggression is achieved through both self- and cross-attention mechanisms. Given a feature that corresponds to a particular node in one image, self-attention aggregates features that correspond to adjacent nodes in the same image, and cross-attention aggregates similar features that correspond to nodes in another image. The framework attends to individual point features' positions and their positions relative to adjacent point features, as in SuperGlue. Let \((\mathbf{h}_{x})_{i}^{\alpha}\), \(x\in\{p,l\}\), denote the matching descriptor for keypoint \(i\) in image \(\alpha\). The matching descriptors are defined as:
\[(\mathbf{h}_{x})_{i}^{\alpha}=\mathbf{W}_{x}(\mathbf{y}_{x})_{i}^{\alpha}+ \mathbf{b}_{x},\ \ x\in\{p,l\},\ \alpha\in\{A,B\}, \tag{2}\]
where \(\mathbf{W}_{x}\) is a weight matrix and \(\mathbf{b}_{x}\) is a bias vector.
### _Optimal Matching layer_
The Optimal Matching layer forms the second block of the framework, similar to SuperGlue. The input to this layer is the structural affinity between the two GNNs that have been encoded, defined in terms of affinity matrices \(\mathbf{S}_{p}\in\mathbb{R}^{P_{A}\times P_{B}}\) and \(\mathbf{S}_{l}\in\mathbb{R}^{Q_{A}\times Q_{B}}\). The \((i,j)\)-th entry of each matrix represents the affinity score between point feature \(i\) in image \(A\) and point feature \(j\) in image \(B\) and is defined as follows:
\[(\mathbf{S}_{x})_{i,j}=\text{exp}\left(\frac{(\mathbf{h}_{x}^{T})_{i}^{A} \mathbf{E}_{x}(\mathbf{h}_{x})_{j}^{B}}{\delta_{x}}\right),\ \ x\in\{p,l\}, \tag{3}\]
where \(\mathbf{E}_{x}\) is a learnable weight matrix and \(\delta_{x}\) is a tunable hyperparameter. The network is subject to the constraints described in Section III-B. As in SuperGlue, the unmatched and occluded P-point and L-point features are assigned to a dustbin, which augments each affinity matrix with an additional row and column that are both filled with a single learnable parameter.
We formulate the constrained optimization problem (4)-(5) below to solve for the assignment matrices \(\mathbf{P}_{p}\in\mathbb{R}^{P_{A}\times P_{B}}\) and \(\mathbf{P}_{l}\in\mathbb{R}^{Q_{A}\times Q_{B}}\):
\[\text{max}\sum_{i=1}^{N+1}\sum_{j=1}^{M+1}(\mathbf{S}_{x})_{i,j}(\mathbf{P}_{x })_{i,j},\ \ x\in\{p,l\} \tag{4}\]
\[\mathbf{P}_{x}\mathbf{1}_{N+1}=\mathbf{a}\ \ \text{and}\ \ \mathbf{P}_{x}^{T} \mathbf{1}_{M+1}=\mathbf{b}, \tag{5}\]
where \(M=P_{A}\), \(N=P_{B}\) for \(x=p\); \(M=Q_{A}\), \(N=Q_{B}\) for \(x=l\); and \(\mathbf{a}\) and \(\mathbf{b}\) are biases. As in SuperGlue, this constitutes a differentiable optimal transport problem and can be solved using the Sinkhorn algorithm [30], which is GPU-optimized. The algorithm is iterated until convergence.
Since all layers of the network are differentiable, we use the negative log-likelihood loss as the matching prediction loss. We backpropagate from ground truth matches to visual descriptors. Let \(GT_{p}\) be the set of ground truth matches of P-point features, \(\{(i,j)\}\subset\mathcal{P}_{A}\times\mathcal{P}_{B}\), and \(GT_{l}\) be the set of ground truth matches of L-point features, \(\{(i,j)\}\subset\mathcal{Q}_{A}\times\mathcal{Q}_{B}\). The sets \(\mathcal{A}_{p}\subseteq\mathcal{P}_{A}\) and \(\mathcal{B}_{p}\subseteq\mathcal{P}_{B}\) will denote the unmatched P-point features in both images, and similarly, \(\mathcal{A}_{l}\subseteq\mathcal{Q}_{A}\) and \(\mathcal{B}_{l}\subseteq\mathcal{Q}_{B}\) will denote the unmatched L-point
features. We define two losses, one for P-point features and one for L-point features:
\[Loss_{x} = -\sum_{(i,j)\in GT_{x}}\log(\mathbf{P}_{x})_{i,j}-\sum_{i\in\mathcal{ A}_{x}}\log(\mathbf{P}_{x})_{i,M+1}\] \[\qquad\quad-\sum_{j\in\mathcal{B}_{x}}\log(\mathbf{P}_{x})_{N+1,j },\qquad x\in\{p,l\},\]
where \(M=P_{A}\), \(N=P_{B}\) for \(x=p\) and \(M=Q_{A}\), \(N=Q_{B}\) for \(x=l\).
### _Camera pose estimation_
As a final step, we perform camera pose estimation by using the point and line matches from 2D-3D point and line correspondences between successive frames. To obtain 3D points and lines, we perform stereo matching using the disparity map generated from the stereo camera images. Since this is a well-established topic and open source modules are readily available, a detailed description of camera pose estimation is outside the scope of this paper.
## IV Experiments
In this section, we present the results of experiments that compare the performance of our StereoVO framework to that of state-of-the-art algorithms for point and line feature matching. We compared **Method 1**, which combines the SuperGlue point-matching algorithm and SOLD2 line-matching algorithm, to **Method 2**, which combines the SuperGlue point-matching algorithm and our novel line-matching algorithm. We tested both methods on the following datasets:
* Ford AV dataset [1], collected by autonomous vehicles, which consists of stereo camera images with accurate ground-truth trajectories obtained from LiDAR-based ICP. Our test data was drawn from Log 3 (Vegetation with clear sunny sky) and Log 4 (Residential area with clear sky).
* Nighttime stereo camera images from the Oxford car dataset [2], collected by an autonomous vehicle. Our test data consisted of images of residential areas with Visual Odometry (VO)-based ground truth.
* Synthetic stereo camera images with ground-truth trajectories from the urban environment in Town 10 of CARLA [29]. Our test data consisted of images of the same scenes under a variety of weather and lighting conditions, such as fog, nighttime, and glare.
Our StereoVO framework was run in real-time on an NVIDIA RTX 2080Ti GPU at around 7 FPS (142 ms). To ensure real-time operation, the framework requires a minimum of 6 GB of GPU memory (VRAM). Point and line matching results from Method 2 are shown in Fig. 1 and Fig. 4 for scenes from real and synthetic datasets, respectively, under various weather and lighting conditions.
### _Comparison of estimated trajectories and pose error_
We applied each method to estimate the vehicle camera poses from the Ford AV Log 4 dataset and generated vehicle trajectories from these pose estimates. The trajectories are plotted in Fig. 5, along with the ground truth (GT) trajectory. The figure shows that both methods yield trajectories that are close to the GT trajectory at all times. Note that at coordinates (2965, -660) and (3175, -825), indicated by arrows in the figure, the vehicle was at a complete stop, causing drift in the visual odometry. This drift can be reduced by fusing measurements from other sensors, such as GNSS and IMU, with the StereoVO estimates. To quantify the deviation of the trajectory generated using each method from the GT trajectory, we computed the Absolute Pose Error (APE) over time between each trajectory and the GT trajectory. Figure 6 compares the time series of the APE for both trajectories and shows that our method (Method 2) outperforms Method 1, in that it generally produced lower APE values over the sampled 160-s period.
Fig. 3: The proposed point and line feature matching architecture, consisting of point and line feature layers, an Attention Graph Neural Network layer for both points and lines, and an Optimal Matching layer that generates an assignment matrix using the Sinkhorn algorithm.
We also evaluated the performance of Method 2 on synthetic data from CARLA for the following scenarios: (1) daytime with clear sky; (2) daytime with fog; and (3) nighttime with no street lights. Figure 7a plots the trajectory generated over 200 frames for each scenario, along with the ground truth (GT) trajectory, and Figure 7b shows the box plot of the absolute pose error (APE) for each scenario. Both figures indicate that the discrepancy between the estimated and GT trajectories is higher for the fog and nighttime scenarios than for the daytime scenario, as expected, but that all three estimated trajectories are relatively close to the GT trajectory.
Table I reports the root-mean-square error (RMSE) be
Fig. 4: Every pair of rows starting from the top in this figure shows grayscale images of various synthetic scenarios from CARLA: (a) clear sky scenario; (b) nighttime scenario; (c) foggy scenario. The first row shows point matches between frames \(i\) and \(i+1\), and the second row shows line matches between frames \(i\) and \(i+1\). Point and line matches were generated by Method 2.
Fig. 5: Comparison of Methods 1 and 2 on the Ford AV Log 4 dataset: ground truth (GT) trajectory and trajectories that were generated using camera pose estimates from each method.
Fig. 6: Comparison of Methods 1 and 2 on the Ford AV Log 4 dataset: Absolute Pose Error (APE) over a sample period of 160 s. The \(x\)-axis displays the time recorded by the vehicle.
Fig. 7: Evaluation of Method 2 on the CARLA synthetic dataset: (a) Ground truth (GT) trajectory and trajectories that were generated using camera pose estimates from images of the same scenes in CARLA under daytime, fog, and nighttime conditions. (b) Box plot of Absolute Pose Error (APE) over a sample of 200 frames for the same scenarios.
tween the estimated vehicle position and its ground truth position, obtained from simulated noise-free GNSS data, over 2000 frames in each of the three simulated scenarios in CARLA. The estimated positions were computed using Method 2 with only point features (detected by SuperPoint), only line features (obtained by our line-matching algorithm), or both point and line features. For each scenario, the use of both point and line features yields a lower RMSE value than either point features or line features alone. Hence, the inclusion of line features in the StereoVO framework leads to improved performance, particularly in low-visibility and low-light conditions.
### _Comparison of number of feature detections and matches_
We also compared the number of point or line features that different algorithms detected and matched, along with the percentage of detected features that were matched, in 200 frames of the Ford AV, Oxford car, and CARLA datasets. Table II lists these quantities for point features that were detected by SuperPoint and matched by SuperGlue and line features that were detected by the SOLD2 line detector and matched by either the SOLD2 line-matching algorithm or ours. The table shows that our line-matching algorithm recovers more line matches than the SOLD2 line-matching algorithm in each tested dataset.
Figure 8 plots the number of point features detected by SuperPoint and the number of line matches obtained by our algorithm in each frame of the daytime, fog, and nighttime scenarios simulated in CARLA. The figure shows that the number of line matches in each frame is not significantly affected by the visibility conditions (clear or foggy) or light level (daytime or nighttime) in the scene. However, the numbers of point features detected in the fog and nighttime scenarios are consistently lower than the number detected in the daytime scenario, and are substantially lower in some frames. This is also reflected in the first row of Table II, which shows fewer total point detections in the CARLA fog and nighttime scenarios than in the daytime scenario.
These results indicate that our line-matching algorithm exhibits robust performance as a scene becomes more texture-poor due to adverse weather conditions and/or low illumination. In turn, this robustness in feature matching maintains the accuracy of the camera pose estimates under such conditions.
## V Conclusion
We have presented a real-time stereo visual odometry framework aided by Attention Graph Neural Networks. This framework incorporates self-supervised learning-based point and line features and uses a novel line-matching technique that samples line features into point features with encoded position constraints. Using real datasets from autonomous vehicles and synthetic datasets from the CARLA driving simulator, we demonstrated that our framework produces robust line-matching in feature-poor scenes and scenes containing repetitive structures, e.g., Manhattan-world scenarios. In these tests, our framework outperformed state-of-the-art point and line feature matching algorithms in terms of the error between estimated and ground-truth vehicle poses, the percentage of detected line features that were matched, and the variability in number of identified features with respect to visibility and lighting conditions. One direction for future work is to incorporate planar features into the framework to improve its robustness. Moreover, developing a single end-to-end framework that performs temporal and stereo matching for both point and line features would be a promising step toward increasing the method's accuracy, robustness, and computation efficiency.
Fig. 8: Number of point features detected by SuperPoint (top three plots) and number of line features obtained by our line-matching algorithm (bottom three plots) in each frame of three runs in CARLA under daytime, fog, and nighttime conditions. |
2305.09585 | Inductive Graph Neural Networks for Moving Object Segmentation | Moving Object Segmentation (MOS) is a challenging problem in computer vision,
particularly in scenarios with dynamic backgrounds, abrupt lighting changes,
shadows, camouflage, and moving cameras. While graph-based methods have shown
promising results in MOS, they have mainly relied on transductive learning
which assumes access to the entire training and testing data for evaluation.
However, this assumption is not realistic in real-world applications where the
system needs to handle new data during deployment. In this paper, we propose a
novel Graph Inductive Moving Object Segmentation (GraphIMOS) algorithm based on
a Graph Neural Network (GNN) architecture. Our approach builds a generic model
capable of performing prediction on newly added data frames using the already
trained model. GraphIMOS outperforms previous inductive learning methods and is
more generic than previous transductive techniques. Our proposed algorithm
enables the deployment of graph-based MOS models in real-world applications. | Wieke Prummel, Jhony H. Giraldo, Anastasia Zakharova, Thierry Bouwmans | 2023-05-16T16:32:08Z | http://arxiv.org/abs/2305.09585v1 | # Inductive Graph Neural Networks for Moving Object Segmentation
###### Abstract
Moving Object Segmentation (MOS) is a challenging problem in computer vision, particularly in scenarios with dynamic backgrounds, abrupt lighting changes, shadows, camouflage, and moving cameras. While graph-based methods have shown promising results in MOS, they have mainly relied on transductive learning which assumes access to the entire training and testing data for evaluation. However, this assumption is not realistic in real-world applications where the system needs to handle new data during deployment. In this paper, we propose a novel Graph Inductive Moving Object Segmentation (GraphIMOS) algorithm based on a Graph Neural Network (GNN) architecture. Our approach builds a generic model capable of performing prediction on newly added data frames using the already trained model. GraphIMOS outperforms previous inductive learning methods and is more generic than previous transductive techniques. Our proposed algorithm enables the deployment of graph-based MOS models in real-world applications.
Wieke Prummel\({}^{1}\), Jhony H. Giraldo\({}^{2}\), Anastasia Zakharova\({}^{1}\), Thierry Bouwmans\({}^{1}\)\({}^{1}\) Laboratoire Mathematiques, Image et Applications (MIA), La Rochelle Universite, France
\({}^{2}\) LTCI, Telecom Paris - Institut Polytechnique de Paris, France
Moving object segmentation, graph neural networks, inductive learning, graph signal processing
## 1 Introduction
Moving Object Segmentation (MOS) is an important problem in computer vision, particularly in surveillance system applications [1]. The goal of MOS is to identify and separate the pixels or regions in a video that correspond to moving objects from the static background or other static objects. Deep learning models [2] have demonstrated strong performance on large-scale datasets. However, as the quality of data improves, these models become increasingly complex and computationally intensive, even with fast algorithms [3], few-shot learning methods [4], and specialized architectures [5].
The most common deep models are mostly supervised and can be divided into four groups [6]: 2D Convolutional Neural Networks (CNNs) [7], 3D CNNs [8], transformer neural networks [9], and generative adversarial networks [10, 11]. In addition to these, some state-of-the-art (SOTA) techniques have been combined with deep methods to create novel approaches, such as MotionRec [12], RT-SBS [13], and GraphMOS [14]. Recent graph-based algorithms like GraphMOS [14] and GraphMOD-Net [15] use semi-supervised learning posed as a graph signal reconstruction problem. These methods are inspired by the theory of graph signal processing [16] and have shown promising results. However, these graph-based methods are transductive in nature, meaning that the model needs to be fully retrained and the graph regenerated whenever a new video is added. To address this issue, we propose inductive techniques for graph-based MOS, where multiple graphs are built instead of a single large graph. This approach reduces the need for rebuilding the whole graph and retraining the model, making it more suitable for real-world deployments, as shown in Fig. 1.
In this work, we propose a novel Graph Inductive Moving Object Segmentation (GraphIMOS) algorithm based on Graph Neural Networks (GNNs) [17]. We represent each instance of the video as a node in a graph, which is generated using a Mask Region Convolutional Neural Network (Mask R-CNN) with a ResNet-50 and Feature Pyramid Network (FPN) backbone. We use optical flow, intensity, and texture features to represent the nodes. Instead of creating a single large graph, as in [14], we generate \(\rho+\alpha\)\(k\)-Nearest Neighbors (\(k\)-NN) graphs, where each graph can have a different number of nodes. We set \(\rho=3\) in the experiments for the training and validation graphs, which are then fed to the proposed GNN model for training and hyperparameter optimization. To evaluate the performance of our model, we test it on one single graph \(\alpha=1\), built from previously unseen videos. Our approach is evaluated on the challenging Change
Figure 1: Transductive vs. inductive learning on MOS
Detection 2014 (CDNet 2014) dataset [18], and we demonstrate competitive results against previous inductive methods.
This paper makes two main contributions. Firstly, we propose an inductive graph-based framework for Moving Object Segmentation (MOS), which is an important step toward the real-world deployment of graph-based methods in video surveillance applications. Secondly, we introduce a novel GNN architecture specifically designed for MOS, called GraphIMOS. To the best of our knowledge, GraphIMOS is the first graph-based inductive learning approach for MOS. The remainder of this paper is organized as follows. In Section 2, we introduce the preliminary concepts and describe the GraphIMOS algorithm and architecture. Section 3 presents the experimental setup and results. Finally, in Section 4, we present our conclusions.
## 2 Graph Inductive Moving Object Segmentation
This section presents the preliminaries of this paper and the proposed inductive graph-based MOS method. Figure 2 shows the pipeline of GraphIMOS, which consists of instance segmentation, node representation, graph construction, and inductive GNN training and evaluation.
### Preliminaries
A graph is a mathematical entity that can be represented as \(G=(\mathcal{V},\mathcal{E})\), where \(\mathcal{V}=\{1,2,\ldots,N\}\) is the set of nodes and \(\mathcal{E}\subseteq\{(i,j)\mid i,j\in\mathcal{V}\text{ and }i\neq j\}\) is the set of edges connecting the nodes \(i\) and \(j\). The adjacency matrix \(\mathbf{A}\in\mathbb{R}^{N\times N}\) is a popular choice of shift operator in GNNs [19], where \(\mathbf{A}_{(i,j)}=a_{i,j}\ \forall\ (i,j)\in\mathcal{E}\), and \(0\) otherwise. For unweighted graphs we have that \(\mathbf{A}\in\{0,1\}^{N\times N}\). Similarly, we have the diagonal degree matrix given by \(\mathbf{D}=\mathrm{diag}(\mathbf{A}\mathbf{1})\). In GNNs, we commonly associate a vector of features \(\mathbf{x}_{i}\in\mathbb{R}^{F}\) to each node \(i\). Therefore, we can represent the whole set of input features as \(\mathbf{X}=[\mathbf{x}_{1},\mathbf{x}_{2},\ldots,\mathbf{x}_{N}]^{\mathsf{T} }\in\mathbb{R}^{N\times F}\). In this paper, we use undirected and weighted graphs.
GraphIMOS is designed to be agnostic to the choice of the GNN used. However, in our experiments, we use the widely used Graph Convolutional Network (GCN) [19]. The propagation rule of GCN is given by:
\[\mathbf{H}^{(l+1)}=\sigma(\tilde{\mathbf{D}}^{-\frac{1}{2}}\tilde{\mathbf{A}} \tilde{\mathbf{D}}^{-\frac{1}{2}}\mathbf{H}^{(l)}\mathbf{W}^{(l)}), \tag{1}\]
where \(\tilde{\mathbf{A}}=\mathbf{A}+\mathbf{I}\), \(\tilde{\mathbf{D}}\) is the degree matrix of \(\tilde{\mathbf{A}}\), \(\mathbf{H}^{(l)}\) is the output matrix of layer \(l\) (with \(\mathbf{H}^{(0)}=\mathbf{X}\)), \(\mathbf{W}^{(l)}\) is the matrix of trainable weights in layer \(l\), and \(\sigma(\cdot)\) is an activation function such as \(\mathrm{ReLU}\) or \(\mathrm{softmax}\). It is worth noting that (1) reduces to the regular multi-layer perceptron when \(\tilde{\mathbf{D}}^{-\frac{1}{2}}\tilde{\mathbf{A}}\tilde{\mathbf{D}}^{-\frac {1}{2}}=\mathbf{I}\).
### Segmentation and Node Representation
For the region proposal, we use Mask R-CNN with ResNet-50 as the backbone and construct graphs using a \(k\)-NN method. The feature representation proposed in [14] is utilized, where
Figure 2: Pipeline of the graph inductive moving object segmentation algorithm via graph neural network learning. After instance segmentation and node feature extraction, the dataset is divided into \(\rho\) graphs for training-validation and into \(\alpha\) testing graphs. The algorithm then classifies nodes in the graphs as either moving or static objects.
the outputs generated by Mask R-CNN are represented as nodes in the graphs. These instances are associated with meaningful representations, such as optical flow, intensity, and texture features. Finally, all the features are concatenated to form a \(930\)-dimensional vector, which represents each instance. For further details on the feature extraction process, please refer to [14, 20].
### Graph Mini-batch
The proposed framework is distinct from previous graph-based MOS methods because it is an inductive architecture. For instance, in [14], the whole graph would need to be rebuilt every time a new video is fed into the algorithm. This requires the optimization problem to be solved again, making deployment in real-world scenarios more challenging. Therefore, instead of creating a single graph from the data, our proposed approach creates \(\rho+\alpha\) separate graphs, each with a different number of nodes. This ensures that the data in the \(\rho\) training-validation graphs are not connected. The adjacency matrices are arranged in a block-diagonal manner to construct a comprehensive graph that includes multiple distinct subgraphs as follows:
\[\mathbf{A}=\begin{bmatrix}\mathbf{A}_{1}&&\\ &\ddots&\\ &&&\mathbf{A}_{\rho}\end{bmatrix}, \tag{2}\]
where \(\mathbf{A}\) is the adjacency matrix in the mini-batch. We define \(\rho\) for the number of training and validation graphs, and \(\alpha\) for the testing graphs as shown in Fig. 2. Our adjacency matrices are stored efficiently, using a sparse representation that only keeps track of non-zero entries: the edges. This means that there is no extra memory overhead. The node and target features are integrated into the node dimension through simple concatenation.
### GNN Architecture
Our model consists of two GCNConv layers [19], various ReLU activation layers, and three linear layers. To reduce overfitting and improve generalization on unseen videos, we use five dropout and four pair batch normalizations (PairNorm) [21]. These techniques also enhance the training stability of the model and prevent over-smoothing. PairNorm is particularly effective in achieving a better convergence of the proposed model. Our goal is to learn meaningful representations of the graph structure and node features to classify objects as either static or moving. The final layer of our model employs a log \(\mathrm{softmax}\) function defined as follows: \(\mathrm{log\_softmax}=\mathrm{log}(\frac{1}{s}\exp{x_{i}})\) where \(s=\sum_{i}\exp{x_{i}}\). This GNN architecture enables GraphIMOS to be easily deployed in real-world applications.
## 3 Experiments and Results
This section introduces the metrics, and the dataset graph partitioning used to conduct the different experiments on GraphIMOS.
### Evaluation Metrics
The evaluation metrics F-Measure, precision, and recall are defined as follows:
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}},\,\text{Precision }=\frac{\text{TP}}{\text{TP}+\text{FP}},\] \[\text{F-measure}=2\frac{\text{Precision}\times\text{Recall}}{ \text{Precision}+\text{Recall}}, \tag{3}\]
where TP, FN, and FP are the true positives, false negatives, and false positives, respectively. According to Table 1, we calculate the F-Measure in Table 2 on node level classification.
### Experiments
We evaluate GraphIMOS against several SOTA algorithms using the large-scale CDNet 2014 dataset [18]. To build an inductive framework, we construct multiple graphs by dividing the data into four sequences: S1, S2, S3, and S4 as shown in Table 1. Therefore, we run 4 experiments to compute the F-Measure in the whole dataset. These sequences were chosen to enable unseen videos evaluation, following the approach in [24]. For each sequence, we compute the results and construct one graph per sequence : \(G1\), \(G2\), \(G3\), and \(G4\).
In each experiment, we use two graphs to train and evaluate GraphIMOS, and one graph for testing. For each experiment we chose to use a different graph to test the performance of the proposed algorithm on unseen videos.
\begin{table}
\begin{tabular}{l c c c} \hline \hline
**Sequences** & **Training** & **Validation** & **Testing** \\ \hline S2, S3, S1, S4 (Exp1) & \(G2,G3\) & \(G1\) & \(G4\) \\ S1, S3, S4, S2 (Exp2) & \(G1,G3\) & \(G4\) & \(G2\) \\ S2, S3, S4, S1 (Exp3) & \(G2,G3\) & \(G4\) & \(G1\) \\ S1, S2, S4, S3 (Exp4) & \(G1,G2\) & \(G4\) & \(G3\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Data Partitioning.
\begin{table}
\begin{tabular}{l c c c c} \hline \hline
**F-Measure** & **Exp1** & **Exp2** & **Exp3** & **Exp4** \\ \hline F-Measure validation & \(0.8420\) & \(0.8006\) & \(0.8386\) & \(0.8014\) \\ F-Measure test & \(0.8388\) & \(0.7969\) & \(0.8367\) & \(0.7567\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: F-Measure Experiments.
### Implementation Details
We employ the PyTorch Geometric library [25] to implement our proposed architecture. The \(k\)-nearest neighbors (\(k\)-NN) graphs are constructed with a value of \(k=40\). In order to prevent overfitting, we use a dropout with a coefficient of \(0.5\). For optimization, we use stochastic gradient descent (SGD) with a momentum of \(0.9\), a learning rate of \(0.01\), and \(5e{-4}\) for weight decay. We train our model for a maximum of \(500\) epochs, using a graph-batch size of \(1\). Our model architecture includes \(5\) hidden layers, and we opt for the negative log likelihood loss for training and evaluating the GNN model.
### Results and Discussion
We compare GraphIMOS with FgSegNet [23], GraphMODNet [22], and GraphMOS [14]. While GraphMOD-Net is transductive in nature, we adapt it to our data partitioning and experimental framework for a fair comparison with GraphIMOS. We also include GraphMOS and GraphMOD-Net with their original performances as references, since they are transductive techniques. The numerical and visual results of the compared methods are shown in Fig. 3 and Table 3, which demonstrate that GraphIMOS surpasses previous inductive learning methods. Our experiments also reveal that GraphMOD-Net [22] shows a performance degradation when evaluated in an inductive setting, possibly due to the challenges of real-world deployments. GraphIMOS strikes a better balance between performance and realistic deployment, making it a promising candidate for real-world applications.
## 4 Conclusion
This paper introduces GraphIMOS, a novel approach that uses GNNs, graph mini-batches, and inductive learning for MOS. The proposed algorithm consists of four key components: instance segmentation using Mask R-CNN, feature extraction for node representation, \(k\)-NN for graph construction, and a GNN-based inductive learning algorithm. To the best of our knowledge, GraphIMOS is the first approach that uses graph-based inductive learning for MOS, demonstrating its novelty and potential. Compared to previous works such as GraphMOD-Net, GraphIMOS offers improved performance and a better trade-off between performance and practical deployment. For future work, we plan to add skip connections and deeper GNN models.
\begin{table}
\begin{tabular}{l c c c c c c c c c} \hline \hline
**Method** & **BSL** & **BWT** & **IOM** & **LFR** & **PTZ** & **THL** & **CJI** & **SHW** & **DBA** & **Overall** \\ \hline \multicolumn{1}{c}{} & \multicolumn{6}{c}{**Transductive Learning Methods**} & \\ GraphMOS [14] & \(0.9398\) & \(0.8294\) & \(0.3607\) & **0.5538** & \(0.7599\) & **0.7292** & \(0.7005\) & **0.9653** & \(0.7334\) & \(0.7302\) \\ GraphMOD-Net [22] (Original) & **0.9550** & **0.8390** & **0.5540** & \(0.5210\) & **0.7700** & \(0.6820\) & **0.7200** & \(0.9420\) & **0.8510** & **0.7593** \\ \hline \multicolumn{1}{c}{} & \multicolumn{6}{c}{**Inductive Learning Methods**} & \\ FgSegNet [23] & \(0.5641\) & \(0.2789\) & \(0.3325\) & \(0.2115\) & \(0.1400\) & \(0.3584\) & \(0.2815\) & \(0.3809\) & \(0.2067\) & \(0.3061\) \\ GraphMOD-Net (Modified) & \(0.6474\) & \(0.6268\) & \(0.5243\) & \(0.5337\) & \(0.5899\) & \(0.5484\) & \(0.4926\) & \(0.6587\) & **0.6254** & \(0.5831\) \\ GraphMOS (Ours) & **0.7003** & **0.6377** & **0.5284** & **0.5478** & **0.5932** & **0.6453** & **0.6700** & **0.6807** & \(0.5868\) & **0.6211** \\ \hline \hline
**CDNet 2014** & \multicolumn{6}{c}{**Original**} & \multicolumn{6}{c}{**Ground Truth**} & **FgSegNet** & **GraphMOD** & **GraphIMOS** \\ \hline Baseline, pedestrians & & & & & & & & & \\ \hline Intermittent object motion, tramstop & & & & & & & & \\ Shadow, cubicle & & & & & & & & \\ \hline \hline \end{tabular}
\end{table}
Table 3: Average F-Measure for transductive and inductive methods. The best score of all methods appears in bold, and the best score of the inductive methods is bold underlined. The columns contain the CDNet2014 [18] challenges : bad weather (BWT), baseline (BSL), camera jitter (CJI), dynamic background (DBA), intermittent object motion (IOM), low frame rate (LFR), PTZ, shadow (SHW), and thermal (THL).
Figure 3: Comparisons of the visual results on unseen videos of the proposed GraphIMOS algorithm with two inductive methods: FgSegNet [23] and the modified GraphMOD-Net [22]. We show results from three different challenges from CDNet 2014 [18]. |
2308.15150 | Unleashing the Potential of Spiking Neural Networks for Sequential
Modeling with Contextual Embedding | The human brain exhibits remarkable abilities in integrating temporally
distant sensory inputs for decision-making. However, existing brain-inspired
spiking neural networks (SNNs) have struggled to match their biological
counterpart in modeling long-term temporal relationships. To address this
problem, this paper presents a novel Contextual Embedding Leaky
Integrate-and-Fire (CE-LIF) spiking neuron model. Specifically, the CE-LIF
model incorporates a meticulously designed contextual embedding component into
the adaptive neuronal firing threshold, thereby enhancing the memory storage of
spiking neurons and facilitating effective sequential modeling. Additionally,
theoretical analysis is provided to elucidate how the CE-LIF model enables
long-term temporal credit assignment. Remarkably, when compared to
state-of-the-art recurrent SNNs, feedforward SNNs comprising the proposed
CE-LIF neurons demonstrate superior performance across extensive sequential
modeling tasks in terms of classification accuracy, network convergence speed,
and memory capacity. | Xinyi Chen, Jibin Wu, Huajin Tang, Qinyuan Ren, Kay Chen Tan | 2023-08-29T09:33:10Z | http://arxiv.org/abs/2308.15150v1 | # Unleashing the Potential of Spiking Neural Networks for
###### Abstract
The human brain exhibits remarkable abilities in integrating temporally distant sensory inputs for decision-making. However, existing brain-inspired spiking neural networks (SNNs) have struggled to match their biological counterpart in modeling long-term temporal relationships. To address this problem, this paper presents a novel Contextual Embedding Leaky Integrate-and-Fire (CE-LIF) spiking neuron model. Specifically, the CE-LIF model incorporates a meticulously designed contextual embedding component into the adaptive neuronal firing threshold, thereby enhancing the memory storage of spiking neurons and facilitating effective sequential modeling. Additionally, theoretical analysis is provided to elucidate how the CE-LIF model enables long-term temporal credit assignment. Remarkably, when compared to state-of-the-art recurrent SNNs, feedforward SNNs comprising the proposed CE-LIF neurons demonstrate superior performance across extensive sequential modeling tasks in terms of classification accuracy, network convergence speed, and memory capacity.
## Introduction
Driven by the recent advance in training algorithm development [22, 23] and model architecture design [10, 11], brain-inspired spiking neural networks (SNNs) have exhibited remarkable performance in tasks such as image classification [22, 24, 25], speech processing [26, 27], and robotic control [12, 10]. Furthermore, when implemented on ultra-low-power and densely-connected neuromorphic chips [1, 11, 12], these models demonstrate compelling energy efficiency and low latency, making them highly promising for achieving ultra-low-power artificial intelligence (AI) at the edge. However, despite these advancements, existing SNNs still face challenges in effectively modeling long-term temporal dependency when compared to their biological counterparts [24, 25].
Towards the goal of enhancing the sequential modeling capability of SNNs, recent research endeavors have focused on developing novel spiking neuron models that incorporate slow-decaying variables capable of storing long-term memory. One notable approach involves the integration of a threshold adaptation mechanism into spiking neurons, wherein the firing threshold of a neuron is elevated and gradually decays following each firing event [13]. This adaptive firing threshold mechanism not only helps suppress excessive neuronal firing but also demonstrates effectiveness in storing long-term memory. Furthermore, Yin et al. propose to use a learnable decaying time constant for the adaptive firing threshold, thereby enabling the storage and utilization of multi-scale temporal information [23]. Similarly, Shaban et al. introduce a novel adaptive spiking neuron model, wherein the threshold undergoes a double-exponential decay, enabling the storage of both short-term and long-term information [2]. However, despite the promising results observed with these models, their ability to establish long-term dependencies remains limited. This limitation can be attributed to the inadequate representation of the temporal structure of sensory inputs within the long-term memory created by the adaptive firing threshold.
In another vein of research, the integration of self-attention mechanisms along with position encoding (PE) has been proposed in Transformer [26] to enhance the efficacy of sequential modeling. Specifically, self-attention enables the direct modeling of temporal dependencies between distant inputs. Additionally, PE has been introduced to explicitly represent the temporal structure of inputs using a fixed-length vector, thereby addressing the position invariance issue associated with self-attention operations. In practice, PE can be generated through a fixed sinusoidal function [26, 27], or learned together with other model parameters [10]. Notably, these advancements have contributed to the remarkable progress witnessed in large language models such as BERT [12] and GPT [1]. Motivated by these developments, attention-based spiking neural networks [24, 25] have recently been proposed to enhance the sequential modeling capabilities of SNNs. However, these models encounter challenges related to high computational com
plexity, limitations in hardware implementation, and the inability to operate in real-time scenarios.
In this work, we present a novel spiking neuron model, dubbed **Contextual Embedding Leaky Integrate-and-Fire (CE-LIF)**. Our proposed model incorporates the concepts of adaptive firing threshold and position encoding to enhance the sequential modeling capability of SNNs. Specifically, we introduce a contextual embedding component to induce the firing threshold adjustments, which is produced by multiplying the membrane potential with a learnable temporal encoding (TE). Notably, the TE allows for the explicit representation of a neuron's preferred temporal pattern, thereby alleviating the challenge of preserving the temporal structure of the input signals within the adaptive firing threshold. To validate the effectiveness of the CE-LIF neuron, we conduct both theoretical analysis and extensive experimental studies, highlighting its superior sequential modeling capabilities. The key contributions of our work can be summarized as follows:
* We propose a novel spiking neuron model called CE-LIF that can significantly enhance the sequential modeling capability of SNNs.
* We provide a theoretical analysis of the proposed CE-LIF neuron model. Our analysis offers valuable insights into how error gradients can be effectively propagated to distant inputs, thereby establishing long-term temporal dependencies.
* We thoroughly validate the effectiveness of CE-LIF on a wide range of sequential modeling tasks. Notably, we demonstrate that the feedforward SNNs comprising CE-LIF neurons can surpass both state-of-the-art (SOTA) recurrent SNNs and LSTM models in terms of classification accuracy, network convergence speed, and memory capacity.
## Methods
### Leaky Integrate-and-Fire (LIF) Neuron Model
Inspired by the rich neuronal dynamics and firing behavior of biological neurons, a number of spiking neuron models have been proposed in the literature, offering varying levels of biological details [11]. For large-scale SNN simulation, the leaky integrate-and-fire (LIF) model has commonly been adopted. This simplified neuron model can describe the essential membrane integration and spike generation processes of biological neurons while remaining computationally efficient. The neuronal dynamic of LIF neurons could be described as follows:
\[\tau_{m}\frac{dv(t)}{dt}=-(v(t)-v_{reset})+I(t), \tag{1}\] \[\text{if}\quad v(t)\geq\theta,\quad v(t)\to v_{reset}.\]
where \(v_{reset}\) denotes the resting potential, \(\tau_{m}\) is the membrane decaying time constant, and \(I\) corresponds to the input current transduced from the input spikes \(S(t)\), that is, \(I(t)=\mathcal{W}S(t)\), where \(\mathcal{W}\) is the synaptic weight. \(\theta\) signifies
Figure 1: The comparison of neuronal structure and dynamics between biological neurons and spiking neurons. **(a)** Biological neurons transduce presynaptic spikes into input currents, which are subsequently integrated into the membrane potential. The spike generation happens once the membrane potential surpasses the firing threshold. Notably, the firing threshold of biological neurons undergoes adaptations in response to the firing activities of the neuron. **(b-d)** The functional block diagrams (bottom row) and neuronal dynamics (top row) of the LIF neuron, ALIF neuron, and our proposed CE-LIF neuron. The LIF neuron generates spikes at a fixed firing threshold. In contrast, the ALIF model refines the LIF model by incorporating a biologically inspired adaptive firing threshold, thereby enhancing neuronal memory capacity while suppressing excessive firing. Furthermore, our proposed CE-LIF model advances upon the ALIF model by replacing the postsynaptic-spike-induced firing threshold adjustment with a contextual-embedding-induced one. Specifically, this contextual embedding is produced by multiplying the membrane potential with a learnable temporal encoding. This refinement not only results in enhanced memory capacity compared to ALIF but also facilitates long-term temporal credit assignment.
the firing threshold. When the membrane potential reaches \(\Theta\), it triggers the generation of an output spike. Following the spike generation, membrane potential will be reset to \(v_{reset}\). In practice, this continuous-time formulation is usually discretized using the Euler method:
\[\left\{\begin{array}{l}V[t]=\alpha\cdot V[t-1]\cdot(1-S[t-1])+I[t],\\ S[t]=H\left(V[t]-\theta\right),\end{array}\right. \tag{2}\]
where \(\alpha=e^{-\tau_{m}}\) is the membrane potential decaying rate, \(H(\cdot)\) is the Heaviside step function. SNNs comprising LIF neurons have demonstrated exceptional performance in pattern recognition tasks with limited temporal context. However, their suitability for tasks necessitating extended temporal dependencies is currently constrained due to two contributing factors. Firstly, the internal memory of LIF neurons, represented by the membrane potential, diminishes rapidly over time and is reset upon neuron firing. It, therefore, presents a significant challenge in retaining long-term memory. Secondly, the backpropagation-through-time (BPTT) algorithm, which is commonly employed in SNN training, poses an additional obstacle to learning long-term dependency. This is attributed to the recursive nature of gradient updates, which can lead to problems such as gradient vanishing and exploding.
### Adaptive LIF Neuron Model
Research on biological neurons has revealed that the neuronal firing threshold undergoes adaptations in response to neuronal firing activities. Specifically, an increase in the frequency of neuronal firing results in an elevation of the firing threshold [16]. This phenomenon has been identified as playing a crucial role in enhancing memory retention. Inspired by these findings, the adaptive threshold LIF (ALIF) neuron model has been introduced with the aim of enhancing the memory capacity of spiking neurons [1]. The formulation of the ALIF model can be summarized as follows:
\[\left\{\begin{array}{l}\Theta[t]=\beta\cdot(\Theta[t-1]-\Theta_{0})+\gamma \cdot S[t-1]+\Theta_{0},\\ V[t]=\alpha\cdot V[t-1]\cdot(1-S[t-1])+I[t],\\ S[t]=H\left(V[t]-\Theta[t]\right),\end{array}\right. \tag{3}\]
where \(\Theta_{0}\) represents the initial firing threshold. Each postsynaptic spike contributes to a transient increase in the firing threshold \(\Theta\) with a gain of \(\gamma\), whose contribution decays at a slow rate of \(\beta\) (e.g., 0.99). This firing threshold adaptation mechanism encompasses two significant advantages. Firstly, the elevated firing threshold can effectively suppress excessive firing, thereby improving the efficiency of neural signal processing. Secondly, benefiting from its slow decay rate and non-resetting characteristics, the adaptive threshold can serve as a long-term memory. However, within such memory storage, the input information is compressed into low-resolution binary spikes with their temporal structures being inadequately represented, thereby presenting substantial obstacles when performing temporal credit assignments (see Supplementary Materials for more detailed analysis).
### Contextual Embedding LIF Neuron
To address the above-identified deficiencies in ALIF neurons, we redesign the adaptive firing threshold by replacing the postsynaptic-spike-induced firing threshold increment with a contextual-embedding-induced one, we refer to the resulted neuron model as **Contextual Embedding LIF (CE-LIF)**. The refined adaptive firing threshold function is expressed as:
\[\Theta[t]=\beta\cdot(\Theta[t-1]-\Theta_{0})+TE[t]\odot V[t-1]+\Theta_{0}, \tag{4}\]
where \(\odot\) denotes the Hadamard product. The proposed contextual embedding comprises two interacting components, namely the membrane potential \(V\) and the temporal encoding vector \(TE\). By replacing \(S[t-1]\) with \(V[t-1]\)
Figure 2: Illustration of the evolution of neuronal variables during the Seq-MNIST classification task. **(a)** The input image is processed pixel-by-pixel through a raster scan. The recorded **(b)** contextual embeddings, **(c)** adaptive firing thresholds, and **(d)** the output spike trains of all output neurons. In (d), the black color bars represent the generated spikes.
in the firing threshold update function, the issue of low-resolution spike-based information representation is effectively addressed. This refinement not only aligns more closely with existing biological findings [12, 13], but also facilitates the effective delivery of gradients to early timesteps (see analysis in Ablations and Supplementary Materials). Additionally, the temporal encoding vector \(TE\in\mathbb{R}^{T}\) hard codes the preferred temporal pattern of a neuron, ensuring every neuron within the same layer possesses its unique TE vector. Therefore, the proposed contextual embedding effectively circumvents the challenge of preserving the temporal structure of input signals within the firing threshold.
Notably, the inner product between \(V\) and \(TE\) acts as an indicator of the presence of the preferred temporal pattern. This information is subsequently integrated into the firing threshold to facilitate context-dependent processing. In order to elucidate the dynamic interaction between these two components in enabling context-dependent processing, we provide a visualization in Figure 2 to illustrate the evolution of \(TE\odot V\), \(\Theta\), and \(S\) throughout the Sequential MNIST (Seq-MNIST) classification task. In this task, input images from the MNIST dataset are processed on a pixel-by-pixel basis via a raster scan [10]. Notably, as depicted in Figure 2(b), the \(TE\odot V\) of target neurons often display negative values, indicating the detection of their preferred temporal patterns. Consequently, this leads to a consistent reduction in the firing threshold \(\Theta\) in Figure 2(c), ultimately resulting in the observed bursting behaviors exhibited by the target neurons, as illustrated in Figure 2(d). In contrast, non-target neurons more frequently exhibit positive values in their \(TE\odot V\) representation, leading to elevated firing thresholds that inhibit them from firing.
### Impact of CE on Gradient Propagation
Here, we provide a theoretical analysis to explain how gradients can be effectively delivered to earlier timesteps in CE-LIF neurons. Specifically, we adopt the BPTT algorithm along with surrogate gradient [14, 15] for parameter update, which can be summarised as follows:
\[\Delta\mathcal{W}^{l}\propto\frac{\partial\mathcal{L}}{\partial\mathcal{W}^{ l}}=\sum_{t=1}^{T}\frac{\partial\mathcal{L}}{\partial V^{l}[t]}S^{l-1}[t],\quad \Delta b^{l}\propto\frac{\partial\mathcal{L}}{\partial\mathcal{W}^{l}}=\sum_{ t=1}^{T}\frac{\partial\mathcal{L}}{\partial V^{l}[t]}, \tag{5}\]
where \(\mathcal{L}\) is the loss function. \(\mathcal{W}^{l}\) and \(b^{l}\) refer to weight and bias terms of layer \(l\), respectively. The partial derivative of \(\frac{\partial\mathcal{L}}{\partial V^{l}[t]}\) can be further decomposed and calculated as follows:
\[\begin{split}\frac{\partial\mathcal{L}}{\partial V^{l}[t]}& =\frac{\partial\mathcal{L}}{\partial S^{l}[t]}\frac{\partial S^{l }[t]}{\partial V^{l}[t]}+\frac{\partial\mathcal{L}}{\partial V^{l}[t+1]} \frac{\partial V^{l}[t+1]}{\partial V^{l}[t]}+\frac{\partial\mathcal{L}}{ \partial\Theta^{l}[t+1]}\frac{\partial\Theta^{l}[t+1]}{\partial V^{l}[t]}\\ &=\frac{\partial\mathcal{L}}{\partial S^{l}[t]}g^{\prime}[t]+ \frac{\partial\mathcal{L}}{\partial V^{l}[t+1]}\alpha(1-S^{l}[t])+\frac{ \partial\mathcal{L}}{\partial\Theta^{l}[t+1]}TE[t+1],\\ \frac{\partial\mathcal{L}}{\partial S^{l}[t]}&=\frac{ \partial\mathcal{L}}{\partial V^{l}[t+1]}\frac{\partial V^{l}[t+1]}{\partial S ^{l}[t]}+\frac{\partial\mathcal{L}}{\partial V^{l+1}[t]}\frac{\partial V^{l+ 1}[t]}{\partial S^{l}[t]}\\ &=-\frac{\partial\mathcal{L}}{\partial V^{l}[t+1]}\alpha V^{l}[t]+ \frac{\partial\mathcal{L}}{\partial V^{l+1}[t]}W^{l},\\ \frac{\partial\mathcal{L}}{\partial\Theta^{l}[t]}& =\frac{\partial\mathcal{L}}{\partial S^{l}[t]}\frac{\partial S^{l}[t]}{ \partial\Theta^{l}[t]}+\frac{\partial\mathcal{L}}{\partial\Theta^{l}[t+1]} \frac{\partial\Theta^{l}[t+1]}{\partial\Theta^{l}[t]}\\ &=-\frac{\partial\mathcal{L}}{\partial S^{l}[t]}g^{\prime}[t]+ \frac{\partial\mathcal{L}}{\partial\Theta^{l}[t+1]}\beta,\end{split} \tag{6}\]
where \(g^{\prime}[t]=H^{\prime}(V^{l}[t]-\Theta^{l}[t])\) refers to the surrogate gradient function, which is applied during error backpropagation to address the discontinuity of spike generation function given in Eq. (2). In particular, we adopt a boxcar function [14] that is defined as follows:
\[g^{\prime}[t]=\left\{\begin{array}{ll}1,&\text{if}\quad|V^{l}[t]-\Theta^{l }[t]|<\Gamma,\\ 0,&\text{otherwise},\end{array}\right. \tag{7}\]
where \(\Gamma\) is a hyperparameter that determines the permissible range for gradient propagation.
Subsequently, by transforming Eq. (6) into a cumulative form using recursive accumulation, we have:
\[\begin{split}\frac{\partial\mathcal{L}}{\partial\Theta^{l}[t]}& =\sum_{i=t}^{T}-\frac{\partial\mathcal{L}}{\partial S^{l}[i]}g^{ \prime}[t]\beta^{i-t}=\sum_{i=t}^{T}-\frac{\partial\mathcal{L}}{\partial S^{l}[ i]}\frac{\partial S^{l}[i]}{\partial V^{l}[i]}\beta^{i-t}\\ &=\sum_{i=t}^{T}-\frac{\partial\mathcal{L}}{\partial V^{l}[i]} \beta^{i-t},\end{split} \tag{8}\]
Finally, by substituting Eq. (8) into Eq. (6), we can rewrite \(\frac{\partial\mathcal{L}}{\partial V^{l}[t]}\) as follows:
\[\begin{split}\frac{\partial\mathcal{L}}{\partial V^{l}[t]}& =\underbrace{\frac{\partial\mathcal{L}}{\partial S^{l}[t]}g^{ \prime}[t]}_{\text{LIF (Spatial)}}+\underbrace{\frac{\partial\mathcal{L}}{\partial V^{l}[t+1]} \alpha(1-S^{l}[t])}_{\text{LIF (Temporal)}}\\ &\quad\quad-\underbrace{\sum_{i=t+1}^{T}\frac{\partial\mathcal{L}}{ \partial V^{l}[i]}\beta^{i-t}TE[t+1]}_{\text{CE}},\end{split} \tag{9}\]
where the first two terms have an identical format as in the LIF model. The first term, as illustrated in Figure 3, represents the spatial credit assignment (SCA) between consecutive layers. However, the SCA may encounter the dead gradient problem when the surrogate gradient value \(g^{\prime}[t]\) equals zero. Furthermore, the second term corresponds to the temporal credit assignment (TCA) that decays exponentially at a rate of \(\alpha\) as well as resets after each spike generation. Consequently, the gradient information cannot be effectively propagated over a long period of time. Notably, our proposed CE
Figure 3: Illustration of the error backpropagation in an SNN comprising CE-LIF neurons. The backward paths of CE (orange dotted lines) establish a highway that can backpropagate the error information directly to earlier timesteps. Better to view this figure in color.
can effectively address this notorious problem by establishing a gradient highway between all dependent timesteps. By incorporating appropriately learned values of \(TE\) alongside a slow decay rate of \(\beta\), the CE-LIF model can effectively propagate gradients to much more distant timesteps compared with the ALIF model, as will be demonstrated in the Experiments section.
## Experiments
In this section, we provide a comprehensive analysis of the proposed CE-LIF model in terms of the sequential modeling capability, network convergence speed, and efficacy in performing long-term TCA. Moreover, ablation studies among different implementations of contextual embedding are also provided to demonstrate the superiority of the proposed design. The detailed experimental setups are provided in the Supplementary Materials.
### Pixel-level Sequential Image Classification
We first evaluate the performance of our proposed CE-LIF model on two widely adopted sequential classification tasks, namely Seq-MNIST and Permuted Sequential MNIST (PS-MNIST) [13]. In these tasks, the input images are processed by a model pixel-by-pixel through a raster scan. As the results summarized in Table 1, the CE-LIF model outperforms all other SOTA SNN implementations with the same or a lesser number of parameters. These results are also competitive with other ANN models, such as LSTM [10], IndRNN [12], and TCN [1]. Notably, the results of our CE-LIF model are achieved with a feedforward network structure, while almost all other works employ a recurrent network structure to achieve effective sequential modeling. Considering that our feedforward SNNs have already achieved saturation in terms of classification accuracy on these datasets, introducing a recurrent network structure would lead to an unnecessary parameter increase. As a result, we restrict our analysis of CE-LIF to a feedforward SNN in the following sections. For a more comprehensive analysis of the spiking RNN utilizing CE-LIF neurons, we refer readers to the Supplementary Materials.
Moreover, the CE-LIF model exhibits significantly faster and more stable training convergence compared with LIF and ALIF models. As demonstrated in Figure 4, the CE-LIF model achieves rapid convergence on the Seq-MNIST task within a mere ten training epochs, whereas the LIF and ALIF models require more than 100 epochs to converge. Furthermore, the CE-LIF model exhibits a much smoother loss landscape, which facilitates training convergence and offers great potential for improved generalization. These discrepancies do not primarily stem from the ease of convergence in a feedforward structure. More crucially, they can be attributed to the more effective TCA established by the proposed contextual embedding. Therefore, these findings highlight the superiority of the proposed CE-LIF model in sequential modeling.
### Memory Capacity Analysis
We further analyze the memory capacity of the proposed CE-LIF model on the adding problem and copy memory problem that necessitates long-term memory [11]. Specifically, the comparative study is performed among the CE-LIF, LSTM, and ALIF models.
**Adding problem** is a regression task in which two input sequences of length \(T\) are provided, one representing a value sequence and the other an indicator sequence [1]. The value sequence comprises randomly sampled entries from the range of \((0,1)\), while the indicator sequence assigns a value of \(1\) to two randomly selected entries and \(0\) to the remaining entries. The indicator sequence works as a pointer to indicate which two entries in the value sequence should be added. In this task, input sequences are processed by models one entry after the
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Model** & **SNN** & **Architecture** & **Parameters** & **Seq-MNIST** & **PS-MNIST** \\ \hline LSTM [10] & No & Recurrent & 66.5k & 98.20\% & 88.00\% \\ IndRNN [12] & No & Recurrent & 99.2k & 99.50\% & 96.00\% \\ TCN [1] & No & Convolution & 70.0k & 99.00\% & 97.20\% \\ \hline LSNN [1] & Yes & Recurrent & 68.2k & 93.70\% & N.A. \\ DEEP-R LSNN [1] & Yes & Recurrent & 66.4k & 96.40\% & N.A. \\ DEXAT [1] & Yes & Recurrent & N.A. & 96.40\% & N.A. \\ AHP [1] & Yes & Recurrent & 68.4k & 96.00\% & N.A. \\ LIF* & Yes & Feedforward & 85.1k & 63.45\% & - \\ LTMD* [14] & Yes & Feedforward & 85.1k & 68.56\% & - \\ PLIF* [15] & Yes & Feedforward & 85.1k & 87.92\% & - \\ GLIF* [15] & Yes & Feedforward & 85.4k & 95.27\% & - \\
**CE-LIF (Ours)** & **Yes** & **Feedforward** & **83.5k** & **98.19\%** & **97.90\%** \\ \hline LIF* & Yes & Recurrent & 155.1k & 84.14\% & 55.13\% \\ LTMD* [15] & Yes & Recurrent & 155.1k & 84.62\% & 54.93\% \\ ALIF [16] & Yes & Recurrent & 156.3k & 98.70\% & 94.30\% \\ PLIF* [15] & Yes & Recurrent & 155.1k & 91.79\% & - \\ GLIF* [15] & Yes & Recurrent & 157.5k & 96.64\% & 90.47\% \\
**CE-LIF (Ours)** & **Yes** & **Feedforward** & **153.9k** & **98.84\%** & **98.14\%** \\ \hline \hline \multicolumn{6}{l}{* Our reproduced results based on publicly available} \\ - & These models are unable to converge & \multicolumn{1}{c}{} \\ N.A. & These results are not publicly available & \multicolumn{1}{c}{} \\ \end{tabular}
\end{table}
Table 1: Comparison of model performance on pixel-level sequential image classification tasks. For both Seq-MNIST and PS-MNIST datasets, the sequence lengths are set to 784.
other, and the model will output the sum after receiving all entries. The mean squared error (MSE) is used as the loss function \(\mathcal{L}\). It is worth noting that the baseline MSE for this task is 0.167, obtained by assuming both entries take an average value of 0.5. The learning curves for the sequence lengths of \(T=100\), \(200\), \(500\), and \(800\) is presented in Figure 5(a-d). We notice that feedforward SNNs comprising CELIF neurons can successfully converge across all sequence lengths. In contrast, the selected baseline models exhibit inferior performance, with LSTM performing better than recurrently connected ALIF. Despite the slower convergence speed, the LSTM model reaches an MSE comparable to that of the CE-LIF model when \(T=100\) and \(200\). However, both models fail to converge for longer sequence lengths. Notably, the CE-LIF model exhibits a slight increase in MSE with increasing sequence length, attributed to the accumulated quantization errors from spike-based representation.
**Copy memory problem** is a classification task with 10 output classes ranging from \(0\) to \(9\). The total input sequence length is \(T+20\), where the key input sequence \(x_{0:10}\) is fed into the model during the first \(10\) timesteps, with each entry uniformly sampled from integer \(1\) to \(8\). For the following \(T\) timesteps, the inputs are set to \(0\). During the last \(10\) timesteps, the model consistently receives an input of \(9\), signifying the decision-making phase, and the model is expected to output \(x_{0:10}\) sequentially during this period. To successfully accomplish this task, the model is anticipated to possess long-term memory that can hold the input \(x_{0:10}\) for a prolonged period of \(T\). To match the spike-based representation in SNNs, we employ one-hot encoding to encode the input values before feeding them into SNNs, with cross-entropy (CE) loss being used as the loss function. Assuming \(y_{0:T+10}=0\) and \(y_{T+10:\text{end}}\) are sampled uniformly at random from \(0\) to \(9\), the baseline loss can be calculated as \(\frac{10\ln(8)}{T+20}\) (Arjovsky, Shah, and Bengio 2016). Figure 5 (e-h) present the learning curves for \(T=100\), \(200\), \(400\), and \(500\). Remarkably, the feedforward SNNs comprising the proposed CE-LIF neurons can converge within 5,000 iterations, even for the challenging case of \(T=500\). In contrast, both the LSTM and ALIF models fail to surpass the baseline value even with the shortest time interval \(T=100\), indicating they can not preserve information beyond the \(T\) time interval.
Figure 4: Comparison of **(a)** learning curves and **(b-d)** loss landscapes among LIF, ALIF, and CE-LIF models. Note that the CE-LIF model adopts a feedforward structure, while LIF and ALIF models use a recurrent one. These structures are chosen to maximize the respective model’s performance. The results in (a) are obtained across three runs with different random seeds.
Figure 5: Learning curves for **(a-d)** adding problem and **(e-h)** copy memory problem.
### Efficacy of CE in Facilitating Long-term TCA
To provide more insights into how long-term temporal relationships have been established in CE-LIF neurons, we provide a visualization in Figure 6 to illustrate the error gradients calculated for CE-LIF, LSTM, and ALIF models during training. All models have been trained on the copy memory problem with \(T=400\), and the gradients \(Grad[t]=\partial\mathcal{L}/\partial S^{l}[t]\) of the last hidden layer are reported. In this task, the inputs that contain the most valuable information are located within the first \(10\) timesteps, while the memory recall occurs during the last \(10\) timesteps. Therefore, an ideal model for this task should be able to establish long-term dependencies between the output error and the distant inputs that are situated \(410\) timesteps away. Noticeably, the CE-LIF model demonstrates an impressive ability to backpropagate gradients to these distant inputs effectively. In contrast, both the ALIF and LSTM models encounter challenges in propagating gradients across such a lengthy interval, although the ALIF model exhibits slightly better performance compared to the LSTM model. This empirical observation aligns with the theoretical analysis presented in the earlier section.
### Ablation Study of Contextual Embedding Design
In the CE-LIF model, the contextual embedding is formulated as the product of \(TE\) and \(V\). Here, we conduct an ablation study to evaluate the effectiveness of this design. The results presented in Table 2 demonstrate that the proposed design outperforms alternative candidates on both benchmarks. Notably, a significant improvement is observed when changing from \(S[t-1]\) used in ALIF to \(V[t-1]\). Furthermore, the accuracy is further improved when multiplying \(V[t-1]\) with the temporal encoding \(TE[t]\) that facilitates the temporal structure modeling. Hence, this study provides compelling evidence regarding the significant effectiveness of the proposed contextual embedding design.
### Visualization of Temporal Encoding
While previous sections have highlighted the superior sequential modeling capabilities of the CE-LIF model, it remains unclear what information is stored in TE that contributes to effective sequential modeling. Therefore, we investigate the learned TE on the Seq-MNIST task. As the heat map presented in Figure 7, the color at each coordinate \((i,j)\) represents the cosine similarity between \(TE[i]\) and \(TE[j]\). Before training, there is no transparent correlation between different time steps. In contrast, the heat map exhibits periodic patterns after training, demonstrating higher similarities between neighboring time steps and time steps that are multiples of 28 apart. This pattern aligns well with the structure of the input image, suggesting that \(TE\)s contribute to the modeling of temporal structure. Furthermore, it is observed that later time steps exhibit broader connections with earlier ones, thus contributing to effective decision-making by incorporating a broader temporal context.
## Conclusion
In this work, we introduced a novel spiking neuron model called CE-LIF, which can enhance the sequential modeling capabilities of SNNs. The theoretical analysis and extensive experimental studies demonstrated the efficacy of the proposed contextual embedding in facilitating long-term TCA, thereby leading to rapid network convergence and superior temporal classification accuracies. Furthermore, our experiments on the copy memory problem demonstrated the significantly increased memory capacity of CE-LIF compared to SOTA ALIF and LSTM models. It, therefore, opens up a myriad of opportunities for solving challenging temporal signal processing tasks with neuromorphic solutions.
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**ID** & \(\mathbf{CE[t]}=\) & **Seq-MNIST** & **PS-MNIST** \\ \hline
1 & \(S[t-1]\) & 68.66\% & 36.64\% \\
2 & \(V[t-1]\) & 87.55\% & 72.60\% \\
3 & \(TE[t]\) & 95.36\% & 90.19\% \\
4 & \(V[t-1]+TE[t]\) & 95.55\% & 89.97\% \\
5 & \(S[t-1]\odot TE[t]\) & 98.61\% & 96.21\% \\
6 & \(\mathbf{V[t-1]\odot TE[t]}\) & **98.84\%** & **98.14\%** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparison of various contextual embedding options in sequential image classification tasks. Note that a feedforward SNN is adopted in this experiment.
Figure 6: Illustration of the \(Grad[t]\) calculated for the ALIF, LSTM, and CE-LIF models in performing long-term TCA.
Figure 7: The cosine similarity between different time steps of \(TE\)**(a)** before training and **(b)** after training. |
2303.15223 | How far generated data can impact Neural Networks performance? | The success of deep learning models depends on the size and quality of the
dataset to solve certain tasks. Here, we explore how far generated data can aid
real data in improving the performance of Neural Networks. In this work, we
consider facial expression recognition since it requires challenging local data
generation at the level of local regions such as mouth, eyebrows, etc, rather
than simple augmentation. Generative Adversarial Networks (GANs) provide an
alternative method for generating such local deformations but they need further
validation. To answer our question, we consider noncomplex Convolutional Neural
Networks (CNNs) based classifiers for recognizing Ekman emotions. For the data
generation process, we consider generating facial expressions (FEs) by relying
on two GANs. The first generates a random identity while the second imposes
facial deformations on top of it. We consider training the CNN classifier using
FEs from: real-faces, GANs-generated, and finally using a combination of real
and GAN-generated faces. We determine an upper bound regarding the data
generation quantity to be mixed with the real one which contributes the most to
enhancing FER accuracy. In our experiments, we find out that 5-times more
synthetic data to the real FEs dataset increases accuracy by 16%. | Sayeh Gholipour Picha, Dawood AL Chanti, Alice Caplier | 2023-03-27T14:02:43Z | http://arxiv.org/abs/2303.15223v1 | # How far generated data can impact Neural Networks performance?
###### Abstract
The success of deep learning models depends on the size and quality of the dataset to solve certain tasks. Here, we explore how far generated data can aid real data in improving the performance of Neural Networks. In this work, we consider facial expression recognition since it requires challenging local data generation at the level of local regions such as mouth, eyebrows, etc, rather than simple augmentation. Generative Adversarial Networks (GANs) provide an alternative method for generating such local deformations but they need further validation. To answer our question, we consider noncomplex Convolutional Neural Networks (CNNs) based classifiers for recognizing Ekman emotions. For the data generation process, we consider generating facial expressions (FEs) by relying on two GANs. The first generates a random identity while the second imposes facial deformations on top of it. We consider training the CNN classifier using FEs from: real-faces, GANs-generated, and finally using a combination of real and GAN-generated faces. We determine an upper bound regarding the data generation quantity to be mixed with the real one which contributes the most to enhancing FER accuracy. In our experiments, we find out that 5-times more synthetic data to the real FEs dataset increases accuracy by 16%.
Facial Expression Recognition, Generative Adversarial Networks, Synthetic data.
## 1 Introduction
Deep learning (DL) has achieved high accuracy performance in various complex tasks including recognition Rakesh et al. (2022), detection Zhou et al. (2022), localization Grumiaux et al. (2022), etc. Yet despite its success, it requires large amounts of labeled data, especially if high performance is required. For instance, considering a Facial Expression Recognition (FER) model trained on a specific Facial Expressions (FEs) dataset, it would not perform as well when applied to a moderately different real-world dataset. This is due to the distribution shift coming from a lack of diversity and biases in the datasets against certain demographic changes Drozdowski et al. (2020) such as race, gender, and age.
Biases in the training data prone trained models towards overfitting as they are optimized over the majority samples (e.g. certain age) represented in the dataset. Hence a low performance is expected over minor samples (e.g. certain races). To address this issue, we argue that having at disposal a diverse dataset would help in overcoming such biases and building a generalizable model. However, acquiring and labeling image and video data is a very expensive and time-consuming task and sometimes it is not even feasible. In this paper, we study the impact of synthetic data generation on the
performance of neural networks. We propose to alleviate the bias issue by testing a data augmentation procedure able to generate balanced and diverse data samples.
Several works da Silva and Pedrini (2015); Gu et al. (2012); Hasani and Mahoor (2017); and Zavarez et al. (2017) routinely performed standard data augmentation using affine transformation (e.g., translation, scaling, rotation, reflection, shearing, cropping, etc.). Standard augmentation does not bring any new information to enrich the training dataset to solve the bias problem. On the contrary, Generative adversarial networks (GANs) Goodfellow et al. (2014) offer the opportunity, to increase the amount of training samples, and to enrich the diversity of the final training set under certain experimental data generation process. In this paper, we consider an FER task and we address and evaluate the use of generated synthetic FEs via GANs to compensate the lack of diversity in FE training databases in an attempt to reduce the bias of the considered FER model and to increase its generalization ability.
Here, we consider a classical CNN classification scheme as it is not our intention to build a novel classifier. However we carefully design the data augmentation scheme based on combining multiple GANs that consider generating: i) new and diverse FEs with new identities and races, various genders, and different ages; ii) various FEs deformation intensities, which makes the generated facial expressions closer to spontaneous human behavior; and iii) balanced dataset where we guarantee that each identity gets the same amount of generated images per emotion class.
To this end, our contributions are:
* We design a method to generate diverse and balanced facial expression deformations.
* We empirically investigate the contribution of synthetic data and their role in improving DL performance.
* We perform a cross-database evaluation to estimate fairly the impact of generated data on the generalizability of the trained model.
The paper is structured as follows: Section 2 discusses related works; Section 3 presents the proposed procedure of building an FER system based on augmented data; Section 4 discusses the experimental results; Finally, Section 5 concludes the paper.
## 2 Related Works
In most traditional research in facial expression recognition, the combination of face appearance descriptors used to represent facial expressions with deep learning techniques is considered to overcome the difficult factors for FER. Regardless, due to the small size of public image-labeled databases, Data Augmentation (DA) techniques are often used to increase the size of the database. In addition to DA geometric transformations, more complex guided augmentation methods can be used for DA, such as GAN. In Yi et al. (2018), a conditional GAN is used to generate images to augment the FER2013 dataset. A CNN is used to train the predictive model, and the average accuracy increased by 5% after applying the GAN DA technique. Chu et al. (2019) proposed an FER method based on Contextual GAN. Chu's model uses a contextual loss function to enhance the facial expression image and a reconstruction loss function to retain the subject's identity information in the expression image. Experimental results with the extended CK+ database Lucey et al. (2010) show that Chu's method improves recognition performance by 7%. However, neither Yi's nor Chu's studies perform cross-database evaluation nor consider the generation of balanced synthetic FEs classes. Porcu et al. (2020) experimented with the combination of various data augmentation approaches, such as using synthetic images, and discovered that a combination of synthetic data with horizontal reflection, and translation can increase the accuracy by approximately 30%. They performed cross-database evaluations by training their model on an "augmented" KDEF database Lundqvist et al. (1998) and testing it on two different databases (CK+ and ExpW Zhanpeng Zhang and Tang (2016)). Unlike them, we design our method to consider a diverse but balanced generation of FE classes and create our experimental setup to resemble fair performance metrics.
## 3 Data Modality
Generative Adversarial Networks are used to generate different FEs for training our FER algorithm. Our model design splits into three different compartments: the data generation stage, the CNN classifier training stage, and the inference stage.
### Dataset Generation Process
Our data generation process relies on using two GANs on top of each other. One is for new identity generation while the other is used to impose the generation of local FEs. First, we generate new identities with new facial features using
the StyleGAN model of Karras et al. (2020) that randomly generates realistic human faces. Additionally, since we want to compare the performance of our FER model trained with both real or generated facial features, we build a database that resembles existing public databases. In those public datasets, subjects pose different expressions in front of a fixed-setting camera. For this reason, we build a novel method that jointly uses StyleGAN and StarGAN on top of each other as a way to reinforce the FEs generation process over new identities. However, due to the randomness of the StyleGAN model and the desirability of a balanced training set, we use the structure of a StarGAN model Choi et al. (2017) for image-to-image translation with different settings to artificially synthesize the six Ekman emotions (anger, disgust, fear, happiness, sadness, and surprised) on a single generated identity. We train the StarGAN model with the spontaneous public database Affectnet-HQ Mollahosseini et al. (2019) since this database captures images from various settings, and from lots of people through the internet. We use the trained model to generate facial expressions on both real face images and StyleGAN generated face images as shown in figure 1. The final result of using the image-to-image translation StarGAN model to synthesize different expressions for a given real or generated identity is shown in figure 2. As we can see, there are several artifacts in the output images, which are mainly found on the outer part of the face. However, these artifacts are not important in our task since we only focus on facial features for facial expression recognition. During this process, we generated 100,000 identities and synthesized 6 basic emotions on each of them. Finally, with some preprocessing (face cropping, gray-scale, and resizing), we generated the balanced dataset illustrated in figure 3.
### Convolutional Neural Network
In the second stage of our method, we design a CNN classifier whose architecture is summarized in table 1. Our purpose is to use a simple yet effective classifier in order to focus our attention on the contribution of GAN-generated images with respect to model enhancement. To avoid the overfitting effect, we use drop-out layers.
In the first experiment, the CNN classifier is trained on the two facial expression public databases (RaFD Langner et al. (2010), and Oulu-CASIA Zhao et al. (2011)) labeled with the 6 basic Ekman emotions. In the second experiment, the CNN model is trained again from scratch using only generated facial expressions. These two control experiments serve as baselines. Finally, we re-train the CNN model again by gradually augmenting the public databases with images of generated FEs with the same number of identities each time.
### Testing Phase
To fairly evaluate the performance of our method, we split the real and generated database to create a test database. About 17% of the data that are created are used for testing purposes. Although these test datasets are necessary to assess the model's performance, the similarity in distribution between the test and train sets makes it difficult to determine the exact contribution of the generated data to the model's performance. To ensure a fair analysis of the results and prevent bias in model prediction, it is important for our settings to perform a cross-database evaluation in which our test data resemble zero correlation with training sets. Hence, to have a fixed reference test dataset to compare all the models, we use the MMI database Pantic et al. (2005) which is completely blind to the training process.
Figure 1: Two samples of facial features.
Figure 2: Examples of synthetic facial expressions. In the top row, the StarGAN model acts on an actual human face. In the bottom row, the model works with a generated identity.
## 4 Results and Analysis
In the following, we present the results of three experiments with different settings and designs. RaFD Langner et al. (2010) and Oulu-CASIA Zhao et al. (2011) real databases have been used in experiments 1 and 3. Alternatively, in experiment 2 we use only synthetic data, and these synthetic data are also used in experiment 3 for further analysis.
### Experiment 1 - Training with real data
In this first baseline experiment, the CNN classifier for the FER model has been trained with real face images coming from RaFD and Oulu-CASIA which in total have 144 subjects. Here, we use 109 subject images with 6 basic emotions for training, 10 for validation, and 25 for testing. From these data, we only consider the frontal faces that are associated with emotional labels.
Our trained CNN classifier achieves 69.6% of accuracy when it is tested over 25 subjects. However, we observe overfitting because our model achieves 84.5% in the training phase. By applying a cross-database evaluation using the MMI database Pantic et al. (2005), the obtained accuracy drops to 45% which is expected due to the limited number of subjects we have in the training dataset. Next, we analyze each class separately to get an insight into the classes' separability. Figure 4 presents the associated confusion matrix. Based on this map, the "Happy" emotion has the best performance and the "Disgust" class is also showing a good performance compared to other classes of emotions. While this confusion matrix provides a comprehensive overview of each class, it is unnormalized, making later comparisons difficult. To analyze the results of the cross-database evaluation on the MMI database in a more detailed manner, in a second step, we measure three metrics (precision, recall, and F1-score) to explore the model's prediction with the annotations provided for the MMI database. Figure 5 presents these metrics results for each class of emotions. It can be noticed that the model trained on real facial features has the most difficulty at recognizing the "Sad" class, while the other classes are not showing a good performance either. Despite having two real databases for training, this model fails to perform adequately. As a result, adding more data to the training is necessary and we argue that adding synthetic data might aid in overcoming the overfitting and also in lifting up the accuracy rate.
\begin{table}
\begin{tabular}{|c|c c c c c|} \hline & Layer & input & number of filters & Pool size & Activation function \\ \hline
1 & Conv2D & \(64\times 64\times 1\) & 32 & & Relu \\
2 & Conv2D & \(64\times 64\times 32\) & 64 & & Relu \\
3 & Max Pooling & \(64\times 64\times 64\) & & \(2\times 2\) & \\ \hline
4 & \multicolumn{4}{|c|}{Drop out 25\%} & \\ \hline
5 & Conv2D & \(32\times 32\times 64\) & 128 & & Relu \\
6 & Max Pooling & \(32\times 32\times 128\) & & \(2\times 2\) & \\
7 & Conv2D & \(16\times 16\times 128\) & 128 & & Relu \\
8 & Max Pooling & \(16\times 16\times 128\) & & \(2\times 2\) & \\ \hline
9 & \multicolumn{4}{|c|}{Drop out 25\%} & \\ \hline
10 & \multicolumn{4}{|c|}{Flatten} & \\
11 & \multicolumn{4}{|c|}{Dense **1024**} & & Relu \\ \hline
12 & \multicolumn{4}{|c|}{Drop out 50\%} & \\ \hline
13 & \multicolumn{4}{|c|}{Dense **6**} & \multicolumn{2}{|c|}{Softmax} \\ \hline \end{tabular}
\end{table}
Table 1: Model summary of the considered CNN-based model for Facial Expression Recognition.
Figure 3: Samples of generated FEs either on a real face or on a generated one.
### Experiment 2 - Training with synthetic generated data
In the second experiment, we follow the same protocol. The only difference is that we are using synthetic facial images as the training dataset. We consider the same number of synthetic identities as in the real dataset in the first experiment (109 identities). These identities are generated with the process presented in section 3.1. For each identity, all six basic emotions exist in the dataset. Training our model with this synthetic dataset, the accuracy reaches 99.84% during the training process and 97.6% while testing on the synthetic dataset. Also, no overfitting is observed in this experiment. Although these results show a significant improvement, performing the cross-database evaluation on the MMI database is not that promising. On the MMI database, the obtained accuracy drops to 47% showing nearly the same performance as the model trained in experiment 1.
Figure 6 presents the confusion matrix of the model trained with the synthetic dataset for the MMI database to discover whether the model trained on synthetic data has similar classifying difficulties as the model trained on real data. Comparing the Confusion Matrix in figures 4 and 6 we notice:
1. There has been a huge improvement in recognizing the class "Surprised", 620 samples instead of 187 samples.
2. We can observe improvements in the recognition of the "Angry" class, 251 samples instead of 187.
3. As compared to the CNN classifier trained on real faces, we see some drop in the "Disgust", "Fear", and "Sad" classes, but both models seem to have similar difficulties.
Also based on the presentation of precision, recall, and F1-score in figure 7, it appears the recall scores have decreased for most classes. We can therefore say that except for the "Surprised" class, the CNN model trained on synthetic data alone is unable to match the actual facial expressions annotations provided in the MMI database. The results of our current experiment prove that synthetic datasets can achieve similar performance as real datasets. Hence our final aim is to increase the dataset size to improve the performance at all class levels. In this case, we hope that the combination of these two databases will help solve such problems.
Figure 4: Confusion Matrix on the MMI database in experiment one.
Figure 5: Precision, recall, and F1-score on the MMI database obtained on the CNN model trained with real faces only (cf. experiment 1).
### Experiment 3 - Training with augmented datasets
In the last experiment, we augment the Real Facial Expressions (RFEs) dataset of experiment 1 with Generated Facial Expressions (GFEs). The number of generated identities in each unit is the same as the number in the real database used for experiment 1 (109 identities for training, 10 identities for validation, and 25 identities for testing). As an example, RFEs + 2 \(\times\) GFEs is the extension of the real FEs with two units of generated FEs (109 real identities + 218 generated identities for training). Each of the augmented datasets is split into training, validation, and test sets. And the CNN model is trained on each dataset individually. Each augmented dataset is represented in table 2 indicating the model accuracy during training and testing. The results demonstrate that adding more synthetic FEs to the training set results in constant improvement of training and testing accuracies. The study also reports no evidence of overfitting.
The cross-database evaluation on the MMI database is then performed for further validation and figure 8 shows the accuracy obtained from each trained model. Note that the first two points are the result of cross-database evaluation obtained in experiments 1 and 2 respectively. According to this figure, the highest accuracy corresponds to the model trained on the RFEs + 5 \(\times\) GFEs dataset with 58.3%. This performance from the model trained on the 5th augmented dataset indicates a 13% gain in response to the model trained in experiment 1 (with real FEs). But beyond this point,
\begin{table}
\begin{tabular}{c c c} \hline \hline & Training accuracy & Testing accuracy \\ \hline RFEs + GFEs & 91\% & 85.3\% \\ RFEs + 2 \(\times\) GFEs & 93.8\% & 89\% \\ RFEs + 3 \(\times\) GFEs & 94.8\% & 92.7\% \\ RFEs + 4 \(\times\) GFEs & 95.8\% & 92.5\% \\ RFEs + 5 \(\times\) GFEs & 97.6\% & 94.3\% \\ RFEs + 6 \(\times\) GFEs & 97.8\% & 94\% \\ RFEs + 10 \(\times\) GFEs & 97.9\% & 95.1\% \\ RFEs + 15 \(\times\) GFEs & 98.9\% & 95.5\% \\ RFEs + 20 \(\times\) GFEs & 98.9\% & 97\% \\ \hline \hline \end{tabular}
\end{table}
Table 2: Accuracy of the model trained on augmented datasets (Real Facial Expressions (RFEs) augmented by Generated Facial Expressions (GFEs)).
Figure 6: Confusion Matrix on MMI database in experiment two.
Figure 7: Precision, recall, and the F1-score on the MMI database for the model trained in experiment two (section 4.2).
the accuracy drops significantly due to a catastrophic forgetting mode caused by the large number of synthetic facial features in the training set overwhelming the facial features of the real face database.
To see the improvement of our best model (RFs + 5 \(\times\) GFFs) in each class separately, we present the confusion matrix and the calculated precision, recall, and F1-score metrics on the MMI database in figures 9 and 10 respectively. It appears that the "Sad" class performs significantly better than the two baseline experiments in all three metrics. Based on the recall scores in all classes, we can conclude that this trained model matches facial expressions in the MMI database to their actual annotations better than other trained models. In contrast with the model trained in experiment 1 (training set of real FEs), only the "Anger" class's performance decreases. In conclusion, based on our observation, we can say that generated data along with the real facial features is helping the model's recognition ability.
Furthermore, there is no limit to the number of identities we can generate. But there is a point beyond which adding new generated FEs no longer improves the results. We have observed experimentally that there is an upper limit in augmentation in relation to the size of the real face database.
Figure 8: The result of cross-database evaluation on the MMI database. RFEs is referring to Real Facial Expressions and GFFs is referring to Generated Facial Expressions.
Figure 10: Precision, recall, and F1-score on the MMI database for the model trained on the RFEs + 5 \(\times\) GFFs database in experiment three (section 4.3).
Figure 9: Confusion Matrix on MMI database in experiment three with the model trained on RFEs + 5 \(\times\) GFFs database.
### Comparison with the state-of-the-art
As a final step in this study, we compare our results with state-of-the-art findings. We use the VGG16 tool to calculate the accuracy of the FER VGG16 model on the MMI database. With that model, we achieve 54.08% accuracy while our best CNN-based model reaches 58.3% in accuracy. Through the use of synthetic facial features and a simpler model, we enhance the accuracy by 4%.
Many state-of-the-art studies have reported their evaluation results on the CK+ database. Nevertheless, we did not use the CK+ database in our training or testing processes. Therefore, in order to perform the comparison, we evaluate our best model performance on the CK+ database and the result is presented in table 3. It can be seen that the approach proposed by Zavarez et al. (2017) is the only one that outperforms our proposed CNN model. However, the difference is only 1.09% while they trained their model using 6 different public databases and some classical data augmentation techniques. Whilst our results are achieved with smaller training datasets using only two public databases and GAN images which makes our results more outstanding. In addition, compared to the study in Porcu et al. (2020) that is explained in section 2, even though their model's accuracy increased by 30%, our model had more promising results based on this cross-database evaluation.
Figure 11 shows the result of our CNN-based model in the cross-database evaluation on the CK+ database. For this database, we achieve an accurate model for most of the classes even though there is no record of this public database in our training data.
During this study, we replaced the MMI database with the CK+ database for cross-database evaluation. As a result, model performance increased by 16% rather than the 13% gain we previously achieved. While it is undeniable that generated data is a costless method that can help improve FER model accuracy, the exact gain would be determined by the test databases in applications.
Figure 11: Confusion Matrix on CK+ database.
\begin{table}
\begin{tabular}{|c|l|l|l|} \hline & Method & Training Database & Accuracy \\ \hline
1 & Proposed method & RaFD + Oulu-CASIA +GAN & **87.49\%** \\ \hline
2 & Porcu et al. (2020) & KDEF & 53.30\% \\ \hline
3 & da Silva and Pedrini (2015) & MUG & 45.60\% \\ \hline
4 & da Silva and Pedrini (2015) & JAFFE & 48.20\% \\ \hline
5 & da Silva and Pedrini (2015) & BOSPHOROUS & 57.60\% \\ \hline
6 & Lekidoui et al. (2017) & KDEF Lundqvist et al. (1998) & 78.85\% \\ \hline
7 & Gu et al. (2012) & JAFFE & 54.05\% \\ \hline
8 & Hasani and Mahoor (2017) & MMI+FERA & 73.91\% \\ \hline
9 & Molahosseini et al. (2016) & MultiPIE Gross et al. (2008), MMI, CK+, DISFA Mavadati et al. (2013), FERA Valstar et al. (2017), SFEW Dhall et al. (2011), and FERA2013 & **85.58\%** \\ \hline
10 & Zavarez et al. (2017) & CK+, JAFFE, MMI, RaFD, KDEF, BU-3DFE Yin et al. (2006), and ARFace Martinez and Benavente (1998) & **85.58\%** \\ \hline \end{tabular}
\end{table}
Table 3: Comparison among state-of-the-art cross-database experiments tested on the CK+ database.
## 5 Conclusions
The purpose of this study was to investigate how generated data could be used to augment the data in a deep learning model to improve its performance. We chose a simple facial expression recognition model for this proposal. Our synthetic balanced dataset was created using two GAN models to test the potential improvement of the FER model performance. With real databases, synthetic datasets, and augmented datasets, we trained the CNN classifier multiple times for the FER task.
Our study confirms that enriching the training dataset with GAN images can improve CNN classifier performance. Training and cross-database evaluation performances were improved by augmenting real databases with synthetic facial features. In comparison to a model trained solely from real facial images, our best model shows a 16% increase in accuracy. On the same database, we also compared our results with the state-of-the-art and computed the accuracy of the VGG16 model, achieving 4% higher accuracy.
For further study, we propose to first augment the training database with additional real facial expressions. This will enable us to improve the performance of the model, as it would also let us augment more GAN images. Secondly, we propose to enrich the VGG16 database with our generated dataset to see if we can improve the performance of the VGG16 model as well. And third, we would like to study the potential performance increase for other applications related to facial models.
**Material, codes, and Acknowledgement:** Results can be reproduced using the code available in the GitHub repository [https://github.com/sayeh1994/synthesizin_facial_expression](https://github.com/sayeh1994/synthesizin_facial_expression) and [https://github.com/sayeh1994/Facial-Expression-Recognition](https://github.com/sayeh1994/Facial-Expression-Recognition). Most of the computations presented in this paper were performed using the Gricad infrastructure ([https://gricad.univ-grenoble-alpes.fr](https://gricad.univ-grenoble-alpes.fr)), which is supported by Grenoble research communities.
|
2301.10536 | Understanding and Improving Deep Graph Neural Networks: A Probabilistic
Graphical Model Perspective | Recently, graph-based models designed for downstream tasks have significantly
advanced research on graph neural networks (GNNs). GNN baselines based on
neural message-passing mechanisms such as GCN and GAT perform worse as the
network deepens. Therefore, numerous GNN variants have been proposed to tackle
this performance degradation problem, including many deep GNNs. However, a
unified framework is still lacking to connect these existing models and
interpret their effectiveness at a high level. In this work, we focus on deep
GNNs and propose a novel view for understanding them. We establish a
theoretical framework via inference on a probabilistic graphical model. Given
the fixed point equation (FPE) derived from the variational inference on the
Markov random fields, the deep GNNs, including JKNet, GCNII, DGCN, and the
classical GNNs, such as GCN, GAT, and APPNP, can be regarded as different
approximations of the FPE. Moreover, given this framework, more accurate
approximations of FPE are brought, guiding us to design a more powerful GNN:
coupling graph neural network (CoGNet). Extensive experiments are carried out
on citation networks and natural language processing downstream tasks. The
results demonstrate that the CoGNet outperforms the SOTA models. | Jiayuan Chen, Xiang Zhang, Yinfei Xu, Tianli Zhao, Renjie Xie, Wei Xu | 2023-01-25T12:02:12Z | http://arxiv.org/abs/2301.10536v1 | # Understanding and Improving Deep Graph Neural Networks:
###### Abstract
Recently, graph-based models designed for downstream tasks have significantly advanced research on graph neural networks (GNNs). GNN baselines based on neural message-passing mechanisms such as GCN and GAT perform worse as the network deepens. Therefore, numerous GNN variants have been proposed to tackle this performance degradation problem, including many deep GNNs. However, a unified framework is still lacking to connect these existing models and interpret their effectiveness at a high level. In this work, we focus on deep GNNs and propose a novel view for understanding them. We establish a theoretical framework via inference on a probabilistic graphical model. Given the fixed point equation (FPE) derived from the variational inference on the Markov random fields, the deep GNNs, including JKNet, GCNII, DGCN, and the classical GNNs, such as GCN, GAT, and APPNP, can be regarded as different approximations of the FPE. Moreover, given this framework, more accurate approximations of FPE are brought, guiding us to design a more powerful GNN: coupling graph neural network (CoGNet). Extensive experiments are carried out on citation networks and natural language processing downstream tasks. The results demonstrate that the CoGNet outperforms the SOTA models.
## 1 Introduction
Graphs have received increasing attention in recent years, driving the unprecedented development of graph neural networks (GNNs). In particular, neural graph-based models are applied to various downstream tasks such as biology [1, 16], social analysis [13], and computer vision [14, 15, 16]. However, it has been observed that classical GNNs like GCN and GAT achieve the best performance in most downstream tasks at only a two-layer network. With the network depth increasing, the performance drops rapidly.
Hence, a profusion of work tries to tackle the performance degradation problem. These deep GNN models design various feature propagation processes based on the message-passing mechanism of GNN. For instance, JKNet [11] flexibly adjusts the neighbor range of each node by using a layer aggregation network architecture. Another excellent model Deep Adaptive Graph Neural Network decouples transformation and propagation to leverage larger receptive fields. GCNII [2] adds Initial residual and Identity mapping based on GCN, extending GCN to a \(k\)-th order of polynomial filter. Despite fruitful achievements, these works study GNNs from various perspectives, including the spatial and spectral domains that have garnered the most attention in recent years. Driven by the different interpretations of GNNs, a question arises: Is there a framework that can interpret these deep GNNs uniformly? If such a framework exists, we can leverage it to understand the performance degradation problem of classical GNNs more in-depth and identify the weakness of the existing deep GNNs to facilitate their development.
In this paper, we understand graph convolution from a probabilistic perspective and develop a general interpretation framework for deep GNNs. GNNs and probabilistic graphical models (PGMs) are prominent tools for studying structured data. [15] note the iterative propagation scheme of variational inference in PGMs, which provides an intuitively appealing direction for connecting GNNs. Thus, we start from the variational inference of Markov random fields and obtain its iterative solution embedded in the Hilbert space. Inspired by the close connection between GNNs and the first-order Taylor expansion of the iterative solution, we establish a unified framework for representing different GNNs and their deep variants. We then incorporate some popular deep graph networks, such as JKNet, DGCN, and GCNII [11, 12, 2], into the developed theoretical framework with the help of high-order Taylor approximation. Furthermore, with the proposed framework, we analyze the performance degradation problem and design a more effective model, the Coupling Graph Neural Network (CoGNet). Through extensive experiments on three semi-supervised node classification benchmarks and natural language processing downstream tasks, including text classifica
tion and multi-hop question answering, we demonstrate that the CoGNet achieves strong performances in both shallow and deep network layers, including multiple SOTA results.
## 2 Related Work
### Graph Neural Networks
Graph Neural Network (GNN) is a framework for graph representation learning. The basic GNNs follow a neural message-passing mechanism. They exchange messages between connected nodes and update node features using neural networks. In the past few years, some baseline GNN models, such as GCN, GIN, and GAT [2, 14, 15, 16], have been proposed and achieved great popularity. These models have been successfully applied to many downstream tasks, including recommender systems [17, 11], drug analysis [15], community detection [2, 14, 16], etc.
However, these GNN models are known to suffer from performance degradation when deepening the network structures. This phenomenon may be caused by problems such as over-parameterization, over-smoothing, and weak generalization of the model. Many works on improving the performance of deep GNN models have been proposed recently. Jumping Knowledge Network [14] is one of the earliest deep GNNs, combining the node representations of each layer at the last layer. Another excellent model DAGNN [14] adaptively incorporates information from large receptive fields. Recently, DropEdge [13] randomly mutes a certain number of edges during each training epoch to alleviate the over-smoothing issue. Other deep models, such as GCN-NII [2] and DGCN [12], have also achieved good performance. However, these models design their propagations from different perspectives, and a unified language is lacking to describe them.
### Interpretability of GNNs
Theoretical interpretability has become a focus of research on graph representation learning. As a generalization of convolution on graph-structured data, graph convolution has inspired many works to explore GNNs from the spectral perspective. [11] shows that the propagation process of the GCN is a low-pass filter and attributes performance degradation to the over-smoothing problem. [15] understands GNNs as graph signal denoising. Graph wavelet neural network [14] uses graph wavelets to replace the Fourier basis in GCN. [1, 16, 17] design the network aggregation from the perspective of spectral filters. Another line of work analyzes the connections between GNNs and graph isomorphism testing. [14] proves that message-passing GNNs are no more powerful than the Weisfeiler-Lehman (WL) algorithm [15] when given discrete information as node features. [16] shows that the expressive power of \(K\)-hop message passing is bounded by 3-WL test. Most recently, several works have been devoted to generalizing deep learning theory to graph machine learning. [16] uses Neural Tangent Kernel to analyze infinitely wide multi-layer GNNs trained by gradient descent. [2] explores generalization in GNNs through VC Dimension based generalization error bounds. In this work, we understand GNNs from a novel probabilistic perspective and analyze their intrinsic connections.
## 3 GNNs as Embedded Graphical Models
In this section, we establish the connections between the GNN models and the probabilistic inference in graphical models. We first introduce the notations used throughout the paper.
**Notations.** Given a weighted undirected Graph \(G=(V,E)\) with \(n\) nodes \(v_{i}\in V\) and edges \((v_{i},v_{j})\in E\), let \(\mathbf{A}\in\mathbb{R}^{n\times n}\) denote the adjacency matrix and \(\hat{\mathbf{D}}\) denote the diagonal degree matrix, i.e., \(\mathbf{D}_{ii}=\sum_{(v_{i},v_{j})\in E}\mathbf{A}_{ij}\). Let \(\hat{\mathbf{A}}=(\mathbf{D}+\mathbf{I}_{n})^{-\frac{1}{2}}\left(\mathbf{I}_{n }+\mathbf{A}\right)(\mathbf{D}+\mathbf{I}_{n})^{-\frac{1}{2}}\) denote a normalized variant of the adjacency matrix (with self-loops). We denote the node feature matrix as \(\mathbf{X}\in\mathbb{R}^{n\times d}\) for a \(d\)-dimensional feature vector \(\mathbf{x}_{i}\) associated with each node \(v_{i}\) and use \(\mathcal{N}(i)\) to represent the set of neighboring nodes of node \(v_{i}\) (including itself).
We next introduce message passing in graphical models. Our starting point is structured data modeled with the PGM. Markov random field is a PGM based on an undirected graph. It is especially suitable for handling high-dimensional data with graph structure. With the conditional independence assumptions of graph structure, we can simplify the joint distribution \(p\) over some set of discrete random variables \(\mathcal{X}=\{x_{1},...,x_{n}\}\), and then solve it by optimization. Considering an undirected Graph \(G\), we introduce latent variable \(z_{u}\) associated with each node \(u\). The input node features \(\mathbf{X}\in\mathbb{R}^{n\times d}\) is the observed variable. The aim is to find conditional distributions \(p\left(\mathbf{z}\mid\mathbf{X}\right)\) over latent variables \(\mathbf{z}=\{z_{1},\cdots,z_{n}\}\) so that we can make inference.
For a Markov random field with graph \(G\), computing the posterior \(p\) is a computationally intractable task. Mean-field variational inference, one of the most popular approximate inference techniques, is employed here for approximation:
\[p\left(z_{1},\cdots,z_{n}\mid\mathbf{X}\right)\approx\prod_{i=1}^{n}q_{i} \left(z_{i}\right). \tag{1}\]
By minimizing the free energy between the approximate posterior \(q\) and the true posterior \(p\), we obtain the optimal distribution \(q^{*}\). It's hard to find a direct solution to this optimization problem. [20] shows that the above optimization problem satisfies the following fixed point equations:
\[\log q_{i}^{*}\left(z_{i}\right)=c+\log\left(\phi\left(z_{i},x_{i}\right) \right)+\sum_{j\in\mathcal{N}(i)}\sum_{z_{j}}q_{j}^{*}\left(z_{j}\right)\log \left(\psi\left(z_{i},z_{j}\right)\right),\]
where \(c\) is a constant, \(\psi\) and \(\phi\) are non-negative potential functions. The above equation exhibits the relationship between marginals of adjacent nodes, and we can obtain its iterative
form solution:
\[\log q_{i}^{(l+1)}\left(z_{i}\right)= c_{i}^{(l)}+\log\left(\phi\left(z_{i},x_{i}\right)\right)\] \[+\sum_{j\in\mathcal{N}(i)}\sum_{z_{j}}q_{j}^{(l)}\left(z_{j}\right) \log\left(\psi\left(z_{i},z_{j}\right)\right), \tag{2}\]
where \(q_{i}^{*}(z_{i})=\underset{l\rightarrow\infty}{\lim}q^{l}(z_{i})\). We can abbreviate Eq. (2) as:
\[q_{i}^{(l+1)}\left(z_{i}\right)=\mathcal{F}_{i}\left(z_{i},q_{j}^{(l)}\left(z _{j}\right)\right),\quad j\in\mathcal{N}(i). \tag{3}\]
Here \(\mathcal{F}_{i}(\cdot)\) is a function determined by the potential functions. Note that these potential functions are defined on the clique where node \(i\) is located. Eq. (3) establishes an iterative update formula to aggregate the neighbor information. And [1] further mapped it to a high-dimensional space with the help of Hilbert space embedding, thus linking the high-dimensional data and the low-dimensional structure. They map distributions \(q(z)\) into Hilbert space using some injective functions \(\phi_{\alpha}\). As a result, we can obtain the embedding \(\mu_{z_{i}}\) in Hilbert space by \(\mu_{z_{i}}:=\int_{z_{i}}\phi_{\alpha}(z_{i})q_{i}(z_{i})dz_{i}\).
**Theorem 1**.: _[_1_]_ _Given a finite-dimensional feature map \(\phi\) that maps \(p(x)\) to \(\mu\), if \(\phi\) is injective, then any function that applies on p(x) is equivalent to computing a corresponding function on \(\mu\)._
According to Theorem 1, we can denote the function corresponding to \(\mathcal{F}_{i}\) in Eq. (3) after the kernel embedding as \(\tilde{\mathcal{F}}_{\alpha}\). For the recursive expression of \(q_{i}\) (Eq. (3)), we have the following iterative formula after Hilbert space embedding:
\[u_{i}^{(l)}=\tilde{\mathcal{F}}_{\alpha,i}\left(u_{j}^{(l-1)},j\in\mathcal{N }(i)\right). \tag{4}\]
In order to have a more straightforward distinction, we use \(\ell\) to denote the number of network layers in graph networks and \(l\) to represent the number of iterations.
Following the breakthrough work of [1], several papers put forward further discussions. [1] find the theoretical connection between message-passing GNN and mean-field variational inference. This inspires us to apply the idea to analyzing GNNs and explore it further. For simplicity of derivation, we start from the assumption that \(u_{i}\) is unidimensional. We denote \(\mathbf{U}_{i}\in\mathbb{R}^{m\times 1},m=\left|\mathcal{N}(i)\right|\), as the vector consisting of the neighbourhoods of node \(i\):
\[\mathbf{U}_{i}^{(l)}=\left[u_{1}^{(l)},u_{2}^{(l)},...,u_{m}^{(l)}\right]^{ \top},\quad m\in\mathcal{N}(i). \tag{5}\]
where \(u_{m}^{(l)}\) is the \(m\)-th entrie of vector \(\mathbf{U}_{i}^{(l)}\). Now we can give the Taylor expansion of Eq. (4) at \(\mathbf{U}_{i}^{(l)}=\mathbf{0}\) as:
\[u_{i}^{(l)}= \tilde{\mathcal{F}}_{\alpha,i}(\mathbf{0})+\tilde{\mathcal{F}}_{ \alpha,i}^{\prime}(\mathbf{0})\mathbf{U}_{i}^{(l-1)}+\frac{1}{2}\mathbf{U}_{i }^{(l-1)^{\top}}\tilde{\mathcal{F}}_{\alpha,i}^{\prime\prime}(\mathbf{0}) \mathbf{U}_{i}^{(l-1)}\] \[+\cdots+\frac{\tilde{\mathcal{F}}_{\alpha,i}^{n}(\mathbf{0})}{n! }\left[\mathbf{U}_{i}^{(l-1)}\right]^{n}+o\left[\mathbf{U}_{i}^{(l-1)}\right]^ {n}. \tag{6}\]
We denote the \(n^{th}\) order derivative by \(\tilde{\mathcal{F}}_{\alpha,i}^{n}\). The value of \(\tilde{\mathcal{F}}_{\alpha,i}^{n}(\mathbf{0})\) is node-specific. Actually, we can already find the connection between the probabilistic graph model and the GNN through Eq. (6). The embedded high-dimensional variables and the iterative message-passing mechanism match perfectly with GNN. To make it more understandable, in the following, we briefly analyze the first-order approximation of Eq. (6):
\[u_{i}^{(l)}\approx\tilde{\mathcal{F}}_{\alpha,i}(\mathbf{0})+\tilde{\mathcal{ F}}_{\alpha,i}^{\prime}(\mathbf{0})\mathbf{U}_{i}^{(l-1)}, \tag{7}\]
where \(\mathbf{U}_{i}^{(l-1)}\) consists of its neighbors and \(u_{i}^{(l)}\) corresponds to the embedding of conditional probability \(q_{i}\) in the Hilbert space. We can find that Eq. (7) satisfies the recursive message-passing mechanism. \(\tilde{\mathcal{F}}_{\alpha,i}^{\prime}(\mathbf{0})\mathbf{U}_{i}^{(l-1)}\) is an inner product term, which aggregates neighbors \(u_{j}^{(l-1)}\) (including \(u_{i}^{(l-1)}\)) after multiplying by the coefficients:
\[u_{i}^{(l)}\approx\tilde{\mathcal{F}}_{\alpha,i}(\mathbf{0})+\sum_{j\in \mathcal{N}(i)}f_{ij}\cdot u_{j}^{(l-1)}, \tag{8}\]
where \([f_{ij},j\in\mathcal{N}(i)]^{\top}\triangleq\tilde{\mathcal{F}}_{\alpha,i}^{ \prime}(\mathbf{0})\). This form is exactly consistent with the neural message-passing mechanism of GNN.
## 4 A Unified Framework
In the previous section, we elaborate message-passing mechanism of GNN from the perspective of inference on PGMs. According to Eq. (8), we can find that the vanilla GNN is equivalent to the first-order approximation of Eq. (6). In this section, we establish a unified framework to interpret existing GNN baselines and some well-designed deep GNN variants.
The formula of variational inference after embedding into Hilbert space exhibits a close connection with the mechanism of GNNs. Eq. (4) aggregates neighborhood variables and updates its own variable, which is the same as the key core of neural message-passing. This implies that different GNN propagation mechanisms are different approximations of the function \(\tilde{\mathcal{F}}_{\alpha,i}\). With the help of Taylor expansion Eq. (6), we can understand this framework more clearly. In the following, we theoretically prove that the propagation mechanisms of some popular GNN variants can be seen as fitting different order approximations of Eq. (6).
### Interpreting GCN and SGC
Graph Convolutional Network (GCN) is a popular baseline GNN inspired by spectral graph convolutions. We show the definition of vanilla graph convolution [12] with bias as follows:
\[h_{i}^{(\ell)}=\sigma\left(b_{i}^{(\ell)}+\sum_{j\in\mathcal{N}(i)}\frac{w_{j}^ {(\ell)}}{\sqrt{d_{i}d_{j}}}h_{j}^{(\ell-1)}\right). \tag{9}\]
A \(k\)-layer GCN can aggregate the messages of \(k\)-hop neighbors. Simplifying Graph Convolutional Network (SGC) removes nonlinearity activation in GCN while doing propagations. We will discuss the effect of nonlinearity activation in Section 4.5. Here we assume that nonlinearity activations do not significantly affect the network and analyze the two similar models, SGC and GCN, together.
As a basic message-passing neural network, GCN naturally satisfies the form of Eq. (8). To be specific, \(\tilde{\mathcal{F}}_{\alpha,i}\) is determined by the potential functions defined on the clique, but since the kernel mapping \(\phi_{\alpha}\) is undetermined, the learnable weights \(w\) coming with clique-related constants \(d_{i},d_{j}\) are used to approximate it. On the other hand, the bias in Eq. (9) corresponds to the constant term in Eq. (8). The specific equivalence is as follows:
\[h_{i}^{(\ell)}\Rightarrow u_{i}^{(l)},\quad b_{i}\Rightarrow\tilde{\mathcal{ F}}_{\alpha,i}(\mathbf{0}),\quad\frac{w_{j}^{(\ell)}}{\sqrt{d_{i}d_{j}}} \Rightarrow f_{ij}.\]
The aggregation layer of the GCN is inherently connected to the first-order approximation of Eq. (6). Through the analysis in Section 5.1, we will find that such a propagation process will deteriorate the performance after the network structure is deepened.
### Interpreting GAT
Graph attention network (GAT) [20] applies a popular attention mechanism to the aggregation layer. It uses attention weights to weigh aggregate neighbor messages. The ways to parameterize the attention weights \(\alpha\) can be dot product or feedforward neural network. The layers of the GAT-styled model can be represented as follows:
\[\begin{split} h_{i}^{(\ell)}=\sigma\left(\sum_{j\in\mathcal{N}( i)}\alpha_{ij}w_{j}h_{j}^{(\ell-1)}\right),\\ \alpha_{ij}=\text{Softmax}\left(f(h_{i}^{(\ell-1)},h_{j}^{(\ell -1)})\right),\end{split} \tag{10}\]
where \(\alpha_{ij}\) denotes the attention weight on neighbor \(j\in\mathcal{N}(i)\) when we are aggregating information at node \(v_{i}\), and \(f(\cdot)\) denotes a learnable attention weight calculation function.
We notice that the node aggregation process of GCN and GAT is quite similar. Compared with GCN, which uses the degree of nodes \(d\) for weighted aggregation, GAT uses attention weights \(\alpha\) instead. So its equivalence with Eq. (8) is:
\[\alpha_{ij}w_{j}^{\ell}\approx\left.\frac{\partial\tilde{\mathcal{F}}_{\alpha, i}(\mathbf{U}_{i})}{\partial u_{j}}\right|_{\mathbf{U}_{i}=0}. \tag{11}\]
The attention mechanism has a greater computational cost, but its attention coefficients can better fit \(\tilde{\mathcal{F}}_{\alpha,i}\) than GCN. This is because the value of the function \(\tilde{\mathcal{F}}_{\alpha,i}\) is determined by the node \(v_{i}\) and its neighbors. GAT can learn the features of the clique according to the node vector and its neighbors, while GCN can only use the node degree. The experimental results in Section 6 also verified this conclusion.
Both GCN and GAT are derived based on the first-order Taylor expansion, so they have performance degradation problems. There are several existing works on this issue, and their network architectures can alleviate the performance degradation problem of deep networks to some extent. In the following, we will interpret them from the perspective of PGM representation and analyze why they can achieve better results.
### Interpreting APPNP and GCNII
In the previous section, we elaborated on the classical GNNs under our framework. Intuitively, we have two ways to design a more powerful GNN. One is to find a more precise technique to fit \(\tilde{\mathcal{F}}_{\alpha,i}\), and the other is to perform message propagation based on the higher-order expansion of Eq. (6). Indeed, the propagation process of APPNP and GCNII can be regarded as the generalized form of second-order expansion. To prove this, we first briefly present two models.
APPNP [1] is a simple GNN originated from Personalized PageRank. It can be considered as the linear combination of the initial features and the current layer:
\[\mathbf{H}^{(\ell+1)}=(1-\alpha)\hat{\mathbf{A}}\mathbf{H}^{(\ell)}+\alpha \mathbf{H}^{(0)}. \tag{12}\]
GCNII [10] and APPNP explore the improvement of GCN from different perspectives. Still, the feature propagation of GCNII can be regarded as introducing identity mapping and a trainable weight matrix based on APPNP. The network propagation of GCNII is:
\[\begin{split}\mathbf{H}^{(\ell+1)}=\sigma\left(\left((1-\alpha) \,\hat{\mathbf{A}}\mathbf{H}^{(\ell)}+\alpha\mathbf{H}^{(0)}\right)\right.\\ \left.\left((1-\beta)\,\mathbf{I}_{n}+\beta\mathbf{W}^{(\ell)} \right)\right).\end{split} \tag{13}\]
The identity mapping in GCNII model helps assure that it performs at least as well as a shallow network. While in the theoretical analysis, we do not need to consider network optimization. In this case, we can reformulate the aggregation formula of GCNII as:
\[\mathbf{H}^{(\ell+1)}=\sigma\left(\hat{\mathbf{A}}\mathbf{H}^{(\ell)}\mathbf{ W}^{(\ell_{1})}+\mathbf{H}^{(0)}\mathbf{W}^{(\ell_{2})}\right). \tag{14}\]
When we adopt \(\beta=0\) in GCNII, we can find out that GCNII reduces to APPNP [1]. In other words, APPNP can be seen as a degenerate form of GCNII. Next, we will only analyze the propagation process of GCNII, and it is straightforward to modify the proof to obtain a nearly equivalent result for the APPNP.
**Proposition 1**.: _The propagation process of GCNII is equivalent to the second-order expansion of Eq. (6), where the initial residual corresponds to the approximation of the quadratic term._
Proof.: We start with the second-order Taylor expansion:
\[\begin{split} u_{i}^{(l)}&\approx\tilde{\mathcal{F}}_ {\alpha,i}(\mathbf{0})+\tilde{\mathcal{F}}_{\alpha,i}^{\prime}(\mathbf{0}) \mathbf{U}_{i}^{(l-1)}\\ &+\frac{1}{2}\mathbf{U}_{i}^{(l-1)^{\top}}\tilde{\mathcal{F}}_{ \alpha,i}^{\prime\prime}(\mathbf{0})\mathbf{U}_{i}^{(l-1)}+o\left[\mathbf{U}_ {i}^{(l-1)}\right]^{2}.\end{split} \tag{15}\]
We cannot directly express the quadratic term in the form of a graph convolution. To circumvent this problem, we approximate it with a linear term of the node features \(\mathbf{U}_{i}\). We know from Eq. (5) that \(\mathbf{U}_{i}\) is a tensor consisting of the features of node \(v_{i}\) and its neighbors. So we can rewrite the quadratic term as:
\[\frac{1}{2}\mathbf{U}_{i}^{(l-1)^{\top}}\tilde{\mathcal{F}}_{\alpha,i}^{\prime \prime}(\mathbf{0})\mathbf{U}_{i}^{(l-1)}=f_{1}\left(u_{i}^{(0)}\right)+\sum_{j \in\mathcal{N}(i)}f_{2}\left(u_{j}^{(l-1)}\right), \tag{16}\]
where \(f_{1}\) and \(f_{2}\) denote different transformations. Hence Eq. (15) is deduced as the following form:
\[u_{i}^{(l)}\approx\tilde{\mathcal{F}}_{\alpha,i}(\mathbf{0})+\sum_{j\in\mathcal{ N}(i)}g_{ij}\cdot u_{j}^{(l-1)}+f_{1}\left(u_{i}^{(0)}\right), \tag{17}\]
where we only keep the linear terms about \(u_{i}\) and \(u_{j}\), and \(g_{ij}\) represent the parameters. We represent Eq. (15) as the first-order expansion plus the initial residual, which is consistent with the ideas of GCNII and APPNP. The detailed proof is deferred to the appendix.
With this connection, one can show that the propagation process of GCNII is equivalent to the approximate form of the second-order expansion of Eq. (6). This means that our framework based on PGM representation can well explain this deep GNN model.
### Interpreting JKNet and DGCN
Jumping Knowledge Network (JKNet) and Decoupled Graph Convolutional Network (DGCN) are well-designed deep GNNs, and we connect their propagation operations in our framework using a similar pattern.
The JKNet proposed by [20] combines all previous representations at the last layer. The specific combination mechanisms can be max-pooling, concatenation, and LSTM-attention. For convenience, as is similar to [15], we omit the non-linear activation \(\sigma(\cdot)\). We denote \(\mathbf{Z}\) as the final output of the model and take the attention mechanism as an example of combination process for analyzing. The attention-JKNet can be described as:
\[\mathbf{Z}=\sum_{\ell=1}^{L}\alpha_{\ell}\hat{\mathbf{A}}^{\ell}\mathbf{X} \mathbf{W}^{\ell}, \tag{18}\]
where \(\alpha_{\ell}\) are learnable attention weights and \(\sum_{\ell=1}^{L}\alpha_{\ell}=1\). DGCN adopts a representation ensemble similar to JKNet, and uses a transformation process in each layer similar to GCNII :
\[\mathbf{Z}=\sum_{\ell=1}^{L}\alpha_{\ell}\hat{\mathbf{A}}^{\ell}\mathbf{X} \left(\beta_{\ell}\mathbf{W}^{(\ell)}+\left(1-\beta_{\ell}\right)\mathbf{I}_{ n}\right). \tag{19}\]
\(\alpha_{\ell}\) and \(\beta_{\ell}\) are trainable weights, \(\mathbf{I}_{n}\) is the identity mapping. DGCN ensures that the performance of the deep network is at least not worse than the shallow network by adding identity mapping. In fact, its propagation process is the same as JKNet.
For this kind of operation that ensemble the representations of \(k\) layers, it corresponds to the \(k\)-th expansion of Eq. (6):
\[u_{i}^{(l)}=\sum_{k=1}^{K}\frac{\tilde{\mathcal{F}}_{\alpha,i}^{k}(\mathbf{0} )}{k!}\left[\mathbf{U}_{i}^{(l-1)}\right]^{k}, \tag{20}\]
\[\frac{\tilde{\mathcal{F}}_{\alpha,i}^{k}(\mathbf{0})}{k!}\left[\mathbf{U}_{i }^{(l-1)}\right]^{k}\Rightarrow\alpha_{k}\hat{\mathbf{A}}^{k}\mathbf{X} \mathbf{W}^{k}.\]
Since the \(k\)-th order term of the expansion will contain high-dimensional tensors, we do not show the specific correspondence here. But we can know that the \(k\)-th term in Eq. (6) can aggregate k-hop information, and the coefficient items \(\frac{\tilde{\mathcal{F}}_{\alpha,i}^{k}(\mathbf{0})}{k!}\) are fitted by the trainable weight matrix.
In section 4.3, we proved that the transformations and identity mappings of GCNII can effectively reduce the error, so DGCN that applies a similar transformations method will theoretically perform better than JKNet. The experimental results also verify our presumptions.
### Discussion on Non-linearity
In the above subsections, we did not pay attention to non-linearity when analyzing these models. Here we discuss the role of activation functions in our framework. Recall what we stated in section 3, when we embed the formula of the obtained iterative solution into the Hilbert space, the mapping function needs to be injective. In [20], the authors discussed the graph convolution and proved its injectivity. This implies that adding an activation function (ReLU) satisfies our assumption. On the other hand, our network parameters need to fit the function \(\tilde{\mathcal{F}}\), and the non-linear activation can help the network better fit the non-linear functions.
## 5 On Designing Deep GNNs
In section 4, we obtained a unified framework that establishes the connection between the GNN models and the Taylor expansions of Eq. (4). However, the popular message-passing GNNs, such as GCN and GAT, are known to suffer from the performance degradation problem, which limits the deepening of their network structure. In this section, we use our framework to understand the performance degradation problem and explore a methodology to improve GNNs.
### Performance Degradation Problem
Several works study this performance degradation phenomenon from different perspectives, including generalization capability, low pass filtering on graphs, optimization of GNN, etc. Here we use the relationship between the GNN and Eq. (6) to analyze the reasons for the performance degradation of the classical GNNs.
We know that after enough iterations of Eq. (3), \(q^{l}\) will converge to the optimal solution \(q^{*}\). However, the propagation formula of GNN is not identical to Eq. (6) (Hilbert space embedding of Eq. (3)), but more similar to its first-order approximation. This means each layer of the GNN introduces an extra noise \(\epsilon^{(l)}\) when updating \(q^{(l)}\):
\[\hat{q_{i}}^{(l+1)}\left(z_{i}\right)+\epsilon_{i}^{(l+1)}=F_{i}\left(z_{i}, \hat{q_{j}}^{(l)}\left(z_{j}\right)\right),\quad j\in\mathcal{N}(i), \tag{21}\]
where \(F_{i}\) denotes the approximate form of Eq. (3), and \(\hat{q_{i}}\) denotes the iterative result1 of the GNNs. As the network deepens (the number of iterations increases), the convergence rate of \(q^{(l)}\) gradually slows down, but the accumulation of errors \(\epsilon^{(l)}\) increases. Therefore, the performance of baseline GNNs degrades greatly when stacking more layers. For concreteness, we limit our discussion here. We refer readers to the appendix for a more detailed description.
Footnote 1: Technically, the iteration of the GNN acts on the embedding vector of \(q_{i}\), here we simply replace it with \(q_{i}\).
### Coupling Graph Neural Network
Based on the established framework, we have some approaches to improve the performance of the GNN model from a high-level view. Using GNN for semi-supervised node classification can be regarded as a marginal distribution estimation of latent variables on PGMs. Thus, we can improve GNN from the perspective of the iterative solution of PGM. A deeper network corresponds to more iterations in Eq. (4); hence it can obtain better results. But this still requires the propagation process of the network to fit Eq. (6) as closely as possible. The approximation to Eq. (6) will introduce errors, causing performance degradation after the network reaches a certain depth.
Intuitively, Eq. (6) can be considered as the upper bound of the performance that variants of GNN can achieve. However, the computational cost of the propagation process and network structure which completely follows Eq. (6), is unacceptable. To this end, We need to design a computationally efficient approximation of Eq. (6) with as little error as possible. We propose a novel GNN model, Coupling Graph Neural Network (CoGNet), based on our established framework. Formally, we define the \(\ell\)-th layer of CoGNet as:
\[\begin{split}&\mathbf{P}^{(\ell+1)}=\mathcal{G}(\mathbf{H}^{ \ell},\mathbf{H}^{\ell-1})(\lambda_{\ell}\mathbf{W}_{\ell}+(1-\lambda_{\ell} )\mathbf{I}_{n}),\\ &\mathcal{G}(\mathbf{H}^{\ell},\mathbf{H}^{\ell-1})=\gamma_{\ell }\hat{\mathbf{A}}\mathbf{H}^{(\ell)}+(1-\gamma_{\ell})\mathbf{H}^{(\ell-1)}, \end{split} \tag{22}\]
where \(\lambda\) and \(\gamma\) are layer-specific learnable weights, and \(\mathbf{H}^{(\ell+1)}=\text{ReLU}(\mathbf{P}^{(\ell+1)})\).
In fact, the propagation process of CoGNet is equivalent to the second-order Taylor expansion of Eq. (4), but it is more accurate than GCNII. See the appendix for more detailed proof. We use the coupling of the two representations \(\mathcal{G}(\mathbf{H}^{\ell},\mathbf{H}^{\ell-1})\) as an approximation to Eq. (6), which reduces computational cost with small approximation errors. Note that in deep network layers, we use the initial representation as the coupling term. On the other hand, the learnable weights \(\lambda\) and \(\gamma\) enable the network to fit better the propagation process of Eq. (6). In addition, following the idea of GCNII, we also introduce identity mapping to enhance the deep network performance further.
The propagation process of CoGNet, compared with the vanilla GCN, introduces additional storage costs. Therefore, we follow the idea of the Reversible Transformer [14] and design reversible coupling, which recovers the representation of the previous layer in the backward pass without the need for checkpoints. For the large graph input, the reversible coupling can effectively reduce the model's memory requirements.
## 6 Experiment
In this section, we conduct extensive semi-supervised node classification experiments to evaluate CoGNet. We test the performance of CoGNet on the citation networks and natural language processing (NLP) downstream tasks.
### Citation Networks
#### 6.1.1 Dataset and Baselines
We use three standard benchmark citation datasets: Cora, Citeseer, and Pubmed for semi-supervised node classification. Their statistics are summarized in the appendix. We use the same fixed training/validation/testing split as [12] on three datasets. We evaluate our model against the following baselines:
* Graph convolutions: Chebyshev [13], GCN [11], GAT [15], SGC [20], APPNP [16], Graph U-Net [17].
* Deep GNNs: JKNet [21], GCNII [2], DAGNN [18], DGCN [2].
* Regularized GNN: Dropedge [14], GraphMix [23], GRAND [15]. Same as [15], we report the results of these methods with GCN as the backbone.
We use CoGNet-S to denote a shallow CoGNet with less than 4 layers. We further propose the CoGNet++ model, which applies two strategies, Consistency Regularization [15] and Dropedge [14], on CoGNet.
#### 6.1.2 Experiment Results
We summarize the performance on citation datasets in Table 1. We run CoGNet 100 times and report the mean and standard deviation of these 100 runs.
The upper part of Table 1 shows the variants of GNN, which are all shallow models. We can observe that CoGNet-S outperforms most baseline models. Specifically, the accuracy of the CoGNet compared with GCN and GAT has been greatly improved. In addition, we also compare the performance of popular deep GNN models, such as JKNet, GCNII, DAGNN, etc. We observe CoGNet outperforms all baseline deep GNN models. On the other hand, the deep CoGNet has a significant improvement over its shallow model, indicating that it can effectively alleviate the performance degradation problem of GNNs.
To better compare the performance of CoGNet and other deep GNNs, we plot the performance of the deep models with various numbers of layers in Fig. 1. We can observe that for the same number of network layers, CoGNet performs best in most cases. This result verifies the superiority of the propagation process of our model. It is worth noting that for the performance of shallow layers, models such as JKNet and GCNII have no advantage over GCN, but CoGNet can achieve better results than them in shallow networks.
We also apply the popular regularization strategy on graph-based models to our model, proposing CoGNet++. We can observe that it achieves state-of-the-art performance on Cora and Pubmed datasets, and it also achieves competitive results on the Citeseer dataset.
### NLP Tasks
Many NLP problems can be naturally expressed as graph structures, such as constructing sentences as graphs with words as nodes and constructing text as graphs composed of
paragraphs and entities. Therefore, neural graph-based models have emerged in recent years and have received increasing attention. However, shallow networks limit their performance. For example, in multi-hop Question Answering (QA), the two-layer graph convolutional network makes the nodes only access two-hop information and invisible for long-range knowledge. We only need to replace the GNN in the model [23, 24] with the CoGNet, which makes the network acquire a wider node perception field while deepening network layers and thus reach better results. We conduct experiments to test the performance of CoGNet on two NLP tasks, including text classification and multi-hop QA. Specific parameters of the experiment and more detailed illustrations refer to the appendix.
### Datasets
To thoroughly compare our model with the GCN, we test it on five widely used datasets of text classification: 20NG, MR, Ohsumed, R8, and R52. Their statistics are summarized in the appendix. HotpotQA is a dataset for explainable multi-hop QA.
#### Text Classification
Text classification is a fundamental task in NLP. [23] constructs a corpus-level heterogeneous graph containing document nodes and word nodes and uses a 2-layer GCN for classification. The results in Table 2 demonstrate a significant improvement of CoGNet over GCN and SGC in text classification.
#### Multi-hop QA
Multi-hop text-based QA is a popular topic in NLP. Many models explicitly find the inference path of the question with the help of graphs. For this case, multi-layer GNNs can obtain multi-hop information to assist inference. DFGN [24] constructs a graph of the entities mentioned in the query and then dynamically combines them with the help of a GAT. The two-layer GAT in DFGN can only reach two hops of information. Deepening the network depth can obtain multi-hop information, but the accuracy of downstream tasks is affected by the deep GNN. Table 3 reveals the test performance on the Hotpot QA dataset. We can observe that GCN has the worst performance, while shallow CoGNet (CoGNet-S) has a significant improvement over DFGN (GAT). On the other hand, deepening the CoGNet can achieve better results.
## 7 Conclusion and Future Work
In this paper, we developed a unified theoretical framework to understand the GNN baselines as well as various deep
\begin{table}
\begin{tabular}{c|c c c} \hline \hline Model & Cora & Citeseer & Pubmed \\ \hline Chebyshev & 81.2 & 69.8 & 74.4 \\ GCN & 81.4 & 70.9 & 79.1 \\ GAT & 83.3 & 72.6 & 78.5 \\ SGC & 81.0 & 71.9 & 78.9 \\ APPNP & 83.3 & 71.8 & 80.1 \\ Graph U-Net & 84.4 & 73.2 & 79.6 \\ \hline JKNet & 81.1 & 69.8 & 78.1 \\ GCNII & 85.5 & 73.4 & 80.2 \\ DAGNN & 84.4 & 73.3 & 80.5 \\ DGCN & 84.8 & 72.7 & 80.0 \\ \hline Dropedge & 82.8 & 72.3 & 79.6 \\ GraphMix & 83.9 & 74.5 & 81.0 \\ GRAND & 85.4 & \(\mathbf{75.4}\) & 82.7 \\ \hline CoGNet-S & \(84.4\pm 0.7\) & \(72.4\pm 0.6\) & \(79.6\pm 0.9\) \\ CoGNet & \(85.6\pm 0.5\) & \(73.7\pm 0.7\) & \(80.5\pm 0.5\) \\ CoGNet++ & \(\mathbf{86.5\pm 0.3}\) & \(75.2\pm 0.4\) & \(\mathbf{82.9\pm 0.4}\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Summary of semi-supervised classification accuracy results on Cora, Citeseer, and Pubmed.
\begin{table}
\begin{tabular}{c|c c c c} \hline \hline Model & 20NG & R8 & R52 & Ohsumed & MR \\ \hline TextGCN & 86.3 & 97.1 & 93.5 & 68.4 & 76.8 \\ +SGC & \(\mathbf{88.5}\) & 97.2 & 94.0 & 68.5 & 75.9 \\ +CoGNet & \(88.3\) & \(\mathbf{97.4}\) & \(\mathbf{94.1}\) & \(\mathbf{69.1}\) & \(\mathbf{77.2}\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Summary of test accuracy on text classification.
Figure 1: Semi-supervised node classification performance with various depths from 4 to 32.
GNN models using a graphical model representation. Specifically, we obtained an iterative solution of variational inference on Markov random fields, and the propagation operation of GNNs can be represented as approximate forms of it. We also proposed a theoretically motivated and powerful GNN which performs well on both shallow and deep network layers. An interesting direction for future work is to establish the connection between the approximate sampling methods, and the graph neural network to pursue a faster and more powerful sample-based GNN [3, 10, 11]. To complete the picture, understanding and improving the general GNN with the help of other variational methods would also be interesting.
|
2306.13926 | Graph Neural Networks Provably Benefit from Structural Information: A
Feature Learning Perspective | Graph neural networks (GNNs) have pioneered advancements in graph
representation learning, exhibiting superior feature learning and performance
over multilayer perceptrons (MLPs) when handling graph inputs. However,
understanding the feature learning aspect of GNNs is still in its initial
stage. This study aims to bridge this gap by investigating the role of graph
convolution within the context of feature learning theory in neural networks
using gradient descent training. We provide a distinct characterization of
signal learning and noise memorization in two-layer graph convolutional
networks (GCNs), contrasting them with two-layer convolutional neural networks
(CNNs). Our findings reveal that graph convolution significantly augments the
benign overfitting regime over the counterpart CNNs, where signal learning
surpasses noise memorization, by approximately factor $\sqrt{D}^{q-2}$, with
$D$ denoting a node's expected degree and $q$ being the power of the ReLU
activation function where $q > 2$. These findings highlight a substantial
discrepancy between GNNs and MLPs in terms of feature learning and
generalization capacity after gradient descent training, a conclusion further
substantiated by our empirical simulations. | Wei Huang, Yuan Cao, Haonan Wang, Xin Cao, Taiji Suzuki | 2023-06-24T10:21:11Z | http://arxiv.org/abs/2306.13926v2 | # Graph Neural Networks Provably Benefit from Structural Information: A Feature Learning Perspective
###### Abstract
Graph neural networks (GNNs) have pioneered advancements in graph representation learning, exhibiting superior feature learning and performance over multilayer perceptrons (MLPs) when handling graph inputs. However, understanding the feature learning aspect of GNNs is still in its initial stage. This study aims to bridge this gap by investigating the role of graph convolution within the context of feature learning theory in neural networks using gradient descent training. We provide a distinct characterization of signal learning and noise memorization in two-layer graph convolutional networks (GCNs), contrasting them with two-layer convolutional neural networks (CNNs). Our findings reveal that graph convolution significantly augments the benign overfitting regime over the counterpart CNNs, where signal learning surpasses noise memorization, by approximately factor \(\sqrt{D}^{q-2}\), with \(D\) denoting a node's expected degree and \(q\) being the power of the ReLU activation function where \(q>2\). These findings highlight a substantial discrepancy between GNNs and MLPs in terms of feature learning and generalization capacity after gradient descent training, a conclusion further substantiated by our empirical simulations.
## 1 Introduction
Graph neural networks (GNNs) have recently demonstrated remarkable capability in learning node or graph representations, yielding superior results across various downstream tasks, such as node classifications [1; 2; 3], graph classifications [4; 5; 6; 7] and link predictions [8; 9; 10], etc. However, the theoretical understanding of why GNNs can achieve such success is still in its infancy. Compared to multilayer perceptron (MLPs), GNNs enhance representation learning with an added message passing operation [11]. Take graph convoluational network (GCN) [1] as an example, it aggregates a node's attributes with those of its neighbors through a _graph convolution_ operation. This operation, which leverages the structural information (adjacency matrix) of graph data, forms the core distinction between GNNs and MLPs. Empirical evidence from three node classification tasks, as shown in
Figure 1, suggests GCNs outperform MLPs. Motivated by the superior performance of GNNs, we pose a critical question about graph convolution:
* _What role does graph convolution play during gradient descent training, and what mechanism enables a GCN to exhibit better generalization after training?_
Several recent studies have embarked on a theoretical exploration of graph convolution's role in GNNs. For instance, Baranwal et al. (2021) [12] considered a setting of linear classification of data generated from a contextual stochastic block model [13]. Their findings indicate that graph convolution extends the regime where data is linearly separable by a factor of approximately \(1/\sqrt{D}\) compared to MLPs, with \(D\) denoting a node's expected degree. Baranwal et al. (2023) [14] further investigated the impact of graph convolutions in multi-layer networks, showcasing improved non-linear separability. However, these studies these examples, while insightful, assume the Bayes optimal classifier of GNNs, thereby losing a comprehensive characterization of the GNNs' optimization process. Consequently, there exists a notable gap in characterization of learning process and corresponding generalization ability of GNNs between existing theoretical explorations and the detailed examination of GNNs.
To respond to the growing demand for a comprehensive theoretical understanding of graph convolution, we delve into the feature learning process [15; 16; 17] of graph neural networks. In our study, we introduce a data generation model--termed SNM-SBM--that combines a signal-noise model [15; 18] for feature creation and a stochastic block model [19] for graph construction. Our analysis is centered on the convergence and generalization attributes of two-layer graph convolution networks (GCNs) when trained via gradient descent, compared with the established outcomes for two-layer convolutional neural networks (CNNs) as presented by Cao et al. (2022) [15]. While both GCNs and CNNs demonstrate the potential to achieve near-zero training error, our study effectively sheds light on the discrepancies in their generalization abilities. We emphasize the crucial contribution of graph convolution to the enhanced performance of GNNs. Our study's key contributions are as follows:
* We establish global convergence guarantees for graph neural networks training on data drawn from SNM-SBM model. We demonstrate that, despite the nonconvex optimization landscape, GCNs can achieve zero training error after a polynomial number of iterations.
* We further establish population loss bounds of overfitted GNN models trained by gradient descent. We show that under certain conditions on the signal-to-noise ratio, GNNs trained by gradient descent will prioritize learning the signal over memorizing the noise, and thus achieves small test losses.
* We delineate a marked contrast in the generalization capabilities of GCNs and CNNs following gradient descent training. We identify a specific regime where GCNs can attain nearly zero test error, whereas the performance of the model discovered by CNNs does not exceed random guessing. This conclusion is further substantiated by empirical verification.
## 2 Related Work
Role of Graph Convolution in GNNs.Enormous empirical studies of various GNNs models with graph convolution [20; 21; 22; 23; 24] have been demonstrating that graph convolutions can enhance the performance of traditional classification methods, such as a multi-layer perceptron (MLP). Towards theoretically understanding the role of graph convolution, Xu et al. (2020) [25] identify conditions under which MLPs and GNNs extrapolate, thereby highlighting the superiority of GNNs for extrapolation problems. Their theoretical analysis leveraged the concept of the over-parameterized networks and the neural tangent kernel [26]. Huang et al. (2021) [27] employed a similar approach to examine the role of graph convolution in deep GNNs within a node classification setting. They discovered that excessive graph convolution layers can hamper the optimization and generalization of GNNs, corroborating the well-known over-smoothing issue in deep GNNs [28]. Another pertinent work by Hou et al. (2022) [29] proposed two smoothness metrics to measure the quantity and quality of information derived from graph data, along with a novel attention-based framework. Some
Figure 1: Performance (test accuracy) comparison between GCN and MLP on node classification tasks.
rent works [12; 14; 21] have demonstrated that graph convolution broadens the regime in which a multi-layer network can classify nodes, compared to methods that do not utilize the graph structure, especially when the graph is dense and exhibits homophily. Yang et al. (2022) [30] attributed the major performance gains of GNNs to their inherent generalization capability through graph neural tangent kernel (GNTK) and extrapolation analysis. As for neural network theory, these works either gleaned insights from GNTK [31; 27; 32] or studied the role of graph convolution within a linear neural network setting. Unlike them, our work extends beyond NTK and investigates a more realistic setting concerning the convergence and generalization of neural networks in terms of feature learning.
Feature learning in neural networks.This work builds upon a growing body of research on how neural networks learn features. Allen-Zhu et al. (2020) [18] formulated a theory illustrating that when data possess a "multi-view" feature, ensembles of independently trained neural networks can demonstrably improve test accuracy. Further, Allen-Zhu et al. (2022) [16] demonstrated that adversarial training can purge certain small dense mixtures from the hidden weights during the training process of a neural network, thus refining the hidden weights. Ba et al. (2022) [33] established that the initial gradient update contains a rank-1'spike', which leads to an alignment between the first-layer weights and the linear component feature of the teacher model. Cao et al. (2022) [15] investigated the benign overfitting phenomenon in training a two-layer convolutional neural network (CNN), illustrating that under certain conditions related to the signal-to-noise ratio, a two-layer CNN trained by gradient descent can achieve exceedingly low test loss through feature learning. Alongside related works [34; 35; 17; 36; 37; 38; 39; 40], all these studies have underscored the existence of feature learning in neural networks during gradient descent training, forming a critical line of inquiry that this work continues to explore. However, the neural tangent kernel (NTK) theory [41; 42; 43; 44], also known as "lazy training" [45], where the neural network function is approximately linear in its parameters, cannot demonstrate feature learning. Thus, the optimization and generalization analysis in our study extends beyond the NTK regime.
## 3 Problem Setup and Preliminary
### Notations
We use lower bold-faced letters for vectors, upper bold-faced letters for matrices, and non-bold-faced letters for scalars. For a vector \(\mathbf{v}=(v_{1},v_{2},\cdots,v_{d})^{\top}\), its \(\ell_{2}\)-norm is denoted as \(\|\mathbf{v}\|_{2}\triangleq\sqrt{\sum_{i=1}^{d}v_{i}^{2}}\). For a matrix \(\mathbf{A}=(a_{ij})\in\mathbb{R}^{m\times n}\), we use \(\|\mathbf{A}\|_{2}\) to denote its spectral norm and \(\|\mathbf{A}\|_{F}\) for its Frobenius norm. When comparing two sequences \(\{a_{n}\}\) and \(\{b_{n}\}\), we employ standard asymptotic notations such as \(O(\cdot)\), \(o(\cdot)\), \(\Omega(\cdot)\), and \(\Theta(\cdot)\) to describe their limiting behavior. Specifically, we write \(a_{n}=O(b_{n})\) if there exists a positive real number \(C_{1}\) and a positive integer \(N\) such that \(|a_{n}|\leq C_{1}|b_{n}|\) for all \(n\geq N\). Similarly, we write \(a_{n}=\Omega(b_{n})\) if there exists \(C_{2}>0\) and \(N>0\) such that \(|a_{n}|>C_{2}|b_{n}|\) for all \(n\geq N\). We say \(a_{n}=\Theta(b_{n})\) if \(a_{n}=O(b_{n})\) and \(a_{n}=\Omega(b_{n})\). Besides, if \(\lim_{n\to\infty}|a_{n}/b_{n}|=0\), we express this as \(a_{n}=o(b_{n})\). We use \(\widetilde{O}(\cdot)\), \(\widetilde{\Omega}(\cdot)\), and \(\widetilde{\Theta}(\cdot)\) to hide logarithmic factors in these notations respectively. Moreover, we denote \(a_{n}=\text{poly}(b_{n})\) if \(a_{n}=O((b_{n})^{p})\) for some positive constant \(p\) and \(a_{n}=\text{polylog}(b_{n})\) if \(a_{n}=\text{poly}(\log(b_{n}))\). Lastly, sequences of integers are denoted as \([m]=\{1,2,\dots,m\}\).
### Data model
In our approach, we utilize a signal-noise model for feature generation, combined with a stochastic block model for graph structure generation. Specifically, we define the feature matrix as \(\mathbf{X}\in\mathbb{R}^{n\times 2d}\), with \(n\) representing the number of samples and \(2d\) being the feature dimensionality. Each feature associated with a data point is generated from a _signal-noise model_ (SNM), conditional on the Rademacher random variable \(y\in\{-1,1\}\), and a latent vector \(\boldsymbol{\mu}\in\mathbb{R}^{d}\):
\[\mathbf{x}=[\mathbf{x}^{(1)},\mathbf{x}^{(2)}]=[y\boldsymbol{\mu}, \boldsymbol{\xi}], \tag{1}\]
where \(\mathbf{x}^{(1)},\mathbf{x}^{(2)}\in\mathbb{R}^{d}\), and \(\boldsymbol{\xi}\sim\mathcal{N}(\mathbf{0},\sigma_{p}^{2}\cdot(\mathbf{I}-\| \boldsymbol{\mu}\|_{2}^{-2}\cdot\boldsymbol{\mu}\boldsymbol{\mu}^{\top}))\) consists of independent standard normal entries with \(\sigma_{p}^{2}\) as the variance. The term \(\mathbf{I}-\|\boldsymbol{\mu}\|_{2}^{-2}\cdot\boldsymbol{\mu}\boldsymbol{\mu} ^{\top}\) is employed to guarantee that the noise vector is orthogonal to the signal vector \(\boldsymbol{\mu}\). The signal-noise model we have adopted is inspired by the structure of an image composed of multiple patches, where we consider a two-patch
model for simplicity. The first patch \(\mathbf{x}^{(1)}\), represented by the signal vector, corresponds to the target or meaningful information in an image, such as an object or feature of interest. The second patch \(\mathbf{x}^{(2)}\), represented by the noise vector, corresponds to the background or other irrelevant details in the image, which can be considered as nuisance variables or features. It's worth mentioning that a series of recent works [18; 15; 35; 46] have explored similar signal-noise models to illustrate the feature learning process and benign overfitting of neural networks.
Following this, we implement a stochastic block model with inter-class edge probability \(p\) and intra-class edge probability \(s\), devoid of self-loops. Specifically, the adjacency matrix \(\mathbf{A}=(a_{ij})_{n\times n}\) is Bernoulli distributed, with \(a_{ij}\sim\text{Ber}(p)\) when \(y_{i}=y_{j}\), and \(a_{ij}\sim\text{Ber}(s)\) when \(y_{i}=-y_{j}\). The combination of a stochastic block model with the signal-noise model (1) is represented as \(\mathrm{SNM}-\mathrm{SBM}(n,p,s,\boldsymbol{\mu},\sigma_{p},d)\). Consequently, the raw feature and graph structure are generated as \((\mathbf{A},\mathbf{X},\mathbf{y})\sim\mathrm{SNM}-\mathrm{SBM}(n,p,s, \boldsymbol{\mu},\sigma_{p},d)\), allowing the data model (1) used in MLP to be considered as a special case where \(p=s=0\). Note that the primary distinction between the SNM-SBM and Contextual stochastic block model (CSBM) [47] lies in the representation of the contextual part. In our SNM-SBM model, the contextual part, or input feature, is given by a two-patch model. Conversely, in CSBM, the input feature is given by a Gaussian mixture model.
### Neural network model
In this section, we present two distinct types of neural network models: a two-layer convolutional neural network (CNN), which falls under the category of a multilayer perceptron (MLP), and a Graph Convolutional Neural Network (GCN) [1].
Cnn.We introduce a two-layer CNN model, denoted as \(f\), which utilizes a non-linear activation function, \(\sigma(\cdot)\). Specifically, we employ a polynomial ReLU activation function defined as \(\sigma(z)=\max\{0,z\}^{q}\), where \(q>2\) is a hyperparameter. Note that the use of a polynomial ReLU activation function aligns with related studies [18; 16; 15; 35; 48] that investigate neural network feature learning. Mathematically, given the input data \(\mathbf{x}\), the CNN's output is represented as \(f(\mathbf{W},\mathbf{x})=F_{+1}(\mathbf{W}_{+1},\mathbf{x})-F_{-1}(\mathbf{W}_ {-1},\mathbf{x})\), where \(F_{+1}(\mathbf{W}_{+1},\mathbf{x})\) and \(F_{-1}(\mathbf{W}_{+1},\mathbf{x})\) are defined as follows:
\[F_{j}(\mathbf{W}_{j},\mathbf{x})=\frac{1}{m}\sum_{r=1}^{m}\left[ \sigma(\mathbf{w}_{j,r}^{\top}\mathbf{x}^{(1)})+\sigma(\mathbf{w}_{j,r}^{\top }\mathbf{x}^{(2)})\right], \tag{2}\]
where \(m\) is the width of hidden layer, the second layer parameters are fixed as either \(+1\) or \(-1\). We assume a poly-logarithmic network width in relation to the training sample size, i.e., \(m=\mathrm{polylog}(n)\), and \(\mathbf{w}_{j,r}\in\mathbb{R}^{d}\) refers to the weight of the first layer's \(r\)-th neuron connected to the second layer's \(j\) class. The symbol \(\mathbf{W}\) collectively represents the model's weights. Moreover, each weight in the first layer is initialized from a random draw of a Gaussian random variable, \(\mathbf{w}_{j,r}\sim\mathcal{N}(\mathbf{0},\sigma_{0}^{2}\cdot\mathbf{I}_{d \times d})\) for all \(r\in[m]\) and \(j\in\{-1,1\}\), with \(\sigma_{0}\) regulating the initialization magnitude for the first layer's weight.
Upon receiving training data \(\mathcal{S}\triangleq\{\mathbf{x}_{i},y_{i}\}_{i=1}^{n}\) drawn from \(\mathrm{SNM}-\mathrm{SBM}(n,p=0,s=0,\boldsymbol{\mu},\sigma_{p},d)\), we aim to learn the network's parameter \(\mathbf{W}\) by by minimizing the empirical cross-entropy loss function:
\[L_{\mathcal{S}}^{\mathrm{CNN}}(\mathbf{W})=\frac{1}{n}\sum_{i=1}^ {n}\ell(y_{i}\cdot f(\mathbf{W},\mathbf{x}_{i})), \tag{3}\]
where \(\ell(y\cdot f(\mathbf{W},\mathbf{x}))=\log(1+\exp(-f(\mathbf{W},\mathbf{x}) \cdot y))\). The update rule for the gradient descent used in the CNN is then given as:
\[\mathbf{w}_{j,r}^{(t+1)} =\mathbf{w}_{j,r}^{(t)}-\eta\cdot\nabla_{\mathbf{w}_{j,r}}L_{ \mathcal{S}}^{\mathrm{CNN}}(\mathbf{W}^{(t)})\] \[=\mathbf{w}_{j,r}^{(t)}-\frac{\eta}{nm}\sum_{i=1}^{n}\ell_{i}^{ \prime(t)}\cdot\sigma^{\prime}(\langle\mathbf{w}_{j,r}^{(t)},\boldsymbol{\xi}_ {i}\rangle)\cdot jy_{i}\boldsymbol{\xi}_{i}-\frac{\eta}{nm}\sum_{i=1}^{n}\ell_ {i}^{\prime(t)}\cdot\sigma^{\prime}(\langle\mathbf{w}_{j,r}^{(t)},y_{i} \boldsymbol{\mu}\rangle)\cdot j\boldsymbol{\mu}, \tag{4}\]
where we define the loss derivative as \(\ell_{i}^{\prime}\triangleq\ell^{\prime}(y_{i}\cdot f_{i})=-\frac{\exp(-y_{i} \cdot f_{i})}{1+\exp(-y_{i}\cdot f_{i})}\). It's important to clarify that the model we use for the MLP part is a two-layer CNN network. We categorize it as an MLP for comparison purposes with the graph neural network.
Gcn.Graph neural network (GNNs) fuse graph structure information and node features to learn representation of nodes. Consider a two-layer GCN \(f\) with graph convolution operation on the first layer. The output of the GCN is given by \(f(\mathbf{W},\tilde{\mathbf{x}})=F_{+1}(\mathbf{W}_{+1},\tilde{\mathbf{x}})-F_{- 1}(\mathbf{W}_{-1},\tilde{\mathbf{x}})\), where \(F_{+1}(\mathbf{W}_{+1},\tilde{\mathbf{x}})\) and \(F_{-1}(\mathbf{W}_{+1},\tilde{\mathbf{x}})\) are defined as follows:
\[F_{j}(\mathbf{W}_{j},\tilde{\mathbf{x}})=\frac{1}{m}\sum_{r=1}^{m}\left[\sigma( \mathbf{w}_{j,r}^{\top}\tilde{\mathbf{x}}^{(1)})+\sigma(\mathbf{w}_{j,r}^{ \top}\tilde{\mathbf{x}}^{(2)})\right]. \tag{5}\]
Here, \(\tilde{\mathbf{X}}\triangleq[\tilde{\mathbf{x}}_{1},\tilde{\mathbf{x}}_{2}, \cdots,\tilde{\mathbf{x}}_{n}]^{\top}=\tilde{\mathbf{D}}^{-1}\tilde{\mathbf{ A}}\mathbf{X}\in\mathbb{R}^{n\times 2d}\) with \(\tilde{\mathbf{A}}=\mathbf{A}+\mathbf{I}_{n}\) representing the adjacency matrix with self-loop, and \(\tilde{\mathbf{D}}\) is a diagonal matrix that records the degree of each node, namely, \(\tilde{D}_{ii}=\sum_{j}\tilde{A}_{ij}\). For simplicity we denote \(D_{i}\triangleq\tilde{D}_{ii}\). Therefore, in contrast to the CNN model (2), the GCNs (5) incorporate the normalized adjacency matrix \(\tilde{\mathbf{D}}^{-1}\tilde{\mathbf{A}}\), also termed as graph convolution, which serves as a pivotal component. The structure of the networks has been carefully chosen for the following reasons: 1) The decision to fix the second layer in our network structure is a choice to facilitate theoretical derivation. This approach is standard in literature (as seen in references [15; 44]). Even with the second layer fixed, the optimization problem remains non-convex, allowing us to study complex learning dynamics. 2) By observing signal learning and noise memorization (defined in Equation 10), which depend only on the first layer's weight, we can gain valuable insights into how a neural network learns signal and noise from data. This approach enables us to analyze the concrete learning process, contributing to a deeper understanding of GNNs.
### Objective function and test loss
With the training data \(\mathcal{S}\triangleq\{\mathbf{x}_{i},y_{i}\}_{i=1}^{n}\) and \(\mathbf{A}\in\mathbb{R}^{n\times n}\) drawn from \(\mathrm{SNM}-\mathrm{SBM}(n,p,s,\boldsymbol{\mu},\sigma_{p},d)\), we consider to learn the network's parameter \(\mathbf{W}\) by optimizing the empirical cross-entropy loss function:
\[L_{\mathcal{S}}^{\mathrm{GCN}}(\mathbf{W})=\frac{1}{n}\sum_{i=1}^{n}\ell(y_{i} \cdot f(\mathbf{W},\tilde{\mathbf{x}}_{i})). \tag{6}\]
The gradient descent update for the first layer weight \(\mathbf{W}\) in GCN can be expressed as:
\[\mathbf{w}_{j,r}^{(t+1)} =\mathbf{w}_{j,r}^{(t)}-\eta\cdot\nabla_{\mathbf{w}_{j,r}}L_{ \mathcal{S}}^{\mathrm{GCN}}(\mathbf{W}^{(t)})\] \[=\mathbf{w}_{j,r}^{(t)}-\frac{\eta}{nm}\sum_{i=1}^{n}\ell_{i}^{ \prime(t)}\sigma^{\prime}(\langle\mathbf{w}_{j,r}^{(t)},\tilde{y}_{i} \boldsymbol{\mu}\rangle)\cdot j\tilde{y}_{i}\boldsymbol{\mu}-\frac{\eta}{nm} \sum_{i=1}^{n}\ell_{i}^{\prime(t)}\sigma^{\prime}(\langle\mathbf{w}_{j,r}^{(t) },\tilde{\boldsymbol{\xi}}_{i}\rangle)\cdot jy_{i}\tilde{\boldsymbol{\xi}}_{i}, \tag{7}\]
where we define "aggregated label" \(\tilde{y}_{i}=D_{i}^{-1}\sum_{k\in\mathcal{N}(i)}y_{k}\) and "aggregated noise vector" \(\tilde{\boldsymbol{\xi}}_{i}=D_{i}^{-1}\sum_{k\in\mathcal{N}(i)}\boldsymbol{\xi}_ {k}\), with \(\mathcal{N}(i)\) being a set that contains all the neighbor of node \(i\).
In this study, our primary objective is to demonstrate the enhanced feature learning capabilities of GNNs in comparison to CNNs. This is achieved by examining the generalization ability of the GNN model through the lens of test loss (population loss). Our test loss is defined based on unseen test data. We build a stochastic block model to model how the data can be generated. What we study is following: given \(n\) training data points and the corresponding graph with \(n\) nodes are generated following the data model. We train a GNN model based on the \(n\) training data points. We suppose that the new test data are generated following the same distribution, and its connection in the graph to the training data points are still following the stochastic block model. We study the loss at the new test data achieved by GNN trained on the \(n\) training points. We specifically study the population loss by taking the expectation over the randomness of the test data, which is formulated as follows:
\[L_{\mathcal{D}}^{\mathrm{GCN}}(\mathbf{W})=\mathbb{E}_{\tilde{\mathbf{x}},y \sim\mathcal{D}=\mathrm{SNM}-\mathrm{SBM}}\ell(y\cdot f(\mathbf{W},\tilde{ \mathbf{x}})). \tag{8}\]
## 4 Thereotical Results
In this section, we introduce our key theoretical findings that elucidate the optimization and generalization processes of feature learning in GCNs. Through the application of the gradient descent rule outlined in Equation (7), we observe that the gradient descent iterate \(\mathbf{w}_{j,r}^{(t)}\) is a linear combination of
its random initialization \(\mathbf{w}_{j,r}^{(0)}\), the signal vector \(\boldsymbol{\mu}\) and the noise vectors in the training data \(\boldsymbol{\xi}_{i}\)1 for \(i\in[n]\). Consequently, for \(r\in[m]\), the decomposition of weight vector iteration can be expressed:
Footnote 1: By referring to Equation (7), we assert that the gradient descent update moves in the direction of \(\tilde{\boldsymbol{\xi}}_{i}\) for each \(i\in[n]\). Then we can apply the definition of \(\tilde{\boldsymbol{\xi}}_{i}=D_{i}^{-1}\sum_{k\in\mathcal{N}(i)}\boldsymbol{ \xi}_{k}\).
\[\mathbf{w}_{j,r}^{(t)}=\mathbf{w}_{j,r}^{(0)}+\gamma_{j,r}^{(t)}\cdot\| \boldsymbol{\mu}\|_{2}^{-2}\cdot\boldsymbol{\mu}+\sum_{i=1}^{n}\rho_{j,r,i}^{(t )}\cdot\|\boldsymbol{\xi}_{i}\|_{2}^{-2}\cdot\boldsymbol{\xi}_{i}. \tag{9}\]
where \(\gamma_{j,r}^{(t)}\) and \(\rho_{j,r,i}^{(t)}\) serve as coefficients. We refer to Equation (9) as the signal-noise decomposition of \(\mathbf{w}_{j,r}^{(t)}\). The normalization factors \(\|\boldsymbol{\mu}\|_{2}^{-2}\) and \(\|\boldsymbol{\xi}_{i}\|_{2}^{-2}\) are introduced to ensure that \(\gamma_{j,r}^{(t)}\approx\langle\mathbf{w}_{j,r}^{(t)},\boldsymbol{\mu}\rangle\), and \(\rho_{j,r,i}^{(t)}\approx\langle\mathbf{w}_{j,r}^{(t)},\boldsymbol{\xi}_{i}\rangle\). We employ \(\gamma_{j,r}^{(t)}\) to characterize the process of signal learning and \(\rho_{j,r,i}^{(t)}\) to characterize the noisy represent. From an intuitive standpoint, if, for some iteration certain \(\gamma_{j,r}^{(t)}\) values are sufficiently large while all \(|\rho_{j,r,i}^{(t)}|\) are relatively small, this indicates that the neural network is primarily learning the label through feature learning. This scenario can lead to _benign overfitting_, characterized by both minimal training and test errors. Conversely, if some \(|\rho_{j,r,i}^{(t)}|\) values are relatively large while all \(\gamma_{j,r}^{(t)}\) are small, the neural network will achieve a low training loss but a high test loss. This occurs as the neural network attempts to generalize by memorizing noise, resulting in a _harmful overfitting_ regime.
To facilitate a fine-grained analysis for the evolution of coefficients, we introduce the notations \(\overline{p}_{j,r,i}^{(t)}\triangleq\rho_{j,r,i}^{(t)}\mathds{1}(\rho_{j,r,i }^{(t)}\geq 0)\), \(\underline{\rho}_{j,r,i}^{(t)}\triangleq\rho_{j,r,i}^{(t)}\mathds{1}(\rho_{j, r,i}^{(t)}\leq 0)\). Consequently, we further express the vector weight decomposition (9) as:
\[\mathbf{w}_{j,r}^{(t)}=\mathbf{w}_{j,r}^{(0)}+j\cdot\gamma_{j,r}^{(t)}\cdot \|\boldsymbol{\mu}\|_{2}^{-2}\cdot\boldsymbol{\mu}+\sum_{i=1}^{n}\overline{p} _{j,r,i}^{(t)}\cdot\|\boldsymbol{\xi}_{i}\|_{2}^{-2}\cdot\boldsymbol{\xi}_{i} +\sum_{i=1}^{n}\underline{\rho}_{j,r,i}^{(t)}\cdot\|\boldsymbol{\xi}_{i}\|_{2} ^{-2}\cdot\boldsymbol{\xi}_{i}. \tag{10}\]
Our analysis will be made under the following set of assumptions:
**Assumption 4.1**.: Suppose that
1. The dimension \(d\) is sufficiently large: \(d=\tilde{\Omega}(m^{2\nu[4/(q-2)]}n^{4\nu[(2q-2)/(q-2)]})\).
2. The size of training sample \(n\) and width of GCNs \(m\) adhere to \(n,m=\Omega(\operatorname{polylog}(d))\).
3. The learning rate \(\eta\) satisfies \(\eta\leq\tilde{O}(\min\{\|\boldsymbol{\mu}\|_{2}^{-2},\sigma_{p}^{-2}d^{-1} \})\).
4. The edge probability \(p,s=\Omega(\sqrt{\log(n)/n})\) and \(\Xi\triangleq\frac{p-s}{p+s}\) is a positive constant.
5. The standard deviation of Gaussian initialization \(\sigma_{0}\) is chosen such that \(\sigma_{0}\leq\tilde{O}(m^{-2/(q-2)}n^{-[1/(q-2)]\lor 1}\cdot\min\{(\sigma_{p} \sqrt{d/(n(p+s))})^{-1},\Xi^{-1}\|\boldsymbol{\mu}\|_{2}^{-1}\}\).
_Remark 4.2_.: (1) The requirement for a high dimension in our assumptions is specifically aimed at ensuring that the learning occurs in a sufficiently over-parameterized setting [49, 15] when the second layer remains fixed. We are interested in exploring the over-parameterization scenario where both GNNs and CNNs can be trained to achieve arbitrarily small training loss, and then comparing the test losses after the training loss has been minimized. (2) It's necessary for the sample size and neural network width to be at least polylogarithmic in the dimension \(d\). This condition ensures certain statistical properties of the training data and weight initialization hold with a probability of at least \(1-d^{-1}\). (3) The condition on \(\eta\) is to ensure that gradient descent can effectively minimize the training loss. (4) The assumption regarding edge probability guarantees a sufficient level of concentration in the degree and an adequate display of homophily of graph data. (5) Lastly, the conditions imposed on initialization strength \(\sigma_{0}\) are intended to guarantee that the training loss can effectively converge to a sufficiently small value and to discern the differential learning speed between signal and noise.
Given the above assumptions, we present our main result on feature learning of GCNs in the following theorem.
**Theorem 4.3**.: _Suppose \(\epsilon>0\), and let \(T=\tilde{\Theta}(\eta^{-1}m\sigma_{0}^{-(q-2)}\Xi^{-q}\|\boldsymbol{\mu}\|_{2} ^{-q}+\eta^{-1}\epsilon^{-1}m^{3}\|\boldsymbol{\mu}\|_{2}^{-2})\). Under Assumption 4.1, if \(n\cdot\operatorname{SNR}^{q}\cdot\sqrt{n(p+s)}^{q-2}=\tilde{\Omega}(1)\), where \(\operatorname{SNR}\triangleq\|\boldsymbol{\mu}\|_{2}/(\sigma_{p}\sqrt{d})\) is the signal-to-noise ratio, then with probability at least \(1-d^{-1}\), there exists a \(0\leq t\leq T\) such that:_
* _The GCN learns the signal:_ \(\max_{r}\gamma_{j,r}^{(t)}=\Omega(1)\) _for_ \(j\in\{\pm 1\}\)_._
* _The GCN does not memorize the noises in the training data:_ \(\max_{j,r,i}|\rho_{j,r,i}^{(T)}|=\tilde{O}(\sigma_{0}\sigma_{p}\sqrt{d/n(p+s)})\)_._
* _The training loss converges to_ \(\epsilon\)_, i.e.,_ \(L_{\mathcal{S}}^{\mathrm{GCN}}(\mathbf{W}^{(t)})\leq\epsilon\)_._
* _The trained GCN achieves a small test loss:_ \(L_{\mathcal{D}}^{\mathrm{GCN}}(\mathbf{W}^{(t)})\leq c_{1}\epsilon+\exp(-c_{2} n^{2})\)_._
_where \(c_{1}\) and \(c_{2}\) are positive constants._
Theorem 4.3 outlines the scenario of _benign overfitting_ for GCNs. It reveals that, provided \(n\cdot\mathrm{SNR}^{q}\cdot\sqrt{n(p+s)}^{q-2}=\tilde{\Omega}(1)\), the GCN can learn the signal by achieving \(\max_{r}\gamma_{j,r}^{(t)}=\Omega(1)\) for \(j\in\{\pm 1\}\), and on the other hand, the noise memorization during gradient descent training is suppressed by \(\max_{j,r,i}|\rho_{j,r,i}^{(T)}|=\tilde{O}(\sigma_{0}\sigma_{p}\sqrt{d/n(p+s)})\), given that \(\sigma_{0}\sigma_{p}\sqrt{d/n(p+s)}\ll 1\) according to assumption 4.1. Because the signal learned by the network is large enough and much stronger than the noise memory, it can perfectly predict the label in the test sample according to the learned signal when it generalizes. Consequently, the learned neural network can attain small training and test losses.
To illustrate the pronounced divergence between GNN and CNN in terms of generalization capability post-gradient descent training, we show that, under identical conditions, a GCN engages in signal learning while a CNN emphasizes noise memorization, and thus diverges in the ability of generalization:
**Corollary 4.4** (Informal).: _Under assumption 4.1, if \(n\cdot\mathrm{SNR}^{q}\cdot\sqrt{n(p+s)}^{q-2}=\tilde{\Omega}(1)\) and \(n^{-1}\cdot\mathrm{SNR}^{-q}=\tilde{\Omega}(1)\), then with probability at least \(1-d^{-1}\), then there exists a \(t\) such that:_
* _The trained GNN achieves a small test loss:_ \(L_{\mathcal{D}}^{\mathrm{GCN}}(\mathbf{W}^{(t)})\leq c_{1}\epsilon+\exp(-c_{2} n^{2})\)_._
* _The trained CNN has a constant order test loss:_ \(L_{\mathcal{D}}^{\mathrm{CNN}}(\mathbf{W}^{(t)})=\Theta(1)\)_._
Corollary 4.4 clearly provides a condition that GNNs learn the signal and achieves a small test loss while the CNNs can only memorize noises and will have a \(\Theta(1)\) test loss. Whether a CNN learns the signal or noise depends on the signal-to-noise ratio (\(\mathrm{SNR}\)), and the number of samples \(n\). According to Cao et al. [15], CNN can learn the signal and filter out the noise when \(n\cdot\mathrm{SNR}^{q}>1\). On the other hand, when \(n\cdot\mathrm{SNR}^{q}<1\), as focused in this work, the strength of signal and number sample are not large enough for a CNN to focus on the signal learning and generalize well on the unseen data. We have illustrated this demontration in Figure 2. The improvement in _benign overfitting_ regime is facilitated by graph convolution, a process that will be elaborated on in the subsequent section. Through the precise characterization of neural network feature learning from optimization to generalization, we have successfully demonstrated that the graph neural network can gain superiority with the help of graph convolution.
## 5 Proof Sketches
In this section, we outline the proof sketches, drawing inspiration from the study of feature learning in CNNs. Our approach follows and builds upon the methodologies described in [15], allowing us to extend and apply these concepts in a new context. We discuss the primary challenges encountered during the study of GNN training, and illustrate the key techniques we employed in our proofs to overcome these challenges:
* Graph convolution aggregates information from neighboring nodes to the central node, which often leads to the loss of statistical stability for the aggregated noise vectors and labels. To overcome this challenge, we utilize a dense graph input, achieved by setting the edge probability as per Assumption 4.1.
* Graph convolution can potentially cause erratic iterative dynamics of coefficients during the feature learning process. To mitigate this issue, we introduce the concept of homophily into the graph input, which helps in stabilizing the coefficient iterations.
* Lastly, for the generalization analysis, depicting the generalization ability of graph neural networks poses a significant challenge. To address this issue, we introduce an expectation over the distribution for a single data point and develop an algorithm-dependent test error analysis.
These main techniques are further elaborated upon in the following sections, and detailed proofs for all the results can be found in the appendix.
### Iterative analysis of the signal-noise decomposition under graph convolution
To analyze the feature learning process of graph neural networks during gradient descent training, we introduce an iterative methodology, based on the signal-noise decomposition in decomposition (10) and gradient descent update (7). The following lemma offers us a means to monitor the iteration of the signal learning and noise memorization under graph convolution:
**Lemma 5.1**.: _The coefficients \(\gamma_{j,r}^{(t)},\overline{\rho}_{j,r,i}^{(t)},\underline{\rho}_{j,r,i}^{(t)}\) in decomposition (10) adhere to the following equations:_
\[\gamma_{j,r}^{(0)},\overline{\rho}_{j,r,i}^{(0)},\underline{\rho }_{j,r,i}^{(0)}=0, \tag{11}\] \[\gamma_{j,r}^{(t+1)}=\gamma_{j,r}^{(t)}-\frac{\eta}{nm}\cdot \sum_{i=1}^{n}\ell_{i}^{(t)}\sigma^{\prime}(\langle\mathbf{w}_{j,r}^{(t)}, \tilde{y}_{i}\boldsymbol{\mu}_{i}\rangle)y_{i}\tilde{y}_{i}\|\boldsymbol{ \mu}\|_{2}^{2},\] (12) \[\overline{\rho}_{j,r,i}^{(t+1)}=\overline{\rho}_{j,r,i}^{(t)}- \frac{\eta}{nm}\cdot\sum_{k\in\mathcal{N}(i)}D_{k}^{-1}\cdot\ell_{k}^{\prime (t)}\cdot\sigma^{\prime}(\langle\mathbf{w}_{j,r}^{(t)},\tilde{\boldsymbol{ \xi}}_{k}\rangle)\cdot\|\boldsymbol{\xi}_{i}\|_{2}^{2}\cdot\mathds{1}(y_{k}=j),\] (13) \[\underline{\rho}_{j,r,i}^{(t+1)}=\underline{\rho}_{j,r,i}^{(t)}+ \frac{\eta}{nm}\cdot\sum_{k\in\mathcal{N}(i)}D_{k}^{-1}\cdot\ell_{k}^{\prime (t)}\cdot\sigma^{\prime}(\langle\mathbf{w}_{j,r}^{(t)},\tilde{\boldsymbol{ \xi}}_{k}\rangle)\cdot\|\boldsymbol{\xi}_{i}\|_{2}^{2}\cdot\mathds{1}(y_{k}=-j). \tag{14}\]
Lemma 5.1 simplifies the analysis of the feature learning in GCNs by reducing it to the examination of the discrete dynamical system expressed by equations (11)-(14). Our proof strategy emphasizes an in-depth evaluation of the coefficient values \(\gamma_{j,r}^{(t)},\overline{\rho}_{j,r,i}^{(t)},\underline{\rho}_{j,r,i}^{( t)}\) throughout the training.
Figure 2: Illustration of performance comparison between GNN and CNN. The benign overfitting represents the setting under which the overfitted NN trained by gradient descent is guaranteed to have small test loss, and the harmful overfitting region represents the setting under which the test loss is of constant order (large). The red curve represents the separation condition between two phases for CNN, namely \(n\cdot\mathrm{SNR}^{q}=1\)[15]. Above the red line, CNN generalizes well; below the red line, CNN generalizes poorly. On the other hand, the blue curve represents the separation condition for GNN, namely \(n\cdot\mathrm{SNR}^{q}\sqrt{n(p+s)}^{q-2}=1\) (Theorem 4.3). Above the blue curve, GNN generalizes well. The orange band region above the blue curve but below the red curve highlights where GNN can outperform CNN.
### A two-phase dynamics analysis
We then propose a two-stage dynamics analysis to elucidate the behavior of these coefficients inspired by [15]. Subsequently, we can depict the generalization ability of GCN with the learned weight.
Stage 1.Intuitively, the initial neural network weights are small enough so that the neural network at initialization has constant level cross-entropy loss derivatives on all the training data: \(\ell_{i}^{\prime(0)}=\ell^{\prime}[y_{i}\cdot f(\mathbf{W}^{(0)},\tilde{\mathbf{ x}}_{i})]=\Theta(1)\) for all \(i\in[n]\). This is guaranteed under Condition 4.1 on \(\sigma_{0}\). Motivated by this, the dynamics of the coefficients in (12) - (14) can be greatly simplified by replacing the \(\ell_{i}^{\prime(t)}\) factors by their constant upper and lower bounds. The following lemma summarizes our main conclusion at stage 1 for signal learning:
**Lemma 5.2**.: _Under the same conditions as Theorem 4.3, there exists \(T_{1}=\tilde{O}(\eta^{-1}m\sigma_{0}^{2-q}\Xi^{-q}\|\boldsymbol{\mu}\|_{2}^{-q})\) such that_
* \(\max_{r}\gamma_{j,r}^{(T_{1})}=\Omega(1)\) _for_ \(j\in\{\pm 1\}\)_._
* \(|\rho_{j,r,i}^{(t)}|=O\left(\sigma_{0}\sigma_{p}\sqrt{d}/\sqrt{n(p+s)}\right)\) _for all_ \(j\in\{\pm 1\}\)_,_ \(r\in[m]\)_,_ \(i\in[n]\) _and_ \(0\leq t\leq T_{1}\)_._
The proof can be found in Appendix C.1. Lemmas 5.2 leverages the period of training when the derivatives of the loss function are of a constant order. It's important to note that graph convolution plays a significant role in diverging the learning speed between signal learning and noise memorization in this first stage. Originally, the learning speeds are roughly determined by \(\|\boldsymbol{\mu}\|_{2}\) and \(\|\boldsymbol{\xi}\|_{2}\) respectively. However, after applying graph convolution, the learning speeds are approximately determined by \(|\tilde{y}|\cdot\|\boldsymbol{\mu}\|_{2}\) and \(\|\boldsymbol{\xi}\|_{2}\) respectively. Here, \(|\tilde{y}|\cdot\|\boldsymbol{\mu}\|_{2}\) is close to \(\|\boldsymbol{\mu}\|_{2}\), but \(\|\tilde{\boldsymbol{\xi}}\|_{2}\) is much smaller than \(\|\boldsymbol{\xi}\|_{2}\) (see Figure 3 for an illustration). This means that graph convolution can slow down the learning speed of noise memorization, thus enabling GNNs to focus more on signal learning in the initial training stage.
Stage 2.Building on the results from the first stage, we then move to the second stage of the training process. In this stage, the loss derivatives are no longer constant, and we demonstrate that the training loss can be minimized to an arbitrarily small amount. Importantly, the scale differences established during the first stage of learning continue to be maintained throughout the training process:
**Lemma 5.3**.: _Let \(T,T_{1}\) be defined in Theorem 4.3 and Lemma 5.2 respectively and \(\mathbf{W}^{*}\) be the collection of GCN parameters \(\mathbf{w}_{j,r}^{*}=\mathbf{w}_{j,r}^{(0)}+2qm\log(2q/\epsilon)\cdot j\cdot \|\boldsymbol{\mu}\|_{2}^{-2}\cdot\boldsymbol{\mu}\). Then under the same conditions as Theorem 4.3, for any \(t\in[T_{1},T]\), it holds that:_
Figure 3: An illustrative example of noise vector before and after graph aggregation. In this example, we consider \(d=3\) and all degree are 1. The black vectors stand for noise vectors \(\boldsymbol{\xi}\) before graph convolution. Each of them are orthogonal to each other. The red vectors represent noise vectors after graph convolution \(\tilde{\boldsymbol{\xi}}\). They are graph convoluted noise vectors of two original noise vectors. Note that the \(\ell_{2}\) norm between two kinds of vector follows \(\|\tilde{\boldsymbol{\xi}}\|_{2}=\frac{\sqrt{2}}{2}\|\boldsymbol{\xi}\|_{2}\). This plot demonstrates how graph convolution shrinks the \(\ell_{2}\) norm of noise vectors.
* \(\max_{r}\gamma_{j,r}^{(T_{1})}\geq 2,\forall j\in\{\pm 1\}\) and \(|\rho_{j,r,i}^{(t)}|\leq\sigma_{0}\sigma_{p}\sqrt{d/(n(p+s))}\) for all \(j\in\{\pm 1\}\), \(r\in[m]\) and \(i\in[n]\).
* \(\frac{1}{t-T_{1}+1}\sum_{s=T_{1}}^{t}L_{\mathcal{S}}^{\mathrm{SCN}}(\mathbf{W}^ {(s)})\leq\frac{\|\mathbf{W}^{(T_{1})}-\mathbf{W}^{\star}\|_{F}^{2}}{(2q-1) \eta(t-T_{1}+1)}+\frac{\epsilon}{(2q-1)}\).
_Here we denote \(\|\mathbf{W}\|_{F}\triangleq\sqrt{\|\mathbf{W}_{+1}\|_{F}^{2}+\|\mathbf{W}_{- 1}\|_{F}^{2}}\)._
Lemma 5.3 presents two primary outcomes related to feature learning. Firstly, throughout this training phase, it ensures that the coefficients of noise vectors, denoted as \(\rho_{j,r,i}^{(t)}\), retain a significantly small value while coefficients of feature vector, denoted as \(\gamma_{j,r}^{(t)}\) can achieve large value. Furthermore, it offers an optimization-oriented outcome, indicating that the optimal iterate within the interval \([T_{1},T]\). In this process, graph convolution and gradient descent will continue to maintain the speed gap between signal learning and noise memory, and when the time is large enough, the training loss will tend to receive an arbitrarily small value.
### Test error analysis
Finally, we consider a new data point \((\mathbf{x},y)\) drawn from the distribution SNM-SBM. The lemma below further gives an upper bound on the test loss of GNNs post-training:
**Lemma 5.4**.: _Let \(T\) be defined in Theorem 4.3. Under the same conditions as Theorem 4.3, for any \(t\leq T\) with \(L_{\mathcal{S}}^{\mathrm{SCN}}(\mathbf{W}^{(t)})\leq 1\), it holds that \(L_{\mathcal{D}}^{\mathrm{SCN}}(\mathbf{W}^{(t)})\leq c_{1}\cdot L_{\mathcal{S }}^{\mathrm{SCN}}(\mathbf{W}^{(t)})+\exp(-c_{2}n^{2})\)._
The proof is presented in the appendix. Lemma 5.4 demonstrates that GNNs achieve _benign overfitting_ and completes the last step of feature learning theory.
## 6 Experiments
In this section, we validate our theoretical findings through numerical simulations using synthetic data, specifically generated according to the SNM-SBM model. We set the signal vector, \(\mathbf{\mu}\), to drawn from a standard normal distribution \(\mathcal{N}(\mathbf{0},\mathbf{I})\). The noise vector, \(\mathbf{\xi}\), is drawn from a Gaussian distribution \(\mathcal{N}(\mathbf{0},\sigma_{p}^{2}\mathbf{I})\). We train a two-layer CNN defined as per equation (2) and a two-layer GNN as per equation (5) with polynomial ReLU \(q=3\). We used the gradient descent method with a learning rate of \(\eta=0.03\). The primary task we focused on was node classification, where the goal was to predict the class labels of nodes in a graph.
Feature learning dynamics.Firstly, we display the training loss, test loss, training accuracy, and test accuracy for both the CNN and GNN in Figure 4. In this case, we further set the training data size to \(n=250\), input dimension to \(d=500\), noise strength to \(\sigma_{p}=20\), and edge probability to \(p=0.5\), \(s=0.08\). We observe that both the GNN and CNN can achieve zero training error. However, while the GNN obtains nearly zero test error, the CNN fails to generalize effectively to the test set. This simulation result serves to validate our theoretical results in Theorem 4.3 and Corollary 4.4.
Verification via real-world data.We conducted an experiment using real data, specifically by replacing the synthetic feature with MNIST input features. We select numbers 1 and 2 from the ten digital numbers, and applied both CNN and GNN models as described in our paper. Detailed results and visualizations can be found in the Figure 5. The results were consistent with our theoretical
Figure 4: Training loss, testing loss, training accuracy, and testing accuracy for both CNN and GNN over a span of 100 training epochs.
conclusions, reinforcing the insights derived from our analysis. We believe that this experiment adds a valuable dimension to our work, bridging the gap between theory and practice.
Phase diagram.We then explore a range of Signal-to-Noise Ratios (SNRs) from 0.045 to 0.98, and a variety of sample sizes, \(n\), ranging from 200 to 7200. Based on our results, we train the neural network for 200 steps for each combination of SNR and sample size \(n\). After training, we calculate the test accuracy for each run. The results are presented as a heatmap in Figure 6. Compared to CNNs, GCNs demonstrate a perfect accuracy score of 1 across a more extensive range in the SNR and \(n\) plane, indicating that GNNs have a broader _benign overfitting_ regime. This further validates our theoretical findings.
## 7 Conclusion and Limitations
This paper utilizes a signal-noise decomposition to study the signal learning and noise memorization process in training a two-layer GCN. We provide specific conditions under which a GNN will primarily concentrate on signal learning, thereby achieving low training and testing errors. Our results theoretically demonstrate that GCNs, by leveraging structural information, outperform CNNs in terms of generalization ability across a broader benign overfitting regime. As a pioneering work that studies feature learning of GNNs, our theoretical framework is constrained to examining the role of graph convolution within a specific two-layer GCN and a certain data generalization model. In fact, the feature learning of a neural network can be influenced by a myriad of other factors, such as activation function, optimization algorithm, and data model [48, 35, 37]. Future work can extend our framework to consider the influence of a wider array of factors on feature learning within GCNs.
|
2301.04225 | Inferring Gene Regulatory Neural Networks for Bacterial Decision Making
in Biofilms | Bacterial cells are sensitive to a range of external signals used to learn
the environment. These incoming external signals are then processed using a
Gene Regulatory Network (GRN), exhibiting similarities to modern computing
algorithms. An in-depth analysis of gene expression dynamics suggests an
inherited Gene Regulatory Neural Network (GRNN) behavior within the GRN that
enables the cellular decision-making based on received signals from the
environment and neighbor cells. In this study, we extract a sub-network of
\textit{Pseudomonas aeruginosa} GRN that is associated with one virulence
factor: pyocyanin production as a use case to investigate the GRNN behaviors.
Further, using Graph Neural Network (GNN) architecture, we model a single
species biofilm to reveal the role of GRNN dynamics on ecosystem-wide
decision-making. Varying environmental conditions, we prove that the extracted
GRNN computes input signals similar to natural decision-making process of the
cell. Identifying of neural network behaviors in GRNs may lead to more accurate
bacterial cell activity predictive models for many applications, including
human health-related problems and agricultural applications. Further, this
model can produce data on causal relationships throughout the network, enabling
the possibility of designing tailor-made infection-controlling mechanisms. More
interestingly, these GRNNs can perform computational tasks for bio-hybrid
computing systems. | Samitha Somathilaka, Daniel P. Martins, Xu Li, Yusong Li, Sasitharan Balasubramaniam | 2023-01-10T22:07:33Z | http://arxiv.org/abs/2301.04225v1 | # Inferring Gene Regulatory Neural Networks for Bacterial Decision Making in Biofilms
###### Abstract
Bacterial cells are sensitive to a range of external signals used to learn the environment. These incoming external signals are then processed using a Gene Regulatory Network (GRN), exhibiting similarities to modern computing algorithms. An in-depth analysis of gene expression dynamics suggests an inherited Gene Regulatory Neural Network (GRNN) behavior within the GRN that enables the cellular decision-making based on received signals from the environment and neighbor cells. In this study, we extract a sub-network of _Pseudomonas aeruginosa_ GRN that is associated with one virulence factor: pyocyanin production as a use case to investigate the GRNN behaviors. Further, using Graph Neural Network (GNN) architecture, we model a single species biofilm to reveal the role of GRNN dynamics on ecosystem-wide decision-making. Varying environmental conditions, we prove that the extracted GRNN computes input signals similar to natural decision-making process of the cell. Identifying of neural network behaviors in GRNs may lead to more accurate bacterial cell activity predictive models for many applications, including human health-related problems and agricultural applications. Further, this model can produce data on causal relationships throughout the network, enabling the possibility of designing tailor-made infection-controlling mechanisms. More interestingly, these GRNNs can perform computational tasks for bio-hybrid computing systems.
Gene Regulatory Networks, Graph Neural Network, Biofilm, Neural Network.
## I Introduction
Bacteria are well-known for their capability to sense external stimuli, for complex information computations and for a wide range of responses [1]. The microbes can sense numerous external signals, including a plethora of molecules, temperatures, pH levels, and the presence of other microorganisms [2]. The sensed signals then go through the Gene Regulatory Network (GRN), where a large number of parallel and sequential molecular signals are collectively processed. The GRN is identified as the main computational component of the cell [3], which contains about 100 to more than 11000 genes (the largest genome identified so far belongs to _Sorangium cellulosum_ strain So0157-2) [4]. Despite the absence of neural components, the computational process through GRN allows the bacteria to actuate through various mechanisms, such as molecular production, motility, physiological state changes and even sophisticated social behaviors. Understanding the natural computing mechanism of cells can lead to progression of key areas of machine learning in bioinformatics, including prediction of biological processes, prevention of diseases and personalized treatment [5].
Bacterial cells are equipped with various regulatory systems, such as single/two/multi-component systems including _Quorum sensing_ (QS), to respond to environmental stimuli. The receptors and transporters on cell membranes can react and transport extracellular molecules, which subsequently interact with respective genes. In turn, the GRN is triggered to go through a complex non-linear computational process in response to the input signals. In the literature, it has been suggested that the computational process through the GRN of a bacterial cell comprises a hidden neural network (NN)-like architecture [6, 7]. This indicates that, even though bacterial cells can be categorized as non-neural organisms, they perform neural decision-making processes through the GRN. This results in recent attention towards Molecular Machine Learning systems, where AI and ML are developed using molecular systems [8]. In these systems, several neural components can be identified in GRNs, in which genes may be regarded as
Fig. 1: Illustration of the Gene Regulatory Neural Networks (GRNN) extraction and the implementation of the GNN to model the biofilm. The diffusion of molecules from one cell to another is modeled as a vector, where \(m_{q}\) represents the concentration of the \(q^{th}\) molecular signal.
computational units or neurons, transcription regulatory factors as weights/biases and proteins/second messenger Molecular Communications (MC) as neuron-to-neuron interactions. Owing to a large number of genes and the interactions in a GRN, it is possible to infer sub-networks with NN behaviors that we term Gene Regulatory Neural Networks (GRNN). The non-linear computing of genes results from various factors that expand through multi-omics layers, including proteomic, transcriptomic and metabolomic data (further explained in Section II-A). In contrast, the GRNN is a pure NN of genes with summarized non-linearity stemmed from multi-omics layers with weights/biases.
Identification of GRNNs can be used to model the decision-making process of the cell precisely, especially considering simultaneous multiple MC inputs or outputs. However, due to the limited understanding and data availability, it is still impossible to model the complete GRN with its NN-like behaviors. Therefore, this study uses a GRNN of _Pseudomonas aeruginosa_ that is associated with _PhoR-PhoB_ and _BqsS-BqsR_ two-component systems (TCSs) and three QS systems related to pyocyanin production as a use case to explore the NN-like behaviors. Although a single bacterium can do a massive amount of computing, they prefer living in biofilms. Hence, in order to understand the biofilm decision-making mechanism, we extend this single-cell computational model to an ecosystem level by designing an _in-silico_ single species biofilm with inter-cellular MC signaling as shown in Fig. 1.
The contributions of this study are as follows:
* **Extracting a GRNN:** Due to the complexity and insufficient understanding of the gene expression dynamics of the full GRN, we only focus on a sub-network associated with pyocyanin production (shown in Fig. (a)a) to investigate the NN-like computational behavior of the GRN. Further, the genes of extracted sub-network are arranged following a NN structure that comprises input, hidden and output layers, as shown in Fig. (b)b.
* **Modeling a biofilm as a GNN:** The GRNN only represents the single-cell activities. To model the biofilm-wide decision-making process, we use a Graph Neural Network (GNN). First, we create a graph network of the bacterial cell and convert it to a GNN by embedding each node with the extracted GRNN as the update function. Second, the diffusion-based MCs between bacterial cells in the biofilm are encoded as the message-passing protocol of the GNN, as shown in Fig. (c)c.
* **Exploring the behaviors of the GRNN and intracellular MC dynamics to predict cell decisions:** The output of the GRNN is evaluated by comparing it with the transcriptomic and pyocyanin production data from the literature. Finally, an edge-level analysis of the GRNN is conducted to explore the causal relationships between gene expression and pyocyanin production.
This paper is organized as follows: Section II explains the background of bacterial decision-making in two levels: cellular-level in Section II-A and population-level in Section II-B, while the background on the _P. aeruginosa_ is introduced in Section II-C. Section III is dedicated to explaining the model design of cellular and population levels. The results related to model validation and the intergenic intra-cellular signaling pattern analysis are presented in Section IV and the study is concluded in Section V.
## II Background
As the model expands through single cellular and biofilm-wide decision-making layers, this section provides the background of how a bacterium uses the GRN to make decisions and how bacterial cells make decisions in biofilms. Moreover, we briefly discuss the cellular activities of the _Pseudomonas aeruginosa_ as it is the use case species of this study.
### _Decision-Making Process of an Individual Cell_
Prokaryotic cells are capable of sensing the environment through multiple mechanisms, including TCSs that have been widely studied and it is one of the focal points of this study. The concentrations of molecular-input signals from the extracellular environment influence the bacterial activities at the cellular and ecosystem levels [9]. Apart from the extracellular signals of nutrients, it is evident that the QS input signals have a diverse set of regulative mechanisms in biofilm-wide characteristics, including size and shape [10]. These input signals undergo a computational process through the GRN, exhibiting a complex decision-making mechanism. Past studies have explored and suggested this underpinning computational mechanism in a plethora of directions, such
Fig. 2: Extraction of a GRNN considering a specific sub-network of the GRN where a) is the two-component systems (TCSs) and QS network that is associated with the pyocyanin production, b) is the derived GRNN that is equipped with hypothetical nodes (**hns**) without affecting its computation process to form a symmetric network structure and c) is the conversion of real biofilm to the suggested _in-silico_ model.
as using differential equations [11] and probabilistic Boolean networks [12] and logic circuit [13]. All of these models mainly infer that the bacterial cells can make decisions not just based on the single input-output combinations, but they can integrate several incoming signals non-linearly to produce outputs.
The studies that focus on differences in gene expression levels suggest that a hidden weight behavior controls the impact of one gene on another [6]. This weight behavior emerges through several elements, such as the number of transcription factors that induce the expression, the affinity of the transcription factor binding site, and machinery such as thermoregulatory and enhancers/silencers [14, 15]. Fig. 3 depicts a set of factors influencing the weight between genes. The weight of an edge between two genes has a higher dynamicity as it is combinedly determined by several of these factors. Based on environmental conditions, the GRN of the bacterial cell adapts various weights to increase the survivability and repress unnecessary cellular functions to preserve energy. An example of such regulation is shown in Fig. 4 where a _P. aeruginosa_ cell uses a thermoregulatory to regulate the QS behaviors. Fig. 3(a) has a set of relative weights based on cell activities in an environment at 37\(\,{}^{\circ}\)C, while Fig. 3(b) represents weights at 30\(\,{}^{\circ}\)C. The weights between the **hn21** and _rhlR_ are different in two conditions, and these cellar activities are further explained in [14].
### _Biofilm Decision-Making_
Even though an individual cell is capable of sensing, computing, and actuating, the majority of bacterial cells live in biofilms, where the survivability is significantly increased compared to their planktonic state. Biofilm formation can cause biofouling and corrosion in water supply and industrial systems [16]. However, biofilms formation can be desirable in many situations, for example, bioreactors in wastewater treatment [17], bioremediation of contaminated groundwater [18, 19], where biofilms serve as platforms for biogeochemical reactions. A massive number of factors can influence biofilm formation, including substrant surface geometrical characteristics, diversity of species constituting the biofilm, hydrodynamic conditions, nutrient availability, and especially communication patterns [20] where the TCS and QS play significant roles. A TCS comprises a _histidine kinase_ that is the sensor for specific stimulus and a cognate response regulator that initiates expressions of a set of genes [21]. Hence, in each stage, essential functions can be traced back to their gene expression upon a response to the input signals detected by bacterial cells. For instance, in the first stage of biofilm formation, the attachment of bacteria to a surface is associated with sensing a suitable surface and altering the activities of the flagella. In the next stage, _rhramnolipids_ production is associated with ferric iron Fe\({}^{3+}\) availability in the environment, mostly sensed through _BqsS-BqsR_ TCSs. Further, Fe\({}^{3+}\) was identified as a regulator of _pqSA_, _pqsR_, and _pqsE_ gene expressions that are associated with the production of two critical components for the formation of microcolonies: eDNA and EPS [22]. Similarly, in the final stage, the dispersion process can also be traced back to a specific set of gene regulations, including _bdlA_ an _rbdA_[23, 24]. An understanding of the underlying decision-making process of bacteria may enable us to control their cellular activities.
### _Pseudomonas Aeruginosa_
The main reason for selecting _P. aeruginosa_ in this work lies in its alarming role in human health. For example, this species is the main cause of death in cystic fibrosis patients [25]. _P. aeruginosa_ is a gram-negative opportunistic pathogen with a range of virulence factors, including pyocyanin and cytotoxin secretion [26]. These secreted molecules can lead to complications such as respiratory tract ciliary dysfunction and induce proinflammatory and oxidative effects damaging the host cells [27]. The biofilms are being formed on more than 90% endotracheal tubes implanted in patients who are getting assisted ventilation, causing upper respiratory tract infections [28]. In addition, another important reason for targeting _P. aeruginosa_ is the data availability for the GRN structure [29], pathways [30], genome [31], transcriptome [32] and data from mutagenesis studies [33, 34]. Compared to the complexity of the GRN, the amount of data and information available on the
Fig. 4: Two GRNN setups with different weights associated with two environmental conditions. a) is the relative weight setup of _P. aeruginosa_ cell in 37\(\,{}^{\circ}\)C and b) is in 30\(\,{}^{\circ}\)C.
Fig. 3: Illustration of gene expression regulators that are considered the weight influencers of the edges of GRNN. Here, the \(\alpha_{(\varphi)}\), \(\alpha_{(\sim\varphi)}\), \(\alpha_{(TF)}\), \(\alpha_{(Rep)}\), \(\alpha_{(eTF)}\) and \(\alpha_{(sTF)}\) are relative concentrations of sigma factors, anti-sigma factors, transcription factors (TFs), repressors, enhancer-binding TFs and silencer-binding TFs respectively. Moreover, \(\beta_{(Prom)}\), \(\beta_{(Eph)}\), and \(\beta_{(Sil)}\) are the binding affinities of the promoter, operator, enhancer and silencers regions respectively.
gene-to-gene interactions and expression patterns is insufficient to develop an accurate full _in-silico_ model. Therefore, we chose a set of specific genes that are associated with QS, TCS, and pyocyanin production.
## III System design
This section explains the system design in two main phases, extracting a NN-like architecture from the GRN targeting the set of genes and creating a model of the biofilm ecosystem.
### _Extracting Natural Neural Network from GRN_
We first fetch the structure of the GRN graph from Reg-ulomePA [29] database that contains only the existence of interactions and their types (positive or negative). As the next step, using information from the past studies [35, 36, 37, 38], we identified the genes involved in the **Las**, **Rhl** and **PQS** QS systems, _PhoR-PhoB_ and _BqsS-BqsR_ TCSs, and pyocyanin production to derive the sub-network of GRN as shown in Fig 2a. We further explored the expression dynamics using transcriptomic data [39, 40] where we observed the non-linearity in computations that are difficult to capture with existing approaches such as logic circuits, etc. [6], making the NN approach more suitable. However, a NN model with a black box that is trained on a large amount of transcriptomic data records to do computations similar to the GRN has a number of limitations, especially in understanding the core of the computational process [41]. Our model does not use a conventional NN model; instead, we extract a NN from the interaction patterns of the GRN, which we consider a pre-trained GRNN. In this sub-network, we observed that the lengths of expression pathways are not equal. For example, the path from _PhoR-PhoB_ to the _phz2_ gene has two hops, but the path from the _BqsS-BqsR_ system to the _rhlR_ gene only has one hop. The extracted network has the structure of a random NN. Hence, we transform this GRNN to Gene Regulatory Feedforward Neural Network by introducing hypothetical nodes (**hns**) that do not affect the behaviors of the GRNN as shown in Fig 2b. In this transformation, we decide the number of hidden layers based on the maximum number of hops in gene expression pathways. In our network, the maximum number of hops is two, which determines the number of hidden layers as one, and then the number of hops of all the pathways is leveled by introducing **hns**. If a **hn** is introduced between a source and target genes, the edge weights from the source node to the **hn** and from **hn** to the target node are made "1" so that the **hn** does not have an influence on the regulation of genes. Moreover, if a gene does not induce another in the network, the weight of the edge between that pair is made "0".
Here, we summarize multiple factors of interaction into a weight that determines the transcriptional regulation of a particular gene. This regulation process occurs when the gene products get bound to the promoter region of another, influencing the transcriptional machinery. Hence, we observe this regulation process of a target gene as a multi-layered model that relies on the products of a set of source genes, the interaction between gene products, and the diffusion dynamics within the cell. Creating a framework to infer an absolute weight value using all the above factors is a highly complex task. In order to infer weight, one method is to train a NN model with the same structure as the GRN using a series of transcriptomic data. However, this approach also has numerous challenges, such as the lack of a sufficient amount of data in similar environments.
Therefore, we estimate a set of relative weights based on genomic, transcriptomic, and proteomic explanations of each interaction from the literature. The weights were further fine-tuned using the transcriptomics data. A relative weight value of an edge can be considered a summarizing of multi-layer transcriptional-translation to represent the impact of the source gene on a target gene.
In this computational process, we identify another layer of interactions that occur within the cell. The produced molecules by the considered TCs network go through a set of metabolic interactions that are crucial for the functionality of the cell. Since our primary goal is to explore the NN behaviors of GRN, we model these inter-cellular chemical reactions as a separate process, keeping the gene-to-gene interactions and metabolic interactions in two different layers. To model the complete pyocyanin production functionality of the cell, we use the inter-cellular molecular interactions shown in Fig 5. Here, RhlR is a transcriptional regulator of _P. aeruginosa_ that forms a complex by getting attached to its cognate inducer C4-HSL and then binds to the promoter regions of relevant genes [42]. Similarly, LasR transcriptional regulator protein and 3-oxo-C12-HSL (3OC), and PqsR with PQS and HHQ form complexes and get involved in the regulation of a range of genes [43, 44]. Further, C10H10O6 in the environment are converted by the _P. aeruginosa_ cells in multiple steps using the products of the GRN we consider. First, C10H10O6 is converted into phenazine-1-carboxylic using the enzymes of _pqsABCDEFG_ genes. Later, phenazine-1-carboxylic was converted into 5-Methylphenazine-1-carboxylate, and finally, 5-Methylphenazine-1-carboxylate into Pyocyanin by PhzM and PhzS, respectively [45].
Molecular accumulation within a bacterial cell can be considered its memory module where certain intra-cellular interactions occurs. Therefore, we define an internal memory matrix \(IM\) as,
\[\begin{array}{ccccc}&im_{1}&im_{2}&...&im_{J}\\ &B_{1}&\begin{pmatrix}C_{1,im_{1}}^{(t)}&C_{1,im_{2}}^{(t)}&...&C_{1,im_{J}}^{( t)}\\ C_{(2,im_{1})}^{(t)}&C_{(2,im_{2})}^{(t)}&...&C_{2,im_{J}}^{(t)}\\ \vdots&\vdots&\ddots&\vdots\\ &B_{P}&\begin{pmatrix}C_{(P,im_{1})}^{(t)}&C_{(P,im_{2})}^{(t)}&...&C_{(P,im_{J })}^{(t)}\\ \end{pmatrix},\end{array}\end{array} \tag{1}\]
where the concentration of the internal molecule \(im_{j}\) is
Fig. 5: Illustrations of intra-cellular metabolite interaction.
\(C_{(i,im_{j})}^{(t)}\).
GRNN process molecular signals from the environment and other cells. Hence, we used the approach of GNN as a scalable mechanism to model the MCs and biofilm wide decision-making process. The extreme computational power demand of modeling the diffusion-based MCs of each cell is also avoided by using this approach.
### _Graph Neural Network Modeling of Biofilm_
First, the biofilm is created as a graph network of bacterial cells where each node is a representation of a cell, and an edge between two nodes is a MC channel. We convert the graph network into a Graph Neural Network (GNN) in three steps: 1) embedding the extracted GRNN of pyocyanin production into each node as the update function, 2) encoding the diffusion-based cell-to-cell MC channels as the message passing scheme, and 3) creating an aggregation function at the reception of molecular messages by a node as shown in Fig. 6. Next, we define feature vectors of each node of the GNN to represent the gene expression profile of the individual cell at a given time. Subsequently, considering \(L\) is the number of genes in the GRNN, \(P\) is the number of bacterial cells in the biofilm and \(b_{(i,g)}^{(t)}\) is the expression of gene \(g_{l}\) by the bacteria \(B_{i}\), we derive the following matrix \(\mathbf{FV}^{(t)}\) that represents all the feature vectors of the GNN at time \(t\).
\[\mathbf{FV}^{(t)}=\begin{array}{ccccc}g_{1}&g_{2}&...&g_{L}\\ B_{1}&\begin{pmatrix}b_{(1,g_{1})}^{(t)}&b_{(1,g_{2})}^{(t)}&...&b_{(1,g_{L}) }^{(t)}\\ b_{(2,g_{1})}^{(t)}&b_{(2,g_{2})}^{(t)}&...&b_{(2,g_{L})}^{(t)}\\ \vdots&\vdots&\ddots&\vdots\\ B_{P}&\begin{pmatrix}b_{(P,g_{1})}^{(t)}&b_{(P,g_{2})}^{(t)}&...&b_{(P,g_{L}) }^{(t)}\end{pmatrix}\end{array}\end{array} \tag{2}\]
The computational output of the GRNN of each node results in the secretion of a set of molecules that are considered messages in our GNN model as illustrated in the Fig. 7.
When the number of molecular species considered in the network is \(Q\) and output \(m_{q}\) molecular message from bacterial cell \(B_{i}\) at TS \(t\) is \(msg_{(i,m_{q})}^{(t)}\), we derive the matrix
\[\mathbf{MSG}^{(t)}=\begin{array}{ccccc}m_{1}&m_{2}&...&m_{Q}\\ B_{1}&\begin{pmatrix}msg_{(1,m_{1})}^{(t)}&msg_{(1,m_{2})}^{(t)}&...&msg_{(1, m_{Q})}^{(t)}\\ msg_{(2,m_{1})}^{(t)}&msg_{(2,m_{2})}^{(t)}&...&msg_{(1,m_{Q})}^{(t)}\\ \vdots&\vdots&\ddots&\vdots\\ B_{P}&\begin{pmatrix}msg_{(P,m_{1})}^{(t)}&msg_{(P,m_{2})}^{(t)}&...&msg_{(P, m_{Q})}^{(t)}\end{pmatrix}\end{array} \tag{3}\]
Further, we use a static diffusion coefficients vector
\[\mathbf{D}=\{D_{m_{1}},D_{m_{2}},...,D_{m_{Q}}\}, \tag{4}\]
where \(D_{m_{q}}\) is diffusion coefficient of molecular species \(m_{q}\).
We define another matrix \(\mathbf{ED}\) that contains the euclidean distances between bacterial cells in the biofilm as follows
\[\mathbf{ED}=\begin{array}{ccccc}B_{1}&B_{2}&...&B_{P}\\ B_{1}&\begin{pmatrix}d_{(1,1)}&d_{(1,2)}&...&d_{(1,P)}\\ B_{2}&d_{(2,1)}&d_{(2,2)}&...&d_{(2,P)}\\ \vdots&\vdots&\ddots&\vdots\\ B_{P}&\begin{pmatrix}d_{(P,1)}&d_{(P,2)}&...&d_{(P,P)}\end{pmatrix}\end{array} \tag{5}\]
where \(d_{i,j}\) is the euclidean distance between the \(i^{th}\) and \(j^{th}\) cells.
Fig. 6: Illustration of the GNN components where a) is a snapshot of the bacterial network that has the gene expression profile as the feature vector. Further, this gene expression pattern of a cell is encoded to a message of secreted molecules where MC plays a crucial role. Moreover, b) shows the temporal behavior of the GNN, that the output of one graph snapshot influences the next.
Fig. 7: The process of one GRNN outputs reaching another GRNN as molecular messages.
The feature vector of \(i^{th}\) bacterial cell at the TS \(t+1\) is then modeled as,
\[\mathbf{FV}_{i}^{(t+1)}=GRNN_{i}(\mathbf{MSG}_{i}^{(t)}+S_{i}^{(t)}) \tag{6}\]
where \(MSG_{i}^{(t)}\) is the message generated by the same cell in the previous TS. The \(GRNN_{i}\) is the extracted GRNN that is the update function in the GNN learning process and \(\mathbf{S}_{i}^{(t)}=\mathbf{R}_{i}^{(t)}+\mathbf{K}_{i}^{(t)}\), is the aggregate function. In the aggregation component, the \(\mathbf{R}_{i}^{(t)}\) is the incoming signals from peer bacterial cells and \(K_{(i:m_{q})}^{(t+1)}\) is the external molecule input vector at the location of \(B_{i}\) and the TS \(t\) that is expressed as
\[\mathbf{K}_{i}^{(t+1)}=\big{\{}K_{i:m_{1}}^{(t+1)},K_{:i:m_{2}}^{(t+1)},...,K_{ :m_{Q}}^{(t+1)}\big{\}}. \tag{7}\]
In order to compute \(\mathbf{R}_{i}^{(t+1)}\), we use a matrix \(\mathbf{Y}_{i}\); \(\mathbf{Y}_{i}=\overset{\leftrightarrow}{1}_{[Q\times 1]}\times\)ED\({}_{i}\), where \(\overset{\leftrightarrow}{1}_{[Q\times 1]}\) is an all-ones matrix of dimension \(Q\times 1\). The \(\hat{g}\) matrix is then defined as follows,
\[\mathbf{\hat{g}}(\mathbf{D}^{\intercal},\mathbf{Y},t)= \tag{8}\] \[\begin{bmatrix}g(D_{m_{1}},d_{(i,1)},t)&g(D_{m_{1}},d_{(i,2)},t)&...&g(D_{m_{1}},d_{(i,P)},t)\\ g(D_{m_{2}},d_{(i,1)},t)&g(D_{m_{2}},d_{(i,2)},t)&...&g(D_{m_{2}},d_{(i,P)},t) \\ \vdots&\vdots&\ddots&\vdots\\ g(D_{m_{Q}},d_{(i,1)},t)&g(D_{m_{Q}},d_{(i,2)},t)&...&g(D_{m_{Q}},d_{(i,P)},t) \end{bmatrix}\]
In the above matrix, \(g(D_{m_{l}},d_{(i,j)},t)\) is the Green's function of the diffusion equation as shown below,
\[\hat{G}(D_{m_{l}},d_{(i,j)},t)=\frac{1}{\left(4\pi D_{m_{l}}t\right)^{\frac{ 3}{2}}}\exp\left(-\frac{d_{(i,j)}^{2}}{4D_{m_{l}}t}\right). \tag{9}\]
Further, the incoming signal vector \(\mathbf{R}_{i}^{(t+1)}\) is denoted as below,
\[\mathbf{R}_{i}^{(t+1)}=diag\big{(}\mathbf{\hat{g}}(\mathbf{D}^{\intercal}, \mathbf{Y},t)\times\mathbf{MSG}^{(t)}\big{)}. \tag{10}\]
Further, we equip our model with a 3-D environment to compensate for the noise element and external molecule inputs. Environment-layer is designed as a 3-D grid of voxels that can store precise information on external nutrients (similarly to our previous model in [46]). The diffusion of nutrient molecules through the medium is modeled as a random-walk process. This layer allows us to enrich the model with the dynamics of nutrient accessibility of bacterial cells due to diffusion variations between the medium and the Extracellular Polymeric Substance (EPS).
The bacterial cells in the ecosystem also perform their own computing tasks individually, resulting in a massively parallel processing framework. Hence, we use the python-cuda platform to make our model closer to the parallel processing architecture of the biofilm, where we dedicate a GPU block for each bacterial cell and the threads of each block for the matrix multiplication of the GRNN computation associated with the particular cell. Additionally, due to the massive number of iterative components in the model, the computational power demand faces significant challenges with serial programming making parallelization the best match for the model.
## IV Simulations
In this section, we first explain the simulation setup and then discuss the results of gene expression and molecular production dynamics to prove the accuracy of the extracted GRNN, emphasizing that it works similarly to the real GRN. Later, we use computing through the GRNN to explain certain activities of the biofilm.
### _Simulation Setup_
As our interest is to investigate the NN-like computational process, we do not model the formation process of the biofilm, but we only remodel a completely formed biofilm and disregarding the maturation and dispersion stages. In this model, we consider the biofilm as a static 3-D structure of bacterial cells. Hence, we first place bacterial cells randomly in the model in a paraboloid shape using the equation, \(z<\frac{x^{2}}{5}+\frac{y^{2}}{5}+20\) where \(x\), \(y\) and \(z\) are the components of 3-D Cartesian coordinates. This paraboloid shape is chosen to make the spacial arrangement of the cells close to real biofilm while keeping the cell placement process mathematically simple. Within this 3-D biofilm region, we model the diffusivity according to \(D_{B}/D_{aq}=0.4\), which is the mean relative diffusion [47] where \(D_{B}\) and \(D_{aq}\) are the average molecular diffusion coefficients of the biofilm and pure water, respectively. Further, to start the simulation at a stage where the biofilm is fully formed and the MC is already taking place, we filled the internal memory vector of each cell with the average molecular level at the initial TS. Each bacterial cell will use the initial signals from the internal memory and use its GRNN to process and update the feature vector for the next TS. Table I presents the parameter descriptions and values used for the simulation. As shown in Table I, the model runs for 150 TSs, generating data on a range of functions for the system. For instance, this model can produce data on feature vector of each cell, MC between cells,
\begin{table}
\begin{tabular}{l r r} \hline
**Parameter** & **Value** & **Description** \\ \hline No. of cells & 2000 & The number of cells is limited due to the memory availability of the server. \\ No. of genes & 13 & The network only consists of the gene that are directly associated with QS, _PhoR-PhoB_ and _BqsS-BqsR_ TCSs, and pyeocyanin production. \\ No. internal memory molecules & 16 & The set of molecules that involved in QS, _PhoR-PhoB_ and _BqsS-BqsR_ TCSs,and ppyocyanin production. \\ No. messenger molecules & 4 & The number of molecules that were exchanged between cells in the sub network. \\ Dimensions of the environment & 20x20x20\(\mu m\) & The dimensions were fixed considering the average sizes of _P. aeruginosa_ biofilms and computational demand of the model. \\ Duration & 150 TSs & The number of TSs can be modified to explore the cellular and ecosystem level activities. For this experiment we fixed a TS to represent 30mins. \\ No. iterations per setup & 10 & Considering the stochasticity ranging from the gene expression to ecosystem-wide communications, the experiments were iterated 10 times. \\ \hline \end{tabular}
\end{table} TABLE I: Parameters utilised in the system development
molecular consumption by cells, secretion to the environment, and nutrient accessibility of cells for each TS.
In order to prove that our GRNN computes similarly to the natural bacterial cell and collective behaviors of the cells are the same as the natural biofilm, we conduct a series of experiments. We explore the GRNN computation and biofilm activities under High Phosphate (HP) and Low Phosphate (LP) levels using eight experimental setups as follows, 1) wild-type bacteria (WD) in LP, 2) _lasR_ mutant (_lasR\(\Delta\)_) in LP, 3) phoB mutant (_phoB\(\Delta\)_) in LP, 4) _lasR_ & PhoB double mutant (\(\text{LasR}\Delta\text{PhoB}\Delta\)) in LP, 5) WD in HP, 6) _lasR\(\Delta\)_ in HP, 7) _PhoB\(\Delta\)_ in HP and _LasR\(\Delta\)PhoB\(\Delta\)_ in HP. While the WD uses the full GRNN, _lasR\(\Delta\)_ is created by making the weight of the link between _hn22_ and _lasR_ as "0". Further, the GRNN of _phoB\(\Delta\)_ is created by making the weights of links from _PhoB_ to _hn23_ and _PhoB_ to _pqsABCDE_ also "0".
### _Model Validation_
First, we show the nutrient accessibility variation in the biofilm through Fig 8. The cells in the biofilm core have less accessibility while the cells closer to the periphery have more access to nutrients due to variations in diffusion between the environment and the EPS. Fig 8 shows that when a low phosphate concentration is introduced to the environment, the direct access to the nutrient by the cells is limited. After the \(TS=10\), around 60% of cells have access to 20% of the nutrient concentration. Further, Fig 8 shows that the increased nutrient introduction to the environment positively reflects on the accessibility. This accessibility plays a role mainly in the deviation of gene expression patterns resulting in phenotypic differentiations that is further analyzed in Section IV-C.
Comparing the predictions of molecular production through GRNN computing with the wet-lab experimental data from the literature, we are able to prove that the components of the GRN work similarly to a NN. Fig. 9 shows the pyocyanin accumulation variations of the environment in the eight setups mentioned earlier as results of decision-making of the GRNN. Production of pyocyanin of the WD _P. aeruginosa_ biofilms is high in LP, compared to the HP environments as shown in Fig: 9. Further, the same pattern can be observed in the _lasR\(\Delta\)_ biofilms, but with a significantly increased pyocyanin production in LP as shown in Fig. 9. The _phob\(\Delta\)_ and _LasR\(\Delta\)phob\(\Delta\)_ biofilms produce a reduced level of pyocyanin compared to WD and _LasR\(\Delta\)_ that are shown in Fig. 9 and Fig. 9 respectively. We then present a comparison between GRNN prediction and wet-lab experimental data [48] as ratios of HP to LP in Fig. 10. The differences between pyocyanin production through GRNN in HP and LP condition for all the four setups in Fig. 10 are fairly close to the wet-lab data. In the WD setup, the difference between the GRNN model and wet-lab data only has around 5% difference, while deviations around 10% can be observed in _lasR\(\Delta\)_ and _phoB\(\Delta\)_. The most significant deviation around 20% of pyocyanin production difference is visible in _lasR\(\Delta\)phoB\(\Delta\)_ that is caused by the lack of interaction from other gene expression pathways, as we only extracted a sub-network portion of the GRN. Therefore, these results prove that the extracted GRNN behaves similarly to the GRN dynamics.
We further prove that the GRNN computing process performs similarly to the GRN by comparing the gene expression behaviors of the model with the wet-lab data [48] as shown in Fig. 11. First, we show the expression dynamics of genes _lasI_, _pqsA_ and _rhR_ of WD in LP in Fig. 11, Fig. 11 and Fig. 11 respectively. All the figures depict that gene expression levels are higher in LP compared to HP until around \(TS=100\). Beyond that point, relative gene expression levels are close to zero as the the environment run out of nutrients. Moreover, the differences in gene expression levels predicted by the GRNN
Fig. 8: The nutrient accessibility variations of cells is expressed in two different environment conditions: a) low phosphate and b) high phosphate concentrations.
Fig. 10: Evaluation of the model accuracy by comparing HP to LP pyocyanin production ratio with wet-lab data from [48].
Fig. 9: Relative Pyocyanin accumulation of four different biofilms of a) WD, b) lasR\(\Delta\), c) phoB\(\Delta\) and d) lasR\(\Delta\)phob\(\Delta\) in both low and high phosphate levels.
computing for LP and HP are also compared with the wet-lab data in Fig. (d)d. In this comparison, it is evident that the predicted gene expression differences of all three genes are close to the wet-lab data with only around 10% variation. The performance similarities between the GRNN and real cell activities once again prove that the GRN has underpinning NN-like behaviors.
### _Analysis of GRNN Computing_
Fig. 12 and Fig. 13 are used to show the diverse information flow of the GRNN that cause the variations in pyocyanin
Fig. 11: Expression levels of three different genes to that were used to prove the accuracy of the GRNN: a) _lasI_, b) _pqSA_, c) _rhIR_ expression levels in LP and HP and d) comparison between GRNN computing results and wet-lab data.
Fig. 12: Gene expression and associated information flow variations in GRNNs of a) WD b) _lasR\(\Delta\)_ and c) phoB\(\Delta\) in LP.
Fig. 13: Gene expression and associated information flow variations in GRNNs of a) WD b) _lasR\(\Delta\)_ and c) phoB\(\Delta\) in HP.
production in LP and HP conditions, respectively. Here, we use gene expression profiles extracted from one bacterial cell located at (7, 9, 2)\(\mu\)m in the Cartesian coordinates that is in the middle region of the biofilm with limited access to the nutrients. First, the gene expression variations of WD, _lasR\(\Delta\)_, and _phob\(\Delta\)_ bacterial cells in LP (Fig. 12) and HP (Fig. 13) are shown for \(TS<50\). Next, the information flow through the GRNN is illustrated above each expression profile at time \(TS=20\), where the variations will be discussed. In Fig. (a)a, impact of the inputs 3OC-LasR and phosphate cause higher expression levels of the nodes **hn12** and _phoB_ in the input layer that cascade the nodes _phZ1_, _phZ2_, _pqsR_, _lasR_, 3OC, _rhlR_ and _PqsH_ in the output layer at \(TS=20\). Fig. (b)b has significantly higher _pqsA_ operon expression levels compared to HP conditions (Fig. (b)b), reflecting higher yyocanin production that can be seen in Fig. (b)b. Nevertheless, the reduced gene expression levels, except _pqsA_ operon, of _lasR\(\Delta\)_ biofilm in both LP (Fig. (b)b) and HP (Fig. (b)b) conditions compared to the other setups emphasize that the inputs via inter-cellular MC significantly alter GRNN computing outputs. In contrast, only a smaller gene expression difference can be observed between the two setups of _phob\(\Delta\)_ in LP (Fig. (c)c and _phob\(\Delta\)_ in HP (Fig. (c)c) resulting in minimized myocardium production differences as shown earlier in Fig. (c)c.
The GRNN model supports the understanding of the gene expression variations due to factors such as nutrient accessibility, where in our case is a single species biofilm. Fig. 14 depicts the variability in the gene expression levels for four different locations of the biofilm at \(TS=3\). Fig. (a)a and Fig. (b)b are the gene expression profiles and the signal flow through GRNN pairs of two cells located close to the attached surface and the center of the biofilm. The phosphate accessibility for these two locations is limited. Hence, edges from _phob_ have a higher information flow compared to the other two cells near the periphery of the biofilm, which can be observed in Fig. (c)c and Fig. (d)d. The microbes in the center (Fig. (a)a) and the bottom (Fig. (b)b) mainly have access to the inter-cellular MCs, while the other two bacteria have direct access to the extracellular phosphate.
This GRNN produced data can further be used to understand the spatial and temporal dynamics of phenotypic clustering of gene expressions which is important in predicting and diagnosis of diseases [49]. Fig. 15 shows the phenotypic variation of WD biofilm in LP. Fig. (a)a shows the number of cluster variations over the first 30 \(TSs\) when the significant phenotypic changes of the biofilm is evident. At around \(TS=9\) and \(TS=10\), the bacterial cells have the most diverse expression patterns due to the highest extracellular nutrient penetration (can be seen in Fig. (a)a) to the biofilm and inter-cellular communications. Here we use four TSs (\(TS=5\) - Fig. (b)b, \(TS=15\) - Fig. (c)c, \(TS=23\) - Fig. (d)d and \(TS=30\) - Fig. (e)e) to analyze this phenotypic differentiation. Each pair of Uniform Manifold Approximation and Projection (UMAP) plot and diagram of cell locations of each cluster explain how nutrient accessibility contribute to the phenotypic clustering. Although at \(TS=5\) (Fig. 15) the average number of clusters is over four, there are only two major clusters that can be observed with higher proportions, as shown in the pie chart. Among the two major clusters (blue and green) of Fig. (b)b, the bacteria in the blue cluster can mostly be found in the
Fig. 14: Illustration of GRNN information flow variations concerning the particular positions of cells within the biofilm. We selected four cells at a) [10, 10, 0] – close to the attached surface, b) [10, 10, 5]- close to the periphery, c) [7, 10, 13] – at the center and d) [3, 15, 0] – close to the attached surface and the periphery of the biofilm.
center of the biofilm, while the green cluster cells are close to the periphery. Fig. 15c and Fig. 15d have more clusters as the nutrient accessibility among cells is high. In contrast, due to the lack of nutrients in the biofilm, a limited number of clusters can be seen in the biofilm after around \(TS=30\), which can be observed Fig. 15e.
## V Conclusion
The past literature has captured the non-linear signal computing mechanisms of Bacterial GRNs, suggesting underpinning NN behaviors. This study extracts a GRNN with summarized multi-omics gene expression regulation mechanisms as weights that can further analyze gene expression dynamics, design predictive models, or even conduct _in-vivo_ computational tasks. We used _P. aeruginosa_ single species biofilm as a use case and extracted relevant gene expression data from databases such as RegulomePA and transcriptomic data from databases including GEO. Due to the complexity of the GRN and expression dynamics, we only considered a smaller sub-network of the GRN as a GRNN that is associated with QS, iron and phosphate inputs, and pyocyanin production. Considering this GRNN, we modeled the computation process that drives cellular decision-making mechanism. As bacteria live in ecosystems in general where intra-cellular communication play a significant role in cellular activities, an _in-silico_ biofilm is modeled using GNN to further analyze the biofilm-wide decision-making. A comparison between the GRNN generated data and the transcriptomic data from the literature exhibits that the GRN behaves similarly to a NN. Hence, this model can explore the causal relationships between gene regulation and cellular activities, predict the future behaviors of the biofilm as well as conduct bio-hybrid computing tasks. Further, in the GRNN extraction phase, we were able to identify the possibility of modeling more network structures with various number of input nodes, hidden layers, and output nodes. In addition, GRN components including auto regulated genes and bidirectional intergenic interactions hints the possibility of extracting more sophisticated types of GRNNs such as Recurrent NN and Residual NN in the future. The idea of extracting sub-networks as NNs can lead to more intriguing intra-cellular distributed computing. Further, this model can be extended to multi-species ecosystems for more advanced predictive models as well as distributed computing architectures combining various NNs.
|
2301.11166 | Flex-Net: A Graph Neural Network Approach to Resource Management in
Flexible Duplex Networks | Flexible duplex networks allow users to dynamically employ uplink and
downlink channels without static time scheduling, thereby utilizing the network
resources efficiently. This work investigates the sum-rate maximization of
flexible duplex networks. In particular, we consider a network with
pairwise-fixed communication links. Corresponding combinatorial optimization is
a non-deterministic polynomial (NP)-hard without a closed-form solution. In
this respect, the existing heuristics entail high computational complexity,
raising a scalability issue in large networks. Motivated by the recent success
of Graph Neural Networks (GNNs) in solving NP-hard wireless resource management
problems, we propose a novel GNN architecture, named Flex-Net, to jointly
optimize the communication direction and transmission power. The proposed GNN
produces near-optimal performance meanwhile maintaining a low computational
complexity compared to the most commonly used techniques. Furthermore, our
numerical results shed light on the advantages of using GNNs in terms of sample
complexity, scalability, and generalization capability. | Tharaka Perera, Saman Atapattu, Yuting Fang, Prathapasinghe Dharmawansa, Jamie Evans | 2023-01-20T12:49:21Z | http://arxiv.org/abs/2301.11166v2 | # Flex-Net: A Graph Neural Network Approach to Resource Management in Flexible Duplex Networks
###### Abstract
Flexible duplex networks allow users to dynamically employ uplink and downlink channels without static time scheduling, thereby utilizing the network resources efficiently. This work investigates the sum-rate maximization of flexible duplex networks. In particular, we consider a network with pairwise-fixed communication links. Corresponding combinatorial optimization is a non-deterministic polynomial (NP)-hard without a closed-form solution. In this respect, the existing heuristics entail high computational complexity, raising a scalability issue in large networks. Motivated by the recent success of Graph Neural Networks (GNNs) in solving NP-hard wireless resource management problems, we propose a novel GNN architecture, named Flex-Net, to jointly optimize the communication direction and transmission power. The proposed GNN produces near-optimal performance meanwhile maintaining a low computational complexity compared to the most commonly used techniques. Furthermore, our numerical results shed light on the advantages of using GNNs in terms of sample complexity, scalability, and generalization capability.
## I Introduction
Recently, time division duplex (TDD) methods have become more popular compared to frequency division duplex (FDD) methods [1], since TDD methods perform better when uplink and downlink data rates are asymmetric. In this paper, we investigate the resource allocation of TDD networks which allow users only to transmit or receive at a given time slot, i.e., half-duplex. Typically in a TDD network, uplink and downlink time slots are predefined. This predefined nature can be relaxed to increase the utilization of the network by allowing dynamic scheduling of communication direction. Such networks are known as flexible duplex networks [2].
The advantages of dynamic scheduling come at a cost. It introduces a challenging combinatorial optimization problem that is mathematically challenging and computationally expensive to solve. There are various algorithms suggested in the literature for resource scheduling in flexible duplex networks. Previous works include iterative pattern search algorithms for resource scheduling in flexible duplex networks [2, 3], radio frame selection algorithm for flexible duplex networks [1], a flexible duplex framework for joint uplink and downlink resource allocation [4], and resource management with flexible duplex in Narrowband Internet of things (NB-IoT) [5], to name a few. In [6], authors propose a flexible duplex network with fixed node pairs under the assumption of a balanced traffic load. In this paper, we focus on a similar but more generalized system model than in [6], which allows the nodes to transmit, receive or be silent depending on the availability of data in the buffer to transfer.
Recent breakthroughs in machine learning on non-Euclidian graph data have also attracted the interest of the wireless network community. The inherent graph structure of wireless networks makes GNNs more suitable than fully-connected neural networks (FCNNs) or convolutional neural networks (CNNs) to tackle wireless network problems. Recent efforts using GNNs, such as power control [7], channel estimation [8], cellular network traffic prediction [9], and network localization [10], have demonstrated promising results, outperforming classical methods while also offering significant computational complexity improvements.
Motivated by the recent successes of GNNs in wireless networks, for the first time we investigate the potential of using GNNs to jointly optimize the power and communication direction of a flexible duplex network.
The main contributions of this paper are as follows:
1. We formulate a novel graph structure that can represent the flexible duplex network. This graph can represent desired links and potential interference links including the direction to efficiently learn the geometric and numerical features of the flexible duplex network.
2. We propose a novel GNN model called **Flex-Net** with an unsupervised-learning strategy to jointly optimize communication direction and transmit power to maximize the sum-rate of the flexible duplex network.
3. We compare numerical results obtained by extensive simulations using the proposed GNN with baselines listed in Table I. We show that the proposed method outperforms baselines in terms of performance and time complexity. Furthermore, we analyze the sample complexity, scalability, and generalization capability of the proposed approach.
## II System Model
We consider a flexible duplex network consisting of \(2N\) transceiver nodes with interference channels as shown in Fig. 1. In the figure, solid lines and dashed lines indicate desired links and interference links, respectively. Solid circles and hollow circles indicate transmitters (Txs) and receivers (Rxs), respectively. For convenience, nodes are indexed from \(1\) to \(2N\). Without loss of generality, we define that the nodes with adjacent indices (\(1\leftrightarrow 2,...,2n-1\leftrightarrow 2n,...,(2N-1)\leftrightarrow 2N\)) act as user pairs.
Only one node of each user pair is in Tx mode whereas the other node is in Rx mode. Overall, there are \(N\) user pairs in the network. In a Tx-Rx pair, the Rx experiences interference from \((N\!-\!1)\) Tx nodes of other connected pairs.
Most of the existing works consider fixed sets of Tx and Rx [7, 11, 12]. For convenience, we can consider nodes with odd indices as Rxs and nodes with even indices as Txs. In a network with a fixed set of Tx and Rx pairs, i.e., not a flexible duplex network, the signal to interference-plus-noise ratio (SINR) of a receiver node can be written as
\[\gamma_{n}\!=\!\frac{p_{n+1}|h_{n,n+1}|^{2}}{\sigma_{n}^{2}\!+\!\sum_{k\neq n+1 }^{N}\!p_{2k}|h_{n,2k}|^{2}},\forall n\!=\!1,\!3,...,\!2N\!-\!1, \tag{1}\]
where \(p_{n}\) denotes the transmit power of the \(n\)th node, \(h_{n,k}\) denotes the complex channel state information (CSI) from the \(k\)th Tx to the \(n\)th Rx and \(\sigma_{n}^{2}\) denotes the noise power at the \(n\)th Rx.
In this work, we consider a flexible duplex network where we do not have a fixed set of Tx or Rx in a given user pair. Hence, we need to define the SINR for all the nodes in the network. SINR of the \(n\)th node of a flexible duplex network is given by
\[\gamma_{n}\!=\!\frac{p_{m}d_{m}|h_{n,m}|^{2}}{\sigma_{n}^{2}\!+\!\sum_{k\neq m,n}^{2N}\!p_{k}d_{k}|h_{n,k}|^{2}},\forall n\!=\!1,\!2,...,\!2N, \tag{2}\]
where \(m\!=\!2(n\bmod 2)\!+\!n\!-\!1\), \(d_{m}\!=\!1\!-\!d_{n}\), and \(d_{n}\!\in\!\{0,\!1\}\). The Rx state and Tx state of the \(n\)th node are represented by \(d_{n}\!=\!0\) and \(d_{n}\!=\!1\), respectively. If a node has no data to transmit, its CSI can be set to zero to ensure that no resources are allocated to it. Furthermore, we consider a more realistic non-reciprocal channel environment, i.e., \(h_{m,n}\) may not be equal to \(h_{n,m}\).
## III Optimization Problem
In this section, we formulate the optimization objective of the network, which aims to jointly optimize the power allocation and the communication direction of the flexible duplex network. To this end, the sum-rate utility maximization problem can be written as
**Problem 1**.: \[\max_{p_{n},d_{n},\forall n} \sum_{n=1}^{2N}\!\log_{2}\!\left(\!1\!+\!\frac{p_{m}d_{m}|h_{n,m}| ^{2}}{\sigma_{n}^{2}\!+\!\sum_{k\neq m,n}^{2N}\!p_{k}d_{k}|h_{n,k}|^{2}}\! \right)\!,\] \[s.t. 0\!\leq\!p_{n}\!\leq\!P_{\max},\quad\forall n,\] \[m\!=\!2(n\bmod 2)\!+\!n\!-\!1,\quad\forall n,\] \[d_{m}\!=\!1\!-\!d_{n},\quad\forall n,\] \[d_{n}\!\in\!\{0,\!1\},\quad\forall n,\]
where \(P_{\max}\) denotes the maximum transmit power of each node.
**Theorem 1**.: _Problem 1 is NP-hard for any number of user pairs._
Proof.: For a network with a fixed set of Tx and Rx pairs, i.e., that is not a flexible duplex network, following the convention that nodes with odd indices are Rxs and nodes with even indices are Txs, the sum-rate maximization problem can be written as [11]
**Problem 2**.: \[\max_{p_{n},\forall n} \sum_{n=1}^{N}\!\log_{2}\!\left(\!1\!+\!\frac{p_{2n}|h_{2n-1,2n}| ^{2}}{\sigma_{2n-1}^{2}\!+\!\sum_{k\neq n}^{N}\!p_{2k}|h_{2n-1,2k}|^{2}}\! \right)\!,\] \[s.t. 0\!\leq\!p_{n}\!\leq\!P_{\max},\quad\forall n\]
which is known as NP-hard [13]. There are only \(N\) Txs hence the upper bound of the summation. If there exists a polynomial-time reduction from Problem 1 to Problem 2, we can conclude that Problem 1 is NP-hard.
In a given flexible duplex network, assume that nodes with even and odd indices act as Tx (\(d_{n}\!=\!1\)) and Rx (\(d_{n}\!=\!0\)), respectively. Then only the nodes with odd indices will contribute to the sum-rate. Hence, Problem 1 can be reduced to Problem 2 by substituting communication directions. There exists a linear-time transformation from Problem 1 to Problem 2. This completes the proof.
As mentioned in the Theorem 1, Problem 1 is an NP-hard, non-convex combinatorial optimization problem with binary constraints. We provide two potential ways to obtain near-optimal solutions in the next section.
## IV Joint power and communication direction optimization
In this section, we focus on two methods to solve the optimization Problem 1. There are two variables to optimize, namely i) the power allocation vector denoted by \(\boldsymbol{p}\!=\![p_{1},\!...,\!p_{2N}]^{\mathsf{T}}\), and ii) the communication direction vector denoted by \(\boldsymbol{d}\!=\![d_{1},\!...,\!d_{2N}]^{\mathsf{T}}\). First, we develop a heuristic approach based on an iterative coordinate descent method. Then, we propose a novel GNN approach, called **Flex-Net**, to jointly optimize power allocation and communication directions.
### _Heuristic Approach_
In this approach, we use an iterative coordinate descent method to optimize one variable at a time. Since this is a combinatorial problem with integer variables, we adapt the direct search mechanism suggested in [2] to optimize the discrete integer variable \(\boldsymbol{d}\) while keeping \(\boldsymbol{p}\) fixed.
First, the communication direction vector \(\boldsymbol{d}\) is optimized using the direct search algorithm with initial power values.
Fig. 1: A flexible half-duplex network with \(2N\) transceiver nodes.
Then the power vector \(\mathbf{p}\) is recalculated using the weighted minimum mean square error (WMMSE) [14] algorithm. The above steps are repeated until the achieved sum-rate is not improved by a user-defined constant \(\varepsilon\) over subsequent iterations. Despite the near-optimal sum-rate performance, the computational complexity of this method is \(\mathcal{O}(n^{4})\)1. This makes the algorithm difficult to be applied for real-time resource allocation in large-scale networks. To overcome the computational complexity issue of this algorithm, we propose a novel GNN-based approach in the next subsection.
Footnote 1: The number of initializations increases linearly and the worst-case time complexity of each run is \(\mathcal{O}(n^{3})\). This includes the linear complexity of sum-rate calculation. Altogether, the time complexity is \(\mathcal{O}(n^{4})\).
### **Flex-Net** Approach
In this subsection, we propose a novel GNN named **Flex-Net** to jointly optimize \(\mathbf{p}\) and \(\mathbf{d}\). First, we represent the flexible duplex network as a graph with two types of edges. CSI of desired links and crosslinks are used as vertex features and edge features, respectively. The created graph is used as the input to the proposed GNN model. A short introduction about GNNs and details of the graph formulation, proposed architecture, theoretical motivation, and optimization methods are detailed below.
#### Iii-B1 Graph Neural Networks
There are two main types of GNNs: Spectral GNNs and Spatial GNNs [15, 16]. Spectral GNNs are designed based on a signal processing perspective and operate in the spectral domain, while spatial GNNs focus on the structure of the graph and can aggregate information from neighboring nodes like the convolution kernels present in Convolutional Neural Networks (CNNs). Being restricted to certain operations in the frequency domain, Spectral GNNs have limited expressive power. Therefore, we use a spatial GNN to optimize the objective function in Problem 1.
Given a graph structure with node features and edge features, GNNs use neighborhood aggregation functions and combination functions to learn representations of nodes of the graph. This process is followed for multiple iterations to learn sufficient structural information about the neighborhood of nodes. Mathematically, aggregation and combination steps of the \(\ell\)th layer are
\[\mathbf{a}_{v}^{(\ell)} =\operatorname{AGGREGATE}^{(\ell)}\Big{(}\Big{\{}\mathbf{x}_{u}^{( \ell-1)},\mathbf{x}_{v}^{(\ell-1)},\mathbf{e}_{uv}\!:\!u\!\in\!\mathcal{N}(v)\Big{\}} \Big{)}\] \[\mathbf{x}_{v}^{(\ell)} =\operatorname{COMBINE}^{(\ell)}\Big{(}\mathbf{x}_{v}^{(\ell-1)},\mathbf{ a}_{v}^{(\ell)}\Big{)},\]
where \(\mathbf{x}_{v}^{(\ell)}\) is the embedding of node \(v\) at the \(\ell\)th layer, \(\mathbf{e}_{uv}\) is the edge feature between node \(u\) and \(v\), and \(\mathcal{N}(v)\) represents the neighbours of node \(v\).
#### Iii-B2 Graph Representation of the Flexible Duplex Network
In our system model, there are \(2N\) transceiver nodes. The signal from each Tx acts as interference to the unintended Rxs. Observing this physical network structure, we formulate the network graph as follows.
Each node in the network is represented by a vertex in the graph. Hence, there are \(2N\) vertices in the graph. The \(n\)th vertex contains \(g_{n,m}\!=\!|h_{n,m}|^{2}\) as the vertex feature. This is motivated by the fact that the sum-rate expression contains the squared magnitude of CSI in the numerator. Vertices of the graph are connected using two types of edges. i) Undirected edges represent desired links of the network, denoted by \(\mathbf{e}_{d}\), and ii) directed edges represent all the _potential_ interference, denoted by \(\mathbf{e}_{i}\). The squared magnitude of CSI from node \(v\) to \(u\) is used as the edge feature of \(\mathbf{e}_{i}\). This is motivated by the fact that the interference is a function of squared channel magnitudes. These \(\mathbf{e}_{i}\) edges become an interference only if the origin node of an edge is a Tx, hence the name potential interference. Fig. 2 illustrates the network graph of a flexible duplex network with \(2N\) transceivers.
### _Motivation for the Proposed Architecture_
There has been growing interest in the literature to explore the architecture of a GNN to maximize its representation capability. Strictly speaking, GNN should construct unique node embeddings which represent the neighborhood and node features. As pointed out in [17] when the node and edge features are from a countable multiset, the aggregation and combination functions should be injective for the GNN to maximize its representation capability.
From a wireless communication standpoint, there might be multiple nodes that share the same optimized power and direction values despite the differences in associated CSI. This suggests that multiple nodes with different neighborhoods may share the same embedding, i.e., GNN layer \(\mathcal{F}\!:\!\mathbf{x}^{(\ell-1)}\!\rightarrow\!\mathbf{x}^{(\ell)}\) may take a non-injective form. In the next subsection, we propose a more flexible GNN architecture, which can approximate any injective or non-injective function. In particular, we relax the constraint of using injective functions. Empirical results suggest that the proposed architecture generalizes well for the objective proposed in Problem 1.
Fig. 2: Graph representation of a flexible duplex network. Solid lines indicate \(\mathbf{e}_{d}\) and dashed lines indicate \(\mathbf{e}_{i}\), where \(g_{i,j}=|h_{i,j}|^{2}\) and \(m\!=\!2(n\bmod 2)\!+\!n\!-\!1\).
### **Flex-Net Architecture**
In general, GNNs can perform three types of tasks i) node-level, ii) edge-level, and iii) graph-level. In node-level tasks, predictions are based on individual nodes. As the name suggests edge-level tasks are performed to find the presence, direction, or any other properties of the edges. Graph-level tasks are performed on the entire graph to obtain insights into the whole graph.
In this work, we perform two types of tasks on the network graph. An edge-level task is used to find the directions of the desired links between nodes. In addition to that, a node-level task is used to predict the optimal power value for each node. Our GNN is comprised of two information aggregation steps to exploit connections represented by \(\mathbf{e}_{d}\) and \(\mathbf{e}_{i}\). We perform the following operations on two types of edges:
\[\mathbf{\alpha}^{(\ell)}_{v;\text{inft}} = \gamma\Big{[}\phi\Big{(}\mathbf{W}^{(\ell)}_{v;\text{inft}}\mathbf{x}^{( \ell-1)}_{v}\!+\!\mathbf{W}^{(\ell)}_{v;\text{inft}}\mathbf{x}^{(\ell-1)}_{v}\] \[\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad+\mathbf{W }^{(\ell)}_{e;\text{inft}}\mathbf{e}_{u,v}\!:\!u\!\in\!\mathcal{N}_{\text{inft}}( v)\Big{)}\Big{]},\] \[\mathbf{c}^{(\ell)}_{v} = \Big{(}\mathbf{x}^{(1)}_{v}\,\|\,\mathbf{\alpha}^{(\ell)}_{v;\text{inft} }\Big{)},\] \[\mathbf{\alpha}^{(\ell)}_{v;\text{sfx}} = \gamma\Big{[}\phi\Big{(}\mathbf{W}^{(\ell)}_{v;\text{deft}}\mathbf{c}^{( \ell)}_{u}\!+\!\mathbf{W}^{(\ell)}_{v;\text{sfx}}\mathbf{c}^{(\ell)}_{v}\!:\!u\!\in\! \mathcal{N}_{\text{d}sr}(v)\Big{)}\Big{]},\] \[\mathbf{x}^{(\ell)}_{v} = \Big{(}\mathbf{x}^{(1)}_{v}\,\|\,\mathbf{\alpha}^{(\ell)}_{v;\text{sfx}} \Big{)}, \tag{3}\]
where \(\gamma\) represents a permutation invariant pooling function such as maximum or summation, \(\phi\) represents a non-linear activation function, \(\mathbf{x}^{(\ell)}_{v}\) represents the node features of the node \(v\) in the \(\ell\)th layer, \(\mathbf{W}^{(\cdot)}_{(\cdot;)}\) matrices represent trainable weight matrices, \(\mathcal{N}_{\text{inft}}(v)\) is the set of adjacent nodes connected with \(\mathbf{e}_{i}\) edges towards node \(v\), \(\mathcal{N}_{\text{d}sr}(v)\) is the set of adjacent nodes connected to node \(v\) with \(\mathbf{e}_{d}\) edges, \(\mathbf{e}_{u,v}\) denotes edge feature of \(\mathbf{e}_{i}\) from node \(u\) to \(v\) and \(\mathbf{x}^{(1)}_{v}\) denotes the node embedding of the first layer which is the squared channel magnitude of the desired link. Skip connection from the first layer to layer \(\ell\) is called a residual connection. Such residual connections reduce the risk of vanishing or exploding gradients during backpropagation. Empirically, residual connections result in a significant increase in the performance of deep neural networks [18]. The symbol \(\|\) denotes the vector concatenation. Moreover, unlike the GNNs described in previous research, the **Flex-Net** is able to accurately generate node embeddings for a flexible duplex network due to its use of two aggregation steps.
After performing the above aggregation and combination steps for multiple layers, embeddings of the final layer are used to predict the power values of nodes as follows:
\[p_{n}\!=\!P_{\max}\mathrm{SIGMOID}\bigg{(}\frac{1}{T_{p}}\mathrm{MLP}\Big{(} \mathbf{x}^{(\text{final})}_{n}\Big{)}\bigg{)}, \tag{4}\]
where \(T_{p}\) is a scaling parameter called the _temperature_, \(\mathrm{MLP}\) represents a trainable multi-layer perceptron, and \(\mathbf{x}^{(\text{final})}_{n}\) represents the final layer embedding of \(n\)th node. Usage of a low-temperature value provides more extreme power values biased towards \(0\) or \(P_{\max}\) which are similar to the power values obtained using the WMMSE algorithm.
Directions of the desired links are found by considering the embeddings of adjacent nodes connected by \(\mathbf{e}_{d}\). As described in the system model, the direction is represented with a binary variable. Due to the lack of differentiability, it is difficult to optimize the network with the binary constraint. Therefore, we relax the binary constraint and consider it to be a real number between \(0\) and \(1\). Then we decide the direction of the edge by considering the embeddings of nodes in both ends as follows:
\[d_{u,v}\!=\!\mathrm{SIGMOID}\bigg{(}\frac{1}{T_{d}}\mathrm{MLP}\Big{(}\mathbf{x} ^{(\text{final})}_{u}\,\|\,\mathbf{x}^{(\text{final})}_{v}\Big{)}\bigg{)}, \tag{5}\]
where \(T_{d}\) is the temperature parameter, \(\mathbf{x}^{(\text{final})}_{u}\) and \(\mathbf{x}^{(\text{final})}_{v}\) denotes node embeddings of the adjacent nodes connected by \(\mathbf{e}_{d}\). Similar to the case of power allocation, usage of a low-temperature value works as a regularizer to restrain the relaxed binary variable to a tight neighborhood of \(0\) or \(1\).
We optimize the trainable parameters of the network using _ADAM_ which is an adaptive variant of the stochastic gradient descent algorithm. We use the negative value of Problem 1 with relaxed binary constraint as the loss function. This unsupervised learning mechanism eliminates the need of labels for training. Data (channel realizations) required for the training process is generated by following the method explained in Section V.
## V Numerical Results
In this section, we compare the proposed approach with different existing algorithms in terms of performance, time complexity, and generalization capability.
### _Simulation Setup_
We consider a flexible duplex network spanned over \(4\!\times\!4\,\text{km}^{2}\) area. For convenience, we assume the devices are arranged in a 2D space, but the devices can be distributed in any dimensional space in our GNN model. We assume the devices are Poisson disk distributed which is similar to a uniformly distributed case but with a minimal distance of \(100\)m. Devices are paired randomly to form desired links.
To generate CSI, we consider the large and small-scale fading effects of the network [19]. Free-space path loss is calculated for \(5\,\text{GHz}\) frequency with log-normal shadowing of \(9.5\) dB. Furthermore, we assume a Rayleigh fading channel which is a suitable model to simulate fading in an urban environment and is commonly used for performance evaluation of resource allocation methods.
\begin{table}
\begin{tabular}{l c c} \hline \hline Approach & Time Complexity & Performance (avg.) \\ \hline Exhaustive Search & \(\mathcal{O}(2^{n})\) & 100\% \\
**Flex-Net** & \(\mathbf{\mathcal{O}(n^{2})}\) & **95.8\%** \\ Heuristic Search & \(\mathcal{O}(n^{4})\) & 95.5\% \\ Max Power & \(\mathcal{O}(n)\) & 49.9\% \\ Max Power with Silent Nodes & \(\mathcal{O}(n^{2})\) & 67.5\% \\ \hline \hline \end{tabular}
\end{table} TABLE I: Algorithms used in the experiments
Simulations are carried out for 4-user to 32-user scenarios. We compare the proposed approach with the baselines given in table I. For the _Exhaustive Search_, the WMMSE algorithm is applied to all the direction combinations. The _Max power_ strategy selects the direction with the strongest CSI magnitude as the communication direction and uses \(P_{\max}\) as the transmit power. In addition to that, _Max power with Silent Nodes_ strategy turns off the transmitter if there is at least one crosslinking with twice the received power of the desired link. All the algorithms are implemented in Python language 2. For large matrix manipulations, Numpy is used.
Footnote 2: The code is available at [https://github.com/tharaka-perera/flex-net](https://github.com/tharaka-perera/flex-net)
All the implemented classical algorithms are accelerated to achieve native machine code performance using a just-in-time compiler. Neural networks are implemented from the scratch using Pytorch and Pytorch Geometric frameworks. To do a fair comparison, all the processing is done on a single-core CPU during performance and time comparisons. GPU is used only during training to reduce training time.
### _Hyperparameter Tuning of the GNN_
Neural networks comprise different hyperparameters. In our experiments, we analyze the effect of a few key hyperparameters.
In the literature [20], it is considered that GNNs demand a smaller number of training samples compared to conventional FCNNs. To check the validity of that hypothesis and to find a suitable training sample count for our experiments, we test the performance against the number of training samples for the 32-user case. Each model is trained for 50 iterations and the performance is evaluated. Results are shown in Fig. 2(a). The proposed model achieves more than 99% of performance with \(10^{4}\) samples. This is significantly low compared to the sample complexity of power control approaches proposed with FCNNs or CNNs [12, 21].
Furthermore, we evaluate the effect of the number of layers in the GNN for performance. Results are presented in Fig. 2(a). Even though the performance is improved with the number of layers, **Flex-Net** can outperform the classical approach with only 3 GNN layers. We use 3 layers in the rest of the simulations.
Finally, we select the mini-batch size and learning rate
Fig. 4: (a) Average sum-rate comparison of different algorithms. (b) Running time per sample for different algorithms. (c) Sum-rate comparison of a set of models (multiple models) which are trained with a fixed number of nodes and a model (single model) trained with a variable number of nodes.
Fig. 3: Hyperparameter tuning of the **Flex-Net**. (a) Average sum-rate performance against the sample count and the number of layers. (b) Average sum-rate performance against mini-batch size and learning rate. (c) Average sum-rate comparison of max-pooling and sum-pooling.
using a parametric grid-search. Results are illustrated in Fig. 2(b). Small mini-batch sizes combined with small learning rates result in better performance. In contrast, higher learning rates results in overshooting, hence the instability and poor performance. We choose the mini-batch size of 64 (improved training time) with 0.002 learning rate for the rest of the simulations.
### _Pooling Function_
In the proposed GNN architecture, node embeddings are updated recursively layer by layer. As the pooling function of the aggregation function, the usage of an injective multiset function, _sum-pooling_ is preferred over _max-pooling_[17]; nevertheless, succeeding work such as [22] questions this argument. In our experiments, we find that the performance of both pooling functions is almost identical. We use _sum-pooling_ in rest of the experiments.
### _Performance_
The average sum-rate performance of the proposed architecture is compared against all the baseline approaches. The simulation results are summarized in Fig. 3(a). Simulation results indicate that the proposed GNN approach outperforms all the classical methods in the network configurations tested. Moreover, it can achieve tightly close results to that of the exhaustive search.
### _Time Complexity_
In the midst of growing demand for higher data rates with lower latency, it is crucial for the wireless network to control thousands of users with minimal processing overhead. GNN shines in this regime with its capabilities to match the performance of classical algorithms while keeping the time complexity significantly low. We compare the average running time of GNN with other baselines for \(10^{4}\) test samples. Simulation results are given in Fig. 3(b). We can see that GNN outperforms both the exhaustive search and the heuristic search significantly. This makes the GNN approach suitable to be used in real-time networks with low latency.
### _Generalization_
GNN operations neither depend on the number of nodes nor the number of edges in the network. Hence GNNs can handle variable input sizes without retraining, unlike traditional FCNNs. This makes it incredibly practical to be used in wireless networks with a variable number of users.
To study the generalization capability of GNN, instead of training multiple models for different numbers of nodes, we train a single model and test performance for networks with 4 to 32 users. Samples with different numbers of nodes are used for the training. Empirical data presented in Fig. 3(c) suggests the performance of **Flex-Net** is not affected by the changes in the number of users.
## VI Conclusion
In this work, a joint power allocation and communication direction selection problem is investigated for flexible duplex networks. We considered a system model that can dynamically schedule the communication direction of a TDD network. With the goal of maximizing the sum-rate performance of the network, an optimization problem is formulated. We prove that the optimization problem in focus is an NP-hard problem. To circumvent this challenging problem, a novel GNN-based approach is presented. First, a flexible duplex network is represented as a graph to be used as the input to the proposed GNN model. Then, the GNN model is optimized using the generated graph data in an unsupervised manner. To obtain the maximum network utility possible, a grid-search method is used to find suitable hyperparameters for the GNN. Finally, extensive numerical analysis is carried out to compare the performance of the proposed approach and four other baselines. Numerical results suggest that the proposed **Flex-Net** method can generate near-optimal results with reduced time complexity compared to existing methods. Further analysis verified the advantages of the proposed method in terms of sample complexity, scalability, and generalization capability.
|
2302.13553 | Predicting EEG Responses to Attended Speech via Deep Neural Networks for
Speech | Attending to the speech stream of interest in multi-talker environments can
be a challenging task, particularly for listeners with hearing impairment.
Research suggests that neural responses assessed with electroencephalography
(EEG) are modulated by listener`s auditory attention, revealing selective
neural tracking (NT) of the attended speech. NT methods mostly rely on
hand-engineered acoustic and linguistic speech features to predict the neural
response. Only recently, deep neural network (DNN) models without specific
linguistic information have been used to extract speech features for NT,
demonstrating that speech features in hierarchical DNN layers can predict
neural responses throughout the auditory pathway. In this study, we go one step
further to investigate the suitability of similar DNN models for speech to
predict neural responses to competing speech observed in EEG. We recorded EEG
data using a 64-channel acquisition system from 17 listeners with normal
hearing instructed to attend to one of two competing talkers. Our data revealed
that EEG responses are significantly better predicted by DNN-extracted speech
features than by hand-engineered acoustic features. Furthermore, analysis of
hierarchical DNN layers showed that early layers yielded the highest
predictions. Moreover, we found a significant increase in auditory attention
classification accuracies with the use of DNN-extracted speech features over
the use of hand-engineered acoustic features. These findings open a new avenue
for development of new NT measures to evaluate and further advance hearing
technology. | Emina Alickovic, Tobias Dorszewski, Thomas U. Christiansen, Kasper Eskelund, Leonardo Gizzi, Martin A. Skoglund, Dorothea Wendt | 2023-02-27T07:12:16Z | http://arxiv.org/abs/2302.13553v1 | # Predicting EEG Responses to Attended Speech via Deep Neural Networks for Speech
###### Abstract
Attending to the speech stream of interest in multi-talker environments can be a challenging task, particularly for listeners with hearing impairment. Research suggests that neural responses assessed with electroencephalography (EEG) are modulated by listener's auditory attention, revealing selective neural tracking (NT) of the attended speech. NT methods mostly rely on hand-engineered acoustic and linguistic speech features to predict the neural response. Only recently, deep neural network (DNN) models without specific linguistic information have been used to extract speech features for NT, demonstrating that speech features in hierarchical DNN layers can predict neural responses throughout the auditory pathway. In this study, we go one step further to investigate the suitability of similar DNN models for speech to predict neural responses to competing speech observed in EEG. We recorded EEG data using a 64-channel acquisition system from 17 listeners with normal hearing instructed to attend to one of two competing talkers. Our data revealed that EEG responses are significantly better predicted by DNN-extracted speech features than by hand-engineered acoustic features. Furthermore, analysis of hierarchical DNN layers showed that early layers yielded the highest predictions. Moreover, we found a significant increase in auditory attention classification accuracies with the use of DNN-extracted speech features over the use of hand-engineered acoustic features. These findings open a new avenue for development of new NT measures to evaluate and further advance hearing technology.
## I Introduction
The challenge of attending the target speech signal while ignoring other sounds is an extensively-studied problem known as the "cocktail party" problem [2]. To date, research on "cocktail party" environments has progressed significantly to a point where it is now possible to decode (i.e., classify) the attended speech by quantifying "neural tracking" (NT) of speech [3, 4], i.e., by comparing the neural activity of the listener, recorded with electroencephalogram (EEG), to the activity of multiple candidate speech sources in a listening environment [5, 6]. NT methods have allowed to assess the real benefits of the hearing aids [6, 7].
NT methods involve encoding of the speech by estimating the temporal response function (TRF) that linearly maps time-lagged speech signals to EEG. NT methods proposed in the literature mostly rely on hand-engineered acoustic and linguistic speech feature that include for example speech envelope, spectrogram, pitch, phonetic and lexical features [8, 9, 10, 11, 12]. Despite the successful usage of acoustic-linguistic features in NT, it remains unclear to what extent language models [13, 14] may be used to extract relevant features.
Modern artificial intelligence models using deep neural networks (DNN) revolutionized the field of speech representation showing that DNN models, without specific language knowledge, can derive speech features that correlates well with neural responses recorded with functional magnetic resonance imaging (fMRI), magnetoencephalography (MEG) and electrocorticography (ECoG) [15, 16, 17]. Furthermore, recent work has suggested that DNN models can successfully predict speech comprehension from the neural responses recorded with fMRI [18]. Lastly, Li et. al. [17] demonstrated that speech features in hierarchical DNN layers can better predict neural responses than hand-engineered acoustic-phone features, as observed in high signal-to-noise (SNR) ECoG signals, throughout the auditory pathway [17]. However, whether DNN-derived speech features can better predict noninvasive, low SNR EEG responses and, classify attention in multi-talker listening environments remains unknown.
To address this issue, we compare a wide variety of hand-engineered acoustic and DNN-derived speech features in light of human neural responses to competing speech. Specifically, we analyze the EEG responses of 17 healthy younger adults. During 45 min-long sessions the listeners were instructed to attend to one of two competing talkers. We trained a variety of NT models and compare their ability to linearly map speech onto the EEG recordings. Furthermore, we investigate the hierarchy of layers in the DNN models. Finally, we trained a variety of NT models and compare their ability classify the attended speech.
## II Methods
The experimental protocol was reviewed and approved by the ethics committee for the capital region of Denmark (journal number H-21065001). The study was conducted according to the Declaration of Helsinki, and all the participants gave a written consent prior to the experiment.
### _Study Design_
#### Ii-A1 Participants
Participants comprised 17 younger adults (9 males, mean age 29.0, SD 6.4). All participants were
native Danish speakers, had normal or corrected-to-normal vision, had no history of neurological disorders, dyslexia, or diabetes mellitus, and had clinically normal hearing.
#### Ii-A2 Stimuli and Recording
During the experimental session presented in this study, participants were asked to attend to one of two different audiobooks narrated in Danish. The stimuli comprised 33 \(\sim\)\(1\,\mathrm{min}\)-long segments from audiobook recordings of _Himalaya i sigte_ (a story of traveling in the Himalayas) read by a female talker and _Simon_ (a biography on Simon Spies) read by a male talker, and sampled at \(44.1\,\mathrm{kHz}\). Prolonged silent periods in the speech stimuli longer than \(500\,\mathrm{ms}\) were shortened to \(500\,\mathrm{ms}\). Stimuli were routed through a sound card (RME Hammerfall DSP multiface II, Audio AG, Germany) and were played via loudspeakers (Genelec 8040A; Genelec Oy, Finland) at an average intensity of 70 dB SPL each positioned \(\pm 30^{\circ}\) to the left or right of the center. EEG data were acquired at a sampling rate of \(8192\,\mathrm{Hz}\) with a BioSemi ActiveTwo 64-channel EEG recording system in 10-20 layout.
#### Ii-A3 Experimental Session Design
A total of 33 trials were conducted, with the first trial used for training and 32 trials used for analysis. Each trial consisted of \(5\,\mathrm{s}\) of silence, \(1\,\mathrm{min}\) of speech mixture and two 2-choice questions on attended story to keep the participants alert. The 32 trials were divided into 8 blocks of 4 randomized consecutive trials, with 2 blocks for each of "male right", "male left", "female right" and "female left". Before each block, a visual cue on the screen and \(5\,\mathrm{second}\) of the to-be-attended speech were presented indicating talker (male or female) and the side (left or right) to be attended.
### _Neural Data Analysis_
#### Ii-B1 EEG Preprocessing
The EEG data were re-referenced to the average of the mastoid electrodes, band-pass filtered between 0.1 and \(10\,\mathrm{Hz}\) and re-sampled to \(100\,\mathrm{Hz}\). Subsequently, signal components of non-neural origin were removed using a procedure based on independent component analysis [19]. Next, the data were filtered between 1 and \(10\,\mathrm{Hz}\) and normalized to zero mean and unit variance. In a final step, data were segmented into trials of \(59\,\mathrm{s}\) duration from 0 to \(59\,\mathrm{s}\) relative to the onset of the speech.
#### Ii-B2 Neural Tracking of Speech
Quantifying Brain Prediction ScoresThe TRF framework allows to study how the brain processes competing speech. It includes two stages: a training stage to derive TRFs for the each talker and a testing stage to quantify how well EEG responses can be predicted. In the training stage, time-lagged speech features of each talker \(S\) are linearly mapped to the EEG response(s) \(R\) of the listener based on TRF \(W\) derived via regularized linear regression (rLR) with a parameter \(\lambda\) to control for overfitting [3]:
\[W=\left[\mathcal{H}(S)^{T}\mathcal{H}(S)+\lambda I\right]^{-1}\mathcal{H}(S)R \tag{1}\]
where \(\mathcal{H}(*)\) is a Hankel matrix (see [3] for more details). In the testing stage, EEG responses are predicted as:
\[\hat{R}=\mathcal{H}(S)W \tag{2}\]
The quality of the prediction is quantified in terms of a brain prediction score (BPS) measuring the correlation (a Pearson's \(r\)) between the true and reconstructed EEG responses.
Classifying Auditory AttentionThe NT framework allows to classify auditory attention (i.e., identify the attended speech) in multi-talker environments. In order to classify which of the streams a listener attended to, two TRF models \(W_{att}\) and \(W_{ign}\) from (1) are assembled to become two competing prediction models for every single EEG channel. Next, the EEG signals (\(\widehat{R}_{att}\) and \(\widehat{R}_{ign}\)) are independently predicted from the attended (\(S_{att}\)) and the ignored (\(S_{ign}\)) speech signals. To estimate which of the predicted EEG signals (\(\widehat{R}_{att}\) versus \(\widehat{R}_{ign}\) ) are most likely representing the attended speech, we compute channel-by-channel brain prediction scores \(BPS_{att}\) and \(BPS_{ign}\). Finally, we compare \(BPS_{att}\) and \(BPS_{ign}\) values averaged across all EEG channels and the signal with the highest BPS is classified as the attended speech.
### _Speech Feature Extraction_
#### Ii-C1 Hand-Engineered Speech Features
Hand-engineered acoustic features considered for this study included _speech envelope_ (the root-mean-square of \(10\,\mathrm{ms}\) windows and scaled by raising the value to the power of a compression parameter of 0.3 or 1 indicating no compression), the _envelope derivative_, _spectrogram_ (100 linearly spaced components between \(0\,\mathrm{Hz}\) and \(8\,\mathrm{kHz}\) computed with a short-time Fourier transform at \(100\,\mathrm{Hz}\), and scaled by a compression parameter of 0.3), Mel Frequency Cepstral Coefficients (_MFCC_) (13 components representing different frequencies between \(20\,\mathrm{Hz}\) and \(8\,\mathrm{kHz}\), as well as their derivatives and the second derivative for a total of 39 features) and _pitch_ (absolute and relative pitch, and pitch change computed as in [17]). The MFCC feature set was also used as an initialization of the labels for DNN training. Similar to [17], we included a baseline model comprising full acoustic features.
#### Ii-C2 DNN-extracted Speech Features
We employ the Hidden unit BERT (HuBERT) DNN model - a transformer-based self-supervised model for speech feature learning [14]. A major component of HuBERT model training is applying the predictive loss over the masked portions of speech driving the model to learn a fused acoustic and language feature set over the speech input. Using ECoG recordings, it has recently been shown that the HuBERT DNN model yielded the best BPS among the benchmarks DNN models [17].
Our goal is to extract relevant speech features in different DNN layers in order to use them as inputs to the NT models. With the speech material presented in our study being in Danish, different methods are employed to obtain a Danish version of HuBERT DNN model. For a complete description please refer to [1].
Since both the audio used in the experiments and the LibriSpeech corpus [20] of the English HuBERT model stem from audiobooks, we collected a similar Danish speech corpus for training purposes. Only continuous, clearly spoken, Danish speech without background noise was included. The main source was speech materials used in previous studies
conducted at Eriksholm Research Centre. Additionally, the publicly available Danish audiobooks found on LibriVox [21] were included. For all speech files, the starts of the files with an introduction (e.g., the name of the reader or the book title) were removed. Mono channel audio signal was created by averaging the stereo channels, resampled to \(16\,\mathrm{kHz}\) and divided into equally long segments. To avoid a strong effect of individual speakers, the amount of speech data was limited to 300 files per speaker. In total 3900 such audio files (\(>65\,\mathrm{h}\)) were prepared and divided into training and validation sets in a common \(80/20\) split.
An important component of the HuBERT DNN models are the artificially created labels with which the DNN is trained. Based on MFCCs, all speech segments were clustered with k-means. These clusters were used as labels for the DNN training. We considered three major HuBERT DNN models, see Table I. First, the original 'base' HuBERT DNN model, referred to as the 'English DNN' in this study, was trained on \(960\,\mathrm{h}\) of continuous English speech from the LibriSpeech corpus [14]. Second, the Danish HuBERT DNN model, here referred to as the 'Danish DNN', used the \(\sim\)\(65\,\mathrm{h}\) data set of Danish speech for training with randomly initialized weights which mimics the original training of the base English DNN [14]. Third, a self-supervised fine-tuning (SSFT) was added as an additional training option. The English DNN is used to initialize the network weights. Here, only the latest layers of the pre-trained DNN are replaced with new layers to allow prediction of different clusters. The training objective during SSFT is the HuBERT objective of classifying segments of the unseen speech data. We refer to this model as SSFT A1.
## III Results & Discussion
### _Predicting EEG from DNN-Extracted Speech Features_
We first test whether DNN-extracted speech features linearly predict EEG responses. To this aim, we fit a rLR to predict the EEG activity elicited by the attended speech from the HuBERT model input with the same speech. We then compute a BPS, i.e. the correlation between the true EEG responses and the EEG responses predicted from the rLR. On average across EEG channels, the BPS for an English DNN HuBERT model are significantly distributed above zero with the mean BPS of 0.051 at layer 1 (L1), 0.054 at layer 5 (L5) and 0.05 at layer 12 (L12). Using speech features from the Danish DNN HuBERT model, a lower BPS of 0.035 at L1 to 0.015 at L12 were achieved.
Second, we evaluate whether DNN-extracted speech features can better predict EEG responses than hand-engineered acoustic features (see Fig. 1-2). Similar to the speech from HuBERT model, we first fit a rLR to predict the EEG activity from the acoustic features. On average, a BPS of 0.039, 0.042, 0.029, 0.037, 0.032 and 0.038 for acoustic envelope, all envelope features, pitch, MFCC, spectrogram, and all features, respectively, were observed. Next, we compute a normalized BPS, i.e., the squared BPS from the DNN HuBERT model divided by the squared BPS with all envelope features as input to the rLR. Lastly, we observe that both the English DNN and the SSFT DNN A1 HuBERT models provide normalized BPS scores that are significantly higher than 1 at their best layer (p \(<\) 0.05, 2-sided t-tests with BPS for 64 EEG channels). Our results are consistent with previous findings suggesting that DNN-derived speech features correlates well with the neural activity [15, 16, 17].
Third, analysis of hierarchical DNN layers shows that early layers (layer group 1: L1-L5) yielded higher BPS than later layers (layer group 2: L6-L12; \(p<0.05\) for one-way ANOVA factor 'layer group'). This is in line with recent studies providing evidence for the speech processing hierarchy within auditory cortex [22, 23].
### _Attention Classification with DNN-extracted Speech_
Classifying auditory attention is notoriously challenging [4]. This issue poses strong limitations on the future application of NT methods to hearing devices. While hand-engineered acoustic features can be used in NT methods
Fig. 1: The normalized mean brain prediction scores (BPS) for predicting the EEG activity elicited by the attended speech from the HuBERT model input with the same speech. A BPS higher than 1 signifies a higher quality of prediction from DNN-extracted speech features than from the hand-engineered acoustic features.
Fig. 2: The mean BPS for each subject predicting the EEG responses from the HuBERT DNN models averaged across all trials and channels.
to decode attention, we show that DNN-extracted speech features yield results that are consistently higher than those described in neuroscientific literature (see Fig. 3). We find a significant increase in classification accuracy with the use of DNN-extracted features over the use of acoustic features.
For the best acoustic feature set (envelope features), a mean attention (attended vs. ignored speech) classification accuracy of 75% (SD 43%) was achieved. With the best DNN feature set (from the L5 of the English DNN), the attention classification accuracy improved to 79% (SD 40%), yielding statistically significant differences (p = 0.0319, 2-sided t-test with 17 subjects).
## IV Conclusions
We propose a new framework to predict EEG responses to attended speech. Overall, the present study suggests DNN models for speech can retrieve information that correlate to speech processing hierarchy. Interestingly, our analyses highlights that EEG responses are significantly better predicted by DNN-extracted speech features than by hand-engineered acoustic features. Furthermore, analysis of hierarchical DNN layers shows that early layers yield the highest predictions. Finally, we find a significant increase in auditory attention classification accuracy with the use of DNN-extracted speech features over the use of hand-engineered acoustic features. In sum, NT methods could used to evaluate and further advance hearing technology and we propose a new approach to increase EEG prediction and attention classification accuracy.
|
2303.12202 | Removing Noise From Simulated Events at The Main Drift Chamber of BESIII
Using Convolutional Neural Networks | BESIII is the particle detector of the Beijing Electron-Positron Collider,
which is a {\tau} -charm factory working at energies around 4 GeV. The first
part of the detector, around the collision site, is called the Main Drift
Chamber, MDC. The events recorded at MDC are mixed with the background noise of
various origins. On average, about 10% of the hits of an event are noises.
Still, the noise level differs event by event, and some of the events might
even get more noise hits than signal hits, making the analysis less efficient.
The standard algorithms of the offline software system of BESIII reconstruct
signal tracks using the polluted data. This reduces the reconstruction
efficiency of high noise tracks. In this article, we test the idea of using
supervised deep learning techniques to remove this noise beforehand. We
generate Monte Carlo events, then mix them with noise hits coming from real
data. At first, we use deep learning techniques to classify the hits based on
their individual features. Then, we simplify every event to a 40 by 43 picture
and use image recognition tools to remove the noise. The average noise level
for these events with only two signal tracks is about 30%. On average, the
techniques presented in this article can purify Bhabha events to nearly 99%
while preserving about 99% of the signal tracks. | Hosein Karimi Khozani, Zhang Yao, Yuan Ye | 2023-03-21T21:23:52Z | http://arxiv.org/abs/2303.12202v1 | Removeing Noise From Simulated Events at The Main Drift Chamber of BESIII Using Convolutional Neural Networks
###### Abstract
BESIII is the particle detector of the Beijing Electron-Positron Collider, which is a \(\tau\)-charm factory working at energies around 4 GeV. The first part of the detector, around the collision site, is called the Main Drift Chamber, MDC. The events recorded at MDC are mixed with the background noise of various origins. On average, about 10% of the hits of an event are noises. Still, the noise level differs event by event, and some of the events might even get more noise hits than signal hits, making the analysis less efficient. The standard algorithms of the offline software system of BESIII reconstruct signal tracks using the polluted data. This reduces the reconstruction efficiency of high noise tracks. In this article, we test the idea of using supervised deep learning techniques to remove this noise beforehand. We generate Monte Carlo events, then mix them with noise hits coming from real data. At first, we use deep learning techniques to classify the hits based on their individual features. Then, we simplify every event to a 40 by 43 picture and use image recognition tools to remove the noise. The average noise level for these events with only two signal tracks is about 30%. On average, the techniques presented in this article can purify Bhabha events to nearly 99% while preserving about 99% of the signal tracks.
## 1 Introduction
MDC is a 2.6m long cylindrical drift chamber with an outer diameter of 1.6m. It has 6796 sense wires which are distributed in 43 layers. There are two levels of trigger filtration in BESIII before the data gets stored. The efficiency of this system is as high as 100% for Bhabha scattering, and 97.7% for any \(J/\Psi\) decay mode [1]. At the same time, the background rate reduces significantly, from \(10^{4}\) KHz to about 1 KHz out of 3 KHz, which is the rate of event storage on the offline system [1]. This is an efficient process, but still, one third of this data is uninteresting background. Furthermore, the number of hits of an event is typically between 100 to 200, which about 5 to 15 percent of them are noises. The standard packages used on the offline system should remove the rest of the noise. Basically, these packages find the tracks of interest by considering all the hits, and the noise is eventually left aside like background tracks. Therefore it is hard to analyze events with high levels of noise. Our motivation is to reduce noise beforehand with deep learning methods while keeping efficiency high.
We present the first phase of our project here, in which we worked with simulated Bhabha events. Working with these simple events is a suitable choice for starting this project. Moreover, BESIII events are, in general, very clean. Though the luminosity is high, still most of the events
have only two or four signal tracks. Another notable point is that Bhabha events are useful for purposes such as accurate luminosity measurements. Initially, we look at the situation as a hit classification problem and form neural networks that can distinguish noise hits solely based on their features. The features, in general, include time and charge, but we here only work with raw-time values. For the next step, we form convolutional networks to look at the whole event at once and remove the noise. These models basically remove the noise by finding the tracks, just like the standard algorithms. We later continued this work with graph neural networks and with more complicated events. The results will show up in an upcoming paper soon. The lesson from those studies is that the networks we find here need little change for more complicated situations and are indeed applicable to them as well.
## 2 Data Generation
MDC maps the 3D image of the events to 2D by recording the hits, which show up as electric pulses at the end caps. Still, the whole 3D image of an event is reconstructable, thanks to the time of flight information and the fact that the sense wires are not all aligned. The wires in the _straight_ layers are aligned with the \(z\) axes. However, wires of the _stereo_ layers have angles with this direction.
As mentioned above, we work with Bhabha events for the start. These scattering events only include two tracks of high energy electrons and positrons. The solenoid magnetic field at MDC is about 1 T. The diameter of the detector is about 1.6 m. Naturally, the tracks are straight lines. Having 43 layers means there are around 86 signal hits for each event. Bhwide generator is used to simulate these events [2]. We do not work with all the available information, which would be accessible for real data only after the reconstruction process. Instead, only what would be in the outcome of MDC is considered, which includes two geometrical dimensions plus the time that the hit happens and its electric charge value.
Next, we add noise to these events using another package of the offline system of the spectrometer called BESEventMixer[2]. This algorithm uses real data and randomly adds noise of various origins to the simulated events. The noise hits have only space and time related features. The added noise is therefore independent of the events as expected and is, on average, about 40 hits per event. Hence, about one third of our data is noise, and the neural networks that we form have the task of removing it. We simulated 80000 events, which was enough for our purposes here.
## 3 Fully Connected Networks
For the first step, we choose the regression approach to classify the hits into signal or background. The feature space has two space dimensions and one time dimension [Fig. 1]. We developed a neural network that is, in principle, able to learn a threshold in time for every cell of every layer that discriminates between signal and background. This is related to the time that the generated particle most likely reaches that point. Such a network cannot make use of the geometry of the trajectories, which is the motivation behind using convolutional networks introduced in the next section. In fact, all the hits are introduced to the network simultaneously and not as in individual events. Nonetheless, the outcome is better than a simple cut line in time for a few percents.
The model which works the best has seven fully connected hidden layers. This network can increase the original 70% average purity of the events to 93% and keep 94% of the signals [Fig. 2]. In other words, it removes 85% of the noise with the expense of losing about 6% of the signal hits. This result is the baseline for us to compare the effectiveness of other models, such as the CNN model introduced in the next section and the graph neural networks which will be presented in another article.
Since this model sees the hits one by one, we can apply it to one part of the data if needed. So it can be used in combination with other models. For example, in the next section, we show
how to simplify the events to pictures with fewer resolutions. If we apply this dense model to the data lost during simplification, then the efficiency of the whole model is comparable to when no simplifications are involved, while it is a faster and lighter model in terms of memory use.
## 4 Convolutional neural networks
The 3D trajectory of particles in MDC lit the drift cells, which send their signals to the end caps at the ends of their lengths. Thus, our data in its raw format includes the 2D projection of the 3D events. The pixels of each image are arranged in 43 concentric circles, each with a different resolution. The number of cells gradually increases from 40 on the first two layers to 288 on the last three. There are several acceptable ways to map this to a square to feed the neural networks. Here, we choose a simple method of looking at the events with the resolution of the first layer. So, we map every event to a 2D image with a size of 43 by 40. This means that the information of some of the neighboring cells is combined at the outer layers.
With this simplification, the neural network cannot make use of the information of about 2% of the hits. When that happens, one of the things that we can do is to just keep the hits that happened earlier since they are more likely to be signal hits. A better way is to pass that part of the hits from the classifying network introduced in the previous section. It was mentioned there that just looking at the time and position values of the hits can lead to more than 85% noise deletion and about 94% signal preservation. If we apply this to the 2%, this simplification
of the images removes about 0.1% of the signal hits and pollutes the data for only about 0.2%. The real situation is even better since the hit classification results are more efficient better for the hits happening at the last layers. Therefore we take this simplification of the images as a good approximation. Furthermore, we normalize the time value of each hit and show it to the network just like color is presented for normal pictures (Fig. 3).
Our investigations show that a deep learning model with five convolutional layers and five dense layers can successfully remove noise hits while preserving signal tracks. This network does the job by detecting the tracks along with the use of time values. This situation is just like when the color of the pixels helps the segmentation process for regular images. We observe that it is necessary to downsize mildly with the filtering process of the convolutional layers, then flatten them and pass the results through dense layers. The last hidden layer has 64 nodes. The target layer has 1720 nodes which is the number of pixels needed to rebuild the pictures. It is not needed to have convolutional layers for upsampling which are present in models like Unet [3]. In the final image, the particle tracks are boldened, and the off-track noise is gone perfectly. Moreover, we test different thresholds to keep the hits. This way, the tracks become sharper, and the on-track noise also disappears. In the end, we intersect the result with the input to not have any extra hits. Figure 4 show the result of passing an event from the trained network and then applying the threshold.
We train the network with 77000 events up to about 100 epochs using the IHEP GPU farm. The result is an increase in the average purity of the events from the original amount of about 70% to 98% while about 99% of the signal hits are preserved (Fig. 5). This means that, on average, every event will have only about 1.5 noise hits and lose only one signal hit after passing through the trained network.
We examined many possibilities and came up with the above architecture of the convolutional network, which is a rich model with about 20 million trainable parameters. It is worth mentioning that for different purposes, different areas of Fig. 5 might be favorable. We usually use the crossing point of purity and efficiency diagrams to compare different models. After this work, we tried more complicated events and more detailed images, and it turned out that the same structure worked for them as well. As for the Bhabha events, we try 100 by 100 pixel images which have comparable resolution with the real 2D images, e.g. 6796 pixels. They also lead to similar results and show that the above model is acceptable. We will discuss them along with more techniques and results in an upcoming paper.
Figure 4: A random event which includes noise is shown on the left side. The image at the middle shows the outcome of the network for this image. The right side image shows the same result after applying a threshold.
## 5 Conclusion
Since we already have many tools in high energy physics to generate simulated data and real data has also been stored for many years, it is very reasonable to use machine learning techniques in this area. Moreover, even a slight improvement in the purification of the stored events can be important in physics analysis. We see that even simplified models can have acceptable performances while being very fast and light which makes them good candidates for the trigger system or pre-processing of data. The hit classification approach for Bhabha events at the drift chamber of BESIII detector makes a baseline for further investigations. It also shows that a regression approach can be used in combination with other methods. Finally, the convolutional neural network that we introduced can distinguish the particle tracks and remove the noise in them in a way that the efficiency of the process and the purity of the final events are both about 98.7% at the same time.
|
2301.07710 | Fully Elman Neural Network: A Novel Deep Recurrent Neural Network
Optimized by an Improved Harris Hawks Algorithm for Classification of
Pulmonary Arterial Wedge Pressure | Heart failure (HF) is one of the most prevalent life-threatening
cardiovascular diseases in which 6.5 million people are suffering in the USA
and more than 23 million worldwide. Mechanical circulatory support of HF
patients can be achieved by implanting a left ventricular assist device (LVAD)
into HF patients as a bridge to transplant, recovery or destination therapy and
can be controlled by measurement of normal and abnormal pulmonary arterial
wedge pressure (PAWP). While there are no commercial long-term implantable
pressure sensors to measure PAWP, real-time non-invasive estimation of abnormal
and normal PAWP becomes vital. In this work, first an improved Harris Hawks
optimizer algorithm called HHO+ is presented and tested on 24 unimodal and
multimodal benchmark functions. Second, a novel fully Elman neural network
(FENN) is proposed to improve the classification performance. Finally, four
novel 18-layer deep learning methods of convolutional neural networks (CNNs)
with multi-layer perceptron (CNN-MLP), CNN with Elman neural networks
(CNN-ENN), CNN with fully Elman neural networks (CNN-FENN), and CNN with fully
Elman neural networks optimized by HHO+ algorithm (CNN-FENN-HHO+) for
classification of abnormal and normal PAWP using estimated HVAD pump flow were
developed and compared. The estimated pump flow was derived by a non-invasive
method embedded into the commercial HVAD controller. The proposed methods are
evaluated on an imbalanced clinical dataset using 5-fold cross-validation. The
proposed CNN-FENN-HHO+ method outperforms the proposed CNN-MLP, CNN-ENN and
CNN-FENN methods and improved the classification performance metrics across
5-fold cross-validation. The proposed methods can reduce the likelihood of
hazardous events like pulmonary congestion and ventricular suction for HF
patients and notify identified abnormal cases to the hospital, clinician and
cardiologist. | Masoud Fetanat, Michael Stevens, Pankaj Jain, Christopher Hayward, Erik Meijering, Nigel H. Lovell | 2023-01-16T06:58:20Z | http://arxiv.org/abs/2301.07710v1 | Fully Elman Neural Network: A Novel Deep Recurrent Neural Network Optimized by an Improved Harris Hawks Algorithm for Classification of Pulmonary Arterial Wedge Pressure
###### Abstract
Heart failure (HF) is one of the most prevalent life-threatening cardiovascular diseases in which 6.5 million people are suffering in the USA and more than 23 million worldwide. Mechanical circulatory support of HF patients can be achieved by implanting a left ventricular assist device (LVAD) into HF patients as a bridge to transplant, recovery or destination therapy and can be controlled by measurement of normal and abnormal pulmonary arterial wedge pressure (PAWP). While there are no commercial long-term implantable pressure sensors to measure PAWP, real-time non-invasive estimation of abnormal and normal PAWP becomes vital. In this work, first an improved Harris Hawks optimizer algorithm called HHO+ is presented and tested on 24 unimodal and multimodal benchmark functions. Second, a novel fully Elman neural network (FENN) is proposed to improve the classification performance. Finally, four novel 18-layer deep learning methods of convolutional neural networks (CNNs) with multi-layer perceptron (CNN-MLP), CNN with Elman neural networks (CNN-ENN), CNN with fully Elman neural networks (CNN-FENN), and CNN with fully Elman neural networks optimized by HHO+ algorithm (CNN-FENN-HHO+) for classification of abnormal and normal PAWP using estimated HVAD pump flow were developed and compared. The estimated pump flow was derived by a non-invasive method embedded into the commercial HVAD controller. The proposed methods are evaluated on an imbalanced clinical dataset using 5-fold cross-validation. The proposed CNN-FENN-HHO+ method outperforms the proposed CNN-MLP, CNN-ENN and CNN-FENN methods and improved the classification performance metrics across 5-fold cross-validation with an average sensitivity of 79%, accuracy of 78% and specificity of 76%. The proposed methods can reduce the likelihood of hazardous events like pulmonary congestion and ventricular suction for HF patients and notify identified abnormal cases to the hospital, clinician and cardiologist for emergency action, which can diminish the mortality rate of patients with HF.
Deep learning, convolutional neural networks, fully Elman neural networks, metaheuristics, heart failure, Harris Hawks algorithm.
## I Introduction
Cardiovascular disease (CVD) is a highly prevalent illness affecting 26.7 million people in the United States of America [1]. 6.5 million people are suffering from heart failure (HF) in the USA and more than 23 million worldwide [2]. The prevalence of HF will increase by 46% from 2012 to 2030, leading to more than 8 million adult with HF according to the American Heart Association [1]. Although heart transplantation is the gold standard treatment for end-stage HF patients, the number of donor hearts is significantly less than the demand for heart transplantation and therefore the mortality of people on the waitlist is high. Mechanical circulatory support is one of the most suitable treatments for HF patients, and is achieved by implanting a mechanical pump, called a left ventricular assist device (LVAD), into the body of the HF patients [1, 2].
Currently LVADs are operated at constant speed which makes them insensitive to changes in demand as physiological conditions change [3]. This can lead to hazardous events like ventricular suction (ventricular collapse because of low pressure in the ventricle) or pulmonary congestion (excess fluid in the lungs because of high pressure in the ventricle) [4]. Physiological control systems for LVADs can be used to automatically adjust pump speed to maintain a constant left ventricular end-diastolic pressure (LVEDP) [4, 5]. Maintaining this important clinical variable can supplement the Frank-Starling response of the native heart and therefore can prevent these hazardous events for HF patients [6, 7, 8, 9].
This physiological control system approach requires an implantable pressure sensor to measure LVEDP in HF patients. However, there are currently no commercial long-term implantable pressure sensors available. An alternative is to use pulmonary arterial wedge pressure (PAWP) as it can be measured more easily as a surrogate index for LVEDP by catheterization [3, 4, 10, 11]. Nevertheless, measuring the PAWP by pulmonary artery catheterization can only work for a short period of time in hospital settings as most of these patients are discharged home, and this technique not being suitable of safe outside the hospital environment. Therefore, the non-invasive prediction of abnormal and normal PAWP becomes more critical. If these values can be predicted, a physiological control system is able to automatically adjust the pump speed to restore PAWP to a safe level.
Machine learning algorithms can be employed for identifying the abnormal and normal PAWP using a non
invasive signal from the implanted pump [11]. These algorithms mainly include feature extraction, feature selection and classification parts. However, manually extracting and selecting suitable features is time-consuming and can lead to overfitting [12]. Furthermore, extracting features manually can reduce the generalization ability of the machine learning methods [12].
To overcome this issue, deep learning methods such as convolutional neural networks (CNNs) can be used to automatically extract and select the features from the raw input signals or images [12, 13, 14]. Previously, a variety of deep learning methods have been used for the classification of cardiovascular disease using electrocardiogram (ECG) signals [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]. Furthermore, several previous studies have employed recurrent neural networks (RNN) for classification of CVDs [28, 29]. The results demonstrated that RNNs outperform static conventional neural networks like a multi-layer perceptron (MLP) as RNNs have a dynamic processing ability [12, 30, 31, 32, 33, 34]. However, the Elman neural network (ENN) is standing out among many classical types of RNNs and is widely applied in different research fields [35, 36, 31, 37]. An ENN, which has a dynamic memory ability, can use the previous and current features of the input signals for improving the classification performance metrics and is more suited for the small imbalanced dataset used in this work. Modification of ENN can further improve the classification performance.
CNNs suffer from the need for many hyper-parameters, which should be optimized during training of the networks. However, optimizing hyper-parameters manually is very challenging [38, 39, 40].
Moreover, the hyper-parameters are data dependent and therefore may not be appropriate in another dataset. Obtaining the appropriate values of the hyper-parameters of CNNs is not an easy task since there is no robust mathematical approach which can be employed. Hence, determining the values of the hyper-parameters of CNNs necessitates many iterations to achieve better performance [39]. Random and grid searches could be employed to determine the hyper-parameters automatically, however these are time consuming [39]. In addition, Bayesian optimization methods could be also used to achieve the hyper-parameters. However, it requires estimation of several statistics of the error function, which can lead to an inefficient results [41, 42]. Proposing an automatic method based on the metaheuristic algorithms for optimization of the values of these parameters can significantly result in less computational cost and higher performance [43]. These metaheuristic algorithms can also work on non-continuous, and non-differentiable problems [44, 45].
There are many metaheuristic algorithms such as Particle Swarm Optimization (PSO) [46], Differential Evolution (DE) [47], Gravitational Search Algorithm (GSA) [48], Harris Hawks Optimization (HHO) [44], Marine Predators Algorithm (MPA) [49], Slime Mould Algorithm (SMA) [50], Equilibrium Optimizer (EO) [51], Salp Swarm Algorithm (SSA) [52], Grey Wolf Optimizer (GWO) [53], Preaching Optimization Algorithm (POA) [54], Red fox optimization algorithm (RFO) [55], African Cultures Optimization Algorithm (AVOA) [56] and Artificial Gorilla Troops Optimizer (GTO) [57]. In metaheuristics, two major strategies of exploration and exploitation of random search are executed. While exploration refers to finding relevant areas in the solution space, exploitation concerns the extraction of useful information from these areas [58]. Based on the "no free lunch (NFL)" theorem [59], which states that there is no ideal metaheuristic to solve all types of optimization problems well [60], any given problem may benefit from an improved metaheuristic algorithm. The HHO algorithm outperformed many other metaheuristic algorithms for finding optimal solution in different benchmark functions [61, 44, 60], and several applications such as image thresholding problems [62], estimation of photovoltaic models [63] and drug design [64]. The HHO algorithm was inspired by chasing and escaping behavior between Harris Hawks and rabbits as was recently introduced by Heidari et al. [44]. Furthermore, Heidari et al. showed that HHO can fail in providing optimal solutions in some cases [60, 44]. These findings motivated us to try to improve the well-known HHO algorithm.
This is the first study on detection of abnormal and normal PAWP non-invasively from pump flow for HF patients with implanted LVADs using a deep learning method. This study aims to improve the performance of the abnormal and normal PAWP classifications which can be employed in real-time. Although there are many deep learning methods in the literature, none to date have considered the effect of a recurrent neural network in the last layers of a CNN for this purpose. The proposed network has connections between two consecutive time points for the output layer, two consecutive time points for the hidden layer, input layer to output layer, and output layer to hidden layer. The hypothesis of this study was that these connections may fully use the long-term, spatial and temporal information of the input, hidden and output variables. Furthermore, the conventional optimization methods in the literature might not be capable of escaping from the local optima. Therefore, a new optimization method was proposed not only to optimize the hyper-parameters of the proposed deep learning methods, but also to improve the performance over standard benchmark functions. The classification of PAWP based on the pump flow signal from the commercial HVAD controller can be used to adjust the pump speed in real-time and therefore reduce the likelihood of hazardous events like pulmonary congestion and ventricular suction. Furthermore, the proposed method can be implemented on a mobile software platform and notify identified abnormal cases to the hospital, clinician and cardiologist for emergency action, which can diminish the mortality rate patients with HF.
The novelty of this work is multifold, first a modified HHO algorithm called HHO+ is proposed. Second, a new fully Elman neural network called FENN is proposed, which employs long-term and temporal information of the input and output variables that can improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO+ algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO algorithm to further improve the classification performance. Third, the hyper-parameters of FENN were optimized by the proposed HHO algorithm to further improve the classification performance.
performance. Finally, four non-invasive approaches for the classification of abnormal and normal PAWP via combination of CNN, ENN, FENN and HHO+ using the pump flow signal are proposed and compared. Relevant features are automatically extracted from the input pump flow signal by a CNN.
In the following sections, first the clinical dataset and preprocessing are described. Next, the HHO, CNN and ENN algorithms are introduced. Then, an improved Harris Hawks algorithm (HHO+) and novel fully Elman neural network (FENN) are presented. The proposed HHO+ is compared with recent metaheuristics such as HHO [44], MPA [49], SMA [50], EO [51], SSA [52] and GWO [53]. Subsequently, four novel methods for classification of PAWP, namely CNN-MLP, CNN-ENN, CNN-FENN and CNN-FENN-HHO+, are fully proposed. Afterwards, the performance evaluation metrics, K-fold stratified cross validation procedure and weighted cross-entropy loss function are described. Then, the proposed HHO+ is validated on 24 unimodal and multimodal benchmark functions. Subsequently, the comparative classification results of CNN-MLP, CNN-ENN, CNN-FENN and CNN-FENN-HHO+ on 5-fold cross-validation using a clinical patient dataset are presented. Finally, a discussion of the results, study limitations and future work concludes the paper.
## II Methodology
### _Dataset_
The clinical data set was achieved from 25 stable and ambulatory patients with implanted HVAD (HeartWare, Medtronic) pump. PAWP was measured using right heart catheterization (7.5-French double transducer Swan-Ganz CCO catheter; Edwards Lifesciences, Irvine, CA) into the pulmonary artery of the implanted patients. HVAD pump flow was estimated by a non-invasive method embedded into the commercial HVAD controller. PAWP and pump flow were recorded in different pump speeds and exercise workloads. The sampling rate of the pressure and flow measurements were 50 Hz. The experimental study was approved by St Vincent's hospital research ethics committee [11]. The data were used for a 5-fold cross-validation dataset for evaluation of the proposed methods. PAWP of less than 8 or greater than 16 mmHg was taken to be abnormal, and other values as a normal condition, based on the clinicians' suggestions from St Vincent hospital in Sydney, Australia. The recorded dataset is an imbalanced dataset which has 459 abnormal PAWP and 1338 normal PAWP samples.
### _Data pre-processing_
A Butterworth low-pass filter with stop frequency of 15 Hz was employed to remove the higher frequency noise and smooth the PAWP and pump flow signals. The pump flow signal was then segmented with a length of 6 s (300 samples). The mean PAWP was calculated for each segment from all the samples between two consecutive minima using the filtered PAWP. PAWP has a pulsatile waveform due to heart contractility, and inhalation and exhalation. This process is shown in Fig. 1.
### _Background materials_
The HHO algorithm is a population-based and gradient-free optimization algorithm, which was inspired by exploring a prey (rabbit), surprising bounce, collaborative behavior of hawks, and different attacking strategies for catching a prey. Although the hawks first look for different potential locations to hunt, the rabbit exhibits escaping behavior to improve its survival chance. In this analogy, the rabbit represents the best solution, and the hawks represent candidate solutions in each iteration [44].
The CNN is one of the most popular deep learning methods and was proposed by Fukushima in 1980 and improved by Lecun in 1998 [65, 66]. CNNs can automatically extract features from the raw input signals using some filters and then map the features to the labeled classes [31].
ENNs are similar to feed-forward neural networks, except that the hidden layer has a recurrent connection with a certain delay to each neuron, allowing the network a dynamic response to time dependent input data, which can increase the performance of the classification [12].
Due to space limitations on the manuscript, the HHO, CNN and ENN algorithms are described in detail in supplementary materials in sections 1, 2 and 3, respectively.
### _Improved Harris Hawks algorithm (HHO+)_
#### Ii-D1 Improved exploration and exploitation algorithm (IEEA)
In the conventional HHO algorithm, the exploration and exploitation phases were only defined based on the escaping energy of the rabbit. However, this cannot give the whole required information for different attacking strategies on catching a prey as other factors such as velocity of the hawks and rabbit are also very important in each step of the HHO algorithm.
The marine predator algorithm (MPA) [49] is a new metaheuristic algorithm mimicking the whole life of a predator and prey in terms of their velocities. The results showed that
Fig. 1: A Butterworth low-pass filter with stop frequency of 15 Hz was employed to remove the higher frequency noise and smooth the PAWP and pump flow signals. The mean PAWP was calculated for each segment from all the samples between two consecutive minima using the filtered PAWP. PAWP: pulmonary arterial wedge pressure.
MPA is extensively able to explore and exploit the solution space [49]. However, the solutions derived from MPA can be trapped in local optima. Therefore, a new algorithm to improve the global solution and avoid trapping in local optima is presented here, which was inspired from MPA. In the improved exploration and exploitation algorithm (IEEA), some phases of MPA were modified and then combined, and an adaptive decreasing threshold was added to the algorithm, in which all have been determined experimentally. This algorithm mimics the process of hawks hunting a rabbit and the rabbit escaping in terms of their velocities and rapid movements. Accordingly, employing the IEEA can prevent the solutions being trapped into local optima and improve the optimal solution.
The improved exploration and exploitation algorithm includes two sections: (1) when the rabbit is escaping equal to or faster than the hawks are moving and (2) when the hawks are moving faster than the escaping rabbit. The first phase occurs in the initial iteration of optimization, where exploration is more important than exploitation. The second phase happens in the intermediate and last phases of optimization, where the exploration attempts are converted to exploitation gradually or exploitation matters more than exploration.
These two phases are mathematically described as follows:
\[\begin{array}{l}X_{t+1}\\ =\left\{\begin{array}{ll}X_{t}+rand\times R_{G}\times(X_{rabbit,t}-R_{G} \times X_{t})&if\;rand<a\\ (X_{rabbit,t}+rand\times R_{G}\times(R_{G}\times X_{rabbit,t}-X_{t})\; otherwise\end{array}\right.\end{array} \tag{1}\]
where \(X_{t+1}\) and \(X_{t}\) are the position vectors of the hawks in iteration \(t+1\) and \(t\), respectively. \(X_{rabbit,t}\) denotes the position of the rabbit (best solution) in iteration \(t\). \(a\) is an adaptive decreasing threshold for switching between exploration and exploitation algorithms. \(rand\) denotes a uniformly distributed random number in the interval (0,1) and \(R_{G}\) is a vector including random numbers based on the zero-mean and unit-variance Gaussian distribution:
\[R_{G}(x)=\frac{1}{\sqrt{2\pi\sigma^{2}}}exp\left(-\frac{(x-\mu)^{2}}{2\sigma^ {2}}\right)=\frac{1}{\sqrt{2\pi}}exp\left(-\frac{x^{2}}{2}\right) \tag{2}\]
\(\mu\) and \(\sigma\) denote the mean and variance of the Gaussian distribution, respectively.
The adaptive decreasing threshold \(a\) is defined as follows:
\[a=tanh(-\left(\frac{t}{T}\right)+1) \tag{3}\]
where \(t\) and \(T\) are the current and maximum number of iterations, respectively. A maximum number of iterations is employed as the stopping criterion for the HHO+ algorithm. To compare Levy-flight and Gaussian distributions, 2D trajectory of Levy-flight and Gaussian distributions are shown in Fig. S4a and 4b, respectively.
```
Inputs: The population size N and maximum number of iterations T Initialize the random hawk populations \(X_{t}(i=1,2,...,N)\) in the specific search space while (maximum iteration is not met) do Calculate the fitness values of hawks Set \(X_{rabbit}\) as best solution of hawks for (each hawk (\(X_{i}\))) do Update the initial energy E0 and jump strength J Update the E using Eq. (S3) If(\(|E|\geq 1\)) then Exploration phase Update the hawk vectors using Eq. (S1) elseif(\(|E|<1\))then Exploitation phase if(\(r\geq 0.5\) and \(|E|\geq 0.5\)) then Update the hawk vectors using Eq. (S4) elseif(\(r\geq 0.5\) and \(|E|<0.5\))then Hard besiege Update the hawk vectors using Eq. (S6) elseif(\(r<0.5\) and \(|E|\geq 0.5\))then SBWPRD Update the hawk vectors using Eq. (S10) elseif(\(r<0.5\) and \(|E|<0.5\))then HBWPRD Update the hawk vectors using Eq. (S11) end Update X\({}_{\text{rabbit}}\) by the proposed IEEA using Eqs. (1), (2) and (3) Apply QOBL in Algorithm S2 and update X\({}_{\text{rabbit}}\) end for Return The location of rabbit (\(X_{rabbit}\)) and its fitness value where \(w_{2}\), \(w_{3}\) and \(w_{1}\) are the connection weights between hidden layer to output layer, input layer to hidden layer, and input layer to hidden layer, respectively. \(\gamma_{c1}(\mathbf{t})\), \(\gamma_{c2}(\mathbf{t})\) and \(\gamma_{c}(\mathbf{t})\) denote the output context layer 1, output context layer 2 and context layer for hidden layer at \(t\), respectively. \(b_{2}\) and \(b_{1}\) are the bias for output layer and hidden layer. \(w_{4}\), \(w_{6}\) and \(w_{8}\) represent the recurrent connection weights between the moment \(t\) and \(t-1\) of \(x_{c}\), \(y_{c1}\) and \(y_{c2}\), respectively. \(w_{5}\), \(w_{7}\) and \(w_{9}\) indicate the connection weights of \(x(t-1)\) to \(x_{c}(\mathbf{t})\), \(y(t-1)\) to \(y_{c1}(t)\), and \(y(t-1)\) to \(y_{c2}(t)\). \(y(t)\) and \(x(t)\) represent the vector of the output layer and hidden layer at \(t\), respectively, and \(u(t-1)\) is the vector of the input layer at \(t-1\). \(f\) and \(g\) represent the activation function of the output layer and hidden layer, which were chosen as softmax and hyperbolic tangent sigmoid, respectively.
```
**Algorithm 1** Pseudo code of the proposed HHO+ algorithm
### _Proposed combined CNN with FENN and HHO+ (CNN-FENN and CNN-FENN-HHO+)_
In this study, a CNN with FENN (CNN-FENN) and CNN with FENN optimized by HHO+ (CNN-FENN-HHO+) are proposed and compared to CNN with MLP (CNN-MLP) for classification of abnormal and normal PAWP using the features from the pump flow signal. All three CNNs are trained and validated with the same patient dataset.
In standard CNNs, a MLP is employed in the final layers to map the features to the labeled classes. However, the combination of CNN with MLP may result in poor classification performance on time-related data [12]. Therefore, in this study, the CNN-MLP in which the last two layers (fully-connected layers) are substituted with a FENN (CNN-FENN),
Fig. 2: Architecture of the proposed FENN model. u(t-1) is the vector of the input layer at the moment t-1, \(\mathbf{x(t)}\) represents the vector of hidden layer, and \(\mathbf{x_{c}(t)},\mathbf{y_{x1}(t)}\) and \(\mathbf{y_{c2}(t)}\) represent context layer for hidden layer, output context layer 1 and output context layer 2 at the moment \(\mathbf{t}\), and \(\mathbf{y(t)}\) is the vector of output layer at the time t.
is trained by the Adam algorithm [70] to classify the abnormal and normal PAWP. Fig. 3 depicts the architecture of the proposed CNN-FENN model.
The proposed deep learning methods were optimized by testing different filter sizes, number of layers and the types of each layer to minimize the loss function using grid search. To further improve the classification performance of CNN-FENN, three hyper-parameters related to training of CNNs, namely initial learning rate (ILR), learning rate drop factor (LRDF), and dropout probability (DP), were optimized by the proposed HHO+. Fig. 4 shows the flowchart of the proposed CNN-FENN-HHO+ system for classification of the abnormal and normal PAWP. In this hybrid algorithm, first the hawk populations are randomly generated, as in the classical HHO algorithm. Then, the fitness function in Eq. (14) is calculated by training the CNN-FENN and taking the average of the 10 results of training datasets. Afterward, the positions of hawks are updated using the proposed Algorithm 1. Once the current iteration reaches the maximum number of iterations, the found optimal values of ILR, LRDF and DP are fed to the CNN-FENN for validation on the test dataset. The final result is obtained by taking the average of the 5 results of the test dataset through 5-fold cross validation using the optimal parameters found by the proposed HHO+ algorithm.
### _Experimental setup, structure and parameters of HHO+, CNN-FENN and CNN-FENN-HHO+_
Table S2 shows the parameter settings for the optimization algorithms: HHO [44], MPA [49], SMA [50], EO [51], SSA [52] and GWO [53]. The proposed HHO+ is compared with these algorithms on 24 unimodal and multimodal benchmark optimization functions [53, 71] with the dimension of 1000. Table S3 shows the mathematical equations of these benchmark functions, depicted in Fig. S5. The population size for all the optimization algorithms and maximum iterations were set to 30 and 500, respectively [44]. All the optimization algorithms were randomly initialized. To increase the robustness of the result due to used random values in the optimization algorithms, each algorithm is initialized and run 30 times.
Table S4 represents the type of each layer, kernel sizes, activation functions and other parameters of the proposed CNN-FENN and CNN-FENN-HHO+, respectively. Layers 1 to 8 were created by convolution and batch normalization layers with LeakyReLU activation. Afterwards, layers 9 to 12 were constructed by convolution layers with LeakyReLU activation, max-pooling layers with stride 2 and batch normalization layers. Then, layers 13 to 16 were made by convolution and batch normalization layers with LeakyReLU activation. Finally, a ENN and FENN with 20 neurons in the hidden layer and activation function of hyperbolic tangent sigmoid (Tansig) and two neurons in the output layer with softmax activation were employed in layer 17 and 18 of CNN-FENN and CNN-FENN-HHO+, respectively.
As can be seen from Table S1 and Table S4 the same convolutional layers, batch normalization layers, size of kernels and activation functions were used for CNN-MLP, CNN-FENN and CNN-FENN-HHO+. The main difference among these methods is the last two layers which are used for classification
Fig. 3: Architecture of the proposed CNN-FENN model for classification of the abnormal and normal PAWP. 300 samples of pump flow signal are fed to the CNN-FENN as input. This is followed by three convolutional layers as well as batch normalization layers. Five convolutional, max-pooling layers with stride 2 and batch normalization layers are placed in the subsequent layers. The proposed FENN layer is located in the last layer of the CNN-FENN model to classify the abnormal and normal PAWP.
of the features automatically extracted by the convolutional kernels.
The Adam algorithm was employed to optimize the weights and biases of the proposed CNN-MLP, CNN-FENN and CNN-FENN-HHO+ methods [70]. The algorithm by He was used to initialize the weights for CNN-MLP, CNN-FENN and CNN-FENN-HHO+ as it outperforms the well-known Xavier algorithm [72]. Furthermore, the proposed CNN-MLP, CNN-FENN and CNN-FENN-HHO+ were trained with 1000 iterations and a batch size of 179. This batch size value was set to one tenth of the total number of samples used in this study. All methods were implemented and run in MATLAB version 2020b (MathWorks, USA) and the experiments were performed on a computer with 16 GB of RAM, Core i7-8700K [email protected] GHz.
### _Performance evaluation metrics_
Three standard performance metrics including accuracy, sensitivity and specificity were used to assess and evaluate the proposed methods:
\[Accuracy=\frac{TP+TN}{TP+FN+TN+FP} \tag{11}\] \[Sensitivity=\frac{TP}{TP+FN}\] (12) \[Specificity=\frac{TN}{TN+FP} \tag{13}\]
where true positive (TP) denotes the number of abnormal PAWP classified correctly, true negative (TN) the number of the normal PAWP classified correctly, false positive (FP) indicates the number of normal PAWP classified incorrectly as abnormal PAWP, and false negative (FN) the number of the abnormal PAWP classified incorrectly as normal PAWP.
Accuracy refers to the proposed methods' ability to identify both abnormal and normal PAWP correctly, sensitivity is the proposed methods' ability to correctly detect abnormal PAWP, and specificity refers to the proposed methods' ability to identify the normal PAWP correctly.
### _K-fold stratified cross validation_
A 5-fold stratified cross validation [23] was employed to evaluate the ability of the proposed methods to classify abnormal and normal PAWP. Stratified cross validation was chosen due to the imbalanced dataset. It selects an equal portion of abnormal and normal PAWP for each fold of the dataset. First, the abnormal and normal PAWP samples were partitioned into ten parts, and nine parts of abnormal and normal PAWP samples were used to train the proposed methods and the rest were used for testing. Then, this process was repeated nine times to consider each of the ten folds for testing and the remaining folds for training. Moreover, 10% of the training dataset was assigned into a validation subset through cross-validation. In each fold, five patients which were not seen in the training dataset, were used in the test dataset for each iteration.
### _Loss function_
The classical cross-entropy function is not a suitable loss function due to the imbalanced clinical dataset used in this work. This function may result in high accuracy but very low sensitivity or specificity or will bias toward the majority class. Although it is important that the proposed methods correctly detect abnormal PAWP (high sensitivity), they should also be able to correctly identify normal PAWP (high specificity). The following weighted cross-entropy loss function [73] was employed to train the proposed deep neural networks for classifying abnormal and normal PAWP:
Fig. 4: Flowchart of the proposed CNN-FENN-HHO+ system.
\[Loss\ Function=-\sum_{j=1}^{K}w_{j}\ \times T_{j}\times log\big{(}p_{j} \big{)} \tag{14}\] \[w_{j}=1-\frac{\text{number of samples in the $j^{th}$ class}}{\text{number of total samples}}\] \[,\sum_{j=1}^{K}w_{j}=1 \tag{15}\]
where \(\text{w}_{j}\) is the weight assigned to the class \(j\), \(K\) is the number of classes, \(\text{T}_{j}\) is the \(j^{th}\) element of the ground truth (target) vector and \(p_{j}\) is the \(j^{th}\) element of the estimated vector.
## III Results
### _Benchmark function validation_
The comparative results of the proposed HHO+ on 24 unimodal and multimodal benchmark optimization functions for dimension 1000 are presented in Table S5.
The mean and standard deviation of 30 runs of each HHO+, HHO, MPA, SMA, EO, SSA and GWO algorithm are shown. According to this table, HHO+ achieved the best solutions on all the unimodal and multimodal benchmark optimization functions. As can be observed, the proposed HHO+ achieved an optimal fitness of 0 within 500 iterations with average and standard deviation of 0 in the benchmark functions of F1, F2, F7, F8, F11, F13, F21, F22, F23, and F24.
TABLE I shows the comparative results of two non-parametric statistical tests; Wilcoxon rank sum test [74] and Friedman's test [75] for dimension 1000. Wilcoxon rank sum test is a non-parametric statistical test that can determine the significant differences between the results of two algorithms. Friedman's test is able to rank the optimization methods based on their overall performance across different benchmark functions. According to this table, HHO+ obtained the best average ranking followed by HHO, SMA, MPA, EO, GWO and SSA, respectively. In the table, the signs '+', '=', and '-' indicate that the proposed HHO+ is significantly better than, equal or worse than the other optimization algorithms for significance level of 5%, respectively using Wilcoxon rank sum test. Friedman's test also showed the overall rank of the optimization methods on all the benchmark functions. The best results are marked in bold in Table S5 and TABLE I. It can be seen from TABLE I that HHO+ outperformed HHO, MPA, SMA, EO, SSA and GWO in 12, 22, 18, 24, 24, 24 benchmark functions, respectively, for a p-value of less than 0.05. Although the Wilcoxon rank sum test showed that HHO+ achieved better results than the other optimization methods for the majority of the benchmark functions, this merit was not statistically significant for the rest of the functions. Friedman's test results also showed that HHO+ was placed in the first rank compared to other competitors.
Fig. S6 shows convergence curves for F1 to F24, respectively. As can be seen from these figures, the HHO+ convergence curve is better (converges faster) than other optimization algorithms for both unimodal and multimodal benchmark optimization functions, except F11, F12 and F13, in which the HHO+ is ranked in second place.
Fig. S7 depicts the scalability results of the proposed HHO+ with different dimensions from 100 to 5000 in logarithm scale for the selected benchmark functions of F5, F6, F9, F15, F16 and F19 as the most challenging (not very close to the global minimum) functions shown in Table S3. Fig. S8 also shows the scalability results of the proposed HHO+ with different dimensions for F16 and F19 in normal scale to show the superiority of HHO+ more clearly. It can be observed from these figures that HHO+ outperforms the other optimization algorithms in both lower and higher dimensional problems.
Table S6 and S7 show the computational time of the optimization methods (HHO+, HHO, MPA, SMA, EO, SSA and GWO) on each of the 24 benchmark functions for dimension 1000 across 30 runs and the proposed deep learning methods (CNN-MLP, CNN-ENN, CNN-FENN and CNN-FENN-HHO+) across 30 training runs (10 epochs), respectively. It can be observed from these tables that the HHO optimization algorithm and CNN+MLP network structure have the minimum computational complexity.
_Application of the proposed FENN and HHO+ on the classification of pulmonary arterial wedge pressure_
Four 18-layer deep learning methods called CNN-MLP, CNN-ENN, CNN-FENN and CNN-FENN-HHO+ for classification of abnormal and normal PAWP using pump flow were compared in TABLE II. This table presents the average and standard deviation of the classification results of PAWP across 5-fold cross validation. The results show that the proposed CNN-FENN-HHO+ improved accuracy, sensitivity and specificity, and outperforms CNN-MLP, CNN-ENN and CNN-FENN methods. Table II also presents the p-values (95% confidence level) based on the Wilcoxon rank sum test to show the statistical significance between the methods. The results show that the proposed CNN-FENN-HHO+ method statistically outperforms the CNN-MLP method.
## IV Discussion
In this work, an improved HHO (HHO+) algorithm was proposed by combination of HHO, IEEA and QOBL algorithms, being validated on 24 unimodal and multimodal benchmark functions. Although the combination of IEEA, QOBL and HHO algorithm increased the computational complexity of the HHO+ algorithm as shown in Table S6, stagnation in HHO can be avoided more efficiently. The proposed IEEA and employed QOBL concepts generate a set of solutions that can improve the convergence rate and global solution of the original HHO algorithm. This is the advantage of the proposed HHO+ in terms of computational time cost since simply increasing the number of iterations cannot improve the performance of the optimization methods as shown in Fig. S6. In this figure, the convergence curves of all the optimization algorithms except HHO+ stay constant after some iterations for most benchmark functions. The average and standard deviation of 0 in the benchmark functions of F1, F3, F7, F8, F11, F13, F21, F22, F23 and F24 indicate the robustness of the proposed HHO+ on both unimodal and multimodal benchmark functions. Overall, the experimental and statistical (Friedman mean rank and Wilcoxon rank tests) analyses from Table S5 and TABLE I showed the superiority of the proposed HHO+ over the classical HHO and other state-of-the-art algorithms to find the global optima. Fig. S7 and Fig. S8 demonstrate that the performance of HHO+ remains consistently superior even in high-dimensional problems, while the performance of other methods is degraded by increasing dimensions.
A novel Elman neural network called FENN was proposed to improve the classification performance for the considered problem. Moreover, the proposed HHO+ was employed to optimize the three hyper-parameters of CNN-FENN called ILR, LRDF and DP for classification of abnormal and normal PAWP. The results shown in TABLE II indicate that the proposed CNN-FENN-HHO+ method improved accuracy, sensitivity and specificity. This improvement supports the hypothesis of this study that connections between two consecutive time points for the output layer, two consecutive time points for the hidden layer, input layer to output layer, and output layer to hidden layer of a recurrent neural network might fully use the long-term, spatial and temporal information of the input, hidden and output variables of the features, and can therefore lead to higher performance. Appropriate features were automatically extracted from the pump flow signal by convolutional filters in these four deep learning methods. Although the training and testing times of CNN-FENN-HHO+ shown in Tables S7 demonstrate the highest computational complexity compared to other algorithms due to the additional connections between the neurons in the FENN, the proposed algorithm takes only about 1 ms for each heartbeat in the test dataset, which is rapid enough for real-time implementation of the method.
An imbalanced clinical dataset was used in this study for classification of abnormal and normal PAWP. An imbalanced training dataset can impede the convergence of the training process by biasing the training algorithm toward the majority class. Furthermore, it may affect the generalizability of the proposed methods and the performance on the test dataset. Although data augmentation strategies such as oversampling and down-sampling can balance the samples of the classes, they are prone to cause overfitting or losing useful information [76, 77]. Therefore, in this work, the weighted loss function was proposed to overcome the problem.
Lai et al. [11] employed multiple linear regression to estimate PAWP using the slope of the HVAD flow waveform at diastole for HF patients. However, the method resulted in poor \(\tau^{2}\) of 0.54. Furthermore, the ability of the slope of the HVAD flow waveform at diastole to discriminate PAWP \(\geq\) 20 mmHg (high PAWP) was evaluated by sensitivity and specificity. The results showed a sensitivity of 77% and specificity of 86% for identifying high PAWP. However, in this study, both low and high PAWP were set to abnormal PAWP and the rest as normal. In addition, it is not clear how much data was employed for training, validation, and testing which can change the results significantly.
Estimation of high PAWP (PAWP \(\geq\) 18 mmHg) using the slope of the ventricular filling phase based on 15 HVAD patients was proposed by Grinstein [78]. Although here, too, it is not clear how much data was employed for training, validation and testing, the results derived from multivariable regression demonstrated a sensitivity of 87% and specificity of 95% for only high PAWP. However, in this work, both low and high PAWP was set to abnormal PAWP and 5-fold cross
validation on 25 HVAD patients was used to assess the results. Imamura et al. [79] employed the slope of the ventricular filling phase to estimate high PAWP (PAWP \(\geq\) 18 mmHg) using a linear regression. The results show a sensitivity and specificity of 91.5% and 95.2% to predict only high PAWP, respectively.
Although this work only focuses on the classification of normal and abnormal PAWP using pump flow, it has the potential to be extended to detection of many types of cardiac arrhythmias and real-time monitoring using the ECG signal from the proposed deep learning methods. Moreover, the proposed HHO+ algorithm can be employed to solve real problems with unknown search spaces such as path planning, feature selection, electrical power generation systems, manufacturing processes, image processing, bio-informatics and solar photovoltaic parameter estimation [80].
One of the limitations of this study is that the methods were compared and validated on a small clinical dataset. Therefore, a larger clinical dataset is needed to train and validate the proposed methods. Furthermore, the computational complexity of the optimization and training of the CNN-FENN-HHO+ is higher than the other methods. However, the optimization and training of the CNN-FENN-HHO+ method are performed offline, so it does to some extent obviate this issue.
The accuracy, sensitivity and specificity of the proposed method can still be improved by using a more sophisticated neural network for mapping the final features derived by CNN filters to the labeled classes. Furthermore, the performance of deep networks may be improved by using larger training datasets. The relatively small clinical dataset used in this study may have limited the performance of the compared network. Accordingly, future work will include testing other neural network architectures and collecting additional clinical data for training and validating them on independent datasets.
## V Conclusion
A novel improved HHO (HHO+) optimization algorithm was proposed, which was validated for optimization of 24 unimodal and multimodal benchmark functions. The results showed that the proposed HHO+ can further improve the global solution and convergence rate. Furthermore, a novel Elman neural network called FENN was proposed to improve the performance metrics of the classification problem. The proposed HHO+ was employed to optimize the three hyper-parameters of CNN-FENN called ILR, LRDF and DP. Moreover, four 18-layer deep learning methods called CNN-MLP, CNN-ENN, CNN-FENN and CNN-FENN-HHO+ for classification of abnormal and normal PAWP using pump flow were developed and compared. The proposed methods were evaluated on an imbalanced clinical dataset using 5-fold cross-validation. Useful features were automatically extracted from the low-pass filtered pump flow signal by convolutional filters. The results demonstrated that the combination of CNN, FENN and HHO+ for classification of abnormal and normal PAWP improved the classification performance. The classification of PAWP based on the pump flow signal can be used to adjust the pump speed in real-time and therefore reduce the likelihood of hazardous events like pulmonary congestion and ventricular suction for HF patients. Furthermore, the proposed method can be implemented on a mobile software platform and report the identified abnormal cases to the hospital, which can diminish the mortality rate of patients with HF.
## Acknowledgment
The authors would like to recognize the financial assistance provided by the National Health and Medical Research Council Centers for Research Excellence (APP1079421).
|
2310.14978 | LC-TTFS: Towards Lossless Network Conversion for Spiking Neural Networks
with TTFS Coding | The biological neurons use precise spike times, in addition to the spike
firing rate, to communicate with each other. The time-to-first-spike (TTFS)
coding is inspired by such biological observation. However, there is a lack of
effective solutions for training TTFS-based spiking neural network (SNN). In
this paper, we put forward a simple yet effective network conversion algorithm,
which is referred to as LC-TTFS, by addressing two main problems that hinder an
effective conversion from a high-performance artificial neural network (ANN) to
a TTFS-based SNN. We show that our algorithm can achieve a near-perfect mapping
between the activation values of an ANN and the spike times of an SNN on a
number of challenging AI tasks, including image classification, image
reconstruction, and speech enhancement. With TTFS coding, we can achieve up to
orders of magnitude saving in computation over ANN and other rate-based SNNs.
The study, therefore, paves the way for deploying ultra-low-power TTFS-based
SNNs on power-constrained edge computing platforms. | Qu Yang, Malu Zhang, Jibin Wu, Kay Chen Tan, Haizhou Li | 2023-10-23T14:26:16Z | http://arxiv.org/abs/2310.14978v1 | # LC-TTFS: Towards Lossless Network Conversion for Spiking Neural Networks with TTFS Coding
###### Abstract
The biological neurons use precise spike times, in addition to the spike firing rate, to communicate with each other. The time-to-first-spike (TTFS) coding is inspired by such biological observation. However, there is a lack of effective solutions for training TTFS-based spiking neural network (SNN). In this paper, we put forward a simple yet effective network conversion algorithm, which is referred to as LC-TTFS, by addressing two main problems that hinder an effective conversion from a high-performance artificial neural network (ANN) to a TTFS-based SNN. We show that our algorithm can achieve a near-perfect mapping between the activation values of an ANN and the spike times of an SNN on a number of challenging AI tasks, including image classification, image reconstruction, and speech enhancement. With TTFS coding, we can achieve up to orders of magnitude saving in computation over ANN and other rate-based SNNs. The study, therefore, paves the way for deploying ultra-low-power TTFS-based SNNs on power-constrained edge computing platforms.
Deep Spiking Neural Network, Time-to-first-spike Coding, ANN-to-SNN Conversion, Image Classification, Image Reconstruction, Speech Enhancement
## I Introduction
Over the last decade, we have witnessed tremendous progress in artificial intelligence technologies, that include computer vision [1, 2, 3, 4], speech processing [5, 6], natural language processing [7, 8], and robotics [9, 10]. However, the core computational model behind this revolution, i.e., artificial neural network (ANN), is computationally expensive to operate. This prompts the researchers to improve the computational efficiency of ANNs, for example, through model compression [11, 12], network accelerator [13], and reduction of on-chip data movements [14]. Nevertheless, the high computational cost remains a major roadblock to the deployment of ANNs on power-constrained platforms, such as wearable and mobile devices [15].
The human brains evolve over many millennia under strong ecological pressure to be highly efficient and effective, therefore, it is worthwhile to look into the computation principles adopted by biological neural networks. Motivated by this, the spiking neural networks (SNNs), which were initially introduced to simulate neural computations [16], are now considered a power-efficient alternative to the mainstream ANNs, with a great potential to become the solution for power-constrained platforms.
SNNs, which emulate the information processing mechanism of biological neural networks [17, 18, 19, 20, 21], represent and transmit information through asynchronous action potentials or spikes. Due to the complex spatial-temporal dependency of spike trains and the discontinuity at the spike generation time, the canonical back-propagation (BP) algorithm is not directly applicable to the training of SNNs [22, 23]. The surrogate gradient learning method [24] has been introduced recently to address these problems. It models the spiking neuron as a self-recurrent neural network that explicitly captures the spatial-temporal dependency between input and output spike trains. Furthermore, the continuous surrogate gradient functions are introduced during gradient back-propagation that effectively addresses the discontinuity issue at the spike generation time. Despite much progress on a host of machine learning and neuromorphic benchmarks [25, 26, 27, 28, 29, 30, 31], it is computationally prohibitive to exactly model the temporal dynamics of SNNs due to exorbitant memory requirement, even for a network of less than ten layers [27]. Besides, this method suffers from the vanishing and exploding gradient problem that is notorious for recurrent neural networks, making long-range temporal credit assignments ineffective. A more biologically plausible way entails considering propagating spikes only when the neuron fires spikes, which reduces the overall number of gradient propagations on neuromorphic hardware [32]. Zhu et al. [32] have rigorously proved that event-based propagation allocates gradients from one output spike to its corresponding input spikes, thus preserving the sum of gradients between layers. Armed with this insight, they successfully trained SNNs with temporal gradients on the CIFAR-100 dataset for the first time.
In another vein of research, ANN-to-SNN conversion methods are introduced as an alternative solution to address the difficulties in direct SNN training. A large body of these network conversion methods takes the firing rate of spiking neurons to approximate the activation value of analog neurons used in the ANN, which we refer to as _rate conversion_ in this paper. By carefully determining the firing threshold of spiking neurons or the weight normalization factor, the pre-trained network parameters of ANN can be directly transferred
to the SNN with an equivalent network structure [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]. In this way, we can avoid the expensive spatio-temporal credit assignments in surrogate gradient learning. The rate conversion methods map ANN to SNN with high precision on major machine learning benchmarks, such as ImageNet-12 [43, 48, 49, 50, 51], with a high latency [42] due to the requirement of a large simulation time window. The benefits that rate-based SNNs bring are hence limited.
It has long been identified in the biological neural systems that the precise spike firing time, in addition to the spike firing rate, carries a significant amount of information [52]. Based on these insights, the time-to-first-spike (TTFS) coding scheme was formulated [53, 54, 55, 56], where only one single spike is allowed within each time window as shown in Fig. 1 (a), and a stronger stimulus is transduced into an earlier firing spike. In this way, with a fewer number of spikes, the TTFS coding scheme is expected to be more efficient computationally than rate-based coding.
Embracing the TTFS coding, Rueckauer et al. [42] proposed an ANN-to-SNN conversion algorithm, where the activation value of ANN was treated as the instantaneous firing rate, and subsequently converted to the equivalent spike time in SNN. However, the scalability of this conversion algorithm to deeper network architecture was not demonstrated. The TDSNN [57] algorithm has been proposed to achieve better scalability, which introduces an auxiliary ticking neuron for each operating spiking neuron and a TTFS-like reverse coding scheme. However, the additional spikes generated from auxiliary ticking neurons adversely affect the model efficiency. In contrast, our method uses the same network architecture as the ANN, which does not require any additional neurons or spikes. Recently, the T2FSNN [58] algorithm has been introduced with improved conversion performance on TTFS-based SNNs, while their results still lag behind rate-based SNNs. Moreover, their kernel-based dynamic threshold is considered more computationally expensive on hardware implementation than ours layer-wise dynamic thresholds. Similar to the TDSNN work, Han and Roy [59] proposed a Temporal-Switch-Coding (TSC) scheme and a corresponding TSC spiking neuron model. However, this coding scheme requires two spikes to encode the information of each analog neuron, whereby the information is represented as the time difference between these two spikes. Besides, the introduced TSC neuron model is computationally more expensive than the Integrate-and-Fire neuron model adopted in other works. In what follows, in contrast to the rate conversion introduced earlier, we refer to the ANN-to-SNN conversion based on the TTFS coding as _TTFS conversion_.
In this work, we aim to bridge the accuracy gap between TTFS conversion and rate conversion, thereby fully realizing the computational advantages of SNNs on power-constrained platforms. Toward this goal, we make the following three contributions:
1. We perform a comprehensive analysis on the problems underlying TTFS conversion, including temporal dynamics problem and time-warping problem.
2. We propose a simple yet effective TTFS conversion algorithm that can effectively address all the above problems. As shown in Fig. 1 (c), it establishes a near-perfect mapping between activation values of ANNs and spike times of SNNs, which leads to a near-lossless TTFS conversion.
3. We successfully implement the TTFS conversion algorithm for image classification, image reconstruction, and speech enhancement tasks. To the best of our knowledge, this is the first work that applies TTFS-based SNN in solving challenging signal reconstruction tasks.
The rest of this paper is organized as follows: In Section II, we introduce the research problems to set the stage for our study. In Section III, we present the proposed TTFS conversion algorithm to address the identified problems. In Section IV, we first evaluate the proposed conversion algorithm on the image classification task. Then, we thoroughly evaluate the effectiveness of the proposed algorithm through a series of ablation studies. In Section V, we further evaluate the proposed algorithm on two signal reconstruction tasks, i.e. image reconstruction and speech enhancement. Finally, Section VI concludes the study.
## II Preliminaries and Problem Analysis
We begin by introducing the analog and spiking neuron models, as well as the TTFS coding scheme. We then analyze the problems underlying TTFS conversion.
### _Preliminaries_
#### Ii-A1 Analog neuron model
In ANN-to-SNN conversion, an ANN is first trained, wherein analog neurons are employed and formulated as follows,
\[a_{i}^{l}=f(\sum_{i}^{N}w_{ij}^{l}a_{j}^{l-1}+b_{i}^{l}) \tag{1}\]
where \(a_{j}^{l-1}\) and \(a_{i}^{l}\) are the input and output of neuron \(i\) at layer \(l\), respectively. \(w_{ij}^{l}\) is the synaptic weight between pre-synaptic neuron \(j\) and post-synaptic neuron \(i\), and \(b_{i}^{l}\) is the bias term of neuron \(i\). \(f(\cdot)\) denotes the activation function, for which we use a modified version of the Rectified Linear Unit (ReLU) function. Specifically, we clamp the activation value to be within \([0,1]\), similar to the ReLU6 function [60], and we refer to it as ReLU1 hereafter. As will be explained in the following section, this ensures a one-to-one correspondence can be established between ANN and SNN for lossless TTFS conversion.
#### Ii-A2 Spiking neuron model
For SNN, to be converted from the pre-trained ANN, we employ the Rectified Linear Postsynaptic Potential (Rel-PSP) spiking neuron model proposed in [61], whose membrane potential \(V_{i}^{l}(t)\) can be expressed as
\[V_{i}^{l}(t)=\sum_{j=1}^{N^{l-1}}w_{ij}^{l}K(t-t_{j}^{l-1}) \tag{2}\]
where \(K(\cdot)\) refers to the PSP kernel function, which is defined as
\[K(t-t_{j}^{l-1})=\begin{cases}t-t_{j}^{l-1}&\text{if}\quad t>t_{j}^{l-1}\\ 0&\text{otherwise}\end{cases} \tag{3}\]
For \(t>t_{j}^{l-1}\), Eq. (2) can be further simplified as
\[V_{i}^{l}(t)=\sum_{j=1}^{N^{l-1}}w_{ij}^{l}(t-t_{j}^{l-1}) \tag{4}\]
The neuron \(i\) fires a spike once its membrane potential exceeds the firing threshold \(\vartheta\), whose spike time \(t_{i}^{l}\) is defined as
\[t_{i}^{l}=\mathcal{F}\left\{t|V_{i}^{l}(t)=\vartheta,t\geq 0\right\} \tag{5}\]
The neuronal dynamics of the ReL-PSP spiking neuron model are illustrated in Fig. 1 (b). Without loss of generality, we set the firing threshold \(\vartheta\) to 1 in this work.
#### Ii-A3 TTFS encoding scheme
To encode the first spike time of a ReL-PSP spiking neuron with the activation value of a ReL1U1 neuron, we follow the TTFS encoding scheme. For each layer that with separate time window, as shown in Fig. 1 (a) and (c), we encode the activation value \(a_{i}^{l}\) into the spike time \(t_{i}^{l}\) as per
\[\frac{t_{i}^{l}-t_{min}^{l}}{t_{max}^{l}-t_{min}^{l}}=1-a_{i}^{l} \tag{6}\]
where \(t_{max}^{l}\) and \(t_{min}^{l}\) are the maximum and minimum permissible spike time of SNN layer \(l\). We define the time window \(T^{l}=t_{max}^{l}-t_{min}^{l}\). Without loss of generalizability, we fix this value to be 1 for all layers, i.e., \(T=1\). Hence, we can establish the following encoding function
\[t_{i}^{l}=l+1-a_{i,n}^{l}, \tag{7}\]
### _TTFS Conversion Problems_
#### Ii-B1 Temporal dynamics problem
Following the above TTFS encoding scheme, a larger activation value in the ANN layer shall be encoded into an earlier spike in the corresponding SNN layer, and vice versa. The additional temporal dynamics introduced during the conversion process may, however, give rise to missing spikes and premature spikes. The missing spike problem happens, during ANN-to-SNN conversion, when an analog neuron receives multiple tiny weighted inputs, while their corresponding spikes as a whole are insufficient to trigger an output spike within the given time window. In contrast, the premature spike problem, which has been also described in [42], happens when the positive weighted spikes arrive earlier than the negative ones, causing the actual number of output spikes more than expected.
To better understand the premature spike problem, let's consider a network formed by two input neurons \(A\) and \(B\) that is connected to an output neuron \(C\), with synaptic weights \(w_{CA}=5\) and \(w_{CB}=-10\). As shown in Fig. 2(a), assuming the activation value of analog neurons \(A\) and \(B\) is \(a_{A}=0.8\) and \(a_{B}=0.4\). As these two weighted inputs cancel out each other, the net input received by the neuron \(C\) will be \(0\). According to Eq. (6), the converted spike time of spiking neurons \(A\) and \(B\) are \(t_{A}=0.2\) and \(t_{B}=0.6\). Assuming the firing threshold is \(1\), the earlier input spike from neuron \(A\) will trigger neuron \(C\) to fire a spike at \(t_{C}=0.4\), before receiving the inhibition input from neuron \(B\). In this example, both neurons \(A\) and \(B\) contribute to neuron \(C\) in the ANN, while the contribution of neuron B has been discarded in the SNN due to the additional temporal dynamics introduced after the TTFS conversion.
We refer to both missing spike and premature spike problems as the temporal dynamics problem, which will compound across network layers and may eventually lead to a fatal mismatch between the outputs of ANN and SNN. To eliminate this problem, we propose a dynamic firing threshold mechanism
Fig. 1: (a) Comparison of rate and TTFS coding schemes. (b) Illustration of spiking neuronal dynamics with ReL-PSP kernel function. (c) Illustration of inference pipeline of the TTFS converted SNN, wherein each layer operates in consecutive but non-overlapping time windows. The inset on top shows the data distribution of activation values in an ANN and spike times of the converted SNN. The activation values are mapped to spike times in a one-to-one correspondence following the TTFS encoding scheme.
Fig. 2: Illustration of the premature spike problem. (a) For ANN, the net inputs from neurons A and B are summed to \(0\), causing neuron C to remain inactivated. (b) For SNN, after TTFS conversion, the earlier spike from neuron A will cause neuron C to fire a ‘premature’ spike at \(t_{c}=0.4\), before the arrival of the inhibition input from neuron B.
to ensure spiking neurons in the \(l\)-th layer only fire within the permissible time window \([lt,(l+1)T)\), after all their input spikes are received. This ensures the contributions from pre-synaptic spiking neurons are fully considered by the post-synaptic spiking neuron. The details of this mechanism will be explained in Section III-A.
#### Ii-B2 Time-warping problem
As we already introduced in Section II-A2, the spiking neuron will fire a spike when the membrane potential \(V_{i}^{l}(t)\) reaches the firing threshold \(\vartheta\). According to Eq. (5), the spike time \(t_{i}^{l}\) can be calculated as
\[t_{i}^{l}=\frac{\vartheta+\sum_{j=0}^{N^{l-1}}w_{ij}^{l}t_{j}^{l-1}}{\sum_{j=0 }^{N^{l-1}}w_{ij}^{l}} \tag{8}\]
Following Eq. (6), the activation value \(a_{j}^{l-1}\) of the analog neuron should be encoded into spike time \(t_{j}^{l-1}\) as per
\[t_{j}^{l-1}=l-a_{j}^{l-1} \tag{9}\]
Taking Eq. (9) into Eq. (8), we can establish the following relationship between the activation value \(a_{j}^{l-1}\) and the spike time \(t_{i}^{l}\)
\[t_{i}^{l}=\frac{\vartheta+l\times\sum_{j=0}^{N^{l-1}}w_{ij}^{l}-\sum_{j=0}^{N^ {l-1}}w_{ij}^{l}a_{j}^{l-1}}{\sum_{j=0}^{N^{l-1}}w_{ij}^{l}} \tag{10}\]
According to Eq. (10), the spike time \(t_{i}^{l}\) depends on both weighted inputs \(\sum_{j=0}^{N^{l-1}}w_{ij}^{l}a_{j}^{l-1}\) and weight sum \(\sum_{j=0}^{N^{l-1}}w_{ij}^{l}\). When transferring an activation value \(a_{j}^{l-1}\) from an analog neuron to a spiking neuron, this additional dependency on the weight sum will cause a significant mismatch between the ANN and SNN outputs if not properly addressed. Ideally, identical inputs should produce consistent outputs in \(t_{i}^{l}\). Yet, variations in the weight sum for each neuron \(i\) cause deviations in the output for the same input value. We refer to this problem as the _time-warping problem_. As will be introduced in Section III-B, we propose a weight regularization strategy to ensure the weight sum equals \(1\), thereby eliminating this time-warping problem.
## III LC-TTFS conversion algorithm
### _Solve temporal dynamics problem with dynamic threshold_
As discussed in Section II-B1, the temporal dynamics problem will result in a mismatch between the ANN and SNN outputs. To address this problem, we propose a dynamic firing threshold for spiking neurons. As shown in Fig. 3(a), the dynamic firing threshold \(\vartheta^{l}(t)\) for neurons in the \(l\)-th layer is determined according to the following piecewise linear function
\[\vartheta^{l}(t)=\begin{cases}\infty&\text{if}\quad t<Tl\\ 1&\text{if}\quad t\in[Tl,T(l+1))\\ -\infty&\text{if}\quad t\geq T(l+1)\end{cases} \tag{11}\]
The role of the proposed dynamic firing threshold is to set the spike time outside the permissible time window to the two boundary values. This is equivalent to applying a transformation function \(F^{l}(t)\), defined as in Eq. (12) and illustrated in Fig. 3(b). Following this dynamic firing threshold, the earliest spike time for neurons in the \(l\)-th layer is \(Tl\), and the latest spike should fire before \(T(l+1)\). As such, the time window is non-overlapping for each layer, and spiking neurons at layer \(l\) only start to fire after all input spikes from layer \(l-1\) are being integrated, therefore, overcoming the temporal dynamics problem.
\[F^{l}(t)=\begin{cases}Tl&\text{if}\quad t<Tl\\ t&\text{if}\quad t\in[Tl,T(l+1))\\ T(l+1)&\text{if}\quad t\geq T(l+1)\end{cases} \tag{12}\]
It is worth noting that there are two main differences between our proposed dynamic threshold and the method proposed in [42]. Concretely, 1) the dynamic threshold introduced in [42] depends on the weight of each neuron, resulting in the firing threshold varying from neuron to neuron that will cause significant hardware overhead. In contrast, our method shares one firing threshold for all neurons in the same layer. 2). our
Fig. 3: (a) Illustration of the dynamic firing threshold. (b) Illustration of the effective spike time transformation achieved by the dynamic firing threshold. The x- and y-axis represent the spike time before and after applying the dynamic firing threshold, respectively. (c) Illustration of the ReLU1 activation function used in the ANN. Note that the activation values of analog neurons in (c) can be mapped to spike times in (b) in a one-to-one correspondence, while the order of the mapping is reversed following the TTFS encoding scheme.
method does not require calculating the missing spikes which is computationally expensive.
The dynamic firing threshold ensures that the spiking neurons fire only within their permissible time window. To achieve a lossless conversion from the ANN, the activation value of each ANN layer should also be bounded within a particular interval. To this end, we employ the ReLU1 activation function, which is formulated as follows
\[y(x)=\begin{cases}0&\text{if}\quad x\leq 0\\ x&\text{if}\quad x\in(0,1]\\ 1&\text{if}\quad x>1\end{cases} \tag{13}\]
As shown in Figs. 3(b) and 3(c), with the proposed ReLU1 function, the ANN activation region is one-to-one mapped to the spike time region. The ablation study performed in Section IV-D5 highlights the necessity of this dynamic threshold mechanism toward a lossless TTFS conversion.
### _Solve time-warping problem with weight regularization_
To deal with the time-warping problem introduced in Section II-B2, we proposed a two-step weight regularization strategy to ensure the weight sum in Eq. (10) will take a constant value of 1. In the first step, we impose a soft constraint by penalizing those weight sums that are not equal to 1 with an L1 loss function \(\mathcal{L}_{W}\) that is defined as follows
\[\mathcal{L}_{W}=\sum_{l=0}^{L-1}\sum_{i=0}^{N^{l}}\left|\sum_{j=0}^{N^{l-1}}w_ {ij}^{l}-1\right| \tag{14}\]
As shown in Fig. 4(a), this step drives the overall weight sum distribution towards 1, which can largely alleviate the time-warping problem. However, these seemingly small deviations from the ideal value of 1 will compound across layers and significantly deteriorate the performance of converted SNNs.
To fully resolve the time-warping problem, we further impose a hard constraint by distributing the weight sum deviation evenly across all contributing synapses for each neuron. As shown in Fig. 4(b), by introducing soft and hard constraints during ANN pre-training, we ensure all weight sums are exactly equal to 1. As the soft constraint already drives the weight sum to approach the ideal value, the additional hard constraint has little interference to the learning dynamics and network convergence. This has been confirmed by the ablation study that will be introduced in Section IV-D.
With the time-warping problem resolved, we now can establish the relationship between \(t_{i}^{l}\) and \(a_{i}^{l}\). Considering weight regularization, we obtain
\[t_{i}^{l}=1+l-\sum_{j=0}^{N^{l-1}}w_{ij}^{l}a_{j}^{l-1}, \tag{15}\]
here, \(\sum_{j=0}^{N^{l-1}}w_{ij}^{l}=1\) and \(\vartheta=1\). With the Eqns. (12, 13) and visualization in Fig.3 (b,c), we yield
\[F^{l}(x)=T(l+1)-y(T(l+1)-x). \tag{16}\]
As mentioned in Section II-A3, we adopt \(T=1\) in this work, thereby obtaining
\[F^{l}(x)=l+1-y(l+1-x). \tag{17}\]
Substitute Eqn. (15) into Eqn. (17), we have
\[F^{l}(t_{i}^{l}) =l+1-y(l+1-t_{i}^{l}) \tag{18}\] \[=l+1-y(l+1-1-l+\sum_{j=0}^{N^{l-1}}w_{ij}^{l}a_{j}^{l-1})\] \[=l+1-a_{i}^{l}\]
Since \(F^{l}(t_{i}^{l})=t_{i}^{l}\) holds true within the permissible time window, we ultimately obtain
\[t_{i}^{l}=l+1-a_{i}^{l}, \tag{19}\]
This result is consistent with the encoding scheme for neurons in layer \(l-1\), as depicted by Eqn. (9). However, it introduces a T steps shift to have a non-overlapping window.
### _Pre-activation normalization strategy_
The BN is an important technique to accelerate the deep neural network training, which normalizes the pre-activation of each layer to follow normal distribution so as to mitigate the internal covariate shift problem. We indeed concur that the bias term from an ANN can be transposed into an SNN by injecting a constant input current at the beginning of each applicable time window. This strategy has proven effective in addressing the internal covariate shift issue in many cases [51, 62]. However, in this work, this approach is not directly
Fig. 4: Illustration of weight sum distributions of a randomly selected network layer, trained on the CIFAR-10 dataset, after imposing the (a) soft constraint, and (b) both soft and hard constraints.
applicable to our proposed TTFS conversion method. The reason for this lies in the fact that once the BN parameters are merged with the weight sum constraint inherent in the pre-trained ANN model, the constraint becomes invalidated. Essentially, the preservation of this constraint is crucial for the functionality of our proposed framework.
To compensate for the absence of BN, we propose to normalize the pre-activation distribution of each layer implicitly by introducing a new loss term \(\mathcal{L}_{A}\) as given in Eq. (20). Since we expect the activation values to lie within \((0,1]\) as desired for ReLU1, therefore, we apply an L1 loss to the pre-activation of each layer, encouraging them to fit a normal distribution with zero mean and standard deviation of 1/3, i.e., \(\mathcal{N}(0,1/9)\). This ensures \(99.7\%\) pre-activation values will lie within the interval \([-1,1]\), such that the activation values will mostly lie within \((0,1]\).
\[\mathcal{L}_{A}=\sum_{l=0}^{L-1}\sum_{i=0}^{N^{l}}\left|\sum_{j=0}^{N^{l-1}}w_ {ij}^{l}a_{j}^{l-1}-A_{i}^{l}\right| \tag{20}\]
where \(A_{i}^{l}\) is a vector, wherein entry \(i\) is the normalized form, draw from \(\mathcal{N}(0,1/9)\), of the pre-activation \(\sum_{j=0}^{N^{l-1}}w_{ij}^{l}a_{j}^{l-1}\).
In Fig. 5, we show an example of how the pre-activation normalization strategy effectively drives the distribution of pre-activation values towards a normal distribution of \(\mathcal{N}(0,1/9)\). Without the normalization, the pre-activation values are skewed towards a mean of \(-0.3\). The effectiveness of this strategy in pre-training high-performance ANNs will be further demonstrated in our ablation study introduced in Section IV-D4.
### _Overall LC-TTFS algorithm_
The proposed LC-TTFS conversion algorithm consists of two stages. In the first stage, we pre-train an ANN with the constraints described above, and the overall loss function is defined as follows
\[\mathcal{L}=\mathcal{L}_{ce}+\lambda_{W}\mathcal{L}_{W}+\lambda_{A}\mathcal{L }_{A} \tag{21}\]
where the \(\mathcal{L}_{ce}\) is the cross-entropy loss for classification tasks, \(\mathcal{L}_{W}\) is the weight regularization loss defined in Eq. (14), and \(\mathcal{L}_{A}\) is the pre-activation normalization loss defined in Eq. (20). \(\lambda_{W}\) and \(\lambda_{A}\) are hyperparameters that balance the contribution of each individual loss term. Additionally, the hard constraints are imposed after each weight update to ensure a unity weight sum for all the neurons.
In the second stage, the weights of the pre-trained ANN are directly copied to the SNN to perform inference. We set the threshold of neurons in the last SNN layer to be infinity, such that the decision can be made based on the accumulated membrane potential. By directly mapping the pre-activation of ANN into the neuron membrane potential of SNN, it frees the ANN from applying the activation function in the output layer that deteriorates the pre-training.
## IV Experiments on Image Classification
In this section, we first evaluate the effectiveness of the proposed LC-TTFS conversion algorithm on the image classification task. Then, we perform a comprehensive analysis of the conversion efficacy and computational efficiency of converted SNNs. Finally, we present ablation studies that are designed to validate the effectiveness of each individual component of the proposed algorithm.
### _Experimental Setup_
#### Iv-A1 Datasets
We perform image classification experiments on CIFAR-10 and CIFAR-100 [63] datasets, which are commonly used for benchmarking SNN learning algorithms. The CIFAR-10 dataset consists of 60,000 colored images with a standard dataset split of 45,000, 5,000, and 10,000 for train, validation, and testing. These images are categorized into 10 classes with an image size of 32\(\times\)32\(\times\)3. The CIFAR-100 dataset is an extended version of CIFAR-10, which includes the 32\(\times\)32\(\times\)3 images from 100 classes. We follow the same image pre-processing procedures as outlined in [62].
#### Iv-A2 Implementation details
To facilitate the comparison with other existing works, we adopt VGGNet [64] and ResNet [2]. In particular, we follow the same VGG-11, VGG-16, and ResNet-20 network architectures as described in [49], except that we do not include BN layers. The dropout is applied after every layer except the pooling layers in VGG-11 and VGG-16, whereas it is only applied after the fully connected (FC) layers in ResNet-20. Given the absence of BN layers, it is important to have a proper weight initialization. To this end, we initialize the weights of convolutions layers to the normal distribution \(\mathcal{N}(0,\frac{2}{k^{2}n})\), where \(k\) and \(n\) correspond to the kernel size and the number of output channels at each layer. For FC layers, the weights are initialized to the normal distribution \(\mathcal{N}(0,0.0001)\).
We use the PyTorch library for all experiments, as it supports accelerated and memory-efficient training on multi-GPU machines. We train VGG-11 and VGG-16 for 300 epochs and ResNet-20 for 200 epochs, and we adopt the SGD optimizer with a momentum of \(0.9\) and weight decay of \(0.0005\). We initialize the learning rate at \(0.01\) and decay its value by 10 at 0.6, 0.8, and 0.9 of the total number of epochs. We follow a discrete-time simulation for SNNs, with a time step of 0.02 ms
Fig. 5: Comparison of the pre-activation value distributions with (blue) and without (brown) applying the pre-activation normalization technique proposed in this work. Note that the data distribution approaches a normal distribution of N(0,1/9) after applying the pre-activation normalization. The data is extracted from a randomly selected network layer trained on the CIFAR-10 dataset. It is better to view this figure in color.
and 50 time steps for each layer. We report the classification accuracy on the test set.
### _Experimental Results and Analysis_
#### Iii-B1 Classification Accuracy
Table I reports our experimental results on CIFAR-10 and CIFAR-100 datasets. For the CIFAR-10 dataset, our VGG-11 and ResNet-20 models achieved a SNN model classification accuracy of 91.25% and 92.67%, outperforming all other existing conversion methods. Our VGG-16 model also achieved competitive accuracy to other prior works using the same network structure. The same conclusion can also be drawn from the results of the CIFAR-100 dataset. Our ResNet-20 model achieves an accuracy of 72.36%, which is the best-reported result on this dataset as far as we know. Similarly, our VGG-16 model outperforms other works using temporal coding, which is also competitive to methods based on rate coding.
The efficacy of our algorithm in achieving a lossless TTFS conversion is pronounced when looking at the conversion error. Notably, as shown in the last column of Table I, the conversion errors from the pre-trained ANNs are negligible. To better understand the origin of the conversion errors, we have plotted the activation values of the pre-trained ANN against those mapped back from the spike times of the converted SNN (following the TTFS encoding scheme). As illustrated in Fig. 6, the data distribution of the mapped back activation values closely follows that of the pre-trained ANN, except for the quantization errors arising from the discretized SNN simulation. The effect of such quantization errors is marginal from our experimental results and can be easily addressed by increasing the temporal resolution of SNN.
### _Computational Efficiency_
The TTFS-based SNNs are believed to be computationally more efficient than their rate-based counterparts. To shed light on this point, we follow the practices adopted by Intel [65] and compute the power proxy via the following equations:
\[P_{proxy}=SynOPs+NeuronOPs, \tag{22}\]
where \(SynOPs\) and \(NeuronOPs\) are the total number of synaptic operations and the total number of neuron updates, respectively. As extrapolated from the Loihi architecture [66], the energy weightage of a singular NeuronOPs corresponds approximately to that of around 10 SynOPs. This is due to the NeuronOPs being a multi-bit operation. Importantly, our utilized neuron model, ReLU-PSP, avoids the exponential leaky mechanism present in the LIF model. To update the neuronal state, ReLU-PSP requires only an addition operation at each time step, which is almost equivalent to a SynOPs.
With reference to the configuration specifics reported by Lee et al. [67], we have computed and tabulated the total \(P_{proxy}\) cross our work and that of Diehl et al. [39], and Segupta et al. [48]. As illustrated in Table II, our TTFS conversion algorithm evidently surpasses the energy efficiency metrics of traditional rate-based conversion methods.
### _Ablation Studies_
Here, we present the ablation studies that are designed to validate the necessity and contribution of each individual component in the proposed algorithm. All the experiments are performed on the CIFAR-10 dataset using VGG-11. The experimental results are summarized in Table III with more detailed discussions presented in the following.
#### Iii-D1 Model 1
We began by removing all the constraints that applied to the pre-trained ANN (i.e., soft and hard constraints for the weight sum, ReLU1 activation function, and pre-activation normalization) and the converted SNN (i.e., dynamic firing threshold). As a result, the accuracy of the ANN improved by only 0.03% over the baseline model. It suggests applying the proposed set of constraints has negligible influence on the ANN pre-training. The converted SNN, however, failed to perform the image classification task with the test accuracy dropping to a chance level, indicating it is crucial to apply the proposed set of constraints for a lossless TTFS conversion.
#### Iii-D2 Model 2a and 2b
We further studied the necessity of soft and hard constraints for the weight sum regularization. Dropping the hard constraint while keeping all the rest constraints during the ANN pre-training had minimal impact on the ANN model, whereas the accuracy of the converted SNN dropped by 4.62%. It suggests the hard constraint for weight sum regularization is essential to eliminate the time-warping problem discussed in Section III-B. We further explored dropping both the soft and hard constraints during the ANN pre-training. Interestingly, this allows the ANN model to perform better than the baseline model. However, we noticed that the accuracy of the converted SNN dropped by 62.92%, implying the soft constraint is critical for alleviating the time-warping problem.
#### Iii-D3 Model 3
ReLU1 activation function bounds the activation values within a particular interval, so as to establish a one-to-one correspondence between the ANN and SNN. To understand the contribution of this constraint, we replaced the ReLU1 activation function with a standard ReLU function, while keeping all the rest constraints during the ANN pre-training. Interestingly, compared to the baseline model with
Fig. 6: Comparison of the distribution of activation values of a pre-trained ANN and those mapped back from the spike times of the converted SNN following the TTFS encoding scheme. The data is extracted from a randomly selected network layer trained on the CIFAR-10 dataset.
full constraints, the model using the ReLU function performs slightly worse than the one using the ReLU1 function. This may be explained by the fact that the ReLU1 activation function can indirectly regularize the weight sum and hence lead to easier fulfillment of the weight sum constraint. However, when changed to the ReLU activation function, it results in a severe accuracy drop of 26.43% on the converted SNN. These results indicate the ReLU1 function is imperative to ensure a one-to-one correspondence between the activation value of ANNs and the spike time of SNNs.
#### Iii-B4 Model 4
Similar to Models 2 and 3, we pre-trained the ANN with all constraints except for the pre-activation normalization. This relaxes the pre-activation values from falling into the value range desired by the ReLU1. It, therefore, leads to poorer accuracy in the pre-trained ANN. We notice that the accuracy drop is more significant for networks with more layers (data not shown here), which is due to the internal covariate shift problem discussed in Section III-C. As expected, the absence of the pre-activation normalization technique did not affect the SNN conversion, and it can still achieve comparable accuracy to the pre-trained ANN.
#### Iii-B5 Model 5
Finally, we follow the same ANN pre-training procedures as the baseline model, while during the network conversion, we replaced the dynamic firing threshold with a fixed threshold of \(1\). This modification results in a 13.48% accuracy drop during the network conversion. To further illustrate the effectiveness of applying the dynamic threshold to address the temporal dynamics problem discussed in Section II-B1, we plotted the spike time distribution using the fixed threshold and the proposed dynamic threshold. As shown in Fig. 7 (a), the spike times spread outside their allocated time intervals, and this problem becomes more obvious for deeper layers. Consequently, it leads to a high level of mismatch from the pre-trained ANN. In contrast, with the proposed dynamic threshold, the neurons at different layers only spike in their allocated time interval, i.e., \([Tl,T(l+1))\). This ensures the pre-synaptic spiking neurons fully contribute to their post-synaptic spiking neurons, eliminating the temporal dynamics problem. Although this non-overlapping time window may scarify the synchronized benefit of SNN, we highlight that our goal is to achieve lossless conversion from ANN to SNN using temporal coding without any training in SNN. To this end, the ANN activation and SNN spiking time are needed to be perfectly matched with each other. Therefore, we adopt the proposed synchronized approach to realize this requirement. It is worth noting that the synchronized layer-wise processing is also used in other exciting temporal coding works, such as [57, 58, 68].
\begin{table}
\begin{tabular}{l c c c} \hline \hline Model & Diehl et al. & Segupta et al. & Ours \\ \hline VGG9 & 730.4M & 794M & 117M \\ ResNet9 & 956.4M & 1,226.6M & 107.8M \\ ResNet11 & 854.6M & 796.3M & 144.4M \\ \hline \hline \end{tabular}
\end{table} TABLE II: Comparison of the Total \(P_{proxy}\).
\begin{table}
\begin{tabular}{l l l c c c} \hline \hline
**Dataset** & **Method** & **Network Architecture** & **Neural Coding** & **Acc. (\%)** & \(\Delta\)**Acc. (\%)** \\ \hline \multirow{8}{*}{CIFAR10} & SPIKE-NORM [48] & VGG-16 & Rate & 91.55 & -0.15 \\ & PTL [62] & VGG-11 & Rate & 91.24 & 0.65 \\ & CQ trained SNN [51] & VGG-11 & Rate & 82.09 & -0.05 \\ & CQ trained SNN [51] & VGG-16 & Rate & 92.48 & -0.08 \\ & RMP [43] & VGG-16 & Rate & 93.63 & -0.01 \\ & RMP [43] & ResNet-20 & Rate & 91.36 & -0.11 \\ & Hybrid Training [49] & VGG-16 & Rate & 91.13 & -1.68 \\ & Hybrid Training [49] & ResNet-20 & Rate & 92.22 & -0.93 \\ & T2FNN [58] & VGG-16 & Temporal & 91.43 & - \\ & TSC [59] & VGG-16 & Temporal & 93.63 & -0.01 \\ & TSC [59] & ResNet-20 & Temporal & 91.42 & -0.05 \\ & **Ours** & **VGG-11** & **Temporal** & **91.25** & **-0.05** \\ & **Ours** & **VGG-16** & **Temporal** & **92.72** & **-0.07** \\ \hline \multirow{8}{*}{CIFAR100} & CQ trained SNN [51] & VGG-like & Rate & 71.52 & -0.4 \\ & RMP [43] & VGG-16 & Rate & 70.93 & -0.29 \\ \cline{1-1} & RMP [43] & ResNet-20 & Rate & 67.82 & -0.9 \\ \cline{1-1} & Hybrid Training [49] & VGG-11 & Rate & 67.87 & -3.34 \\ \cline{1-1} & T2FNN [58] & VGG-16 & Temporal & 68.79 & - \\ \cline{1-1} & TSC [59] & VGG-16 & Temporal & 68.18 & 0.25 \\ \cline{1-1} & TSC [59] & ResNet-20 & Temporal & 70.97 & 0.54 \\ \cline{1-1} & **Ours** & **VGG-16** & **Temporal** & **70.15** & **-0.13** \\ \cline{1-1} & **Ours** & **ResNet-20** & **Temporal** & **72.36** & **0.13** \\ \hline \hline \end{tabular}
\end{table} TABLE I: Comparison of the classification accuracy of different SNN models on the CIFAR-10 and CIFAR-100 datasets. Note that Acc. refers to the accuracy of converted SNN, and \(\Delta\) Acc. refers to the difference between the pre-trained ANN and the converted SNN.
## V Experiments on Signal Reconstruction
In the previous section, we demonstrate the effectiveness and scalability of the proposed LC-TTFS conversion algorithm on image classification tasks. Existing TTFS-based learning algorithms often employ methods that achieve TTFS-based learning by either dropping or masking subsequent spikes after the first one during the training phase. Moreover, while there are gradient-based direct training algorithms cited in [45, 48], they have manifested convergence challenges, especially concerning deep neural networks. Although these methods might prove efficient for classification tasks, their efficacy diminishes notably when deployed for signal reconstruction tasks. In contrast, our proposed method adopts a conversion-based approach. This approach fundamentally eradicates the convergence issue and paves the way for establishing a direct and lossless mapping from the ANN. This ensures that information integrity remains uncompromised throughout the process. Performing TTFS encoding at each layer, allows us to preserve the information across the network and opens up the opportunity to perform signal reconstruction tasks with TTFS-based SNNs. In this section, we demonstrate the applicability and superior learning capability of the proposed LC-TTFS algorithm on two signal reconstruction tasks: image reconstruction and speech enhancement tasks.
### _Image Reconstruction with Autoencoder_
Here, we first demonstrate the applicability of our algorithm to image reconstruction tasks with an autoencoder network. The autoencoder is a typical neural network that is used to learn compact latent representations of input signals via a bottleneck layer that has a reduced latent dimension. From this compact latent representation, the autoencoder then reconstructs the original input signals as accurately as possible [69].
#### V-A1 Experimental Setup
The experiments on image reconstruction are performed using the MNIST dataset [70]. Following the approach from [62], we use a fully-connected autoencoder with a 784-128-64-32-64-128-784 architecture and train it to minimize the MSE between the original input and the reconstructed output signal.
The initial model was pre-trained as an ANN before being converted into a TTFS-based SNN using our proposed algorithm. We utilized the SGD optimizer for pre-training, with a cosine annealing learning rate schedule [71]. The output from spiking neurons was processed through a sigmoid function to generate the reconstructed image.
Evaluation of our model was carried out using two commonly used image quality metrics, PSNR and SSIM, both of which provided insight into the quality of reconstructed images. We provide the results of these evaluations on the test set.
#### V-A2 Result and Analysis
Table IV summarises the results of on the image reconstruction task. Our TTFS-based SNN model achieves a comparable performance to the ANN-based counterpart in terms of the PSRN and SSIM metrics. In addition, the qualitative results shown in Fig. 8 demonstrate the TTFS-based SNN model can effectively reconstruct the
\begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Model** & **Soft** & **Hard** & **ReLU1** & **Norm** & **Dynamic** & **ANN (Acc.\%)** & **SNN (Acc.\%)** & \(\Delta\)**Acc.\%** \\ \hline Baseline & ✓ & ✓ & ✓ & ✓ & ✓ & 91.30 & 91.25 & 0.05 \\
1 & ✗ & ✗ & ✗ & ✗ & ✗ & 91.33 & 10.00 & 81.33 \\
2a & ✓ & ✗ & ✓ & ✓ & ✓ & 91.57 & 86.95 & 4.62 \\
2b & ✗ & ✗ & ✓ & ✓ & ✓ & 92.10 & 29.18 & 62.92 \\
3 & ✓ & ✓ & ✗ & ✓ & ✓ & 90.87 & 64.44 & 26.43 \\
4 & ✓ & ✓ & ✓ & ✗ & ✓ & 89.60 & 89.67 & -0.07 \\
5 & ✓ & ✓ & ✓ & ✓ & ✗ & 91.30 & 77.82 & 13.48 \\ \hline \hline \end{tabular}
\end{table} TABLE III: Summary of the result of ablation studies. Note that \(\Delta\) Acc. refers to the difference between the pre-trained ANNs and the converted SNNs given in columns 7 and 8, respectively. **Soft**: soft constraint for weight sum; **Hard**: hard constraint for weight sum; **ReLU1**: ReLU1 activation function; **Dynamic**: dynamic firing threshold; **Norm**: pre-activation normalization.
Fig. 7: Illustration of spike timing distribution of SNN models (a) with a fixed firing threshold and (b) with a dynamic firing threshold.
images with high quality. Altogether, these results suggest the proposed conversion algorithm is highly effective for the image reconstruction task.
By representing information using spike times, the TTFS-based SNN is expected to greatly improve the energy efficiency over the rate-based counterparts. Following the same evaluation metrics introduced in Section IV-C, we report the energy proxy in Table IV. As shown, the energy efficiency of our TTFS-based model remains competitive with a high-optimized rate-based SNN reported in [62].
### _Time-domain Speech Enhancement_
Speech enhancement, which improves the intelligibility and quality of noisy speech signals [66], has proven its importance in a vast amount of applications, including voice-based communication, hearing aids, speech recognition, and speaker identification [72, 73, 74, 75, 76]. Conventional speech enhancement methods are typically based on statistical models that estimate the data distribution of clean and noise signals, such as spectral subtraction [77] and Wiener filter [78]. However, these methods have shown limited improvements in speech quality under real-world scenarios. Recently, the ANN-based speech enhancement models have greatly improved the speech quality and intelligibility under complex acoustic environments [79, 80, 81, 82, 83]. Given a huge demand for speech enhancement technologies on mobile and IoT devices that have a limited power budget, it is, therefore, beneficial to develop power-efficient SNN-based speech enhancement models.
Speech enhancement can be considered as separating the human voice from the background noise. Inspired by the recent success of the time-domain speech separation model ConvTasNet [84], we proposed a TTFS-based speech enhancement model. As illustrated in Fig. 9(a), the proposed speech enhancement model takes the noisy speech waveform as input and outputs an enhanced speech waveform. This model consists of three parts: an encoder, an enhancement module, and a decoder. The **encoder** transforms the noisy speech waveform \(x(t)\) into a high-dimensional feature representation, namely embedding coefficients, using a 1D convolutional layer. The 1D convolutional layer contains \(N(=128)\) filters, and each filter is configured to have a time window of \(L(=20)\) and a stride of \(L/2(=10)\) samples. For each time window, the **enhancement module** estimates a mask, using a stack of dilated convolutional layers, to separate the noise from the human voice. A \(1\times 1\) convolution layer is first applied to normalize the encoded feature representation, and the dilated convolution layers with the filter of 128, kernel size of \(1\times 3\), and stride of \(1\) are repeated \(10\) times with doubled dilation rate of \([1,2,4,...,512]\). The mask for human voices is then estimated by applying another \(1\times 1\) convolution layer. Subsequently, the feature representation of the enhanced speech is obtained by masking the background noise with the estimated mask. Finally, the **decoder** reconstructs a high-quality speech waveform \(y(t)\) from the masked feature representation using a 1D deconvolutional layer, which takes a reverse operation to the 1D convolutional layer in the encoder.
Following the ConvTasNet, we train the proposed SNN-based speech enhancement model to minimize the multi-scale scale-invariant signal-to-distortion ratio (SI-SDR) [85] loss, which is defined as:
\[\mathcal{L}_{SI-SDR}=-10log_{10}\bigg{(}\frac{\|\frac{\langle s,s\rangle}{ \langle s,s\rangle}s\|^{2}}{\|\frac{\langle\hat{s},s\rangle}{\langle s,s \rangle}s-\hat{s}\|^{2}}\bigg{)} \tag{23}\]
where \(\hat{s}\) and \(s\) are enhanced and reference clean speech signals, respectively. We normalize these two signals to zero means to ensure scale invariance.
#### Iv-B1 Experimental Setup
To test our speech enhancement model, we employed a widely recognized dataset by Valentini et al. [86]. This dataset includes clean utterances from the Voice Bank corpus [87] and its noisy version created by combining clean utterances with environmental noise samples. The training set comprises 11,572 utterances mixed with ten types of noise at four different SNRs: 15 dB, 10 dB, 5 dB, and 0 dB. The test set contains 824 distinct utterances blended with five additional noise types at four SNRs: 17.5 dB, 12.5 dB, 7.5 dB, and 2.5 dB. Following the precedent set by SEGAN [79] and CNN-GAN [80], we reduced the original sampling rate to 16 kHz, without additional pre-processing.
Using the LC-TTFS algorithm, we pre-trained the ANN-based speech enhancement model for 100 epochs, utilizing an early stopping scheme and an Adam optimizer. The model was then converted into an SNN-based module, employing the membrane potential in the \(1\times 1\) spiking convolution layers.
We evaluate the speech enhancement models using the following standard metrics, which are available on the publisher's
\begin{table}
\begin{tabular}{l l c c c} \hline \hline
**Model** & **Coding** & **PSNR** & **SSIM** & **Energy Proxy** \\ \hline SNN [62] & Rate & 20.74 & 0.84 & 715.8K \\
**ANN (ours)** & - & 20.90 & 0.917 & - \\
**SNN (ours)** & Temporal & 20.83 & 0.916 & 581.2K \\ \hline \hline \end{tabular}
\end{table} TABLE IV: Comparison of the results of different methods on the image reconstruction task.
Fig. 8: Comparison of the original and the reconstructed images from our TTFS-based autoencoder. For each image pair, the left one is the original image, and the right one is the reconstructed image.
website1.
Footnote 1: [https://www.rcpress.com/downloads/K14513/K14513_CD_Files.zip](https://www.rcpress.com/downloads/K14513/K14513_CD_Files.zip)
1. PESQ: Perceptual evaluation of speech quality. The wide-band version recommended by ITU-T P.862.2 standard [88] is used in this work.
2. CSIG: Mean option score (MOS) prediction of the signal distortion attending only to the speech signal [89].
3. CBAK: MOS prediction of the intrusiveness of background noise [89].
4. COVID: MOS prediction of the overall effect [89].
All metrics are calculated by comparing the enhanced speech to the clean reference speech, we report the average values for all 824 utterances in the test set.
#### V-B2 Result and Analysis
Table V compares the results of our ANN- and SNN-based speech enhancement models with other existing works using the four evaluation metrics introduced earlier. Our ANN-based model outperforms other existing methods across all the evaluation metrics, suggesting the effectiveness of the proposed model architecture. Moreover, the TTFS-based SNN model achieved comparable performance to the pre-trained ANN model, demonstrating the capability of the proposed TTFS conversion algorithm in solving the challenging speech enhancement task.
We also performed subjective evaluation by listening to the enhanced speech signals generated by both the ANN- and SNN-based speech enhancement models. We find the SNN-enhanced speech samples are nearly indistinguishable from those high-quality ones generated by the ANN model. We publish some enhanced speech examples from the test set online to demonstrate our model performance2. In addition, we select a random speech sample from the test set and plot the power spectrum for the corresponding noisy, clean, ANN- and SNN-enhanced speech waveforms as shown in Fig. 9(b). It is clear that the SNN-enhanced speech spectrum exhibits a high level of similarity to the ANN-enhanced one, and both of them are very close to the ground truth clean speech spectrum. These results again highlight the effectiveness of the proposed model architecture and the TTFS conversion algorithm.
Footnote 2: The listening examples are available online at [https://drive.google.com/file/d/1g5OCATyH1B3U5z_x6qDZam8bMcmElxR/view?usp=sharing](https://drive.google.com/file/d/1g5OCATyH1B3U5z_x6qDZam8bMcmElxR/view?usp=sharing)
## VI Discussion and Conclusion
In this work, we identify and thoroughly investigate two major problems underlying the effective TTFS conversion, namely the temporal dynamics problem and time-warping problem. Based on this study, we further propose a novel TTFS conversion algorithm to address these problems, namely LC-TTFS. Firstly, to tackle the temporal dynamics problem, we introduce a dynamic firing threshold mechanism for spiking neurons that only allows neurons to fire within the allocated time window. In this way, the causal relationship between the input and output neurons is maintained throughout the network layers. Secondly, we apply a set of well-designed loss functions during the ANN pre-training to eliminate the
\begin{table}
\begin{tabular}{l c c c c} \hline \hline Model & PESQ & CSIG & CBAK & COVID \\ \hline Noisy & 1.97 & 3.35 & 2.44 & 2.63 \\ Wiener [79] & 2.22 & 3.23 & 2.68 & 2.67 \\ SEGAN [79] & 2.16 & 3.48 & 2.94 & 2.80 \\ CNN-GAN [80] & 2.34 & 3.55 & 2.95 & 2.92 \\
**ANN (Ours)** & **2.36** & **3.63** & **3.03** & **2.98** \\
**SNN (Ours)** & **2.35** & **3.64** & **3.01** & **2.98** \\ \hline \hline \end{tabular}
\end{table} TABLE V: Comparison of the experimental results of different speech enhancement models. The results are higher the better.
Fig. 9: (a) SNN-based speech enhancement network architecture. (b) From top to bottom: the power spectrum of noisy, clean, ANN-enhanced, and SNN-enhanced speech waveforms.
time-warping problem. Finally, we apply the pre-activation normalization technique during the ANN pre-training to alleviate the internal covariate shift problem due to lack of BN layer. With these problems being well addressed, we establish a near-perfect mapping, apart from the marginal discretization error in the SNN simulation, between the ANN activation values and the SNN spike times, leading to a near-lossless TTFS conversion. This also enables us to go beyond the commonly considered classification tasks and opens up a new avenue for solving high-fidelity signal reconstruction tasks with TTFS-based SNNs.
The SNNs thus converted have demonstrated superior classification and signal reconstruction capabilities on image classification, image reconstruction, and challenging speech enhancement tasks. By representing information using spike times, instead of firing rates, we show TTFS-based SNNs can significantly improve the computational efficiency over both ANN and rate-based SNNs. By avoiding costly and ineffective direct SNN training, the proposed algorithm, therefore, opens up myriad opportunities for deploying efficient TTFS-based SNNs on power-constrained edge computing platforms. The carefully designed ablation studies on each individual component of the proposed algorithm highlight the necessity and synergy of these algorithmic components in achieving a near-lossless TTFS conversion. We would like to acknowledge that the proposed TTFS-based SNN requires a separate and non-overlapping time window for each layer, which adversely affects the inference speed. Therefore, we are interested in studying whether a perfect mapping can still be achieved under a shared time window to improve the inference speed, and we leave this as future work.
|
2307.01004 | Joint Coordinate Regression and Association For Multi-Person Pose
Estimation, A Pure Neural Network Approach | We introduce a novel one-stage end-to-end multi-person 2D pose estimation
algorithm, known as Joint Coordinate Regression and Association (JCRA), that
produces human pose joints and associations without requiring any
post-processing. The proposed algorithm is fast, accurate, effective, and
simple. The one-stage end-to-end network architecture significantly improves
the inference speed of JCRA. Meanwhile, we devised a symmetric network
structure for both the encoder and decoder, which ensures high accuracy in
identifying keypoints. It follows an architecture that directly outputs part
positions via a transformer network, resulting in a significant improvement in
performance. Extensive experiments on the MS COCO and CrowdPose benchmarks
demonstrate that JCRA outperforms state-of-the-art approaches in both accuracy
and efficiency. Moreover, JCRA demonstrates 69.2 mAP and is 78\% faster at
inference acceleration than previous state-of-the-art bottom-up algorithms. The
code for this algorithm will be publicly available. | Dongyang Yu, Yunshi Xie, Wangpeng An, Li Zhang, Yufeng Yao | 2023-07-03T13:40:20Z | http://arxiv.org/abs/2307.01004v2 | Joint Coordinate Regression and Association For Multi-Person Pose Estimation, A Pure Neural Network Approach
###### Abstract
We introduce a novel one-stage end-to-end multi-person 2D pose estimation algorithm, known as Joint Coordinate Regression and Association (JCRA), that produces human pose joints and associations without requiring any post-processing. The proposed algorithm is fast, accurate, effective, and simple. The one-stage end-to-end network architecture significantly improves the inference speed of JCRA. Meanwhile, we devised a symmetric network structure for both the encoder and decoder, which ensures high accuracy in identifying keypoints. It follows an architecture that directly outputs part positions via a transformer network, resulting in a significant improvement in performance. Extensive experiments on the MS COCO and CrowdPose benchmarks demonstrate that JCRA outperforms state-of-the-art approaches in both accuracy and efficiency. Moreover, JCRA demonstrates 69.2 mAP and is 78% faster at inference acceleration than previous state-of-the-art bottom-up algorithms. The code for this algorithm will be publicly available.
## 1 Introduction
One of the fundamental and compelling computer vision tasks is human pose estimation (HPE), and this task has attracted intense attention in recent years. With the increase of computing power, algorithms with higher accuracy and faster computing speed are emerging. Compared with single-person pose estimation, the multi-person pose estimation(MHPE) is more complex as it aims to detect all the instances and identify joints of each person. The importance of MHPE mainly comes from a large set of application [1, 8, 36] based on it, i.e., human behaviors understanding, motion capture, violence detection, pedestrian tracking, crowd riot scene identification, human-computer interaction, and autonomous driving, et. al
In order to solve MHPE task, there are two mainstream methods exists with two-stage frameworks: top-down [2, 10, 45, 32, 41] and bottom-up [43, 43, 12, 16, 17] approaches. the top-down paradigm takes two stages, the first is to detect human bounding boxes and then perform single person pose estimation for each bounding box. For the human detection stage, top-down algorithms are more accurate as the algorithm transformed the problem into a single-person-pose estimation problem by utilizing the object detection algorithm to find each person. However, the computational cost is large and expensive, As the number of human instances in images increases. The pose estimation accuracy depends heavily on the performance of the detection network. As a result, most real-world applications are based on bottom-up algorithms.
The other branch is bottom-up, which first locates identity-free keypoints and then group them into different person.The grouping process is usually heuristic,hand-crafted and tedious, with lots of tricks to adjust hyper-parameters and this work may cost a lot of manpower.
In order to overcome the shortcomings of the above two methods, a new method has recently been proposed, which directly estimates multi-person poses from the input image in one single stage [30, 34, 38, 39, 40, 42, 43]. FCpose [30] and InsPose [39] propose a fully convolutional multi-person pose estimation framework which is efficient with the dynamic instance-aware convolutions. SPM [34] proposes a structured pose representation that makes person instance and body joint position representation to be a whole unit.
Inspired by recent work on end-to-end trainable object detection using Transformer, POET [40] proposed an end-to-end trainable approach for MHPE, Combining a convolutional neural network with a transformer encoder-decoder architecture, POET formulate multi-instance pose estimation from images as a direct set prediction prob
lem. PETR [38] describes an end-to-end paradigm with one-stage Transformer framework, in PETR multi-person pose queries are learned to directly reason a set of full-body poses.First pose decoder predicts multi full-body poses in parallel, Then a joint decoder is utilized to further refine the poses by exploring the kinematic relations between body joints. This end-to-end framework removes some post-processing like RoI cropping, NMS, and grouping.
The aforementioned end-to-end methods achieve a good trade-off between accuracy and efficiency despite they don't need the extra RoI (Region of Interest) cropping and keypoints grouping post-progressing. However, heatmap [34, 56] or score map [30, 39] or NMS (Non-Maximum Suppression) [30, 43, 39] and decoder data fusion [38] post-progressing are need although, which are not really end-to-end optimized MHPE. To simplify the pipeline further, i.e. remove the postprocessing part and concentrate all operations on neural networks, We propose a novel JCRA for human pose estimation, which deals with the aforementioned problem effectively. The JCRA makes full use of the transformer's advantage allowing for estimating keypoint directly and accurately without heatmaps. The final network realizes a notable performance enhancement compared to start-of-the-art results on the COCO val2017 dataset [26]. The main contributions of this paper are:
* We propose a real end-to-end learning framework for MHPE named JCRA. The proposed JCRA method directly predicts full-body pose without any post-processing.
* JCRA surpasses all end-to-end methods and has obtained a very close score in large-scale MHPE tasks compared with top-down methods.
* JCRA predicts the multi-person pose of each individual in the image and video very fast with the highest accuracy. Compared with the current end-to-end State-Of-The-Art algorithm PETR [38], JCRA's inference speed is almost increased by 2 times.
## 2 Related Works
The pose estimation has developed from CNNs [47] to vision transformer networks. Early works applied transformers as a better decoder [20, 23, 50], e.g., TransPose [50] directly processes the features extracted by CNNs to model the global relationship. TokenPose [23] proposes token-based representations by introducing extra tokens to estimate the locations of occluded keypoints and model the relationship among different keypoints. To get rid of the CNNs for feature extraction, HRFormer [53] is proposed to
Figure 1: Overview of (a) top-down, (b) bottom-up, (c) two-stage end-to-end methods and (d) one sate end-to-end methods. The last row show the overview of our Joint Coordinate Regression and Association (JCRA) algorithm. JCRA is a one-stage end-to-end method.
use transformers to extract high-resolution features directly. A delicate parallel transformer module is proposed to fuse multi-resolution features in HRFormer gradually. These transformer-based pose estimation methods obtain superior performance on popular keypoint estimation benchmarks. In Fig. 1, The pose estimation work branched out bottom-up, top-down and recent two-stage end-to-end methods.
### Top-down MHPE methods
Two stages are involved in a top-down pose estimation algorithm: detecting human bounding boxes and then estimating a single person's pose for each bounding box. The typical top-down algorithm includes Hourglass [32], RMPE [11], CPN [6], SimpleBaseline [47], HRNet [41], which detect the keypoints of a single person within a person bounding box. The person bounding boxes are usually generated by an object detector [37]. Mask R-CNN [14] directly adds a keypoint detection branch on Faster R-CNN [37] and reuses features after ROIAlign. All the aforementioned algorithms utilized heatmaps to encode and decode keypoints, an following those algorithms, Simcc [22] applied direct regression of the coordinates of the key points by the negative log-likelihood loss function. In short, Top-down methods are accurate but highly dependent on the detector's performance, and incorporating a personal detector would cost more running time.
### Bottom-up MHPE alogirhtms
The pose estimation usually contains key points detection and associations, most works performed the procedure independently until Openpose [3], Which learning the fittest association of joints, regardless of the number of people in the image, which is an effective non-parametric representation. In addition, this method is bottom-up and consists of only one stage so that the pose can be served in real time. Later, associative embedding [31] method were proposed, where the network outputs the detection and grouping simultaneously. Those papers remarks on the transition from two-stage pose estimation to a single stage.
The stacked hourglass network [33] plays a key role, where the features of different scales can be combined and consolidated to get the relevant spatial connections associated with the body part. The symmetric architecture results in an improvement in both performance and efficiency. Our network design is enlightened by the stacked hourglass network to some degree.
### End-to-end MHPE methods
The top-down and bottom-up methods are two polar of the solutions, in order to balance them, the single-stage methods [38, 39, 40, 30, 43, 34] are proposed, which densely regress a set of pose candidates over spatial locations, where each candidate consists of the keypoint positions that are from the same person. POET [40] proposed an end-to-end trainable approach for MHPE, which combines a convolutional neural network with a transformer encoder-decoder architecture, POET formulates multi-instance pose estimation from images as a direct set prediction problem. PETR [38] describes an end-to-end paradigm with one-stage Transformer framework, in PETR multi-person pose queries are learned to directly reason a set of full-body poses. Followed by a pose decoder that predicts multi full-body poses in parallel, Then a joint decoder is utilized to further refine the poses by exploring the kinematic relations between body joints. This end-to-end framework removes some post-processing like part RoI cropping, pose-NMS, and grouping.
The transformer [5] based approaches are the new trend as researchers are exploring attention mechanisms for human pose estimation. The transformer is an architecture of encoder-decoder, the encoder-decoder framework in general refers to a situation in which one process represents, or "encodes" input data into one vector, and then another process "decodes" that vector into the desired output. In order for the decoder to be able to use all of the hidden states, this matrix needs to be condensed into a vector of consistent size - we cannot pass a hidden state into the decoder whose size varies based on the number of elements in the source sequence. Consequently, attention was born.
\[\text{Attention}(Q^{\prime},K^{\prime},V^{\prime})=\text{softmax}(\frac{Q^{ \prime}K^{\prime T}}{\sqrt{d_{k}}})V^{\prime} \tag{1}\]
Where \(\in\mathbb{R}^{m\times d_{model}}\), \(K\in\mathbb{R}^{n\times d_{model}}\) and \(V\in\mathbb{R}^{n\times d_{model}}\).
Motivated by [55] Transformers have been applied to the pose estimation task with some success. TransPose [51] and HRFormer [54] enhance the backbone via applying the Transformer encoder to the backbone; TokenPose [24] designs the pose estimation network in a ViT-style fashion by splitting image into patches and applying class tokens, which makes the pose estimation more explainable. These methods are all heatmap-based and use a heavy transformer encoder to improve the model capacity. In contrast, Poseur [29] is a regression-based method with a lightweight transformer decoder. Thus, Poseur is more computationally efficient while can still achieve high performance. PRTR [21] leverages the encoder-decoder structure in transformers to perform pose regression. PRTR is based on DETR [5], i.e., it uses Hungarian matching strategy to find a bipartite matching between non-class-specific queries and ground-truth joints.
Early works tend to treat the transformer as a better decoder [21, 24, 51], e.g., TransPose [51] directly processes the features extracted by CNNs to model the global relationship. TokenPose [24] proposes token-based representations by introducing extra tokens to estimate the locations of occluded keypoints and model the relationship among
different keypoints. To get rid of the CNNs for feature extraction, HRFormer [54] is proposed to use transformers to extract high-resolution features directly. A delicate parallel transformer module is proposed to fuse multi-resolution features in HRFormer gradually. These transformer-based pose estimation methods obtain superior performance on popular keypoint estimation benchmarks. However, they either need CNNs for feature extraction or require careful designs of the transformer structures. ViTPose [48] explored the plain vision transformers for the pose estimation tasks. PETR [38] adapted DETR [5] by directly output person key points, bounding box, and person probability. logocap [49] learning the local-global contextual adaptation for bottom-up human pose estimation.
## 3 Algorithm
### The Motivation
Multi-person pose estimation has gained great progress in recent years [3, 9, 22, 31, 35, 44, 52], which can be categorized as keypoints detection and association briefly. Complex transformations are applied in either top-down or bottom-top algorithms, i.e. the representation and decode of the heatmaps in order to estimate keypoint location accurately, the representations of the keypoint associations like part affinity field [3] and associative embedding [31]. Most of the complexity is comes from post-processing, which solved by non-trivial methods. Simplifying the whole pipeline would be valuable to the community.
### Joint Coordinate Regression and Association (JCRA)
The proposed Joint Coordinate Regression and Association can output keypoint coordinates directly without heatmaps, and the association of those keypoints by the query of the transformer. The proposed algorithm is one-stage end-to-end, all operations are performed by neural networks, we illustrated the architecture of our method in Fig. 2.
### Backbone
A Resnet50 [15] is applied to extract features of the image, followed by feature pyramid networks to extract multi-level feature maps. Flattened image features are fed into the keypoint encoder and refined. In order to demonstrate the effectiveness and robustness of JCRA, we used the ResNet50 backbone on the Coco dataset, and the SwinL backbone on the CrowdPose dataset.
### Keypoint Encoder
The keypoint encoder is applied to refine the multi-scale feature maps. Before passing flattened image features to the keypoint encoder, positional encoding is added. A feed-forward network (FFN) and a multi-scale deformable attention [46] module are present in each encoder layer. In keypoint encoder, \(6\) deformable encoder layers are stacked in sequence.
### Pose Decoder
In a similar way to the keypoint encoder, we use the deformable attention module to build the keypoint decoder.
Figure 2: Overview of Joint Coordinate Regression and Association (JCRA) algorithm
The keypoint decoder predicts \(300\) full-body keypoints in parallel based on the \(300\) keypoint queries and the refined multi-scale feature tokens. The \(300\) keypoint queries are transformed into an output embedding by the decoder. They are then independently decoded into key points and scores by a feed-forward network (FFN), resulting in \(300\) final predictions. The shape of the final tensor is \(300\)x17x3. The \(17\) is the number of keypoints in COCO dataset, while \(3\) is (x,y,confidence) of each keypoint, (x,y) is the coordinate of keypoint.
### Loss Functions
In accordance with [5], we employ a set-based Hungarian loss, ensuring a distinct prediction for each ground-truth pose. Our pose decoder's classification head utilizes the same classification loss function (\(L_{c}\)) as in [57]. \(L_{c}\) is the focal loss function [25] for the classification branch. Additionally, we incorporate \(L_{1}\) loss (\(L_{reg}\)) and OKS loss (\(L_{oks}\)) for pose regression heads in our pose decoder, respectively. Analogous to [39], we employ auxiliary heatmap regression training for rapid convergence. We employ a deformable transformer encoder to generate heatmap predictions. Subsequently, we calculate a variant of focal loss [18] between the predicted and ground-truth heatmaps, denoted as \(L_{hm}\). The comprehensive loss function of our model can be expressed as:
\[\text{L}=L_{c}++\lambda_{1}L_{hm}+\lambda_{2}L_{reg}+\lambda_{3}L_{oks} \tag{2}\]
The loss weights are denoted by \(\lambda_{1}\), \(\lambda_{2}\), and \(\lambda_{3}\).
### One-stage Vs Two-stage End-to-end Framework
In Table 1, we compare JCRA with other frameworks for pose estimation. JCRA represents a comprehensive, one-stage end-to-end framework. The one-stage end-to-end framework for human posture estimation offers advantages such as high efficiency, enhanced accuracy, and robust performance. By integrating multiple processing stages, this approach minimizes computational time and resource demands, enabling real-time processing. The one-stage end-to-end framework has exhibited considerable speed advantages in both model training and model inference.
The two-stage end-to-end framework, similar to PETR [38], comprises two decoders: the primary decoder and the refinement decoder. The refinement decoder serves to enhance the detection accuracy of key points. As observed in Table 4, PETR [38] demonstrates a superior keypoint detection capability for challenging samples compared to JCRA. Nonetheless, for large and medium-sized targets, JCRA attains greater accuracy. Analogous occurrences were also observed in the COCO validation and COCO test datasets. We concluded that the one-stage end-to-end framework excels in detecting keypoints for large and medium-sized targets. Conversely, the two-stage end-to-end framework, incorporating a refinement decoder, exhibits an improvement in keypoint detection capabilities for difficult targets.
### Symmetrical Network Architecture
Symmetry in the design, characterized by an equal number of layers in both the encoder and decoder, guarantees that each level of abstraction in the encoder corresponds to a level in the decoder, facilitating the translation of abstractions back into more concrete forms.
The JCRA employs an approximately symmetric network architecture, consisting of six encoder layers and five decoder layers. The advantages of a symmetric encoder and decoder include: A reduction in information loss during the encoding and decoding processes, leading to enhanced reconstruction quality of the output. A more balanced model that effectively captures pertinent features of the input data during both encoding and decoding. The model can acquire more comprehensive and stable representations of the input data that exhibit a high tolerance towards variations and noise. Owing to its symmetric network architecture, the JCRA attains a 69.2 mAP without necessitating keypoint refinement. When the number of layers in the encoder and decoder networks is proximate, higher accuracy can be achieved, as illustrated in Fig. 4.
## 4 Experimental Results
### COCO Keypoint Detection
We perform a thorough comparison of the improvement of JCRA to state-of-the-art algorithms in human pose estimation, and the experiment datasets used for evaluation are COCO [26], which consists of about \(200K\) images and contain around \(250K\) people with annotated key points, the dataset contains diverse scenarios such as scale variation, different camera views, and occlusion in the image. We employed the val2017 dataset, which comprises 5,000 images, to validate our ablation experiments. In addition, we compared our method to other state-of-the-art approaches on the test-dev set that contains 20,000 images.
**Evaluation metrics.** The standard evaluation metric is based on Object keypoint Similarity (OKS). We report standard average precision and recall scores1: \(AP_{50}^{kp}\) (\(AP^{kp}\) at
\begin{table}
\begin{tabular}{l|c|c|c|c} \hline
**Frameworks** & **Rol-free** & **Grouping-free** & **NMS-free** & **Refine-free** \\ \hline Top-down & & ✓ & & \\ Bottom-up & ✓ & & & \\ \hline Non end-to-end & ✓ & ✓ & & \\ Two-stage end-to-end & ✓ & ✓ & ✓ & ✓ \\ One-stage end-to-end & ✓ & ✓ & ✓ & ✓ \\ \hline \end{tabular}
\end{table}
Table 1: Comparison of pose estimation frameworks
OKS = 0.50), \(AP^{kp}_{75}\), \(AP^{kp}\) (mean of AP scores from OKS = 0.50 to OKS = 0.95 with the increment as 0.05), \(AP^{kp}_{M}\) for persons of medium sizes and \(AP^{kp}_{L}\) for persons of large sizes.
### Results on the COCO val2017 dataset
We compare JCRA to the state-of-the-art methods in pose estimation in Table 2. Our method achieves best performance among all bottom-up algorithms, and comparable performance with top-down human pose estimation algorithms, The compared algorithms include CMU-Pose [3] and Mask R-CNN [14], PETR [38] and Simcc [22], VitPose [48], the state-of-the-art top-down pose estimation algorithm, respectively. Visualization outputs by JCRA are presented in Fig. 3. The network makes competitive results even in the condition that large overlaps or congestion exist among multiple people.
Table 2 shows that our result (69.2 AP) is \(0.58\%\) higher than the latest PETR [38] for two-stage end-to-end methods. Our method is much simple and more effective. Our algorithm even suppressed top-down methods regarding the \(AP^{kp}_{L}\) metric.
### Results on the COCO test-dev
Initially, we compared our Joint Coordinate Regression and Association (JCRA) with other state-of-the-art methods, as presented in Table 3. Utilizing the same back
\begin{table}
\begin{tabular}{c|c|c c c|c|c|c} \hline Method & Backbone & \(AP^{kp}\) & \(AP^{kp}_{\text{so}}\) & \(AP^{kp}_{T}\) & \(AP^{kp}_{M}\) & \(AP^{kp}_{L}\) & Speed(fps) \\ \hline \multicolumn{8}{c}{Top-down methods} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \\ \hline Mask R-CNN [14] & ResNet-50 & 64.2 & 86.6 & 69.7 & 58.7 & 73.0 & 8.2 \\ Simcc [22] & ResNet-50 & 73.0 & 89.3 & 79.7 & **69.5** & **79.9** & - \\ Power [29] & ResNet-50 & 75.4 & 90.5 & 82.2 & 68.1 & 78.6 & - \\ ViTPose [48] & ViTPose-B & **75.8** & **90.7** & **83.2** & 68.7 & 78.4 & - \\ \hline \hline \multicolumn{8}{c}{Bottom-up methods} & \multicolumn{1}{c}{} \\ \hline CMU-Pose [3] & VGG-19 & 65.3 & 85.2 & 71.3 & 62.2 & 70.7 & 10.1 \\ DEKP [13] & HRNet-W32 & 68.0 & 86.7 & 74.5 & 62.1 & 77.7 & 1.8 \\ HrHRNet [7] & HRNet-W32 & 68.5 & - & - & **64.3** & 75.3 & 1.8 \\ \hline \hline \multicolumn{8}{c}{Two-stage end-to-end methods} \\ \hline \multicolumn{8}{c}{PETR [38]} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \\ \hline \multicolumn{8}{c}{Fully one-stage end-to-end methods} \\ \hline \multicolumn{8}{c}{Fully one-stage end-to-end methods} \\ \hline JCRA(Ours) & ResNet-50 & **69.2** & **89.4** & **76.7** & 63.0 & **78.3** & **14.6** \\ \hline \end{tabular}
\end{table}
Table 2: Keypoint detection AP on COCO val2017 dataset
Figure 3: The visualization results of the JCRA. The first row and the second row show the visualization results on COCO dataset, respectively. A wide range of poses can be handled by JCRA, including viewpoint change, occlusion, and crowded settings.
bone network for feature extraction, our JCRA surpasses all existing bottom-up approaches and end-to-end methods. Remarkably, without further enhancements, our model achieved an impressive AP score of 67.6 using ResNet-50.
**Inference time.** In Fig. 5, we demonstrate the speed-accuracy trade-off between our JCRA and state-of-the-art methods. JCRA surpasses all top-down, bottom-up and end-to-end methods in both speed and accuracy domains. JCRA with ResNet-50 can achieve \(78\%\) acceleration of inference speed than previous state-of-the-art bottom-up algorithms.
### Results on CrowdPose
The CrowdPose [19] dataset is extensive, containing 20,000 images with approximately 80,000 individuals, where each individual was labeled with 14 body joints. It is split into train, validation, and test subsets, containing about 10,000, 2,000, and 8,000 images, respectively. The models were trained on the training and validation subsets to attain optimal performance, and the results were reported on the test set, following the protocol in [7].
**Evaluation metric.** The standard average precision based on OKS, which is the same as COCO, is adopted as the evaluation metric. The CrowdPose dataset is divided into three crowding levels: easy, medium, and hard. We report \(AP^{kp}\), \(AP^{kp}_{50}\), \(AP^{kp}_{75}\), \(AP^{kp}_{E}\), \(AP^{kp}_{M}\), and \(AP^{kp}_{H}\) metrics for images in the easy, medium, and hard categories.
**Test set results.** The results of our approach, compared to other state-of-the-art methods on the test set, are displayed in Table 4. In contrast to top-down methods that lose their superiority in crowded scenes, our approach demonstrates robustness and achieves a 71.9 AP score without the need for flipping tests, surpassing the most recent two
Figure 4: L represents the encoder and decoder layers. L =4,3 means that the number of layers of the keypoint encoder is 4, and the number of layers of pose decoder is 3. When L = 6,5, we got the highest score 69.2 mAP on COCO val2017 dataset.
Figure 5: A comparative analysis of speed and accuracy across various methods.
\begin{table}
\begin{tabular}{c|c|c c c|c c|c} \hline \hline Method & Backbone & \(AP^{kp}\) & \(AP^{kp}_{00}\) & \(AP^{kp}_{00}\) & \(AP^{kp}_{00}\) & Speed(fps) \\ \hline \multicolumn{8}{c}{Top-down methods} & \multicolumn{1}{c}{} \\ \hline Mask R-CNN [14] & ResNet-50 & 62.7 & 87.0 & 68.4 & 57.4 & 71.1 & 8.2 \\ PRTR [21] & HRNet-W32 & 72.1 & 90.4 & 79.6 & 68.1 & 79.0 & - \\ Simec† [22] & ResNet-50 & 72.7 & 91.2 & 80.1 & 69.2 & 79.0 & - \\ \hline \multicolumn{8}{c}{Bottom-up methods} & \multicolumn{1}{c}{} \\ \hline CMU-Pose [3] & VGG-19 & 64.2 & 86.2 & 70.1 & 61.0 & 68.8 & 10.1 \\ DEKP [13] & HRNet-W32 & 67.3 & 87.9 & 74.1 & 61.5 & 76.1 & 1.8 \\ HeHRNet [7] & HRNet-W32 & 66.4 & 87.5 & 72.8 & 61.2 & 74.2 & 1.8 \\ \hline \multicolumn{8}{c}{Non end-to-end methods} & \multicolumn{1}{c}{} \\ \hline DirectPose [42] & ResNet-50 & 62.2 & 86.4 & 68.2 & 56.7 & 69.8 & 9.9 \\ FCRPose [30] & ResNet-50 & 64.3 & 87.3 & 71.0 & 61.6 & 70.5 & 10.7 \\ InsPose [39] & ResNet-50 & 65.4 & 88.9 & 71.7 & 60.2 & 72.7 & 9.1 \\ DirectPose [42] & ResNet-101 & 63.3 & 86.7 & 69.4 & 57.8 & 71.2 & - \\ FCRPose [30] & ResNet-101 & 65.6 & 87.9 & 72.6 & 62.1 & 72.3 & 7.8 \\ InsPose [39] & ResNet-101 & 66.3 & 89.2 & 73.0 & 61.2 & 73.9 & 7.3 \\ \hline \multicolumn{8}{c}{Two-stage end-to-end methods} & \multicolumn{1}{c}{} \\ \hline PETR [38] & ResNet-50 & 67.6 & 89.8 & 75.3 & 61.6 & 76.0 & 8.2 \\ \hline \multicolumn{8}{c}{Fully one-stage end-to-end methods} & \multicolumn{1}{c}{} \\ \hline JCRA(Ours) & ResNet-50 & **67.6** & **90.0** & 75.2 & **61.6** & **76.1** & **14.6** \\ \hline \end{tabular}
\end{table}
Table 3: Keypoint detection AP on COCO test-dev dataset. The symbol \(\uparrow\) is used to indicate the adoption of Gaussian label smoothing in our experiments.
stage end-to-end method, PETR [38]. Our JCRA is a fully one-stage end-to-end method without a refinement decoder block, which enhances its flexibility and adaptability for estimating human poses in crowded scenes.
## 5 Conclusion and Future Works
In this work, we present a novel transformer-based network called JCRA, which predicts keypoint results directly. The algorithm is simple, effective, and can be easily designed for real-time industrial multi-person applications, achieving state-of-the-art results on the challenging COCO benchmark. Our experiments validate the ability of JCRA to estimate body poses in high quality and real-time. Further work is needed to improve the accuracy of keypoints for \(AP_{M}^{kp}\). Although JCRA achieves similar results for \(AP_{L}^{kp}\) compared to top-down methods, improving the accuracy of keypoints for \(AP_{M}^{kp}\) will enable JCRA to perform as well as the top-down methods. Additionally, JCRA can be naturally extended by adding an object detection head on top of the decoder outputs, similar to Mask R-CNN's direct addition of a keypoint detection branch from Faster R-CNN. By doing so, the outputs of JCRA will include both keypoints and bounding boxes, allowing the information of bounding boxes to enhance the accuracy of keypoints.
|
2301.02683 | Classifying topological neural network quantum states via diffusion maps | We discuss and demonstrate an unsupervised machine-learning procedure to
detect topological order in quantum many-body systems. Using a restricted
Boltzmann machine to define a variational ansatz for the low-energy spectrum,
we sample wave functions with probability decaying exponentially with their
variational energy; this defines our training dataset that we use as input to a
diffusion map scheme. The diffusion map provides a low-dimensional embedding of
the wave functions, revealing the presence or absence of superselection sectors
and, thus, topological order. We show that for the diffusion map, the required
similarity measure of quantum states can be defined in terms of the network
parameters, allowing for an efficient evaluation within polynomial time.
However, possible ''gauge redundancies'' have to be carefully taken into
account. As an explicit example, we apply the method to the toric code. | Yanting Teng, Subir Sachdev, Mathias S. Scheurer | 2023-01-06T19:00:21Z | http://arxiv.org/abs/2301.02683v1 | # Classifying topological neural network quantum states via diffusion maps
###### Abstract
We discuss and demonstrate an unsupervised machine-learning procedure to detect topological order in quantum many-body systems. Using a restricted Boltzmann machine to define a variational ansatz for the low-energy spectrum, we sample wave functions with probability decaying exponentially with their variational energy; this defines our training dataset that we use as input to a diffusion map scheme. The diffusion map provides a low-dimensional embedding of the wave functions, revealing the presence or absence of superselection sectors and, thus, topological order. We show that for the diffusion map, the required similarity measure of quantum states can be defined in terms of the network parameters, allowing for an efficient evaluation within polynomial time. However, possible "gauge redundancies" have to be carefully taken into account. As an explicit example, we apply the method to the toric code.
## I Introduction
In the last few years, machine learning (ML) techniques have been very actively studied as novel tools in many-body physics [1; 2; 3; 4; 5; 6; 7]. A variety of valuable applications of ML has been established, such as ML-based variational ans\(\hat{\text{a}}\)ze for many-body wave functions, application of ML to experimental data to extract information about the underlying physics, ML methods for more efficient Monte-Carlo sampling, and employment of ML to detect phase transitions, to name a few. Regarding the latter type of applications, a particular focus has recently been on topological phase transitions [8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29; 30; 31]. This is motivated by the challenges associated with capturing topological phase transitions: by definition, topological features are related to the global connectivity of the dataset rather than local similarity of samples. Therefore, unless the dataset is sufficiently simple such that topologically connected pairs of samples also happen to be locally similar or features are used as input data that are closely related to the underlying topological invariant, the topological structure is hard to capture reliably with many standard ML techniques [11; 12].
In this regard, the ML approach proposed in Ref. [12], which is based on diffusion maps (DM) [32; 33; 34; 35], is a particularly promising route to learn topological phase transitions; it allows to embed high-dimensional data in a low-dimensional subspace such that pairs of samples that are smoothly connected in the dataset will be mapped close to each other, while disconnected pairs will be mapped to distant points. As such, the method captures the central notion of topology. In combination with the fact that it is unsupervised and thus does not require _a priori_ knowledge of the underlying topological invariants, it is ideally suited for the task of topological phase classification. As a result, there have been many recent efforts applying this approach to a variety of problems, such as different symmetry-protected, including non-Hermitian, topological systems [36; 37; 38; 39; 40; 41], experimental data [42; 39], many-body localized states [43], and dynamics [44]; extensions based on combining DM with path finding [36] as well as with quantum computing schemes [45] for speed-up have also been studied.
As alluded to above, another very actively pursued application of ML in physics are neural network quantum states: as proposed in Ref. [46], neural networks can be used to efficiently parameterize and, in many cases, optimize variational descriptions of wave functions of quantum many-body systems [47; 48; 49; 50; 51; 52; 53; 54; 55; 56]. In particular, restricted Boltzmann machines (RBMs) [4] represent a very popular neural-network structure in this context. For instance, the ground states of the toric code model [57] can be exactly expressed with a _local_ RBM ansatz [58], i.e., where only neighboring spins are connected to the same hidden neurons. When additional non-local extensions to the RBM ansatz of Ref. [58] are added, this has been shown to also provide a very accurate variational description of the toric code in the presence of a magnetic field [59].
In this work, we combine the DM approach of Ref. [12] with neural network quantum states with the goal of capturing topological order in an unsupervised way in interacting quantum many-body systems. We use a local network ansatz, with parameters \(\Lambda\), as a variational description for the wave functions \(\ket{\Psi(\Lambda)}\) of the low-energy subspace of a system with Hamiltonian \(\hat{\mathcal{H}}\). While we also briefly mention other possible ways of generating ensembles of states, we primarily focus on an energetic principle: we sample wavefunctions such that the probability of \(\ket{\Psi(\lambda)}\) is proportional to \(\exp(-\bra{\hat{\mathcal{H}}}_{\Lambda}/T)\) where \(\bra{\hat{\mathcal{H}}}_{\Lambda}=\bra{\Psi(\Lambda)}\hat{\mathcal{H}}\ket{ \Psi(\Lambda)}\). As illustrated in Fig. 1(a), the presence of superselection sectors in the low-energy spectrum of \(\hat{\mathcal{H}}\) implies that the ensemble of states decays into disconnected subsets of states for sufficiently small \(T\) (at least at fixed finite system size); these can be extracted, without need of prior labels, with dimensional reduction via DM (and subsequent \(k\)-means clustering), and thus allow to identify topological order. For sufficiently large \(T\), more and more high-energy states are included and all sectors are connected, see Fig. 1(b), as can also be readily revealed via DM-based embedding of the states.
Importantly, DM is a kernel technique in the sense that the input data \(x_{l}\) (in our case the states \(\ket{\Psi(\Lambda_{l})}\))
does not directly enter as a high-dimensional vector but only via a similarity measure \(S(x_{l},x_{l^{\prime}})\), comparing how "similar" two samples \(l\) and \(l^{\prime}\) are. In the context of applying DM to the problem of topological classification, it defines what a smooth deformation ("homotopy") of samples is. We discuss two possible such measures. The first one is just the quantum mechanical overlap, \(S_{\text{q}}(\Lambda_{l},\Lambda_{l^{\prime}})=|\langle\Psi(\Lambda_{l})|\Psi (\Lambda_{l^{\prime}})\rangle|^{2}\), of the wave functions. Although conceptually straightforward, its evaluation is computationally costly on a classical computer as it requires importance sampling. The local nature of our network ansatz allows us to also construct an alternative similarity measure that is expressed as a simple function of the network parameters \(\Lambda_{l}\) and \(\Lambda_{l^{\prime}}\) describing the two states to be compared. This can, however, lead to subtleties associated with the fact that two states with different \(\Lambda\) can correspond to the same wave functions (modulo global phase). We discuss how these "gauge redundancies" can be efficiently circumvented for generic states.
We illustrate these aspects and explicitly demonstrate the success of this approach using the toric code [57], a prototype model for topological order which has also been previously studied with other ML techniques with different focus [58, 59, 60, 15, 16, 17, 18]. We show that the DM algorithm learns the underlying loop operators wrapping around the torus without prior knowledge; at low \(T\), this leads to four clusters corresponding to the four ground states. At larger \(T\), these clusters start to merge, as expected. Interestingly, the DM still uncovers the underlying structure of the dataset related to the expectation value of the loop operators. Finally, we also show that applying a magnetic field leads to the disappearance of clusters in the DM, capturing the transition from topological order to the confined phase.
The remainder of the paper is organized as follows. In Sec. II, we describe our ML approach in general terms, including the local network quantum state description we use, the ensemble generation, a brief review of the DM scheme of Ref. [12], and the similarity measure in terms of neural network parameters. Using the toric code model as an example, all of these general aspects are then discussed in detail and illustrated in Sec. III. Finally, explicit numerical results can be found in Sec. IV and a conclusion is provided in Sec. V.
## II General algorithm
Here, we first present and discuss our algorithm [see Fig. 2(a)] in general terms before illustrating it using the toric code as an example in the subsequent sections. Consider a system of \(N\) qubits or spins, with associated operators \(\{\hat{\mathbf{s}}\}=\{\hat{\mathbf{s}}_{i},i=1,\cdots,N\}\), \(\hat{\mathbf{s}}_{i}=(\hat{s}_{\text{r}}^{x},\hat{s}_{i}^{y},\hat{s}_{i}^{z})\), and interactions governed by a local, gapped Hamiltonian \(\hat{\mathcal{H}}=\mathcal{H}(\{\hat{\mathbf{s}}\})\). We represent the states \(|\Psi(\Lambda)\rangle\) of this system using neural network quantum states [46],
\[|\Psi(\Lambda)\rangle=\sum_{\mathbf{\sigma}}\psi(\mathbf{\sigma};\,\Lambda)\ket{\mathbf{ \sigma}}, \tag{1}\]
where \(\mathbf{\sigma}\!=\!\{\sigma_{1},\sigma_{2},...,\sigma_{N}|\sigma_{i}=\pm 1\}\) enumerates configurations of the physical spin variables in a local computational basis (e.g. \(s^{z}\)-basis) and \(\Lambda\) is the set of parameters that the network \(\psi\) depends on to output the wavefunction amplitude \(\psi(\mathbf{\sigma};\,\Lambda)=\langle\mathbf{\sigma}|\Psi(\Lambda)\rangle\) for configuration \(\ket{\mathbf{\sigma}}\). Because the physical Hilbert space scales exponentially with the system size, there is a trade-off between the expressivity versus efficiency when choosing a network architecture (or ansatz) \(\psi\), so that the weights \(\Lambda\) can approximate the state \(|\Psi(\Lambda)\rangle\) to a reasonable degree and
Figure 1: (a) An illustration of a “low-energy” ensemble. Two (or more) initial states, \(|\Psi(\Lambda^{0})\rangle\) and \(|\Psi(\Lambda^{1})\rangle\), from two distinct topological sectors are chosen as “seeds” (green dots). The dots denote the dataset (later fed into the DM), which are a set of quantum states labeled by network parameters \(\Lambda\). This dataset is generated using the procedure outlined in Sec. II.1 and Algorithm. 1, where the next state \(\Lambda^{\prime}\) (blue dots at each arrow) is proposed by a random local perturbation and accepted with probability based on the energy expectation \(\langle H\rangle_{\Lambda^{\prime}}\). In the small-\(T\) regime, the full dataset is not inter-connected by such local perturbations and cluster among each topological sectors (at left and right valley). (b) An illustration of a “high-energy” ensemble. The states are generated using the same algorithm as before, however with a large hyperparameter \(T\) (compared to the energy gap \(\Delta\)). In this regime, the dataset include some of the low-energy states (blue dots), but also some high-energy states (red dots). Because the high-energy states are agnostic of the low-energy topological sectors, there exist paths (denoted by arrows among dots in the elliptical blob) such that the two initial seeds from distinct topological sectors effectively “diffuse” and form one connected cluster.
can at the same time be an efficient representation (with minimal number of parameters \(\Lambda\) that scale as a polynomial in \(N\)). To reach the ground state or, more generally, the relevant low-energy sector of the Hamiltonian \(\hat{\mathcal{H}}\) for the low-temperature physics, we minimize the energy in the variational subspace defined by Eq. (1) using gradient descent with a learning rate \(\lambda\),
\[\Lambda\to\Lambda-\lambda\,\partial_{\Lambda}\left<\hat{\mathcal{H}}\right>_{ \Lambda},\quad\left<\hat{\mathcal{H}}\right>_{\Lambda}=\left<\Psi(\Lambda) \right|\hat{\mathcal{H}}\left|\Psi(\Lambda)\right>. \tag{2}\]
Here, the quantum mechanical expectation value \(\left<\hat{\mathcal{H}}\right>_{\Lambda}\) is evaluated using importance sampling (see Appendix B).
While there are exponentially many states in the Hilbert space, the low-energy sector of a local Hamiltonian is expected to occupy a small subspace where states obey area law entanglement [61, 62] whereas a typical state obeys volume law [63, 64]. Motivated by these considerations, we consider a class of networks that naturally describe quantum states that obey area-law entanglement. Pictorially, in such networks, the connections from the hidden neurons (representing the weights \(\Lambda\)) to the physical spins are _quasi-local_[51, 53, 54, 55]. In that case, it holds
\[\psi(\boldsymbol{\sigma},\Lambda)=\phi_{1}(\boldsymbol{\sigma}_{1},\Lambda_{ 1})\times\phi_{2}(\boldsymbol{\sigma}_{2},\Lambda_{2})\times\cdots, \tag{3}\]
where \(\boldsymbol{\sigma}_{j}\!=\!\{\sigma_{k}\}_{k\in j}\) denote (overlapping) subsets of neighboring spins with \(\cup_{j}\boldsymbol{\sigma}_{j}=\boldsymbol{\sigma}\) and \(\Lambda_{j}\) are the subsets of the network parameters (weights and biases) that are connected to the physical spins in j.
```
procedure(\(\{\Lambda\}_{n=1}^{N}\)) init: optimized parameters \(\Lambda\) for\(k\) independent times do: for\(n\) sampling steps do: Propose new parameter \(\Lambda_{p}=f(\Lambda_{t})\) Accept with probability determined by energy \(\left<\hat{\mathcal{H}}\right>_{\Lambda}\) and parameter \(T\): \(\Lambda_{t+1}=\mathbb{P}_{\mathrm{accept}}(\Lambda^{\prime}|\Lambda;T)\) return the last \(m\) states for each \(k\): \(\{\Lambda_{i}|i=n-m,...,n\}_{k}\)
```
**Algorithm 1** Ensemble generation
### Dataset: network parameter ensembles
The dataset we use for unsupervised detection of topological order consists of an ensemble of wavefunctions \(\{|\Psi(\Lambda)\rangle\}_{l}\), parameterized by the set of network parameters \(\{\Lambda\}_{l}\). While, depending on the precise application, other choices are conceivable, we generate this ensemble such that the relative occurrence of a state \(|\Psi(\Lambda)\rangle\) is given by \(\rho_{T}(\Lambda)=\exp(-\left<\hat{\mathcal{H}}\right>_{\Lambda}/T)/Z\), with appropriate normalization factor \(Z\). As such, a small value of the "temperature-like" hyperparameter \(T\) corresponds to a "low-energy" ensemble while large \(T\) parametrize "high-energy" ensembles.
In practice, to generate this ensemble, we here first optimize the parameters \(\Lambda\) via Eq. (2) to obtain wavefunctions with lowest energy expectation values. As Eq. (1) does not contain all possible states, this will, in general, only yield approximations to the exact low-energy eigenstates of \(\hat{\mathcal{H}}\). However, as long as it is able to capture all superselection sectors of the system as well as (a subset of) higher energy states connecting these sectors, Eq. (1) will be sufficient for our purpose of detecting topological order or the absence thereof. We perform this optimization several times, \(\Lambda\to\Lambda_{l}^{0}\), with different initial conditions, to obtain several "seeds", \(\Lambda_{l}^{0}\); this is done to make sure we have a low-energy representative of all superselection sectors. Ideally the dataset is sampled directly from the the target probability distribution \(\rho_{T}\), if for instance, one has access to an experimental system at finite temperature. Here, we adopt a Markov-chain-inspired procedure for generating the ensemble based on \(\rho_{T}\) for each of these seeds. Specifically, starting from a state \(\Lambda\), we propose updates on a randomly chosen local block of parameters connected to the spins at sites j,
\[\Lambda\,\to\,\Lambda^{\prime}=\{\Lambda_{1},\Lambda_{2},\cdots,u(\Lambda_{ j}),\cdots,\Lambda_{N}\}, \tag{4}\]
where the update \(u\) only depends on \(\Lambda_{j}\). The proposed parameter \(\Lambda^{\prime}\) given the current parameter \(\Lambda\) is accepted with probability
\[\mathbb{P}_{\mathrm{accept}}(\Lambda^{\prime}|\Lambda;T)=\min\Bigl{(}1,\,e^{- \frac{\left<\hat{\mathcal{H}}\right>_{\Lambda^{\prime}}-\left<\hat{\mathcal{H }}\right>_{\Lambda}}{T}}\Bigr{)}. \tag{5}\]
This means that if the proposed state \(\Psi(\Lambda^{\prime})\) has a lower energy expectation value than \(\Psi(\Lambda)\), then the proposal will be accepted; otherwise, it will be accepted with a probability determined by the Boltzmann factor. The entire ensemble generation procedure is summarized in Algorithm 1.
### Diffusion map
As proposed in Ref. [12], DM is ideally suited as an unsupervised ML algorithm to identify the presence and number of superselection sectors in a collection of states, such as \(\{|\Psi(\Lambda)\rangle\}_{l}\) defined above. To briefly review the key idea of the DM algorithm [32, 33, 34, 35] and introduce notation, assume we are given a dataset \(X=\{x_{l}|l=1,2,...,M\}\), consisting of \(M\) samples \(x_{l}\). Below we will consider the cases \(x_{l}=\Lambda_{l}\) and \(x_{l}=|\Psi(\Lambda_{l})\rangle\); in the first case, the samples are the network parameters parametrizing the wavefunction and, in the second, the samples are the wavefunctions themselves.
To understand DM intuitively, let us define a diffusion process among states \(x_{l}\in X\). The probability of state \(x_{l}\) transitioning to \(x_{l^{\prime}}\) is defined by the Markov transition matrix element \(p_{l,l^{\prime}}\). To construct \(p_{l,l^{\prime}}\), we introduce a symmetric and positive-definite kernel \(k_{\epsilon}(x_{l},x_{l^{\prime}})\) between states \(x_{l}\) and \(x_{l^{\prime}}\). Then the transition probability matrix
\(p_{l,l^{\prime}}\) is defined as
\[p_{l,l^{\prime}}=\frac{k_{\epsilon}(x_{l},x_{l^{\prime}})}{z_{l}},\quad z_{l}=\sum_ {l^{\prime}}k_{\epsilon}(x_{l},x_{l^{\prime}}), \tag{6}\]
where the factor \(z_{l}\) ensures probability conservation, \(\sum_{l^{\prime}}p_{l,l^{\prime}}=\!1\,\forall l\). Then spectral analysis on the transition probability matrix leads to information on the _global_ connectivity of the dataset \(X\), which, in our context of \(X\) containing low-energy states, allows to identify superselection sectors and, thus, topological order [12]. To quantify how strongly two samples \(x_{l}\) and \(x_{l^{\prime}}\) are connected, one introduces the \(2t\)-step diffusion distance [32, 33, 34, 35],
\[D_{2t}(l,l^{\prime})=\sum_{l^{\prime\prime}}\frac{1}{z_{l^{\prime\prime}}}[(p ^{t})_{l,l^{\prime\prime}}-(p^{t})_{l^{\prime},l^{\prime\prime}}]^{2}, \tag{7}\]
where \(p^{t}\) denotes the \(t\)-th matrix power of the transition probability matrix \(p\). It was shown that \(D_{2t}\) can be computed from the eigenvalues \(\lambda_{n}\) and right eigenvectors \(\psi_{n}\) of the transition matrix \(p\): with \(\sum_{l^{\prime}}p_{l,l^{\prime}}\left(\psi_{n}\right)_{l^{\prime}}\!=\! \lambda_{n}\left(\psi_{n}\right)_{l}\), and in descending ordering \(\lambda_{n}>\lambda_{n+1}\), it follows
\[D_{2t}(l,l^{\prime})=\sum_{n=1}^{M-1}\lambda_{n}^{2t}[(\psi_{n})_{l}-(\psi_{n} )_{l^{\prime}}]^{2} \tag{8}\]
after straightforward algebra [35]. Geometrically, this means that the diffusion distance is represented as a Euclidean distance (weighted with \(\lambda_{n}\)) if we perform the non-linear coordinate transformation \(x_{l}\rightarrow\{(\psi_{n})_{l},n=0,\ldots M-1\}\). Furthermore, as the global connectivity is seen from the long-time limit, \(t\rightarrow\infty\), of the diffusion distance, the largest eigenvalues are most important to describe the connectivity. To be more precise, let us choose a kernel \(k_{\epsilon}\) of the form
\[k_{\epsilon}(x_{l},x_{l^{\prime}})=\exp\left(-\frac{1-S(x_{l},x_{l^{\prime}})} {\epsilon}\right), \tag{9}\]
where \(S\) is a _local similarity measure_ which obeys \(S\in[0,1]\), \(S(x_{l},x_{l^{\prime}})=S(x_{l^{\prime}},x_{l})\), and \(S(x,x)=1\). Here "local" means that \(S(x_{l},x_{l^{\prime}})=\sum_{i}\mathcal{S}_{i}(x_{l},x_{l^{\prime}})\) where \(\mathcal{S}_{i}(x_{l},x_{l^{\prime}})\) only depend on the configuration of \(x_{l}\) and
Figure 2: (a) Overview of the ML algorithm applied in this work: the “seeds” \(\{\Lambda^{0}\}\) are computed using variational Monte Carlo (see Appendix B), a Markov-chain algorithm is used to generate the network parameter ensemble dataset (Sec. II.1), then a similarity metric is used for the definition of kernels in the DM method (Sec. II.2 and Sec. II.3), and finally \(k\)-means is applied to the low-dimensional embedding in the subspace provided by the dominant DM eigenvector components. (b) The square lattice geometry for the toric code model, where the qubits \(\hat{s}_{i}\) are defined on the links of the lattice (grey dots). The Hamiltonian [given in Eq. (16)] is written in terms of the operators \(\hat{\mathcal{P}}_{P}\) (supported by spins on plaquette \(P\) denoted by the red square) and star \(\hat{\mathcal{S}}_{S}\) (supported by spins on star \(S\) denoted by the blue links). The two blue lines along \(x(y)\) directions denote the Wilson loop operators \(\hat{W}_{1,x}(\hat{W}_{2,g})\) along the straight paths \(\bar{x}(\bar{y})\). (c) An illustration of the quasi-local ansatz in Eq. (17). The ansatz is a product over local function \(\phi\) of spins in plaquette (or star), which depends on parameters \(\{w_{Xj},b_{X}\}\) for \(X=P(S)\) being plaquette (or star).
\(x_{l^{\prime}}\) in the vicinity of site \(i\). While we will discuss possible explicit forms of \(S\) for our quantum mechanical \(N\) spin/qubit system in Sec. II.3 below, a natural choice for a classical system of \(N\) spins, \(x_{l}=\{\mathbf{S}^{l}_{j},(\mathbf{S}^{l}_{i})^{2}=1,i=1,2,\ldots,N\}\), is \(S_{\text{cl}}(x_{l},x_{l^{\prime}})=\sum_{i}\mathbf{S}^{l}_{i}\cdot\mathbf{S}^{l}_{i}/N\). In Eq. (9), \(\epsilon\) plays the role of a "coarse graining" parameter that is necessary as we only deal with finite datasets \(X\): for given \(X\), we generically expect \(k_{\epsilon}(x_{l},x_{l^{\prime}})=p_{l,l^{\prime}}=\delta_{l,l^{\prime}}\) as \(\epsilon\to 0\), i.e., all samples are dissimilar if \(\epsilon\) is sufficiently small and all eigenvalues \(\Lambda_{n}\) approach 1. In turn, for \(\epsilon\to\infty\) the coarse graining parameter is so large that all samples become connected, \(k_{\epsilon}(x_{l},x_{l^{\prime}})\to 1\); as \(p_{l,l^{\prime}}\to 1/M\), we will have \(\lambda_{n>0}\to 0\), while the largest eigenvalue \(\lambda_{0}\) is always 1 (as a consequence of probability conservation). For values of \(\epsilon\) in between these extreme limits, the DM spectrum contains information about \(X\), including its topological structure: as shown in Ref. [12], the presence of \(k\in\mathbb{N}\) distinct topological equivalence classes in \(X\) is manifested by a range of \(\epsilon\) where \(\lambda_{1},\ldots\lambda_{k-1}\) are all exponentially close (in \(\epsilon\)) to 1, with a clear gap to \(\lambda_{n\geq k}\). Furthermore, the different samples \(l\) will cluster--with respect to the normal Euclidean measure, e.g., as can be captured with \(k\)-means--according to their topological equivalence class when plotted in the mapped \(k-1\)-dimensional space \(\{(\psi_{1})_{l},(\psi_{2})_{l},\ldots,(\psi_{k-1})_{l}\}\). In the following, we will use this procedure to identify the superselection sectors in the ensemble of wave functions defined in Sec. II.1. To this end, however, we first need to introduce a suitable similarity measure \(S\), to be discussed next.
### Local similarity measure
A natural generalization of the abovementioned classical similarity measure \(S_{\text{cl}}=\sum_{i}\mathbf{S}^{l}_{i}\cdot\mathbf{S}^{l}_{i}/N\), which can be thought of as the (Euclidean) inner product in the classical configuration space, is to take the inner product in the Hilbert space of the quantum system,
\[S_{\text{q}}(\Lambda_{l},\Lambda_{l^{\prime}})=|\langle\Psi(\Lambda_{l})| \Psi(\Lambda_{l^{\prime}})\rangle|^{2}. \tag{10}\]
While this or other related fidelity measures for low-rank quantum states could be estimated efficiently with quantum simulation and computing setups [65; 66; 67; 68], estimating \(S_{\text{q}}\) is generally a computationally expensive task on a classical computer, as it requires sampling over spin configurations for our variation procedure. To make the evaluation of the similarity measure more efficient, we here propose an alternative route that takes advantage of the fact that we use a local ansatz for \(\psi(\mathbf{\sigma};\Lambda)\), see Eq. (3). Our goal is to express the similarity measure directly as
\[S_{\text{n}}(\Lambda_{l},\Lambda_{l^{\prime}})=\frac{1}{N_{\text{j}}}\sum_{ \text{l}}f((\Lambda_{l})_{\text{j}},(\Lambda_{l^{\prime}})_{\text{j}}), \tag{11}\]
where \(f\) only compares a local block of parameters denoted by \(\text{j}\) and is a function that can be quickly evaluated, without having to sample spin configurations. Furthermore, \(S(x_{l},x_{l^{\prime}})=S(x_{l^{\prime}},x_{l})\) can be ensured by choosing a function \(f\) that is symmetric in its arguments and \(S\in[0,1]\) is also readily implemented by setting \(N_{\text{j}}=\sum_{\text{j}}\) and appropriate rescaling of \(f\) such that \(f\in[0,1]\). The most subtle condition is
\[S_{\text{n}}(\Lambda_{l},\Lambda_{l^{\prime}})=1\quad\Longleftrightarrow\quad |\Psi(\Lambda_{l})\rangle\propto|\Psi(\Lambda^{\prime}_{l})\rangle\,, \tag{12}\]
since, depending on the precise network architecture used for \(\psi(\mathbf{\sigma};\Lambda)\), there are "gauge transformations" \(g\in\mathcal{G}\) of the weights, \(\Lambda_{l}\to g[\Lambda_{l}]\), with
\[|\Psi(\Lambda_{l})\rangle=e^{i\vartheta_{g}}\,|\Psi(g[\Lambda_{l}])\rangle \tag{13}\]
for some global phase \(\vartheta_{g}\). We want to ensure that
\[S_{\text{n}}(\Lambda_{l},\Lambda_{l^{\prime}})=S_{\text{n}}(\Lambda_{l},g[ \Lambda_{l^{\prime}}])=S_{\text{n}}(g[\Lambda_{l}],\Lambda_{l^{\prime}}) \tag{14}\]
for all such gauge transformations \(g\in\mathcal{G}\). A general way to guarantee Eq. (14) proceeds by replacing,
\[S_{\text{n}}(\Lambda_{l},\Lambda_{l^{\prime}})\quad\longrightarrow\quad\max_{g, g^{\prime}\in\mathcal{G}}S_{\text{n}}(g[\Lambda_{l}],g^{\prime}[\Lambda_{l^{ \prime}}]). \tag{15}\]
However, in practice, it might not be required to iterate over all possible gauge transformations in \(\mathcal{G}\) due to the locality of the similarity measure. In the following, we will use the toric code and a specific RBM variational ansatz as an example to illustrate these gauge transformations and how an appropriate function \(f\) in Eq. (11) and gauge invariance (14) can be implemented efficiently.
Finally, note that, while we focus on applying DM in this work, a similarity measure in terms of neural network parameters can also be used for other kernel techniques such as kernel PCA. Depending on the structure of the underlying dataset, DM has clear advantage over kernel PCA: the former really captures the global connectivity of the dataset rather than the subspace with most variance that is extracted by the latter. This is why kernel PCA fails when identifying, e.g., winding numbers, in general datasets where DM still works well [12]. Specifically for our case study of the toric code below, we find that kernel PCA can also identify topological sectors for small \(T\) and without magnetic field, \(h=0\), as a result of the simple data structure; however, only DM works well when \(h\) is turned on, as we discuss below.
## III Example: Toric Code
Now we illustrate our DM-based ML algorithm using the toric code model [57], defined on an \(L_{x}\times L_{y}\) square lattice with spin-\(1/2\) operators or qubits on every bond, see Fig. 2(b), leading to a total of \(N=2L_{x}L_{y}\) spins; throughout this work, we will assume periodic boundary conditions. Referring to all four spins on the edges of an elementary square (vertex) of the lattice as plaquette \(P\) (star \(S\)), the plaquette and star operators are defined
as \(\hat{\mathcal{P}}_{P}=\prod_{i\in P}\hat{s}_{i}^{x}\) and \(\hat{\mathcal{S}}_{S}=\prod_{i\in S}\hat{s}_{i}^{x}\), respectively. The toric code Hamiltonian then reads as
\[\tilde{H}_{\rm tc}=-J_{P}\sum_{P}\hat{\mathcal{P}}_{P}-J_{S}\sum_{S}\hat{ \mathcal{S}}_{S}, \tag{16}\]
where the sums are over all plaquettes and stars of the lattice. All "stabilizers" \(\hat{\mathcal{P}}_{P}\), \(\hat{\mathcal{S}}_{S}\) commute among each other and with the Hamiltonian. Focusing on \(J_{P},J_{S}>0\), the ground states are obtained as the eigenstates with eigenvalue \(+1\) under all stabilizers. A counting argument, taking into account the constraint \(\prod_{S}\hat{\mathcal{S}}_{S}\!=\!\prod_{P}\hat{\mathcal{P}}_{P}\!=\!\mathds{1}\), reveals that there are four, exactly degenerate ground states for periodic boundary conditions.
To describe the ground-states and low-energy subspace of the toric code model (16) variationally, we parameterize \(\psi(\mathbf{\sigma};\,\Lambda)\) in Eq. (1) using the ansatz
\[\psi_{\rm rbm}(\mathbf{\sigma};\,\Lambda)= \prod_{P}\cos(b_{P}+\sum_{j\in P}w_{Pj}\sigma_{j})\] \[\times \prod_{S}\cos(b_{S}+\sum_{j\in S}w_{Sj}\sigma_{j}), \tag{17}\]
proposed in Ref. [58], where every plaquette \(P\) (star \(S\)) is associated with a "bias" \(b_{P}\) (\(b_{S}\)) and four weights \(w_{P,j}\) (\(w_{S,j}\)), all of which are chosen to be real here, i.e., \(\Lambda=\{b_{P},b_{S},w_{P,j},w_{S,j}\}\). This ansatz can be thought of as an RBM [46] (see Appendix A), as illustrated in Fig. 2(c), with the same geometric properties as the underlying toric code model. It is clear that Eq. (17) defines a quasi-local ansatz as it is of the form of Eq. (3), with j enumerating all plaquettes and stars (and thus \(N_{j}=2N\)). For this specific ansatz, the gauge transformations \(g\in\mathcal{G}\), as introduced in Sec. II.3 above, are generated by the following set of operations on the parameters \(b_{P}\), \(b_{S}\), \(w_{P,j}\), and \(w_{S,j}\):
1. For \(X\) being any plaquette or star, multiplying all biases and weights of that plaquette or star by \(-1\) [see Fig. 3(a)], \[g_{X,-}:\,b_{X}\to-b_{X},\ w_{Xj}\to-w_{Xj},\] (18a) leaves the wave function invariant [\(\vartheta_{g}=0\) in Eq. (13)].
2. Adding \(\pi\) to either the bias or any of the weights associated with the plaquette or star \(X\) [see Fig. 3(b)], \[g_{X,\pi,b}: \!b_{X}\to b_{X}+\pi,\] (18b) \[g_{X,\pi,j}: \!w_{Xj}\to w_{Xj}+\pi,\quad j\in X,\] (18c) leads to an overall minus sign [\(\vartheta_{g}=\pi\) in Eq. (13)].
3. For any closed loop \(\ell\) (or \(\bar{\ell}\)) on the direct (or dual lattice), adding \(\frac{\pi}{2}\) to all weights of the stars (plaquettes) that are connected to the spins crossed by the string [see Fig. 3(c-d)], \[g_{\ell}:\,w_{Sj}\to w_{Sj}+\frac{\pi}{2},\quad Sj\in\ell,\] (18d) \[g_{\bar{\ell}}:\,w_{Pj}\to w_{Pj}+\frac{\pi}{2},\quad Pj\in\bar{ \ell},\] (18e) leads to \(\vartheta_{g}=0\) or \(\pi\) in Eq. (13) depending on the length of the string. Note that any loop configuration \(\mathcal{L}\), which can contain an arbitrary number of loops, can be generated by the set \(\{g_{S},g_{P},g_{x,y},g_{\bar{x},\bar{y}}\}\), where \(g_{S}\) (\(g_{P}\)) creates an elementary loop on the dual (direct) lattice encircling the star \(S\) (plaquette \(P\)), see Fig. 3(c,d), and \(g_{x,y}\) (\(g_{\bar{x},\bar{y}}\)) creates a non-contractible loop on the direct (dual) lattice along the \(x,y\) direction. Since the length of any contractible loop is even, \(\vartheta_{g}=0\) for any string transformations generated by \(g_{S}\) and \(g_{P}\). Meanwhile, on an odd lattice, the gauge transformations \(g_{x,y}(g_{\bar{x},\bar{y}})\) involve an odd number of sites and thus lead to \(\vartheta_{g}=\pi\).
Figure 3: Gauge freedom of RBM ansatz in Eq. (17). The following transformations only lead to a global phase: (a) Multiplying all the parameters of a plaquette (or star, not shown) by a minus sign, see Eq. (18a); (b) A \(\pi\) shift of a single parameter, see Eqs. (18b) and (18c); (c) A \(\pi/2\) shift to the weights crossed by a string \(\bar{l}\), defined by \(g_{\bar{l}}\) in Eq. (18e). The straight pink line represents the transformation on a non-contractible loop denoted by \(g_{y}\); (d) Same as (c) but for loops on the direct lattice and \(g_{\bar{l}}\) and \(g_{\bar{y}}\), cf. Eq. (18d).
A highly inefficient way of dealing with this gauge redundancy would be to use a choice of \(S_{n}\) in Eq. (11) which is not invariant under any of the transformations in Eq. (18); this would, for instance, be the case by just taking the Euclidean distance of the weights,
\[\begin{split} S_{\text{eu}}&(\Lambda_{l},\Lambda_{l^ {\prime}})\propto||\Lambda_{l}-\Lambda_{l^{\prime}}||^{2}\\ &=\sum_{X}\Bigl{[}(b_{X}^{l}-b_{X}^{l^{\prime}})^{2}+\sum_{j \in X}(w_{Xj}^{l}-w_{Xj}^{l^{\prime}})^{2}\Bigr{]},\end{split}\]
where the sum over \(X\) involves all plaquettes and stars. Naively going through all possible gauge transformations to find the maximum in Eq. (15) would in principle rectify the lack of gauge invariance. However, since the number of gauge transformations scales exponentially with system size \(N\) (holds for each of the three classes, 1.-3., of transformations defined above), such an approach would become very expensive for large \(N\). Luckily, locality of the ansatz and of the similarity measure allows us to construct similarity measures that can be evaluated much faster: as an example, consider
\[\begin{split} S_{n}&(\Lambda_{l},\Lambda_{l^{ \prime}})=\frac{1}{2}+\frac{1}{10N}\sum_{X}\max_{\tau_{X}=\pm}\Bigl{[}\\ &\sum_{j\in X}\cos 2(\tau_{X}w_{Xj}^{l}-w_{Xj}^{l^{\prime}})+ \cos 2(\tau_{X}b_{X}^{l}-b_{X}^{l^{\prime}})\Bigr{]},\end{split} \tag{19}\]
which clearly obeys \(S_{n}(\Lambda_{l},\Lambda_{l^{\prime}})=S_{n}(\Lambda_{l^{\prime}},\Lambda_{l})\), \(S_{n}(\Lambda_{l},\Lambda_{l^{\prime}})\in[0,1]\), and locality [it is of the form of Eq. (11) with j enumerating all \(X\)]. Concerning gauge invariance, first note that the choice of \(\cos(\cdot)\) immediately leads to invariance under Eq. (18a). Second, for each \(X\) we only have to maximize over two values (\(\tau_{X}\)) to enforce invariance under Eqs. (18b) and (18c), i.e., the maximization only doubles the computational cost.
The "string" redundancy, see Eqs. (18d) and (18e), however, is not yet taken into account in Eq. (19). It can be formally taken care of by maximizing over all possible loop configurations, denoted by \(\mathcal{L}\),
\[\begin{split} S_{\text{str}}&(\Lambda_{l},\Lambda_{ l^{\prime}})=\frac{1}{2}+\frac{1}{10N}\max_{\mathcal{L}}\Bigl{\{}\sum_{X} \max_{\tau_{X}=\pm}\Bigl{[}\\ &\sum_{j\in X}\mu_{Xj}^{\mathcal{L}}\cos 2(\tau_{X}w_{Xj}^{l}-w_{ Xj}^{l^{\prime}})+\cos 2(\tau_{X}b_{X}^{l}-b_{X}^{l^{\prime}})\Bigr{]}\Bigr{\}}, \end{split} \tag{20}\]
where \(\mu_{Xj}^{\mathcal{L}}=-1\) if \(Xj\) lives on a loop contained in \(\mathcal{L}\) and \(\mu_{Xj}^{\mathcal{L}}=1\) otherwise. While there is an exponential number of such strings, Ref. [12] has proposed an algorithm to efficiently find an approximate maximum value. In our case, this algorithm amounts to randomly choosing a plaquette \(P\) or a star \(S\) or a direction \(d=x,y\) and then applying \(g_{S}\) or \(g_{P}\) or \(g_{d=x,y}\) to \(\Lambda_{l}\) in Eq. (19). If this does not decrease the similarity, keep that transformation; if it decreases the similarity, discard the gauge transformation. Repeat this procedure \(N_{g}\) times. In Ref. [12], \(N_{g}\) between \(10^{3}\) and \(10^{4}\) was found to be enough for a large system consisting \(18\times 18\) square-lattice sites (total of \(N=2\times 18^{2}\) qubits). On top of this, \(g_{S}\) and \(g_{P}\) are local and, hence, the evaluation of the change of the similarity with the gauge transformation only requires \(\mathcal{O}(N^{0})\) amount of work.
In the numerical simulations below, using Eq. (19) without sampling over loop configurations \(\mathcal{L}\) turned out to be sufficient. The reason is that, for our Markov-chain-inspired sampling procedure of \(\Lambda_{l}\) (see Appendix C), updates that correspond to these loop transformations happen very infrequently. Furthermore, even if a few pairs of samples are incorrectly classified as distinct due to the string redundancy, the DM will still correctly capture the global connectivity and, hence, absence or presence of topological sectors.
Figure 4: (a) DM spectrum for topological phase at \(h=0\) and \(T=0.1\) using the neutral network similarity measure in Eq. (19). Inset left: associated leading DM components; color represents the loop observable expectations values defined in (c-d). Inset right: DM spectrum in descending order at \(\epsilon=0.01\) indicated by the dashed line. (b) Same as (a), but using exact overlaps \(S_{\text{q}}\) in Eq. (10) as metric. (c) Color map for the non-local loop values \(\langle\overline{W}_{1}\rangle,\langle\overline{W}_{2}\rangle\) in the left insets of (a) and (b). (d) Different straight Wilson loops \(\hat{W}_{1,x_{i}}\) (\(\hat{W}_{2,g_{i}}\)) along \(x\) (\(y\)) direction, denoted by blue (red) lines. The loop values in the color map in (c) are spatial averages over all straight-loop expectation values (as in the equations for \(\langle\overline{W}_{1}\rangle,\langle\overline{W}_{2}\rangle\)).
Numerical results
We next demonstrate explicitly how the general procedure outlined above can be used to probe and analyze topological order in the toric code. We start from the pure toric code Hamiltonian defined in Eq. (16) using the variational RBM ansatz in Eq. (17). An ensemble of network parameters is generated by applying the procedure of Sec. II.1 (see also Algorithm 1) for a system size of \(N\!=\!18\) spins; the hyperparameters for ensemble generation and more details including the form of \(u\) in Eq. (4) are given in Appendix C. From now on, we measure all energies in units of \(J_{P}\) and set \(J_{S}=J_{P}=1\).
Let us first focus on the low-energy ensemble and choose \(T=0.1\) in Eq. (5). For the simple similarity measure in Eq. (19), that can be exactly evaluated at a time linear in system size \(N\), we find the DM spectrum shown in Fig. 4(a) as a function of \(\epsilon\) in Eq. (9). We observe the hallmark feature of four superselection sectors [12]: there is a finite range of \(\epsilon\) where there are four eigenvalues exponentially close to \(1\). The association of samples (in our case states) and these four sectors is thus expected to be visible in a scatter plot of a projected subspace spanned by the first three non-trivial eigenvectors \(\psi_{1,2,3}\)[12]; note the zeroth eigenvector \((\psi_{0})_{l}=C\) is always constant with eigenvalue \(\lambda=1\) from probability conservation. In fact, we can see these clusters already in the first two components, see left inset in Fig. 4(a). Then a standard \(k\)-means algorithm is applied onto this projected subspace to identify the cluster number for each data point. To verify that the ML algorithm has correctly clustered the states according to the four physical sectors, we compute the expectation value for each state of the string operators,
\[\hat{W}_{1,\bar{x}}=\prod_{i\in\bar{x}}\hat{s}_{i}^{x},\quad\hat{W}_{2,\bar{y} }=\prod_{i\in\bar{y}}\hat{s}_{i}^{x}, \tag{21}\]
where \(\bar{x}(\bar{y})\) are loops defined on the dual lattice winding along the \(x(y)\) direction, shown as blue lines in Fig. 2(b). We quantify the association of a state to physical sectors by the average of a set of straight loops \(\mathcal{X}(\mathcal{Y})\) winding around the \(x(y)\) direction, shown as blue (red) lines in Fig. 4(d). Indicating this averaged expectation value \(\langle\overline{W}_{1}\rangle,\langle\overline{W}_{2}\rangle\) in the inset of Fig. 4(a) using the color code defined in Fig. 4(c), we indeed see that the clustering is done correctly.
To demonstrate that this is not a special feature of the similarity measure in Eq. (19), we have done the same analysis, with result shown in Fig. 4(b), using the full quantum mechanical overlap measure in Eq. (10). Quantitative details change but, as expected, four superselection sectors are clearly identified and the clustering is done correctly. We reiterate that the evaluation of the neural-network similarity measure in Eq. (19) [exact evaluation \(\mathcal{O}(N)\)] is much fast than that in Eq. (10) [exact evaluation \(\mathcal{O}(2^{N})\), but we can compute it approximately with importance sampling] on a classical computer. Note, however, that once \(S_{n}\) is computed for all samples, the actual DM-based clustering takes the same amount of computational time for both approaches. Consequently, suppose there is a quantum simulator that can efficiently measure the quantum overlap in Eq. (10) or any other viable similarity measure for that matter, then we can equivalently use the "measured" similarity for an efficient clustering of the superselection sectors via the DM scheme. As a next step, we demonstrate that the superselection sectors are eventually connected if we take into account states with sufficiently high energy. To this end, we repeat the same analysis but for an ensemble with \(T=1\). As can be seen in the resulting DM spectrum in Fig. 5(a), there is no value of \(\epsilon\) where more than one eigenvalue is (exponentially) close to \(1\) and separated from the rest of the spectrum by a clear gap. Here we used again the simplified measure in Eq. (19), but have checked nothing changes qualitatively when using the overlap measure. To verify that this is the correct answer for the given dataset, we again computed the expectation value of the loop operators in Eq. (21) for each state in the ensemble. This is shown in Fig. 5(b), where we also use color to indicate the energy expectation value for each state. We can clearly see the four low-energy (blue) sectors (with \(|W_{1,2}|\simeq 1\)) are connected via high-energy (red) states (with \(|W_{1,2}|\ll 1\)). This agrees with the DM result that
Figure 5: (a) DM spectrum for the high-energy ensemble at \(h\!=\!0\) and \(T\!=\!1\). The inset is the spectrum at \(\epsilon=0.03\) indicated by the dashed line in the main panel; (b) Spatially averaged straight Wilson loops \(\langle\overline{W}_{1(2)}\rangle\) [see Fig. 4(c-d)] along two directions for the states in (a), where the color encodes energy density \(\langle H\rangle/N\); (c) Leading DM components where the color of the dots encodes \(\langle\overline{W}_{1(2)}\rangle\) using the color map in Fig. 4(d); (d) DM spectrum for the trivial phase at \(h\!=\!1.0\) and \(T\!=\!0.1\) using the quantum metric \(S_{\rm q}\).
all states are connected within the ensemble (topological order is lost). We can nonetheless investigate the clustering in the leading three non-trivial DM components \(\psi_{1,2,3}\). Focusing on a 2D projection in Fig. 5(c) for simplicity of the presentation, we can see that the DM reveals very interesting structure in the data: the four lobes roughly correspond to the four colors blue, red, orange, and green associated with the four superselection sectors and the states closer to \(|W_{1,2}|=1\) (darker color) appear closer to the tips. Finally, note that the colors are arranged such that the red and green [orange and blue] lobes are on opposite ends, as expected since they correspond to \((W_{1},W_{2})\simeq(1,-1)\) and \((-1,1)\) [\((-1,-1)\) and \((1,1)\)].
Another route to destroying topological order proceeds via application of a magnetic field. To study this, we extend the toric code Hamiltonian according to
\[\hat{H}^{\prime}_{\rm tc}=\hat{H}_{\rm tc}-h\sum_{i}\hat{s}_{i}^{z}. \tag{22}\]
Clearly, in the limit of \(h\to\infty\), the ground state is just a state where all spins are polarized along \(\hat{s}^{z}\) and topological order is lost. Starting from the pure toric model (\(h=0\)) and turning on \(h\) reduces the gap of the "charge excitations" defined by flipping \(\hat{\mathcal{S}}_{S}\) from \(+1\) in the toric code groundstate to \(-1\). Their condensation leads to a second-order quantum phase transition [69, 70, 71, 72].
Before addressing the transition, let us study the large-\(h\) limit. We first note that our ansatz in Eq. (17) does not need to be changed as it can capture the polarized phase as well. For instance, denoting the "northmost" (and "southmost") spin of the plaquette \(P\) (and star \(S\)) by \(j_{0}(P)\) (and \(j_{0}(S)\)), respectively, the spin polarized state is realized for [see also Fig. 8(a) in the Appendix]
\[b_{P}=b_{S}=-\frac{\pi}{4},\ \ w_{Xj}=\begin{cases}\frac{\pi}{4},&j=j_{0}(X), \\ 0,&\text{otherwise}.\end{cases} \tag{23}\]
In fact, the spin polarized state has many representations within our RBM ansatz in Eq. (17), including representations that are not just related by the gauge transformations in Eq. (18). For instance, the association \(j\to j_{0}(X)\) of a spin to a plaquette and star can be changed, e.g., by using the "easternmost" spin. As discussed in more detail in Appendix A.2, this redundancy is a consequence of the product from of \(\psi_{\rm rbm}(\mathbf{\sigma})\) in Eq. (17) and the fact that \(\psi_{\rm rbm}(\mathbf{\sigma})\) is _exactly_ zero if there is a single \(j\) with \(\sigma_{j}=-1\); consequently, it is a special feature of the simple product nature of the spin-polarized ground state. While in general there can still be additional redundancies besides the aforementioned gauge transformations, we do not expect such a structured set of redundancy to hold for generic states. There are various ways of resolving this issue. The most straightforward one is to replace the simple overlap measure \(S_{\rm n}\) in Eq. (11) by the direct overlap \(S_{\rm q}\) in Eq. (10) for a certain fraction of pairs of samples \(l\) and \(l^{\prime}\). If this fraction is large enough, the DM algorithm will be able recognize that clusters of network parameters that might be distinct according to \(S_{\rm n}\) actually correspond to identical wave functions. We refer to Appendix A.3 where this is explicitly demonstrated. We note, however, that kernel PCA will not work anymore in this case; it will incorrectly classify connected samples as distinct as it's based on the variance of the data rather than connectivity. For simplicity of the presentation, we use \(S_{\rm q}\) for all states in the main text and focus on DM.
Figure 6: DM spectra for low-energy ensembles with \(T\!=\!0.3\) at finite field \(h\). (a) First 10 eigenvalues for various field values \(h\!=\!0.475,0.55,0.575,0.6,0.7\) at \(\epsilon\!=\!0.05\). The dot marker (\(h\!=\!0.475\)) shows that the eigenvalue spectra have four-fold degeneracy, indicating signature for topological order. In comparison, for spectra marked by the the triangular markers (\(h\geq 0.55\)), such degeneracy is absent. A transition field value \(h_{t}\simeq 0.55\) is identified by observing that a gap opens in the degenerate eigenvalue spectra. This is consistent with what we have observed in the fidelity using the same dataset [see Appendix B.1]. (b) Projected eigenvectors onto the first two components for \(h\!=\!0.475\). The color encodes \(\langle\overline{W}_{1(2)}\rangle\) with the color scheme of Fig. 4(c). The black cross marks the \(k\)-means centers. (c) Same as (b) for \(h=0.7\). (d) Expectation for averaged straight Wilson loops \(\langle\overline{W}_{1(2)}\rangle\) along two directions for the states in (b). The color encodes the clustering results from \(k\)-means in the projected subspace of the eigenvectors shown in (b). (e) Same as (d) for ensemble shown in (c).
The DM spectrum for large magnetic field, \(h=1\), and low temperatures, \(T=0.1\), is shown in Fig. 5(d). Clearly, there is no value of \(\epsilon\) for which there is more than one eigenvalue close to \(1\) while exhibiting a gap to the rest of the spectrum. This shows that, as expected, the magnetic field \(h\) has lead to the loss of topological order.
To study with our DM algorithm the associated phase transition induced by \(h\), we repeat the same procedure for various different values of \(h\). The resulting spectra for selected \(h\) are shown in Fig. 6(a). We see that there are still four sectors for \(h=0.55\) in the data that are absent for \(h=0.575\) and larger values. While the associated critical value of \(h\) is larger than expected [69; 70; 71], this is not a shortcoming of the DM algorithm but rather a consequence of our simple local variational ansatz in Eq. (17). By computing the fidelity as well as loop-operator expectation values, we can see that a critical value around \(h=0.55\) is the expected answer for our dataset (see Appendix B.1). More sophisticated ansatze for the wavefunction are expected to yield better values, but this is not the main focus of this work. More importantly, we see in Fig. 6(b) that the DM clustering of the states correctly reproduces the clustering according to the averaged loop operator expectation values \(\langle\overline{W}_{j}\rangle\) (again indicated with color). Alternatively, this can be seen in Fig. 6(d) where \(\langle\overline{W}_{j}\rangle\) is indicated for the individual samples. Using four different colors for the four different clusters identified by the DM, we see that all states are clustered correctly. As expected based on the eigenvalues, there are no clear clusters anymore for larger \(h\), Fig. 6(c); nonetheless, naively applying \(k\)-means clustering in \(\psi_{1,2,3}\) manages to discover some residual structure of the wavefunctions related to \(\langle\overline{W}_{j}\rangle\) as demonstrated in Fig. 6(e).
## V Summary and discussion
In this work, we have described an unsupervised ML algorithm for quantum phases with topological order. We use neural network parameters to efficiently represent an ensemble of quantum states, which are sampled according to their energy expectation values. To uncover the structure of the superselection sectors in the quantum states, we used the dimensional reduction technique of diffusion map and provided a kernel defined in terms of network parameters. As opposed to a kernel based on the overlap of wavefunctions (or other quantum mechanical similarity measures of states for that matter), this metric can be evaluated efficiently (within polynomial time) on a classical computer.
We illustrated our general algorithm using a quasi-local restricted Boltzmann machine (RBM) and the toric code model in an external field; the choice of network ansatz was inspired by previous works [58; 59] showing the existence of efficient representations of the low-energy spectrum in terms of RBMs. Allowing for spatially inhomogeneous RBM networks, we identified the "gauge symmetries" of the ansatz, i.e., the set of changes in the network parameters that do not change the wavefunction, apart from trivial global phase factors. We carefully designed a similarity measure that is gauge invariant--a key property as, otherwise, identical wavefunctions represented in different gauges would be falsely identified as being distinct. We showed that the resultant unsupervised diffusion-map-based embedding of the wavefunctions is consistent with the expectation values of loop operators; it correctly captures the presence of superselection sectors and topological order at low energies and fields, as well as the lack thereof when higher-energy states are involved and/or the magnetic field is increased. We also verified our results using the full quantum mechanical overlap of wavefunctions as similarity measure.
On a more general level, our analysis highlights the importance of the following two key properties of diffusion maps: first, in the presence of different topological sectors, the leading eigenvectors of diffusion maps capture the connectivity rather than, e.g., the variance as is the case for PCA. For this reason, the clustering is still done correctly even if a fraction of pairs of wavefunctions are incorrectly classified as being distinct due to the usage of an approximate similarity measure. This is why complementing the neural-network similarity measure, which has additional, state-specific redundancies in the large-field limit, by direct quantum mechanical overlaps for a certain fraction of pairs of states is sufficient to yield the correct classification. The second key property is that diffusion map is a kernel technique. This means that the actual machine learning procedure does not require the full wavefunctions as input; instead, only (some measure of) the kernel of all pairs of wavefunctions in the dataset is required. We have used this to effectively remove the gauge redundancy in the RBM parametrization of the states by proper definition of the network similarity measure in Eq. (20). Since the evaluation of full quantum mechanical similarity measures, like the wavefunction overlap, are very expensive on classical computers, an interesting future direction would be to use the emerging quantum-computing resources to evaluate a similarity measure quantum mechanically. This could then be used as input for a diffusion-map-based clustering.
We finally point out that the ensemble of states we used in this work, which was based on sampling states according to their energy with respect to a Hamiltonian, is only one of many possibilities. The proposed technique of applying diffusion map clustering using a gauge-invariant kernel in terms of network parameters of a variational description of quantum many-body wavefunctions can be applied more generally, in principle, to any ensemble of interest. For instance, to consider arbitrary local perturbations, one could generate an ensemble using finite depth local unitary circuits. Alternatively, one could generate an ensemble based on (Lindbladian) time-evolution to probe the stability of topological order against time-dependent perturbations or the coupling to a bath. We leave the investigation of such possibilities for future works.
Code and data availability
The Monte Carlo simulations in this work were implemented in JAX [73]. Python code and data will be available at [https://github.com/teng10/ml_toric_code/](https://github.com/teng10/ml_toric_code/).
## Acknowledgements
Y.T. acknowledges useful discussions with Dmitrii Kochkov, Juan Carrasquilla, Khadijeh Sona Najafi, Maine Christos and Rhine Samajdar. Y.T. and S.S. acknowledge funding by the U.S. Department of Energy under Grant DE-SC0019030. M.S.S. thanks Joaquin F. Rodriguez-Nieva for a previous collaboration on DM [12]. The computations in this paper were run on the FASRC Cannon cluster supported by the FAS Division of Science Research Computing Group at Harvard University.
## Appendix A Variational Ansatz: Restricted Boltzmann Machine
The variational ansatz in Eq. (17) is a _further-restricted_ restricted Boltzmann machine (RBM), first introduced by Ref. [58]. RBM is a restricted class of Boltzmann machine with an "energy" function \(E_{\text{RBM}}(\boldsymbol{\sigma},\boldsymbol{h};\Lambda)\) dependent on the network parameters \(\Lambda\), where \(\boldsymbol{\sigma}\) are physical spins and \(\boldsymbol{h}=\{h_{1},h_{2},\cdots,h_{N}\mid h_{i}=\pm 1\}\) are hidden spins (or hidden neurons) that are Ising variables. The parameters \(\Lambda\) define the coupling strength among the physical and hidden spins. The restriction in RBM is that the couplings are only between the physical spin \(\sigma_{i}\) and hidden spin \(h_{j}\) with strength \(-w_{ij}\), so that the "energy" function takes the form \(E_{\text{RBM}}(\boldsymbol{\sigma},\boldsymbol{h};\Lambda)\!=\!-\sum_{i}a_{i} \sigma_{i}-\sum_{i}b_{i}h_{i}-\sum_{ij}w_{ij}\sigma_{i}h_{j}\). It is a generative neural network that aims to model a probability distribution \(\mathbb{P}\) based on the Boltzmann factor,
\[\mathbb{P}(\boldsymbol{\sigma};\Lambda) =\frac{1}{Z}\sum_{\boldsymbol{h}}e^{-E_{\text{RBM}}(\boldsymbol{ \sigma},\boldsymbol{h};\Lambda)}, \tag{18a}\] \[\text{normalization}\quad Z =\sum_{\boldsymbol{\sigma},\boldsymbol{h}}e^{-E_{\text{RBM}}( \boldsymbol{\sigma},\boldsymbol{h};\Lambda)}. \tag{18b}\]
For the task of modeling a quantum wavefunction amplitude \(\psi(\boldsymbol{\sigma};\Lambda)\), RBMs can be used as a variational ansatz by extending the parameters \(\Lambda\) to complex numbers.
Further restricting parameters to the interlayer connections to the plaquette and star geometry in the toric code model [cf. Fig. 2(c)] and taking all parameters \(\Lambda\) to be purely imaginary, we recover the ansatz in Eq. (17) (up to normalization factor \(\widetilde{Z}\)),
\[\psi(\boldsymbol{\sigma};\Lambda) =\frac{1}{\widetilde{Z}}\sum_{X=P,S}\sum_{h_{X}=\pm 1}e^{-i \sum_{X}(w_{Xj}\sigma_{j}+b_{X})h_{X}},\] \[=\frac{1}{\widetilde{Z}}\prod_{X=P,S}\cos(\sum_{j\in X}w_{Xj} \sigma_{j}+b_{X}). \tag{19}\]
The \(\cos(\cdot)\) factors come from summing over the hidden neurons and the ansatz factorizes into the product of individual plaquette (star) terms because of the restricted connections. The estimation of physical observables of a wave function based on the RBM ansatz requires Monte Carlo sampling procedure which we discuss in Appendix B.
### Ground states representation in different topological sectors
Placing the toric code model in Eq. (16) on the torus geometry, it is useful to define the loop operators,
\[\hat{W}_{1} =\prod_{i\in\bar{l}_{x}}\hat{s}_{i}^{x},\quad\hat{W}_{2}=\prod_{i \in\bar{l}_{y}}\hat{s}_{i}^{x}, \tag{20a}\] \[\hat{V}_{1} =\prod_{i\in l_{x}}\hat{s}_{i}^{z},\quad\hat{V}_{2}=\prod_{i\in l _{y}}\hat{s}_{i}^{z}, \tag{20b}\]
where \(l_{x,y}\) is a non-contractible loop along \(x\), \(y\) direction, and \(\bar{l}_{x,y}\) is similar on the dual lattice. Note the loop operators along two directions do not commute with each other as \(\left[\hat{W}_{1},\hat{V}_{2}\right]\neq 0\) and \(\left[\hat{W}_{2},\hat{V}_{1}\right]\neq 0\). However, since the hamiltonian commute with these loop operators \(\left[\hat{W}_{1,2},\hat{H}_{\text{tc}}\right]\!=\!\left[\hat{V}_{1,2},\hat{H }_{\text{tc}}\right]\!=\!0\), it follows that the ground state subspace is four-fold degenerate and spanned by the eigenvectors of the loop operators.
Suppose we work in the eigenbasis of \(\hat{W}_{1,2}\); we define the four orthogonal ground states \(\left|\psi_{i}\right\rangle(i=0,1,2,3)\) that
Figure 7: RBM representations of the four toric code ground states in the eigenbasis [Eq. (18)] of loop operators \(\hat{W}_{1},\hat{W}_{2}\) in Eq. (20a).
span \(\mathcal{L}\) as,
\[\hat{W}_{1}\ket{\psi_{0}}=\ket{\psi_{0}},\quad\hat{W}_{2}\ket{\psi_{0} }=\ket{\psi_{0}}, \tag{10a}\] \[\hat{W}_{1}\ket{\psi_{1}}=\ket{\psi_{1}},\quad\hat{W}_{2}\ket{\psi_{1 }}=-\ket{\psi_{1}},\] (10b) \[\hat{W}_{1}\ket{\psi_{2}}=\ket{\psi_{2}},\quad\hat{W}_{2}\ket{\psi_{2 }}=-\ket{\psi_{2}},\] (10c) \[\hat{W}_{1}\ket{\psi_{3}}=-\ket{\psi_{3}},\quad\hat{W}_{2}\ket{\psi_ {3}}=-\ket{\psi_{3}}. \tag{10d}\]
The RBM ansatz in Eq. (11) can represent eigenstates of \(\hat{W}_{1,2}\) with eigenvalues \((W_{1},W_{2})=(\pm 1,\pm 1)\). Ref. [58] gave an representation of \(\ket{\psi_{3}}\) with parameters,
\[w_{Pj}=\frac{\pi}{4},\quad b_{P}=0,\quad w_{Sj}=\frac{\pi}{2},\quad b_{S}=0.\] (11a) On a system with odd number of sites along \[x\] and \[y\] direction, the other three degenerate states can be realized analogously by fixing the weights associated to stars to be \[w_{Sj}\!=\!0,b_{S}\!=\!0\]. Then the four states can be chosen by changing the \[w_{Pj}\] and \[b_{P}\] as shown in Fig. 7.
### Network parameter redundancies in polarized phase
In Sec. III, we identified a set of gauge transformations Eq. (18) that leave a generic wavefunction parameterized by the RBM ansatz in Eq. (17) invariant up to a global phase [Eq. (13)]. Such gauge transformations should be taken into consideration when evaluating the similarity measure \(S_{n}\). Moreover, we have numerically verified that for states generated close to the exact toric code wave functions, \(S_{n}\) is a good proxy for the quantum measure \(S_{\rm q}\) after explicit removals of such redundancies via \(S_{n}\) in Eq. (19). However, as alluded to in the discussions of the large-\(h\) limit, there are state-specific redundancies that are generally not related by the gauge transformations in Eq. (18).
Let us illustrate such redundancies here for the polarized state \(\ket{\Psi}=\ket{1,\cdots,1}_{z}\) which has all spin pointing up in the \(z\)-basis. Notice that there is the same number of \(\cos(\cdot)\) factors in the wavefunction ansatz as the number of spins. As a result, we can define a "_covering_" by assigning each individual spin to a single factor, and choosing the weights to ensure all spins are pointing up. Any such "covering" is a valid representation of the polarized state. For example, one representation is given by,
\[b_{P}=b_{S}=-\frac{\pi}{4},\ \ w_{Sj}=\begin{cases}\frac{\pi}{4},&j=j_{s}(S),\\ 0,&\text{otherwise},\end{cases}\quad\text{and}\ \ \ w_{\rm Pj}=\begin{cases}\frac{\pi}{4},&j=j_{n}(P),\\ 0,&\text{otherwise}.\end{cases} \tag{11b}\]
where \(j_{s}(S)\) denotes the "southmost" spin in the star \(S\) and \(j_{n}(P)\) denotes the "northmost" spin in the plaquette \(P\) [see Fig. 8(a)]. Any such coverings of the spins will correspond to a polarized state. For example, performing a "rotation" leads to a different covering in Fig. 8(b). Actually, because most amplitudes in local-\(z\) basis are \(0\) so there are so few constraints in the wave function amplitudes, a continuous set of weights exist to represent the polarized state, so there are an infinite amount of redundancies for completely polarized state.
To illustrate this, let us consider the simplest example of just two spins [the boxed region in Fig. 8(c)] with the same RBM ansatz, which can be easily generalized to more spins. For two spins, such ansatz is given by,
\[\psi_{\Lambda}(\sigma_{A},\sigma_{B})=\cos(b_{S}+w_{SA}\sigma_{A}+w_{SB} \sigma_{B})\cos(b_{P}+w_{PA}\sigma_{A}+w_{PB}\sigma_{B}), \tag{12}\]
where the weights \(\Lambda=\{\Lambda_{S}=\{b_{S},w_{SA},w_{SB}\},\,\Lambda_{P}=\{b_{P},w_{PA},w_{PB }\}\}\) with \(\Lambda_{Xj}\in[0,\pi)\) for \(X=S\) or \(P\) fully determine the two-qubits physical state. For example, the following two choices of weights [\(\Lambda_{1}\) and \(\Lambda_{2}\) pictorially in
Figure 8: (a-b) Two RBM representations Eq. (10) of the polarized state. (c) A path that connects the presentation for two spins in (a-b), which is explicitly shown in Table. 1.
Fig. 8(c)] both parametrize the polarized state:
\[\Lambda_{1}=\{b_{S}=-\frac{\pi}{4},w_{SA}=0,w_{SB}=\frac{\pi}{4},b_{P} =-\frac{\pi}{4},w_{PA}=\frac{\pi}{4},w_{PB}=0\}, \tag{10a}\] \[\Lambda_{2}=\{b_{S}=-\frac{\pi}{4},w_{SA}=\frac{\pi}{4},w_{SB}=0,b _{P}=-\frac{\pi}{4},w_{PA}=0,w_{PB}=\frac{\pi}{4}\},\] (10b) \[\psi_{\Lambda_{1,2}}=\begin{cases}1,&\sigma_{A}=\sigma_{B}=1,\\ 0,&\text{otherwise}.\end{cases} \tag{10c}\]
Now to illustrate the continuous redundancies, we construct a path in the parameter space to go from \(\Lambda_{1}\) to \(\Lambda_{2}\). The path is composed of three steps [Fig. 8(c)],
\[\Lambda_{1}\xrightarrow{\text{path}\,1}\Lambda_{3}\xrightarrow{\text{path}\,2 }\Lambda_{4}\xrightarrow{\text{path}\,3}\Lambda_{2}, \tag{11}\]
where the intermediate parameters are given by,
\[\Lambda_{3}=\{b_{S}=0,w_{SA}=\frac{\pi}{4},w_{SB}=-\frac{\pi}{4}, b_{P}=-\frac{\pi}{4},w_{PA}=\frac{\pi}{4},w_{PB}=0\}, \tag{12}\] \[\Lambda_{4}=\{b_{S}=0,w_{SA}=\frac{\pi}{4},w_{SB}=-\frac{\pi}{4}, b_{P}=-\frac{\pi}{4},w_{PA}=0,w_{PB}=\frac{\pi}{4}\}. \tag{13}\]
Along each path component, referred to as path 1 through 3 in Table 1, the parameters of \(S\) (or \(P\)) are varied and the other held fixed, while remaining in the exactly polarized state. The path is continuous except at a singular point on path 1 where the wave function vanishes at \(\Lambda_{\text{singular}}=\{b_{S}=0,w_{SA}=\frac{\pi}{4},w_{SB}=-\frac{\pi}{4},b_{P}=-\frac{\pi}{4},w_{PA}=\frac{\pi}{4},w_{PB}=0\}\).
### Resolving the special redundancies
In Appendix A.2, we explicitly showed that there can be a large set of redundancies given a polarized state. Hence, for simplicity in the main text, we have used the direct overlap \(S_{q}\) in Eq. (10) as the relevant measure at finite field values. As discussed in the main text, a straightforward way to alleviate the redundancies in the similarity measure \(S_{n}\) in Eq. (19) of the network parameters is to complement it with the direct overlap. By using a combination of both measures, we are able to reduce the amount of computational cost of the direct overlap
\begin{table}
\begin{tabular}{|c||c|c|c|} \hline Path 1 & \(w_{SB}=b_{S}+w_{SA}-\frac{\pi}{2}\) & \(\Lambda_{P}\) fixed & product \(\psi=\psi_{S}\times\psi_{P}\) \\ \(\Lambda_{1}\rightarrow\Lambda_{3}\) & \(w_{SA}:[0,\frac{\pi}{4}),w_{SB}:[\frac{\pi}{4},-\frac{\pi}{4}),b_{S}:[-\frac{ \pi}{4},0)\) & \(w_{PA}=\frac{\pi}{4},w_{PB}=0,b_{P}=-\frac{\pi}{4}\) & \\ \hline \hline \(\cos(b_{X}+w_{XA}+w_{XB})\) & \(\neq 0\) if \(b_{S}+w_{SA}\neq\frac{n}{2}\pi,n\in\mathbb{Z}\to 0\to 1\) & 1 & \(\to 0\to 1\) \\ \hline \(\cos(b_{X}+w_{XA}-w_{XB})\) & & & \(0\) ✓ \\ \hline \(\cos(b_{X}-w_{XA}+w_{XB})\) & \(\cos(2b_{S}-\frac{\pi}{2})\to 0\) & & \(0\) ✓ \\ \hline \(\cos(b_{X}-w_{XA}-w_{XB})\) & & & \(0\) ✓ \\ \hline \hline Path 2 & \(\Lambda_{S}\) fixed & \(w_{PB}=b_{P}-w_{PA}+\frac{\pi}{2}\) & & \\ \(\Lambda_{3}\rightarrow\Lambda_{4}\) & \(w_{SA}=\frac{\pi}{4},w_{SB}=-\frac{\pi}{4},b_{S}=0\) & \(w_{PA}:[\frac{\pi}{4},0],w_{PB}:[0,\frac{\pi}{4}],b_{P}=-\frac{\pi}{4}\) & \\ \hline \(\cos(b_{X}+w_{XA}+w_{XB})\) & 1 & 1 & 1 \\ \hline \(\cos(b_{X}+w_{XA}-w_{XB})\) & 0 & \(\cos(2w_{PA}-\frac{\pi}{2})\to 0\) & 0 ✓ \\ \hline \(\cos(b_{X}-w_{XA}+w_{XB})\) & 0 & & \(0\) ✓ \\ \hline \(\cos(b_{X}-w_{XA}-w_{XB})\) & & & \(0\) ✓ \\ \hline \hline Path 3 & \(w_{SB}=-b_{S}+w_{SA}+\frac{\pi}{2}\) & \(\Lambda_{P}\) fixed & & \\ \(\Lambda_{4}\rightarrow\Lambda_{2}\) & \(w_{SA}=\frac{\pi}{4},w_{SB}:(-\frac{\pi}{4},0],b_{S}:(0,-\frac{\pi}{4})\) & \(w_{PA}=0,w_{PB}=\frac{\pi}{4},b_{P}=-\frac{\pi}{4}\) & \\ \hline \(\cos(b_{X}+w_{XA}+w_{XB})\) & 1 & 1 & 1 \\ \hline \(\cos(b_{X}+w_{XA}-w_{XB})\) & & 0 & 0 ✓ \\ \hline \(\cos(b_{X}-w_{XA}+w_{XB})\) & 0 & & 0 ✓ \\ \hline \(\cos(b_{X}-w_{XA}-w_{XB})\) & & & 0 & ✓ \\ \hline \end{tabular}
\end{table}
Table 1: A path going from \(\Lambda_{1}\) to \(\Lambda_{2}\) is composed of three steps. Path 1 (\(\Lambda_{1}\rightarrow\Lambda_{3}\)) is smooth except at the point \(w_{SA}=\frac{\pi}{4},w_{SB}=-\frac{\pi}{4},b_{S}=0\), where the wavefunction vanishes. This is further denoted by the red arrows first decreasing to 0 before increasing to 1 in the first row. Path 2 and 3 are both smooth. The last column illustrates that the wavefunction \(\psi\) remains in the polarized state along the path.
by a fraction as the similarity is easy to compute. More specifically, we define a mixed measure \(S_{m}\) by replacing a random fraction (given by \(f\)) of the similarity measure pairs \(\left\{l,l^{\prime}\right\}\) by a rescaled overlap measure \(\widetilde{S}_{q}\) such that,
\[S_{m}(l,l^{\prime})=\begin{cases}\widetilde{S}_{q}(l,l^{\prime})&\text{with probability }f,\\ S_{n}(l,l^{\prime})&\text{with probability }1-f.\end{cases} \tag{38}\]
The following rescaling of the overlap measure \(S_{q}\) is necessary as we want to include the two measures on an equal-footing given by,
\[\widetilde{S}_{q} =\frac{S_{q}-n_{q}}{m_{q}-n_{q}}\cdot(m_{n}-n_{n})+n_{n}, \tag{39a}\] \[m_{q} =\max(S_{q}),\quad n_{q}=\min(S_{q}),\] (39b) \[m_{n} =\max(S_{n}),\quad n_{n}=\min(S_{n}). \tag{39c}\]
For example, we see that the minimum of the rescaled overlap is the same as the minimum of the similarity \(\min(\widetilde{S}_{q})=\min(S_{n})\).
In Fig. 9, we demonstrate that by using a mixed measure with a fraction of \(f=0.4\) replacement, our algorithm with DM is able to identify the presence (indicated by the shaded blue region for smaller field values \(h=0.475\) and \(h=0.55\)) and absence (\(h=0.7\)) of superselection sectors across various field values, consistent with the predictions of the algorithm using direct overlap (shown in Fig. 6). We note that in the case with a mixed measure, DM is a natural technique as the algorithm looks for connectivity; whereas kernel PCA would fail to identify such transition (since a fraction of pairs of wave functions are incorrectly considered to be dissimilar by \(S_{n}\), the leading kernel PCA components still show four separated clusters up to the largest magnetic field, \(h=1\)).
## Appendix B Optimization with Variational Monte Carlo
To find the ground state \(\ket{\Psi(\Lambda^{0})}\propto\sum_{\mathbf{\sigma}}\psi(\mathbf{\sigma};\Lambda^{0}) \ket{\mathbf{\sigma}}\), we wish to minimize the energy expectation \(\bra{E}=\bra{\Psi}\hat{H}\ket{\Psi}/\bra{\Psi}\) (omitting the variational parameters \(\Lambda^{0}\) in this section), which is bounded by the ground state energy by the variational principle. An exact computation \(\bra{E}_{\text{exact}}\) is costly as the summation enumerates over exponentially many spin configurations \(\mathbf{\sigma}\) as the system size increases. Here we use variational Monte Carlo (VMC) importance sampling algorithm to estimate such expectation values. The idea is to compute relative probability between different configurations and sample from the true wavefunction probability density \(\ket{\psi(\mathbf{\sigma})}^{2}\), without having to compute \(\ket{\psi(\mathbf{\sigma})}^{2}\) for all \(\mathbf{\sigma}\). To perform this algorithm, we initialize \(M\) random configurations \(\{\mathbf{\sigma}_{i}\}_{i=1}^{M}\) and continue each with random walks based on previous configurations, hence forming \(M\) Markov chains.
In particular, the Metropolis-Rosenbluth algorithm [74] is used to propose the next configuration \(\mathbf{\sigma}^{\prime}_{i}\) that is locally connected to \(c_{i}\) according to function \(g(\mathbf{\sigma}^{\prime}|\mathbf{\sigma})\). For the toric code model, we use two types of proposals: spin flips and vertex flips. Here, we will assume a probability of \(p\) for proposing spin flips and analogously \(1-p\) for vertex flips that are equally likely at all sites:
\[g(\mathbf{\sigma}^{\prime}|\mathbf{\sigma})=\begin{cases}\frac{p}{n_{s}},&\text{for spin flips}\\ \frac{1-p}{n_{v}},&\text{for vertex flips}\end{cases} \tag{40}\]
where \(n_{s}\) and \(n_{v}\) are the number of all possible spin and vertex flips. The acceptance of \(\mathbf{\sigma}^{\prime}\) is determined by a probability,
\[\mathbb{P}_{\text{accept}}(\mathbf{\sigma}\rightarrow\mathbf{\sigma}^{\prime})=\min \left(|\frac{\psi(\mathbf{\sigma}^{\prime})}{\psi(\mathbf{\sigma})}|^{2},\,1\right). \tag{41}\]
Figure 9: DM spectra for different field values \(h=0.475,0.55,0.7\) at \(T=0.3\) using a mixed similarity measure \(S_{m}\) with a fraction \(f=0.4\) in Eq. (38). The blue shaded regions highlight the existence of a range of \(\epsilon\) with spectral gap between the degenerate eigenvalues and the decaying eigenvalues, indicating underlying superselection sectors. As the field value approaches the transition field \(h_{c}\), the range of such region shrinks and disappears at high field \(h=0.7\), indicating the absence of sectors.
The random walks will be repeated long enough so that the final configurations at the tail of the chains \(\Sigma_{\text{MC}}=\{\mathbf{\sigma}_{f}\}_{i=b}^{M}\) approximate samples drawn from the probability distribution \(|\psi(\mathbf{\sigma})|^{2}\). A certain number \(b\) of walkers in each chain are discarded to reduce the biases from initialization of the chains. Then the expectation of an observable \(\hat{O}\) is given by,
\[\left\langle\hat{O}\right\rangle_{\text{MC}} =\frac{\sum_{\mathbf{\sigma}}\psi(\mathbf{\sigma})^{*}\langle\mathbf{\sigma} |\hat{O}|\Psi\rangle}{\sum_{\mathbf{\sigma}}|\psi(\mathbf{\sigma})|^{2}}, \tag{10a}\] \[=\frac{\sum_{\mathbf{\sigma}}|\psi(\mathbf{\sigma})|^{2}\frac{\langle\mathbf{ \sigma}|\hat{O}|\Psi\rangle}{\psi(\mathbf{\sigma})}}{\sum_{\mathbf{\sigma}}|\psi(\mathbf{ \sigma})|^{2}},\] (10b) \[=\frac{1}{M}\sum_{\mathbf{\sigma}\in\Sigma_{\text{MC}}}\frac{\langle \mathbf{\sigma}|\hat{O}|\Psi\rangle}{\psi(\mathbf{\sigma})}. \tag{10c}\]
Defining a local value of the operator \(\hat{O}\) as,
\[O_{\text{loc}}=\frac{\langle\mathbf{\sigma}|\hat{O}|\Psi\rangle}{\psi(\mathbf{\sigma} )}, \tag{11}\]
then the Monte Carlo estimation is the average of the local values in the Markov chain: \(\left\langle\hat{O}\right\rangle_{\text{MC}}=\frac{1}{M}\sum_{\mathbf{\sigma}\in \Sigma_{\text{MC}}}O_{\text{loc}}\).
Next, to minimize \(\langle E\rangle\), we can compute its gradient with respect to the weights \(\Lambda^{0}\) in terms of the local energy \(E_{\text{loc}}\) and wavefunction amplitude derivative \(D_{i}\):
\[\partial_{\Lambda_{i}}\langle E\rangle =\langle E_{\text{loc}}D_{i}\rangle-\langle E_{\text{loc}} \rangle\langle D_{i}\rangle \tag{12a}\] \[E_{\text{loc}} =\frac{\langle\mathbf{\sigma}|\,H\,|\Psi\rangle}{\psi(\mathbf{\sigma})}, \quad D_{i}=\frac{\partial_{\Lambda_{i}}\psi(\mathbf{\sigma})}{\psi(\mathbf{\sigma})} \tag{12b}\]
Finally, we use gradient descent with learning rate \(\lambda\),
\[\Lambda_{i}\rightarrow\Lambda_{i}-\lambda\partial_{\Lambda_{i}}\langle E\rangle, \tag{13}\]
to minimize the energy expectation value. The gradient descent is performed by using an adaptive Adam optimizer [75]. We repeat this training step until empirical convergence.
Note that the RBM ansatz can get stuck in local minima. To find the toric code ground state, we initialize the network parameters close to the analytic solutions in Eq. (10).
### Fidelity
To find the approximate ground states at finite field values \(h\) with step size \(\Delta h\), we initialize the weights to be those from the previous field value \(h-\Delta h\), and then use the current optimized weights as the initialization for the next step \(h+\Delta h\). A good indication of a quantum phase transition is by inspecting the fidelity \(\mathcal{F}(h)\) defined as,
\[\mathcal{F}(h)=|\langle\psi(h)|\psi(h+\Delta h)\rangle|^{2}. \tag{14}\]
The critical field \(h_{c}\) is identified as a dip in the fidelity, indicating an abrupt change in the ground state wavefunction. A field value of \(h_{c}\simeq 0.57\) (at dashed line in Fig. 10) is found for the RBM ansatz. Note that one can get more accurate field value by including loop expectations in the ansatz as done in Ref. [59].
## Appendix C Ensemble generation
Using the algorithm outlined in Sec. 1, we can generate ensembles that deviate from the initial optimized parameters by setting hyper-parameter \(T=0.1,0.3,1\). The other choices of hyper-parameters for the ensembles are number of independent chains \(k=2\), length of each chain \(n=250\), and number of samples kept \(m=n\). The parameter proposal function we use consists of with probability \(p_{m}\) randomly apply minus sign or randomly adding local noise at a single spin site \(\jmath\). More precisely,
\[f(\Lambda,\xi) =\begin{cases}f_{-,\jmath},&\text{with probability}:p_{m},\\ f_{\text{local},\jmath},&\text{with probability}:1-p_{m},\end{cases} \tag{15a}\] \[f_{-,\jmath} =\begin{cases}-(\Lambda)_{i},&i\in\jmath\\ (\Lambda)_{i},&i\not\in\jmath\end{cases}\] (15b) \[f_{\text{local},\jmath} =\begin{cases}\text{uniform}(0,\xi)+(\Lambda)_{\text{i}},&\text{ i}\in\jmath\\ (\Lambda)_{i},&i\not\in\jmath\end{cases} \tag{15c}\]
In the exact toric code state, \(f_{-,\jmath}\) corresponds to act \(\sigma_{x}\) operator at site \(\jmath\) to create a pair of m-particles. In the trivial phase, depending on the parametrization of the state, \(f_{-,\jmath}\) could correspond to a single spin flip at site \(\jmath\). The hyperparameters are chosen to be \(p_{m}=0.3\) and \(\xi=0.2\). In Fig. 11, we visualize the ensembles by computing their loop expectations \(\langle\overline{W}_{j}\rangle\) at different field values.
Figure 10: Fidelity \(\mathcal{F}\) as a function of field \(h\). The red dashed line is drawn to guide the eye, where the dip in fidelity indicates the critical field value \(h_{c}\simeq 0.57\). |
2303.03496 | Wind Turbine Gearbox Fault Detection Based on Sparse Filtering and Graph
Neural Networks | The wind energy industry has been experiencing tremendous growth and
confronting the failures of wind turbine components. Wind turbine gearbox
malfunctions are particularly prevalent and lead to the most prolonged downtime
and highest cost. This paper presents a data-driven gearbox fault detection
algorithm base on high frequency vibration data using graph neural network
(GNN) models and sparse filtering (SF). The approach can take advantage of the
comprehensive data sources and the complicated sensing networks. The GNN
models, including basic graph neural networks, gated graph neural networks, and
gated graph sequential neural networks, are used to detect gearbox condition
from knowledge-based graphs formed using wind turbine information. Sparse
filtering is used as an unsupervised feature learning method to accelerate the
training of the GNN models. The effectiveness of the proposed method was
verified on practical experimental data. | Jinsong Wang, Kenneth A. Loparo | 2023-03-06T21:08:07Z | http://arxiv.org/abs/2303.03496v1 | # Wind Turbine Gearbox Fault Detection Based on Sparse Filtering and Graph Neural Networks
###### Abstract
The wind energy industry has been experiencing tremendous growth and confronting the failures of wind turbine components. Wind turbine gearbox malfunctions are particularly prevalent and lead to the most prolonged downtime and highest cost. This paper presents a data-driven gearbox fault detection algorithm base on high frequency vibration data using graph neural network (GNN) models and sparse filtering (SF). The approach can take advantage of the comprehensive data sources and the complicated sensing networks. The GNN models, including basic graph neural networks, gated graph neural networks, and gated graph sequential neural networks, are used to detect gearbox condition from knowledge-based graphs formed using wind turbine information. Sparse filtering is used as an unsupervised feature learning method to accelerate the training of the GNN models. The effectiveness of the proposed method was verified on practical experimental data.
Keywords:Wind energy, fault detection, graph neural network, sparse filtering
## 0 Introduction
The wind market of 2021 trend data shows that the global market has an installed base of 590-GW that delivers clean energy to the consumers representing a 10% increase compared with 2020 [1]. China and the United States have the largest wind energy capacities at 211,392 MW and 96,433 MW, respectively [1]. Average turbine size (rotor diameter, and hub height) and capacity (nameplate) are continuing a long-term growth trend. Comparing utility-scale wind turbines in 2010 and 2018, in 2018 the average diameter is 116 (m) and the average hub height is 88 (m) (a 35% increase) while the average nameplate capacity is 2.4 MW (a 60% increase) [1]. If current trends continue, wind energy can save consumers $280 billion, reduce 12.3 gigatons of greenhouse gases emission, preserve 260 million gallons of water, increase tax revenue by $3.2 billion, and support 600,000 jobs by 2050 [2].
Wind energy reliability issues are a result of the rapidly growing market and wind turbine technology development. Higher wind energy reliability can improve operation and maintenance (O&M) costs, capacity factors, levelized cost, and grid interconnection [3]. The failure of wind turbine components is a critical reliability issue; downtime caused by component failures has harmful effects economic and operational aspects [4]. Gerbox malfunctions have the most prolonged downtime, the most expensive O&M costs, and the most substantial impact on grid operations [5]. Gerbox vibration is monitored to assist with wind turbine health management and avoid malfunctions [6].
Internet of Things (IoT) has been an attracting technology for real-time monitoring of valuable devices. IoT-based wind turbine Prognostics and Health Management (PHM) is defined as a lifecycle support system, in which, (1) wind turbine data is collected for mission-critical and cost-sensitive components, for example, the gearbox; (2) fault detection, diagnosis, and prognosis are implemented by processing and modeling these data; (3) decision support system is able to interpret these outcomes to accomplishable required operational and maintenance strategies [7]. By 2030, IoT-based wind turbine technologies such as PHM [7] have the potential to increase wind turbine production by 25% and reduce cost by 50% [8]. However, IoT-based PHM systems can be challenging, they require sensing and vibration condition monitoring, analysis of oil debris, and accurate and reliable fault detection, diagnosis, and prediction algorithms to improve decision-making [7].
On the other hand, there are some data-driven approaches that using the sensing data collected from IoT system for fault detection of wind turbines. Neural-network-based approaches have been widely used for fault detection, resulting is high performance in some applications. Samanta presented a genetic algorithm-based artificial neural network for fault detection and diagnosis [9]. In Samanta's work, time-domain statistical features are extracted from the raw vibration data obtained under different loading and operating conditions. This data was then used as input to a multilayer perceptron neural network, and a genetic algorithm is used for feature selection to optimize the classification accuracy. The GA-based ANN achieved 100% classification accuracy, which was better than without the GA and like a GA-based support vector machine (SVM). Amar et al. proposed an ANN-based detection and diagnosis system using frequency-domain features extracted by the Fast Fourier Transform (FFT) [10]. Feature selection from the FFT spectral images was based on a 2D averaging filter and binary image. Saravanan et al. proposed an ANN-based fault detection system
using the discrete wavelet transformation (DWT) [11]. Gaussian Process (GP) is used for wind turbine condition monitoring to identify operational anomalies [12]. An artificial neural network (ANN)-based condition monitoring approach using data from supervisory control and data acquisition system is proposed [13]. Random Forests and XGboost are combined to establish a data-driven wind turbine fault detection framework [14]. Denoising auto encoder (DAE) is also used to develop a multivariate data-driven fault detection framework [15]. Ensemble empirical mode decomposition (EEMD) and independent component analysis (ICA) are proposed to integrate to conduct wind turbine gearbox diagnosis [16]. In order to select the optimal variables, a PCA-based approach is proposed [17]. Compressed sensing is proposed to identify the impulsive feature [18]. These previous works used a typical fault detection and diagnosis process: signal preprocessing, feature extraction and selection, and classification. Lei et al. propose an intelligent fault diagnosis method for mechanical vibration data with unsupervised feature learning [19]. This method contained two stages: unsupervised feature extraction and classification. Sparse filtering [20] was implemented by an unsupervised two-layer neural network based on optimized sparsity distribution from the raw data for feature extraction. The features were then classified using SoftMax regression [21]. As compared to traditional ANN-based models, Lei's work reduced the prior knowledge and related feature extraction expertise that is required. The model had similar efficiency to CNN-based models using comprehensive vibration data but reduced computational cost. Zhang et al. proposed an innovative approach for wind turbine fault detection based on Gaussian Processes (GP) [22] and bootstrap-based ensemble neural networks (BENN) [23] to produce early prediction of the health conditions, with high level accuracy when applied to gearbox oil temperature and the generator winding voltage datasets [24]. However, the hidden domain knowledge of wind turbine such as the structural information of the sensing data, and the features (or the number of features) are still manual selected. A comprehensive review of vibration-based fault diagnosis of wind turbine gearbox is given by Wang et al [25].
To address the issues and opportunities discussed above, this paper presents a hybrid approach of sparse filtering and GNN (SF-GNN) for wind turbine fault detection. In general, SF-GNN identifies the gearbox health condition from a knowledge-based input graph that efficiently conducts high frequency sensor data via the acceleration of sparsening filtering and ontologically describes the wind turbine and gearbox, and generates either a single output of the condition of an individual component and sequential outputs with additional semantical information to the conditions. Three GNN models are deployed in this paper: basic graph neural networks [26][27], Gated Graph Neural Networks (GG-NNs) [28] and Gated Graph Sequence Neural Networks (GGS-NNs) [28]. All three GNN-based models are trained in a supervised manner for node classification. The input graph is modeled by a knowledge-based structure that explicitly incorporates wind turbine terminologies, sensors, and operating conditions.
The motivation to use GNN-based models is to classify the target node by considering complete wind turbine information, that is the composition of wind turbine, and the structure of sensors are utilized to provide robust and reasonable results. In a general sense of sensor network, a large number of sensors are mounted and organized as a complex network. For example, each component of a wind turbine gearbox is monitored by one or more sensor(s) for comprehensive operation state tracking. To detect the fault and malfunctional events based on an induvial or partial sensor(s) is time-consuming and suffering low accuracy outcomes, due to massive data sources. Therefore, this paper claims that deep neural nets with graph input, containing a group of sensors structured by relation types (such as hierarchical and causal), outperforms the methods only considering individual sensors.
Additionally, the literatures reviewed in this paper present highlights of prediction models with input of individual sensor data source or a group of sources but without relations, which causes that the detection outcomes are adapted to a fixed operation situation. However, the fault events are caused by one or more impacts. For example, a data source of the mid shaft is applied for the fault detection, that is, the fault is assumed to occur in such situation of the defect of the shaft instead of considering the comprehensive causes as a real world problem.
The motivation to use sparse filtering is to improve the efficiency of the GNN-based models, specifically to reduce the computational cost of feature learning. the data source used in this work is high frequency vibration data; that is, it presents extra sensitive noise impact than usual data source. Therefore, it is a challenge to use such as raw data input of a deep network, let alone organize such multiple sources in a relational graph. Therefore, sparse filtering is applied to control this issue. It is an unsupervised learning method and drives sparsity the feature matrix of the ultra-high frequency sensor signals, standardize the features to receive equal activation, and qualify the signals data validity to GNNs.
The contributions of this paper are considered that (1) a data-driven approach SF-GNN (based on sparse filtering and graph neural networks) is proposed for vibration-based wind turbine gearbox fault detection; (2) a knowledge-based graph of the ontological wind turbine gearbox and sensor data is developed; (3) sequential outputs provide semantical detection results for single or multiple defect occurrence; (4) SF-GNN outperforms accuracy and the computing time; (5) to the best of our knowledge, this is the first paper to use GNN-based for wind turbine fault detection.
The reminder of the paper is organized as follows: Section II introduces the SF-GNN models, the main GNN-based methods are reviewed, and their significance is explained. Section III introduces the experimental setup and the performance of the SF-GNN models are investigated with comparisons to neural-network-based models. The effect of sparse filtering for performance improvement and the impact of GNN-based fault detection are also discussed. Section IV provides a summary and conclusions.
## 1 Methods
### General Graph Neural Networks
The graph neural network (GNN) is a neural network-based approach for representation learning and classifying nodes in a graph [27]. Representation learning is an approach to simplify a complex graph structure. The graph of complex system, for example a biological network or group of social media users, can be very large and complicated. Features with structural information are extracted and interpreted from the graph and then used for the intended application, such as prediction and classification [29]. Traditionally, structural information is extracted using hand-engineered approaches. On the contrast, representation learning maps the original graph network to a low-dimensional space that can be used to infer and present the graph. This process is called node embedding or node labeling [29]. Representation learning accelerates graph-based applications to learn and encode structural information in a simplified approach.
Concisely, GNNs provide node embedding and node classification. In this work, a GNN is used as a supervised node classification method. The input graph is the knowledge-based graph structure of the wind turbine and the target node is one of the health condition nodes.
In the embedding stage, given the graph \(G=(V,E)\), each node in \(V\) is mapped to a low dimensional space. Each node representation \(x_{v}^{(t)}\) at timestep \(t\) is defined by \(f_{w}^{t}\), which is implemented as a recurrent neural network. The embedding of \(x_{v}^{(t=0)}\) is randomly initialized and in the absence of node attribute labels, each iteration updates the representation as [26][28] :
\[x_{v}^{(t)}=f_{w}^{t}(l_{w},l_{conv},l_{v^{\prime}},x_{v^{\prime}}^{(t-1)}). \tag{1}\]
GNN is based on a recursive approach where information (labels) from neighbor nodes and edges are aggregated and the network \(f_{w}^{t}\) is decomposed as the sum of per-edge aggregation functions \(f_{agt}\):
\[f_{Embed}\Big{(}l_{w},l_{conv},l_{v^{\prime}},x_{v^{\prime}}^{( t)}\Big{)}=\] \[\sum_{v^{\prime}_{in}}f_{agt}\Big{(}l_{w},l_{v^{\prime}\to v },l_{v^{\prime}},x_{v^{\prime}}^{(t-1)}\Big{)}+\] \[\sum_{v^{\prime}_{out}}f_{agt}(l_{w},l_{v\to v^{\prime}},l_{v^{ \prime}},x_{v^{\prime}}^{(t-1)}). \tag{2}\]
The \(f_{agt}\) are defined by a neural network [21] with configuration of labels and non-linear activation function, and a recursion for updating the trainable parameters \(w\) and \(b\) as follows:
\[x_{v}^{(t)}=\sum_{v^{\prime}\in V(v)}f_{agt}[W^{(l_{w}l_{v^{\prime}}-v^{\prime }l_{v^{\prime}})}x_{v^{\prime}}^{(t-1)}+b^{(l_{w}l_{v^{\prime}}-v^{\prime}l_{v^ {\prime}})}]. \tag{3}\]
Once the final embedding space is computed, the second stage of node classification is defined by the neural network \(g_{w}^{t}\)[21]:
\[y_{v}^{(t)}=g_{w}^{t}(x_{v}^{(t)},l_{v}). \tag{4}\]
### The gated Graph Neural Networks
The gated graph sequential neural network (GGS-NN) is a GNN-based approach using a modified gated graph neural network (GG-NN) [28]. In the GNN, neighbor node information is aggregated by one shared neural network across layers. When the complexity of the input graph increases, over fitting the GNN parameters and the computational cost of training by backpropagation with vanishing gradient problem is a problem [29]. The GG-NN addresses these issues by performing a recurrent update with similar gating mechanisms. The GG-NN includes "information aggregation \(+\) RNN" [29] with fixed-steps of representation learning and unrolling recurrence using backpropagation optimization methods through time and specific node information as the initialized input. GGS-NN is an extension of GG-NN where multiple GGS-NNs are used to perform predictions of: (1) the output of the current step, and (2) initialization for the next step [28].
In the initialization step, each node \(v\in V\) is annotated with a real-valued feature \(F^{(v)}\in\mathbb{R}^{D}\), and then the state vector is initialized from the features. In this work, features are optimized using sparse filtering. In the propagation step, the graph is unrolled to the fixed step while the nodes aggregate information from neighbors. The aggregation function is the same as with the GNN, but the general propagation model is replaced by the Gated Recurrent Unit (GRU) [30] that is used for hidden state updating that depends on aggregation and the previous state. In the output step, node-level output is computed like the GNN; the GGS-NN is used to produce an output sequence of the wind turbine's operating condition, including component type and name, sensor, and final health state.
### Sparsity Optimization
Sparse filtering is an unsupervised learning method with the objective to make the feature matrix sparse [20]. Each feature in column (\(d\)) and row (\(i\)) in the feature matrix is defined as:
\[F_{i}^{d}=W^{T}x^{d} \tag{5}\]
where \(W\) denotes the weight matrix; \(x^{d}\) denotes the \(d\)-\(th\) input data from the training set of \(\{x^{d}\}_{d=1}^{D}\), \(x^{d}\in\mathbb{R}^{N\times 1}\). The sparse filtering iteration begins with normalization of each input data using the \(L_{2}\) norm:
\[L_{2}(F_{i})=F_{i}/\|F_{i}\|_{2}. \tag{6}\]
Each feature from the normalized input data is then normalized using the \(L_{2}\) norm,
\[L_{2}(F^{d})=F^{d}/\|F^{d}\|_{2}. \tag{7}\]
Each normalized feature is then minimized using the \(L_{1}\) norm:
\[min\ \sum_{l=1}^{D}\left\|L_{2}(F^{d})\right\|_{1}. \tag{8}\]
The learning performance is measured according to three properties of the features: population sparsity, lifetime sparsity, and high dispersal [20].
Population sparsity describes the quantity of non-zero active element should be minimal, which requires high sparseness from the input data. The sparsity of the input \(x^{d}\) is defined as the \(L_{1}\) norm of \(F^{d}\). During the \(L_{2}\) normalization process, the feature is projected onto the surface of the unit ball. Then by the \(L_{1}\) minimization, the sparseness of the feature is improved.
Lifetime sparsity describes the quality of the sparsity of the feature that is expected to be discriminative with a high potential of selectivity [31]. The sparsity of feature \(F_{i}\) is defined as the \(L_{1}\) norm of \(F_{i}\). A significantly high level of sparseness can achieve lifetime sparsity.
High dispersal describes the statistical properties of features that are expected to have similar activation. The activation similarity is measured by the variance over all features. Lower values of variance indicate higher dispersal. The \(L_{2}\) norm, based on Euclidian distance, measures the variance [31] and normalized features share equal activation.
Sparse filtering can deal with high-dimensional inputs gracefully, and is very easy to use, for it has only one hyperparameter, the number of features to learn.
## 2 The Proposed Method
A SF-GNN is developed for wind turbine fault detection based on graph neural networks accelerated by sparse filtering. The core concept of the approach is to use the GNNs to classify the vibration data labeled as normal or fault within a graph structure, and the aim is to produce single and sequential detection outcomes. The approach includes three modules: graph identification, feature learning, and fault detection.
### Graph Identification
A graph is a type of data structure that describes relationships and interactions between individual entities. The edges and nodes of a graph define the directed graph structure, \(G=(V,E)\), where \(V\) denotes the nodes \(v\in V\), and \(E\) denotes the edges with direction from node \(v\) to \(v^{\prime}\), \(e=(v,v^{\prime})\in V\times V\)[29].
In this paper, the graph structure includes the following configurations to each node and edge: Labels and Neighbors. Labels are assigned to the nodes and edges. Node label \(l_{v}\) describes the features of each entity, for example, the health conditions of the wind turbine components. Edge label \(l_{CON}\) describes the connection level between two entities. The edge label contains \(l_{v\to v^{\prime}}\) indicates an outgoing connection (\(v\to v^{\prime}\)) and \(l_{v^{\prime}\to v}\) for an incoming connection (\(v^{\prime}\to v\)). Neighbors are nodes that connect with node \(v\) with labels \(l_{v^{\prime}}\). \(v^{\prime}_{in}\) and \(v^{\prime}_{out}\) are incoming and outgoing nodes, respectively. The label and neighbor configurations above are used in the GNN [28].
The graph is formed as a knowledge-based structure that is adapted and modified from the wind energy ontology developed Dilek Kucuk et al [32]. In the knowledge-based graph, the labels and neighbors includes the following specifications of the three hierarchical levels: the wind turbine structural components, the sensors and data, and the conditions that include the four relationships: "is-a", "has", "measures", and "causes". Level 1 is modeled as the terminology node that is associated with the wind turbine components including the gearbox elements and the bearing arrangements. These nodes are connected by "has". Level 2 is modeled as the data node that defines the sensors mounted on the gearbox components and the corresponding measured data. They are connected to sensor type nodes by "is-a" and the data type nodes by "measures". Level 3 is modeled as the state nodes that define the health conditions of the wind turbine components that are connected by "causes". The meta nodes, for example, the data type and the component type, are used to define the attributes of the nodes.
### Sr-Gnn
The SF-GNN is a two-stage fault detection model. The input of the model is defined by a knowledge-based structure of the wind turbine, including the components, the sensor network, the health conditions, and the connection relationships (_Graph Identification_). The first stage is feature learning by sparse filtering where high frequency raw vibration data corresponding to the sensor nodes (_Feature Learning_) is preprocessed. The second stage is wind turbine using GNN-based models. The SF-GNN includes two of the models: the basic graph neural network and gated graph neural network. The basic GNN generates a single detection output that reflects
Figure 1: The knowledge-based structure. This figure presents a general sense of the graph identification. The actual input graph is explained in the experiment section.
the general health condition of the wind turbine gearbox. GGS-NN generate either single or sequential detection output(s). The sequential outputs reflect detailed health conditions of the components with type and name, sensor, and final health state. The general framework of the SF-GNN is presented in Fig. 2.
## 3 Experiments
### Experiment Setup
Experiments are conducted to demonstrate the node classification efficiency of the GNN-based approaches and the effect of the SF-based feature learning. In the first part of the experiment, the single output accuracy of GNN and GG-NN are investigated with the comparisons to a multilayer perceptron [21] and the SF-based Softmax regression [19]. In the second part, the sequence output accuracy of GGS-NN is investigated via using raw vibration data, SF-based features, time- and frequency-domain features [9], and graph inputs.
For the implementation, sparse filtering and other GNN-based approaches are adapted and modified from available models [33][34][35][36]. The activation function is log-sigmoid [37] and the loss function is cross entropy [37]. The hyperparameters are selected as: hidden layer size = 16; learning rate fixed at 0.001; \(\text{dropout}=0.2\), and length of \(L_{2}\) regularization = 0.05.
For the training procedure, the optimization uses Kingma et al's method [38]. The parameter (weight and bias) initialization uses Glorot et al.'s method [39]. The maximum epoch number is 1,000. An early stopping criterion is used to terminate computations if there is no improvement in the loss function for the first 20 epochs. The datasets are divided according to: 60% training, 20% testing, and 20% development. Both normal and defected datasets of 8 sensors are used for training. That is, the ground-truth data of the healthy or normal condition datasets are used for the method evaluations including generalization check of SF-GNN.
For evaluation, the confusion matrix [40] is used to quantify the classification accuracy, and the accuracy is defined as the ratio of the true positives and true negatives over the total set of classifications.
### Data Description
Wind turbine vibration data from the National Renewable Energy Laboratory (NREL) is used for the experiments [41]. The test turbine has three-blades, is stall-controlled and upwind, with rated power of 750kW; generator operates at 1200 rpm or 1800 rpm nominal. Two gearboxes (one "healthy" and one "damaged") are tested under the operating conditions: main shaft speed at 22.09 rpm, nominal high-speed shaft at 1800 rpm, 50% of rated power. The descriptions of the accelerometers are shown in Table I. The vibration data (m/s\({}^{2}\)) is collected at 40 kHz for 10 minutes by the accelerometers mounted on the gearboxes. The data are labeled as "healthy" and "damaged" according to the conditions of two gearboxes. Each 40-kHz dataset is divided into segments where each data segment is 0.1-second in length with 4,000 samples in each segment. There are 50,000 segments in total and these segments are considered as raw (vibration) data. In this dataset, the defects of the wind turbine are caused by oil-loss events. The fault type are summarized and labeled for the targeted node classification task. Vibratory acceleration data at high frequency is used in this paper. Disturbance of the acceleration indicates defect occurrence on the wind turbine gearbox. Accordingly, the faults of the wind turbine are detectable through vibration-based methods.
The input knowledge-based graph is formed based on the description provided previously. The graph includes 21 terminology nodes, 8 data nodes, 2 state nodes, and 4 meta nodes, with three different edge types. 8 sensor signals are considered in the experiment and correspond to the data nodes.
### Results and Discussions
\begin{table}
\begin{tabular}{c c} \hline Sensor Name & Description \\ \hline AN3 & Ring gear radial 6 o’clock \\ AN4 & Ring gear radial 12 o’clock \\ AN5 & LS-SH radial \\ AN6 & IMS-SH radial \\ AN7 & HS-SH radial \\ AN8 & HS-SH upwind bearing radial \\ AN9 & HS-SH downwind bearing radial \\ AN10 & Carrier downwind radial \\ \hline \end{tabular}
\end{table}
Table 1: The sensor description
Figure 2: The framework of SF-GNN. Module 1 identifies the input graph with wind turbine knowledge and raw sensor data. Module 2 learns processes feature learning on the raw sensor data within the input graph, which is the stage 1 of SF-GNN. Module 3 initiates GNN models and generates the single detection output by basic GNN and GG-NN and the sequential output by GGS-NN, which is the stage 2 of SF-GNN.
\(\bullet\) The Effect of Sparse Filtering: The only hyperparameter in sparse filtering is the input dimension. Four different input dimensions are tested as shown in Table II: 50, 100, 300 and 500. For the dimensions 100, 300 and 500, the models do not have significantly different accuracy; however, the running time does increase as the dimension increases. The 300-dimension test provides more detailed features than the 100-dimension test. The detailed features include redundant active entities, which incurs extra running time and overfitting. The 100-dimension test results can distinguish one active entity (the highest peak) and a few others with moderate running time. Therefore, the 100-dimension inputs are used for the experiments.
* Single Output Results: As presented in Table III, the combined approach of sparse filtering and GNN-based models achieves higher accuracy with increased computational cost. From the detection results, the SF-learned features with the GNN-based models efficiently outperform the raw and manual features (Feature-GNN and Feature-GG-NN), but still have greater computational cost than MLP and SF-SoftMax, which are baseline models with feature inputs without graph structure inputs. Therefore, they perform detection with less computing time.
* Sequential Outputs Results: The GGS-NN learns the nodes and their relationships from the entire input graph. The output sequence includes node predictions of components, data types, and the health state; and includes the relationship (edge) predictions of "has", "is-a", "measures", and "causes". Semantically, for example, the level 1 outputs are "the gearbox has a ring gear" and "the ring gear has AN3"; the level 2 outputs are "AN3 is a sensor" and "AN3 measures vibration"; and the level 3 output is "AN3 causes fault operations"-meaning the fault is located on the component where AN3 is mounted. This experiment includes two test cases: one fault signal and two fault signals. As presented in Table IV, the two cases achieve similar accuracy. Compared to the overall accuracy of the basic GGS-NN at 87.27%, which is like the work of Li et al., the sparse filtering has an accuracy of 90.73%. For the sequence results, we observe: (1) SF-learned features perform better than the GGS-N; (2) sequential outputs have lower accuracy than single outputs. Sparse filtering is a problem-specific feature learning method for the single output case in which the GG-NN concentrates on state node prediction depending on the vibration signal data; therefore, sparse filtering has direct impact on GG-NN performance. Node annotation for initialization can impact accuracy. During the procedure of GGS-NN, annotated nodes predicted by the GG-NN models has unstable performance compared to the pre-set and fixed annotations in the single-output case; therefore, lower accuracy occurs in the case of sequential outputs.
\(\bullet\) The Impact of the GNN-Based Approaches: According to the performance of wind turbine fault detection system using the graph models, the GNN-based approaches are the most effective and have the greatest promise. Specifically: (1) graph-based inputs can integrate related knowledge of the configuration and operations of the wind turbine, the sensor network, and the data sources. This integration of information helps to interpret and manage how data from different sensors and wind turbines can effectively be used in developing learning algorithms and systems for fault detection, diagnosis, and prognosis. The results of sequential detection indicate that GNN-based approaches can effectively use multiple factors for fault detection and produce comprehensive analytical results for IoT applications such as using "big" data from wind turbine experiments to develop a fault detection and diagnosis system that can improve wind turbine operational reliability and transmission grid reliability and resiliency.
## 4 Conclusion
A GNN-based wind turbine fault detection method is proposed in this paper using experimental data from NREL. This work deploys two methods: GNNs and sparse filtering. SF-GNN identifies the gearbox health condition from a knowledge-based input graph that ontologically describes the wind turbine and gearbox and generates a single output of the condition of an individual component and sequential outputs with additional semantical information to the conditions. Sparse filtering is deployed to sparsity the feature matrix of the high frequency sensor signals, standardize the features to receive equal activation, and qualify the signals data validity to GNNs. As compared to the original GNNs achievements, this work presents a complex input graph with multiple edge and node types and more sensitive and higher frequency signals, and outperforms in accuracy and efficiency by acceleration of sparse filtering.
As the experiment demonstrated, the GNN-based approaches can efficiently detect the component faults using both single and sequential output detection strategies. The GGS-NN can successfully produce a logical and reasonable fault detection sequence using data from a single sensor or from multiple sensors. Sparse filtering provides significant improvements in
\begin{table}
\begin{tabular}{c c c} \hline Preprocessing & 1 fault signal & 2 fault signals \\ \hline SF & 90.73 & 90.36 \\ Raw & 87.27 & 88.17 \\ Feature & 90.04 & 89.56 \\ \hline \end{tabular}
\end{table}
Table 4: The sequence outputs accuracies (%)
\begin{table}
\begin{tabular}{c c c c} \hline Input Dimension & GNN & GG-NN & GGS-NN & Running time (s) \\ \hline
50 & 74.24 & 88.25 & 82.57 & \(<\) 60 \\
100 & 92.33 & 93.74 & 90.73 & \(<\) 60 \\
300 & 91.72 & 94.14 & 90.12 & 62 \\
500 & 92.41 & 93.62 & 90.83 & 78 \\ \hline \end{tabular}
\end{table}
Table 2: The effect of Sf on GNN-based models
\begin{table}
\begin{tabular}{c c c} \hline Models & Accuracy (\%) & Running time (s) \\ \hline SF-GNN & 92.33 & 54 \\ SF-GG-NN & **93.74** & 47 \\ Feature-GNN & 83.54 & 58 \\ Feature-GG-NN & 89.28 & 52 \\ SF-SoftMax & 89.92 & **38** \\ \hline \end{tabular}
\end{table}
Table 3: The single output accuracies
the single output cases but only modest improvements in the sequential output cases.
Future work is necessary to improve accuracy, reduce the computational burden, and further explore the GGS-NN-based method. We have observed in our application that GNN-based methods can be improved by including representation learning using raw data instead of incorporating a separate feature learning stage.
|
2310.13965 | Cloud-Connected Wireless Holter Monitor Machine with Neural Networks
Based ECG Analysis for Remote Health Monitoring | This study describes the creation of a wireless, transportable Holter monitor
to improve the accuracy of cardiac disease diagnosis. The main goal of this
study is to develop a low-cost cardiac screening system suited explicitly for
underprivileged areas, addressing the rising rates of cardiovascular death. The
suggested system includes a wireless Electrocardiogram (ECG) module for
real-time cardiac signal gathering using attached electrodes, with data
transfer made possible by WiFi to a cloud server for archival and analysis. The
system uses a neural network model for automated ECG classification,
concentrating on the identification of cardiac anomalies. The diagnostic
performance of cardiologist-level ECG analysis is surpassed by our upgraded
deep neural network architecture, which underwent thorough evaluation and
showed a stunning accuracy rate of more than 88\%. A quick, accurate, and
reasonably priced option for cardiac screening is provided by this
ground-breaking technology, which smoothly merges wireless data transfer with
AI-assisted diagnostics. In addition to providing a thorough overview of the
development process, this paper also highlights methods used to improve model
accuracy, such as data preparation, class imbalance correction using
oversampling, and model fine-tuning. The work shows the viability of a
comprehensive remote cardiac screening system powered by AI and maximising the
use of wearable and cloud computing resources. Such cutting-edge remote health
monitoring technologies have great promise for improved health outcomes and
early identification, especially in resource-constrained countries. | Azlaan Ranjha, Laiba Jabbar, Osaid Ahmed | 2023-10-21T10:45:14Z | http://arxiv.org/abs/2310.13965v1 | Cloud-Connected Wireless Holter Monitor with Neural Networks Based ECG Analysis for Remote Health Monitoring
###### Abstract
This study describes the creation of a wireless, transportable Holter monitor to improve the accuracy of cardiac disease diagnosis. The main goal of this study is to develop a low-cost cardiac screening system suited explicitly for underprivileged areas, addressing the rising rates of cardiovascular death. The suggested system includes a wireless Electrocardiogram (ECG) module for real-time cardiac signal gathering using attached electrodes, with data transfer made possible by WiFi to a cloud server for archival and analysis. The system uses a neural network model for automated ECG classification, concentrating on the identification of cardiac anomalies. The diagnostic performance of cardiologist-level ECG analysis is surpassed by our upgraded deep neural network architecture, which underwent thorough evaluation and showed a stunning accuracy rate of more than 88%. A quick, accurate, and reasonably priced option for cardiac screening is provided by this ground-breaking technology, which smoothly merges wireless data transfer with AI-assisted diagnostics. In addition to providing a thorough overview of the development process, this paper also highlights methods used to improve model accuracy, such as data preparation, class imbalance correction using oversampling, and model fine-tuning. The work shows the viability of a comprehensive remote cardiac screening system powered by AI and maximising the use of wearable and cloud computing resources. Such cutting-edge remote health monitoring technologies have great promise for improved health outcomes and early identification, especially in resource-constrained countries.
## I Introduction
Cardiovascular disorders, which include ailments like myocardial infarction, cardiac arrest, and arrhythmia, continue to be the largest cause of death worldwide. To effectively identify and manage these illnesses, electrocardiogram (ECG) analysis has emerged as a key technique. Medical professionals can identify anomalies by using an ECG, which examines the complex electrical signals driving heart rhythm.
Traditional Holter monitoring requires wearing ECG equipment continuously for several days, followed by post-recording analysis. Real-time wireless ECG data transmission has become possible because of technological advancements, which make remote monitoring easier. Automating ECG analysis using deep neural networks enables quick screening and diagnosis of heart abnormalities. Through the use of wireless signal transmission and deep learning, this project aims to develop an intelligent wireless Holter monitoring system that will provide quick, reliable, and affordable cardiac screening.
The suggested methodology calls for the wireless real-time transmission of ECG signals from wearable sensors to cloud-based computers. The wireless data transmission is to be done by the use of WiFi modules such as the ESP32. The selection of an ESP32 as a WiFi module was done as they are low-cost and extremely versatile, therefore they are recommended for such projects. A neural network model then performs automated classification to separate between healthy and unhealthy cardiac beats. With the use of AI-powered remote cardiac monitoring, this programme aims to reduce the rising worldwide burden of cardiovascular diseases by providing the possibility of early detection and preventive intervention.
The integrated wireless ECG system shown in this work, along with a deep learning algorithm, is intended to improve and scale heart health screening. This paper explains in great detail the system design, implementation, and real-world evaluation.
## II Problem Statement
With over 17 million fatalities reported in 2019, cardiovascular diseases (CVDs) have emerged as a global health issue and are now the leading cause of death worldwide [10][11]. Notably, low and middle-income countries endure a disproportionate amount of the burden, with CVDs serving as these areas' main cause of mortality [10]. For instance, in Pakistan alone in 2020, 240,720 people died as a result of CVDs, accounting for more than 16% of all fatalities that year [12]. Myocardial infarction and strokes are to blame for the majority of these CVD-related deaths [10][13]. The burden of CVD-related mortality can be reduced with quick and precise diagnosis combined with prevention actions [14]. In this context, electrocardiogram (ECG) monitoring is crucial since it enables medical professionals to spot abnormal heart rhythms linked to CVDs [15][16]. However, classic Holter ECG devices have some serious disadvantages, such as obtrusive
electrical connections and skin discomfort from prolonged use [17][18]. Furthermore, real-time wireless data transmission is not possible with conventional Holters, which might cause delays in diagnosis and treatment [19]. Recent developments have allowed us to provide a small, wireless ECG Holter monitor that makes use of cloud-based computing and artificial intelligence, offering potential answers [20][21][22][23]. The suggested system is proposed to use wireless wearable sensors to record real-time electrocardiogram (ECG) signals and send the information to cloud servers for distant data archiving and analysis. Based on the wireless data acquired, a powerful deep neural network model automatically distinguishes between normal and pathological heartbeats. This ground-breaking method can potentially' democraise affordable and convenient cardiac screening by removing geographical restrictions [21]. Furthermore, AI-powered diagnosis makes it easier to quickly identify potentially fatal cardiac anomalies [20][23]. This study aims to develop and verify a cloud-based deep learning analytics-based integrated wireless ECG monitoring system [21]. If it works, this sophisticated remote cardiac screening method could be a game-changer in the early detection and prevention of CVD [21]. This strategy, especially in areas with limited resources, shows promise in reducing the rising burden of CVD-related mortality by eliminating barriers that prevent prompt life-saving therapies [21].
## III Literature Review
An in-depth knowledge of current research is essential to advancing solutions and addressing the rising global burden of cardiovascular diseases (CVDs) in the fields of remote health monitoring and intelligent medical systems. This literature review examines current research on wireless Electrocardiogram (ECG) devices and deep learning for automated cardiac arrhythmia detection, highlighting significant improvements and unresolved problems that warrant additional study. This study seeks to provide context and motivate the AI-powered wireless Holter monitor presented in this research by carefully reviewing pertinent papers published in prestigious journals and conference proceedings. We will evaluate current methods for cloud-based analysis, remote ECG capture, and machine-learning models for accurate ECG classification. To advance the state-of-the-art in accessible and accurate cardiac screening through intelligent remote health monitoring systems, it is important to comprehensively evaluate the ideas that are most relevant to our research while also identifying interesting directions. The design choices we make for our methodologies and the contextualization of our contributions will be influenced by this foundation.
### _Issues with traditional Holter monitors_
Numerous studies have repeatedly concluded that typical Holter monitors have significant shortcomings when it comes to the identification of cardiovascular disease. These restrictions show up as a scant diagnostic yield that typically ranges between 15% to 40% [1][9], with around 23% of patients requiring additional Holter testing. This inefficiency grows more pressing in the United States, where a single patient testing session costs a significant $23,000. Furthermore, these conventional instruments' lengthy diagnostic turnaround times worsen the problem. As a result, a plethora of substitute products have hit the market, however, they tend to concentrate primarily on ECG data and frequently ignore the important impact that patients' background demographics play, which has been noted in the literature [9]. Medical professionals who may not have the data analysis skills displayed by Machine Learning (ML) models are commonly trusted with handling these demographic intricacies. Furthermore, given that doctors can only analyse the data after around 24-48 hours have passed, standard Holter monitors struggle with ongoing issues such as short battery life. Additionally, there are the issues of skin discomfort brought on by surface electrode leads, and delays in diagnosis [3]. Additionally, there is cause for worry because about a quarter (25%) of patients have trouble starting their devices while they are having symptomatic episodes [1].
### _ECG Performance and WiFi Data Transmission_
The use of the ESP32 for wireless data transmission has been determined to be the best option due to its affordability and effective data transfer capabilities, assuring the preservation of data quality and reducing the danger of data loss. Researchers have looked into using a Raspberry Pi computer to receive transmitted data in some cases, and this has shown the capacity to sustain high-quality data transmission [2].
Devices like SmartCardia [1] and Zio [9], each offering particular benefits, are readily available on the market. Through the use of a specialised adhesive patch, SmartCardia tackles the issue of skin sensitivity. Zio, on the other hand, has bragged about how accurately it gathers data. It's crucial to recognise the research's limitations, though. Only 40 candidates were tested a rather small sample size, which is insufficient for a thorough evaluation [1]. In addition, SmartCardia makes use of a Bluetooth module, which can present its own set of difficulties and risks in the context of a complex health-focused solution [1].
### _Low Power Consumption_
Power consumption is a key issue when it comes to wireless or battery-operated gadgets. Implementing a sleep mode during periods of inactivity and optimising hardware to maximise power efficiency are two strategies that may be used to address this problem [2].
### _Alternate Methods of Cardiovascular Diagnosis_
Different scientific disciplines have investigated other ways of evaluating cardiac abnormalities in addition to electrocardiogram (ECG) data. Pharmacological treatments for cardiac diseases can be just as successful as surgical ones, according to research. Pharmacological techniques have occasionally been effective in lowering the risk of abrupt arrhythmia. Additionally, certain genetic variants linked to a higher risk of cardiac arrest have been found [5].
Diverse modelling approaches have been employed by researchers to enhance understanding within the medical community regarding the relationship between cardiac arrhythmia and heart failure. These encompass clinical cases (human patient data), animal testing (lab experiments involving animals), pluripotent stem cell testing, and computational models. These methodologies offer valuable insights, aiding medical practitioners in comprehending heart diseases and the influence of various demographic factors on heart-related conditions. Specifically, in the mentioned research, calcium dyes were utilized to induce heart contractions. Subsequently, these contraction patterns were employed to train machine learning models for patient diagnosis [4].
Convolutional Neural Networks (CNNs), a type of machine learning model, have emerged as the optimal choice for ECG data analysis due to their superior model accuracy. In a comparative analysis, CNNs outperformed models such as BP Neural Networks and Random Forest Classifiers, achieving an accuracy rate of approximately 99.7% based on key parameters including accuracy, sensitivity, specificity, and positive prediction rate. The models effectively classified the results into multiple categories, demonstrating robustness and reliable performance [7]. However, it is crucial to note that the model's reliance solely on ECG data limits its diagnostic accuracy. Furthermore, the results were entirely software-based, excluding any potential variations introduced by hardware integration. Despite these limitations, the model's architecture shows significant potential and can be adapted to develop more sophisticated and personalized models for improved task performance.
### _Comparison with Human Cardiologist_
The core of our research is the possibility for our model to outperform human medical professionals in terms of diagnostic precision. This capability serves as the foundation for the benefits and justification of creating such a model, which aims to support cardiologists and other medical professionals in making accurate judgements.
According to studies, the average healthcare professional's accuracy is around 54%, but with the right training, that figure may rise to about 67% [8]. However, this figure is very low, especially in a crucial sector like cardiology where there is little room for error because of the high risk of death. According to additional data, trained cardiologists, residents, and medical students diagnose ECGs with an accuracy rate of about 42%, 68.5%, and 74%, respectively [8].
While additional training could potentially enhance a cardiologist's accuracy in ECG reading, this approach is financially burdensome and time-intensive [8]. Furthermore, there is no assurance of universal improvement. Consequently, there has been a surge in research focusing on machine-learning models for cardiac ailments, given their superior accuracy, precision, and efficiency [8].
## IV Methodology
### _Machine Learning Model_
#### Iv-A1 Dataset Collection
Our research project's first stage involved the thorough collection of reliable datasets. Numerous cardiologists were consulted in-depth and interviewed before the process of data gathering began. These consultations had the goal of clarifying the key characteristics required for correctly identifying cardiac arrhythmia and other heart disorders in patients. It is crucial to stress that real patient data was not used until the appropriate parties gave their consent, due to ethical reasons. Instead, our dataset was meticulously sourced from reputable and established online repositories and sources with a proven track record of data quality and reliability. Subsequently, a comprehensive amalgamation of various datasets was executed to construct a more expansive and tailored dataset aligned with our testing requirements. This culminated in the creation of the final merged dataset, comprising categorical data derived from patients' medical histories and background demographics [24], in conjunction with ECG data obtained from patients [25].
#### Iv-A2 Data Preprocessing
The final amalgamated dataset underwent a rigorous categorization process, resulting in two distinct classes of patient labels: "Normal Heart Condition" and "Abnormal Heart Condition." It is noteworthy that the ECG data was initially organized into separate folders denoting normal and abnormal data, yet lacked corresponding labels. To address this, a deliberate integration strategy was employed, whereby normal ECG data was concatenated with the records of patients classified as "normal," and conversely, abnormal ECG data was linked with the corresponding "abnormal" patient records. Following this integration, the dataset underwent a systematic shuffling procedure, accompanied by a resetting of data indices to ensure randomness and uniformity.
Both before and following the integration process, meticulous data quality control measures were implemented. These included regular inspections and the removal of any instances of null values, duplicate entries, or outliers. Furthermore, to enhance the fidelity of the ECG data, Butterworth Lowpass filters were applied to mitigate noise artefacts. These filters, widely adopted in signal processing, are favoured for their characteristics, which encompass a flat pass-band response, gradual roll-off, ease of design, and stability in steady-state
Fig. 1: Machine Learning Pipeline
operation. It is imperative to acknowledge that the choice of filter type hinges on specific application requirements, with alternative options such as Chebyshev, elliptic, and Finite Impulse Response (FIR) filters offering varying trade-offs to cater to distinct needs [26][27][28].
#### Iii-B3 Feature Engineering
Following the meticulous completion of the Data Preprocessing phase within our model training pipeline, we transitioned to the subsequent step, namely, feature engineering. Leveraging the rich ECG data at our disposal, we embarked on a journey to expand and diversify our dataset, thereby enhancing our model's training regimen and its ability to gain deeper insights into the patients' conditions.
For each column of the ECG data, a comprehensive array of features was diligently extracted and subsequently incorporated as new columns appended to the dataset. Each row in the dataset was thereby endowed with a unique set of features, encompassing parameters such as 'HR Variability,' 'QRS Duration Mean,' 'QRS Duration STD,' 'Spectral Sum,' 'Spectral Max,' 'Spectral Max Frequency,' 'Spectral Mean,' 'Spectral STD,' 'Skewness,' 'Kurtosis,' and many more. This enrichment process served to provide the model with a more comprehensive and nuanced representation of the underlying ECG data [29][30].
Subsequently, the datasets underwent a normalization procedure, and steps were taken to rectify any imbalances present within the label classes. Following a final round of data filtration, the dataset was judiciously partitioned into distinct training and test sets, primed for deployment in our training model [31][32].
#### Iii-B4 Model Structure and Training
An extremely nuanced and complex sequential training model was designed using tools such as TensorFlow and Keras. [33] The model has 7 Dense layers, along with the output layer. After each layer, normalization and dropout methods are used [34][35][36]. Alongside these, other elements such as Learning Rate Scheduler, Callbacks and Early Stopping are also used [37][38]. All this has been done to increase model accuracy and reduce over-fitting and model losses. As our classification labels were binary encoded we used binary cross-entropy loss function [39][40][41][42] and many other metrics such as accuracy and AUC score etc [43]. were used to guide the model towards our desired functionality.
#### Iii-B5 Model Results
The dataset was subjected to a meticulous partitioning process, with 70% of the data allocated for training purposes and the remaining 30% reserved for rigorous testing. To maintain a balanced representation of classes within the dataset, the'stratify' parameter was thoughtfully utilized in association with the classification labels. Additionally, within the confines of the training data subset, a prudent allocation of approximately 10% was set aside for validation purposes.
Upon completion of the arduous model training process, the training data yielded a noteworthy accuracy rate of approximately 88%, affirming the model's robust performance.
Furthermore, it is worth highlighting that the accuracy achieved with the test data also closely approximated 88%. This noteworthy consistency in accuracy is particularly striking given the substantial disparity in sample sizes between the training and test sets. It is a testament to the model's commendable ability to maintain its accuracy, showcasing its proficiency in effectively generalizing to previously unseen data. This robust performance underscores the model's suitability for practical applications in real-world contexts.
A crucial attribute of the model is its resilience against common issues such as under-fitting and over-fitting, further
\begin{table}
\end{table} TABLE I: Train Data Results
Fig. 3: Filtered Normal ECG Signal
Fig. 2: Dataset Figures
solidifying its effectiveness. This quality enhances its reliability and suitability for a wide range of practical scenarios.
Lastly, the model underwent rigorous evaluation utilizing our validation dataset. This pivotal phase serves as an invaluable introspection into the real-world capabilities and performance of our established machine-learning model.
### _Hardware Design_
The development of a patient-centric prototype hinged critically on the design of robust hardware. This hardware design imperative necessitated an interface that seamlessly balances user-friendliness while effectively addressing longstanding issues associated with traditional Holter monitors. These challenges encompassed concerns related to skin irritation, timely communication of patient conditions to healthcare providers, sub-optimal accuracy rates, and the inconvenience posed by the cumbersome, outdated hardware apparatus.
#### Iii-B1 ECG Module
The AD8232 ECG module was ultimately determined to be the best option for our project's hardware basis after thorough investigation and cautious consideration. This strategic choice was influenced by several compelling elements, all of which added to the module's fit for our project. The AD8232 module stands out for its low power consumption, which is in line with the efficiency goals of our project and provides a practical, affordable option for resource-conscious development. Given the intrinsically weak nature of ECG signals, its outstanding High Common Mode Rejection Ratio (CMRR) is crucial in maintaining the integrity of acquired ECG signals. Additionally, the module's broad input voltage range, high input impedance, and built-in Right-Leg Drive (RLD) circuitry all improve signal quality and patient comfort by successfully reducing problems like skin irritation. Perhaps most importantly, the module can be easily integrated into a variety of wearable health devices, including smartwatches and wristbands, which exactly meet the needs of our project. The AD8232 ECG module is positioned as the cornerstone of our hardware design thanks to this extensive collection of qualities, making it well-suited to carry out the goals of our project.
#### Iii-B2 Solar-Panel Exterior
Throughout our research endeavours, our team embarked on a mission to conceptualize and develop an affordable, precise, and high-quality biomedical product that could be accessible to the broader populace, thereby democratizing healthcare access. An intriguing outcome of our research efforts culminated in the exploration of perovskite, a material distinguished by its three-dimensional atomic or ionic arrangement, which may include metal halides. The global appeal of perovskite centres around its exceptional attributes, notably its lightweight nature and cost-effectiveness. Particularly promising are the recent advancements in perovskite-based photovoltaic cells, as exemplified by the remarkable 23.03% efficiency achieved by researchers from South Korea and Pakistan. This breakthrough underscores the material's viability as a potential replacement for conventional solar cells. Incorporating perovskite into our concept holds the promise of assuring continuous charging, preventing any chance of patient condition degradation during charging intervals, and ensuring uninterrupted gadget performance. This invention perfectly complements our main objective of continuous and seamless patient monitoring.
#### Iii-B3 ECG Leads
The integration of adhesive lead patches, widely recognized for their established presence in commercial applications, constitutes a pivotal component of our project implementation. This strategic inclusion serves a dual-fold purpose: first and foremost, it bolsters user convenience, while simultaneously facilitating sustained and effective utilization of the product over the long term. Notably, our project accommodates two distinct variations of these leads to cater to varying patient requirements. One variant seamlessly integrates these leads within our wristband design, while the other introduces an additional adhesive patch on the chest region. This strategic augmentation enhances data acquisition, leading to improved model performance and heightened result accuracy.
#### Iii-B4 WiFi Data Transfer Module
Within the scope of our project, the ESP32 module emerged as the optimal choice for our WiFi module, a decision that was substantiated by the outcomes of our extensive research. The ESP32 module was distinguished by several noteworthy attributes that rendered it a standout selection. These attributes encompassed its impressive traits such as low power consumption and
\begin{table}
\end{table} TABLE II: Test Data Results
\begin{table}
\end{table} TABLE III: Validation Data Results
cost-effectiveness. Moreover, the module's suitability for the intricate task of ECG data acquisition was underscored by its dual-core processor, affording the capability for simultaneous data capture from our ECG module and seamless data transmission to the cloud. The versatility of the ESP32 module, encompassing both WiFi and Bluetooth connectivity, further bolstered its appeal and utility. Collectively, these attributes established the ESP32 as a premier IoT device, adept at facilitating high-fidelity data transfer and the reliable execution of critical processes.
### _Software_
#### Iv-C1 Establishment and Maintenance of Cloud Database
Throughout the execution of our project, the meticulous configuration of resilient infrastructure to seamlessly accommodate patient background data, health records, and real-time ECG data emerged as a paramount consideration. In harmony with the specific prerequisites of our project, we strategically opted to integrate the Amazon Web Services (AWS) IoT Core with AWS for Healthcare and Life Sciences. This deliberate fusion was orchestrated with several pivotal objectives in mind.
Foremost among these objectives was the reinforcement of our project's capabilities in terms of reliable and uninterpret connectivity. This integration empowered us to achieve frictionless wireless data transfer and secure data storage, effectively leveraging our IoT devices for these purposes. Additionally, the incorporation of AWS for Healthcare and Life Sciences proved instrumental in ensuring adherence to stringent healthcare data privacy regulations, affirming our commitment to maintaining the requisite standards.
Of notable significance was the streamlined implementation of robust encryption protocols and secure storage mechanisms for patient ECG data. These measures, which would otherwise necessitate substantial expertise, time, and computational resources, were seamlessly integrated as a result of this strategic partnership.
Furthermore, this integration furnished our project with the invaluable advantage of real-time data monitoring and visualization, instrumental elements in the successful execution of our objectives.
An additional noteworthy enhancement we consider for our project is the development of a dedicated database, leveraging established frameworks such as MongoDB or MySQL. The adoption of such frameworks holds the potential to significantly enhance our data accessibility and manipulation capabilities to align with our specific project requirements.
#### Iv-C2 Project Website and App Design
The development of a user-centric project website and mobile application stands as a pivotal component of our ongoing research initiative. The forthcoming design of the user interface (UI) and user experience (UX) for these digital platforms will be characterized by meticulous attention to detail, with the overarching aim of ensuring effortless interaction and accessibility for both patients and healthcare professionals.
Our vision for the project website is that it will serve as a comprehensive gateway, granting users convenient access to their health records, real-time ECG data, and essential cardiac health information. Similarly, the impending mobile application is designed to empower users with a versatile means to monitor their health while on the move, delivering real-time notifications and intuitive data visualization.
At present, the website is under construction, leveraging a skill set encompassing HTML, CSS, and JavaScript. This strategic choice bestows unparalleled adaptability and affords the website developer full control over its features. Although the development of the mobile application is yet to commence, the plan entails its creation using either Flutter or React Native.
In both cases, data storage and retrieval for the website and app will be facilitated by AWS, a selection motivated by its scalability, robust data security measures, and alignment with healthcare privacy regulations. In essence, our choice of these tools and services was underpinned by their capacity to provide a resilient and secure foundation for our project's digital interface, harmonizing seamlessly with our overarching objectives of accessibility, data protection, and cross-platform usability.
## V Discussion
We have attained a commendable accuracy rate of 89%, leveraging an amalgamation of cost-effective yet high-quality hardware to deliver real-time results of significant merit. Nevertheless, one notable constraint is the restriction on real-time data acquisition from the device. Furthermore, the extended-term utility remains uncertain, as testing duration spanning several weeks or months continue to align with those of a conventional Holter monitor. To address this limitation, we propose a potential enhancement: the training of data on more robust computational infrastructure, possibly incorporating edge machine learning techniques. This augmentation holds promise for further elevating accuracy levels.
## VI Conclusion
Examination of the results and graphical representations underscores the exceptional performance of our model, particularly in the context of incorporating patient background demographics and medical history. This achievement not only presents a distinctive solution for patients but also offers vital support to healthcare professionals worldwide. |
2304.01568 | Arrhythmia Classifier Based on Ultra-Lightweight Binary Neural Network | Reasonably and effectively monitoring arrhythmias through ECG signals has
significant implications for human health. With the development of deep
learning, numerous ECG classification algorithms based on deep learning have
emerged. However, most existing algorithms trade off high accuracy for complex
models, resulting in high storage usage and power consumption. This also
inevitably increases the difficulty of implementation on wearable Artificial
Intelligence-of-Things (AIoT) devices with limited resources. In this study, we
proposed a universally applicable ultra-lightweight binary neural network(BNN)
that is capable of 5-class and 17-class arrhythmia classification based on ECG
signals. Our BNN achieves 96.90% (full precision 97.09%) and 97.50% (full
precision 98.00%) accuracy for 5-class and 17-class classification,
respectively, with state-of-the-art storage usage (3.76 KB and 4.45 KB).
Compared to other binarization works, our approach excels in supporting two
multi-classification modes while achieving the smallest known storage space.
Moreover, our model achieves optimal accuracy in 17-class classification and
boasts an elegantly simple network architecture. The algorithm we use is
optimized specifically for hardware implementation. Our research showcases the
potential of lightweight deep learning models in the healthcare industry,
specifically in wearable medical devices, which hold great promise for
improving patient outcomes and quality of life. Code is available on:
https://github.com/xpww/ECG_BNN_Net | Ninghao Pu, Zhongxing Wu, Ao Wang, Hanshi Sun, Zijin Liu, Hao Liu | 2023-04-04T06:47:54Z | http://arxiv.org/abs/2304.01568v2 | # Arrhythmia Classifier Based on Ultra-Lightweight Binary Neural Network
###### Abstract
Reasonably and effectively monitoring arrhythmias through ECG signals has significant implications for human health. With the development of deep learning, numerous ECG classification algorithms based on deep learning have emerged. However, most existing algorithms trade off high accuracy for complex models, resulting in high storage usage and power consumption. This also inevitably increases the difficulty of implementation on wearable Artificial Intelligence-of-Things (AIoT) devices with limited resources. In this study, we proposed a universally applicable ultra-lightweight binary neural network(BNN) that is capable of 5-class and 17-class arrhythmia classification based on ECG signals. Our BNN achieves 96.90% (full precision 97.09%) and 97.50% (full precision 98.00%) accuracy for 5-class and 17-class classification, respectively, with state-of-the-art storage usage (3.76 KB and 4.45 KB). Compared to other binarization works, our approach excels in supporting two multi-classification modes while achieving the smallest known storage space. Moreover, our model achieves optimal accuracy in 17-class classification and boasts an elegantly simple network architecture. The algorithm we use is optimized specifically for hardware implementation. Our research showcases the potential of lightweight deep learning models in the healthcare industry, specifically in wearable medical devices, which hold great promise for improving patient outcomes and quality of life. Code is available on: [https://github.com/xpww/ECG_BNN_Net](https://github.com/xpww/ECG_BNN_Net).
arrhythmia, ECG classification algorithm, Artificial Intelligence-of-Things, ultra-lightweight binary neural network, wearable medical device.
## I Introduction
Cardiovascular diseases (CVDs) are the primary cause of death worldwide, killing more people than any other cause [1]. Arrhythmia, a type of CVDs, is considered to be responsible for most cases of sudden cardiac death that occur each year [2]. Since the global outbreak of the COVID-19 virus in 2019, arrhythmia has become a common manifestation of cardiovascular disease in COVID-19 patients, and a series of clinical case studies of hospitalised patients in China reported palpitation as the initial symptom in 7.3% and arrhythmia in 16.7% [3]. Electrocardiography currently plays an irreplaceable role in the clinical diagnosis of heart disease and can be used to help medical staff identify the specific type of arrhythmia [4].
As wearable AIoT technology continues to advance, there is growing interest in implementing ECG classification algorithms on wearable devices. This would enable real-time monitoring of heart health status without the need to visit a hospital. Low-power and low-computational-cost ECG monitoring algorithms are becoming increasingly popular [6, 7, 8], but most of them still rely on multi-bit fixed-point computation, which is a significant contributor to computational resource consumption and storage costs. Moreover, the majority of studies also design complex algorithms for pre-processing ECG signals.
To address the aforementioned issues and further reduce hardware costs while conserving computational resources, we employed binarization algorithm. This technique converts the weights and activations of the neural network to \(\{+1,-1\}\), which can be stored in hardware as 1-bit \(\{0,1\}\) values, effectively reducing storage costs by 32x. Additionally, the convolution operation is converted to bit-wise XNOR-POPCOUNT, aligning seamlessly with the underlying hardware arithmetic logic [9]. The primary contributions of this article are as follows:
* Firstly, a universal hardware-friendly network has been proposed. By quantizing the activations and weights to \(\{+1,-1\}\), fixing the network structure parameters, operator fusion, and replacing the softmax layer, we have created a binary neural network that is easy to program for hardware and can switch between 5-class and 17-class classification arrhythmia monitoring modes.
* Secondly, our structure eliminates the need for fully connected(FC) layers. FC layers are almost universally employed in neural networks, their removal resulting in a significant reduction in both storage requirements and computational complexity of the model.
* Finally, our 5-class and 17-class arrhythmia classification models achieved remarkable storage compression rates of 29.71x and 29.85x, respectively, with storage usages of 3.76KB and 4.45KB, while maintaining high accuracies of 96.90% and 97.50%, respectively. The storage consumption of the model and the accuracy of the 17-class arrhythmia classification model have reached the state-of-the-art level among known lightweight models.
## II Related Work
Pattern recognition is widely used for monitoring arrhythmias. Prior to classification, signal preprocessing techniques such as filtering and wavelet transformation are applied to extract features [10, 11, 12]. While this method can achieve satisfactory accuracy, implementing feature extraction algorithms such as filtering and wavelet transformation on wearable devices requires additional resources. Additionally, the high dependence of algorithm performance on the extracted features also greatly reduces the model's generalization ability [13, 14].
In recent years, with the development of computing power, the computation cost and power consumption of neural networks have increased rapidly. One of the optimal solutions to address these issues is neural network quantization. The most commonly used method of quantization is converting floating-point numbers to 8-bit fixed-point [15]. Further advances in quantization have resulted in 4-bit quantization, which has only led to approximately 2% loss in accuracy for AlexNet and VGG16 [16]. The most extreme form of quantization is Binary Neural Networks (BNN), which convert both weights and activations to \(\{+1,-1\}\)[9].
With the development of lightweight models and the focus on implementing ECG classification algorithms in wearable devices, an increasing number of lightweight neural networks have emerged. In [17], a hierarchical quantization algorithm based on a greedy algorithm was used to classify ECG with varying bit-widths for different network layers due to their importance. In [18], the activations and weights of the ECG arrhythmia classification CNN were both quantized to 8 bits. Farag et al. [19] proposed a lightweight independent short-time Fourier transform (STFT) convolutional neural network model and quantized it to 8 bits. In [20], an adaptive sensor node architecture was designed, and the proposed CNN model was quantized to 8 bits. Sivapalan et al. [21] converted floating-point operations to 16-bit and 32-bit fixed-point operations for implementation on an embedded platform. Sun el al. [22] used the Adaptive Loss-aware Quantization (ALQ) algorithm to classify 17-class arrhythmias. Janveja et al. [6] proposed a low power work and also quantized the model.
In the existing body of research, there are relatively few studies that focus on quantizing the weights and activations of neural networks to \(\{+1,-1\}\) for ECG classification. Wu et al. [23] designed a full-precision CNN with 9 layers of 1D convolution and 1 fully connected layer, which is then binarized. However, they only utilized F1-score as the evaluation metric for their model, without providing other relevant information such as accuracy, which makes it difficult to compare their results with other models in a comprehensive manner. Wong et al. [24] designed a BNN to classify ECG signals into V-class and non-V-class, implemented on an FPGA. Their model demonstrates exceptional energy efficiency and superior accuracy. However, we observed that the proposed network's fully connected layer constitutes more than 97% of the total parameters, and dividing ECG data into only two categories falls short of meeting the needs of both doctors and patients. Wang et al. [25] proposed a 15-layer CNN to classify ECG and binarized the model. The accuracy of their model requires improvement, and optimization of the batch normalization layer has not been taken into account. During batch normalization computation, floating-point operations are still necessary. Additionally, the parameters in the CNN architecture are not uniform, which poses considerable challenges for the hardware design of BNN. Yun et al. [26] binarized the CNN+LSTM model used for classifying psychological health based on ECG, greatly reducing inference latency and energy consumption. Their model achieves 87% accuracy with a memory footprint of 47KB, indicating ample room for further improvement.
## III Methodology
This section will introduce our network architecture and the binarization method. Our approach has systematically addressed the deficiencies in the relevant literature.
### _Convolutional Neural Network (CNN) Architecture_
To simplify software and hardware programming and facilitate future hardware design, the main structure of the CNN is composed of numerous blocks with standardized parameters such as convolution kernel size, pooling size, pooling stride, etc. To minimize the number of weights in the CNN, we creatively removed the fully connected layers, which are commonly seen in CNN classification networks. This also eliminates the need to separately consider Processing Elements (PE) for FC layers. To reduce the dimensionality of the convolutional output for subsequent classification, we implemented GSP [27], which eliminates the division operation in GAP and renders the entire CNN architecture almost free of division operations. To avoid the exponential operation caused by using the softmax function for classification, we replaced it with a comparator, with the index of the maximum value serving as the classification result.
By setting the number of channels in the output of the last basic block to the desired number of classes and combining it with GSP's dimension reduction, we can simply compare the output of the last dimension of GSP to obtain the specific type of arrhythmia.
Through the aforementioned efforts, we have addressed the following issues in works [23, 24, 25, 26]: insufficient number of
categories and limited model flexibility, substantial parameter consumption resulting from the presence of fully connected layers, and hardware design difficulties stemming from the intricate model architecture. Fig. 1 depicts our baseline CNN structure.
### _Method of Binarization_
Floating-point operations are costly and not supported by most embedded hardware. Binary neural network, on the other hand, utilizes XNOR and POPCOUNT operations to convert the floating-point MAC operations of convolutional and fully connected layers into bit-wise operations. This maximizes the reduction in computational complexity and memory usage of weights. We use (1) to transform the weights and activation values into \(\{+1,-1\}\).
\[x^{b}=Sign(x)=\left\{\begin{aligned} &+1,& x\geq 0\\ &-1,& otherwise\end{aligned}\right. \tag{1}\]
During network training, network are performed using the transformed \(\{+1,-1\}\) values. However, when updating weights using loss values, the floating-point values of the weights prior to being converted by the Sign function will be updated. The gradient of the Sign function is infinite at 0 and 0 elsewhere, making it impossible to perform gradient calculations based on the chain rule. We adopt Ding et al.'s Information-Enhanced Estimator(IEE) [32] to approximate the derivative of the Sign function.
### _Optimizing Batch Normalization Through Operator Fusion_
The aforementioned methodology enabled the successful training of BNN. However, conventional network architectures entail additional operations such as activation functions, batch normalization, and pooling. Prior works [23, 25, 26] have utilized batch normalization, but without any additional processing optimizations, this operation will introduce additional floating-point computations, consume hardware resources, and increase computational latency.
Note that PReLU, batch normalization, and Sign function can be mathematically fused into a threshold function, we introduce this optimization method in the ECG classification network to address the aforementioned issue. We use PReLU instead of the more common ReLU because it can improve the representation of BNN [31]. Below are the specific computational procedures.
\[f(x)=\begin{cases}x&\text{if }x\geq 0\\ ax&\text{otherwise}\end{cases} \tag{2}\]
\[y=\frac{x-\mu}{\sqrt{\sigma^{2}+\varepsilon}}\gamma+\beta \tag{3}\]
Equation (2) and (3) correspond to PReLU and batch normalization respectively. If batch normalization is placed after PReLU in the network, we can merge them into (4).
\[y=\begin{cases}kx+b&\text{if }x\geq 0\\ akx+b&\text{otherwise}\end{cases} \tag{4}\]
Here are the values for k and b:
\[k=\frac{\gamma}{\sqrt{\sigma^{2}+\varepsilon}} \tag{5}\] \[b=\beta-\frac{\mu\gamma}{\sqrt{\sigma^{2}+\varepsilon}} \tag{6}\]
If the function following the batch normalization is Sign function, then (4) can be further merged with sign to obtain (7), which \(\delta_{+}\) is \(\frac{-b}{k}\) and \(\delta_{-}\) is \(\frac{-b}{ak}\).
\[y=\begin{cases}\text{sign}_{\delta_{+}}(x)&\text{if }x\geq 0\\ \text{sign}_{\delta_{-}}(x)&\text{otherwise}\end{cases} \tag{7}\]
Therefore, the order of operators within the basic block can be determined as **Conv, MaxPool, PReLU and BatchNorm**. The reason why the Sign function was not listed is because it is integrated within the Convolution layer of the next basic block. Specifically, the binarization of the previous layer's activations and the convolution layer's own weights are both carried out within the convolution layer itself.
## IV Experiment
In this section, we first introduce the dataset and evaluation metrics used in the experiment. Then, we present the specific parameters of the CNN network structure. Next, we present the details and data of the experiment. Finally, we compare our experimental results with the state-of-the-art lightweight models developed in recent years.
### _Dateset_
The network in this experiment is used for both 17-classification and 5-classification of ECG data. All data used in the experiment are sourced from the MIT-BIH Arrhythmia database of PhysioNet [28].
The 17-class dataset is the same as Plawiak et al. [29], which includes normal sinus rhythm, pacemaker rhythm, and 15 types of heart failure (with at least 10 signal segments collected for each type). Plawiak et al. randomly selected 1000 10-second ECG signal segments for analysis.
The 5-class dataset contains 7740 10-second segments, and the classification follows the AAMI EC57 standard [30], dividing all data into five categories: ventricular ectopic beat (V), normal or bundle branch block beat (N), supraventricular ectopic beat (S), fusion beat (F), and unknown beat (Q).
Regardless of whether it is the 5-class or 17-class data, we used a signal from one lead (MLII), recorded at 360HZ with 3600 samples in 10 seconds.
Fig. 1: Baseline convolutional neural network (CNN) structure
### _Evaluation Metrics_
The utilization of diverse and rational evaluation metrics allows for a comprehensive assessment of network performance from various perspectives. To holistically evaluate model performance, we employ a variety of indicators including accuracy (ACC), sensitivity (SEN), specificity (SPE), precision (PRE), and F1-score.
### _Specific Parameters of the Network Structure_
After conducting extensive experiments at full precision, we have determined that the optimal number of blocks for CNN is 6. The structures of the 5-class model and the 17-class classification model are almost identical, with the only difference being the output channels of block 6, which correspond to the number of categories for the corresponding arrhythmia. Therefore, by modifying only the final output channel and replacing the network weights, the classifier can switch between 5-class and 17-class classification, endowing the model with universality. Table I presents the specific structural parameters of the proposed CNN. Based on this structure, our model can achieve an accuracy of 97.09% for 5-class classification and 98.00% for 17-class classification at full precision.
### _Experimentation of Binarization Methods_
For the 5-class classification of arrhythmia, our experimental setup utilized a batch size of 512 and a learning rate of 0.02. For the 17-class classification of arrhythmia, we employed a batch size of 64 and a learning rate of 0.002. All datasets were partitioned such that 80% was allocated to the training set and 20% to the testing set, and the models were trained for 1000 epochs.
We tried several popular BNN optimization methods and found that IEE [32] achieved the best accuracy of 96.90% in the 5-class classification model, which is only 0.19% lower than the full precision model. As for the 17-class classification BNN model of arrhythmia, the accuracy always fluctuates between 96.50% and 97.50%, and no method can further improve its accuracy. We refer to the models with accuracies of **96.90%** and **97.50%** as the BP(Better Performance) models.
At the end, we also quantize the ECG signal to \(\{+1,-1\}\) and treat it as an "extreme denoising" technique. Under this circumstance, the first convolution layer can be replaced with XNOR+POPCOUNT. We refer to the model processed in this way as an LP (Low Power) model. Experimental results demonstrate that even under such stringent conditions, our ECG 5-class and 17-class classification models can achieve accuracies of **91.50%** and **92.00%**, respectively.
The storage space required for the 5-class classification model is **3.76KB**, achieving a compression ratio of 29.71x. The corresponding arrhythmia 17-class classification model requires a total storage of **4.45KB**. This results in a memory compression of 29.85x.
Due to space limitations, we only provide the confusion matrix of the BP model in Fig. 2 and Fig. 3.
Fig. 3: Confusion matrix for the 17-class ECG classification model
Fig. 2: Confusion matrix for the 5-class ECG classification model
### _Comparison with State-of-the-Art Lightweight ECG Classification Models in Recent Years_
Table II compares the performance of the proposed model with state-of-the-art lightweight models from various perspectives.We have noticed a dearth of research on 17-class lightweight models for ECG. In order to ensure objective and fair comparison results, we have included Tuncer's full precision work [33] in Table II.
Methodologically, our 1D model is easier to implement in hardware compared to Scrugi et al.'s [20] and Wong et al.'s [24] 2D models.
In terms of bit-width, our model employs 1-bit values for both the activations and weights. This results in a storage footprint that is 8 times smaller than that of the model in work [20], and 16-32 times smaller than that of the model in reference [21] when the number of weights are same.
Regarding the number of distinguishable arrhythmia classes, our model is capable of recognizing 5 and 17 categories, whereas the works [21] and [24] are only able to recognize 2 categories.
In terms of evaluation metrics, we used 5 evaluation metrics, which made up for the shortcomings of insufficient evaluation metrics in work [23]. And the 5-class classification model has the highest specificity of 98.5% among 1-bit models, while the accuracy, specificity, and precision of 17-class classification model are among the highest in all 17-class models, with values of 97.5%, 99.8%, and 96.4%, respectively.
In terms of data processing, our work only standardizes the data. This avoids the hardware considerations brought about by the complex data processing methods of works [20, 21, 23, 33]. Compared to works [22] and [25], which normalize the data, our accuracy is also 1.66% and 1.23% higher than theirs respectively.
Finally, our model's storage occupation is at the state-of-the-art level, with only 3.76 KB of storage required for the 5-class classification model and 4.45 KB for the 17-class classification model.
### _Discussion_
In summary, by binarizing the weights and activations and fusing the operators into a threshold function, our arrhythmia 5-class classification model and 17-class classification model achieved a storage compression of 29.71 and 29.85 times, respectively, with only a slight decrease in accuracy of 0.19% and 0.50%. Even after transforming all the data in the dataset to \(\{+1,-1\}\), our network still achieves an accuracy of no less than 91.50%, which demonstrates its excellent anti-interference capability. Removing the fully connected layer and replacing the softmax layer further simplified the model's complexity and computational burden. While achieving the most advanced storage usage known, the accuracy was superior or equal to that of other models under the same classification standards. Additionally, the universal structure enables wearable devices to switch between 5-class and 17-class monitoring modes.
Due to the limitation of weights and activations to \(\{+1,-1\}\) in the network, our BNN inevitably shows some gaps in evaluation metrics such as SEN and F1-score when compared to the full-precision network. In order to narrow the gap between the BNN and full-precision network in all aspects while maintaining the hardware friendliness of the BNN, this remains a challenging problem to be tackled in future research.
## V Conclusion
In this study, we propose a universal ultra lightweight BNN for 5-class and 17-class classification of long-term ECG signals. Computationally, all convolution operations in the model can be performed using XNOR gates, and the remaining main operations are mathematically fused into a threshold function, which almost completely eliminates multi-bit MAC and further reduces hardware energy consumption. Structurally, the regular structure facilitates future hardware implementation. In terms of model size, the memory consumed by storing the model is at the lowest known level. In the future, we will focus on the FPGA implementation of the BNN model
to test its hardware acceleration effect and other performance parameters in real-life situations.
|
2305.17023 | Are Deep Neural Networks Adequate Behavioural Models of Human Visual
Perception? | Deep neural networks (DNNs) are machine learning algorithms that have
revolutionised computer vision due to their remarkable successes in tasks like
object classification and segmentation. The success of DNNs as computer vision
algorithms has led to the suggestion that DNNs may also be good models of human
visual perception. We here review evidence regarding current DNNs as adequate
behavioural models of human core object recognition. To this end, we argue that
it is important to distinguish between statistical tools and computational
models, and to understand model quality as a multidimensional concept where
clarity about modelling goals is key. Reviewing a large number of
psychophysical and computational explorations of core object recognition
performance in humans and DNNs, we argue that DNNs are highly valuable
scientific tools but that as of today DNNs should only be regarded as promising
-- but not yet adequate -- computational models of human core object
recognition behaviour. On the way we dispel a number of myths surrounding DNNs
in vision science. | Felix A. Wichmann, Robert Geirhos | 2023-05-26T15:31:06Z | http://arxiv.org/abs/2305.17023v1 | # Are Deep Neural Networks Adequate Behavioural Models of Human Visual Perception?
###### Abstract
Deep neural networks (DNNs) are machine learning algorithms that have revolutionised computer vision due to their remarkable successes in tasks like object classification and segmentation. The success of DNNs as computer vision algorithms has led to the suggestion that DNNs may also be good models of human visual perception. We here review evidence regarding current DNNs as adequate behavioural models of human core object recognition. To this end, we argue that it is important to distinguish between statistical tools and computational models, and to understand model quality as a multidimensional concept where clarity about modelling goals is key. Reviewing a large number of psychophysical and computational explorations of core object recognition performance in humans and DNNs, we argue that DNNs are highly valuable scientific tools but that as of today DNNs should only be regarded as promising--but not yet adequate--computational models of human core object recognition behaviour. On the way we dispel a number of myths surrounding DNNs in vision science.
## 1 Introduction
Computational modelling in vision science has a long and rich history dating back at least to Schade's photoelectric analog of the visual system and Reichardt's motion detector [108; 50; 101]. Computational models are useful because, first, a thorough and stringent quantitative understanding of an aspect of human visual perception implies we should be able to build a computational model of it. Second, a computational model can serve as a concrete, testable hypothesis of a theory and deepen our understanding through an iterative process of experimentation, model assessment and model improvement. Models in vision science come in many flavours, some borrowing computational elements such as filters or gain-control from engineering, some using information theory to motivate or derive properties of parts of the model, and others using Bayesian statistics to optimally read-out the activity within a model to derive the model decision: There is substantial diversity of models in vision science, and those models typically use whichever method or algorithm promises to be most helpful in a given context [16].
In computer vision a new class of algorithms from machine learning (ML), so-called deep neural networks or DNNs, have effectively revolutionised the field. DNNs were explicitly developed to solve complex, real-world pattern recognition problems and are now often able to correctly identify an object in a "typical" real-world photograph. DNNs entered centre stage in 2012 when a DNN named AlexNet, designed and trained by Krizhevsky et al. [71], comprehensively won the ImageNet Large Scale Visual Recognition Challenge (ILSVRC): Trained on 1.2 million images it was able to classify a set of 50,000 hitherto unseen images into 1,000 classes with an error rate of 16.4%--down from 25.8% in the previous year (by a non-DNN algorithm; error rates indicate top-5 error, i.e. whether the ground truth label was contained in the top five predictions of the model). Ever since
2012 the ILSVRC was won each year by a DNN, and DNNs are the de facto standard for pattern recognition in machine learning and computer vision1 In essence, a DNN is a nonlinear function approximator implemented as a very large collection of simple units which are connected to (typically a subset) of other units by variable connection strength, the so-called weights. The function of the DNN arises from the collective action of units, their connectivity pattern (the DNN architecture), the weights connecting units and their nonlinear activation function, i.e. how inputs to a unit are combined and transformed into its output passed to other units. DNNs are sometimes said to be based on neuroscience with units (neurons) connected to each other via variable weights (axons and dendrites with synapses of varying strength). The initial inspiration for neural networks did indeed come from neuroscience but DNNs only embody a highly simplified version of real neurons, their rich dynamics, intricate connectivity and dendritic processing complexity. The "neural network" part in the name of DNNs should thus be taken with more than a grain of salt [c.f. 27]. Accessible introductions to DNNs are, for example, LeCun et al. [76], Kriegeskorte [70] or Serre [112]. A comprehensive treatment of DNNs can be found in [47]. In a simplified cartoon-history, DNNs (with four or more layers) could be regarded as the children of (three-layer) connectionism popular from the mid 1980s to the late 1990s [105; 85], and as the grand-children of the (two-layer) perceptron popular from the late 1950s to the late 1960s [86; 104]2. A comprehensive overview of the more complex and multistranded historical development of deep learning is provided by Schmidhuber [109].
Footnote 1: Since 2017 ILSVRC is not run anymore given that DNNs have basically solved the challenge: State-of-the-art (SOTA) top-5 performance is less than 1.0% error. However, the ImageNet dataset still serves as a benchmark and is widely used as such.
Footnote 2: As we state, a highly simplified cartoon-history; we are aware of some of the other DNN milestones like the Neocognitron [33], LeNet [75] or HMax [103] which cannot be placed conveniently in the “family history” as presented above.
## 2 Deep Neural Networks as Tools in Science
DNNs are able to perform highly non-linear mappings from potentially very high dimensional inputs--like images with tens of thousands of pixels--to potentially high dimensional outputs--like the one thousand categories of ImageNet3. DNNs learn the non-linear and high-dimensional input-output mapping from massive amounts of training data alone: they learn which features and dimensions of the input, and their non-linear transformations and combinations, are relevant to solve a (classification) task. This ability to find non-linear, high-dimensional mappings makes DNNs a powerful tool in the sciences in general. Here we would like to draw a distinction between _tools_ and _models_--knowing that the distinction is somewhat blurry at its boundary. Tools are a means to an end, they play an important role in the scientific process but are not, in itself, of scientific interest. In general a model, on the other hand, is a concrete instance of a theory and is itself of scientific interest. Many statistical algorithms or methods and tests are tools: We use linear regression, or analysis of variance (ANOVA) for scientific inference but, typically, we do not take them to be scientific models of the phenomenon under investigation.
Footnote 3: In theory shallow, three-layer networks are already universal function approximators [58; 57]. In practice, however, with finite number of hidden units, finite datasets and computing power, shallow networks did not succeed in solving many interesting, large-scale or real-world problems. DNNs, on the other hand, are phenomenally successful at discovering such non-linear and high-dimensional mappings in practice.
**MODEL VS. TOOL**
**Tool:** Algorithm or statistical method which plays an important role in the scientific process but is not, in itself, of scientific interest; a means to an end.
**Model:** A concrete instance of a theory and itself of scientific interest. Different types of models exist such as statistical or mechanistic models as well as different modelling goals; see section 3.
As tools, DNNs excel in science: For example, DNNs have helped to speed up and improve single-molecule localisation microscopy [114], make fast and accurate 3D protein folding predictions [111], substantially accelerate climate science simulations [98], help in rapid gravitational wave
parameter estimation [20] and in applied mathematics deep reinforcement learning was used to find faster matrix multiplication algorithms [31]. In the neurosciences and vision science DNNs as tools have led to clear improvements of methods: DeepLabCut allows markerless pose estimation of single [84] and multiple animals [74], helping video-based observation and analysis of freely behaving animals. Simulation-based inference allows parameter inference in computational models that, without deep learning, would remain computationally intractable and has begun to see successful cognitive neuroscience applications [46, 8]. [44] argue that so-called generative adversarial networks (GANs) can be used to generate visual stimuli which are, on the one hand, complex and realistic but, at the same time, offer much more control than simply trying to find suitable stock or internet images.
The success of DNNs as tools goes beyond method improvements, however. An important additional role is to use DNNs for exploration, as was clearly and convincingly argued for by [16]4. One aspect of exploration are proof-of-concept or proof-of-principle demonstrations. [96], for example, showed that important aspects of intuitive physics can be acquired entirely through visual, bottom-up, learning. In a similar vein in the domain of gloss perception, [116] used unsupervised DNNs to demonstrate how perceptual dimensions like gloss--only imperfectly corresponding to distal physical properties--can be learned from the entangled proximal stimulus without the need for (Bayesian) prior knowledge or generative models. DNNs can thus be used to explore how richly structured our visual environment is, and how much about the (distal) 3D world could in principle be extracted from (proximal) 2D sensors in a purely discriminative fashion [see e.g. 115]5. Another exploratory aspect of DNNs is the generation of new hypotheses: In beautiful work [102] used a neural network to find a causal role for neurones in the macaque medial superior temporal (MST) area whose tuning properties had hitherto been regarded as puzzling. Their neural network analysis suggests that those neurones may play a role in the decision whether self- and scene motion signals arise from the same source or not--and should thus be either combined or analysed separately by downstream neurones. The usefulness of DNNs as tools in (vision) science is beyond doubt; their immense predictive power in high-dimensional input-output mappings is crucial for advanced method acceleration and development, for stimulus generation and for exploration as in proof-of-principle demonstrations or the generation and test of new computational hypotheses.
Footnote 4: We should note, however, that we differ from [16] in terminology but not in substance: We refer to DNNs for exploration as tools, rather than models. Clustering algorithms or principal-component-analysis (PCA), for example, are also exploratory statistical tools. We prefer to term them tools rather than models because they are typically used as a means to explore rather than a model of the underlying phenomenon.
Sometimes it is tempting to turn successful statistical and computational tools into theories--the _tools to theory heuristic_[43]. Scientists use the tools they use when working as metaphors for the workings of the phenomenon under study. Not perhaps in case of linear regression or ANOVA mentioned above, but a more general example mentioned by Gigerenzer is, e.g., the idea of the mind as a statistician by Brunswick, after Pearson had developed inferential statistics. In vision science a modern successor to this idea is the well-known Bayesian brain hypothesis: Bayesian statistics are a useful tool to analyse experimental data and combine them with prior beliefs. The Bayesian brain hypothesis asserts that the visual system itself applies the Bayesian probability calculus to sensory inputs--not only the scientist trying to understand the brain [c.f. 129]. Given their immense usefulness as tools in general, and their success in object recognition in computer vision in particular, it is thus perhaps not surprising that DNNs have also been proposed as computational models of human (core) object recognition in vision science [e.g. 127, 70, 72]6. We will evaluate DNNs as models of human core object recognition in section 4; first we will have a look at what we require of a good model in the next section.
Footnote 5: One may speculate how much Gibson would have appreciated DNNs as proof-of-principle tools, as he argued throughout his career that the visual input alone—the optic array—is sufficiently rich to allow visual behaviour [42] whereas many Bayesian or predictive coding accounts of vision typically stress the—allegedly—improverished nature of the visual input requiring prior knowledge and/or generative processes to accomplish visual perception. DNNs have clearly demonstrated that much more visual information can be obtained from images or videos alone than some vision scientists may have presumed.
What makes a good model a good model?
As stated in the introduction, computational models are useful because, first, they force scientists to make assumptions explicit and specify dependencies within a model more precisely than is possible by language alone [c.f. 13]. Second, based on prior knowledge and previous insights they serve as concrete, experimentally testable hypotheses of theories and should explain data, processes or how processes interact. To model visual behaviour we traditionally employ mechanistic models: Models that capture human behaviour in terms of inputs and outputs, and whose computational ingredients are domain specific, i.e. informed by, or derived from, basic principles known and established in vision science. Typical mechanistic models of spatial vision, for example, employ spatial filters and divisive contrast gain-control as some of their computational and causal building blocks [e.g. 48, 110]. Mechanistic models in vision science come in different flavours, depending on how much they focus on behaviour versus how much they focus on neurophysiological realism. Mechanistic models of psychophysics are abstracted away from the details of the biological implementation--without, hopefully, being outright neurally implausible. If neural plausibility or realism is one of the goals of modelling, the models' ingredients or computational building blocks closely mimic the neuronal hardware and are linked to behaviour by linking propositions [118]. Statistical models, on the other hand, are only concerned with fitting and predicting data, that is, with the correct mapping between inputs and outputs. Typically they are generic and can be used in many different domains. DNNs used as tools as described in section 2 are a prime example of statistical models. However, we still prefer to refer to them as tools if used as a means to an end only, in order to separate this use from the way they are also claimed to be (statistical) _models_ of core object recognition (the ventral stream). Importantly, in the absence of any concrete computational domain knowledge, statistical models are often the only models one could possibly use and they thus often precede mechanistic models.
**STATISTICAL VS. MECHANISTIC MODEL**
**Statistical Model:** Concerned with fitting or predicting data, a correct input-output mapping; probabilistic model describing the relationship between the independent (input) and dependent (output) variables; general purpose.
**Mechanistic Model:** Attempts to find a mechanistic, causal relationship between inputs and outputs which predicts the data; typically uses domain specific components, processes or transformations.
Apart from different scientific goals leading to different types of models, there are multiple modelling desiderata--what we expect our model to be good at, whatever type of model it may be. For mechanistic models of behaviour the following desiderata are of particular importance: how well the model fits the data ("predictivity"), and how much the model aids understanding ("explanation"). In the following we expand on these modelling desiderata and discuss how well, in general, DNNs _as models_ fulfil them.
### Predictivity
Traditionally _goodness-of-fit_ was assessed when modelling: How well are my (already collected) data described by my model. Furthermore, if several models were compared, _model selection_ was applied to select the model offering the best trade-off between fitting the data and model complexity. With the advent of modern and highly adaptable ML classification algorithms the focus shifted from explaining past data (goodness-of-fit) to a more stringent test, namely predicting new data (often termed generalisation in ML). DNNs are trained--their parameters are optimised--on _training_ data but their performance is assessed how well they _predict_ the hitherto unknown _test_ data. On standard datasets such as ImageNet, or when used as tools in science, DNN prediction performance is often spectacularly good and the reason why DNNs are currently so popular. Predictivity can be measured at different levels: at an aggregate level (e.g. "do models achieve human-level accuracy?"), but also at a more fine-grained level, for instance asking whether models predict human response and error patterns at an individual stimulus/image level, which is a much stricter requirement [c.f. 49]. In the case of classification data, the latter can be measured by _error consistency_[40], an image-level metric to assess the degree of similarity between for instance human and machine error patterns: Whether humans and machines agree on which images are easy or difficult to classify [also see 97].
Good prediction performance, ideally both at the coarse and the fine-grained level, is undoubtedly an important desideratum of a good model. However, we argue below that it is only one aspect of a good model. Using prediction performance on a specific task as a _benchmark_ is exceedingly popular in computer vision and ML, and benchmarks are gaining traction in vision science, too. While benchmarks have fuelled a lot of progress, an over-reliance on benchmarks to measure progress can be problematic if model quality is erroneously thought of as a single dimension along which models can be ranked, turning science into a spectator sport; as we argue here, model assessment is multi-dimensional and a single rank does not do good models justice. Furthermore, benchmarks and rankings encourage small and short-term gains and discourage fundamental re-thinking and the exploration of novel directions which, typically, are initially accompanied by worse performance on a benchmark.
### Explanation
Beyond predictivity, an important desideratum of a good model is that it helps to _explain_ the data and how the building blocks of it are causally linked to the observed behaviour. Thus, a good model helps explain a scientific phenomenon, or at least aids in its interpretation and understanding. One way models act as an explanation and aid understanding is if they are simple--they have a limited number of parameters and contain building blocks or modules with identifiable sub-functions. Many of the mechanistic models in vision science are of this type and they appear to follow the adage of George Box:
Since all models are wrong the scientist cannot obtain a "correct" one by excessive elaboration. On the contrary following William of Occam he should seek an economical description of natural phenomena. Just as the ability to devise simple but evocative models is the signature of the great scientist so overelaboration and overparameterization is often the mark of mediocrity. [11, p. 792]
DNNs are made up from simple, well-understood, computational units, but their decisions result from the interplay of hundreds of thousands of units and millions of connections. As of today, DNN decisions remain largely opaque because the post-hoc methods developed to understand DNNs--and thus provide an explanation for their behaviour useful to a scientist--have not yet matured enough: Neither visualising maximally activating features [35, 9, 131] nor heatmap or saliency methods [65, 90, 2] sufficiently explain the functions learned by DNNs. While the methods may still mature and there also exist promising novel approaches which may help in the future, e.g. [17] or [15], for now DNNs provide not as much of an explanation and do not aid understanding as much as we would like them to--they should thus at best be regarded as _statistical_ models in vision science. It should not be left unmentioned, however, that it is not inconceivable that models of an organ as complex as the brain, and behaviours as complex as, for example, object recognition, cannot be modelled using a simple model--at least not whilst having adequate prediction performance. Highly nonlinear systems may require highly nonlinear models and both are notoriously difficult to understand and analyse. This is true for complex nonlinear mechanistic models as it is true for statistical models like DNNs. For successful models of visual perception there may not be a dichotomy between understandable "traditional" (mechanistic) models on the one hand and impenetrable (statistical) DNNs on the other: It is a matter of the complexity of the behaviour our model should predict. Thus however much we like simplicity it may well be that if we want computational models of complex visual behaviour we have to come to terms with Santiago Ramon Y Cajal's insight into nature:
Unfortunately, nature seems unaware of our intellectual need for convenience and unity, and very often takes delight in complication and diversity. [14, p. 240]
Ideally, models should be highly predictive, show human-like error patterns and aid understanding. In practice, all those desiderata appear difficult to achieve when modelling complex human visual behaviour. Different models may be preferable depending on the modelling purpose: DNNs if a highly predictive model is desirable even if it does not provide much of an explanation. At other times a simple, easy to understand mechanistic model which is not nearly as predictive may still be preferable. Thus a model may not only be either good or bad but can be both: Depending on the purpose, models can simultaneously be great and poor, useful and futile: Model assessment is multi-dimensional.
## 4 Adequately Modelling Visual Core Object Recognition
Model assessment is multi-dimensional--but how adequate are current DNNs as models of human perception? We here restrict ourselves to _core_ object recognition [23]: Our fast and seemingly effortless ability to classify objects in the real world or images (photographs) of objects to belong to a particular class or category at the entry level--a cat, elephant, car, house, aeroplane etc. Clearly, human object recognition is more than only classification (and thus more than core object recognition): We are also able to recognise individual exemplars from large and more or less homogenous classes, most obviously in face recognition [93] but also when recognising our cat amongst a dozen other cats in the garden, our car in a parking lot or our bike in the overcrowded bike-rack in front of a University building [for a review see, e.g. 77]. Obviously, there is also more to human vision than object recognition: We use vision to estimate properties of materials and scenes, assessing, for example, distances and surface angles, or use it to guide behaviour and to navigate. But notwithstanding how much else there is to vision, (core) object recognition is undoubtedly very important for perception:
At a functional level, visual object recognition is at the centre of understanding how we think about what we see.
Object identification is a primary end state of visual processing and a critical precursor to interacting with and reasoning about the world. [94, p. 76]
Furthermore, when assessing the adequacy of DNNs as models of human perception it is fair and appropriate to use a task that is not only important for humans and computationally complex, but also one where DNNs excel at. In computer vision, object recognition is continuing to set the standards for DNN performance. The combination of these factors--the importance of object recognition for human perception, the central role of object recognition within computer vision, and the fact that DNNs trained on object recognition are being proposed as models for primate ventral stream core object recognition--collectively render visual core object recognition perhaps the best task for comparing human against machine behaviour and thus assessing the adequacy of DNNs as models of a particularly important aspect of human visual perception. What needs to be successfully modelled in core object recognition are the following central, often replicated and most important findings [7]: The (rapid) recognition of objects under changes in orientation, illumination, partial occlusion as well as if distorted by (moderate levels of) visual noise.
### Robustness to 3D viewpoints
[127] performed an impressive and influential set of experiments in which they optimised the _architecture_ of their DNNs with respect to the performance of the DNN in their object recognition task. One of their main findings--not central to our discussion here--was a correlation between performance of the DNNs on their object recognition tasks and the DNNs' ability to also predict neuronal firing patterns in monkey inferior temporal cortex (IT). The stimuli used by Yamins et al. to test their DNNs were 64 rendered objects (8 exemplars from each of 8 categories) superimposed on natural images as background (note that the objects and their position were not matched to the background, however, resulting in, for example, a boat or table floating in mid air above a landscape). What is central to the current discussion is that Yamins et al. varied the object views: From easy, canonical views in the low variation condition to strong changes of the orientation of the objects in the high variation condition. We know that one of the strengths of human object recognition is its ability to cope with changes in orientation, as mentioned above. Not surprisingly, thus, observers performed reasonably well also in the high variation condition [127, Fig. 2B, p. 8621]. However, not only did human observers perform reasonably well in the high variation condition, but also their best DNN performed nearly as well (resulting from hierarchical modular optimization, HMO). This result suggested that DNNs may thus be on par with humans in their robustness to viewpoint or object orientation changes.
However, the stimuli used by [127] were, first, comparatively few and, second, not embedded in a natural background but only superimposed. [25] elegantly explored the viewpoint dependence of DNN object recognition systematically for a number of modern DNNs (VGG-16, Inception-v3, DenseNet-121 and five others). They found classification accuracy of all DNNs to be 3D view dependent--and strongly so: Whilst classification accuracy was typically between 70 and 80% for standard ImageNet images, performance dropped dramatically with slightly unusual viewpoints to
_below_ 20% for most DNNs, with the best performing DNN still below 50% accuracy7. Note that none of the problematic viewpoints for DNNs pose any difficulty for human observers: The difficult images for DNNs are quickly and effortlessly recognisable for us--at least the examples shown in the paper, see Fig. 1. Similar results were obtained in related studies by Alcorn et al. [3], Abbas and Deny [1] and Ibrahim et al. [61]. Alcorn et al. concluded that their work "revealed how DNNs' understanding of objects like'school bus' and 'fire truck' is quite naive--they can correctly label only a small subset of the entire pose space for 3D objects" (p. 8). It is as well to note that also the images used by all the studies cited above do not contain occlusions; the tested DNNs sometimes generalise poorly to novel 3D viewpoints despite seeing all the relevant objects in full view. In this regard, a 3D viewpoint robustness gap between humans and machines remains.
Footnote 7: [25] did not simply search for unusual viewpoints but optimised them to find views that are difficult for DNNs, a procedure similar to how adversarial images are generated, see section 4.4. This is the reason the authors call them _adversarial viewpoints_.
### Robustness to image distortions
Core object recognition performance should not only be (largely) viewpoint invariant but also robust against other image distortions such as, for example, moderate levels of visual noise. [37] systematically explored this issue for three DNNs (ResNet-152, VGG-19 and GoogLeNet) using 13 different image distortions or degradations. To several of the image distortions DNNs were clearly much less robust than the psychophysically tested human observers; the discrepancy was particularly pronounced for uniform noise, low-pass and high-pass filtering and the so-called Eidolon distortions [66]. In the case of uniform noise, for example, human observers were still around 50-60% correct at a noise variance for which all tested DNNs were essentially at chance performance (6.25% in a 16-fold identification task). Including the image distortions in the training of the DNNs led to super-human performance for the DNNs on the very distortion included in the training, but there was little to no generalisation to other distortions: Even training on undistorted images and images
with low contrast, low-pass and high-pass filtering, phase noise, image rotation and salt-and-pepper noise did not help the DNNs to cope with uniform noise. Thus [37] concluded there is a large robustness gap between DNNs and human observers in their core object recognition ability in the face of image distortions, a conclusion that is corroborated by many other robustness studies [e.g. 6, 124, 53, 67, 54, 60, 62].
However, progress in deep learning is sometimes remarkably swift and thus [41] re-assessed robustness to image distortions--termed out-of-distribution (OOD) robustness in ML--in 52 "classic" and state-of-the-art (SOTA) DNNs of 2021 using a total of 17 OOD datasets and more than 85.000 psychophysical trials in the laboratory. Overall different DNN architectures and training regimes appear to have little systematic influence on DNN robustness, but DNNs trained on at least 14 million images showed near human OOD robustness, with two models even surpassing humans in an aggregate measure of OOD robustness across the 17 datasets. What remained, however, was that none of the DNNs comes close to human robustness to low-pass filtering, consistent with all what we know about the different image features used by DNNs and humans during object recognition and discussed in the next section 4.3. We should also add that most of the DNN architectures popular in vision science--for example AlexNet, VGG, ResNets, DenseNets, Inception--show poor and clearly sub-human OOD robustness if only trained on ImageNet. The lack of OOD robustness of these DNNs should be kept in mind if one compares one or some of them to human performance or neural systems. Furthermore, while increased OOD robustness through training on large-scale datasets is indeed an impressive achievement of ML, we require more than just similar overall prediction performance if we want to assess DNNs as adequate model of human behaviour: We also require _error consistency_ even for "only" statistical models, as we argued in section 3.1 above. With respect to error consistency there remains a large gap between _all_ of the 52 DNNs and human behaviour: Whilst the 90 human observers showed large agreement which images they felt were easy or difficult to recognise, human-machine error consistency is only at about half the value of human-to-human consistency even for the best DNNs [see Fig. 1 (d), p. 5, in 41]. Given the large remaining gap in error consistency between SOTA DNNs and human observers it appears safe to conclude that even the highly OOD robust DNNs appear to process images differently from human observers.
Figure 1: Visualisation of 3D viewpoint dependence of object categorisation of DNNs. The first column shows the real images from a “natural” viewpoints (correct classification; green label below images). The second column shows the rendered images from a viewpoint optimised to lead to wrong classification (“adversarial viewpoints”). Columns 3 to 6 show real images again but taken to approximate the adversarial viewpoints of column 2 (wrong classification; red or orange labels depending on DNN confidence in classification). _Figure source: [25], Fig. 5, page 9 with kind permission from the authors_.
### Image features underlying object recognition
Initially it was widely believed that DNNs recognise objects based on their shape--similar to how humans recognise objects: "[T]he network acquires complex knowledge about the kinds of shapes associated with each category. [...] High-level units appear to learn representations of shapes occurring in natural images" [70, p. 429] or that intermediate DNN layers recognise "parts of familiar objects, and subsequent layers [...] detect objects as combinations of these parts" [76, p. 436]. However, systematic investigations now seriously challenge this view that DNNs, like humans, recognise objects via their shape. [5] conducted a series of experiments in which DNNs (AlexNet and VGG-19) had to classify silhouettes of objects, silhouettes filled with the texture of another object, glass figurines and outline figures. For all stimulus variations DNNs performed poorly, suggesting that DNNs rely much more on surface characteristics like texture than human observers and lack global shape sensitivity. Similar results were obtained by [12] who successfully trained a ResNet-variant they termed "BagNet" on ImageNet. BagNet exclusively relies on a bag-of-local features--no shape encoding possible--but still performed similar to several standard DNNs like VGG-16, ResNet-152 or DenseNet-169 in terms of interactions between image parts, sensitivity to features and errors.
Whilst the previous two studies assessed only DNN performance--either to changed stimuli or using a DNN architecture only capable of using local image patches for classification--in our own work we compared human behaviour directly with DNN classifications ("DNN behaviour"). We used style-transfer algorithms [36, 59] to create cue-conflict stimuli, combining the shape of one object with the local surface characteristics (texture) of another, e.g. the shape of a cat with the texture (or skin) of an elephant [38]. Human observers in a large-scale psychophysical study predominantly classified the cue-conflict stimuli almost exclusively according to their shape, whereas ImageNet-trained DNNs showed a strong texture bias (57.1%-82.8% depending on architecture), indicating that they do not classify objects according to their shape as humans do. Importantly, human-machine comparisons need to be careful and fair: To ensure a core object recognition comparison in this and all our behavioural experiments presentation time was limited to 200 ms (a single fixation) and all images were immediately followed by a high-contrast 1/f noise mask to minimise, as much as psychophysically possible, feedback influences on perception. Finally, observers had to respond quickly to ensure perceptual rather than cognitive responses: core object recognition.
**Shape vis. Texture bias**
**Shape bias:** The tendency to classify images according to their global shape ("cat" in the example here).
**Texture bias:** The tendency to classify images according to their local texture-like characteristics ("elephant" in the example here).
_Image source: [38] with permission from the authors._
The above result still held at least in 2021 when [41] re-assessed, amongst other performance measures, shape and texture bias of 52 DNNs. Amongst the 52 DNNs were a large variety of different SOTA DNN architectures and training variants, including adversarial training, selfsupervision and image-text training (CLIP). Some modern DNNs--adversarially trained, CLIP--exhibited a more human-like (stronger) shape bias than previous DNNs, but even they remain substantially more texture biased than human observers [41, Fig. 3]. A recent study by Malhotra et al. [81] again confirms that humans, but not the DNNs investigated, have a shape bias even when learning novel stimuli for which texture is more predictive. The authors argue that the human shape bias is likely resulting from an inductive bias for shape [c.f. 89, 128]. [56] identified data augmentation as an important factor in increasing shape bias. Furthermore, [32] generated synthetic DNN metamers: Stimuli that are physically different but have indistinguishable activity at a certain layer of a DNN. While metamers for the early layers were recognisable by human observers, the activity of later layer DNN metamers were not metameric for humans, pointing to a different representation of objects in DNNs and humans. Most DNNs do not use the same image features as humans do when recognising objects; but more recent models increasingly rely on object shapes and less on texture-like characteristics [21].
### Susceptibility to adversarial attacks
What are adversarial examples, and why are they problematic?In a nutshell, [117] showed that for standard DNNs, _any_ image of category A can be made to be misclassified to belong to _any_ arbitary category B through a tiny perturbation, often so small that it is invisible to the human eye. Despite a decade of enormous research efforts to make DNNs robust against adversarial attacks, no principled defense mechanism has been found to date. The current best defense is brute-force _adversarial training_[80], which increases the perturbation needed to fool a DNN (an approach that may or may not achieve human-level robustness in the future). Adversarial examples are arguably one of the most pressing open problems of deep learning research, and researchers have started to ask whether adversarial examples exist for human perception, too. Typical methods to find adversarials for DNNs cannot be applied to human perception which is stochastic, sequence dependent and does not provide gradients. Despite those practical challenges, answering the question of whether there are adversarial examples for humans is highly relevant to the debate around DNNs as models of human visual perception [e.g. 28], since this would either indicate strong similarities or strong differences.
The crocodile conjecture: Humans don't suffer from adversarial examples.Do adversarial examples for humans exist? Strictly speaking the answer is unknown, but we believe it to be exceedingly unlikely that proper adversarial examples exist for humans. Unfortunately, while adversarial examples do have a precise definition, other types of images have in recent years been described in some way or another as "adversarial". Here we first precisely define what a convincing adversarial example for humans would be, applying the same definition that is used to define machine adversarials for a deep neural network \(f\). Starting from an arbitrary image \(i\) with ground truth label \(l\) for which \(f(i)=l\) holds (i.e. the original image is correctly classified by the model), an untargeted \(\epsilon\)-adversarial image is an image \(i+\delta\) such that \(f(i+\delta)\neq l\) and \(||\delta||_{p}\leq\epsilon\). This adversarial example is _untargeted_ since the perturbation \(\delta\) (which is small according to some \(L_{p}\) norm, typically \(p\in\{0,1,2,\infty\}\)) just needs to fool the model into classifying \(i+\delta\) as any class except for the original one. In the case of a _targeted_ adversarial, on the other hand, a target class \(l^{\prime}\) with \(l^{\prime}\neq l\) is chosen beforehand, and then any image \(i+\delta\) such that \(f(i+\delta)=l^{\prime}\) is called a targeted adversarial example (subject to the same constraints as above, i.e. \(f(i)=l\) and \(||\delta||_{p}\leq\epsilon\)).
If we transfer this to human visual perception, this would mean that if humans are indeed susceptible to \(\epsilon\)-targeted adversarial examples, then for an arbitrary image \(i\) such as the bananas in Figure 2 there would be a small perturbation \(\delta\) (\(||\delta||_{p}\leq\epsilon\)) such that a human observer would classify \(i+\delta\) as an arbitrary but pre-specified other class, such as a crocodile. If \(\epsilon\) is large enough, this is trivially possible: We simply replace the banana image by a crocodile image. Hence, the crucial aspect is that the perturbation bounded by \(\epsilon\) needs to be small. A standard ResNet-50 model, for example, can be fooled into classifying the banana image into a baseball/power drill/crocodile image with \(\epsilon=0.01\) (using the \(L_{\infty}\) norm and the [0, 1] image range), as shown in Figure 2. This means that while every pixel may be changed, the maximum allowed perturbation is 0.01/1 or 1% for each pixel. For humans, we believe it is impossible to find a perturbation \(\delta\) subject to \(||\delta||_{\infty}\leq 0.01\) that yields a "crocodile" classification for the banana image. We call this the _crocodile conjecture_ (no adversarial examples for
humans).8 Given the many other types of images that have been termed "adversarial", we believe it is important to be precise when considering what a convincing adversarial example for human visual perception would constitute. In the following, we will attempt to explain what adversarial examples are _not_: neither hard images, nor ambiguous images, nor visual illusions.
Footnote 8: We would love to be proven wrong; thus for anyone attempting to achieve this, a convincing demonstration would consist of a forced choice paradigm where the choices are either banana or crocodile, with viewing times of at least 100–200 ms, foveal presentation, \(\epsilon=0.01\) and \(p=\infty\).
What adversarial examples are not: hard images.To err is human, and making errors is a part of perception, whether biological or artificial. A popular image dataset refers to natural, unmodified images that are particularly hard, i.e. images on which making errors is likely, as "Natural Adversarial Examples" [55]. While the dataset is great, the name is not: these hard images have nothing to do with adversarial examples.
What adversarial examples are not: ambiguous images.Just as the existence of hard images is normal, so is the existence of ambiguous images. Examples include the famous rabbit-duck image [63], hybrid images consisting of conflicting high- and low spatial frequencies [92] or an image that resembles both a cat and a dog as in [29] (Figure 1 in arXiv v1 and v2, Figure Supp. 1 in arXiv v3), or multistable images [e.g. 107]. Convincing adversarial examples are not tied to inherently ambiguous images--in fact, adversarial examples are problematic for DNNs precisely because they can be found for arbitrary images.
What adversarial examples are not: visual illusions.While the precise definition of visual illusions is subject to debate [119], it commonly involves a discrepancy between perception and "reality". According to this definition, adversarial examples--if humans were susceptible to them!--might be considered a new type of visual illusion. Importantly, however, the reverse is not true: None of the visual illusions we know are adversarial examples. Like ambiguous images, known visual illusions are non-general; illusions are very particular stimuli or images like the particular configuration of shapes in case of the Kanisza triangle, a particular configuration of luminances (reflectances) in case of lightness and brightness illusions, or a particular viewing angle as in the case of the Necker cube. No (known) visual illusion matches the definition of an adversarial example.
Relevance of machine adversarials for humans.While no proper adversarials for humans are known, a number of studies investigated whether machine adversarials contain patterns that have relevance to humans, too. [130] showed that humans can sometimes anticipate the predictions of deep learning models to adversarial patterns--which is very different from being susceptible to adversarial patterns (also see [28] for control experiments). Furthermore, [29] showed that human classification
Figure 2: The crocodile conjecture: there are no adversarial examples for humans, i.e. it is impossible to make humans classify the bananas in the left image as a crocodile with a tiny perturbation. The original banana image (left) is adversarially modified (by adding tiny perturbations) such that a ResNet-50 then classifies the resulting perturbed adversarial images as either baseball, power drill or African crocodile (depending on the perturbation). Results based on the pre-trained torchvision [82] ResNet-50 implementation and the targeted \(L_{\infty}\) PGD attack with \(\epsilon=0.01\) implemented by Foolbox [99]. _Image source for original banana image (left): Photo by Rodrigo dos Reis on Unsplash, licensed under the Unsplash license._
decisions at short presentation times (63-71 ms)9 are influenced, to a certain degree, by intermediate-size perturbations that are adversarial to deep learning models. Thus intermediate-size (rather than small-size) adversarial perturbations are more than just arbitrary noise to humans. Unfortunately, the study is often erroneously interpreted as showing that there are adversarial examples for humans. The study's design choices purposefully target a regime where humans are highly prone to making errors (baseline classification performance for the choice between two classes is at around 75%, where 50% is chance level), and the study only used semantically related classes (dog/cat, cabbage/broccoli, spider/snake), not arbitrary ones. These are sensible choices for studying small effects under extreme conditions, but this is different from human core object recognition [23]. [29] studied edge cases, using a paradigm that cannot test general perception for arbitrary classes (e.g. banana/crocodile) under conditions where the original image can be categorized with high accuracy.
Footnote 9: In addition images were not shown in the central fovea (approx. 2 degrees of visual angle) but were rather large, extending to 14.2 degrees of visual angle and thus into the periphery.
Taken together, we believe that humans don't have adversarials that can turn any arbitrary image (such as a banana) into an arbitrary other category (such as a crocodile) with only a tiny perturbation--the crocodile conjecture. Humans rely heavily on shape when recognising objects, and object shape and boundaries cannot be significantly changed using tiny perturbations only. Adversarial examples are a profound problem for DNNs, but not for humans.
## 5 Discussion and Open Issues
Status quo: Not adequate, but promising.As described in Section 4, in spite of their excellent prediction performance on standard image datasets like ImageNet, current DNNs see the world differently from human observers. We have reviewed evidence that DNNs still lack robustness to changes in object pose (Section 4.1) and image distortions (Section 4.2), make non-human-like errors as assessed by error consistency (last paragraph of Section 4.2), exhibit a lack of human-level shape bias (Section 4.3) and show a worrying and non-human susceptibility to adversarial images (Section 4.4). These behavioural differences can be exemplified in the following thought experiment: We could generate a dataset containing only adversarial images and images with slightly different 3D viewpoints. While human classification performance would be largely unaffected, DNN performance, on the other hand, could be driven to 0% correct. Conversely, given the low error-consistency between DNNs and humans, we could select a subset of non-adversarially distorted images for which human performance is consistently poor but DNN performance excellent. In effect we could (almost) create a double-dissociation between DNNs and human observers in terms of core object recognition
performance--impossible if both DNNs and humans recognised images similarly. These profound behavioural differences indicate that current DNNs are not yet adequate behavioural models of human core object recognition. At the same time, we would like to stress that assessing the (in)adequacy of DNNs as models of human core object recognition behaviour can only be a snapshot in time--it is true as of today. This does not mean that DNNs are forever, or for theoretical reasons, incapable of becoming adequate models of human core object recognition. In fact, for all of the current challenges described in Section 4, the tremendous pace of progress in deep learning will very likely lead to improvements. Indeed, DNNs struggle with certain distortions--but even so, more recent models have come a long way from AlexNet performance and even show more human-aligned error patterns [41]. Indeed, DNNs are susceptible to adversarial perturbations--but even so, adversarial training keeps improving robustness [80, 18]. Not always are the same models successful along all desired dimensions--for instance, adversarially trained models perform particularly poorly when exposed to rotated or low-contrast images [41]--but the pace of progress overall is substantial and we are keen to see how the next generation of deep learning models might become more behaviourally faithful.
Excitement vs. disappointment.Deep learning is often described as a revolution, and just like with any revolution there is tremendous excitement and simultaneously profound disappointment. Vision science is no different: on the one hand, the ability of DNNs to fit neural data has led to the assessment that "deep hierarchical neural networks are beginning to transform neuroscientists' ability to produce quantitatively accurate computational models of the sensory systems" [126, p. 364] or claims beyond core object recognition that "[d]deep neural networks provide the current best models of visual information processing in the primate brain" [88, p. 1]. On the other hand, behavioural shortcomings have also led to the assessment that there are "deep problems with neural network models of human vision" [10, p. 1]. We believe that both of those perspectives are understandable, and that some--not all--of these seemingly contradictory accounts can be reconciled through greater clarity about the goal of a particular model. Model quality is not a one-dimensional construct: some models are good in some regards and poor in others. In particular, DNNs are the best _predictive_ models in the history of core object recognition models--on computer vision benchmarks. At the same time, they struggle to show human-like performance on more challenging, human vision
inspired performance tests like 3D viewpoint variation or distortion robustness and have low error consistency with humans; furthermore, currently DNNs are also probably among the most inscrutable models, which constitutes a challenge towards the modelling goal of _explanation_.
Future direction: Vision science for deep learning.In Section 2, we talked about the deep learning as tools in science and vision science. Later, we have seen numerous examples of the value of vision science for deep learning: to understand how they work, where they fail, and how they see the world. Psychophysical studies have revealed current limitations of DNNs that are of interest not only to those interested in building better behavioural models, but better deep learning models in general. Careful and fair comparisons (c.f. 34) are the hallmark of vision science, and the field with its strong scientific foundation has much to offer to deep learning, which is still a predominantly engineering-driven area. In return, we may hope to develop better behavioural models of human visual perception, benefiting from rapid advances in deep learning and the field's engineering ingenuity [79, 95]. Interesting developments in the direction of better vision science inspired methods for scrutinising deep learning include generating _controversial stimuli_[45] to distinguish between candidate models [related to the idea of maximum differentiation competition, or MAD, by 122], using crowding measures to assess the importance of local vs. global features [24], and using a comparative biology approach when comparing human and machine visual perception [78], just to name a few. We are convinced that deep learning can benefit from vision science just as much as vision science can benefit from deep learning methods. This will be particularly true if we move beyond core object recognition to visual perception in general. Some of the challenges ahead are well articulated in [73] and [22]; a more sceptical position regarding DNNs as (only) models of perception and cognition is provided by [83].
Future direction: Understanding inductive biases.In machine learning the necessity to make assumptions in order to learn anything useful has been formalised by the _no free lunch theorem_[125]. But understanding the inductive bias of a particular deep learning model--i.e., the set of assumptions that the model makes ahead of being exposed to data--is often incredibly challenging, and there are many complex interactions between, for instance, model architecture and dataset. In spite of those challenges, we believe that it will be very important to improve our understanding of the assumptions that perceptual systems make. Humans, for instance, are far from being a tabula rasa at birth [128], we have a highly structured brain with appropriate inductive bias to help us learn rapidly and robustly from comparatively little data--while deep neural networks, at the moment, still sometimes require more data than a human can possibly be exposed to during their lifetime [60]. There is much that remains to be understood: How do models and tasks interact with datasets (also see box on MYTH: MORE (OF THE SAME) DATA IS ALL WE NEED)? What are the inductive biases of biologically-inspired filters [19, 30]? We witness that "recent work in AI [...] increasingly favoured computational architectures (for example, graph nets and tranformers) that implement an inductive bias towards relational, compositional processing" [96, p. 1263], while standard, simpler convolutional networks are becoming less and less relevant. In a similar direction, [106] introduced capsule networks arguing that DNNs should have an inductive bias for explicit representation of geometric relationships of objects, which helps in order to be viewpoint invariant [68]. As a final question, may we require an explicit mid-level representation, the _pre-semantic_ experience of the world [91, 4]? Currently DNNs are trained _end-to-end_, from pixels to semantics in one model using one objective function. Should we explicitly train DNNs on psychologically inspired mid-level representations, and then go from them to semantics? Building more adequate models of visual perception will likely require increasing attention to the various explicit and implicit assumptions, or inductive biases, made by different models.
## 6 Conclusion
A decade ago no researcher in vision science would have foreseen the phenomenal progress made by machine learning researchers in the field of neural networks. DNNs are spectacularly successful tools for (vision) science but also promising (statistical) models of core object recognition in terms of their prediction performance on standard computer vision image datasets. However, it is also fair to say that few researchers foresaw the substantial problems remaining for DNNs despite their excellent prediction performance on standard computer vision image datasets: their lack of robustness to object pose and image distortions, their non-human-like errors as assessed by error consistency, their as of now ill-understood dependence on the minutiae of the training images, their lack of human-like shape encoding as well as their susceptibility to adversarial images. Last but not least we are still lacking reliable tools to turn well-predicting but complex and non-transparent DNNs into human-understandable explanations--a desideratum of a scientific model beyond purely statistical models. We argue, thus, that as of today DNNs should be regarded as promising--but not yet adequate--models of human core object recognition performance.
AcknowledgmentsWe would like to thank, in alphabetic order, Guillermo Aguilar, Bart Anderson, Blair Bilodeau, Wieland Brendel, Stephane Deny, Roland Fleming, Tim Kietzmann, Thomas Klein, Been Kim, Pang Wei Koh, Simon Kornblith, David-Elias Kunstle, Marianne Maertens, Sascha Meyen, Lisa Schut, Heiko Schutt, Kate Storrs and Uli Wannek for helpful discussions and/or valuable feedback on aspects of the manuscript, and Roland Zimmermann for toolbox advice. Furthermore, the authors are particularly indebted to Frank Jakel and his numerous critical and insightful comments on previous versions of our manuscript. All opinions expressed in this article are our own and are not necessarily shared by any of the colleagues we thank here.
Felix Wichmann is a member of the Machine Learning Cluster of Excellence, funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy - EXC number 2064/1 - Project number 390727645.
|
2305.10758 | Extracting Low-/High- Frequency Knowledge from Graph Neural Networks and
Injecting it into MLPs: An Effective GNN-to-MLP Distillation Framework | Recent years have witnessed the great success of Graph Neural Networks (GNNs)
in handling graph-related tasks. However, MLPs remain the primary workhorse for
practical industrial applications due to their desirable inference efficiency
and scalability. To reduce their gaps, one can directly distill knowledge from
a well-designed teacher GNN to a student MLP, which is termed as GNN-to-MLP
distillation. However, the process of distillation usually entails a loss of
information, and ``which knowledge patterns of GNNs are more likely to be left
and distilled into MLPs?" becomes an important question. In this paper, we
first factorize the knowledge learned by GNNs into low- and high-frequency
components in the spectral domain and then derive their correspondence in the
spatial domain. Furthermore, we identified a potential information drowning
problem for existing GNN-to-MLP distillation, i.e., the high-frequency
knowledge of the pre-trained GNNs may be overwhelmed by the low-frequency
knowledge during distillation; we have described in detail what it represents,
how it arises, what impact it has, and how to deal with it. In this paper, we
propose an efficient Full-Frequency GNN-to-MLP (FF-G2M) distillation framework,
which extracts both low-frequency and high-frequency knowledge from GNNs and
injects it into MLPs. Extensive experiments show that FF-G2M improves over the
vanilla MLPs by 12.6% and outperforms its corresponding teacher GNNs by 2.6%
averaged over six graph datasets and three common GNN architectures. | Lirong Wu, Haitao Lin, Yufei Huang, Tianyu Fan, Stan Z. Li | 2023-05-18T06:57:06Z | http://arxiv.org/abs/2305.10758v2 | Extracting Low-/High- Frequency Knowledge from Graph Neural Networks and Injecting it into MLPs: An Effective GNN-to-MLP Distillation Framework
###### Abstract
Recent years have witnessed the great success of Graph Neural Networks (GNNs) in handling graph-related tasks. However, MLPs remain the primary workhorse for practical industrial applications due to their desirable inference efficiency and scalability. To reduce their gaps, one can directly distill knowledge from a well-designed teacher GNN to a student MLP, which is termed as GNN-to-MLP distillation. However, the process of distillation usually entails a loss of information, and _"which knowledge patterns of GNNs are more likely to be left and distilled into MLPs?"_ becomes an important question. In this paper, we first factorize the knowledge learned by GNNs into low- and high-frequency components in the spectral domain and then derive their correspondence in the spatial domain. Furthermore, we identified a potential _information drowning_ problem for existing GNN-to-MLP distillation, i.e., the high-frequency knowledge of the pre-trained GNNs may be overwhelmed by the low-frequency knowledge during distillation; we have described in detail what it represents, how it arises, what impact it has, and how to deal with it. In this paper, we propose an efficient _Full-Frequency GNN-to-MLP_ (FF-62M) distillation framework, which extracts both low-frequency and high-frequency knowledge from GNNs and injects it into MLPs. Extensive experiments show that FF-62M improves over the vanilla MLPs by 12.6% and outperforms its corresponding teacher GNNs by 2.6% averaged over six graph datasets and three common GNN architectures. Codes are publicly available at:
## Introduction
In many real-world applications, including social networks, chemical molecules, and citation networks, data can be naturally modeled as graphs. Recently, the emerging Graph Neural Networks (GNNs) [16, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] have demonstrated their powerful capability to handle various graph-related tasks [25, 26, 27, 28]. However, practical deployments of GNNs in the industry are still less popular due to inference efficiency and scalability challenges incurred by data dependency [21, 22]. In other words, GNNs generally rely on message passing to aggregate features from the neighborhood, but fetching and aggregating these nodes during inference can burden latency-sensitive applications. In contrast, Multi-Layer Perceptrons (MLPs) involve no data dependence between pairs of nodes and infer much faster than GNNs, but often with less competitive performance. Motivated by these complementary strengths and weaknesses, one solution to reduce their gaps is to perform GNN-to-MLP knowledge distillation [25, 26, 27, 28], which extracts knowledge from a well-trained teacher GNN and then distills it into a student MLP with the same network architecture (e.g., layer number and layer size).
Most of the existing GNN-to-MLP distillation methods [25, 26, 27] focus on special designs on either student MLPs or teacher GNNs, but default to distill knowledge in a node-to-node fashion. For example, CPF [26] combines Label Propagation (LP) [13] into the student MLPs to improve classification performance and thus still suffers from the neighborhood-fetching latency caused by label propagation, which defeats the original intention of MLPs to be inference-efficient. In contrast, GLNN [26] directly distills knowledge from arbitrary GNNs to vanilla MLPs with the same network architecture. While the distilled MLPs of GLNN can be greatly improved by employing more powerful teacher GNNs, the process of distillation usually entails a loss of information [28], which may lead to sub-optimal student MLPs. In this paper, we look away from specific instantiations of teacher GNNs and student MLPs, but rather explore two fundamental questions: (1) _Can existing GNN-to-MLP distillation ensure that sufficient knowledge is distilled from teacher GNNs to student MLPs?_ If not, (2) _Which knowledge patterns of GNNs are more likely to be distilled into student MLPs?_
**Present Work.** In this paper, we identify a potential _information drowning_ problem for existing GNN-to-MLP distillation, i.e., the high-frequency knowledge of the pre-trained GNNs may be overwhelmed by the low-frequency knowledge during distillation. To illustrate this, we first factorize GNN knowledge into low- and high-frequency components using graph signal processing theory in the spectral domain and then derive their correspondence in the spatial domain. Moreover, we conduct a comprehensive investigation of the
roles played by low- and high-frequency components in the distillation process and describe in detail what _information drowning_ represents, how it arises, what impact it has, and how to deal with it. Extensive experiments have shown that high-frequency and low-frequency knowledge are complementary to each other, and they can further improve performance on top of each other. In this paper, we propose a novel _Full-Frequency GNN-to-MLP_ (FF-G2M) distillation framework, which extracts both low- and high-frequency knowledge from teacher GNNs and injects it into student MLPs.
## Related Work
**Graph Neural Networks (GNNs).** The early GNNs define graph convolution kernels in the spectral domain [1, 13] based on the graph signal processing theory, known as ChebyNet [13] and Graph Convolutional Networks (GCN) [14]. The later GNNs directly define updating rules in the spatial space and focus on the design of neighborhood aggregation functions. For instance, GraphSAGE [1] employs a generalized induction framework to generate embeddings for previously unseen nodes by aggregating known node features. Moreover, GAT [15] introduces the self-attention mechanism to assign different importance scores to neighbors for better information aggregation. We refer interested readers to the surveys [16, 17, 18] for more GNN architectures.
**Graph Knowledge Distillation.** Despite the great progress, most existing GNNs share the de facto design that relies on message passing to aggregate features from neighborhoods, which may be one major source of latency in GNN inference. To address this problem, there are previous works that attempt to distill knowledge from large teacher GNNs to smaller student GNNs, termed as GNN-to-GNN [1, 17, 16, 18]. For example, the student model in RDD [19] and TinyGNN [16] is a GNN with fewer parameters but not necessarily fewer layers than the teacher GNN, which makes both designs still suffer from the neighborhood-fetching latency caused by data dependency.
To enjoy the low-latency of MLPs and high-accuracy of GNNs, the other branch of graph knowledge distillation is to directly distill from large teacher GNNs to student MLPs, termed as GNN-to-MLP. The existing work on GNN-to-MLP distillation can be mainly divided into two branches: student MLPs-focused and teacher GNNs-focused. The former branch, such as CPF [16], _directly_ improves student MLPs by adopting deeper and wider network architectures or incorporating label propagation, both of which burden the inference latency. The other branch, such as GLNN [19], distills knowledge from teacher GNNs to vanilla MLPs with the same network architectures but without other computing-consuming operations; while the performance of their distilled MLPs can be _indirectly_ improved by employing more powerful GNNs, they still cannot match their corresponding teacher GNNs. Moreover, PGKD [17] proposes a Prototype-Guided Knowledge Distillation (PGKD) method, which does not require graph edges yet learns structure-aware MLPs. In this paper, we aim to develop a **model-agnostic** GNN-to-MLP distillation that is applicable to various GNN architectures.
**Noticons.** Let \(\mathcal{G}=(\mathcal{V},\mathcal{E},\mathbf{X})\) be an attributed graph, where \(\mathcal{V}\) is the set of \(N\) nodes with features \(\mathbf{X}=[\mathbf{x}_{1},\mathbf{x}_{2},\cdots,\mathbf{x}_{N}]\in\mathbb{R} ^{N\times d}\) and \(\mathcal{E}\) denotes the edge set. Each node \(v_{i}\in\mathcal{V}\) is associated with a \(d\)-dimensional features vector \(\mathbf{x}_{i}\), and each edge \(e_{i,j}\in\mathcal{E}\) denotes a connection between node \(v_{i}\) and \(v_{j}\). The graph structure is denoted by an adjacency matrix \(\mathbf{A}\in[0,1]^{N\times N}\) with \(\mathbf{A}_{i,j}=1\) if \(e_{i,j}\in\mathcal{E}\) and \(\mathbf{A}_{i,j}=0\) if \(e_{i,j}\notin\mathcal{E}\). Consider a semi-supervised node classification task where only a subset of node \(\mathcal{V}_{L}\) with labels \(\mathcal{Y}_{L}\) are known, we denote the labeled set as \(\mathcal{D}_{L}=(\mathcal{V}_{L},\mathcal{Y}_{L})\) and unlabeled set as \(\mathcal{D}_{U}=(\mathcal{V}_{U},\mathcal{Y}_{U})\), where \(\mathcal{V}_{U}=\mathcal{V}\backslash\mathcal{V}_{L}\). The node classification aims to learn a mapping \(\Phi:\mathcal{V}\rightarrow\mathcal{Y}\) with labeled data, so that it can be used to infer the labels \(\mathcal{Y}_{U}\).
**Graph Neural Networks (GNNs).** Most existing GNNs rely on message passing to aggregate features from the neighborhood. A general GNN framework consists of two key computations for each node \(v_{i}\): (1) \(\mathrm{AGGREGATE}\): aggregating messages from neighborhood \(\mathcal{N}_{i}\); (2) \(\mathrm{UPDATE}\): updating node representation from its representation in the previous layer and aggregated messages. Considering a \(L\)-layer GNN, the formulation of the \(l\)-th layer is as follows
\[\mathbf{m}_{i}^{(l)}= \,\mathrm{AGGREGATE}^{(l)}\left(\left\{\mathbf{h}_{i}^{(l-1)}:v_{ j}\in\mathcal{N}_{i}\right\}\right) \tag{1}\] \[\mathbf{h}_{i}^{(l)}= \,\mathrm{UPDATE}^{(l)}\left(\mathbf{h}_{i}^{(l-1)},\mathbf{m}_ {i}^{(l)}\right)\]
where \(1\leq l\leq L\), \(\mathbf{h}_{i}^{(0)}=\mathbf{x}_{i}\) is the input feature, and \(\mathbf{h}_{i}^{(l)}\) is the representation of node \(v_{i}\) in the \(l\)-th layer.
**Multi-Layer Perceptrons (MLPs).** To achieve efficient inference, the vanilla MLPs (with the same network architecture as the teacher GNNs) are used as the student model by default in this paper. For a \(L\)-layer MLP, the \(l\)-th layer is composed of a linear transformation, an activation function \(\sigma=\mathrm{ReLu}(\cdot)\), and a dropout function \(\mathrm{Dropout}(\cdot)\), as
\[\mathbf{z}_{i}^{(l)}=\mathrm{Dropout}\left(\sigma\big{(}\mathbf{z}_{i}^{(l-1)} \mathbf{W}^{(l-1)}\big{)}\big{)},\quad\mathbf{z}_{i}^{(0)}=\mathbf{x}_{i} \tag{2}\]
where \(\mathbf{W}^{(0)}\in\mathbb{R}^{d\times F}\) and \(\mathbf{W}^{(l)}\in\mathbb{R}^{F\times F}\)\((1\leq l<L)\) are weight matrices with the hidden dimension \(F\). In this paper, the network architecture of MLPs, such as the layer number \(L\) and layer size \(F\), is set the same as that of teacher GNNs.
**GNN-to-MLP Knowledge Distillation.** The knowledge distillation is first introduced in [10] to handle mainly image data, where knowledge is transferred from a cumbersome teacher model to a simpler student model. The later works on GNN-to-MLP distillation [16, 19, 16, 17] extend it to the graph domain by imposing KL-divergence constraint \(\mathcal{D}_{KL}(\cdot,\cdot)\) between the softmax label distributions generated by teacher GNNs and student MLPs and directly optimizing the objective function as follows
\[\mathcal{L}_{\mathrm{KD}}=\frac{1}{|\mathcal{V}|}\sum_{i\in\mathcal{V}} \mathcal{D}_{KL}\left(\mathrm{softmax}\left(\mathbf{z}_{i}^{(L)}\right),\mathrm{ softmax}\left(\mathbf{h}_{i}^{(L)}\right)\right) \tag{3}\]
## Knowledge Factorization from the Perspective of Spectral and Spatial Domain
In this section, we first theoretically factorize the knowledge learned by GNNs into low- and high-frequency components in the spectral domain based on graph signal processing theory (Shuman et al., 2013). The normalized graph Laplacian matrix of graph \(\mathcal{G}\) is defined as \(\mathbf{L}=\mathbf{I}_{N}-\widetilde{\mathbf{D}}^{-\frac{1}{2}}\widetilde{ \mathbf{A}}\widetilde{\mathbf{D}}^{-\frac{1}{2}}\), where \(\widetilde{\mathbf{A}}=\mathbf{A}+\mathbf{I}_{N}\in\mathbb{R}^{N\times N}\) is an adjacency matrix with self-loop, \(\widetilde{\mathbf{D}}\in\mathbb{R}^{N\times N}\) is a diagonal degree matrix with \(\widetilde{\mathbf{D}}_{i,i}=\sum_{j}\widetilde{\mathbf{A}}_{i,j}\), and \(\mathbf{I}_{N}\) denotes the identity matrix. Since \(\mathbf{L}\) is a real symmetric matrix, it can be eigendecomposed as \(\mathbf{L}=\mathbf{U}\Lambda\mathbf{U}^{\top}\), where \(\Lambda=\mathrm{diag}\left([\lambda_{1},\lambda_{2},\cdots,\lambda_{N}]\right)\) with each eigenvalue \(\lambda_{l}\in[0,2]\) corresponding to an eigenvectors \(\mathbf{u}_{l}\) in \(\mathbf{U}\)(Chung and Graham, 1997). According to graph signal processing theory, we can directly take the eigenvector \(\{\mathbf{u}_{l}\}_{l=1}^{N}\) as bases. Given signal \(\mathbf{x}\in\mathbb{R}^{d}\), the graph Fourier transform and inverse Fourier transform (Sandryhaila and Moura, 2013; Ricaud et al., 2019) are defined as \(\widehat{\mathbf{x}}=\mathbf{U}^{\top}\mathbf{x}\) and \(\mathbf{x}=\mathbf{U}\widehat{\mathbf{x}}\). Thus, the convolutional \(*_{G}\) between the signal \(\mathbf{x}\) and convolution kernel \(\mathcal{F}\) can be defined as follows
\[\mathcal{F}*_{G}\mathbf{x}=\mathbf{U}\left(\left(\mathbf{U}^{\top}\mathcal{F }\right)\odot\left(\mathbf{U}^{\top}\mathbf{x}\right)\right)=\mathbf{U} \mathbf{g}_{\theta}\mathbf{U}^{\top}\mathbf{x} \tag{4}\]
where \(\odot\) denotes the element-wise product and \(\mathbf{g}_{\theta}\) is a parameterized diagonal matrix. Most of the existing GNNs architectures can be regarded as a special instantiation on the convolutional kernel \(\mathcal{F}\) (i.e., the matrix \(\mathbf{g}_{\theta}\)). For example, GCN-Cheby parameterizes \(g_{\theta}\) with a polynomial expansion \(\mathbf{g}_{\theta}=\sum_{k=0}^{K-1}\alpha_{k}\Lambda^{k}\), and GCN defines the convolutional kernel as \(\mathbf{g}_{\theta}\!=\!\mathbf{I}_{N}-\Lambda\). Considering a special convolution kernel \(\mathcal{F}_{A}\!=\!\mathbf{I}_{N}\), we have \(\mathcal{F}_{A}*_{G}\mathbf{x}\!=\!\mathbf{U}\mathbf{I}_{N}\mathbf{U}^{\top} \mathbf{x}\!=\!\mathbf{U}\widehat{\mathbf{x}}\!=\!\mathbf{x}\), i.e., this is an identity mapping, where all information can be preserved. Next, we decompose the graph knowledge into low-frequency and high-frequency components (Bo et al., 2021; Wu et al., 2019) by factorizing \(\mathcal{F}_{A}\!=\!\mathbf{I}_{N}\) as follows
\[\mathcal{F}_{A}\!=\!\mathbf{I}_{N}\!=\!\frac{1}{2}\!\left(\left(\underbrace{ \mathbf{I}_{N}+\widetilde{\mathbf{D}}^{-\frac{1}{2}}\widetilde{\mathbf{A}} \widetilde{\mathbf{D}}^{-\frac{1}{2}}}_{\text{Low-Phase Filter}\,\,\mathcal{F}_{M}} \right)+\left(\underbrace{\mathbf{I}_{N}-\widetilde{\mathbf{D}}^{-\frac{1}{2}} \widetilde{\mathbf{A}}\widetilde{\mathbf{D}}^{-\frac{1}{2}}}_{\text{High- Phase Filter}\,\,\mathcal{F}_{H}}\right)\right)\]
For a given signal \(\mathbf{x}\in\mathbb{R}^{d}\), e.g., node feature, we have \(\mathcal{F}_{A}*_{G}\mathbf{x}=\frac{1}{2}\left(\mathcal{F}_{M}+\mathcal{F}_{H} \right)*_{G}\mathbf{x}=\frac{1}{2}(\mathcal{F}_{M}*_{G}\mathbf{x}+\mathcal{F} _{H}*_{G}\mathbf{x})=\mathbf{x}\), which means that any signal \(\mathbf{x}\) can be decomposed into the average of two components \(\mathcal{F}_{M}*_{G}\mathbf{x}\) and \(\mathcal{F}_{H}*_{G}\mathbf{x}\).
**Analysis on the Spectral Domain.** The Proposition 1 states what the two components \(\mathcal{F}_{M}*_{G}\mathbf{x}\) and \(\mathcal{F}_{H}*_{G}\mathbf{x}\) represent.
**Proposition 1**: _The convolution kernel \(\mathcal{F}_{M}\) works as a low-pass filter, which filters out high-frequency information, and \(\mathcal{F}_{M}*_{G}\mathbf{x}\) represents low-frequency knowledge; \(\mathcal{F}_{H}\) works as a high-pass filter, which filters out low-frequency information, and \(\mathcal{F}_{H}*_{G}\mathbf{x}\) represents high-frequency knowledge._
**Proof 1**: _For a \(L\)-layer GNN, the signal \(\mathbf{x}\) is filtered by the \(L\)-order convolution kernel \(\mathcal{F}_{M}^{L}=(\mathbf{I}_{N}+\widetilde{\mathbf{D}}^{-\frac{1}{2}} \widetilde{\mathbf{A}}\widetilde{\mathbf{D}}^{-\frac{1}{2}})^{L}=(2\mathbf{I}_ {N}-\mathbf{L})^{L}\) to output \(\mathcal{F}_{M}^{L}*_{G}\mathbf{x}=\mathbf{U}(2\mathbf{I}_{N}-\Lambda)^{L} \mathbf{U}^{\top}\mathbf{x}\) with \(g_{\theta}^{L}(\lambda_{i})=(2-\lambda_{i})^{L}\). As shown in Fig. 1, \(g_{\theta}^{L}(\lambda_{i})\) decreases monotonically in the range \(\lambda_{i}\in[0,2]\) and reaches \(g_{\theta}^{L}(\lambda_{i}\!=\!2)=0\) at \(\lambda_{i}=2\), which mainly amplifies the low-frequency information and filters out the high-frequency information. Similarly, the \(L\)-order convolution kernel \(\mathcal{F}_{H}^{L}\) has \(g_{\theta}^{L}(\lambda_{i})=\lambda_{i}^{L}\). As shown in Fig. 1, \(g_{\theta}^{L}(\lambda_{i})\) increases monotonically in the range \(\lambda_{i}\in[0,2]\) and reaches \(g_{\theta}^{L}(\lambda_{i}=0)=0\) at \(\lambda_{i}=0\), which mainly filters out the low-frequency information but in turn amplifies the high-frequency information._
**Correspondence on the Spatial Domain.** We have derived that \(\mathcal{F}_{M}*_{G}\mathbf{x}\) and \(\mathcal{F}_{H}*_{G}\mathbf{x}\) represent mainly the low- and high-frequency components of signal \(\mathbf{x}\), and we next can derived their correspondences in the spatial domain, as follows
\[\mathcal{F}_{M}*_{G}\mathbf{x}_{i} \rightarrow \mathbf{x}_{i}^{(low)}=\mathbf{x}_{i}+\sum_{j\in\mathcal{N}_{i}} \frac{\mathbf{x}_{j}}{\sqrt{|\mathcal{N}_{i}||\mathcal{N}_{j}|}} \tag{5}\] \[\mathcal{F}_{H}*_{G}\mathbf{x}_{i} \rightarrow \mathbf{x}_{i}^{(high)}=\mathbf{x}_{i}-\sum_{j\in\mathcal{N}_{i}} \frac{\mathbf{x}_{j}}{\sqrt{|\mathcal{N}_{i}||\mathcal{N}_{j}|}}\]
By the derivation in Eq. (5), the low-frequency knowledge \(\mathcal{F}_{M}*_{G}\mathbf{x}\) is the sum of node feature and its neighborhood features in the spatial domain. On the other hand, the high-frequency knowledge \(\mathcal{F}_{H}*_{G}\mathbf{x}\) represents the differences between the target node feature with its neighborhood features. There have recently been some novel GNN models (Bo et al., 2021; Pei et al., 2020; Zhu et al., 2020; Chien et al., 2021) that can capture both low- and high-frequency information simultaneously or adaptively. However, in this paper, we focus on the design of distillation objective functions and do not consider indirect performance improvements by employing these more powerful but complex GNNs. Instead, we consider the most commonly used GNNs, such as GCN (Kipf and Welling, 2016), GraphSAGE (Hamilton, Ying, and Leskovec, 2017), and GAT (Velickovic et al., 2017), all of which rely on multi-layer message passing to aggregate features of neighboring nodes that are multiple hops away, i.e., they essentially work as a low-pass filter \(\mathcal{F}_{M}^{L}\) or its variants.
## Roles Played by Low- and High-Frequency Knowledge during Distillation
### Rethinking the Core of Knowledge Distillation
We rethink the core of knowledge distillation from three shallow-to-deep perspectives to highlight our motivations.
* _Firstly_, knowledge distillation enables the representations of MLPs to "mimic" those of GNNs as closely as possible by imposing KL-divergence constraints between their softmax distribution probabilities. However, such a
Figure 1: Eigenvalues _vs._ Amplitudes
mimicking (or fitting) process is inevitably accompanied by a loss of information, especially high-frequency information, which explains why the performance of student MLPs is always hard to match with that of teacher GNNs.
* _Secondly_, for a neural network framework, any change in the final representations is achieved indirectly by optimizing the mapping function, i.e., the network parameters. In this sense, knowledge distillation essentially optimizes the parameter matrices \(\{\mathbf{W}^{(l)}\}_{l=0}^{L-1}\) of the student MLPs to make it functionally approximates the convolution kernel of the teacher GNNs, which makes the student MLPs also serve as a low-pass filter \(\widetilde{\mathcal{F}}_{M}^{L}\) for graph data.
* _Finally_, the low-pass filter in the spectral domain is equivalent to neighborhood aggregation in the spatial domain as derived in Eq. (5), which in essence can be considered as a special use of the graph topology.
To explore the roles played by graph topology during GNN-to-MLP distillation, we plot the _mean cosine similarity_ of nodes with their first-order neighbors for vanilla GCNs, vanilla MLPs, and Distilled MLPs (GLNN) on the Cora dataset in Fig. 2(a), from which we observe that the mean similarity of GCNs and GLNN gradually increases with training, while that of vanilla MLPs gradually decreases, which indicates that knowledge distillation has introduced graph topology as an inductive bias (as GCNs has done), while vanilla MLPs do not. As a result, the distilled MLPs can enjoy the benefits of topology-awareness in training but without neighborhood-fetching latency in inference.
### High-Frequency Information Drowning
Next, we discuss a potential high-frequency information drowning problem from both spectral and spatial domains, i.e., the high-frequency information of the pre-trained GNNs may be overwhelmed by the low-frequency knowledge during the process of GNN-to-MLP knowledge distillation.
**How information drowning arises?**_From the perspective of spectral domain_, the knowledge distillation optimizes the network parameters of the student MLPs to make it functionally approximate the convolution kernel of the teacher GNNs, i.e., \(\widetilde{\mathcal{F}}_{M}^{L}\approx\mathcal{F}_{M}^{L}\). The information loss induced by such approximation may be inconsequential for high-amplitude low-frequency information but can be catastrophic for those high-frequency information with very low amplitude, as shown in Fig. 2(c). As a result, compared to low-frequency information, high-frequency information is more likely to be drowned by these optimization errors.
**What impact does information drowning have?**_From the perspective of spatial domain_, the information drowning may lead to distilled MLPs that, despite preserving neighborhood smoothing well, can easily neglect differences between nodes, such as pairwise distances. To illustrate this, we consider a target node \(v_{i}\) and its two neighboring nodes \(v_{j}\) and \(v_{k}\) in Fig. 2(d), where they are mapped closely by GNNs. In the process of knowledge distillation, the representations of these three nodes may be mapped around the representations of teacher GNNs, i.e., they are still mapped closely with most of their low-frequency information preserved; however, the relative distances between nodes, i.e., their high-frequency information, may be drowned dramatically. For example, node \(v_{i}\) is adjacent to node \(v_{j}\) but far from node \(v_{k}\) in the representation space of teacher GNNs. However, in the representation space of student MLPs, node \(v_{i}\) becomes closer to node \(v_{k}\) and farther from node \(v_{j}\).
The curves of the pairwise distance differences between the teacher GCNs and the student MLP in Fig. 2(b) show that common knowledge distillation (e.g., GLNN) is not good at capturing high frequency information, compared to our proposed FF-G2M. Moreover, extensive qualitative and quantitative experiments have been provided to demonstrate the harmfulness of the identified high-frequency information drowning problem in the experimental section. The detailed experimental settings, including hyperparameters and evaluation metric definitions, are available in **Appendix B&E**.
## Full-Frequency GNN-to-MLP (FF-G2M) Knowledge Distillation
The above discussions reached two important insights: (1) the inductive bias of graph topology plays an important role, and (2) it is mainly the low-frequency knowledge of graph data that has been distilled from the teacher GNNs to the student MLPs. Inspired by these two insights, we propose _Low-Frequency Distillation_ (LFD) and _High-Frequency Distillation_ (HFD) to fully capture the low-frequency and high-frequency knowledge learned by GNNs, respectively. An high-level overview of the proposed _Full-Frequency GNN-to-MLP_ (FF-G2M) framework is shown in Fig. 3.
Figure 2: (a) Mean cosine similarity (the higher, the better) between nodes with their first-order neighbors on Cora. (b) Pairwise distance differences (the lower, the better) between teacher GCNs and student MLPs on Cora. (c)(d) Illustrations of how the high-frequency information drowning arises and what potential impact it has in the spectral and spatial domains, respectively.
### Low-Frequency Distillation (LFD)
The node representations of teacher GNNs are generated by explicit message passing, so it mainly captures the low-frequency information of the graph data as analyzed earlier. Unlike aggregating features from neighborhoods as in GNNs, we directly distill (diffuse) knowledge from teacher GNNs into the neighborhoods of student MLPs in order to better utilize topological information and low-frequency knowledge captured by GNNs, formulated as follows
\[\mathcal{L}_{\mathrm{LFD}}\!=\!\frac{1}{|\mathcal{E}|}\sum_{i\in\mathcal{V}}\sum_ {j\in\mathcal{N}_{i}\cup i}\mathcal{D}_{KL}\Big{(}\sigma(\mathbf{z}_{j}^{(L)} /\tau_{1}),\sigma(\mathbf{h}_{i}^{(L)}/\tau_{1})\Big{)} \tag{6}\]
where \(\tau_{1}\) is the low-frequency distillation temperature, and \(\sigma=\mathrm{softmax}(\cdot)\) denotes an activation function.
### High-Frequency Distillation (HFD)
As derived in Eq. (5), the high-frequency components in the spectral domain represent the differences between node feature and its neighborhood features in the spatial domain. Inspired by this, we propose High-Frequency Distillation (HFD), a GNN knowledge objective that trains student MLPs to preserve the neighborhood pairwise differences from the representation space of teacher GNNs. The neighborhood pairwise differences around node \(v_{i}\) are defined as the differences between the target node feature \(\mathbf{s}_{i}\) and its neighborhood features \(\{\mathbf{s}_{j}\mid j\in\mathcal{N}_{i}\}\), which can be computed by the kernel \(\mathcal{K}\left(\mathbf{s}_{i},\mathbf{s}_{j}\right)=|\mathbf{s}_{i}-\mathbf{ s}_{j}|\), where \(|\cdot|\) denotes the element-wise absolute values. The high-frequency distillation trains the student model to mimic the neighborhood pairwise differences from the teacher GNNs via KL-divergence constraints, which can be defined as follows
\[\mathcal{L}_{\mathrm{HFD}}\!=\!\frac{1}{|\mathcal{E}|}\sum_{i\in \mathcal{V}}\sum_{j\in\mathcal{N}_{i}}\mathcal{D}_{\mathrm{KL}}\Big{(}\sigma \big{(}\mathcal{K}\big{(}\mathbf{z}_{i}^{(L)},\mathbf{z}_{j}^{(L)}\big{)}/ \tau_{2}\big{)}, \tag{7}\] \[\sigma\big{(}\mathcal{K}\big{(}\mathbf{h}_{i}^{(L)},\mathbf{h}_{ j}^{(L)}\big{)}/\tau_{2}\big{)}\Big{)}\]
where \(\mathcal{K}\left(\cdot,\cdot\right)\) denotes the element-wise absolute values, and \(\tau_{2}\) is the high-frequency distillation temperature.
### Training Strategy
The pseudo-code of the FF-G2M framework is summarized in **Appendix C**. To achieve GNN-to-MLP knowledge distillation, we first pre-train the teacher GNNs with the classification loss \(\mathcal{L}_{\mathrm{label}}=\frac{1}{|\mathcal{V}_{L}|}\sum_{i\in\mathcal{V}_ {L}}\mathcal{H}\big{(}y_{i},\sigma(\mathbf{h}_{i}^{(L)})\big{)}\), where \(\mathcal{H}(\cdot)\) denotes the cross-entropy loss and \(y_{i}\) is the ground-truth label of node \(v_{i}\). Finally, the total objective function to distill the low- and high-frequency knowledge from the teacher GNNs into the student MLPs is defined as follows
\[\mathcal{L}_{\mathrm{total}}=\frac{\lambda}{|\mathcal{V}_{L}|}\sum_{i\in \mathcal{V}_{L}}\mathcal{H}\big{(}y_{i},\sigma(\mathbf{z}_{i}^{(L)})\big{)}\! +\!\big{(}1\!-\!\lambda\big{)}\big{(}\mathcal{L}_{\mathrm{LFD}}\!+\!\mathcal{L }_{\mathrm{HFD}}\big{)}\]
where \(\lambda\) is the weights to balance the influence of the classification loss and two knowledge distillation losses. The time complexity analysis of FF-G2M is available in **Appendix D**.
### Discussion and Comparision
In this subsection, we compare the proposed FF-G2M framework with the commonly used node-to-node distillation (e.g., GLNN) in Fig. 3. While the node-to-node distillation can map neighboring nodes closely in the representation space of MLPs, i.e., preserving low-frequency knowledge, it completely confounds the relative distance between node pairs, i.e., high-frequency knowledge is drowned, leading to a different (incorrect) class-boundary with the teacher GNNs. In terms of the proposed FF-G2M framework, the Low-Frequency Distillation distills (diffuses) the features aggregated from the neighborhood in the teacher GNNs back into their neighborhood of the student MLPs to better utilize the extracted low-frequency knowledge. Besides, High-Frequency Distillation directly distills the neighborhood pairwise differences from teacher GNNs into the student MLPs to better capture the high-frequency knowledge patterns, i.e., the relative positions between pairs of nodes.
## Experiments
**Datasets.** The effectiveness of the FF-G2M framework is evaluated on six public real-world datasets, including Cora [14], Citeseer [11], Pubmed [15], Coauthor-CS, Coauthor-Physics, and Amazon-Photo [12]. For each dataset, following the data splitting settings of [13, 14], we select 20 nodes per class to construct a training set, 500 nodes for validation, and 1000 nodes for testing. A statistical overview
Figure 3: Illustration of the Full-Frequency GNN-to-MLP (FF-G2M) distillation framework, where the dotted red lines denote the predicted class-boundary, the solid black lines denote feature aggregation from the neighborhood, and the dashed black lines denote the distillation of knowledge (neighborhood features and pairwise distances) from teacher GNNs to student MLPs.
of these datasets is placed in **Appendix A**. Besides, we defer the implementation details and hyperparameter settings for each dataset to **Appendix B** and supplementary materials.
**Baselines.** Three basic components in knowledge distillation are (1) teacher model, (2) student model, and (3) distillation loss. As a model-agnostic general framework, FF-G2M can be combined with any teacher GNN architecture. In this paper, we consider three types of teacher GNNs, including GCN [11], GraphSAGE [10], and GAT [21]. As for the student model, we default to using pure MLPs (with the same network architecture as the teacher GNNs) as the student model for a fair comparison. Finally, the focus of this paper is on designing distillation objectives rather than powerful teacher and student models. Therefore, we only take GLNN [13] as an important baseline to compare FF-G2M with the conventional node-to-node distillation approach. The experiments of all baselines and FF-G2M are implemented based on the standard implementation in the DGL library [23] using PyTorch 1.6.0 library on NVIDIA V100 GPU. Each set of experiments is run five times with different random seeds, and the average are reported as metrics.
### Classification Performance Comparison
This paper aims to explore which knowledge patterns _should_ and _how to_ be distilled into student MLPs, rather than designing more powerful teacher GNNs. Therefore, we consider three classical GNNs, including GCN, GraphSAGE, and GAT, as the teacher models and distill their knowledge into MLPs with the same network architecture. The experimental results on six datasets are reported in Table. 1, from which we can make the following observations: (1) In general, more powerful teacher GNNs can lead to student MLPs with better classification performance. However, such improvements are usually very limited and do not work for all datasets and GNN architectures. For example, on the Citeseer dataset, the performance of GLNN drops over the vanilla implementation of teacher GNNs by 0.4% (GraphSAGE) and 0.6% (GAT), respectively. (2) The proposed FF-G2M framework can consistently improve the performance of student MLPs across three GNN architectures on all six datasets. For example, FF-G2M can outperform vanilla teacher GNNs by 2.63% (GCN), 2.58% (GraphSAGE), and 2.55% (GAT) averaged over six datasets, respectively.
### Qualitative and Quantitative Analysis
Extensive qualitative and quantitative experiments are conducted to explore the existence and harmfulness of the information drowning problem and how to solve it by FF-G2M.
**Qualitative Analysis on Visualizations.** We consider GCNs as the teacher model and compare its visualization with that of vanilla MLPs, GLNN, and FF-G2M on the Cora dataset (due to space limitations, more results can be found in **Appendix F**). We select a target node (id 27 for Cora) and analyze its relative position relationship with its neighbors in Fig.4, from which we observe that: (1) The vanilla MLPs map neighboring nodes apart, which indicates that it is not even good at capturing low-frequency information. (2) GLNN fails to capture the relative positions between the target node and its neighbors, i.e., high-frequency information. (3) FF-G2M well preserves the relative positions between nodes while mapping neighboring nodes closely, which suggests that it is good at capturing both low- and high-frequency information. For example, on the Cora dataset, the target node (id 27) is the closest to node (id 1810) and the farthest from node (id 2678) in the visualizations of both teacher GCNs and FF-G2M's student MLPs.
high-frequency knowledge, measured by _KL-divergence_ between the pairwise distances of teacher GNNs and student MLPs, respectively. The detailed mathematical definitions of these two evaluation metrics are available in **Appendix E**. From the experimental results on the Cora dataset reported in Fig. 5, we make four observations: (1) The vanilla MLP does not consider the inductive bias of the graph topology at all and thus fails to capture the low-and high-frequency knowledge in the graph data. (2) GLNN is capable of successfully capturing low-frequency information, i.e., neighborhood smoothing, but is not good at capturing high-frequency knowledge, i.e., difference information between pairs of nodes. (3) The proposed low- and high-frequency distillation has an advantage over GLNN in capturing one type of individual frequency but lags behind in another frequency. (4) The proposed FF-G2M combines both the two distillation and is better at capturing both low- and high-frequency knowledge than GLNN, especially the latter.
### Roles of Low- and High-frequency Knowledge
To evaluate the roles played by low- and high-frequency knowledge in GNN-to-MLP distillation, we consider distillation with only \(\mathcal{L}_{\mathrm{LFD}}\) and \(\mathcal{L}_{\mathrm{HFD}}\), in addition to the full FF-G2M model. The experiments (with GCNs as the teacher model) on six datasets are reported in Table. 2, from which we observe that: (1) The proposed low-frequency distillation \(\mathcal{L}_{\mathrm{LFD}}\) makes fuller use of the graph topology and the low-frequency information from GNNs, and in turn outperforms GLNN that adopts node-to-node distillation on all six datasets. (2) While both low- and high-frequency distillation can work alone to improve the performance of vanilla MLPs, the former plays a _primary_ role and the latter a _secondary_ (auxiliary) role. More importantly, these two distillations are complementary to each other and can further improve performance on top of each other. (3) The FF-G2M (full model) considers both low- and high-frequency distillation and is capable of capturing full-frequency knowledge, and thus can far outperform GLNN on all six datasets.
## Conclusion
In this paper, we factorize the knowledge learned by GNNs into low- and high-frequency components in the spectral and spatial domains and then conduct a comprehensive investigation on their roles played in GNN-to-MLP distillation. Our key finding is existing GNN-to-MLP distillation may suffer from a potential _information drowning_ problem, i.e., the high-frequency knowledge of the pre-trained GNNs may be overwhelmed by the low-frequency knowledge during distillation. Therefore, we propose a novel _Full-Frequency GNN-to-MLP_ (FF-G2M) knowledge distillation framework, which extracts both low- and high-frequency knowledge from GNNs and injects it into MLPs. As a simple but general framework, FF-G2M outperforms other leading methods across various GNN architectures and graph datasets. Limitations still exist; for example, this paper pays little attention to the special designs on teacher GNNs, and designing more expressive teachers to directly capture full-frequency knowledge may be another promising direction.
\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline
**Method** & **Cora** & **Citeseer** & **Pubmed** & **Amazon-Photo** & **Coauthor-CS** & **Coauthor-Phy** \\ \hline Vanilla GCN & 82.2 \(\pm\) 0.5 & 71.6 \(\pm\) 0.4 & 79.3 \(\pm\) 0.3 & 91.8 \(\pm\) 0.6 & 89.9 \(\pm\) 0.7 & 91.9 \(\pm\) 1.2 \\ Vanilla MLP & 59.7 \(\pm\) 1.0 & 60.7 \(\pm\) 0.5 & 71.5 \(\pm\) 0.5 & 77.4 \(\pm\) 1.2 & 87.5 \(\pm\) 1.4 & 89.2 \(\pm\) 0.9 \\ GLNN (Zhang et al., 2021) & 82.8 \(\pm\) 0.5 & 72.7 \(\pm\) 0.4 & 80.2 \(\pm\) 0.6 & 91.4 \(\pm\) 1.0 & 92.7 \(\pm\) 1.0 & 93.2 \(\pm\) 0.5 \\ \hline \hline Low-Frequency KD w/ \(\mathcal{L}_{\mathrm{LFD}}\) & 83.4 \(\pm\) 0.9 & 73.7 \(\pm\) 0.6 & 81.0 \(\pm\) 0.5 & 92.1 \(\pm\) 0.8 & 93.2 \(\pm\) 0.8 & 93.7 \(\pm\) 0.8 \\ High-Frequency KD w/ \(\mathcal{L}_{\mathrm{HFD}}\) & 68.5 \(\pm\) 0.8 & 63.2 \(\pm\) 0.7 & 74.4 \(\pm\) 0.4 & 82.5 \(\pm\) 1.3 & 89.3 \(\pm\) 1.7 & 91.0 \(\pm\) 1.6 \\ FF-G2M (full model) & **84.3 \(\pm\) 0.4** & **74.0 \(\pm\) 0.5** & **81.8 \(\pm\) 0.4** & **94.2 \(\pm\) 0.4** & **93.8 \(\pm\) 0.5** & **94.4 \(\pm\) 0.9** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Classification accuracy \(\pm\) std (%) on six real-world datasets. The best metrics are marked by **bold**.
Figure 4: Representation 2D-Visualizations (by UMAP (McInnes et al., 2018)) of the teacher model and three student models on Cora. Each node is colored by its ground-truth label, and the numbers around the nodes denote the node ids.
Figure 5: (a) Curves of mean cosine similarity (**the higher, the better**) between nodes with their first-order neighbors. (b) Curves of pairwise distance differences (**the lower, the better**) between the teacher GNNs and student MLPs.
## Acknowledgement
This work is supported in part by Ministry of Science and Technology of the People's Republic of China (No. 2021YFA1301603) and National Natural Science Foundation of China (No. U21A20427).
|
2303.11247 | Memorization Capacity of Neural Networks with Conditional Computation | Many empirical studies have demonstrated the performance benefits of
conditional computation in neural networks, including reduced inference time
and power consumption. We study the fundamental limits of neural conditional
computation from the perspective of memorization capacity. For Rectified Linear
Unit (ReLU) networks without conditional computation, it is known that
memorizing a collection of $n$ input-output relationships can be accomplished
via a neural network with $O(\sqrt{n})$ neurons. Calculating the output of this
neural network can be accomplished using $O(\sqrt{n})$ elementary arithmetic
operations of additions, multiplications and comparisons for each input. Using
a conditional ReLU network, we show that the same task can be accomplished
using only $O(\log n)$ operations per input. This represents an almost
exponential improvement as compared to networks without conditional
computation. We also show that the $\Theta(\log n)$ rate is the best possible.
Our achievability result utilizes a general methodology to synthesize a
conditional network out of an unconditional network in a
computationally-efficient manner, bridging the gap between unconditional and
conditional architectures. | Erdem Koyuncu | 2023-03-20T16:33:17Z | http://arxiv.org/abs/2303.11247v1 | # Memorization Capacity of Neural Networks with Conditional Computation
###### Abstract
Many empirical studies have demonstrated the performance benefits of conditional computation in neural networks, including reduced inference time and power consumption. We study the fundamental limits of neural conditional computation from the perspective of memorization capacity. For Rectified Linear Unit (ReLU) networks without conditional computation, it is known that memorizing a collection of \(n\) input-output relationships can be accomplished via a neural network with \(O(\sqrt{n})\) neurons. Calculating the output of this neural network can be accomplished using \(O(\sqrt{n})\) elementary arithmetic operations of additions, multiplications and comparisons for each input. Using a conditional ReLU network, we show that the same task can be accomplished using only \(O(\log n)\) operations per input. This represents an almost exponential improvement as compared to networks without conditional computation. We also show that the \(\Theta(\log n)\) rate is the best possible. Our achievability result utilizes a general methodology to synthesize a conditional network out of an unconditional network in a computationally-efficient manner, bridging the gap between unconditional and conditional architectures.
## 1 Introduction
### Conditional Computation
Conditional computation refers to utilizing only certain parts of a neural network, in an input-adaptive fashion [5, 8, 9]. This can be done through gating mechanisms combined with a tree-structured network, as in the case of "conditional networks" [19] or neural trees and forests [22, 35, 40]. Specifically, depending on the inputs or some features extracted from the inputs, a gate can choose its output sub-neural networks that will further process the gate's input features. Another family of conditional computation methods are the so-called early-exit architectures [12, 20, 36]. In this case, one typically places classifiers at intermediate layers of a large network. This makes it possible to exit at a certain layer to reach a final verdict on classification, if the corresponding classifier is confident enough of its decision.
Several other sub-techniques of conditional computation exist and have been well-studied, including layer skipping [14], channel skipping in convolutional neural networks [11], or reinforcement learning methods for input-dependent dropout policies [4]. Although there are many diverse methods [15], the general intuitions as to why conditional computation can improve the performance of neural networks remain the same: First, the computation units are chosen in an adaptive manner to process the features that are particular to the given input pattern. For example, a cat image is ideally processed by only "neurons that are specialized to cats." Second, one allocates just enough computation units to a given input, avoiding a waste of resources. The end result is various benefits relative to a network without conditional computation, including reduced computation time, and power/energy consumption [21]. Achieving these benefits are especially critical in edge networks with resource-limited devices [23, 24]. Moreover, conditioning incurs minimal loss, or in some cases, no loss in learning performance.
Numerous empirical studies have demonstrated the benefits of conditional computation in many different settings. Understanding the fundamental limits of conditional computation in neural networks is thus crucial,
but has not been well-investigated in the literature. There is a wide body of work on a theoretical analysis of decision tree learning [26], which can be considered as an instance of conditional computation. These results are, however, not directly applicable to neural networks. In [6], a feature vector is multiplied by different weight matrices, depending on the significant bits of the feature vector, resulting in an exponential increase in the number of free parameters of the network (referred to as the capacity of the network in [6]). On the other hand, the potential benefits of this scheme have not been formally analyzed.
### Memorization Capacity
In this work, we consider the problem of neural conditional computation from the perspective of memorization capacity. Here, the capacity refers to the maximum number of input-output pairs of reasonably-general position that a neural network of a given size can learn. It is typically expressed as the minimum number of neurons or weights required for a given dataset of size, say \(n\).
Early work on memorization capacity of neural networks include [2, 27, 34]. In particular, [2] shows that, for thresholds networks, \(O(n)\) neurons and weights are sufficient for memorization. This sufficiency result is later improved to \(O(\sqrt{n})\) neurons and \(O(n)\) weights by [31, 39]. There are also several studies on other activation functions, especially the Rectified Linear Unit (ReLU), given its practicality and wide utilization in deep learning applications. Initial works [16, 42] show that \(O(n)\) neurons and weights are sufficient for memorization in the case of ReLU networks. This is improved to \(O(\sqrt{n})\) weights and \(O(n)\) neurons in [41]. In addition, [30] proves the sufficiency of \(O(n^{2/3})\) weights and neurons, and finally, [38] shows that memorization can be achieved with only \(O(\sqrt{n})\) weights and neurons, up to logarithmic factors. For the sigmoid activation function, it is known that \(O(\sqrt{n})\) neurons and \(O(n)\) weights [18], or \(O(n^{2/3})\) weights and neurons [30] are sufficient. Memorization and expressivity have also been studied in the context of specific network architectures such as convolutional neural networks [7, 29].
The aforementioned achievability results have also been proven to be tight in certain cases. A very useful tool in this context is the Vapnik-Chervonenkis (VC) dimension [37]. In fact, applying the VC dimension theory to neural networks [1], it can be shown that the number of neurons and weights should be both polynomial in the size of the dataset for successful memorization. Specifically, \(\Omega(\sqrt{n})\) weights and \(\Omega(n^{1/4})\) neurons are optimal for ReLU networks, up to logarithmic factors. We will justify this statement later on for completeness.
### Scope, Main Results, and Organization
We analyze the memorization capacity of neural networks with conditional computation. We describe our neural network and the associated computational complexity models in Section 2. We describe a general method to synthesize conditional networks from unconditional networks in Section 3. We provide our main achievability and converse results for memorization capacity in Sections 4 and 5, respectively. We draw our main conclusions in Section 6. Some of the technical proofs are provided in the supplemental material.
We note that this paper is specifically on analyzing the theoretical limits on neural conditional computation. In particular, we show that \(n\) input-output relationships can be memorized using a conditional network that needs only \(O(\log n)\) operations per input or inference step. The best unconditional architecture requires \(O(\sqrt{n})\) operations for the same task. This suggests that conditional models can offer significant time/energy savings as compared to unconditional architectures. In general, understanding the memorization capacity of neural networks is a well-studied problem of fundamental importance and is related to the expressive power of neural networks. A related but separate problem is generalization, i.e. how to design conditional networks that can not only recall the memory patterns with reasonable accuracy but also generalize to unseen examples. The "double-descent" phenomenon [3, 28] suggests that the goals of memorization and generalization are not contradictory and that a memorizing network can potentially also generalize well. A further investigation of this phenomenon in the context of conditional networks, and the design of conditional networks for practical datasets remains beyond the scope of the present work.
**Notation:** Unless specified otherwise, all vector variables are column vectors. We use ordinary font (such as \(u\)) for vectors, and the distinction between a vector and scalar will be clear from the context. The symbols \(O,\Omega\), and \(\Theta\) are the standard Bachmann-Landau symbols. Specifically, \(f_{n}\in O(g_{n})\) means there is a constant \(C>0\) such that \(f_{n}\leq Cg_{n}\) for sufficiently large \(n\). On the other hand, if \(f_{n}\in\Omega(g_{n})\), then there
is a constant \(C>0\) such that \(f_{n}>Cg_{n}\) for sufficiently large \(n\). We write \(f_{n}\in\Theta(g_{n})\) if \(f_{n}\in O(g_{n})\) and \(f_{n}\in\Omega(g_{n})\). The set \(\mathbb{R}^{p}\) is the set of all \(p\)-dimensional real-valued column vectors. The superscript \((\cdot)^{T}\) is the matrix transpose. The function \(\mathbf{1}(\cdot)\) is the indicator function, and \(\lceil\cdot\rceil\) is the ceiling operator. A function \(f(x)\) of variable \(x\) is alternatively expressed as the mapping \(x\mapsto f(x)\). Operator \(\text{rank}(\cdot)\) is the rank of a matrix. Finally, \(\|\cdot\|\) is the Euclidean norm.
## 2 System Model
### Unconditional Feedforward Networks
Consider an ordinary unconditional feedforward network of a homogeneous set of neurons, all of which have the same functionality. We also allow skip connections, which are mainly utilized for the generality of the model for converse results (The construction in our achievability results also skip layers, but at most one layer at a time). Formally, we consider an \(L\)-layer network with the ReLU operation \(\phi(x)=\max\{0,x\}\), and the input-output relationships
\[y_{\ell}=\phi\left(W_{\ell}\left[y_{\ell-1}^{T}\cdots y_{0}^{T}\right]^{T} \right),\,\ell=1,\ldots,L, \tag{1}\]
where \(y_{0}\) is the input to the neural network, \(y_{\ell}\) is the output at Layer \(\ell\), and \(y_{L}\) is the neural network output. Also, \(W_{\ell}\) is the weight matrix at Layer \(\ell\) of appropriate dimensions.
### Measuring the Cost of Computation
A recurring theme of the paper will be to calculate the output of a neural network given an arbitrary input, however with low computational complexity. In particular, in (1), given the outputs of Layer \(\ell-1\), the calculation of the outputs of Layer \(\ell\) can be accomplished through multiplication with matrix \(W_{\ell}\), followed by the activation functions. Each ReLU activation function can be implemented via a simple comparison given local fields. Hence, calculation of the output of Layer \(\ell\) can be accomplished with \(O(\text{dim}W_{\ell})\) operations (multiplications, additions, and comparisons), and the output \(y_{L}\) of the entire network can be calculated using \(O(\sum_{\ell}\text{dim}W_{\ell})\) operations. Here, \(\text{dim}W_{\ell}\) represents the product of the number of rows and columns in \(W_{\ell}\). In other words, \(\text{dim}W_{\ell}\) is the number of dimensions in \(W_{\ell}\). Hence, in unconditional architectures, the number of operations to calculate the output of the network is essentially the same (up to constant multipliers) as the number of weights in the network. With regards to our basic measure of complexity, which relies on counting the number of operations, one can argue that multiplication is more complex than addition or comparison, and hence should be assigned a larger complexity. We hasten to note that the relative difficulty of different operations will not affect our final results, which will have an asymptotic nature.
It is instructive to combine the \(O(\sum_{\ell}\text{dim}W_{\ell})\) complexity baseline with the memorization results described in Section 1. Let \(X=\{x_{1},\ldots,x_{n}\}\subset\mathbb{R}^{p}\) be a dataset of inputs. Let \(d_{1},\ldots,d_{n}\in\mathbb{R}^{r}\) be the corresponding desired outputs. In the memorization task, one wishes to design a network that can provide an output of \(d_{i}\) for an input of \(x_{i}\) for each \(i\in\{1,\ldots,n\}\). It is known that, up to logarithmic factors, \(O(\sqrt{n})\) weights and neurons are sufficient for memorization of \(n\) patterns [38]. It follows from the discussion in the paragraph above that \(O(\sqrt{n})\) operations sufficient to recall a stored memory pattern (i.e. to calculate the output of the neural network for a given \(x_{i}\)). The goal of this paper is to accomplish the same task using much fewer operations required per input. Specifically, we will show how to do perfect recall using only \(O(\log n)\) operations per input. We shall later show that \(\Theta(\log n)\) is, in fact, the best possible rate.
### Conditional Networks
In order to achieve perfect recall using a subpolynomial number of operations, we use the idea of conditional computation. The conditioning model that we utilize in this work is a simple but general scenario where we allow executing different sub-neural networks depending on how an intermediate output of the network compares to some real number. Each conditioning is thus counted as one operation. Formally, we describe a conditional neural network via a rooted full binary tree where every vertex has either \(0\) or \(2\) children. Every vertex is a sequence of operations of the form \(\mathtt{v}_{n+1}\leftarrow\phi(\beta_{n}\mathbf{v}_{n}+\cdots+\beta_{1}\mathbf{ v}_{1})\), where \(\beta_{1},\ldots,\beta_{n}\) are
weights, and variables \(\mathtt{v}_{1},\ldots,\mathtt{v}_{n}\) are either (i) inputs to the neural network, or (ii) defined as new variables preceding \(\mathtt{v}_{n+1}\) at the same vertex or at one of the ancestor vertices. Every edge is a conditioning \(\mathtt{v}\circ\beta\), where \(\mathtt{v}\) should be defined at any one of the vertices that connects the edge to the root node, \(\beta\) is a constant weight, and \(\circ\in\{\leq,<,=,\neq,>,\geq\}\). We assume that the two edges connected to the same vertex correspond to complementary conditions; e.g. \(\mathtt{v}_{1}<3\) and \(\mathtt{v}_{1}\geq 3\).
An example conditional network, expressed in algorithmic form, is provided in Algorithm 1, where \(u\) represents the input, \(o\) is the output, and the subscripts are the vector components. For example, if the input is a vector \(u\) with \(u_{1}>3\), resulting in an intermediate feature vector with \(z_{3}\neq 5\), then two operations are incurred due to the conditionings in Lines 1 and 5, and \(O(\dim(W_{1})+\dim(W_{2})+\dim(W_{5}))\) operations are accumulated due to neural computations.
Our model encompasses various neural conditional computation models in the literature. One example is early exit architectures [13, 20, 36]. As described in Section 1, a typical scenario is where one places intermediate
classifiers to a deep neural network. If an intermediate classifier is confident enough of a decision, then an "early exit" is performed with the corresponding class decision. Here, one skips subsequent layers, saving computation resources. The decision to exit is often a simple threshold check, e.g. whether one of the soft probability outputs of the intermediate classifier exceeds a certain threshold. Hence, most early exit networks can be modeled via the simple if-else architecture described above. Mixture of experts (MoE) architectures [10, 33] can also be realized under our model. In this case, there are multiple gating networks, each of which is responsible for one expert. One routes a feature vector to only a subset of experts whose gating networks have the largest outputs. The choice of experts can be accomplished through if-else statements. For example, for two gates and experts, the gate with the largest output can be found by comparing the difference between the two gates' outputs against zero. Another gating approach that can be realized as a special case of our model can be found in [6].
## 3 Synthesizing a Conditional Network out of an Unconditional Network
Consider an arbitrary unconditional network as in (1), whose implementation requires \(O(\sum_{\ell}\text{dim}W_{\ell})\) operations, as discussed in Section 2.2. Suppose that the network is well-trained in the sense that it can already provide the output \(d_{i}\) for a given input \(x_{i}\), for every \(i\in\{1,\ldots,n\}\). Out of such an unconditional network, we describe here a general methodology to synthesize a conditional network that requires much fewer than \(O(\sum_{\ell}\text{dim}W_{\ell})\) operations, while keeping the input-output relationships \(x_{i}\mapsto d_{i}\), \(i\in\{1,\ldots,n\}\) intact.
We first recall some standard terminology [17]. Consider the neuron \([x_{1},\ldots,x_{n}]\mapsto\phi(\sum_{i}x_{i}w_{i})\). We refer to \(x_{1},\ldots,x_{n}\) as the neuron inputs, and \(w_{1},\ldots,w_{n}\) as the neuron weights. We can now provide the following definition.
**Definition 1**.: _Suppose that the activation function satisfies \(\phi(0)=0\). Given some fixed input to a neural network, a neuron with at least one non-zero input is called an active neuron. A neuron that is not active is called an inactive or a deactivated neuron. A weight is called active if it connects an active neuron to another active neuron and is non-zero. A weight is called inactive if it is not active._
The source of the phrase "inactive" is the following observation: Consider an input to the neural network and the corresponding output. By definition, we will obtain the same output after removing all inactive neurons from the network for the same input. We can simply "ignore" inactive neurons. Likewise, we can remove any inactive weight and obtain the same output.
Our idea is to condition the computation on the set of active neurons and the corresponding active weights. Note that removing the inactive weights and neurons does not change the network output. Moreover, often the number of active weights given an input can be significantly lower than the overall number of neurons of the unconditional architecture (which determines the number of operations required to perform inference
on the unconditional network), resulting in huge computational savings. The complication in this context is that the set of inactive weights depends on the network input. Fortunately, it turns out that determining the set of active weights can be accomplished with fewer operations than actually computing the local fields or outputs of the corresponding active neurons. The final result is provided by the following theorem.
**Theorem 1**.: _Consider an arbitrary dataset \(X=\{x_{1},\ldots,x_{n}\}\subset\mathbb{R}^{p}\) of inputs. Let \(d_{1},\ldots,d_{n}\in\mathbb{R}^{r}\) be the corresponding desired outputs. Suppose that the unconditional neural network defined by (1) satisfies the desired input-output relationships in the sense that for any \(i\), if the input to the network is \(x_{i}\), then the output is \(d_{i}\). Also suppose that the input \(x_{i}\) results in \(\omega_{i}\) active weights. Then, there is a conditional network that similarly satisfies all desired input output relationships, and for every \(i\), performs at most \(p+4\omega_{i}\) operations given input \(x_{i}\)._
Proof.: (Sketch) By an " input configuration," we mean a certain subset of neurons that are active at a certain layer of the unconditional "base" network. We represent input configurations by binary vectors where "0" represents an inactive neuron, while "1" represents an active neuron. As an example, the input configuration \([1\,0\,1]^{T}\) refers to a scenario where only the first and the third neurons at the layer is active. Analogous to input configurations, "output configurations" are binary vectors that represent whether neurons provide zero or non-zero outputs. For example, an output configuration of \([1\,1\,0]^{T}\) means that only the first and the second neurons provide a non-zero output.
Consider first an unconditional network without skip connections. The key idea is to observe that, given the output configuration of Layer \(\ell-1\), one can uniquely obtain the input configuration of Layer \(\ell\). Hence, a conditional network can be designed to operate in the following manner: Given an input, we first find the output configuration \(\mathtt{OC}_{0}\) at Layer 0, which is nothing but the non-zero components of the input vector. This can be done by \(p\) conditioning statements, where \(p\) is the input dimension. The result is a unique input configuration \(\mathtt{IC}_{1}\) at Layer 1. Meanwhile, we can obtain the output \(y_{1}\) of Layer 1 by only calculating the outputs of neurons that correspond to the non-zero components of \(\mathtt{IC}_{1}\), since other neurons at Layer 1 are guaranteed to have all-zero inputs and thus provide zero output. This can be accomplished via \(O(a_{1})\) multiplications and additions, where \(a_{\ell}\) represents the number of active weights in Layer \(\ell\). Then, we find the output configuration \(\mathtt{OC}_{1}\) at Layer 1, using \(|\mathtt{IC}_{1}|\) conditioning statements on \(y_{1}\). Having obtained \(\mathtt{OC}_{1}\), we can similarly find the Layer 2 input configuration and output. The conditional network processes the remaining layers recursively in the same manner. The functionality of the unconditional network is reproduced exactly so all input-output relationships are satisfied. Given that \(\sum_{\ell}a_{\ell}=\omega_{i}\), the total complexity is \(p+O(\omega_{i})\). We refer to the complete proof in Appendix A for the precise bound and generalization to networks with skip connections.
The proof of the theorem in Appendix A suggests that the true complexity is closer to \(2\omega_{i}\) than the actual formal upper bound provided in the theorem statement. The number \(2\omega_{i}\) stems from the \(\omega_{i}\) additions and \(\omega_{i}\) multiplications that are necessary to calculate the local fields of active neurons.
Theorem 1 shows that a design criterion to come up with low computational-complexity neural networks might be to put a constraint on the number of active weights given any training input to an ordinary, unconditional feedforward architecture. Using the theorem, we can synthesize a conditional neural network with the same functionality as the unconditional feedforward network. In the next section, we will apply this idea to the problem of memorization capacity.
We conclude this section by noting that Theorem 1 may prove to be useful in other applications. For example, any method that results in sparse representations or weights, such as pruning, will result in many inactive neurons and weights. Sparsity is useful; however, unstructured sparsity is difficult to exploit: For example, multiplying by a matrix half of whose entries are zero at random positions will likely be as difficult as multiplying by a random matrix without sparsity constraints. The construction in Theorem 1 may provide computational savings for such scenarios.
Another observation is how Theorem 1 can potentially simplify the design of conditional networks. In any conditional architecture, an important question is where to place the decision gates that route information to different parts of the network. It is a combinatorially very difficult if not impossible to optimize a heterogeneous collection of "ordinary neurons" and "gates." Such an optimization is also completely unsuitable for a gradient approach. Hence, most previous works provide some empirical guidelines for gate placement, and do not optimize over the gate locations once they are placed according to these guidelines. The message of
Theorem 1 is that there is no need to distinguish between gates and neurons. All that needs to be done is to train an unconditional network consisting only of ordinary neurons to be as "inactive" as possible, e.g. by increased weight sparsity through regularization [25]. The theorem can then construct a conditional network that can exploit the sparsity to the fullest, placing the gates automatically.
## 4 Memorization with Low Computational Complexity
In this section, we introduce our ReLU network to memorize the input-output relationships \(x_{i}\mapsto d_{i},\,i=1,\ldots,n\). Our network will only yield \(O(\log n)\) active neurons and weights per input. Application of Theorem 1 will then imply a conditional network that can achieve perfect recall with only \(O(\log n)\) operations per input, as desired.
Given a neural network \(f\), and an input \(x\) to \(f\), let \(A(x;f)\) and \(W(x;f)\) denote the number of active neurons and active weights, respectively. Our feedforward ReLU network construction is provided by the following theorem.
**Theorem 2**.: _Let \(X=\{x_{1},\ldots,x_{n}\}\subset\mathbb{R}^{p}\) be a dataset of input patterns such that for every \(i,j\in\{1,\ldots,n\}\) with \(i\neq j\), we have \(x_{i}\neq x_{j}\). Let \(\bar{x}_{i}=\left[\begin{smallmatrix}1\\ x_{i}\end{smallmatrix}\right]\in\mathbb{R}^{q}\), where \(q=1+p\), be the augmented dataset patterns for biasing purposes. Let \(d_{1},\ldots,d_{n}\in\mathbb{R}^{r}\) be the corresponding desired outputs. Suppose every component of \(d_{i}\) is non-negative for each \(i\in\{1,\ldots,n\}\). Then, there is a neural network \(f:\mathbb{R}^{q}\rightarrow\mathbb{R}^{r}\) such that for every \(i\in\{1,\ldots,n\}\), we have \(f(\bar{x}_{i})=d_{i}\),_
\[A(\bar{x}_{i};f) \leq 2(q+1)\lceil\log_{2}n\rceil+q+r\in O(r+q\log n), \tag{2}\] \[W(\bar{x}_{i};f) \leq 12q(q+1)\lceil\log_{2}n\rceil+(r+2)q+r-2\in O(rq+q^{2}\log n). \tag{3}\]
Proof.: (Sketch) We provide an illustrative sketch of the proof. Suppose we wish to memorize the two-dimensional dataset given by Fig. 0(a). We can divide the datasets to two parts via a line, the resulting two parts to further two sub-parts, and so on, until reaching singletons, as shown in Fig. 0(b). The overall network architecture that achieves the performance in the statement of the theorem is then shown in Fig. 2. The initial block \(\mathbf{T}\) is a basic preprocessing translation. The "switch" \(\mathbf{S}_{ij}\) corresponds to the line parameterized by weights \(w_{ij}\) in Fig. 0(b). The switch \(\mathbf{S}_{ij}\) routes the zero vector to one output path and copy its input to the other output path, depending on the side of the \(w_{ij}\)-line its input vector resides. The switches are followed by ReLU neurons with weights \(\gamma_{i}\). These neurons map the corresponding input pattern on the active path to its desired output. Finally, the output of the \(\gamma_{i}\)-neurons are accumulated. As an example, the signals on the graph for input pattern \(\bar{x}_{6}\) is provided, with \(\bar{x}_{6}\triangleq\mathbf{T}(\bar{x}_{6})\). In general, all input-output relationships are satisfied with \(O(\log n)\) active neurons per dataset sample. We refer to the complete proof in Appendix B for the precise bounds.
**Corollary 1**.: _Let \(x_{i},d_{i},\,i=1,\ldots,n\) be a sequence of arbitrary input-output pairs as stated in Theorem 2. Then, there is a conditional network that, for every \(i\), provides an output of \(d_{i}\) whenever the input is \(x_{i}\) by performing only \(O(rq+q^{2}\log n)\) operations._
Proof.: We apply the synthesis procedure in Theorem 1 to the network constructed in Theorem 2. An alternative more "direct" proof (that does not need Theorem 1) is to implement the gating blocks \(\mathbf{S}_{ij}\) in Fig. 1 via if-else conditioning statements, resulting in a similar architecture.
We recall that for ReLU networks without conditional computation, the best achievability result [38] requires \(O(\sqrt{n\log n})\) neurons and weights for memorizing a dataset of size \(n\). Since the construction in [38] is not optimized for conditional computation, it is easily observed that every input activates all \(O(\sqrt{n\log n})\) neurons and weights of the network, resulting in \(O(\sqrt{n\log n})\) active weights per input. In fact, the remarkable construction in [38] is a narrow network of a finite width of only 12, but depth \(O(\sqrt{n\log n})\). Even if every input activates only one neuron at each layer, one obtains \(O(\sqrt{n\log n})\) active neurons or arithmetic operations per input. In contrast, we only need \(O(\log n)\) active weights or operations (via Corollary 1) per input.
The fact that one cannot fundamentally achieve a sub-polynomial number of neurons without conditional computation is an easy consequence of the VC dimension theory. In our setting, the VC dimension corresponds to the cardinality of the largest dataset that can be memorized. Hence, upper bounds on the VC
dimension translate to lower bounds on the memorization capacity. In this context, [1, Theorem 8.6] provides an \(O(n_{w}^{2})\) upper bound on the VC dimension for ReLU networks, where \(n_{w}\) denotes the number of weights in the network. Since any upper bound on the VC dimension is also an upper bound on the cardinality of the largest possible dataset that can be memorized, we have \(n\in O(n_{w}^{2})\). It follows that \(n_{w}\in\Omega(\sqrt{n})\) weights are the best possible for ReLU networks without conditional computation, meaning that the results of [38] are optimal up to logarithmic factors. Also, using the bound \(n_{w}\leq n_{e}^{2}\), where \(n_{e}\) is the number of neurons in the network (equality holds in the extreme scenario where every neuron is connected to every other neuron, including itself), we obtain the necessity of \(\Omega(n^{1/4})\) neurons.
In contrast to the deep and narrow architecture that is optimal for unconditional computation, the network that achieves the performance in Theorem 2 is considerably wider but much shallower. In fact, the proof in Appendix B reveals that our network has width \(O(n)\), with \(O(n)\) nodes, and depth \(O(\log n)\). These numbers are a consequence of the classical binary decision tree that we utilize in our network construction. Thanks to conditional computation, although the network has \(O(n)\) nodes, every dataset pattern activates only \(O(\log n)\) neurons instead of \(O(\sqrt{n})\) neurons without conditional computation. Note that the function \(\log n\) grows much slower than \(\sqrt{n}\) so that the number of neurons activated by the conditional computation is asymptotically negligible relative to an unconditional network. Moreover, every neuron in the conditional computation network has a bounded number of \(q\) weights. The two facts translate to big savings in terms of the cost of computation, thanks to Theorem 1. An interesting open problem that we shall leave as future work is whether one can achieve the same performance with a much smaller network size, e.g. with \(O(\sqrt{n})\) neurons, which is known to be optimal. This will also help reduce the size of the network synthesized by Theorem 1.
Figure 1: The divide and conquer strategy.
Figure 2: An example network architecture for the achievability result. The block \(\mathbf{T}\) represents the transformation in Step 1. Blocks \(\mathbf{S}_{ij}\) are the routing switches. Blocks \(\gamma_{i}\) represent ReLU neurons with weights \(\gamma_{i}\), and the \(\sum\) block represents a ReLU neuron with all-one weights.
It should be mentioned that the bounds (2) and (3) on the number of active neurons and weights as stated in Theorem 2 holds only for input patterns that belong to the dataset. For such patterns, only one path from the input to the output of the neural network is activated. The global behavior of the neural network for arbitrary inputs is more complex. A careful analysis of the construction in Appendix B reveals that near the decision boundaries (the lines in Fig. 1b), multiple paths of the network are activated, This will result in more active neurons and weights than what is suggested by the upper bounds in (2) and (3), respectively. However, the measure of such pathological inputs can be made arbitrarily small by tuning the switches appropriately.
## 5 Ultimate Computational Limits to Memory Recall
In the previous section, we showed that \(O(\log n)\) operations is sufficient to perfectly recall one of \(n\) input-output relationships. We now analyze the necessary number of operations per input for successful recall. Our main result in this context is provided by the following theorem.
**Theorem 3**.: _Let the input vectors \(x_{1},\ldots,x_{n}\in\mathbb{R}^{p}\) and the corresponding desired output vectors \(d_{1},\ldots,d_{n}\in\mathbb{R}\) satisfy the following property:_
* _The matrix_ \(\begin{bmatrix}x_{i_{1}}&\cdots&x_{i_{p+1}}\\ d_{i_{1}}&\cdots&d_{i_{p+1}}\end{bmatrix}\) _has rank_ \(p+1\) _for any subset_ \(\{i_{1},\ldots,i_{p+1}\}\) _of_ \(\{1,\ldots,n\}\)_._
_Suppose that a conditional network \(f\) satisfies the desired input-output relationships: For every \(i\), the output of the network is \(d_{i}\) whenever the input is \(x_{i}\). Also, assume that the number of operations performed on each \(x_{i}\) is bounded above by some \(\alpha\geq 0\). Then, we have \(\alpha\geq\log_{2}\frac{n}{p}\in O(\log n)\)._
Proof.: Since there are at most \(\alpha\) operations per input, there are at most \(\alpha\) comparisons per input as well, counting the comparisons needed to implement the neuron activation functions. We can represent the entire conditional computation graph/network as a binary tree where the distance between the root and a leaf node is at most \(\alpha\). This results in tree of at most \(2^{\alpha}\) leaf nodes. Each node of the tree compares real numbers to intermediate variables, which are linear functions of network inputs or other intermediate variables. Assume now the contrary to the statement of the theorem, i.e. the number of operations for every input is at most \(\alpha\), all input-output relationships are satisfied, but \(n>2^{\alpha}p\). Since there are at most \(2^{\alpha}\) leaf nodes, there is at least one leaf node that admits \(1+p\) inputs (i.e. there are \(1+p\) input patterns of the dataset such that the corresponding path over the tree ends at the leaf node). Without loss of generality, suppose the indices for these inputs are \(\{1,\ldots,1+p\}\). Writing down the input output relationship of the network for the leaf node, we obtain
\[[d_{1}\cdots d_{1+p}]=W_{0}[x_{1}\cdots x_{1+p}] \tag{4}\]
for some \(q\times p\) matrix \(W_{0}\). This relationship follows, as by fixing a path on the tree, we obtain the unique linear transformation \(W_{0}\) that maps the inputs to the neural network to its outputs. According to the Rouche-Capelli theorem [32, Theorem 2.38], a necessary condition for the existence of \(W_{0}\) to solve (4) is
\[\text{rank}([x_{1}\cdots x_{p+1}])=\text{rank}\Big{(}\begin{bmatrix}x_{1}& \cdots&x_{p+1}\\ d_{1}&\cdots&d_{p+1}\end{bmatrix}\Big{)}. \tag{5}\]
On the other hand, as a result of the rank condition stated in the theorem, the left hand side rank evaluates to \(p\), while the right hand side evaluates to \(1+p\). We arrive at a contradiction, which concludes the proof of the theorem.
The condition on the dataset and the desired outputs that appear in the statement of Theorem 3 is, up to a certain extent, necessary for the lower bound to hold. For example, if the desired outputs can simply be obtained as a linear transformation of inputs, then one only needs to perform a constant number of operations for each input to obtain the desired outputs, and the lower bound becomes invalid. In this context, the rank condition ensures that subsets of outputs cannot be obtained as linear functions of inputs. However, it should also be mentioned that the condition is not particularly restrictive in limiting the class of datasets where
the theorem holds. For example, if the components of the dataset members and the corresponding desired outputs are sampled in an independent and identically distributed manner over any continuous distribution with positive support, it can be shown that the rank condition will hold with probability 1. Hence, it can be argued that almost all datasets satisfy the rank condition and thus obey the converse result.
Corollary 1 has shown that \(n\) patterns can be memorized using \(O(\log n)\) operations per input. The matching \(\Omega(\log n)\) lower bound in Theorem 3 proves that the \(\Theta(\log n)\) rate is the best possible. However, the two results do not resolve how the number of operations should scale with respect to the input and output dimensions.1 This aspect of the problem is left as future work.
Footnote 1: Although Theorem 3 only considers scalar desired outputs, it can easily be extended to the multi-dimensional case. In fact, a successful memorization of, say, two-dimensional output vectors with \(o(\log n)\) active neurons would imply the successful memorization of scalar outputs with the same number of neurons (simply by ignoring the neurons that provide the second component of the output), contradicting Theorem 3.
## 6 Conclusions and Discussions
We have studied the fundamental limits to the memorization capacity of neural networks with conditional computation. First, we have described a general procedure to synthesize a conditional network out of an ordinary unconditional feedforward network. According to the procedure, the number of operations required to perform inference on an input in the synthesized conditional network becomes proportional to the number of so-called "active weights" of the unconditional network given the same input. This reduces the problem of designing good conditional networks to the problem of designing ordinary feedforward networks with a low number of active weights or nodes. Using this idea, we have shown that for ReLU networks, \(\Theta(\log n)\) operations per input is necessary and sufficient for memorizing a dataset of \(n\) patterns. An unconditional network requires \(\Omega(\sqrt{n})\) operations to achieve the same performance. We also described a method to synthesize a conditional network out of an unconditional network in a computationally-efficient manner.
One direction for future work is to study the memorization capacity for a sum-constraint, as opposed to a per-input constraint on the number of operations. While a per-input constraint makes sense for delay-sensitive applications, the sum-constrained scenario is also relevant for early-exit architectures, where there is a lot of variation on the size of active components of the network. Extensions of our results to different activation functions or to networks with bounded bit complexity can also be considered. In this context, [38] shows that, for every \(\epsilon\in[0,\frac{1}{2}]\), \(\Theta(n^{\epsilon})\) weights with \(\Theta(n^{1-\epsilon})\) bit complexity is optimal for memorizing \(n\) patterns, up to logarithmic factors. This result was proven under a mild separability condition, which restricts distinct dataset patterns to be \(\delta\)-separated in terms of Euclidean distance. The optimality of the results of [38] suggests that under a similar separability condition, the bit complexity of our designs can also potentially be reduced without loss of optimality. This will remain as another interesting direction for future work.
Many neural network architectures rely heavily on batch computation because matrix multiplications can be performed very efficiently on modern processors. In this context, one disadvantage of conditional architectures is their general misalignment with the idea of batching. Nevertheless, if there are not too many branches on the network, and if the branch loads are balanced, each subbranch can still receive a relatively large batch size. Fortunately, only a few gates can promise significant performance gains [10]. More work is needed, however, to make networks with aggressive conditioning more efficient in the batch setting. In this context, our synthesis theorem can potentially enable conditional networks to be trained as if they are unconditional, enabling batch computation. We note that in techniques like soft-gating [33], a batch also traverses the entire computation graph during training [20].
The main goal of this paper has been to derive theoretical bounds on the memorization capacity. More research is clearly needed for practical methods to train neural networks that can effectively utilize conditional computation and also generalize well. We hope that the constructions and theoretical bounds provided in this paper will motivate further research in the area.
#### Acknowledgments
This work was supported in part by National Science Foundation (NSF) under Grant CNS-2148182 and in part by Army Research Lab (ARL) under Grant W911NF-2120272. |
2301.12651 | Complex Critical Points of Deep Linear Neural Networks | We extend the work of Mehta, Chen, Tang, and Hauenstein on computing the
complex critical points of the loss function of deep linear neutral networks
when the activation function is the identity function. For networks with a
single hidden layer trained on a single data point we give an improved bound on
the number of complex critical points of the loss function. We show that for
any number of hidden layers complex critical points with zero coordinates arise
in certain patterns which we completely classify for networks with one hidden
layer. We report our results of computational experiments with varying network
architectures defining small deep linear networks using
HomotopyContinuation.jl. | Ayush Bharadwaj, Serkan Hoşten | 2023-01-30T04:16:49Z | http://arxiv.org/abs/2301.12651v1 | # Complex critical points of deep linear neural networks
###### Abstract.
We extend the work of Mehta, Chen, Tang, and Hauenstein on computing the complex critical points of the loss function of deep linear neutral networks when the activation function is the identity function. For networks with a single hidden layer trained on a single data point we give an improved bound on the number of complex critical points of the loss function. We show that for any number of hidden layers complex critical points with zero coordinates arise in certain patterns which we completely classify for networks with one hidden layer. We report our results of computational experiments with varying network architectures defining small deep linear networks using _HomotopyContinuation.jl_.
## 1. Introduction
Machine learning applications through deep learning techniques have been enormously successful in areas ranging from natural language processing and object recognition to drug discovery [4, 11]. These techniques involve optimizing a non-convex loss (cost) function such as the mean squared error between the observed and predicted data from the underlying neural network. Typically, this is an NP-hard problem [6] where the loss function has numerous local minima. Though methods such as stochastic gradient descent are empirically observed to close in to _good enough_ local minima (see [1, 9, 17]), a theoretical understanding for the success of deep learning is incomplete.
A deep _linear_ neural network is a simpler model on which detailed analysis is possible [1]. They differ from more general deep neural networks in the activation function used: linear neural networks employ linear activation functions instead of typical nonlinear ones such as ReLU. Nevertheless, the loss function of the deep linear networks is non-convex, and these networks exhibit many characteristics found in deep nonlinear networks. They have been used as a testing ground for ideas in general artificial neural networks [2].
Our starting point is the work of Mehta, Chen, Tang, and Hauenstein [14] in which the authors employ techniques from (numerical)
Introduction
The study of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of local structure of the local structure of the local structure of the local structure of the local structure of local structure of the local structure of the local structure of the local structure of the local structure of the local structure of local structure of the local structure of the local structure of the local structure of the local structure of the local structure of local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of the local structure of local structure of the local structure of the local structure of the local structure of local structure of the local structure
minimize the loss function:
\[\mathcal{L}(W)=\frac{1}{2}\sum_{i=1}^{m}\lVert W_{H+1}W_{H}\cdots W_{1}x_{i}-y_{i }\rVert_{2}^{2}.\]
We will follow [14] to regularize the loss function by using regularization matrices \(\Lambda_{1},\ldots,\Lambda_{H+1}\) where each \(\Lambda_{i}\) is the same size as \(W_{i}\). We arrive at the regularized loss function
\[\mathcal{L}^{\Lambda}(W)=\mathcal{L}(W)+\frac{1}{2}\left(\lVert\Lambda_{1} \circ W_{1}\rVert_{F}^{2}+\cdots+\lVert\Lambda_{H+1}\circ W_{H+1}\rVert_{F}^{ 2}\right) \tag{1}\]
where \(\Lambda_{i}\circ W_{i}\) denotes the entrywise (Hadamard) product of \(\Lambda_{i}\) and \(W_{i}\). This choice of regularization is justified by the results (see Theorem 1 and Theorem 2 in [14]) that for almost all choices of the regularization matrices the solutions to the gradient system \(\nabla\mathcal{L}^{\Lambda}=0\) are isolated and nondegenerate.
### Our contributions
This paper is about the complex critical points of \(\mathcal{L}^{\Lambda}\), namely, the solutions to \(\nabla\mathcal{L}^{\Lambda}=0\). This gradient system is a system of \(N\) polynomial equations in \(N\) variables (weights) where each polynomial has degree \(2H+1\). This set up opens the door to using (numerical) algebraic geometry to bound the number of critical points as well as to compute them.
In Section 2 we will summarize the gradient equations for the regularized loss function of deep linear neural networks. In Section 3 we will prove a bound on the number of complex critical points of the loss function of a linear neural network with one hidden layer trained on a single data point. We achieve this bound by rewriting the gradient equations. Our new bound is much better than the classic Bezout bound as well as the BKK bound previously observed [14, Table I] and confirmed and expanded by us (see Table 1 in the Appendix).
Section 4 is devoted to understanding critical points where certain weights are zero. We show that, for any deep linear network trained on a single data point, if a weight is zero, then the entire row or column containing that weight must be zero. We also prove that row \(k\) of the weight matrix \(W_{i}\) is entirely zero if and only if the column \(k\) of the weight matrix \(W_{i+1}\) is entirely zero. As a corollary, we completely classify the zero patterns of complex critical points for linear networks with one hidden layer trained on a single data point.
In Section 5 we turn to our computational experiments. Using _HomotopyContinuation.jl_[7] we solve the gradient equations for different parameter values of \(d_{x},d_{y}\) and \(d_{i}\) when \(H,m\in\{1,2\}\). These extend the computational horizon beyond the one set in [14]. We believe the extended data we provide will inspire further results.
## 2. Gradient Equations for the Loss Function
The critical points of the regularized loss function \(\mathcal{L}^{\Lambda}(W)\) are the solutions to \(\nabla\mathcal{L}^{\Lambda}=0\), the gradient equations. We derive the gradient equations in a compact form.
Let \(W=W_{H+1}W_{H}\cdots W_{1}\), and let \(U_{i}^{T}=\prod_{j=i+1}^{H+1}W_{j}^{T}\) and \(V_{i}^{T}=\prod_{j=1}^{i-1}W_{j}^{T}\). Then
\[\frac{\partial\mathcal{L}^{\Lambda}}{\partial W_{i}}=U_{i}^{T}\left(W\left( \sum_{k=1}^{m}x_{k}x_{k}^{T}\right)-\left(\sum_{k=1}^{m}y_{k}x_{k}^{T}\right) \right)V_{i}^{T}+\Lambda_{i}\circ W_{i} \tag{2}\]
where the \((j,k)\) entry of the matrix \(\frac{\partial\mathcal{L}^{\Lambda}}{\partial W_{i}}\) is the partial derivative of \(\mathcal{L}^{\Lambda}\) with respect to the \((j,k)\) entry of \(W_{i}\).
It is easy to observe that the resulting system consists of \(N\) polynomials in \(N\) variables. The constant term in each polynomial is zero, therefore \(0\in\mathbb{C}^{N}\) is always a critical point. The terms of highest degree in every polynomial have degree \(2H+1\). This leads to an explicit classical Bezout bound (CBB).
**Proposition 1**.: _[_14_, Proposition 3]_ _The regularized loss function \(\mathcal{L}^{\Lambda}\) has at most \((2H+1)^{N}\) complex critical points._
**Example 2**.: Let us consider a 2-layer network with \(W_{1}=[\alpha_{1}\ \alpha_{2}]\), \(W_{2}=\left[\begin{smallmatrix}\beta_{1}\\ \beta_{2}\end{smallmatrix}\right]\), \(X=\left[\begin{smallmatrix}1&2\\ 3&4\end{smallmatrix}\right]\), \(Y=\left[\begin{smallmatrix}1&3\\ 2&4\end{smallmatrix}\right]\), \(\Lambda_{1}=\left[\begin{smallmatrix}4&-3\end{smallmatrix}\right]\), and \(\Lambda_{2}=\left[\begin{smallmatrix}-2\\ 5\end{smallmatrix}\right]\). Using these in (2), we get the gradient system
\[5\alpha_{1}\beta_{1}^{2}+5\alpha_{1}\beta_{2}^{2}+11\alpha_{2} \beta_{1}^{2}+11\alpha_{2}\beta_{2}^{2}-7\beta_{1}-10\beta_{2}+4\alpha_{1} =0\] \[11\alpha_{1}\beta_{1}^{2}+11\alpha_{1}\beta_{2}^{2}+25\alpha_{2} \beta_{1}^{2}+25\alpha_{2}\beta_{2}^{2}-15\beta_{1}-22\beta_{2}-3\alpha_{2} =0\] \[5\alpha_{1}^{2}\beta_{1}+22\alpha_{1}\alpha_{2}\beta_{1}+25 \alpha_{2}^{2}\beta_{1}-7\alpha_{1}-15\alpha_{2}-2\beta_{1} =0\] \[5\alpha_{1}^{2}\beta_{2}+22\alpha_{1}\alpha_{2}\beta_{2}+25 \alpha_{2}^{2}\beta_{2}-10\alpha_{1}-22\alpha_{2}+5\beta_{2} =0\]
As the above example indicates the gradient equations are sparse. This allows the use of the BKK bound for the number of critical points in \((\mathbb{C}^{*})^{N}\) as well as a modified BKK bound for the number of critical points in \(\mathbb{C}^{N}\)[12, 15]. For instance, the BKK bound for the solutions in \(\mathbb{C}^{4}\) for the gradient equations in Example 2 is 33. The actual number of solutions in \((\mathbb{C}^{*})^{4}\) and \(\mathbb{C}^{4}\) are 16 and 17, respectively. The Bezout bound gives \(3^{4}=81\). Our computational experiments in Section 5 (also see [14]) will show that generally all of these bounds are far from the actual number of critical points. Starting from the next section we take a closer look into improving the BKK bound. We close this section with the following result.
**Proposition 3**.: _Each polynomial in the gradient equations (2) has the same monomial support for generic input and output vectors as \(m\), the number of these vectors, varies while the rest of the parameters, namely, \(H\), \(d_{x}\), \(d_{y}\), and \(d_{i}\), \(i=1,\ldots,H\) stay constant. In particular, BKK bounds on the number of complex critical points for these systems in \((\mathbb{C}^{*})^{N}\) and \((\mathbb{C})^{N}\) are the same bounds for any \(m\)._
Proof.: First, we replace in (2) the matrix \(\sum_{k=1}^{m}x_{k}x_{k}^{T}\) with the \(d_{x}\times d_{x}\) symmetric matrix of indeterminates \(Z=(z_{ij})\), and the matrix \(\sum_{k=1}^{m}y_{k}x_{k}^{T}\) with the \(d_{y}\times d_{x}\) matrix of indeterminates \(T=(t_{ij})\). Multiplying out the matrices in (2) given polynomials in the entries of \(W_{1},\ldots,W_{H+1}\) with coefficients in \(z_{ij}\) and \(t_{ij}\). These polynomials have terms only in degrees \(2H+1\), \(H\), and \(1\). The terms of degree \(2H+1\) that actually appear in a polynomial have coefficients that are linear in the entries of \(Z\), and the terms of degree \(H\) that appear have coefficients that are linear in the entries of \(T\). Finally, the single monomial of degree one that appears in a polynomial has an entry of some \(\Lambda_{i}\) as a coefficient. We claim that for generic \(x_{1},\ldots,x_{m}\) and \(y_{1},\ldots,y_{m}\) the linear coefficient polynomials in \(Z\) or \(T\) do not vanish. This follows from the fact that determinantal varieties of \(d_{x}\times d_{x}\) symmetric matrices and determinantal varieties of \(d_{y}\times d_{x}\) matrices of rank \(\leq r\) are not contained in linear subspaces. Genericity of \(\Lambda_{i}\) guarantees that the required monomial of degree one is also present.
## 3. Networks with one hidden layer trained on one data point
This section provides evidence that, by carefully looking at the gradient equations, one can gain insight into the number of critical points of the regularized loss function. We will treat linear neural networks with one hidden layer trained on a single data point (\(H=1\) and \(m=1\)) with no restrictions on the dimensions of the input and output vectors (\(d_{x}=n\) and \(d_{y}=p\)) as well as on the number of neurons in the hidden layer (\(d_{1}=d\)). Although this may be viewed unrealistic for real world applications it is meant to be a point of departure for more work from symbolic and numerical algebraic geometry.
To simplify the exposition we let \(A=W_{1}\) and \(B=W_{2}\). We also use \(\Lambda=\Lambda_{1}\) and \(\Sigma=\Lambda_{2}\). If we declare \(S_{i}=\sum_{i=1}^{n}a_{ij}x_{j}\) for \(i=1,\ldots,d\) and \(R_{k}=\sum_{i=1}^{d}b_{ki}S_{i}-y_{k}\) for \(k=1,\ldots,p\), then
\[Wxx^{T}-yx^{T}=\begin{pmatrix}R_{1}x_{1}&\cdots&R_{1}x_{n}\\ \vdots&&\vdots\\ R_{p}x_{1}&\cdots&R_{p}x_{n}\end{pmatrix}.\]
Now \(B^{T}(Wxx^{T}-yx^{T})+\Lambda\circ A=0\) yields
\[\left(\sum_{k=1}^{p}b_{k1}R_{k}\right)x_{j} =-\lambda_{1j}a_{1j}\qquad j=1,\ldots,n\] \[\vdots\] \[\left(\sum_{k=1}^{p}b_{kd}R_{k}\right)x_{j} =-\lambda_{dj}a_{dj}\qquad j=1,\ldots,n \tag{3}\]
Similarly, \((Wxx^{T}-yx^{T})A^{T}+\Sigma\circ B=0\) gives rise to
\[R_{k}S_{i}=-\sigma_{ki}b_{ki}\quad\ i=1,\ldots,d\quad\ k=1,\ldots,p. \tag{4}\]
**Lemma 4**.: _For generic input and output vector \(x\) and \(y\) and generic regularization matrices \(\Lambda\) and \(\Sigma\) we obtain_
\[a_{1j} =\left(\frac{x_{j}}{\lambda_{1j}}\frac{\lambda_{11}}{x_{1}} \right)a_{11}\qquad j=1,\ldots,n\] \[\vdots\] \[a_{dj} =\left(\frac{x_{j}}{\lambda_{dj}}\frac{\lambda_{d1}}{x_{1}} \right)a_{d1}\qquad j=1,\ldots,n \tag{5}\]
_and_
\[S_{i}=\left(\sum_{j=1}^{n}\frac{x_{j}^{2}}{\lambda_{ij}}\right)\frac{\lambda _{i1}}{x_{1}}a_{i1}\quad\ i=1,\ldots,d \tag{6}\]
Proof.: For generic data, the equation \(B^{T}(Wxx^{T}-yx^{T})+\Lambda\circ A=0\) implies that \(\Lambda\circ A\) is a matrix of rank at most one since \(xx^{T}\) and \(yx^{T}\) are matrices of rank one. The identities in (5) are an explicit version of this observation. They follow from the fact that \((\sum_{k=1}^{p}b_{k1}R_{k})\), i.e. the coefficient of \(x_{j}\) in the first row of (3), is a constant complex number that does not depend on \(j\). Therefore \(\frac{-\lambda_{1j}a_{1j}}{x_{j}}\) is a constant. Hence, we have \(\frac{-\lambda_{11}a_{11}}{x_{1}}=\frac{-\lambda_{12}a_{12}}{x_{2}}=\cdots= \frac{-\lambda_{1n}a_{1n}}{x_{n}}\). Equivalently, \(a_{1j}=\left(\frac{x_{j}}{\lambda_{1j}}\frac{\lambda_{11}}{x_{1}}\right)a_{11}\) for all \(j=1,\ldots,n\). Repeating the same for all equations in (3) gives (5). Substituting these into \(S_{i}=\sum_{i=1}^{n}a_{ij}x_{j}\) results in (6).
The next result is the main theorem of this section.
**Theorem 5**.: _Consider a linear network where \(H=1\), \(m=1\), \(d_{x}=n\), \(d_{y}=p\) and \(d_{1}=d\) with generic input/output vectors and generic regularization matrices. Then, there are at most_
\[\mathcal{B}_{\mathbb{C}^{*}}=(4p)^{d}\]
solutions of (2) for which \(a_{11},\dots,a_{dn}\in\mathbb{C}^{*}\)._
Proof.: The overall strategy for this proof is to eliminate \(b_{ki}\) using (4), and then substitute the expressions for the \(b_{ki}\) variables so obtained into (3). That will give us a polynomial system in just the \(a_{ij}\) variables. We will then compute the BKK bound for this "reduced" system. That will give us an upper bound on the number of solutions in \((\mathbb{C}^{*})^{d\times n}\).
We first express \(b_{k2}\),..., \(b_{kd}\) in terms of \(b_{k1}\). By the equations in (6) each \(S_{i}\) is equal to \(a_{i1}\) scaled by some constant. Since each \(a_{ij}\) is non-zero by assumption, each \(S_{i}\) is non-zero. Then (4) implies
\[\frac{b_{k1}\sigma_{k1}}{S_{1}}=\frac{b_{k2}\sigma_{k2}}{S_{2}}=\dots=\frac{b_ {kd}\sigma_{kd}}{S_{d}}.\]
Hence, \(b_{k2}=b_{k1}\left(\frac{\sigma_{k1}}{\sigma_{k2}}\frac{S_{2}}{S_{1}}\right)\),..., \(b_{kd}=b_{k1}\left(\frac{\sigma_{k1}}{\sigma_{k,d}}\frac{S_{d}}{S_{1}}\right)\). Substituting the preceding expressions for \(b_{k2}\) through \(b_{kd}\) into \(R_{k}\), we get:
\[R_{k}=b_{k1}\left[S_{1}+\left(\frac{\sigma_{k1}}{\sigma_{k2}}\frac{S_{2}^{2}}{ S_{1}}\right)+\dots+\left(\frac{\sigma_{k1}}{\sigma_{kd}}\frac{S_{d}^{2}}{S_{1}} \right)\right]-y_{k}.\]
Using this expression in (4) and with a bit of algebra we obtain
\[b_{ki}=\frac{y_{k}S_{i}}{\sigma_{ki}}\frac{1}{(1+T_{k})}\]
where \(T_{k}=\frac{S_{1}^{2}}{\sigma_{k1}}+\frac{S_{2}^{2}}{\sigma_{k2}}+\dots+\frac {S_{d}^{2}}{\sigma_{kd}}\). Note that the right hand side of this identity is a rational function of \(a_{ij}\) only. We substitute these expressions for \(b_{ki}\) into the first equation of (3) to result in
\[-\frac{\lambda_{1j}a_{1j}}{x_{j}}=-\sum_{k=1}^{p}\frac{y_{k}^{2}S_{1}}{\sigma _{k1}(1+T_{k})^{2}}.\]
Now, (5) implies \(-\frac{\lambda_{1j}a_{1j}}{x_{j}}=-\frac{\lambda_{11}a_{11}}{x_{1}}\) and using (6) for \(S_{1}\), the above equation gives
\[\frac{1}{\left(\sum_{j=1}^{n}\frac{x_{j}^{2}}{\lambda_{1j}}\right)}-\left[ \frac{y_{1}^{2}}{\sigma_{11}(1+T_{1})^{2}}+\frac{y_{2}^{2}}{\sigma_{21}(1+T_{ 2})^{2}}+\dots+\frac{y_{p}^{2}}{\sigma_{p1}(1+T_{p})^{2}}\right]=0.\]
Clearing denominators we arrive at
\[\frac{(1+T_{1})^{2}(1+T_{2})^{2}\cdot\cdot\cdot(1+T_{p})^{2}}{\left(\sum_{j=1 }^{n}\frac{x_{j}^{2}}{\lambda_{1j}}\right)}-\sum_{k=1}^{p}\frac{y_{k}^{2}}{ \sigma_{k1}}\prod_{i\neq k}^{p}(1+T_{i})^{2}=0. \tag{7}\]
Each \(T_{k}\) is a polynomial in the variables \(a_{11},\dots,a_{d1}\). Hence, (7) is a polynomial equation in these variables only. A total of \(d\) such polynomials comprises a system of \(d\) polynomial equations in \(d\) variables. The solution set contains the solutions to (2) when \(a_{ij}\in\mathbb{C}^{*}\), but it also
contains components with positive dimension, for instance, the codimension two algebraic sets given by \(1+T_{i}=1+T_{j}=0\) for \(i\neq j\). We proceed to introduce regularization for this system as well. To equation \(i=1,\ldots,d\) we add the regularization term \(\mu_{i}a_{di}\) where \(\mu_{i}\) is a regularization parameter. A standard argument using the generalized Sard's theorem and the implicit function theorem guarantees that, for almost all choices of \(\mu_{i}\), \(i=1,\ldots,d\), all solutions to the regularized system are isolated and nondegenerate, and for sufficiently small \(\mu_{i}\), as they shrink to \(0\) uniformly, the solutions to the regularized system either converge to components of the solution set of the non-regularized system (including the solutions we want to count) or diverge to infinity. For an excellent discussion of regularization in the context of solving systems of polynomials we refer to Section 3.2 in [14]. The Newton polytope of (7) and its regularization is \((4p)\Delta_{d}=\operatorname{conv}\{0,4p\cdot e_{1},...,4p\cdot e_{d}\}\) where \(e_{i}\) is the \(i\)-th standard basis vector of \(\mathbb{R}^{d}\). Thus, we obtain a zero-dimensional polynomial system with \(d\) equations in \(d\) variables where the Newton polytope of each equation is \((4p)\Delta_{d}\). Therefore the BKK bound for this system is given by the normalized volume of \((4p)\Delta_{d}\) which is equal to \((4p)^{d}\). This completes the proof.
**Remark 6**.: Theorem 5 gives a bound on the number of critical points of the regularized loss function when the weights in \(A=W_{1}\) are all nonzero. In the following section we will relax this requirement after treating patterns of zeros for the \(H=1\) and \(m=1\) case. We also note that in this theorem we have not made any assumptions about the weights in \(B=W_{2}\).
**Remark 7**.: It is an open question to find a reduced system for \(m>1\) even when \(H=1\) that will yield a better bound on the number of critical points. In particular, is there a systematic way to eliminate the weights in \(B=W_{2}\)?
## 4. Patterns of Zeros
This section is about patterns we observe in the critical points of the regularized loss function of a deep linear neural network. All of our results are about networks trained on a single data point (\(m=1\)). However, we believe the phenomena we observe are more general and persist for arbitrary \(m\). To support this claim we provide computational evidence. We start with the observation that if in a critical point an entry of a weight matrix is zero then the entire row or column of that entry must also consist of zeros.
**Proposition 8**.: _Suppose an arbitrary deep linear neural network is trained on a single generic data point \(x\) with the corresponding generic output vector \(y\). Then, if in a critical point of \(\mathcal{L}^{\Lambda}\) the \((i,j)\) entry of a weight matrix is zero, then either the \(i\)th row or the \(j\)th column of the same weight matrix is zero._
Proof.: We let \(d_{x}=n\) and \(d_{y}=p\). Suppose the \((i,j)\) entry of \(Z=W_{k}\in\mathbb{C}^{r\times s}\) is zero. Then
\[\frac{\partial\mathcal{L}^{\Lambda}}{\partial Z}=U_{Z}^{T}\left(Wxx^{T}-yx^{T} \right)V_{Z}^{T}+\Lambda\circ Z=0\]
where \(U_{Z}=U_{k}\), \(V_{Z}=V_{k}\) and \(\Lambda=\Lambda_{k}\) as in (2). It follows that
\[\begin{pmatrix}D_{1}E_{1}&\cdots&D_{1}E_{s}\\ \vdots&&\vdots\\ D_{r}E_{1}&\cdots&D_{r}E_{s}\end{pmatrix}=-\begin{pmatrix}\lambda_{11}z_{11}& \cdots&\lambda_{1s}z_{1s}\\ \vdots&&\vdots\\ \lambda_{r1}z_{r1}&\cdots&\lambda_{rs}z_{rs}\end{pmatrix} \tag{8}\]
where
\[D_{i}=(U_{Z}^{T})_{i1}R_{1}+\cdots+(U_{Z}^{T})_{ip}R_{p}\]
\[E_{j}=x_{1}(V_{Z}^{T})_{1j}+\cdots+x_{n}(V_{Z}^{T})_{nj}\]
and \(R_{k}=(Wx-y)_{k}\). If \(z_{ij}=0\) then \(D_{i}=0\) or \(E_{j}=0\) and the result follows.
It is worth noting that if row \(i\) of the weight matrix \(W_{k}\) is \(0\), it means that the \(i\)th neuron on layer \(k\) can be removed, and the column \(i\) of \(W_{k+1}\) can be deleted. Conversely, if column \(j\) of the weight matrix \(W_{k}\) is \(0\), then this column can be deleted and the \(j\)th neuron on layer \(k-1\) can be removed. These statements have the following stronger counterpart.
**Theorem 9**.: _Suppose an arbitrary deep linear neural network is trained on a single generic data point \(x\) with the corresponding generic output vector \(y\). Then in a critical point of \(\mathcal{L}^{\Lambda}\) the row \(i\) of \(W_{k-1}\) is zero if and only if the \(i\)th column of \(W_{k}\) is zero._
Proof.: We retain our notation from the previous proof, and let \(P=W_{k-1}\) and \(Z=W_{k}\). Then \(V_{Z}=P\cdots W_{2}W_{1}\), and if row \(i\) of \(P\) is zero, then row \(i\) of \(V_{Z}\) is zero. It follows that \(E_{i}=x_{1}(V_{Z}^{T})_{1i}+\cdots+x_{n}(V_{Z}^{T})_{ni}=0\) and from (8) we conclude that the \(i\)th column of \(Z\) is zero. Conversely, suppose the \(i\)th column of \(Z\) is zero. Since \((U_{P})^{T}=Z^{T}\cdots W_{H}^{T}W_{H+1}^{T}\), then row \(i\) of \((U_{P})^{T}\) is zero. It follows that \(D_{i}=(U_{P}^{T})_{i1}R_{1}+\cdots+(U_{P}^{T})_{ip}R_{p}=0\) and the result follows again from (8).
For the weight matrices \(W_{1}\) and \(W_{H+1}\), Proposition 8 has stronger corollaries.
**Corollary 10**.: _Suppose an arbitrary deep linear neural network is trained on a single generic data point \(x\) with the corresponding generic output vector \(y\). Then, if in a critical point of \(\mathcal{L}^{\Lambda}\) the \((i,j)\) entry of \(W_{1}\) is zero, then the \(i\)th row of \(W_{1}\) must be zero._
Proof.: This follows from equations (5).
**Corollary 11**.: _Suppose an arbitrary deep linear neural network is trained on a single generic data point \(x\) with the corresponding generic output vector \(y\). Then, if in a critical point of \(\mathcal{L}^{\Lambda}\) the \((i,j)\) entry of \(W_{H+1}\) is zero then the \(j\)th column of \(W_{H+1}\) must be zero._
Proof.: Let \(Z=W_{H+1}\) and suppose \(z_{ij}=0\). Then \(D_{i}E_{j}=0\) as in the proof of Proposition 8. We observe that \(U_{Z}\) is the identity matrix and therefore \(D_{i}=R_{i}=(Wx-y)_{i}\). If column \(j\) of \(Z\) is not zero, then \(E_{j}\neq 0\) and therefore \(D_{i}=0\). Hence \(R_{i}=0\) and this means that \((Wx)_{i}=y_{i}\). But this also means that \(i\)th row of \(Z\) is zero, and therefore the \(i\)th row of \(W\) is zero. But then \(y_{i}=0\) which contradicts the genericity of \(y\). We conclude that the \(j\)th column of \(Z=W_{H+1}\) must be zero.
For a network with one hidden layer trained on a single data point we gave a bound on the number of critical points in which the entries of the first weight matrix are in \(\mathbb{C}^{*}\); see Theorem 5. Now we expand this count to all complex critical points.
**Corollary 12**.: _Consider a linear network with \(H=1\), \(m=1\), \(d_{x}=n\), \(d_{y}=p\) and \(d_{1}=d\) with generic input/output vectors and generic regularization matrices. Then, there are at most_
\[\mathcal{B}_{\mathbb{C}}=(1+4p)^{d}\]
_complex solutions of (2)._
Proof.: By the above results the possible patterns of zeros in critical points are completely determined by the rows of \(W_{1}\) that are zero. Since the corresponding columns of \(W_{2}\) must be zero we can reduce the neural network by removing the neurons matching the zero rows of \(W_{1}\). If \(r\) rows of \(W_{1}\) are zero, Theorem 5 implies that there are at most \((4p)^{d-r}\) critical points where the remaining rows of \(W_{1}\) are in \(\mathbb{C}^{*}\). Therefore the number of all complex critical points for this network is
\[\mathcal{B}_{\mathbb{C}}=\sum_{r=0}^{d}\binom{d}{r}(4p)^{d-r}=(1+4p)^{d}.\]
**Example 13**.: Consider a linear neural network with one hidden layer trained on a single input vector where \(d_{x}=d_{y}=d_{1}=2\). The classic Bezout bound on the number of complex critical points is \(3^{8}=6561\). The BKK bound yields \(1089\). According to Theorem 5 the number of critical points in \((\mathbb{C}^{*})^{8}\) is bounded by \(\mathcal{B}_{\mathbb{C}^{*}}=64\), and by the above corollary the number of critical points in \(\mathbb{C}^{8}\) is bounded by \(\mathcal{B}_{\mathbb{C}}=81\). These solutions are expected to come in four flavors:
\[\begin{array}{ccccc}W_{2}&&W_{1}&&W_{2}&&W_{1}\\ \left(\begin{array}{ccccc}*&*&*&*\\ *&*&*&*\end{array}\right)&\left(\begin{array}{ccccc}0&*&0&0\\ 0&*&*&*\end{array}\right)\\ \\ \left(\begin{array}{ccccc}*&0&*&*\\ *&0&0&0\end{array}\right)&\left(\begin{array}{ccccc}0&0&0&0\\ 0&0&0&0\end{array}\right)\end{array}\]
The first type with full support corresponds to critical points in \((\mathbb{C}^{*})^{8}\), and there are at most \(64\) of them. The next two types have zeros in the first or second row of \(W_{1}\), and there are at most \(8\) such solutions for each type. Finally, there is the last type which corresponds to the origin. Using _HomotopyContinuation.jl_ we see that there are actually \(33\) critical points in \(\mathbb{C}^{8}\) of which \(16\) are in \((\mathbb{C}^{*})^{8}\). \(\triangle\)
**Example 14**.: Not every possible pattern of zeros is realized. A simple example comes from the case with \(d_{x}=d_{y}=1\) and \(d_{1}=2\) when \(H=m=1\). Again one expects four types of critical points, but there are no complex critical points with only nonzero coordinates. The total number of critical points is \(9\). A more interesting example arises from the case when \(H=d_{x}=d_{y}=d_{1}=2\) with \(m=1\). The total number of possible types of critical points is ten. However, the following two types of solutions do not appear:
\[\begin{array}{ccccc}W_{3}&&W_{2}&&W_{1}\\ 0&*&0&0&*&*\\ 0&*&*&*&*&*\\ *&0&*&*&*&*\\ *&0&0&0&*&*\end{array}\]
\(\triangle\)
**Conjecture 15**.: All our results in this section are for linear neural networks trained on a single data point. However, in our computations we observe that Proposition 8, Theorem 9, Corollary 10, and Corollary 11 hold for \(m=2\). We conjecture these results to be true for any \(m\).
## 5. Computations and Conclusions
In this section we present results showing the number of critical points for different network architectures, i.e. different values of \(H,m,d_{i},d_{x}\) and \(d_{y}\). When \(H=2\) we use \(d_{1}=d_{2}\) and denote it by \(d_{i}\). The results are summarized in Tables 1 - 4 which can be found in the Appendix. Each case yields a polynomial system whose coefficients are determined by the entries of the data matrices \(X\in\mathbb{R}^{d_{x}\times m}\) and \(Y\in\mathbb{R}^{d_{y}\times m}\), and the regularization constants from \(\Lambda_{i}\). The entries of \(X\) and \(Y\) are drawn i.i.d. from a Gaussian distribution with mean 0 and variance 1. The entries of \(\Lambda_{i}\) are drawn i.i.d. from the uniform distribution between 0 and 1. For each case, all isolated solutions to each of the 100 samples are computed using _HomotopyContinuation.jl_ on a single Amazon EC2 instance. Instances used were of type _c5.4xlarge_ (16 vCPUs, 8 cores, 32 GB memory) or _c5.9xlarge_ (36 vCPUs, 18 cores, 72 GB memory), depending on the size of the polynomial system. Most systems took less than an hour of wall-clock time to solve.
Table 1 through Table 4 expand the results for \(H,m\in\{1,2\}\) reported in [14] where the authors used _Bertini_. We report the classical Bezout bound, the BKK bound, the number of complex critical points (\(N_{\mathbb{C}}\)), the number of complex critical points in the algebraic torus (\(N_{\mathbb{C}^{*}}\)), and the maximum number of real critical points observed (\(\max\{N_{\mathbb{R}}\}\)). Table 1 contains two additional columns reporting \(\mathcal{B}_{\mathbb{C}^{*}}\) and \(\mathcal{B}_{\mathbb{C}}\) of Theorem 5 and Corollary 12, respectively.
We observe that while the BKK bound is much better than the Bezout bound, even the BKK bound is far from the actual number of complex critical points. The number of real critical points is even lower. The gradient equations (2) yield very structured and very sparse polynomials. Though the computed BKK bounds are not tight enough, it would be interesting to study the Newton polytopes of these equations in the hope of finding formulas for their mixed volumes. Theorem 5 provides much tighter bounds for the case of \(H=1\) and \(m=1\). We believe it is worthwhile to attempt to generalize this theorem. However, the real benefit of this theorem or its possible generalizations is in creating custom-made homotopies that will track only \(\mathcal{B}_{\mathbb{C}}\) paths. This will require constructing appropriate initial systems.
We would like to also note that while some of our results explain some of the numbers in the tables, there are other patterns waiting to be explained. Proposition 3 tells us that the BKK bounds in Table 1 and 2, and those in Table 3 and 4 for the same \(d_{i},d_{x},d_{y}\) must match. From the limited computations we have, it appears that the BKK bounds for the identical parameters except \(d_{x}\) and \(d_{y}\) values switched (for instance
\(d_{x}=2\) and \(d_{y}=3\) versus \(d_{x}=3\) and \(d_{y}=3\)) coincide. We invite the reader to unearth more patterns.
|
2310.06171 | Memory-Consistent Neural Networks for Imitation Learning | Imitation learning considerably simplifies policy synthesis compared to
alternative approaches by exploiting access to expert demonstrations. For such
imitation policies, errors away from the training samples are particularly
critical. Even rare slip-ups in the policy action outputs can compound quickly
over time, since they lead to unfamiliar future states where the policy is
still more likely to err, eventually causing task failures. We revisit simple
supervised ``behavior cloning'' for conveniently training the policy from
nothing more than pre-recorded demonstrations, but carefully design the model
class to counter the compounding error phenomenon. Our ``memory-consistent
neural network'' (MCNN) outputs are hard-constrained to stay within clearly
specified permissible regions anchored to prototypical ``memory'' training
samples. We provide a guaranteed upper bound for the sub-optimality gap induced
by MCNN policies. Using MCNNs on 10 imitation learning tasks, with MLP,
Transformer, and Diffusion backbones, spanning dexterous robotic manipulation
and driving, proprioceptive inputs and visual inputs, and varying sizes and
types of demonstration data, we find large and consistent gains in performance,
validating that MCNNs are better-suited than vanilla deep neural networks for
imitation learning applications. Website:
https://sites.google.com/view/mcnn-imitation | Kaustubh Sridhar, Souradeep Dutta, Dinesh Jayaraman, James Weimer, Insup Lee | 2023-10-09T21:49:48Z | http://arxiv.org/abs/2310.06171v2 | # Memory-Consistent Neural Networks for Imitation Learning
###### Abstract
Imitation learning considerably simplifies policy synthesis compared to alternative approaches by exploiting access to expert demonstrations. For such imitation policies, errors away from the training samples are particularly critical. Even rare slip-ups in the policy action outputs can compound quickly over time, since they lead to unfamiliar future states where the policy is still more likely to err, eventually causing task failures. We revisit simple supervised "behavior cloning" for conveniently training the policy from nothing more than pre-recorded demonstrations, but carefully design the model class to counter the compounding error phenomenon. Our "memory-consistent neural network" (MCNN) outputs are hard-constrained to stay within clearly specified permissible regions anchored to prototypical "memory" training samples. We provide a guaranteed upper bound for the sub-optimality gap induced by MCNN policies. Using MCNNs on 9 imitation learning tasks, with MLP, Transformer, and Diffusion backbones, spanning dexterous robotic manipulation and driving, proprioceptive inputs and visual inputs, and varying sizes and types of demonstration data, we find large and consistent gains in performance, validating that MCNNs are better-suited than vanilla deep neural networks for imitation learning applications. Website: [https://sites.google.com/view/mcnn-imitation](https://sites.google.com/view/mcnn-imitation)
## 1 Introduction
For sequential decision making problems such as robotic control, imitation learning is an attractive and scalable option for learning decision making policies when expert demonstrations are available as a task specification. Such demonstrations are typically easier to provide than the typical task specification requirements for reinforcement learning and model-based control, namely, dense rewards and good models of the environment. Furthermore, imitation learning is also typically less experience-intensive than reinforcement learning and less expertise-intensive than model-based control.
We consider the simplest and perhaps most widely used imitation learning algorithm, behavior cloning (BC) [26], which reduces policy synthesis to supervised learning over the expert demonstration data. For example, a neural network policy for an autonomous car could be trained to mimic human driving actions [2]. While the policy is synthesized with supervised learning, the evaluation setup is very different: rather than merely achieving low average error on states from the training data, as common in supervised learning, the trained policy must, when rolled out in the world, successfully accomplish the demonstrated task.
This sequential deployment makes the behavior of imitation policy functions away from their training data particularly critical. To see this, observe that during rollout, the policy's own output actions determine its future input states. Task performance is most closely tied to the policy's behavior on this self-induced set of states, which can deviate from the training dataset of expert demonstrations. In particular, a minor error in the policy's action output at any time may induce a future input state that is subtly different from expert states. If the policy behaves erratically under such small deviations, as it often does in practice, the situation quickly snowballs into a vicious cycle of compounding errors leading to task failure.
Past solutions to this compounding error problem have focused on modifying the behavior cloning setup, such as by permitting online experience [12, 31], reward labels
[25], queryable experts [34], or modifying the demonstration data collection procedure [18]. Instead, we retain the conveniences of the plain BC setup and focus on designing a model class that encourages better behavior beyond the training data, which in turn could boost task performance by mitigating the compounding error phenomenon discussed above. We provide a simple plug-in approach to improve BC with any deep neural network. It is well known that vanilla deep neural networks, only by themselves, can generate large errors when evaluated away from the training points, and even rare errors could derail an entire task rollout. These large errors are particularly evident when the expert demonstrations are few in number such as in robotics where human demonstrations are essential for imitation learning. To tame these errors, we propose semi-parametric "memory-consistent neural networks" (MCNN). MCNNs first subsample the dataset into representative prototype "memories" to form the scaffold for the eventual function. They then fit a parametric function to the rest of the training data that is hard-constrained by the very formulation of the model class, to exactly fit the training data at all the memories, and further, to stay within double-cone-like zones of controllable shapes and sizes centered at each memory. As a result, an MCNN behaves mostly like a nearest-neighbor function close to memories, and mostly like a deep neural network (subject to the double-cone constraints) for from them. All functions in this MCNN model class lie within "permissible regions" centered on each memory, meaning that function values away from the training points are bounded. Under mild assumptions on the expert policy, we show that this property of MCNNs induces an upper bound on the suboptimality of the learned BC policy. Visualizations of MCNNs can be found in Figure 2.
Using MCNNs on 9 imitation learning tasks, with MLP, Transformer and Diffusion backbones, spanning dexterous robotic manipulation and driving, proprioceptive inputs and visual inputs, and varying sizes and types of demonstration data, we find large and consistent gains in performance, validating that MCNNs are better-suited than vanilla deep neural networks for imitation learning applications. Figure 1 visualizes the percentage increase in return with MCNN policies compared to the vanilla BC results reported in D4RL [9] for various quantities of training demonstrations across tasks. The trend of the median demonstrates that MCNNs are highly effective in the low data regime where generalization to test trajectories is stressed.
## 2 Related Work
We present a detailed related work discussion in Appendix C & summarize closely related work here.
**Compounding errors in imitation learning** have previously been tackled by permitting online experience [12, 31], reward labels [25], queryable experts [34], or modifying the demonstration data collection procedure [18]. Our work is orthogonal to these methods and creates a model class that avoids compounding errors by construction. Other works that propose new models for IL such as Implicit BC (IBC) [7], Behavior Transformer (BeT) [35], Action Chunking Transformer [45], and Diffusion Policies [41, 1] are orthogonal to our approach. MCNN can be used as a plug-in approach to improve any of these methods. In fact, we show that MCNN with a BeT backbone outperforms vanilla BeT and MCNN with a diffusion model outperforms diffusion BC on all tasks in our experiments in Section 5. We also show that MCNN outperforms IBC in Section 5.
**Non-parametric and semi-parametric methods in imitation learning** such as nearest neighbors [36], RBFs [32], and SVMs [19] have historically shown competitive performance on various robotic control benchmarks. But, only recently, a semi-parametric approach consisting of neural networks for representation learning and k-nearest neighbors for control was proposed in Visual Imitation through Nearest Neighbors (VINN) [24]. This is the closest paper to our work and in Section 5, we compare with VINN and demonstrate that we outperform their method comprehensively.
Figure 1: **MCNN significantly improves performance on realistic demonstration datasets. We plot the percentage increase in return with MCNN over D4RL BC [9] for various number of demonstrations across many tasks. In this plot, each point is a separate MCNN policy. We see significant improvements in the few demonstrations regime where most realistic imitation learning tasks can be found. The choice of model class is crucial in such regimes and MCNN shines. Additional details are in Appendix E.**
**Theoretical guarantees on the sub-optimality gap in imitation learning** with MCNN are provided in this paper. Such guarantees are not available with vanilla neural networks. Our theorem builds on earlier work on reductions for imitation learning in [33, 28, 2, 29] and leverages intuitions from [23] on bounding the width of the model class.
## 3 Problem Formulation
A _Markov Decision Process (MDP)_ is a tuple \(\mathcal{E}=(\mathcal{S},\mathcal{A},\mathcal{P},\mathcal{R},\gamma,\mathcal{I})\), where \(\mathcal{S}\subseteq\mathbb{R}^{n}\) is the set of states, \(\mathcal{A}\) is the set of actions, \(\mathcal{P}(s^{\prime}|s,a)\) is the probability of transitioning from state \(s\) to \(s^{\prime}\) when taking action \(a\), \(\mathcal{R}(s,a)\) is the reward accreted in state \(s\) upon taking action \(a\), \(\gamma\in[0,1)\) is the discount factor, and \(\mathcal{I}\) is the initial state distribution. We assume that the MDP operates over trajectories with finite length \(H\), in an episodic fashion. Additionally, we assume the set of states \(\mathcal{S}\) to be closed and compact. Given a policy \(\pi:\mathcal{S}\mapsto\mathcal{A}\), the expected cumulative reward accrued over the duration of an episode is given by the following,
\[J(\pi)=\mathbb{E}_{\pi}\big{[}\sum_{t=1}^{H}\mathcal{R}(s_{t},a_{t})\big{]}. \tag{1}\]
In imitation learning, we assume that there exists an expert policy \(\pi^{*}\) unknown to the learner. This policy induces a distribution \(d_{\pi^{*}}\) on the state-action space \(\mathcal{S}\times\mathcal{A}\) obtained by rollouts on the MDP. The learner agent has access to an expert trajectory dataset \(D=\big{\{}(s_{0},a_{0}),(s_{1},a_{1}),\ldots,(s_{N},a_{N})\big{\}}\) drawn from distribution \(d_{\pi^{*}}\). The goal of imitation learning is to estimate a policy \(\hat{\pi}\), which mimics the expert's policy and reduces the _sub-optimality_ gap: \(J(\pi^{*})-J(\hat{\pi})\).
## 4 Approach
Our approach involves developing a new model class, memory consistent neural networks (MCNN), and training it with supervised learning to clone the expert from the demonstration data. We start by setting up the MCNN model class in Sec 4.1, analyze its theoretical properties for imitation learning in Sec 4.2, and finally describe our behavior cloning algorithm that uses MCNNs in Sec 4.3.
### The Model Class: Memory-Consistent Neural Networks
First, we develop the semi-parametric MCNN model class for imitation learning. MCNNs rely on a code-book set of "memories" \(\mathcal{B}:=\{(s_{i},a_{i})\}_{i=1}^{K}\) which are subsampled from the expert training dataset and summarize it. In practice, such a memory code-book can be created using one of various off-the-shelf approaches. We describe our algorithmic choices later in Sec 4.3. For notational convenience, we describe the approach for a scalar action space, but it is easily generalizable to the vector action spaces we evaluate in our experiments.
Given this memory code-book \(\mathcal{B}\), we now define a "nearest memory neighbor policy". For a finite set \(S\subset\mathcal{S}\), and an input \(x\in\mathcal{S}\), we first define its closest element in \(S\) as, \(C_{S}(x)=\operatorname*{arg\,min}_{s\in S}\,d(s,x)\), where \(d\) is some distance metric defined on the space \(\mathcal{S}\). We denote by \(\mathcal{B}|_{S}\), and \(\mathcal{B}|_{A}\) as the set of all states and actions captured by the memory code-book \(\mathcal{B}\). With slight abuse of notation, we denote \(\mathcal{B}(s)\) as the action assigned by the codebook for a state input \(s\). Using the above, we now define a nearest neighbor regression function \(f^{NN}\) as the following,
**Definition 4.1** (Nearest Memory Neighbor Function).: For an input \(x\in\mathcal{S}\), assume that \(s^{\prime}=C_{\mathcal{B}|_{S}}(x)\), then \(f^{NN}(x):=\mathcal{B}(s^{\prime})\).
In other words, the nearest memory neighbor function assigns actions according to a nearest neighbor look-up in the memory code-book \(\mathcal{B}\). We are now ready to define _memory-consistent neural networks_ (MCNN), which permit interpolating between nearest neighbor functions and parametric deep neural network (DNN)-based functions. Let \(f^{\theta}\) denote a DNN function parameterized by \(\theta\), which maps from MDP states to actions.
**Definition 4.2** (Memory-Consistent Neural Network).: A memory-consistent neural network \(f^{MC}\) is defined using the codebook and DNN function pair (\(\mathcal{B},f^{\theta}\)), and hyperparameters \(\lambda\in\mathbb{R}^{+}\), \(L\in\mathbb{R}\) as
\[f^{MC}_{\theta,\mathcal{B}}(x)=\underbrace{f^{NN}(x)\left(e^{-\lambda\ d(x,s^ {\prime})}\right)}_{\text{Nearest Memory Neighbour Function}}+\underbrace{L\left(1-e^{-\lambda\ d(x,s^{\prime})}\right)\,\sigma(f^{ \theta}(x))}_{\text{Constrained Neural Network Function Class}} \tag{2}\]
where, \(s^{\prime}=C_{\mathcal{B}|_{S}}(x)\) is the nearest memory to \(x\), and \(\sigma:\mathbb{R}\mapsto[-1,1]\) is a compressive non-linearity that imposes hard limits on the outputs of \(f^{\theta}\). In practice, we use \(\tanh\) or similar functions.
We refer the reader to Figure 2 to drive the intuition. For inputs that are close to the points in the codebook \(\mathcal{B}\), the function predicts values that are similar to the one observed in the training dataset. More concretely, the value predicted by the function is a simple mixture: \(\alpha f^{NN}(x)+(1-\alpha)\;\;L\;\sigma(f^{\theta}(x))\;\), where the mixing factor \(\alpha\in[0,1]\) changes in proportion to the distance to the nearest memory. Thus, for points further away more weight is placed on the neural network and the memories have little influence. The degree of permissible deviation from nearest neighbor prediction \(f^{NN}\) is controlled by the parameter \(\lambda\). Thus, we obtain a purely nearest neighbor function for \(\lambda=0\), and a vanilla deep neural network function for \(\lambda=\infty\). Note that the MCNN function values in regions far away from memories are in the set \([-L,L]\). For this reason, we normalize output actions to \([-L,L]\) before training an MCNN function.
### Theoretical Analysis of MCNNs for Imitation Learning
For fixed hyperparameters \(L\), \(\lambda\) and memory codebook \(\mathcal{B}\), we denote by \(\mathfrak{F}\), the class of memory-consistent functions outlined in Equation 2. Note that a choice of the DNN function parameters \(\theta\) fixes a specific function in this class as well.
**Assumption 4.3** (Realizability).: We assume that the expert policy \(\pi^{*}\) belongs to the function class \(\mathfrak{F}\).
This assumption trivially holds at the memories, where the MCNN exactly reproduces expert actions. For all other points, we assume that there exist some parameters \(\theta\), which can capture the policy \(\pi^{*}\) with sufficient accuracy, for a choice of \(L\) and \(\lambda\). For a point \(x\) at a distance of \(d(s^{\prime},x)\), the vanilla DNN can affect the predictions only by an amount of \(\pm L\left(1-e^{-\lambda\;d(x,s^{\prime})}\right)\). Without this restriction, we might have been able to capture behaviors that went well beyond these ranges. This is reasonable since, expert policies do not make sudden unbounded jumps in their actions. What we propose here is a way to enforce this bound using a zeroth order nearest neighbor estimate.
We analyze the behavior of this function class, and present some useful lemmas along the way. For a set of memories present in \(\mathcal{B}|_{S}\), we wish to capture the maximum value that the distance term: \(d(x,s^{\prime})\) can take in Equation 2. To that end, we define the _most isolated state_ as the following:
**Definition 4.4** (Most Isolated State).: For a given set of memory points \(\mathcal{B}|_{S}\), we define the most isolated state \(s^{I}_{\mathcal{B}|_{S}}:=\underset{s\in I}{\operatorname*{arg\,max}}\big{(} \underset{m\in\mathcal{B}|_{S}}{\operatorname*{min}}d(s,m)\big{)}\), and consequently the distance of the most isolated point as \(d^{I}_{\mathcal{B}|_{S}}=\underset{m\in\mathcal{B}|_{S}}{\operatorname*{min}} d(s^{I}_{\mathcal{B}|_{S}},m)\)
Figure 2: **The elements of the MCNN model class. In the top row, the left panel shows the nearest memory neighbour component with memories subsampled from the training dataset shown in red circles. The middle panel depicts the constrained neural network function class, where the blue shaded regions represent the permissible regions; by design, the function cannot take values outside these shaded regions. Finally, the right panel shows the combined MCNN model class. The size of the permissible regions can be modulated by increasing \(\lambda\) (bottom left) or by decreasing the number of memories (bottom right). The second row shows many such MCNN model families with increasing capacity. For additional plots, see Appendix A.**
The distance of the most isolated state captures the degree of emptiness that persists with the current knowledge of the state space due to memory code-book \(\mathcal{B}\).
**Lemma 4.5**.: _Assume two sets of memory code-books \(\mathcal{B}_{i},\ \mathcal{B}_{j}\), such that \(\mathcal{B}_{i}\subseteq\mathcal{B}_{j}\), then \(d^{I}_{\mathcal{B}_{i}|_{S}}\geq d^{I}_{\mathcal{B}_{j}|_{S}}\)_
Proof.: The proof of the above lemma is straightforward, since the infimum of a subset (\(\mathcal{B}_{i}\)) is larger than the infimum of the original set (\(\mathcal{B}_{j}\)).
This observation is useful when we study the effects of increasing the size of the code-book \(\mathcal{B}\). Note, when learning a memory-consistent neural network \(f^{MC}_{\theta,\mathcal{B}}\), we deploy the standard SGD based training to adjust the parameters \(\theta\). The choice of the number of memories in \(\mathcal{B}\) is kept as a hyperparameter. This allows us to bound the maximum width of the function class, first described in [23]. We analyze this for single output functions next.
**Lemma 4.6**.: _(Width of Function Class) The width of the function class \(\mathfrak{F}\), \(\forall\ \theta_{1},\theta_{2}\in\Theta,\ \text{and}\ \forall s\in \mathcal{S}\), defined as \(\underset{\theta_{i},\theta_{j}}{max}\left|\left(f^{MC}_{\theta_{i},\mathcal{ B}}-f^{MC}_{\theta_{j},\mathcal{B}}\right)\left(s\right)\right|\) is upper bounded by \(:2L\times\left(1-e^{-\lambda\ d^{I}_{\mathcal{B}_{i}|_{S}}}\right)\)_
Proof.: Please see Appendix B.
**Theorem 4.7**.: _The sub-optimality gap \(J(\pi^{*})-J(\hat{\pi})\leq min\{H,H^{2}|\mathcal{A}|L\big{(}1-e^{-\lambda\ d^{I}_{ \mathcal{B}_{i}|_{S}}}\big{)}\}\)_
Proof.: In order to take advantage of well-known results in the imitation learning literature [33, 28, 2, 29], we restrict ourselves for the purpose of this analysis to the discrete action-space \(\mathcal{A}\) scenario, where the policy \(\pi:\mathcal{S}\mapsto\Delta(\mathcal{A})\). Even still, the intuitions developed through this analysis guide our algorithmic choices in continuous environments. The actions picked in the expert dataset \(D\) induce a dirac distribution over the actions corresponding to each input state.
Recall that in imitation learning, if the population total variation (TV) risk \(\mathbb{T}(\hat{\pi},\pi^{*})\leq\epsilon\), then, \(J(\pi^{*})-J(\hat{\pi})\leq min\{H,H^{2}\epsilon\}\) (See [28] Lemma 4.3). We note the following for population TV risk:
\[\mathbb{T}(\hat{\pi},\pi^{*}) =\frac{1}{H}\sum_{t=1}^{H}\mathbb{E}_{s_{t}\sim f^{t}_{\pi^{*}}} \left[TV(\hat{\pi}(\cdot|s_{t}),\pi^{*}(\cdot|s_{t}))\right]\leq\frac{1}{H} \sum_{t=1}^{H}\mathbb{E}_{s_{t}\sim f^{t}_{\pi^{*}}}\bigg{[}|\mathcal{A}|L \big{(}1-e^{-\lambda\ d^{I}_{\mathcal{B}_{i}|_{S}}}\big{)}\bigg{]} \tag{3}\] \[\leq|\mathcal{A}|L\big{(}1-e^{-\lambda\ d^{I}_{\mathcal{B}_{i}|_{ S}}}\big{)}\]
where \(f^{t}_{\pi^{*}}\) is the empirical distribution induced on state \(s^{t}\) obtained by rolling out policy \(\pi^{*}\). For the first inequality in the above derivation, we use Lemma 4.6. Using this, in the performance gap lemma gives us the following:
\[J(\pi^{*})-J(\hat{\pi})\leq min\{H,H^{2}|\mathcal{A}|L\left(1-e^{-\lambda\ d^{I }_{\mathcal{B}_{i}|_{S}}}\right)\}\]
**Corollary 4.8**.: _Using Lemma 4.5 we know that if \(\mathcal{B}_{i}\subseteq\mathcal{B}_{j}\), then \(\big{(}1-e^{-\lambda\ d^{I}_{\mathcal{B}_{i}|_{S}}}\big{)}\geq\big{(}1-e^{- \lambda\ d^{I}_{\mathcal{B}_{j}|_{S}}}\big{)}\). This can result in lower performance gap according to Theorem 4.7, when \(H\geq H^{2}|\mathcal{A}|L\big{(}1-e^{-\lambda\ d^{I}_{\mathcal{B}_{i}|_{S}}} \big{)}\). Hence, reflecting the utility of adding more memories in such cases._
Takeaways. We summarize the insights from the above theoretical analysis here. First, _our MCNN class of functions is bounded in_ width (_Lemma 4.6_) even though it uses a high-capacity function approximator like DNNs. _No such bound is available for vanilla neural networks._ This translates to a _bounded sub-optimality gap_ (_Theorem 4.7_) _also not available in vanilla neural networks._ Finally, our Corollary states that we can likely gain better imitation learning performance by simply adding more memories (up to a limit).
### Algorithm: Imitation Learning With MCNN Policies
We now describe our algorithm to use MCNNs for imitation learning. The first step in our method is to learn the memory code-book \(\mathcal{B}\) from the expert trajectory dataset \(D\). The goal of Algorithm 1 is to build the nearest memory neighbor function \(f^{NN}\). This is followed by details on the training aspects of the MCNN parameters from the imitation dataset \(\mathcal{D}_{e}\) in Algorithm 2.
For building the memory code-book, we leverage an off-the-shelf approach, Neural Gas [8], that selects prototype samples to summarize a dataset. For completeness, we summarize this approach briefly below.
```
1:Offline dataset \(\mathcal{D}=\{(s_{i},a_{i})\}_{i=1}^{N}\), number of memories \(m\)
2:A nearest neighbor based function \(f^{NN}:\mathcal{S}\mapsto\mathcal{A}\)
3:Nodes \(\mathcal{N}\), edges \(\mathcal{E}\leftarrow\) NeuralGasClustering(\(\mathcal{S}\), \(m\)) // learns the distribution induced by \(\mathcal{D}\)
4:Nodes \(\mathcal{N}^{\prime}\), \(\mathcal{D}(\mathcal{N}^{\prime})\leftarrow\) For each node in \(\mathcal{N}\), find the closest observation in \(\mathcal{D}\), and call this \(\mathcal{N}^{\prime}\). Additionally, return the corresponding action taken by the expert in \(\mathcal{D}\), denoted by the map \(\mathcal{D}(\mathcal{N}^{\prime})\)
5:\(\mathcal{G}\leftarrow\) Define neural-gas with nodes \(\mathcal{N}^{\prime}\), and edges \(\mathcal{E}\).
6:Define a memory code-book \(\mathcal{B}\) using \(\mathcal{B}|_{\mathcal{S}}=\mathcal{G}\) and \(\mathcal{B}|_{\mathcal{A}}=\mathcal{D}(\mathcal{N}^{\prime})\). Pairing nodes in the neural-gas to its corresponding actions.
7:Define a nearest neighbor function \(f^{NN}_{\mathcal{B}}\), along the lines described in Definition 4.1 using \(\mathcal{B}\).
8:return\(f^{NN}_{\mathcal{B}}\)
```
**Algorithm 1** Learning Memories
Definition 4.9 (Neural Gas).: A neural gas \(\mathcal{G}\coloneqq(\mathcal{N},\mathcal{E})\), is composed of the following components,
1. A set \(\mathcal{N}\subset\mathcal{S}\) of the nodes of a network. Each node \(m_{i}\in\mathcal{N}\) is called a memory in this paper.
2. A set \(\mathcal{E}\subset\{(m_{i},m_{j})\in\mathcal{N}^{2},i\neq j\}\) of edges among pairs of nodes, which encode the topological structure of the data. The edges are unweighted.
Neural gas.The neural gas algorithm [8, 27, 20] is primarily used for unsupervised learning tasks, particularly for data compression or vector quantization. The goal is to group similar data points together based on their similarities. The algorithm works by creating a set of prototype vectors, also known as codebook vectors or neurons. These vectors represent the clusters in the data space. The algorithm works by adaptively placing prototype vectors in the data space and distributing them like a _gas_ in order to capture the density. For more details we refer the reader to [8]. We use this in Algorithm 1 (Line 1) to get the initial clustering. We can now go ahead and outline how "memories" are picked in our case.
Learning memories.Algorithm 1 first uses the neural-gas algorithm to pick candidate points (nodes) \(\mathcal{N}\) in the state space. However, these points could be potentially absent in the dataset \(\mathcal{D}\), making it hard to associate the correct action. To remedy this situation, we replace these points with the closest states from the training set as _memories_. Such _memory_ states come with the corresponding actions taken by the expert. This is then used to define a nearest neighbor function by building the memory codebook \(\mathcal{B}\) and defining a function as outlined in Definition 4.1.
```
1:Dataset \(\mathcal{D}=\{(s_{i},a_{i})\}_{i=1}^{N}\), nearest neighbor function \(f^{NN}_{\mathcal{B}}\), neural network function \(f^{\theta}(.)\), batch size, total training steps \(T\), parameters \(\lambda\) and \(L\). Output: Learned policy \(f^{MC}_{\mathcal{B},\mathcal{B}}\)
2:for\(\text{step}=1\) to \(T\)do
3: Sample batch \(\mathcal{B}\) from \(\mathcal{D}\).
4: Forward propagate \((s_{i},a_{i})\sim B\), \(f^{MC}_{\mathcal{B},\mathcal{B}}(x)=f^{NN}_{\mathcal{B}}(x)\left(e^{-\lambda \ d(x,s^{\prime})}\right)+L\left(1-e^{-\lambda\ d(x,s^{\prime})}\right)\ \sigma(f^{\theta}(x))\) where, \(s^{\prime}\) is the nearest neighbor of \(x\) in \(\mathcal{B}|_{\mathcal{S}}\), \(\sigma_{\mathcal{B}}(x)\) is a \(\tanh\)-like activation function given by \(\sigma_{\mathcal{B}}(x)=2\left[\text{LeakyReLU}_{\mathcal{B}}\left(\frac{x+1}{ 2}\right)-(1-\beta)\text{ReLU}\left(\frac{x-1}{2}\right)\right]-1\) and \(\beta=\max\left(0,1-\lfloor\frac{4\pi\epsilon\epsilon}{1000}\rfloor\right)\).
5: Update \(\theta\leftarrow\theta-\nabla\operatorname{\mathbb{E}}_{(s_{i},a_{i})\sim b} \mathcal{L}(f^{MC}_{\mathcal{B},\mathcal{B}}(s_{i}),a_{i})\) where \(\mathcal{L}\) is the negative log-likelihood or mean squared loss or other loss function.
6:endfor
```
**Algorithm 2** Behavior Cloning with Memory-Consistent Neural Networks: Training
Training MCNNs.Finally, we train MCNN policies through gradient descent on the parameters \(\theta\) of the neural network over the expert dataset \(D_{e}\). For the compressive non-linearity, we use the \(\sigma_{\beta}\) function given in Algorithm 2 which is similar to \(\tanh\). We describe this in detail in Appendix E.
## 5 Experimental Evaluation
We now perform a thorough experimental evaluation of MCNN-based behavior cloning in a large variety of imitation learning settings.
**Environments and Datasets:** We test our approach on 9 tasks, in 5 environments: 4 Adroit dextrous manipulation and 1 CARLA environment as pictured in Figure 3. Demonstration datasets are drawn from D4RL [9]. For each Adroit task, we evaluate imitation learning from 2 different experts: (1) small realistic human demonstration datasets (**'human'**) with 25 trajectories per task (5000 transitions), and (2) large demonstration datasets with 5000 trajectories (1 million transitions) from a well-trained RL policy **('expert')**. In CARLA, we train on 400 demonstration trajectories (100K transitions) from a hand-coded expert. For observations, we use high-dimensional states in Adroit pen, hammer, relocate, and door, and \(48\times 48\) images in CARLA. Action spaces are 24-30 dimensional in the Adroit dexterous manipulation environments and 2-D in CARLA.
**Baselines:** We run the following baselines for comparison. **(1) Behavior Cloning:** We obtain results with a vanilla MLP architecture. The details of the architecture can be found in Appendix E. We report results from our implementation of BC and also report results given in D4RL [9] under the names **'MLP-BC'** and **'D4RL BC'** respectively. Our BC implementation has only one difference from [9]'s implementation: we normalize the observations. Normalizing observations has been shown to improve BC's performance [10]. **(2) 1 Nearest Neighbours (1-NN):** We set up a simple baseline where the action for any observation in the online evaluation is the action of the closest observation in the training data. In the expert and cloned datasets for each environment, this amounts to having to perform a search amongst a million datapoints online at every step (which is highly inefficient). **(3) Visual Imitation with (k) Nearest Neighbours (VINN)**[24]: VINN is a recent method that performs a Euclidean kernel weighted average of some k nearest neighbors. In the Adroit case, we directly perform the k nearest neighbors on the raw observation vectors. In the CARLA case, we perform it in the same embedding space that we use to create memories (we discuss this embedding space more below). **(4) CQL-Sparse (CQL-S)**: We learn a policy using the CQL offline RL algorithm [17] and a sparse reward given for task completion only. **(5) Implicit BC (IBC)**[7]: We report the results from [7] which performs BC with energy models on the human tasks. **(6) Behavior Transformer (BeI-BC)**[35]: We train and evaluate a behavior transformer using the official implementation on all tasks. **(7) Diffusion BC (Diff-BC)**[41]: We also train and evaluate a diffusion-based BC policy using the implementation in [41]. We provide additional details for all baselines and comprehensive hyperparameter sweeps in Appendix E.
**Learning memories and MCNN:** We learn neural gas memories with the incremental neural gas algorithm for 10 epochs starting from \(2.5\%\) of the total dataset to \(10\%\) of the total dataset for each task. We update all the transitions in each dataset by appending the closest memory observation and its corresponding target action (see more in Algorithm 1). We train the MCNN on this dataset following Algorithm 2 for \(1\) million steps and evaluate on 20 trajectories after training and repeat each experiment for a minimum of 3 seeds. We report results with an MLP, a behavior transformer (BeT), and a diffusion policy as the underlying neural network under the names **'MCNN+MLP'**, **'MCNN+BeT'**, and **'MCNN+Diff'** respectively. We expand on the experimental setup and all hyperparameters in Appendix E.
**Embedding CARLA images:** In the CARLA tasks, we use an off-the-shelf ResNet34 encoder [2] that has been shown to be robust to background and environment changes in CARLA to convert the \(48\times 48\) images to embeddings of size \(512\). We use this embedding space as the observation space for learning memories and policies.
**Performance Metrics:** All our environments come with pre-specified dense task rewards which we use to define performance metrics. We report the cumulative rewards (return) for each task. For the
Figure 3: The D4RL [9] environments where we evaluate our trained policies: Adroit Pen, Hammer, Relocate, and Door [30], and CARLA’s Town03 and Town04 [3]. The four Adroit environments have proprioceptive observations and the CARLA environment has image observations.
aggregate plots on a set of four tasks, we compute the percentage increase in return of a method over D4RL BC in all four tasks and report the median.
Results:First, for the "human" tasks with the most realistic imitation learning setup, we plot aggregate and taskwise results in Figure 4. In aggregate-human, we see that MCNN+MLP with fixed hyperparameters performs the best followed by MCNN+Diff and IBC at second place. We also see that the MCNN variants of MLP, BeT and Diffusion consistently outperform the vanilla versions. In pen-human-v1, MCNN+MLP outperforms the nearest baseline by 33%. It is also the only method to shoot past the expert ceiling of 100 (depicted by a dashed red line). In hammer-human-v1, MCNN+MLP is the only method to obtain a positive return outpacing the nearest baseline by an order of magnitude (from -11 to 262). In relocate-human-v1, MCNN+BeT is the only method to achieve a positive return. We attribute, like previous work [22], the stronger performance of MCNN+BeT over other MCNN variants in the relocate task to the'memory' advantage available to transformers that is specifically suited for this task (where the historical states inform whether the ball has been grasped). Lastly, in door-human-v1, MCNN+Diff outperforms all but the IBC baseline by an order of magnitude. In this task, where repeated attempts at grasping and opening the door handle are usually required for success, we see methods that enable such repetition (energy models in IBC and diffusion in MCNN+Diff) succeed.
On the expert tasks in Figure 5, even with a large amount of data, we see MCNN+MLP come in first outperforming the nearest baseline in the aggregate plot by over 100%. MCNN+Diff comes in second in aggregate with a 40% improvement over the nearest baseline. Here too, MCNN variants outperform the vanilla versions across all tasks. Also, MCNN+MLP and MCNN+Diff are the only methods to exceed the expert ceiling in all four tasks. Across expert tasks both MCNN+MLP and MCNN+Diff perform competitively and obtain up to a 25% improvement over the nearest baseline.
In the high dimensional CARLA lane task as well, we see in Figure 8 that MCNN+MLP outperforms the nearest baseline by 27%. MCNN+BeT comes in a close second. Additional figures and all means and standard deviations of our results can be found in Appendix F.
Figure 4: **Adroit human tasks [25 demos]:** Comparison of returns (across 20 evaluation trajectories and 3 random seeds) between baselines and our methods (MCNN+BeT, MCNN+Diff, and MCNN+MLP). Our MCNN methods use the same fixed set of hyperparameters across all tasks.
Figure 5: **Adroit expert tasks [5000 demos]:** Comparison of returns (across 20 evaluation trajectories and 3 random seeds) between baselines and our methods (MCNN+BeT, MCNN+Diff, and MCNN+MLP). Our MCNN methods use the same fixed set of hyperparameters across all tasks.
**Discussion:** We identify some high-level trends across our results here. For every architecture - MLP, BeT, or Diffusion, plugging in MCNN significantly improves performance in every task. The best-performing method in nearly every task is an MCNN-based method. MCNN can even improve the performance of simple MLP architectures to beyond that of more sophisticated recent architectures such as Diffusion models. For example, in pen-human-v1 in Figure 4, diffusion outperforms MLP but MCNN+MLP significantly improves upon Diffusion. The above statements remain true across different types and sizes of expert data and across disparate tasks. We discuss some ablations next.
**Ablations:** We plot return against number of memories in Figure 6 for MCNN+MLP. It demonstrates the existence of a "sweet spot" for the number of memories around 10-20% of the dataset. This allows for more efficient inference in MCNN than in baselines like VINN and 1-NN. It also shows the expected degradation to 1-NN performance as the number of memories increases towards 100%. Additional discussion on computation cost and improved efficiency of MCNN compared to VINN and 1-NN can be found in Appendix E.
In Figure 7, we show that given limited online interaction (here, 20 episodes), simply selecting the best-performing hyperparameters (\(\lambda\), \(L\), and a number of memories) further improves MCNN+MLP performance. We also demonstrate the significance of neural gas-based memories by comparing MCNN+MLP with a version that uses randomly chosen memories in Figure 13 in Appendix F. We observe significantly reduced performance with randomly chosen memories. We attribute this to the competitive Hebbian learning algorithm for the neural gas, which is better at capturing the distribution of training points (and creating memories that are "spread out"). This in turn reduces the distance to the most isolated state, improving imitation performance. Additional results on ablating the values of \(\lambda\) and on all other tasks can be found in Appendix F.
## 6 Conclusions and Limitations.
Imitation learning, and in particular behavior cloning, is one of the most promising approaches when it comes to transferring complex robotic manipulation skills from experts to embodied agents. In this work, we introduced MCNNs, a semi-parametric approach to behavior cloning that significantly increases the performance of behavior cloning methods across diverse realistic tasks and datasets regardless of the underlying architecture (MLP, transformer, or diffusion). While our theoretical and empirical results support the idea that appropriately constraining the function class based on training data memories improves imitation performance, MCNNs are only one heuristic way to accomplish this; it is very likely that there are even better-designed model classes in this spirit, that we have not explored in this work. Finally, we would like in future work to explore MCNNs as model classes beyond just behavior cloning, such as in reinforcement learning and meta-learning.
Figure 8: **CARLA [400 demos]**: Comparison of return (across 20 evaluation trajectories and 3 random seeds) between baselines and our methods (MCNN+BeT and MCNN+MLP). For the results shown here, our MCNN methods use the same fixed set of hyperparameters across all tasks.
Figure 6: Number of Memories in MCNN+MLP: Comparison of returns (across 20 evaluation trajectories) with our method (MCNN+MLP) using between 2.5% to 80% of the dataset as memories. We find a "sweet spot" for number of memories at 10-20%. We also see the expected decrease to 1-NN performance as number of memories increases to 100%.
Figure 7: Fixed vs Tuned Hyperparameters in MCNN+MLP: Comparison of returns (across 20 eval trajectories and 3 seeds) between our method with fixed hyperparameters across all tasks and with hyperparameters tuned online. This shows that limited online interaction (20 ep) for finetuning hyperparameters can further improve our method. |
2310.17732 | GNN-GMVO: Graph Neural Networks for Optimizing Gross Merchandise Value
in Similar Item Recommendation | Similar item recommendation is a critical task in the e-Commerce industry,
which helps customers explore similar and relevant alternatives based on their
interested products. Despite the traditional machine learning models, Graph
Neural Networks (GNNs), by design, can understand complex relations like
similarity between products. However, in contrast to their wide usage in
retrieval tasks and their focus on optimizing the relevance, the current GNN
architectures are not tailored toward maximizing revenue-related objectives
such as Gross Merchandise Value (GMV), which is one of the major business
metrics for e-Commerce companies. In addition, defining accurate edge relations
in GNNs is non-trivial in large-scale e-Commerce systems, due to the
heterogeneity nature of the item-item relationships. This work aims to address
these issues by designing a new GNN architecture called GNN-GMVO (Graph Neural
Network - Gross Merchandise Value Optimizer). This model directly optimizes GMV
while considering the complex relations between items. In addition, we propose
a customized edge construction method to tailor the model toward similar item
recommendation task and alleviate the noisy and complex item-item relations. In
our comprehensive experiments on three real-world datasets, we show higher
prediction performance and expected GMV for top ranked items recommended by our
model when compared with selected state-of-the-art benchmark models. | Ramin Giahi, Reza Yousefi Maragheh, Nima Farrokhsiar, Jianpeng Xu, Jason Cho, Evren Korpeoglu, Sushant Kumar, Kannan Achan | 2023-10-26T18:43:16Z | http://arxiv.org/abs/2310.17732v1 | GNN-GMVO: Graph Neural Networks for Optimizing Gross Merchandise Value in Similar Item Recommendation
###### Abstract
Similar item recommendation is a critical task in the e-Commerce industry, which helps customers explore similar and relevant alternatives based on their interested products. Despite the traditional machine learning models, Graph Neural Networks (GNNs), by design, can understand complex relations like similarity between products. However, in contrast to their wide usage in retrieval tasks and their focus on optimizing the relevance, the current GNN architectures are not tailored toward maximizing revenue-related objectives such as Gross Merchandise Value (GMV), which is one of the major business metrics for e-Commerce companies. In addition, defining accurate edge relations in GNNs is non-trivial in large-scale e-Commerce systems, due to the heterogeneity nature of the item-item relationships. This work aims to address these issues by designing a new GNN architecture called GNN-GMVO (Graph Neural Network - Gross Merchandise Value Optimizer). This model directly optimizes GMV while considering the complex relations between items. In addition, we propose a customized edge construction method to tailor the model toward similar item recommendation task and alleviate the noisy and complex item-item relations. In our comprehensive experiments on three real-world datasets, we show higher prediction performance and expected GMV for top ranked items recommended by our model when compared with selected state-of-the-art benchmark models.
Recommendation Systems, Graph Neural Networks, Similar Item Recommendations, Gross Merchandise Value Optimization
## I Introduction
The goal of recommender systems in e-Commerce settings is to increase the click-through rate (CTR) and revenue by recommending items that users will likely interact with and eventually purchase [1]. Similar item recommendation plays a vital role in enhancing customers' exploration experiences on e-Commerce websites, by recommending similar substitutes for a given anchor item. This type of models enables users to be exposed to a broader set of products and allow marketing campaigns to reach potential customers effectively. Both these factors increase the chance of conversion [2].
Different modeling approaches are suggested in the literature to capture complex relations like similarity for items. One of the recent approaches for this task is to use graph-based models, which can identify and formulate the relation between items to make accurate recommendations [3]. GNNs generate representations of nodes that depend on the graph's structure, item pairs links (edge) features, and relations. The most common paradigm for GNNs in item recommendations is to learn node (i.e., product) representation to perform relation predictions based on the embedding vectors [4].
Identifying product relations, such as similarity and complementarity, is important in the e-Commerce recommendation platform [5]. Ignoring these diverse types of relations can lead to losing critical information about item relations. In addition, the ultimate optimization objective can play a critical role in graph models' performance in different settings. For instance, if the graph model's architecture optimizes relevance-related loss functions, it can lead to suboptimal recommendations from a revenue standpoint. This, in turn, can make the usage of those graph architectures prohibitive for large-scale industrial e-Commerce systems.
To address these issues, we propose a new graph-based model that considers the diverse, complex relations in item spaces of large-scale e-Commerce settings and can directly optimize on Gross Merchandise Value (GMV)-related loss function. We call this architecture Graph Neural Network - Gross Merchandise Value Optimizer (GNN-GMVO). Under this model, we propose a new multi-objective decoder function that optimizes on a combination of relevance and GMV. This makes the model capable of adjusting the loss function per the usage setting. In other words, depending on the degree of importance of relevance and revenue, the model objective can change.
Through our extensive experiments, we design a new edge relation based on item-item data that considers relational information like co-view, view-then-bought (an item viewed, then another item is ultimately bought), and co-purchase. This new metric helps us better identify similarity relations among other types of relations between items and reduce noise (i.e., other types of item-item relations).
We perform experiments to validate the proposed archi
tecture on a user-interaction proprietary e-Commerce dataset from _Walmart.com_ and two publicly available datasets from Amazon. According to the results, GNN-GMVO outperforms the currently deployed model in prediction metrics in _Walmart.com_. The model also performs better than GCN [6] and Graph Attention Networks (GAT) [7] models in expected GMV without hurting the NDCG metric.
The rest of this paper is organized as follows. In section II, we present background and related work. In section III, the methodology and the architecture of GNN-GMVO are elaborated. In section IV, we report the experiments conducted to compare the proposed architecture with the existing benchmarks. Section V states the conclusion and direction for future research.
## II Background and related work
Among proposed algorithms for recommendation systems, GNNs have shown to be one of the most promising models [3]. One reason for this success might be the inherent design of the graph models that directly takes advantage of item-item, user-item, or user-sequence interactions. In the last decade, various aspects of GNN-based recommendation systems have come under attention in industry and academia [8, 9, 10]. In this section, we review some of the relevant work to our paper.
One closely related topic to similar item recommendation is social recommendation task. This task emerged with the creation of online social networks. The models in the social recommendation track assume that a given graph node's local neighbors can be used to improve node representation modeling, because a given node's neighbors should have similarity with the node itself [11]. The similarities between nodes are used in two different ways for modeling purpose: (i) to improve final generated node representation modeling [12], (ii) to explicitly use them as regularizers to limit the final node latent representations [13, 14, 15].
Considering diverse nature of item-item relation is one of the important aspect of our work. Because of this another stream of research pertaining to our work is the knowledge graph based recommendation. Knowledge graphs utilize a complex graph structure with several types of nodes and relation among them [16]. Mainstream papers in this area of literature create embeddings for relations and focus on semantic relevance (see [17, 18] for example), and the semantic information of both nodes and relations are considered.
Another research track relevant to our work is models focusing on revenue optimization. Most research in item recommendation systems' literature is based on optimizing the item recommendation relevance. However, in e-Commerce settings, the objective maybe to optimize on generated revenue [19]. There are non-graph machine learning models like [20] and [21] that can potentially model context created by price of recommended items on the user behavior. Some other papers take this one step further and study the so-called assortment optimization problem (see [19, 22]). Under assortment optimization problem, one is interested in finding a subset of items that maximize the revenues. Most of the models studied in this context, like multinomial logistic regression [23], mixed multinomial logistic regression [24], and nested logit model [25] are simple listwise models from an ML standpoint of view, which makes their usage prohibitive in complex big-data settings. However, due to listwise nature of user choice behavior, the assortment optimization problem becomes combinatorially challenging (see [26] for example). For instance, [22] develops a scalable model to identify similar items and maximize revenue by constructing a pointwise ranking model, see [27] and [28] for a survey of models optimizing on generated revenue. However, as mentioned, these models do not explicitly incorporate the item-item relations inherent to graph models and may lose some relational information.
In parallel to non-graph models focusing on optimizing revenue, there are graph models for similar-item recommendation not optimizing on revenue-related metrics. However, they mainly focus on optimizing relevance in the item recommendation setting. For example, [29] develop a method to recommend unforeseen apps to the users by constructing an app-app similarity graph and using users' interaction data with previously installed apps. [30] propose an architecture with a weighted graph attention layer to provide in-session item embedding and recommend the next item in each session while optimizing CTR.
Finally, some papers attempt to present graph-based models that are at least price aware if not optimizing on generated revenue by the recommendations. In their model, the utility scores of items are function of recommended price of the whole list of recommended items. [1] propose a price-aware GNN-based recommender system that discovers user price sensitivity for each price category. To do so, they add nodes for price and category to the user-item graph and allow the item price to be propagated to the user embeddings through the item nodes. This structure allows for user price preference on unexplored categories. To the authors' best knowledge, although revenue awareness has been a research topic for other recommender systems [31, 32], it has not been studied as part of GNN-based recommender systems. In this paper, we seek to fill the literature gap by proposing a graph-based model for a similar item recommendation task that explicitly models item-item relations while optimizing generated revenue by the recommendations.
## III Method
This section introduces the architecture of the proposed GNN-GMVO framework, the high-level system view, and its components. In detail, we discuss GNN-GMVO model, item graph construction, and model training and inference for similar item recommendation tasks. Specifically, we focus on introducing two variants of our model built on Graph Convolutional Networks (GCNs) and Graph Attention Networks (GATs), and call them GCN-GMVO and GAT-GMVO, respectively.
### _GCN-GMVO Model_
Let \(G=(V,E)\) denotes a graph where \(V\) and \(E\) represent the set of nodes and edges of the graph. Also, denote the embedding matrix of nodes by \(X\in\ \mathcal{R}^{d\times|\mathcal{V}|}\), where \(d\) is the dimension size of the embedding and \(|\mathcal{V}|\) is the number of nodes in the graph. The graphs represent the relations defined over different sets of entities (represented by nodes). An edge \(e\in E\) shows a connection between node \(u\) (\(u\in V\)) and node \(v\) (\(v\in V\)).
GNNs are a class of neural network models built on graph structure and use relations defined between the nodes. GNNs aggregate information from the graph's structure to create a deep representation for each node by using a form of message passing to transfer information between nodes to update each node's representation.
Graph Convolutional Networks (GCNs) are among the most popular GNN models. Under GCNs, message passing between nodes is done via Eq. (1):
\[h_{u}^{k}=\textit{ReLU}(W^{k}\sum_{v\in N(u)U_{\{u\}}}h_{v}^{k-1}/\sqrt{|N(u)|| N(v)|}), \tag{1}\]
where \(h_{u}^{k}\) shows hidden representation of node u after _kth_ message passing step, and \(W^{k}\) is a trainable matrix. \(N(u)\) and \(N(v)\) show the neighborhood nodes of \(u\) and \(v\), respectively. For each node, this function aggregates information from its neighborhood and combines it with the previous embedding of that node to update its representation. The input features of each node are used as initial hidden embedding \(h^{0}\) (i.e., \(h_{u}^{0}=X_{u}\)), and after \(K\) message passing steps, the final embeddings of nodes, \(z_{u}\), are created. In other words:
\[z_{u}=h_{u}^{K}\quad\forall u\in V. \tag{2}\]
GCN model operates as the encoder function by using the local graph structure around each node. The encoder maps nodes to an embedding space. A decoder function reconstructs the connections of the graph from the encoded node embeddings. In the similar item recommendation task, the decoder should perform as a predictor of the similarity between pairs of nodes in the graph. This is done by predicting whether two nodes are connected in the graph and reduces to the link prediction problem [33]. Under GCN, the encoder function takes the graph structure and the initial node features as the input, and generates the final embeddings of the nodes using Eq. (2). Then, a decoder function reconstructs the neighborhood structure for each node.
Under the GCN-GMVO framework for the similar item recommendation problem, we aim to optimize on item similarity relevance while inflating the weight of the edges with higher item prices. In other words, the decoder should identify similar items for a given anchor node (item) of interest, while boosting it according to the prices of respective items. To achieve this goal, we adjust the decoder function to make the final loss function more sensitive to links created among neighbors with higher prices. Because of this, the decoder function is modeled as Eq. (3):
\[DEC\left(z_{u},z_{v}\right)=(1+\lambda(p_{u}+p_{v}))(z_{u}^{T}z_{v}), \tag{3}\]
where \(p_{u}\) is the normalized price of item \(u\), and \(z_{u}^{T}z_{v}\) is the inner product between embeddings of nodes \(u\) and \(v\). Note that if \(z_{u}^{T}z_{v}\) is higher for a pair \((u,v)\), nodes \(u\) and \(v\) are more similar. Under Eq. (3), the inner product of the embeddings of two nodes \(u\) and \(v\) are inflated by the sum of normalized prices of both nodes \(u\) and \(v\). \(\lambda\) controls the trade-off between the importance of price and similarity. If \(\lambda=0\), the decoder function only focuses on the similarity between nodes \(u\) and \(v\). However, by increasing the value of \(\lambda\), the decoder considers more weight for the revenue generated by the corresponding nodes of the pairs.
Under GCN-GMVO, we frame the similar item recommendation problem as a link prediction problem. The link prediction is a classification problem where the positive label is assigned to a link between nodes \(u\) and \(v\) if an edge connects the nodes. Also, a negative link is assigned to pairs of nodes if no edge connects them in a graph structure. In order to train the model, we randomly sample a subset of positive edges and an equal number of negative edges from the training data. The sampling is done according to a uniform distribution. Then, to frame the problem as a link prediction problem, a binary cross-entropy loss (Eq. 4), is defined on the encoder-decoder structure:
\[\mathcal{L}= -\frac{1}{N}\sum_{(u,v)\in E}l(DEC(z_{u},z_{v}),A[u,v]) \tag{4}\] \[= -\frac{1}{N}\sum_{(u,v)\in E}y_{(u,v)}.\log\left(\sigma\left(DEC \left(z_{u},z_{v}\right)\right)\right)+\] \[= (1-y_{u_{n},v_{n}}).\log\left(1-\sigma\left(DEC\left(z_{u_{n}},z_ {v_{n}}\right)\right)\right).\]
In Eq. (4), \(\sigma\) denotes the sigmoid function, which maps the decoder to a probability score, and \(A\) is the binary adjacency matrix. In addition, \(u_{n}\) and \(v_{n}\) show the nodes for the negative samples from non-existing edges. The loss function measures the discrepancy between the decoded edge values and the true values.
### _GAT-GMVO Model_
The decoder function defined by Eq. (3) can be applied on other GNN architectures such as GAT (Graph Attention Network) [7] or GraphSAGE [34] to tailor these models toward optimizing revenue while decoding the edges. GAT has shown promising results by combining GNNs with attention mechanism [7]. The GAT model introduces attention weight into graphs, which is used to calculate the hidden representation of the nodes by attending over neighbor's influence during the aggregation step. Eq. (5) shows the hidden representation of node \(u\) in iteration \(k\) of message passing:
\[h_{u}^{k}=\sigma(\sum_{v\in N(u)}\alpha_{u,v}h_{v}^{k-1}), \tag{5}\]
\(\alpha_{u,v}\) shows the attention on neighbours of node \(u\) while aggregating its neighbour information during the message passing. \(\alpha_{u,v}\) can be calculated using Eq. (6):
\[\alpha_{u,v}=\frac{exp(a^{T}[Wh_{u}\oplus Wh_{v}])}{\sum_{v^{\prime}\in N(u)}exp( a^{T}[Wh_{u}\oplus Wh_{v^{\prime}}])}, \tag{6}\]
where \(a\) shows a trainable attention vector, \(W\) is a trainable matrix, and \(\oplus\) denotes the concatenation operation [33]. Other components of GAT-GMVO framework including the decoder and loss can be modeled similar to GCN-GMVO architecture proposed in section III-A. This change in the decoder function can make the GAT model more sensitive to highly priced neighbors.
### _Loss Function Variants_
Cross-entropy function is used to formulate the loss function for GNN-GMVO. However, other types of ranking functions such as pairwise max margin loss can also be utilized to optimize the encoder-decoder loss for GNN-GMVO architecture. Eq. (7) shows the max margin loss function for the link prediction problem.
\[L=\sum_{(u,v)\in E}max(0,-DEC(z_{u},z_{v})+DEC(z_{u_{n}},z_{v_{n}})+\Delta), \tag{7}\]
where \(\Delta\) is the margin for the difference between \(DEC(z_{u_{n}},z_{v_{n}})\) and \(DEC(z_{u},z_{v})\). This loss function helps the model to optimize the weights by minimizing the scores generated by non-existing edges and maximizing the scores generated by positive edges while considering the generated revenue. Since the decoder function takes into account the revenue optimization, the loss function considers lower loss value for the edges with higher price nodes.
### _Item Graph Construction, Model Training, and Model Inference_
Since item-item feature data in its raw format does not include edges among the items, we need to construct a graph for the training purpose to capture the similarity connections between items. To do this, we construct item features for all the nodes. This work uses a pre-trained model called Universal Sentence Encoder (\(USE\)) to extract initial node embeddings \(X\) (see [35] and [36]). This model creates a sentence embedding with dimensions of 512. We use the item name, item category, and other textual information of the item to generate text that is inputted to \(USE\) to generate the embeddings.
In order to detect edges of the graph, we need to define a metric that represents similarity relations between items, as there could be multiple types of relations such as complementarity, substitutability, and relevance among items of a given data in e-Commerce settings. The existence of multiple types of relations can create noise in detecting similar nodes to any given item, as users' click/purchase behavior (which is used to construct the graph) can be affected by these diverse relations among the items. Hence, we use co-view, view-bought, and co-purchase data as signals to define a new and custom metric to identify similarity relations and remove noise:
\[\begin{split} Sc(u,v)=&|cv(u,v)|+|vb(u,v)|+\\ &|vb(v,u)|-|cp(u,v)|\quad\forall u,v\in V,\end{split} \tag{8}\]
where \(|cv\left(u,v\right)\),\(|cp\left(u,v\right)|\) show the number of times items \(u\) and \(v\) are co-viewed and co-purchased together. \(|vb\left(u,v\right)|\) shows the number of times item \(u\) is viewed and then item \(v\) is purchased. We subtract \(|cp\left(u,v\right)|\) from co-view and view-then-bought to account for noise created by complementary items and only keep similarity relations between nodes. Note that complementary items, although bought or viewed together or after one another, are not similar. We use Eq. (9) to detect strong similarity relations while removing noise created by complementary items:
\[edge(u,v)=\begin{cases}1&\text{if }Sc(u,v)>\theta\\ 0&otherwise.\end{cases} \tag{9}\]
Eq. (9) assumes an edge between \(u\) and \(v\) if \(Sc(u,v)\) is larger than a threshold \(\theta\).
We randomly split the graph into training and test sets to train the model and evaluate its performance. The edges are partitioned between training and test sets. We use a two-hop message passing GCN and GAT models with an output embedding of 256 dimensions. In other words, Eq. (1) and Eq. (5) run for two iterations to encode the nodes into final node embeddings \(z_{u}\), \(\forall u\in\mathcal{V}\). Then given sampled negative and positive edges, the loss function (4) is obtained. After completion of training, the obtained model is used for inferencing and ranking.
To perform the model inference on a set of items, we consider all those items as nodes of the graph. We assume an edge between the nodes of a given pair if Eq. (8) holds for that pair. The inference graph is encoded as mentioned in subsections III-A and III-B using the trained model. See subsection III-F for the proposed approach of constructing the edges for cold or new items with zero or small number of views and transactions.
### _Ranking Task for Recommendation_
In this paper, we only focus on optimizing revenue and relevance via using the graph models. Therefore, in order to retrieve similar items, one can use a similarity measure between two items' final graph embeddings. After model inference and encoding nodes to embedding space, we apply a weighted similarity function to find the similarity score between nodes \(u\) and \(v\) using Eq. (10):
\[score\left(u,v\right)=\ (1+\lambda(p_{u}+p_{v}))\times(\frac{z_{u}^{T}z_{v}}{|z_ {u}||z_{v}|}). \tag{10}\]
Eq. (10) represents the weighted cosine similarity score between item \(u\) and item \(v\). When ranking recall set for an anchor item \(u\), the higher the price of item \(v\) (\(v\in\)_Candidate set for u_), the higher it will be ranked.
### _Edge Construction for Cold Items_
In a large-scale e-Commerce implementation of any recommendation module, new items with no user-interaction history are always added. In addition, some items may have low user traffic, and they may not be connected to any other graph nodes using a threshold-base rule like Eq. (8). The new and low-traffic (cold) items become isolated in the graph in these cases. Therefore, the node embeddings generated by the GNN-GMVO model will only use the weights of that node, and no message will be passed from the other nodes of the graph:
\[h_{u}^{k}=\textit{ReLU}(W^{k}h_{u}^{k-1}). \tag{11}\]
In these cases, one may ignore a threshold-based rule like Eq. (8) and add a connection from the node with the most similar initial embedding, \(h_{0}\), to the new/cold item. This case may alleviate the isolation problem of the new/cold items, connect them to the rest of the graph, and obtain better final embeddings. The items with the highest probability are more likely to be similar to each other:
\[S_{i}=\textit{argmax}(\frac{e^{X_{i}X_{j}}}{\sum_{j^{\prime}\in V}e^{X_{i}X_{j }^{\prime}}})\quad\forall j^{\prime}\in V. \tag{12}\]
\(S_{i}\) shows the most similar item to cold item \(i\). For graphs with millions of nodes, approximate nearest neighbour search algorithms such as [37] and [38] could be utilized to retrieve the most similar nodes. Figure 1 summarizes the architecture of the GNN-GMVO model and the steps explained in this section.
## IV Results
### _Results on Walmart dataset_
This section summarizes the conducted empirical experiments to validate the proposed modeling approach on real data instances. We compare the model with the currently deployed recommendation architecture in the similar item recommendation module of _Walmart.com_. We call this benchmark model which is a sophisticated Deep Learning model \(SIRB\) (Similar Item Recommendation Benchmark) in the rest of this paper. The similar item recommendation module of _Walmart.com_ is in the item pages of the platform and seeks to recommend alternative similar items to the main item of the page (See Figure 2).
We use Normalized Distributed Cumulative Gain (NDCG) to measure the ranking relevance. We also define a metric to measure the expected generated GMV by the models' suggested rankings (\(EGMV@K\)). To calculate \(EGMV@K\), after the model ranking, the first \(K\) items are determined for each anchor item. Then, we use the transaction data obtained for a month after model inferencing to approximate the ground truth. We calculate the portion of times each candidate item is being transacted and consider this as the probability of the purchase for each item. More specifically, \(EGMV@K\) is calculated as follows:
\[GMV@K=\sum_{k=1}^{K}\sum_{t=1}^{T}\frac{|Tr_{t,k}|}{\sum_{j\in c_{a}}|Tr_{t,j }|}P_{k}, \tag{13}\]
where \(|Tr_{t,k}|\) is the number of times candidate item \(k\) is purchased at time \(t\), \(\sum_{j\in c_{a}}|Tr_{t,j}|\) shows the total number of transactions for all candidate items under an anchor item \(a\), and \(P_{k}\) shows price for candidate item \(k\).
The data is proprietary and is selected from the Online Grocery category of items and includes about 100,000 items and 4 million links (as the edges of the graph) among those items. The graph edges are constructed using Eq. (9).
We conducted parameter tuning by training the model with different learning rates (0.001, 0.01, 0.1) and epoch sizes (10, 20, 50, and 100). We also tested the model performance using one, two, and three-hop message passing parameter. The op
Fig. 1: Proposed architecture for similar item recommendation (GNN-GMVO).
timal inference results are achieved using learning rate of 0.1 for the ADAM optimizer, the epoch size of 20 with two-hop message passing. PyTorch Geometric 2.2.0 is used for training and inference. Each epoch takes approximately 30 seconds to finish using a machine with 32GB memory and 10 CPU cores. We train our proposed model with different values of \(\lambda\) in Eq. (3) to find \(\lambda\) that maximizes the objective function. When inferencing, node embeddings are generated by loading the trained model and passing the inference graph as a dataset to encode nodes and generate graph embeddings. The inference dataset includes about 50,000 nodes. The candidate set for each anchor item is ranked based on the weighted cosine similarity of the recommended items and the given anchor item (i.e., Eq.(10)). The results are presented in Table 1. Most of the users at item pages of _Walmart.com_ view at most two sets of four items when checking similar item recommendations. This is why we report @8 metrics.
We conducted ablation study to show the importance of the proposed decoder function in optimizing the objective function. When \(\lambda=0\), the model is equivalent to a traditional GCN model without a GMV optimizer. As can be seen in Table I, using GCN model with custom edges defined in Eq. (8) increases NDCG metric by \(4.2\%\) w.r.t. the benchmark SIRB (when \(\lambda=0\)). By increasing \(\lambda\) in GCN-GMVO, the \(NDCG\) metric decreases for \(\lambda\geq 1\). This is expected since for larger values of \(\lambda\) the loss becomes more focused on optimizing the revenue. In addition, from Table I, we see that increasing \(\lambda\) up to 0.5 increases the \(EGMV@8\) metric, but larger \(\lambda\) has an inverse effect as it biases the loss too much so that items relevance (and ultimately \(EGMV@8\)) becomes small. Setting \(\lambda=0.1\) achieves both high \(NDCG\) and \(EGMV\) scores, which translates to increasing both relevance and expected GMV in our test sets. This proves the efficiency of our modeling framework in optimizing both recommendation relevance and revenue in large-scale e-Commerce settings.
Figure 3 shows the set of recommended items for a grocery anchor item by SIRB and GCN-GMVO. The results show that GCN-GMVO model recommends different set of items compared to the SIRB algorithm. The recommended items could potentially decrease the total number of sales if they are too expensive. However, since GNN-GMVO algorithm controls the trade-off between relevance and revenue, by optimizing the loss function we can improve \(EGMV\) generated by the recommendation set. As can be seen from Figure 2(b), the price of the recommendations for the anchor item are slightly more than the recommendations of SIRB (Figure 2(a)). However, the model shows some degree of price elasticity which results in \(EGMV\) boost without hurting \(NDCG\) metric. This is an example of how the proposed algorithm could positively impact the item recommendation task for large-Scale e-Commerce platforms.
features are used in this experiment. Some parts of the data set are missing. For instance, 65% of the products do not have price data. Because of this, we compute the price average and standard deviation to fill in missing values by sampling from the price distribution. The initial node representations are computed by inputting the item's textual information (including category, description, title, and brand) to the USE encoder [35, 36]. Since the frequency for the items co-view, view-bought, and co-purchase are missing in the dataset, we connect the product pairs in the graph if they are co-viewed even once. In other words, in order to build the graph, \(\theta\) in Eq. (9) is considered to be \(0\) for this experiment.
We train our proposed architecture with different values of \(\lambda\) in Eq. (3). The candidate set for each anchor item is based on the items that are viewed after the anchor item. We rank recall set based on the weighted cosine similarity of the recommended items and the given anchor items using Eq. (10). In order to evaluate the models, we measure and compare their performance on top-4 recommended items based on the total number of transactions for each item.
Traditional GCN and Graph Attention Networks (GAT) are considered as the benchmark models for this experiment. The cross-entropy loss function converges after around 20 epochs when training these models. The total run time with a 32GB memory is approximately 5 minutes. We used the same training configuration of the _Walmart.com_ dataset in this experiment. The results show improvement in GMV without impacting the NDCG scores of the recommendations for some cases of positive \(\lambda\)s. One of the goals of the proposed architecture is to improve revenue, consequently GMV, in the large-scale e-Commerce systems without recommending irrelevant items compared to the anchor item. Both of these goals are measured by comparing \(NDCG\) and \(EGMV\) of the recommendation sets.
As can be seen from Table II-Panel A, when \(\lambda=0\)\(EGMV@4\) and \(NDCG@4\) for GCN are 1.95 and 0.641, respectively. They are 1.94 and 0.644 for GAT model. Setting with \(\lambda=0.8\) generates \(EGMV@4=2.02\) for GCN-GMVO and \(EGMV@4=1.98\) for GAT-GMVO models which yields 3.6% and 1.6% improvements in \(EGMV@4\) w.r.t. GCN and GAT benchmark models. Using GCN and GAT architectures along with GMV optimizer as the decoder function can improve GMV metric without hurting the relevance of the recommendations. However, the results show that the GCN is performing slightly better than GAT model in optimizing revenue in this experiment.
#### Iv-B2 Video Games Category
This dataset contains 84,893 items from video game category. We used the same model con
\begin{table}
\begin{tabular}{||l l l||} \hline \(\lambda\) & GCN-GMVO (\(NDCG@8\), \(EGMV@8\)) & SIRB (\(NDCG@8\), \(EGMV@8\)) \\ \hline \hline
0 & (0.3041, 3.0253) & (0.2918, 2.8848) \\
0.05 & (0.3050, 3.0332) & - \\
0.1 & **(0.3060, 3.0372)** & - \\
0.5 & (0.3054, 3.0194) & - \\
1 & 2.2927, 2.8664) & - \\
2 & (0.2995, 2.9905) & - \\ \hline \end{tabular}
\end{table} TABLE I: NDCG and EGMV scores for GCN-GMVO and SIRB recommendation algorithms for _Walmart.com_ dataset.
Fig. 3: Comparison between items recommended by SIRB and GCN-GMVO
figuration and same set of features as the previous experiment to evaluate the model performance on a bigger item graph. We used the same pre-trained model (i.e., \(USE\)) to generate item text embedding using item categories, description, title, and brand features. Similar to the previous experiment, the results show that our architecture can improve \(EGMV\) generated by the recommendation system. We observe that the GAT model with GMVO component outperforms GCN model in optimizing the revenue.
The results (Table II-Panel B) show that the GAT-GMVO model has the highest \(EGMV\) when \(\lambda=0.05\). This shows that the optimal trade-off between relevance and revenue happen when we consider lower weights for the nodes' price. However, we see optimal \(EGMV\) for the GCN-GMVO model when \(\lambda=2\). As can be seen from the table, \(EGMV\) is improved by 1.3% for the GAT-GMVO. This improvement in the \(EGMV\) has no negative impact on the NDCG of the recommendations. We also see that \(EGMV\) is improved by 1.8% under GAT-GMVO model.
## V Conclusion
In this paper, we propose Graph Neural Network-Gross Merchandise Value Optimizer (GNN-GMVO) architecture to optimize GMV while considering complex item-item relations for similar item recommendation task. We develop a new decoder to adjust the generated loss function to become more sensitive to the price of the recommended items. We define a new edge construction framework in the item graph to identify similarity relations between items and remove noise caused by other types of relations in the item space. We propose a step-by step framework to (i) query input feature data, (ii) construct the graph, (iii) train the model, and (iv) use it for inference and ranking tasks. We conduct extensive experiments to train the model and find the optimal weights to trade off GMV and relevance. The results show that the proposed model improves the expected GMV on three real datasets without hurting the NDCG scores of the recommendations. This may prove the usefulness of the proposed approach in further optimizing the GMV in some industrial recommendation settings. In future work, one may add more features such as items' features (price, product type, product category, etc.) and image embedding data to the textual embedding data to enrich the initial embedding inputs of the model and test if this makes the modeling framework more robust. Finally, feeding generated node embeddings by GNN-GMVO architecture to other expert models like wide & deep(W&D) [41], prospectnet [20], DeepFM [42], and xDeepFM [43] can be tested and examine if this further optimizes the model.
|
2309.02248 | Encoding Seasonal Climate Predictions for Demand Forecasting with
Modular Neural Network | Current time-series forecasting problems use short-term weather attributes as
exogenous inputs. However, in specific time-series forecasting solutions (e.g.,
demand prediction in the supply chain), seasonal climate predictions are
crucial to improve its resilience. Representing mid to long-term seasonal
climate forecasts is challenging as seasonal climate predictions are uncertain,
and encoding spatio-temporal relationship of climate forecasts with demand is
complex.
We propose a novel modeling framework that efficiently encodes seasonal
climate predictions to provide robust and reliable time-series forecasting for
supply chain functions. The encoding framework enables effective learning of
latent representations -- be it uncertain seasonal climate prediction or other
time-series data (e.g., buyer patterns) -- via a modular neural network
architecture. Our extensive experiments indicate that learning such
representations to model seasonal climate forecast results in an error
reduction of approximately 13\% to 17\% across multiple real-world data sets
compared to existing demand forecasting methods. | Smit Marvaniya, Jitendra Singh, Nicolas Galichet, Fred Ochieng Otieno, Geeth De Mel, Kommy Weldemariam | 2023-09-05T13:58:59Z | http://arxiv.org/abs/2309.02248v1 | # Encoding Seasonal Climate Predictions for Demand Forecasting with Modular Neural Network
###### Abstract
Current time-series forecasting problems use short-term weather attributes as exogenous inputs. However, in specific time-series forecasting solutions (e.g., demand prediction in the supply chain), seasonal climate predictions are crucial to improve its resilience. Representing mid to long-term seasonal climate forecasts is challenging as seasonal climate predictions are uncertain, and encoding spatio-temporal relationship of climate forecasts with demand is complex. We propose a novel modeling framework that efficiently encodes seasonal climate predictions to provide robust and reliable time-series forecasting for supply chain functions. The encoding framework enables effective learning of latent representations--be it uncertain seasonal climate prediction or other time-series data (e.g., buyer patterns)--via a modular neural network architecture. Our extensive experiments indicate that learning such representations to model seasonal climate forecast results in an error reduction of approximately 13% to 17% across multiple real-world data sets compared to existing demand forecasting methods.
## Introduction
The significant disruption caused by climate variability--be it seasonal (e.g., warmer winters) or extreme events (e.g., heatwaves)--within a supply chain affects its resilience: from demand management to inventory planning [1], [2]. The literature on climate-aware forecasting has highlighted many impactful real-world applications: from creating option plans for pre-season planning [3], [4], energy and utility industries [5], [6], to the manufacturing industry [7].
Today, most retailers recognize the impact of weather in their demand forecast [8], [9] and use short-term weather forecasts (e.g., a week ahead) while predicting demand or employ de-weatherization techniques to understand weather-driven demand patterns [10]. In order to effectively perform demand management or inventory planning, decision-makers require accurate and reliable forecasting w.r.t. temporal and spatial coverage [8], [11]. This is especially critical when considering infusing seasonal-scale forecasting into decision-making workflow processes. In such situations, demand forecasting assesses the seasonal climate prediction [12] and uses them to predict demand for multiple steps in the future. However, climate-aware seasonal-scale demand forecasting is challenging for time-series machine learning since accurately encoding climate variability for demand forecasting is complex [13].
There are two key technical challenges in seasonal-scale climate-aware forecasting: (1) how to represent mid to long-term seasonal climate predictions with uncertainty, and (2) how to encode spatio-temporal relationship of climate forecasts with demand. Fig. 1 illustrates these challenges using a real-world scenario in which the goal is to predict the sales of a set of products across spatial domain using seasonal-scale climate predictions. While Figs. 1(a) and (b) highlight how product sales are spread across locations and times, the seasonal-scale climate predictions have implicit uncertainty with complex spatio-temporal dependency as shown in Fig. 1(c). Modern deep learning techniques can be adapted to address these challenges up to some extent, for example, by treating weather and climate forecasts as an added exogenous variable in the demand prediction stack [14], [15]. Based on our first-hand practical experiences in an industrial setting, due to the high degree of uncertainty embedded in climate prediction ensembles, simply considering such data as exogenous variables at the input layer makes demand predictions erroneous and unreliable for decision-making purposes. Therefore, we need robust models that account for local behaviour across spatial domains and uncertain seasonal-scale predictions.
In this paper, we present a novel modeling framework to address the challenge of encoding noisy seasonal-scale climate forecasts for demand prediction tasks. It features a compact representation of uncertain seasonal climate forecasts such that it
Figure 1: Dimensions of the spatio-temporal seasonal-scale climate-aware forecasting problem. (a) Geography, (b) Product sales across stores, and (c) Uncertain climate predictions.
helps, e.g., in enabling climate resilience in the supply chain by improving demand management, inventory planning, and so forth. As a first step, we extract a set of derived use case-inspired climate features that capture future seasonal climate conditions and the uncertainty associated with these forecasts. We then learn a set of temporal encoders to represent these uncertain climate forecasts with a compact latent representation that captures their uncertainties. We accomplish this by jointly learning a time-series forecasting model and a latent representation using a set of temporal encoders. We summarize our contributions as below:
* We design a modular neural network structure that accommodates different feature types, uncertainty associated with seasonal climate forecasts, and variable-length temporal window sizes based on the availability of the data (e.g. three months of temperature forecast at weekly frequency, one month of precipitation at daily frequency, and so forth).
* We propose a novel technique that learns the latent representations of uncertain seasonal climate forecasts, historical observations, and known inputs (e.g., holidays) for seasonal-scale climate-aware forecasting.
* We show the effectiveness of the climate-aware demand predictions using two different types of climate encoding techniques (Sec. and Sec. ) on real-world datasets from the supply chain domain: a public retail dataset and two large-scale retail industry datasets.
## Motivation and Related Work
Seasonal retail demand is affected by many factors: climate conditions (e.g., temperature, precipitation, humidity), promotional schemes, seasonal events, and so forth. In climate, a range of forecasts for each climate variable is produced by varying initial conditions of climate models that perform multiple simulations, making predictions uncertain. For example, seasonal-scale forecasts from The European Centre for Medium-Range Weather Forecasts (ECMWF) [16] contain 50 ensembles for each climate attribute up to six months in the future, which gets updated every month.
The complexity of climate data can be reduced by conceptualizing the data into trend and noise components [17]. However, modeling such climate data in time-series forecasting is challenging as latent representations need to deal with different types of noise present in seasonal-scale climate predictions. Several approaches have been considered in the past for time-series forecasting in the presence of noise. These approaches can be broadly classified into two categories: classical time-series forecasting and deep learning-based time-series forecasting.
**Classical Time-series Forecasting:** This consists of more classical approaches for modeling time series by including components for modeling level, trend and seasonality. Example of these classical approaches are support vector regression [18], ensemble models [19, 20, 21], exponential smoothing [22], and the Box-Jenkins family of ARIMA [23, 24, 22]. These perform the prediction by using a weighted linear sum of recent historical lags or observations. There are methods such as [25, 26] which
decompose time-series data into a seasonal, trend, and noise components and model them separately to improve forecast accuracy. However, these traditional approaches do not specifically investigate the latent representation learning of seasonal climate predictions for climate-aware forecasting, nor are they suitable for encoding ensemble data representing different levels of uncertainty.
**Deep Learning (DL) based Time-series Forecasting:** In the recent past, DL based approaches have dominated those traditional approaches by providing superiority in terms of modeling complex structures and interdependence between groups of series [27]. Recent works have focused on various deep neural networks such as Convolutional Neural Network (CNN) and Recurrent Neural Network (RNN) for multivariate time-series forecasting [28], [29], including temporal attention [30, 31, 32], dilated CNNs [33], [34], temporal CNNs [35, 36], multivariate attention LSTM-FCN [36, 37], and transformer models [38, 14, 39].
Lim et al. [14] proposed a sequence to sequence temporal fusion technique for representing historical data and known input into a latent space and combining them with static covariate encoders and variable selection networks to identify the relevant features for multi-horizon forecasting. In [30] a temporal attention technique is used to extract time-invariant temporal patterns using CNN for multivariate time-series forecasting. DeepAR [15] performs probabilistic forecasting by training an auto-regressive recurrent neural network model that incorporates negative binomial likelihood to deal with significant variation in time-series data. Ekambaram et al. [40] propose an attention-based multi-modal encoder-decoder model for retail time-series forecasting. In [41] a multifactor attention model is considered for capturing external factors such as short-term historical weather, social media trends, and so forth for predicting retail demand. However, none of these approaches provides a systematic way to model uncertainty associated (due to noise and spatio-temporal variability) with seasonal-scale climate predictions.
While some DL techniques (e.g., [14, 15]) and classical statistical methods (such as [18, 26]) can be repurposed to model seasonal-scale climate forecasts as added exogenous features in the demand prediction stack, we did not come across any work that focuses on learning latent representations based on these features with their associated uncertainties.
## Appendix A Framework for Climate-aware Forecasting
In this section, we describe the proposed framework for encoding multiple different types of geospatial-temporal data such as seasonal climate predictions, historical observation data, prediction of extreme events, etc. for demand forecasting. Our goal is to develop compact representations of uncertain seasonal climate predictions along with other data sources which may have different availability of the data such as three months of temperature forecast at daily frequency, one month of precipitation at weekly frequency, etc. and use them in time series forecasting. Fig. 2 (a) shows the high-level overview of the proposed framework that models various types of time-series data such as historical observations, seasonal climate predictions, non-climate exogenous data, etc. for climate-aware demand forecasting. A set of different temporal encoders are shown in Fig. 2 (b)
that learns the latent representation from each individual time-series data which may require varying model complexity levels.
The problem of seasonal-scale time-series forecasting is defined in terms of a cost function that minimizes the error in the multi-horizon forecasts at each _product_ (\(\mathrm{p_{m}}\)) and store combination. In this paper, _store_ (\(\mathrm{s_{n}}\)) designates any node in a supply chain; for instance, it can be a warehouse or distribution center. The model's forecast is given by:
\[\begin{split}\hat{\mathbf{y}}_{\mathrm{t+\tau}}(\mathrm{s_{n}}, \mathrm{p_{m}},\mathrm{t},\tau,q)=\\ \mathbf{f}^{\mathrm{pred}}(q,\mathbf{y}_{\mathrm{t-k:t}},\mathbf{ X}_{\mathrm{i,t-k:t}}^{\mathrm{o}},\mathbf{X}_{\mathrm{i,t-k:t+\tau}}^{\mathrm{k}}, \mathbf{X}_{\mathrm{i,t-k:t+\tau}}^{\mathrm{c}})\end{split} \tag{1}\]
where \(\mathbf{X}_{\mathrm{i}}^{\mathrm{o}}\) is a set of historical observations (e.g. sales data), \(\mathbf{X}_{\mathrm{i}}^{\mathrm{k}}\) is a set of known inputs (e.g. holidays), \(\mathbf{X}_{\mathrm{i}}^{\mathrm{c}}\) is a set of climate predictions (e.g., min, avg, max temperature), q is the quantile, and \(\hat{\mathbf{y}}_{\mathrm{t+\tau}}(\mathrm{s_{n}},\mathrm{p_{m}},\mathrm{t},\tau)\) is the prediction of \(\tau\)-step ahead forecast at time \(\mathrm{t}\).
Importantly, in Eq. 1, time series data for historical, known and climate data are treated differently. Historical data are only available up to time step \(\mathrm{t}\), but up to \(\mathrm{t+\tau}\) for known and climate forecast data. \(\mathbf{f}^{\mathrm{pred}}\) is a prediction model that includes a set of climate and non-climatic encoders for learning the latent representations. We introduce two such prediction models each associated with a specific latent representation for climatic and non-climatic time series. Next, we present these two prediction models: sub-neural network latent representation and a transformer-based latent representation.
Figure 2: (a) The overall diagram of the proposed climate-aware demand forecasting framework. (b) An example of different types of temporal encoders to deal with different types of input features.
### Latent representation learning using sub-neural networks (LRL-SNN)
We consider a set of time series defined by \(\mathbf{X}=[\mathbf{X}^{\mathrm{o}},\mathbf{X}^{\mathrm{c}},\mathbf{X}^{\mathrm{k}}]\) with \(\mathrm{o}\) being the time series of historical observations, \(\mathrm{c}\) the time series of climate predictions and \(\mathrm{k}\) the known time series. For \(l\in\{\mathrm{o},\mathrm{c},\mathrm{k}\}\), we denote \(\mathbf{I}^{\mathrm{l}}\) the index set such that \(\mathbf{X}^{\mathrm{l}}=\bigcup_{i\in I^{\mathrm{l}}}\mathbf{X}^{\mathrm{l}}_ {\mathrm{i}}\). Finally, we define for each \(l\in\{\mathrm{o},\mathrm{c},\mathrm{k}\}\), an offset \(\tau_{l}\in\mathbb{N}^{\star}\).
At time \(t\) and for label \(l\in\{\mathrm{o},\mathrm{c},\mathrm{k}\}\), we define for \(i\in\mathbf{I}^{\mathrm{l}}\) the window \(w^{l}_{i}(t)\) as:
\[\mathrm{w}^{l}_{i}(t)=(x^{l}_{i,1},x^{l}_{i,2},...,x^{l}_{i,t+\tau_{l}}) \tag{2}\]
with \(\mathbf{X}^{l}_{i}=\{x^{l}_{i,1},\ldots,x^{l}_{i,T}\}\)
For historical observations, climate and known data, \(\mathbf{I}^{\mathrm{l}}\) index a time series of interest--e.g., for historical time series, \(\mathbf{I}^{\mathrm{o}}\) = \(\{\mathbf{P}_{\mathrm{sales}}\), \(\mathbf{P}_{\mathrm{price}}\}\) represents the historical sales or product prices. For climate windows, \(i\) can be included in \(\mathbf{I}^{\mathrm{c}}=\{\mathbf{T}_{\mathrm{min}}\), \(\mathbf{T}_{\mathrm{avg}}\), \(\mathbf{T}_{\mathrm{max}}\), \(\sigma(\mathbf{T}_{\mathrm{min}})\), \(\sigma(\mathbf{T}_{\mathrm{avg}})\ldots\}\) with the times series representing minimum, average or maximum temperatures or their standard deviation respectively over a given ensemble climate time window. Finally, for known input, \(\mathbf{I}^{\mathrm{k}}\) can be \(\{\mathbf{W}_{\mathrm{nbr}},\mathbf{M}_{\mathrm{nbr}}\}\) and represents the week and month numbers, respectively.
We introduce Differencing and Normalizing layers to efficiently represent numerical features such as seasonal-scale temperature (min, max, avg) forecasts to enable transfer across time series. The Differencing layer captures relative trend within a time-series window, whereas the Normalizing layer helps transform each data point such that it window-normalized, so each input window is of comparable scale across multiple inputs. This way of transforming each time-series data helps in improving the learnability of the forecasting model such that it deals with weather variation across stores within geography. However, this step is optional for a certain type of time-series data that captures the uncertainty of the seasonal forecasts such as standard deviation of temperature min.
**Differencing Layer** For all time window \(\mathrm{w}=(x_{1},\ldots,x_{n})\), differenciated window \(\mathbf{w}_{\mathrm{diff}}\) is defined as \(\mathbf{w}_{\mathrm{diff}}=(x_{2}-x_{1},\ldots,x_{i}-x_{i-1},\ldots,x_{n}-x_{ n-1})\). The procedure can easily be inverted by saving \(x_{1}\).
**Normalizing Layer** For all time window \(\mathbf{w}=(x_{1},\ldots,x_{n})\), we denote \(\mu_{w}\) (resp. \(\sigma_{w}\)) its empirical average (resp. its empirical standard deviation, without Bessel's correction). The normalized window \(\mathbf{w}_{\mathrm{norm}}\) is defined \(\mathbf{w}_{\mathrm{norm}}=\{\frac{x_{1}-\mu_{w}}{\sigma_{w}},\ldots,\frac{x_ {i}-\mu_{w}}{\sigma_{w}},\ldots,\frac{x_{n}-\mu_{w}}{\sigma_{w}}\}\). Normalization can be inverted by transmitting \(\mu_{w}\) and \(\sigma_{w}\).
For all temporal data window \(\mathbf{w}(\mathrm{l},\mathrm{i},\tau_{l})\), we have the following successions, from time series data to prediction:
\[\forall l\in\{\mathrm{o},\mathrm{c},\mathrm{k}\},\forall i\in \mathbf{I}^{\mathrm{l}},\mathrm{d}(\mathrm{l},\mathrm{i},\tau_{l}) = \mathbf{w}_{\mathrm{diff}}(\mathbf{w}(\mathrm{l},\mathrm{i},\tau_{ l}))\] (3) \[\forall l\in\{\mathrm{o},\mathrm{c},\mathrm{k}\},\forall i\in \mathbf{I}^{\mathrm{l}},\mathbf{V}(\mathrm{l},\mathrm{i},\tau_{l}) = \mathbf{w}_{\mathrm{norm}}(\mathrm{d}(\mathrm{l},\mathrm{i},\tau_{ }))\] (4) \[\forall l\in\{\mathrm{o},\mathrm{c},\mathrm{k}\},\forall i\in \mathbf{I}^{\mathrm{l}},\mathbf{h}^{\mathrm{l}}_{\mathrm{i}} = \mathbf{TE}^{\mathrm{l}}_{\mathrm{i}}(\mathbf{V}(\mathrm{l},\mathrm{i },\tau_{l}))\] (5) \[\mathbf{H} = \underset{i\in\mathbf{I}^{\mathrm{o}}}{\overset{\mathrm{l}}{ \underset{i\in\mathbf{I}^{\mathrm{o}}}{\underset{i\in\mathbf{I}^{\mathrm{c}}}{ \underset{i\in\mathbf{I}^{\mathrm{c}}}{
with \(\rm{\mbox{$+\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!
for seasonal-scale forecasting. The variable section network and temporal attention mechanism help in modeling the noise present in seasonal-scale climate prediction. Compared to TFT, however, LRL-SNN dedicates a separate temporal encoder for each type of time series (historical, climate, and known). This adds a degree of flexibility in the design of the encoders (e.g., configuration of neural networks) such that it supports different feature types and uncertainty associated with them.
## Experiments
This section first demonstrates the effectiveness of seasonal-scale climate-aware demand forecast using a publicly available grocery retail dataset and two large-scale proprietary retail datasets. We then discuss the ablation study to evaluate the effectiveness of our proposed model. Below we provide a brief description of the datasets used.
**Favorita Grocery Retail Dataset (Ecuador)**: The Corporcion Favorita is a retail chain with stores located throughout Ecuador. This publicly available dataset consists primarily of grocery items and various (non-apparel) consumer goods such as automotive and household accessories [43]. Most of the dataset consists of perishable food items strongly affected by temperature (and humidity).
**Gear Apparel Retail Dataset (USA)**: The outdoor gear and apparel retail (Gear Apparel Retail) dataset consists of a chain of stores and distribution centers (DCs) distributed across the USA. Between 50% - 70% of the dataset contains apparel items with a strong seasonal dependence in the USA. Both the chain of stores and DCs also served as order fulfillment nodes for online purchases.
**Apparel Retail Dataset (India)**: The apparel retail dataset consists of daily sales data from a chain of stores distributed across India. Similar to the Gear Apparel Retail dataset, a sizeable portion of products are seasonal--i.e., over 30% of the products in the dataset consist of items that have demand cycles that have a substantial variance with seasonal changes in India.
Table 1 shows the different characteristics of the datasets such as geography, feature attributes, availability of data period, and so forth. In our experiments, the task is a time-series forecasting task and requires predicting future sales of a product for a given region/store weekly. We use features that are aggregated at a week level while forecasting
\begin{table}
\begin{tabular}{|l|c|c|c|} \cline{2-4} \multicolumn{1}{c|}{} & **Gear Apparel Retail** & **Apparel Retail** & **Favorita Grocery Retail** \\ \hline
**Target** & Unit Sales & Unit Sales & \(\log\)( Unit Sales ) \\ \hline
**Geography** & USA & India & Ecuador \\ \hline
**\#Features** & 6 & 14 & 23 \\ \hline
**\#Unique Time-series** & 180 & 594 & 645 \\ \hline
**\#Train Samples** & \(\sim\)18k & \(\sim\)52k & \(\sim\)79k \\ \hline
**\#Dev Samples** & \(\sim\)4.5k & \(\sim\)12k & \(\sim\)19k \\ \hline
**\#Test Samples** & \(\sim\)14k & \(\sim\)42k & \(\sim\)61k \\ \hline
**Temperature max (\(\lx@math@degree C\))** & \(\mu=18.4\), \(\sigma=8.3\) & \(\mu=33.4\), \(\sigma=8.2\) & \(\mu=21.0\), \(\sigma=5.3\) \\ \hline
**Temperature avg (\(\lx@math@degree C\))** & \(\mu=13.7\), \(\sigma=7.7\) & \(\mu=27.8\), \(\sigma=7.6\) & \(\mu=17.8\), \(\sigma=5.9\) \\ \hline
**Temperature min (\(\lx@math@degree C\))** & \(\mu=8.8\), \(\sigma=7.5\) & \(\mu=22.3\), \(\sigma=7.6\) & \(\mu=14.6\), \(\sigma=6.6\) \\ \hline
**Time Period** & Sept-2016 to April-2020 & Jan-2017 to May-2020 & Jan-2014 to Aug-2017 \\ \hline \end{tabular}
\end{table}
Table 1: Characteristics of large-scale retail datasets.
demand for 12 weeks. In our experiments, we use seasonal climate predictions from ECMWF S5 seasonal forecast system that contains 50 ensembles for each climate attribute such as temperature (min, max, avg.) and precipitation up to six months in the future [16].
The results are reported in terms of average mean absolute percentage error (MAPE), and average root mean squared error (RMSE). Results are generated on 12-week prediction intervals. The error metrics are computed at a finer granularity of 4 weeks and on the whole 12-week prediction intervals. Decomposing the error analysis helps with understanding the influence of the seasonal-scale climate predictions. While reporting comparative results for these three datasets, we show experiments with (1) latent representation learning using sub-neural networks (LRL-SNN), and (2) Temporal Fusion Transformer [14] with and without climate predictions.
**Experimental Settings:** Table 2 shows model parameters and algorithm settings for TFT and LRL-SNN used in our experiments. As mentioned above, ECMWF provides, for each location, 50 measures: temperatures (min, max, and average) and precipitation. For each of these ensembles, we extract a set of derived features such as mean and standard deviation to represent the uncertainty. For LRL-SNN, the last layers of the climate encoders for mean (\(\mu_{d}\)) and standard deviation (\(\sigma_{d}\)) differ depending on the dataset. For Favorita, the values of \(\mu_{d}\) are [32, 16, 16, 16] for \(\mathbf{T}_{\mathrm{avg}}\), \(\mathbf{T}_{\mathrm{min}}\), \(\mathbf{T}_{\mathrm{max}}\) and \(\mathbf{P}_{\mathrm{avg}}\) (precipitation) respectively. Values of \(\sigma_{d}\) are [16, 8, 8, 8] for \(\sigma(\mathbf{T}_{\mathrm{avg}})\), \(\sigma(\mathbf{T}_{\mathrm{min}})\), \(\sigma(\mathbf{T}_{\mathrm{max}})\) and \(\sigma(\mathbf{P}_{\mathrm{avg}})\). Similarly, for Apparel Retail dataset, values of \(\mu_{d}\) are [32, 16, 16] for \(\mathbf{T}_{\mathrm{avg}}\), \(\mathbf{T}_{\mathrm{min}}\), \(\mathbf{T}_{\mathrm{max}}\) and \(\sigma_{d}\) are [16, 8, 8] for \(\sigma(\mathbf{T}_{\mathrm{avg}})\), \(\sigma(\mathbf{T}_{\mathrm{min}})\), \(\sigma(\mathbf{T}_{\mathrm{max}})\). Finally, for Agar Apparel retail dataset, values of \(\mu_{d}\) are [250, 100, 100] for \(\mathbf{T}_{\mathrm{avg}}\), \(\mathbf{T}_{\mathrm{min}}\), \(\mathbf{T}_{\mathrm{max}}\).
### Favorita Grocery Retail Dataset
We evaluate our models and compare them against one of the state-of-the-art approaches--Temporal Fusion Transformer (TFT) [14]. The comparative results are reported in Table 3. We use log-transformed of sales quantity (cf. Table 1) as a target variable similar to [14]. Irrespective of the models, we see a substantial improvement when we incorporate seasonal climate predictions for retail demand forecasting. We show overall error reduction of 12.85% and 6.47% in MAPE for (LRL-SNN + Climate) and (TFT + Climate) over the non-climate models respectively. Furthermore, compared to TFT, our
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c|} \hline \multirow{2}{*}{**Parameters**} & \multicolumn{2}{c|}{**Favorita Grocery Retail**} & \multicolumn{2}{c|}{**Apparel Retail**} & \multicolumn{2}{c|}{**Gear Apparel Retail**} \\ \cline{2-7} & **TFT** & **LRL-SNN** & **TFT** & **LRL-SNN** & **TFT** & **LRL-SNN** \\ \hline \hline
**Dropout Rate** & 0.1 & 0.2 & 0.1 & 0.2 & 0.1 & 0.2 \\ \hline
**Concatenated FFN** & [240] & [200, 1000] & [160] & [2000, 1000] & [160] & [2000, 1000] \\
**TSFN** & - & [2000, 1000, 240] & - & [2000, 1000, 200] & - & [5000, 2500, 1000, 500] \\
**Climate Encoder (mean)** & - & [512, 256, 128, 64, X] & - & [512, 256, 128, 64, X] & - & [5000, 2500, 1000, X] \\
**Climate Encoder (std)** & - & [512, 256, 128, 64, Y] & - & [512, 256, 128, 64, Y] & - & - \\ \hline
**Millbatch Size** & 128 & 32 & 64 & 16 & 64 & 16 \\ \hline
**Learning Rate** & 0.001 & 0.001 & 0.001 & 0.001 & 0.001 & 0.01 \\ \hline
**Window size (\(k\))** & 12 & 12 & 12 & 12 & 12 & 12 \\ \hline
**Prediction interval (\(\tau\))** & 12 & 12 & 12 & 12 & 12 & 12 \\ \hline
**Number of epochs** & 100 & 100 & 100 & 100 & 100 & 100 \\ \hline \end{tabular}
\end{table}
Table 2: Model Configuration Parameters. X and Y denote the last layer size of Temporal Encoders
proposed approach (LRL-SNN + Climate) provides a significant improvement over both the error metrics such as averaged RMSE and averaged MAPE. We can infer from these experimental results that learning a set of temporal encoders based on the levels of data difficulty can consistently outperform transformer-based climate encoding architectures such as TFT.
### Large-scale Industry Datasets (India and USA)
We next evaluate our approach of seasonal-scale climate encoding using temporal encoders by performing a set of experiments on first-of-its-kind large-scale retail industry datasets--i.e., Apparel Retail and Gear Apparel Retail datasets from India and USA, respectively. These datasets have a wide range of retail stores distributed across the geographies with high spatio-temporal climate variability.
#### Apparel Retail Dataset (India)
The Apparel Retail dataset contains mostly retail products such as jacket, sweater, jeans, and so forth across multiple cities in India. Table 4 compares climate-aware demand forecasting error metrics with those of TFT. As can be seen, incorporating climate forecasts as a part of latent representation improves the results significantly for both the error metrics and for TFT and LRL-SNN. Results for LRL-SNN remain competitive, and the use of climate brings the errors lower than the level achieved by TFT. Moreover, the TFT architecture appears to be able to model spatio-temporal climate variability better with the help of LSTM-based encoder-decoder architecture and temporal attention mechanism; such a foreknowledge can especially be helpful in contexts (e.g., India) where the wide variability in time and space occur.
The Gear Apparel Retail dataset includes a large portion of items used for seasonal outdoor sports (e.g., winter jackets and ruggedized bottles for hiking) which are sold across the United States of America (including Alaska). As such, there are significant climate variability from region to region. The goal is to determine if encoded forecast
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c||c|c|} \hline \multirow{2}{*}{**Algorithms**} & \multicolumn{2}{c|}{**week 1-4**} & \multicolumn{2}{c|}{**week 5-8**} & \multicolumn{2}{c||}{**week 9-12**} & \multicolumn{2}{c|}{**Overall**} \\ \cline{2-9} & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** \\ \hline \hline
**TFT** & 18.40 & 1.44 & 21.93 & 4.39 & 24.36 & 6.57 & 23.82 & 4.01 \\ \hline
**TFT + Climate** & **17.00** & 1.29 & **20.07** & **4.05** & **22.24** & **6.04** & **21.70** & **3.69** \\ \hline
**LRL-SNN** & 20.28 & 1.26 & 31.55 & 4.56 & 39.17 & 8.37 & 33.17 & 4.58 \\ \hline
**LRL-SNN + Climate** & 17.15 & **1.11** & 25.37 & 4.09 & 30.87 & 6.66 & 26.62 & 3.83 \\ \hline \end{tabular}
\end{table}
Table 4: Results on large-scale retail industry dataset - Apparel Retail.
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c||c|c|} \hline \multirow{2}{*}{**Algorithms**} & \multicolumn{2}{c|}{**week 1-4**} & \multicolumn{2}{c|}{**week 5-8**} & \multicolumn{2}{c||}{**week 9-12**} & \multicolumn{2}{c|}{**Overall**} \\ \cline{2-9} & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** \\ \hline \hline
**TFT** & 0.98 & 0.35 & 1.03 & 0.18 & 0.89 & 0.17 & 1.07 & 0.25 \\ \hline
**TFT + Climate** & 0.87 & 0.32 & 0.92 & **0.17** & **0.74** & **0.16** & 0.93 & 0.23 \\ \hline
**LRL-SNN** & 0.70 & 0.22 & 0.91 & 0.19 & 0.89 & 0.21 & 0.89 & 0.22 \\ \hline
**LRL-SNN + Climate** & **0.64** & **0.19** & **0.87** & **0.17** & 0.85 & 0.18 & **0.85** & **0.19** \\ \hline \end{tabular}
\end{table}
Table 3: Results of the proposed approach on Grocery retail dataset - Favorita.
data in demand models are able to capture the impacts that climate has on sales-impacts like early winters, a late summer, or an extended autumn period. Tables 5, 6 and 7 show the comparative error metrics for distribution centers (DC), stores and both combined respectively across all of the regions in the USA. Overall, climate-aware models such as TFT + Climate and LRL-SNN + Climate tend to have lower errors than climate-agnostic models across DCs and stores. Climate-encoding using LRL-SNN shows significant improvements compared to TFT and TFT + Climate for store-level retail demand forecasting. Whereas TFT + Climate outperforms as compared to other models for DCs.
### Ablation Study
In any climate-aware demand forecasting, we believe that efficiently encoding seasonal climate prediction can further reduce errors. In Table 8, we show that adding seasonal climate predictions in TFT [14] and LRL-SNN helps in reducing, on average, MAPE by about 17% to 21% and RMSE by about 8% and 14%. One can note that Mean Absolute Error (MAE) for Gear Apparel Retail (Store and Combined) has a negative percentage reduction for TFT + Climate. However, this is expected as gear apparel sales are affected by seasonality, and MAE is significantly affected by low numbers. Thus, in this context, RMSE would be the appropriate error metric. This observation evidenced across three geographically distinct datasets attest that explicitly encoding forecasted seasonal climate leads to improved predictions for regional store purchases.
Furthermore, we compare quantitative and qualitative metrics on the Favorita dataset to show the effectiveness of climate-aware forecasting. Fig. 4(a) compares the quantitative errors product-category wise obtained by our framework, with those of [14]
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c||c|c|} \hline \multirow{2}{*}{**Algorithms**} & \multicolumn{2}{c|}{**week 1-4**} & \multicolumn{2}{c|}{**week 5-8**} & \multicolumn{2}{c||}{**week 9-12**} & \multicolumn{2}{c|}{**Overall**} \\ \cline{2-9} & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** \\ \hline \hline
**TFT** & 6.51 & 1.09 & 7.77 & 1.49 & 8.68 & 1.91 & 9.10 & 1.48 \\ \hline
**TFT + Climate** & 6.99 & 1.02 & 7.36 & 1.19 & **7.48** & **1.30** & 7.93 & 1.16 \\ \hline
**LRL-SNN** & **5.41** & **0.68** & **6.95** & 1.06 & 8.07 & 1.43 & 7.63 & 1.04 \\ \hline
**LRL-SNN + Climate** & 5.55 & **0.68** & 6.97 & **1.02** & 7.86 & 1.34 & **7.61** & **1.00** \\ \hline \end{tabular}
\end{table}
Table 6: Results on Gear Apparel Retail dataset for Stores.
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c||c|c|} \hline \multirow{2}{*}{**Algorithms**} & \multicolumn{2}{c|}{**week 1-4**} & \multicolumn{2}{c|}{**week 5-8**} & \multicolumn{2}{c||}{**week 9-12**} & \multicolumn{2}{c|}{**Overall**} \\ \cline{2-9} & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** \\ \hline \hline
**TFT** & 15.39 & 1.13 & 16.02 & 1.55 & 16.80 & 2.01 & 20.89 & 1.55 \\ \hline
**TFT + Climate** & 15.28 & 1.02 & **15.38** & 1.23 & **15.63** & **1.37** & **19.50** & 1.20 \\ \hline
**LRL-SNN** & 14.58 & 0.78 & 17.88 & 1.59 & 19.93 & 2.22 & 21.62 & 1.50 \\ \hline
**LRL-SNN + Climate** & **14.71** & **0.76** & 16.51 & **1.20** & 17.75 & 1.62 & 20.68 & **1.18** \\ \hline \end{tabular}
\end{table}
Table 7: Results on Gear Apparel Retail dataset for stores and DCs both combined.
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c||c|c|} \hline \multirow{2}{*}{**Algorithms**} & \multicolumn{2}{c|}{**week 1-4**} & \multicolumn{2}{c|}{**week 5-8**} & \multicolumn{2}{c||}{**week 9-12**} & \multicolumn{2}{c|}{**Overall**} \\ \cline{2-9} & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** & **RMSE** & **MAPE** \\ \hline \hline
**TFT** & 94.19 & 1.43 & 89.20 & 2.12 & 88.87 & 2.89 & 125.56 & 2.12 \\ \hline
**TFT + Climate** & **88.88** & **1.05** & **86.52** & **1.59** & **87.94** & **2.01** & **122.12** & **1.52** \\ \hline
**LRL-SNN** & 95.91 & 1.63 & 114.82 & 6.32 & 125.12 & 9.30 & 145.71 & 5.62 \\ \hline
**LRL-SNN + Climate** & 95.94 & 1.52 & 101.14 & 2.79 & 105.53 & 4.11 & 136.63 & 2.74 \\ \hline \end{tabular}
\end{table}
Table 5: Results on Gear Apparel Retail dataset for DCs.
whereas Fig. 4 qualitatively compares the product-category wise effectiveness of climate-aware forecasting with seasonal climate prediction as compared to non-climate model using LRL-SNN. The qualitative metric measures the percentage of scenarios (i.e., product and region combinations) in which the climate-aware model performs better or equal to the climate-agnostic one. We label _Tie_ to show that the climate-aware model outperforms for one error metric but not the other.
## Conclusion
Demand forecasting is a well-studied problem in the time-series domain. In climate-aware demand forecasting scenarios, existing methods do not consider the seasonal climate predictions due to the complexities such as noise, time-series data with different temporal frequencies, and spatio-temporal correlations associated with the climate predictions. In this work, we addressed the problem of seasonal climate-aware demand forecasting by effectively learning joint latent representations of climate predictions, historical observations (e.g., sales figures), and known inputs (e.g., holidays) using a sub-neural network architecture. This way of modeling different types of time-series
Figure 4: (a) Comparative quantitative evaluation (MAPE) on Favorita dataset. (b) Qualitative analysis using LRL-SSN (refer to Sec. ) for details.
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c|} \hline \multirow{2}{*}{**Datasets**} & \multicolumn{2}{c|}{**LRL-SNN + Climate**} & \multicolumn{2}{c|}{**TFT + Climate**} \\ \cline{2-7} & **MAPE** & **RMSE** & **MAE** & **MAPE** & **RMSE** & **MAE** \\ \hline \hline
**Grocery Retail - Favorita** & 12.85 & 4.71 & 7.04 & 6.47 & 13.34 & 12.00 \\ \hline
**Apparel Retail** & 16.54 & 19.76 & 20.01 & 8.07 & 8.91 & 9.01 \\ \hline
**Gear Apparel Retail - Store** & 4.03 & 0.24 & 0.33 & 21.5 & 12.81 & -3.5 \\ \hline
**Gear Apparel Retail - DC** & 51.14 & 6.23 & 12.97 & 28.14 & 2.74 & 1.91 \\ \hline
**Gear Apparel Retail - Combined** & 21.86 & 4.33 & 8.25 & 22.42 & 6.68 & -0.57 \\ \hline \end{tabular}
\end{table}
Table 8: Comparative error reduction (%) using climate-aware models.
data and learning joint latent representation enables a higher degree of flexibility in climate-aware demand prediction tasks. The extensive experiments we have performed indicate that the latent representation of seasonal climate predictions leads to enhanced demand forecasting, thus paving the way for improvement in pre-season planning and demand management for supply chain functions.
Given that we have only considered seasonal climate predictions in our current work, we aim to enrich relevant data sources for predictions in our future work; such sources will include incorporating high-impact lag and derived climate forecast features. Moreover, we will design methods to propagate uncertainty from ensemble forecasts to demand predictions and quantify the associated uncertainty at various granularities.
|
2303.06920 | Pixel-wise Gradient Uncertainty for Convolutional Neural Networks
applied to Out-of-Distribution Segmentation | In recent years, deep neural networks have defined the state-of-the-art in
semantic segmentation where their predictions are constrained to a predefined
set of semantic classes. They are to be deployed in applications such as
automated driving, although their categorically confined expressive power runs
contrary to such open world scenarios. Thus, the detection and segmentation of
objects from outside their predefined semantic space, i.e., out-of-distribution
(OoD) objects, is of highest interest. Since uncertainty estimation methods
like softmax entropy or Bayesian models are sensitive to erroneous predictions,
these methods are a natural baseline for OoD detection. Here, we present a
method for obtaining uncertainty scores from pixel-wise loss gradients which
can be computed efficiently during inference. Our approach is simple to
implement for a large class of models, does not require any additional training
or auxiliary data and can be readily used on pre-trained segmentation models.
Our experiments show the ability of our method to identify wrong pixel
classifications and to estimate prediction quality at negligible computational
overhead. In particular, we observe superior performance in terms of OoD
segmentation to comparable baselines on the SegmentMeIfYouCan benchmark,
clearly outperforming other methods. | Kira Maag, Tobias Riedlinger | 2023-03-13T08:37:59Z | http://arxiv.org/abs/2303.06920v2 | Pixel-wise Gradient Uncertainty for Convolutional Neural Networks applied to Out-of-Distribution Segmentation
###### Abstract
In recent years, deep neural networks have defined the state-of-the-art in semantic segmentation where their predictions are constrained to a predefined set of semantic classes. They are to be deployed in applications such as automated driving, although their categorically confined expressive power runs contrary to such open world scenarios. Thus, the detection and segmentation of objects from outside their predefined semantic space, i.e., out-of-distribution (OoD) objects, is of highest interest. Since uncertainty estimation methods like softmax entropy or Bayesian models are sensitive to erroneous predictions, these methods are a natural baseline for OoD detection. Here, we present a method for obtaining uncertainty scores from pixel-wise loss gradients which can be computed efficiently during inference. Our approach is simple to implement for a large class of models, does not require any additional training or auxiliary data and can be readily used on pre-trained segmentation models. Our experiments show the ability of our method to identify wrong pixel classifications and to estimate prediction quality. In particular, we observe superior performance in terms of OoD segmentation to comparable baselines on the SegmentMelfYouCan benchmark, clearly outperforming methods which are similarly flexible to implement.
+
Footnote †: * equal contribution
## 1 Introduction
Semantic segmentation decomposes the pixels of an input image into segments which are assigned to a fixed and pre-defined set of semantic classes. In recent years, deep neural networks (DNNs) have performed excellently in this task (Chen et al., 2018; Wang et al., 2021), providing comprehensive and precise information about the given scene. However, in safety relevant applications like automated driving where semantic segmentation is used in open world scenarios, DNNs often fail to function properly on unseen objects for which the network has not been trained, see for example the bobby car in Figure 1 (top). These objects from outside the network's semantic space are called of out-of-distribution (OoD) objects. It is of highest interest that the DNN identifies these objects and abstains from deciding on the semantic class for those pixels covered by the OoD object. Another case are OoD objects which might belong to a known class, however, appearing differently to substantial significance from other objects of the same class seen during training. Consequently, the respective predictions are prone to error. For these objects, as for classical OoD objects, marking them as OoD is preferable to the likely case of misclassification which may happen with high confidence. Furthermore, this additional classification task should not substantially degrade the semantic segmentation performance itself outside the OoD region. The computer
Figure 1: _Top_: Semantic segmentation by a state-of-the-art deep neural network. _Bottom_: Gradient uncertainty heatmap obtained by our method.
vision tasks of identifying and segmenting those objects is captured by the notion of OoD segmentation [3, 14].
The recent contributions to the emerging field of OoD segmentation are mostly focused on OoD training, i.e., the incorporation of additional training data (not necessarily from the real world), sometimes obtained by large reconstruction models [1, 13]. Another line of research is the use of uncertainty quantification methods such as Bayesian models [15] or maximum softmax probability [16]. Gradient-based uncertainties are considered for OoD detection in the classification task by Oberdiek et al. [17], Huang et al. [20] and Lee et al. [21] and up to now, have not been applied to OoD segmentation. Grathwohl et al. [20] show that gradient norms perform well in discriminating between in- and out-of-distribution. Moreover, gradient-based features are studied by Riedlinger et al. [2] for object detection to estimate the prediction quality. Hornauer and Belagiannis [2] investigate loss gradients w.r.t. feature activations in monocular depth estimation and show correlations of gradient magnitude with depth estimation accuracy.
In this work, we introduce a new method for uncertainty quantification in semantic segmentation and OoD segmentation based on gradient information. Magnitude features of gradients can be computed at inference time and provide information about the uncertainty propagated in the corresponding forward pass. These features represent pixel-wise uncertainty scores applicable to prediction quality estimation and OoD segmentation. An exemplary gradient uncertainty heatmap can be found in Figure 1 (bottom). Such uncertainty scores have shown improved performance for the quality estimation task in image classification compared to uncertainties contained in the softmax output of DNNs [1]. In addition, instance-wise gradient uncertainty outperforms sampling methods like Monte-Carlo (MC) Dropout [10] and Ensembles [1] in object detection [11]. Calculating gradient uncertainty scores does not require any re-training of the DNN or computationally expensive sampling. Instead, only one backpropagation step for the gradients with respect to the final convolutional network layer is performed per inference to produce gradient scores. Note, that more than one backpropagation step can be performed if deeper gradients need to be computed and other parameters of the model are considered. An overview of our approach is shown in Figure 2.
An application to dense predictions such as semantic segmentation has escaped previous research. Single backpropagation steps per pixel on high-resolution input images quickly become infeasible given that \(10^{6}\) gradients have to be calculated. To overcome this issue, we present a new approach to exactly compute the pixel-wise gradient scores in a batched and parallel manner applicable to a large class of segmentation architectures. We use these gradient scores to estimate the model uncertainty on pixel-level and also the prediction quality on segment-level. Segments are connected components of pixels belonging to the same class predicted by the semantic segmentation network. Finally, the gradient uncertainty heatmaps are investigated for OoD segmentation where high uncertainties indicate possible OoD objects.
We only assume a pre-trained semantic segmentation network as our method is applicable to a wide range of architectures. In our tests, we employ a state-of-the-art segmentation network [3] trained on Cityscapes [15] evaluating in-distribution uncertainty estimation and on four OoD segmentation datasets, namely LostAndFound [13], Fishyscapes [1], RoadAnomaly21 and RoadObstacle21 [2], demonstrating OoD detection performance. The source code of our method is publicly available at [https://github.com/tobiasriedlinger/uncertainty-gradients-seg](https://github.com/tobiasriedlinger/uncertainty-gradients-seg). Our contributions are summarized as follows:
* We introduce a new method for uncertainty quantification in semantic segmentation. Our gradient-based approach is applicable to a wide range of segmentation architectures.
* For the first time, we show an efficient way of computing gradients in semantic segmentation on the pixel-level in a parallel manner making our method less computationally expensive than sampling-based methods.
* For the first time, we demonstrate the robustness of gradient-based uncertainty quantification with respect to predictive error detection and OoD segmentation. For the OoD segmentation task, we achieve area under precision-recall curve values of up to \(69.3\%\) on the LostAndFound benchmark outperforming a variety of methods that have substantially larger requirements.
The paper is structured as follows. We discuss the related work on uncertainty quantification and OoD segmentation in section 2. In section 3, we introduce our method of computing pixel-wise gradient uncertainty scores. Numerical results are shown in section 4, followed by concluding remarks in section 5.
## 2 Related Work
### Uncertainty Quantification
Bayesian approaches [12] are widely used to estimate model uncertainty. The well-known approximation, MC Dropout [10], has proven to be practically efficient in uncertainty estimation and is also
applied to semantic segmentation [11]. In addition, this method is considered to filter out predictions with low reliability [20]. Blum et al. [19] benchmarked pixel-wise uncertainty estimation methods based on Bayesian models or the network's softmax output. Hoebel et al. [20] extracted uncertainty information on pixel-level by using the maximum softmax probability and MC Dropout. Prediction quality evaluation approaches are introduced by DeVries and Taylor [21] and Huang et al. [2016] working on single objects per image. These methods are based on additional CNNs acting as post-processing mechanism. Rottmann et al. [20] present the concepts of meta classification (false positive detection) and meta regression (performance estimation) on segment-level using features as input extracted from the segmentation network's softmax output. This line of research has been extended by a temporal component [14] and transferred to object detection [15, 16] as well as to instance segmentation [14, 17].
While MC Dropout as a sampling approach is computationally expensive to create pixel-wise uncertainties, our method computes only the gradients of the last layer during a single inference run and can be applied to a wide range of semantic segmentation networks without architectural changes. Compared with the work by Rottmann et al. [20], our gradient information can extend the features extracted from the segmentation network's softmax output to enhance the segment-wise quality estimation.
### OOD Segmentation
Uncertainty quantification methods demonstrate high uncertainty for erroneous predictions, so they can intuitively serve for OOD detection as well. For instance, this can be accomplished via maximum softmax (probability) [10], MC Dropout [13] or ensembles [12] which capture model uncertainty by averaging predictions over multiple sets of parameters. Another line of research is OOD detection training, relying on the exploitation of additional training data, not necessarily from the real world, but disjoint from the original training data [1, 14, 15, 16, 17, 18]. In this regard, an external reconstruction model followed by a discrepancy network are considered by Biase et al. [20], Lis et al. [20] and Vojir et al. [20] and normalizing flows are leveraged by Blum et al. [19] and Grcic et al. [20]. Liang et al. [2018] as well as Lee et al. [2018] perform small adversarial perturbations on the input images to improve the separation of in- and out-of-distribution samples.
Specialized training approaches for OOD detection are based on different kinds of re-training with additional data and often require generative models. Meanwhile, our method does not require OOD data, re-training or complex auxiliary models. Moreover, we do not run a full backward pass as is required for the computation of adversarial samples. In fact we found that it is often sufficient to only compute the gradients of the last convolutional layer. Our method is more related to classical uncertainty quantification approaches like maximum softmax, MC Dropout and ensembles. Note that the latter two are based on sampling and thus, much more computationally expensive compared to single inference.
## 3 Method Description
In the following, we consider a neural network with parameters \(\theta\) yielding classification probabilities
\[\hat{\pi}(x,\theta)=(\hat{\pi}_{1},\dots,\hat{\pi}_{C}) \tag{1}\]
over \(C\) semantic categories when presented with input \(x\). During training on paired data \((x,y)\) where \(y\in\{1,\dots,C\}\) is the semantic label given to \(x\), such a model is commonly trained by minimizing some kind of loss function \(\mathcal{L}\) between \(y\) and the predicted probability distribution \(\hat{\pi}(x,\theta)\) using gradient descent on \(\theta\). The gradient step \(\nabla_{\theta}\mathcal{L}(\hat{\pi}(x,\theta)\|y)\) then indicates the direction and strength of training feedback obtained by \((x,y)\). Asymptotically (in the amount of data and training steps taken), the expectation
\[\mathbb{E}_{(X,Y)\sim P}[\nabla_{\theta}\mathcal{L}(\hat{\pi}(X,\theta)\|Y)] \tag{2}\]
of the gradient w.r.t. the data generating distribution \(P\) will vanish since \(\theta\) sits at a local minimum of \(\mathcal{L}\). We assume, that strong models which achieve high test accuracy can be seen as an approximation of such a parameter configuration \(\theta\). Such a model has small gradients on in-distribution data which is close to samples \((x,y)\) in the training data. Samples that differ from training data will receive larger feedback. Like-wise, we assume large training gradients from OOD samples that are far away from the effective support of \(P\).
In order to quantify uncertainty about the prediction \(\hat{\pi}(x,\theta)\), we replace the label \(y\) from above by some auxiliary label for which we make two concrete choices in our method. On the one hand, we replace \(y\) by the class prediction one-hot vector \(y_{k}^{oh}=\delta_{k\hat{c}}\) with \(\hat{c}=\operatorname*{arg\,max}_{k=1,\dots,C}\hat{\pi}_{k}\) and the Kronecker symbol \(\delta_{ij}\). This quantity correlates strongly with training labels on in-distribution data. On the other hand, we regard a uniform, all-warm label \(y_{k}^{uni}=1/C\) for \(k=1,\dots,C\) as a replacement for \(y\). To motivate the latter choice, we consider that classification models are oftentimes trained on the categorical cross entropy loss
\[\mathcal{L}(\hat{\pi}\|y)=-\sum_{k=1}^{C}y_{k}\log(\hat{\pi}_{k}). \tag{3}\]
Since the gradient of this loss function is linear in the label \(y\), a uniform choice will return the average gradient per class
which should be high on OoD data where all possible labels are similarly unlikely. The magnitude of \(\nabla_{\theta}\mathcal{L}(\hat{\pi}\|y)\) serves as uncertainty / OoD score. In the following, we explain how to compute such scores for pixel-wise classification models.
### Efficient Computation in Semantic Segmentation
We regard a generic segmentation architecture utilizing a final convolution as the pixel-wise classification mechanism. In the following, we also assume that the segmentation model is trained via the commonly-used pixel-wise cross entropy loss \(\mathcal{L}_{ab}(\phi(\theta)|y)\) (cf. eq. (3)) over each pixel \((a,b)\) with feature map activations \(\phi(\theta)\). Pixel-wise probabilities are obtained by applying the softmax function \(\Sigma\) to each output pixel, i.e., \(\hat{\pi}_{ab,k}=\Sigma^{k}\left(\phi_{ab}(\theta)\right)\). With eq. (3), we find for the loss gradient
\[\nabla_{\theta}\mathcal{L}_{ab}(\Sigma(\phi(\theta))\|y)=\sum_{k=1}^{C}\Sigma^ {k}(\phi_{ab})(1-y_{k})\cdot\nabla_{\theta}\phi_{ab}^{k}(\theta). \tag{4}\]
Here, \(\theta\) is any set of parameters within the neural network. Detailed derivations of this and the following formulas of this section are provided in Appendix A. Here, \(\phi\) is the convolution result of a pre-convolution feature map \(\psi\) (see Figure 2) against a filter bank \(K\) which assumes the role of \(\theta\). \(K\) has parameters \((K_{e}^{h})_{fg}\) where \(e\) and \(h\) indicate in- and out-going channels respectively and \(f\) and \(g\) index the spatial filter position. The features \(\phi\) are linear in both, \(K\) and \(\psi\), and depend on bias parameters \(\beta\) in the form
\[\phi_{ab}^{d}=(K*\psi)_{ab}^{d}+\beta^{d}=\sum_{j=1}^{\kappa}\sum_{p,q=-s}^{s} (K_{j}^{d})_{pq}\psi_{a+p,b+q}^{j}+\beta^{d}. \tag{5}\]
We denote by \(\kappa\) the total number of in-going channels and \(s\) is the spatial extent to either side of the filter \(K_{j}^{d}\) which has total size \((2s+1)\times(2s+1)\). Explicitly for the last layer gradients we find
\[\frac{\partial\phi_{ab}^{d}}{\partial(K_{e}^{h})_{fg}}=\delta_{dh}\psi_{a+f,b +g}^{e}. \tag{6}\]
Together with eq. (4), we obtain an explicit formula for computing the correct backpropagation gradients of the loss on pixel-level for our choices of auxiliary labels which we state in the following paragraph. The computation of the loss gradient can be traced in Figure 2.
If we take the predicted class \(\hat{c}\) as a one-hot label per pixel as auxiliary labels, i.e., \(y^{oh}\), we obtain for the last layer gradients
\[\frac{\partial\mathcal{L}_{ab}(\Sigma(\phi)\|y^{oh})}{\partial K_{e}^{h}}= \Sigma^{h}(\phi_{ab})\cdot(1-\delta_{h\hat{c}})\cdot\psi_{ab}^{e} \tag{7}\]
which depends on quantities that are easily accessible during a forward pass through the network. Note, that the filter bank \(K\) for \((1\times 1)\)-convolutions does not require spatial indices which is a common situation in segmentation networks. Similarly, we find for the uniform label \(y_{j}^{uni}=1/C\)
\[\frac{\partial\mathcal{L}_{ab}(\Sigma(\phi)\|y^{uni})}{\partial K_{e}^{h}}= \frac{C-1}{C}\Sigma^{h}(\phi_{ab})\psi_{ab}^{e}. \tag{8}\]
Therefore, pixel-wise gradient norms are simple to implement and particularly efficient to compute for the last layer of the segmentation model. In the subsection A.2, we cover formulas for the more general case of deeper gradients as well.
### Uncertainty Scores
We obtain pixel-wise scores (still depending on \(a\) and \(b\)) by computing the partial norm \(\|\nabla_{K}\mathcal{L}_{ab}\|_{p}\) of this tensor over the indices \(e\) and \(h\) for some fixed value of \(p\). This can again be done in a memory efficient way by the natural decomposition \(\partial\mathcal{L}/\partial K_{e}^{h}=S^{h}\cdot\psi^{e}\). In addition to their use in error detection, these scores can be used in order to detect OoD objects in the input, i.e., instances of categories not present in the training distribution of the segmentation network. We identify OoD regions with pixels that have a gradient score higher than some threshold and find connected components like the one shown in Figure 1 (bottom). Different values of \(p\) are studied in the supplementary material. We also consider values \(0<p<1\) in addition to positive integer values. Note, that such choices do not strictly define the geometry of a vector space norm, however, \(\|\cdot\|_{p}\) may still serve as a notion of magnitude and generates a partial ordering. The tensorized multiplications required in eqs. (7) and (8) are far less computationally expensive than a forward pass through the DNN. This means that computationally, this method is preferable over prediction sampling like MC Dropout or ensembles. We abbreviate our method using
Figure 2: Schematic illustration of the computation of pixel-wise gradient norms for a semantic segmentation network with a final \((1\times 1)\)-convolution. Auxiliary labels may be derived from the softmax prediction or supplied in any other way (e.g., as a uniform all-warm label). We circumvent direct back propagation per pixel by utilizing eqs. (7), (8).
the **pixel**-wise **gradient** norms obtained from eqs. (7) and (8) by \(\mathrm{PGN}_{oh}\) and \(\mathrm{PGN}_{uni}\), respectively. The particular value of \(p\) is denoted by superscript, e.g., \(\mathrm{PGN}_{oh}^{p=0.3}\) for the (\(p=0.3\))-seminorm of gradients obtained from \(y^{oh}\).
## 4 Experiments
In this section, we present the experimental setting first and then evaluate the uncertainty estimation quality of our method on pixel and segment level. Last, we apply our gradient-based method to OoD segmentation and show some visual results.
### Experimental Setting
DatasetsWe perform our tests on the Cityscapes [11] dataset for semantic segmentation in street scenes and on four OoD segmentation datasets, i.e., LostAndFound [13], Fishyscapes [12], RoadAnomaly21 and RoadObstacle21 [1]1. The Cityscapes dataset consists of \(2{,}975\) training and \(500\) validation images of dense urban traffic in \(18\) and \(3\) different German towns, respectively. The LostAndFound dataset contains \(1{,}203\) validation images with annotations for the road surface and the OoD objects, i.e., small obstacles on German roads in front of the ego-car. In [1] this dataset is filtered (LostAndFound test-NoKnown) as children and bicycles are considered as OoD objects, although they are included in the Cityscapes training set. The Fishyscapes LostAndFound dataset is based on the LostAndFound dataset and refines the pixel-wise annotations, i.e., it is distinguished between OoD objects, background (Cityscapes classes) and void (anything else). Moreover frames that do not contain OoD objects as well as sequences with children and bikes are removed resulting in \(100\) validation images (and \(275\) non-public test images). The RoadObstacle21 dataset (\(412\) test images) is comparable to the LostAndFound dataset as all obstacles appear on the road. However, the RoadObstacle21 dataset contains more diversity in the OoD objects as well as in the situations (night, snowy conditions and dirty roads) compared to the LostAndFound dataset where all sequences are recorded under good weather conditions. In the RoadAnomaly21 dataset the objects (anomalies) appear anywhere on the image which makes it comparable to the Fishyscapes LostAndFound dataset. While the latter dataset consists of frames extracted from a small number of different scenes, every image of the RoadAnomaly21 dataset (\(100\) test images) shows a unique scene and a wider variety of anomalous objects.
Footnote 1: Benchmark: ([http://segmentmeifyoucan.com/](http://segmentmeifyoucan.com/))
Segmentation NetworksWe consider a state-of-the-art DeepLabv3+ network [1] with two different backbones, WideResNet38 [22] and SEResNeXt50 [20]. The network with each respective backbone is trained on Cityscapes achieving a mean IoU value of \(90.58\%\) for the WideResNet38 backbone and \(80.76\%\) for the SEResNeXt50 on the Cityscapes validation set. We use one and the same model trained exclusively on the Cityscapes dataset for both tasks, the uncertainty estimation and the OoD segmentation, as our method does not need to be re-trained on OoD data. Therefore, our method leaves the entire segmentation performance of the base model completely intact.
### Numerical Results
In our experiments, we apply different \(p\)-norms, \(p\in\{0.1,0.3,0.5,1,2\}\), to our calculated gradients, see subsection 3.2. As we provide only a selection of results in the following, we refer to Appendix D for an ablation study on different values for \(p\) and to Appendix E for further results where the gradients of deeper layers are computed.
Pixel-wise Uncertainty EvaluationIn order to assess the correlation of uncertainty and prediction errors on the pixel level, we resort to the commonly used sparsification graphs [23]. Sparsification graphs normalized w.r.t. the optimal oracle (sparsification error) can be compared in terms of the so-called area under the sparsification error curve (AuSE). The closer the uncertainty estimation is to the oracle in terms of Brier score evaluation, i.e., the smaller the AuSE, the better the uncertainty eliminates false predictions by the model.
The AuSE metric is capable of grading the uncertainty ranking, however, does not address the statistics in terms of given confidence. Therefore, we resort to an evaluation of calibration in terms of expected calibration error (ECE, [11]) to assess the statistical reliability of the uncertainty measure.
As baseline methods we consider quantities that can be obtained without modifying the segmentation model (like MC Dropout) or retraining (like deep ensembles) and which do not need additional data (like re-calibration confidences). Our choices fall on the uncertainty ranking provided by the maximum softmax probabilities native to the segmentation
\begin{table}
\begin{tabular}{l|c c|c c} \hline \hline & \multicolumn{2}{c|}{WideResNet} & \multicolumn{2}{c}{SEResNeXt} \\ \hline & ECE \(\downarrow\) & AuSE \(\downarrow\) & ECE \(\downarrow\) & AuSE \(\downarrow\) \\ \hline Maximum Softmax & \(0.0017\) & \(0.0277\) & \(0.0032\) & \(0.0327\) \\ Entropy & \(0.0063\) & \(0.0642\) & \(0.0066\) & \(0.0623\) \\ \(\mathrm{PGN}_{oh}^{p=2}\) (ours) & \(0.0019\) & \(0.0268\) & \(0.0039\) & \(0.0365\) \\ \(\mathrm{PGN}_{uni}^{p=0.1}\) (ours) & \(0.0186\) & \(0.0784\) & \(0.0346\) & \(0.0427\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Pixel-wise uncertainty evaluation results for both backbone architectures and the Cityscapes dataset in terms of ECE and AuSE.
model as well as the softmax entropy. An evaluation of calibration errors requires normalized scores, so we will normalize our gradient scores according to the highest value obtained on the test data for the computation of ECE.
The resulting metrics are compiled in Table 1 for both architectures evaluated on the Cityscapes val split. We see that both, the uncertainty ranking and the calibration of \(\text{PGN}_{oh}\) are roughly on par with the stronger maximum softmax baseline. Generally, we see the trend that \(\text{PGN}_{uni}\) has higher calibration error by one order of magnitude and higher sparsification errors of up to \(5.2\) percentage points (pp) which may indicate that this kind of score is less indicative of in-distribution errors. Note, that although there is no immediate reason for \(\text{PGN}_{oh}\) to be calibrated in any way, we find calibration errors that are competitive on pixel-level with those of the maximum softmax.
Segment-wise Prediction Quality EstimationTo reduce the number of false positive predictions and to estimate the prediction quality, we use meta classification and meta regression introduced by [14]. As input for the post-processing models, the authors use information from the network's softmax output which characterize uncertainty and geometry of a given segment like the segment size. The degree of randomness in semantic segmentation prediction is quantified by pixel-wise quantities, like entropy and probability margin. To obtain segment-wise features from these quantities, they are aggregated over segments via average pooling. These features used in [14] serve as a baseline in our tests (called MetaSeg).
Similarly, we construct segment-wise features from our pixel-wise gradient \(p\)-norms for \(p\in\{0.1,0.3,0.5,1,2\}\). We compute the mean and the variance of these pixel-wise values over a given segment. These features per segment are considered also for the inner and the boundary since the gradient scores may be higher on the boundary of a segment, see Figure 1 (bottom). The inner of the segment consists of all pixels whose eight neighboring pixels are also elements of the same segment. Furthermore, we define some relative mean and variance features over the inner and boundary which characterizes the degree of fractality. These hand-crafted quantities form a structured dataset where the columns correspond to features and the rows to predicted segments which serve as input to the post-processing models. Details on the construction of these features can be found in Appendix B.
We determine the prediction accuracy of semantic segmentation networks with respect to the ground truth via the segment-wise intersection over union (IoU, [12]). On the one hand, we perform the direct prediction of the IoU (meta regression) which serves as prediction quality estimate. On the other hand, we discriminate between \(\text{IoU}=0\) (false positive) and \(\text{IoU}>0\) (true positive) (meta classification). We use linear classification and regression models.
For the evaluation, we use AuROC (area under the receiver operating characteristic) for meta classification and the determination coefficient \(R^{2}\) for meta regression. As baselines, we employ the maximum softmax probability [14], the entropy and the MetaSeg framework. A comparison of these methods and our approach for the Cityscapes dataset is given in Figure 3. For the evaluation, we separate the gradient features obtained by one-hot (\(\text{PGN}_{oh}\)) and by uniform (\(\text{PGN}_{uni}\)) labels. Also, we consider using all gradient features (PGN) as input to the meta models. With PGN, we outperform the maximum softmax and the entropy baselines as well as the MetaSeg performance with the only exception of meta classification for the SEResNeXt backbone where MetaSeg achieves a marginal \(0.41\) pp higher AuROC value than ours. Moreover, we enhance the MetaSeg performance for both networks and both tasks combining the MetaSeg features with PGN by up to \(1.02\) pp for meta classification and up to \(3.98\) pp for meta regression. This indicates that gradient features contain information which is orthogonal to the information contained in the softmax output. In particular, the highest AuROC value of \(93.31\%\) achieved for the WideResNet backbone, shows the capability of our approach to estimate the prediction quality and filter out false positive predictions on the segment-level.
Figure 3: Segment-wise uncertainty evaluation results for both backbone architectures and the Cityscapes dataset in terms of classification AuROC and regression \(R^{2}\) values. From left to right: maximum softmax, mean entropy, MetaSeg (MS) approach, gradient features obtained by predictive one-hot labels (\(\text{PGN}_{oh}\)), gradient features obtained by uniform labels (\(\text{PGN}_{uni}\)), all gradient features in combination (PGN), MetaSeg in combination with our gradient features.
OoD SegmentationOur results in OoD segmentation are based on the evaluation protocol of the SegmentMelfY-ouCan benchmark[1]. Evaluation on the pixel-level involves the threshold-independent area under precision-recall curve (AuPRC) and the false positive rate at the point of \(0.95\) true positive rate (FPR\({}_{05}\)). The latter constitutes an interpretable choice of operating point for each method where a minimum true positive fraction is dictated. On segment-level, an adjusted version of the mean intersection over union (sIoU) which represents the accuracy of the segmentation obtained by thresholding at a particular point, positive predictive value (PPV or Precision) playing the role of binary instance-wise accuracy and the \(F_{1}\)-score. The latter segment-wise metrics are averaged over thresholds between \(0.25\) and \(0.75\) with a step size of \(0.05\) leading to the quantities \(\overline{\text{sIoU}}\), \(\overline{\text{PPV}}\) and \(\overline{F_{1}}\).
In contrast to the previous evaluations on predictive errors, we do not report here results for both of our models, rather we compare gradient scores as an OoD score as such against other methods on the benchmark and report the best result obtained for both, \(\text{PGN}_{oh}\) and \(\text{PGN}_{uni}\). As baselines, we include the same methods as for error detection before since these constitute a reasonable comparison in addition to some of the well-established methods of estimating epistemic uncertainty like MC Dropout and deep ensemble. Note, that the standard entropy baseline is not featured in the official leaderboard, so we report our own results obtained by the softmax entropy with the WideResNet backbone which performed better. We include a full table of methods in Appendix C and find that our method is in several cases competitive with some of the stronger methods utilizing adversarial examples, auxiliary data or significant alterations of the model architecture.
The results verified by the official benchmark are compiled in Table 2 and Table 3. Across the board, PGN shows strong performance, almost exclusively delivering the best or second-best results with few exceptions. The only prominent exception is in the segment-based PPV metric on LostAndFound test-NoKnown where both, \(\text{PGN}_{oh}\) and \(\text{PGN}_{uni}\) come in behind the maximum softmax and entropy baseline. Meanwhile, the segmentation accuracy in terms of sIoU, as well as the \(F_{1}\) score which is the harmonic mean of Recall and Precision are far superior to these two baselines. This indicates still better OoD segmentation quality and in particular better Recall achieved by \(\text{PGN}\). Gradient scores perform perhaps the least convincingly on the RoadObstacle21 benchmark, where in three cases only the second-best performance is achieved. Overall however, we conclude strong performance of our method in terms of out-of-distribution segmentation across different datasets. We find a slight trend of \(\text{PGN}_{oh}\) performing better in the Obstacle track which can be seen to be closer to in-distribution data in semantic segmentation for autonomous driving. This connection would be consistent with our finding in actual in-distribution errors, while \(\text{PGN}_{uni}\) performs better on the Anomaly track which is more clearly out-of-distribution for street scene recognition. In several cases, our method even beats some of the stronger OoD segmentation methods utilizing, for example on RoadAnomaly21, adversarial samples (ODIN/Mahalanobis by over \(9\) pp in AuPRC), OoD data (Void Classifier by over \(6\) pp AuPRC) or generative models (JSRNet/Embedding Density by over \(5\) pp AuPRC and Image Resynthesis by over \(10\) pp in \(\overline{\text{PPV}}\)).
Figure 4 shows segmentation predictions of the pre-trained DeepLabv3+ network with the WideResNet38 backbone together with its corresponding \(\text{PGN}_{uni}^{p=0.5}\)-heatmap. The two panels on the left show an in-distribution prediction on Cityscapes where uncertainty is mainly concentrated around segmentation boundaries which are always subject to high
\begin{table}
\begin{tabular}{c|c c|c c c|c c|c c c} \hline \hline & \multicolumn{4}{c|}{LostAndFound test-NoKnown} & \multicolumn{4}{c}{RoadObstacle21} \\ \hline & AuPRC \(\uparrow\) & \(\text{FPR}_{05}\downarrow\) & \(\overline{\text{sIoU}}\uparrow\) & \(\overline{\text{PPV}}\uparrow\) & \(\overline{F_{1}}\uparrow\) & AuPRC \(\uparrow\) & \(\text{FPR}_{05}\downarrow\) & \(\overline{\text{sIoU}}\uparrow\) & \(\overline{\text{PPV}}\uparrow\) & \(\overline{F_{1}}\uparrow\) \\ \hline Ensemble & \(2.9\) & \(82.0\) & \(6.7\) & \(7.6\) & \(2.7\) & \(1.1\) & \(77.2\) & \(8.6\) & \(4.7\) & \(1.3\) \\ MC Dropout & \(36.8\) & \(35.6\) & \(17.4\) & \(34.7\) & \(13.0\) & \(4.9\) & \(50.3\) & \(5.5\) & \(5.8\) & \(1.1\) \\ \hline Maximum Softmax & \(30.1\) & \(33.2\) & \(14.2\) & \(62.2\) & \(10.3\) & \(15.7\) & \(16.6\) & \(19.7\) & \(15.9\) & \(6.3\) \\ Entropy & \(52.0\) & \(30.0\) & \(40.4\) & \(53.8\) & \(42.4\) & \(20.6\) & \(16.3\) & \(21.4\) & \(19.5\) & \(10.4\) \\ \hline \(\text{PGN}_{oh}^{p=0.5}\) & \(64.9\) & \(18.4\) & \(48.3\) & \(50.0\) & \(46.9\) & \(18.8\) & \(14.8\) & \(22.1\) & \(16.5\) & \(9.2\) \\ \(\text{PGN}_{uni}^{p=0.5}\) & \(69.3\) & \(9.8\) & \(50.0\) & \(44.8\) & \(45.4\) & \(16.5\) & \(19.7\) & \(19.5\) & \(14.8\) & \(7.4\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: OoD segmentation results for the LostAndFound and the RoadObstacle21 dataset.
Figure 4: Semantic segmentation prediction and our gradient uncertainty heatmap (\(\text{PGN}_{uni}^{p=0.5}\)) for the Cityscapes dataset (_left_) and the RoadAnomaly21 dataset (_right_) for the WideResNet backbone.
prediction uncertainty. Moreover, we see some false predictions in the far distance around the street crossing which can be found as a region of high gradient norm in the heatmap. In the two panels to the right, we see an OoD prediction from the RoadAnomaly21 dataset of a sloth crossing the street which is classified as part vegetation, terrain and person. The outline of the segmented sloth can be seen brightly in the gradient norm heatmap to the right indicating clear separation.
LimitationsWhile our method performs well in terms of segment-wise error detection and raises accuracy compared with previous methods, we declare that our method is merely on-par with other uncertainty quantification methods for pixel-level considerations. Moreover, there have been submissions to the SegmentMelfYouCan benchmark which significantly outperform our method, however, due to the simplicity and flexibility of our method this comes at no surprise. Note, that there are some light architectural restrictions when it comes to our method in that it is required for the final layer to be a convolution.
## 5 Conclusion
In this work, we presented an efficient method of computing gradient uncertainty scores for a wide class of deep semantic segmentation models. Moreover, we appreciate a low computational cost associated with them. Our experiments show that large gradient norms obtained by our method statistically correspond to erroneous predictions already on the pixel-level and can be normalized such that they yield similarly calibrated confidence measures as the maximum softmax score of the model. On a segment-level our method shows considerable improvement in terms of error detection. Gradient scores can be utilized to segment out-of-distribution objects significantly better than any other softmax- or output-based method on the SegmentMelfYouCan benchmark and has competitive results with a variety of methods, in several cases clearly outperforming all of them. We hope that our contributions in this work and the insights into the computation of pixel-wise gradient feedback for segmentation models will inspire future work in uncertainty quantification and pixel-wise loss analysis.
## Acknowledgements
We thank Hanno Gottschalk and Matthias Rottmann for discussion and useful advice. This work is supported by the Ministry of Culture and Science of the German state of North Rhine-Westphalia as part of the KI-Starter research funding program. The research leading to these results is funded by the German Federal Ministry for Economic Affairs and Climate Action within the project "KI Delta Learning" (grant no. 19A19013Q). The authors would like to thank the consortium for the successful cooperation. The authors gratefully acknowledge the Gauss Centre for Supercomputing e.V. www.gauss-centre.eu for funding this project by providing computing time through the John von Neumann Institute for Computing (NIC) on the GCS Supercomputer JUWELS at Julich Supercomputing Centre (JSC).
|
2310.19938 | Lyapunov-Based Dropout Deep Neural Network (Lb-DDNN) Controller | Deep neural network (DNN)-based adaptive controllers can be used to
compensate for unstructured uncertainties in nonlinear dynamic systems.
However, DNNs are also very susceptible to overfitting and co-adaptation.
Dropout regularization is an approach where nodes are randomly dropped during
training to alleviate issues such as overfitting and co-adaptation. In this
paper, a dropout DNN-based adaptive controller is developed. The developed
dropout technique allows the deactivation of weights that are stochastically
selected for each individual layer within the DNN. Simultaneously, a
Lyapunov-based real-time weight adaptation law is introduced to update the
weights of all layers of the DNN for online unsupervised learning. A non-smooth
Lyapunov-based stability analysis is performed to ensure asymptotic convergence
of the tracking error. Simulation results of the developed dropout DNN-based
adaptive controller indicate a 38.32% improvement in the tracking error, a
53.67% improvement in the function approximation error, and 50.44% lower
control effort when compared to a baseline adaptive DNN-based controller
without dropout regularization. | Saiedeh Akbari, Emily J. Griffis, Omkar Sudhir Patil, Warren E. Dixon | 2023-10-30T18:54:08Z | http://arxiv.org/abs/2310.19938v1 | # Lyapunov-Based Dropout Deep Neural Network (Lb-DDNN) Controller
###### Abstract
Deep neural network (DNN)-based adaptive controllers can be used to compensate for unstructured uncertainties in nonlinear dynamic systems. However, DNNs are also very susceptible to overfitting and co-adaptation. Dropout regularization is an approach where nodes are randomly dropped during training to alleviate issues such as overfitting and co-adaptation. In this paper, a dropout DNN-based adaptive controller is developed. The developed dropout technique allows the deactivation of weights that are stochastically selected for each individual layer within the DNN. Simultaneously, a Lyapunov-based real-time weight adaptation law is introduced to update the weights of all layers of the DNN for online unsupervised learning. A non-smooth Lyapunov-based stability analysis is performed to ensure asymptotic convergence of the tracking error. Simulation results of the developed dropout DNN-based adaptive controller indicate a 38.32% improvement in the tracking error, a 53.67% improvement in the function approximation error, and 50.44% lower control effort when compared to a baseline adaptive DNN-based controller without dropout regularization.
Deep neural network, dropout, adaptive control, Lyapunov methods, nonlinear control systems.
## I Introduction
Empirical evidence indicates that deep neural networks (DNNs) can provide better function approximation than single layer neural networks [1]. Traditionally, DNN-based controllers are trained using offline training methods based on prior collected datasets. [2, Section 6.6]. Recent developments in [3, 4, 5, 6, 7] use Lyapunov-based methods to develop unsupervised online learning for all weights of a deep neural network (i.e., Lb-DNNs).
Unfortunately, both offline and Lb-DNNs can exhibit significantly degraded performance due to data overfitting. Another challenge that decreases generalization and performance of the trained DNN is co-adaptation, where multiple neurons, or even entire layers, become overly reliant on each other during the training process [8]. One effective approach to address these issues is through dropout regularization. Dropout was originally introduced by G. Hinton in [9] to prevent co-adaptation of feature detectors and improve the generalization performance of DNNs. Dropout regularization involves stochastically dropping out neurons during training, which helps prevent over-fitting, enhances the overall function approximation performance, and efficiently allocates computational resources while updating the network's weights [10, 11]. By setting the activation of certain individual weights to zero, dropout induces sparse representation in the network which reduces co-dependency in neurons. Moreover, dropouts can be viewed as training an ensemble of multiple DNNs with smaller width that are trained independently. Independence in the training has a regularizing effect and provides better generalization to new information. This intuitive reasoning is also applicable for using dropout in DNN-based adaptive control, since dropouts mitigate co-adaptation by reducing the number of weights influencing an adaptation law.
Although dropout regularization has been used for offline training of DNNs in results such as [12, 13], its application has been limited in real-time adaptive control settings. In [10], the dropout method is employed on a DNN to improve the training performance of inner layers in pseudo real-time, and through simulations, the study demonstrates the improved performance of a DNN-based adaptive controller with dropout. However, the pseudo real-time adaptation laws in [10] are not stability-driven but are rather based on a modular design where the stability analysis is primarily facilitated using robust control techniques.
This paper introduces a novel dropout technique aimed at enhancing the function approximation performance of a DNN-based adaptive controller that updates the weights of all layers of the DNN using the Lyapunov-based update law in [3] (i.e., a Lyapunov-based Dropout Deep Neural Network (Lb-DDNN)). The proposed technique involves the selective inactivation, or dropout, of weights associated with randomly selected neurons within each DNN layer. To incorporate dropout regularization, a new recursive DNN representation and stability-driven weight adaptation laws are constructed by considering the effect of randomization matrices on the closed-loop error system. Through a non-smooth Lyapunov-based stability analysis, the designed controller is guaranteed to stabilize the system in the sense that the tracking error asymptotically converges to zero. Simulation experiments are performed to compare the Lb-DDNN adaptive controller with the baseline adaptive DNN controller developed in [3]. The simulation results show a \(35.56\%\) improvement in the tracking error, a \(49.94\%\) improvement in the function approximation error, and \(48.56\%\) lower control effort in the proposed controller when compared to the baseline controller.
## II Problem Formulation
### _Notation_
The space of essentially bounded Lebesgue measurable functions is denoted by \(\mathcal{L}_{\infty}\). Given two functions \(f:A\to B\) and \(g:B\to C\), where \(A\), \(B\), and \(C\) are sets, the composition of \(f\) and \(g\), denoted as \(g\circ f\), is a new function \(h:A\to C\) defined as \(h\triangleq g\circ f=g\left(f\left(x\right)\right)\), for all \(x\in A\). Let \(\mathbf{0}_{m\times n}\) denote a zero matrix with the dimension of \(m\times n\). Let \(I_{n\times n}\) denote an identity matrix with the dimension of \(n\). For matrices \(A\in\mathbb{R}^{m\times n}\) and \(B\in\mathbb{R}^{p\times q}\), the Kronecker product is denoted as \(A\otimes B\). Given a matrix \(A\triangleq\left[a_{i,j}\right]\in\mathbb{R}^{n\times m}\), where \(a_{i,j}\) denotes the element in the \(i^{th}\) row and \(j^{th}\) column of \(A\), the vectorization operator is defined as \(\text{vec}\left(A\right)\triangleq\left[a_{1,1},\ldots,a_{1,m},\ldots,a_{n,1 },\ldots,a_{n,m}\right]^{\top}\in\mathbb{R}^{nm}\). From [14, Proposition 7.1.9] and given matrices \(A\in\mathbb{R}^{p\times a}\), \(B\in\mathbb{R}^{a\times r}\), and \(C\in\mathbb{R}^{r\times s}\), the vectorization operator satisfies the property \(\text{vec}\left(ABC\right)=\left(C^{\top}\otimes A\right)\text{vec}\left(B \right).\) Differentiating \(\text{vec}\left(ABC\right)\) on both sides with respect to \(\text{vec}\left(B\right)\) yields the property \(\frac{\partial}{\partial\text{vec}\left(B\right)}\text{vec}\left(ABC\right) =C^{\top}\otimes A\). The right-to-left matrix product operator is represented by \(\overset{\curvearrow}{\prod}\), i.e., \(\overset{\curvearrow}{\prod}\overset{\curvearrow}{}A_{p}=A_{m}\ldots A_{2}A_ {1}\), and \(\overset{\curvearrow}{\prod}\overset{\curvearrow}{}A_{p}=1\) if \(a>m\). The Filippov set-valued map defined in [15, Equation 2b] is denoted by \(\text{K}\left[\cdot\right]\). The notation \(\overset{\text{a.at.}}{\left(\cdot\right)}\) denotes that the relation \(\left(\cdot\right)\) holds for almost all time (a.a.t.). Consider a Lebesgue measurable and locally essentially bounded function \(h:\mathbb{R}^{n}\times\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{n}\). Then, the function \(y:\mathcal{I}\rightarrow\mathbb{R}^{n}\) is called a Filippov solution of \(\dot{y}=h\left(y,t\right)\) on the interval \(\mathcal{I}\subseteq\mathbb{R}_{\geq 0}\) if \(y\) is absolutely continuous on \(\mathcal{I}\) and \(\dot{y}\overset{\text{a.at.}}{\text{K}}\left[h\right]\left(y,t\right)\). Given some functions \(f\) and \(g\), the notation \(f\left(y\right)=\mathcal{O}^{m}\left(g\left(y\right)\right)\) means that there exists some constants \(M\in\mathbb{R}_{>0}\) and \(y_{0}\in\mathbb{R}\) such that \(\left\|f(y)\right\|\leq M\left\|g(y)\right\|^{m}\) for all \(y\geq y_{0}\). The operator \(\text{proj}\left(\cdot\right)\) denotes the projection operator defined in [16, Appendix E, Eq. E.4].
### _Dynamic Model and Control Objective_
Consider a control-affine nonlinear system modeled as
\[\dot{x}\left(t\right)=f\left(x\left(t\right)\right)+u\left(t\right), \tag{1}\]
where \(t\in\mathbb{R}_{\geq 0}\), \(x:\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{n}\), \(f:\mathbb{R}^{n}\rightarrow\mathbb{R}^{n}\), and \(u:\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{n}\) denote continuous time, the state, the unknown differentiable drift vector field, and the control input, respectively. The control objective is to design a controller \(u\left(t\right)\) such that the state tracks the desired trajectory \(x_{d}\). To achieve the control objective, an adaptive Lb-DNN architecture and a controller are designed to learn the unknown drift vector field and to achieve asymptotic convergence on the tracking error, respectively. To quantify the control objective, the tracking error \(e:\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{n}\), is defined as
\[e\left(t\right)\triangleq x\left(t\right)-x_{d}\left(t\right), \tag{2}\]
where \(x_{d}:\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{n}\) denotes a continuously differentiable desired trajectory.
**Assumption 1**.: The desired trajectory is designed such that for all \(t\in\mathbb{R}_{\geq 0}\), \(x_{d}\left(t\right)\in\Omega\), and \(\dot{x}_{d}\in\mathcal{L}_{\infty}\), where \(\Omega\subset\mathbb{R}^{n}\) is a known compact set. Hence, the desired trajectory can be bounded as \(\left\|x_{d}\right\|\leq\overline{x_{d}}\), where \(\overline{x_{d}}\in\mathbb{R}_{>0}\) is a known constant.
## III Control Design
### _Deep Neural Network Architecture_
To estimate the unknown nonlinear drift vector field \(f\left(x\right)\), a Lb-DNN architecture is developed using dropout. Dropout randomly omits neurons while training, which helps mitigate over-fitting and co-adaptation, thus improving the overall performance and function approximation capabilities of the DNN [10, 11]. Leveraging the Lyapunov stability-driven weight adaptation laws developed in [3], the dropout DNN is designed such that randomization matrices are used to incorporate dropout techniques into the online, stability-driven weight adaptation. Through the randomization matrices, weights associated with a batch of randomly selected neurons are inactivated, i.e., dropped out, to reduce the interdependency and excessive reliance on specific weights and neurons.
As shown in Figure 1, let the dropout DNN architecture, \(\Phi:\mathbb{R}^{n}\times\{0,1\}_{m=0}^{\sum\limits_{k=0}^{L}L_{m}\times \sum\limits_{m=0}^{k}L_{m}}\times\mathbb{R}^{\sum\limits_{k=0}^{k}L_{j}L_{j+1}} \rightarrow\mathbb{R}^{L_{k+1}}\), be defined as
\[\Phi\left(x,R_{i},\theta\right)=\left(R_{i,k}V_{k}\right)^{\top}\phi_{k} \circ\cdots\circ\left(R_{i,1}V_{1}\right)^{\top}\phi_{1}\circ\left(R_{i,0}V_{0} \right)^{\top}x, \tag{3}\]
where \(k\in\mathbb{Z}_{>0}\) denotes the number of the layers in \(\Phi\left(x,R_{i},\theta\right)\), and \(\phi_{j}:\mathbb{R}^{L_{j}}\rightarrow\mathbb{R}^{L_{j}}\) denotes the vector of smooth activation functions in the \(j^{\text{th}}\) layer, for all \(j\in\{1,\cdots,k\}\).1 For \(j\in\{0,\cdots,k\}\), \(V_{j}\in\mathbb{R}^{L_{j}\times L_{j+1}}\) and \(L_{j}\in\mathbb{Z}_{>0}\) represent the weight matrix and the number of nodes in the \(j^{\text{th}}\) layer of \(\Phi\), respectively. For notation simplicity, the weights can be represented in a vector \(\theta\in\mathbb{R}^{\sum\limits_{j=0}^{k}L_{j}L_{j+1}}\) as \(\theta\triangleq\left[\text{vec}\left(V_{0}\right)^{\top},\text{vec}\left(V_{1} \right)^{\top},\cdots,\text{vec}\left(V_{k}\right)^{\top}\right]^{\top}\). Let \(R_{i}\in\{0,1\}_{m=0}^{\sum\limits_{k=0}^{k}L_{m}\times\sum\limits_{m=0}^{k}L_{m}}\) denote the \(i^{\text{th}}\) instance of the randomization matrix, for all \(i\in\mathcal{I}\triangleq\{1,\cdots,J\}\), where \(\mathcal{I}\) denotes the set of all possible switching instances.
Footnote 1: Although \(\phi_{j}\) is defined as a smooth function, the subsequent analysis allows the inclusion of non-smooth activation functions by using the switched systems analysis in [3].
After every user-selected constant time period of \(\delta t\in\mathbb{R}_{>0}\) seconds, the randomization matrix \(R_{i}\) switches to \(R_{i+1}\), where
Figure 1: The structure of a DNN with three hidden layers, where the dashed and solid lines respectively represent the randomly dropped out and selected weights.
\(R_{i+1}\) is randomly selected from all possible permutations of randomization matrices. Each permutation is defined as
\[R_{i}\triangleq\left[\begin{array}{ccc}\mathbf{0}_{L_{1}\times L_{0}}&\mathbf{0 }_{L_{0}\times L_{1}}&\cdots&\mathbf{0}_{L_{0}\times L_{k}}\\ \mathbf{0}_{L_{1}\times L_{0}}&R_{i,1}&\cdots&\mathbf{0}_{L_{1}\times L_{k}}\\ \vdots&\vdots&\ddots&\vdots\\ \mathbf{0}_{L_{k}\times L_{0}}&\mathbf{0}_{L_{k}\times L_{1}}&\cdots&R_{i,k} \end{array}\right],\ \ \forall i\in\mathcal{I}.\]
For \(i\in\left\{1,\cdots,J\right\}\) and \(j\in\left\{1,\cdots,k\right\}\), \(R_{i,j}\in\left\{0,1\right\}^{L_{j}\times L_{j}}\) is designed to be a diagonal matrix, and the matrix \(R_{i,0}\) is an identity matrix. The number of ones on the diagonal of each \(R_{i,j}\) is equal to a user-selected constant number \(n_{j}\), and the placement of non-zero elements on the diagonal of the matrix \(R_{i,j}\) randomly changes after every \(\delta t\) seconds.2 To illustrate the design of the randomization matrix \(R_{i,j}\) and the effect of dropout on the DNN architecture, the following example is provided.
Footnote 2: Once the system reaches the steady state, the randomization can be stopped in the sense that \(R_{i}\) is replaced with identity matrices. This can be considered as the final permutation of \(R_{i}\) for all \(i\in\mathcal{I}\).
**Example 1**.: Consider \(R_{i,2}\in\left\{0,1\right\}^{3\times 3}\), \(V_{2}\in\mathbb{R}^{3\times 2}\), and let \(n_{2}=1\). Therefore, every \(\delta t\) seconds, \(n_{2}=1\) of the elements on the diagonal of \(R_{i,2}\) are randomly set to 1 and the others are zeroed. The considered permutations of \(R_{i,2}\) for \(i\in\left\{1,2,3\right\}\) are
\[R_{i,2}=\left[\begin{array}{ccc}1&0&0\\ 0&0&0\\ 0&0&0\end{array}\right],\ R_{2,2}=\left[\begin{array}{ccc}0&0&0\\ 0&1&0\\ 0&0&0\end{array}\right],\ R_{3,2}=\left[\begin{array}{ccc}0&0&0\\ 0&0&0\\ 0&0&1\end{array}\right].\]
Let \(v_{p\times q}\in\mathbb{R}\) denote to each individual weight of the weight matrix \(V_{2}\), for rows \(p\in\left\{1,2,3\right\}\) and columns \(q\in\left\{1,2\right\}\). For \(p\in\left\{1,2,3\right\}\), let \(\phi_{2,p}:\mathbb{R}^{L_{2}}\rightarrow\mathbb{R}^{L_{2}}\) denote to the activation functions of the second layer such that the activation vector is \(\phi_{2}=\left[\phi_{2,1},\,\phi_{2,2},\,\phi_{2,3}\right]^{\top}\). Therefore, in the presence and absence of dropout matrix \(\left(R_{3,2}V_{2}\right)^{\top}\phi_{2}\) and \(V_{2}^{\top}\phi_{2}\) are respectively obtained as
\[\left(R_{3,2}V_{2}\right)^{\top}\phi_{2} =\left[\begin{array}{ccc}v_{1,1}&v_{1,2}\\ v_{2,1}&v_{2,2}\\ v_{3,1}&v_{3,2}\end{array}\right]^{\top}\left[\begin{array}{ccc}0&0&0\\ 0&0&0\\ 0&0&1\end{array}\right]^{\top}\left[\begin{array}{ccc}\phi_{2,1}\\ \phi_{2,2}\\ \phi_{2,3}\end{array}\right]\] \[=\left[\begin{array}{ccc}v_{3,1}\phi_{2,3}\\ v_{3,2}\phi_{2,3}\end{array}\right]. \tag{4}\]
\[V_{2}^{\top}\phi_{2} =\left[\begin{array}{ccc}v_{1,1}&v_{1,2}\\ v_{2,1}&v_{2,2}\\ v_{3,1}&v_{3,2}\end{array}\right]^{\top}\left[\begin{array}{ccc}\phi_{2,1} \\ \phi_{2,2}\\ \phi_{2,3}\end{array}\right]\] \[=\left[\begin{array}{ccc}v_{1,1}\phi_{2,1}+v_{2,1}\phi_{2,2}+v_ {3,1}\phi_{2,3}\\ v_{1,2}\phi_{2,1}+v_{2,2}\phi_{2,2}+v_{3,2}\phi_{2,3}\end{array}\right]. \tag{5}\]
Comparing (4) and (5) suggests how the dropout method deactivates the activation functions associated with the zeros on the diagonal of the randomization matrix. Since the dropout matrix is randomly generated, a new batch of weights are selected every \(\delta t\) seconds.
The universal function approximation property states that the function space of (3) is dense in \(\mathcal{C}\left(\mathcal{X}\right)\), where \(\mathcal{C}\left(\mathcal{X}\right)\) denotes the space of continuous functions over the compact set \(\mathcal{X}\subseteq\mathbb{R}^{n}\), where \(x\in\mathcal{X}\)[17, Theorem 1.1]. Therefore, for all \(j\in\left\{0,\cdots,k\right\}\), there exists a corresponding vector of ideal weights \(\theta^{*}\in\mathbb{R}^{\frac{k}{j\times}L_{j}L_{j+1}}\) such that \(\sup_{x_{d}\in\Omega}\left\|f\left(x\right)-\Phi\left(x,R_{i},\theta^{*} \right)\right\|\leq\overline{\varepsilon}\). Thus, the drift vector field can be modeled as
\[f\left(x\right) = \Phi\left(x,R_{i},\theta^{*}\right)+\varepsilon\left(x\right), \tag{6}\]
where \(\varepsilon:\mathbb{R}^{n}\rightarrow\mathbb{R}^{n}\) denotes an unknown function reconstruction error that can be bounded as \(\sup\left\|\varepsilon\left(x\right)\right\|\leq\overline{\varepsilon}\).
**Assumption 2**.: The vector of ideal weights can be bounded by a known constant \(\overline{\theta}\in\mathbb{R}_{>0}\) as \(\left\|\theta^{*}\right\|\leq\overline{\theta}\), [18, Assumption 1].
### _Adaptation Law_
To fulfill the tracking objective, the DNN model in (6) is used to estimate the unknown drift dynamics in (1). Since the ideal weights of the modeled DNN are unknown, adaptive estimates of the weight matrices are developed to learn the unknown drift dynamics \(f\left(x\right)\). Let \(\hat{\theta}:\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{\frac{k}{j\times 2}L_{j}L_{j+1}}\) be defined as \(\hat{\theta}\left(t\right)\triangleq\left[\text{vec}\left(\widehat{V}_{0} {}\right)^{\top},\text{vec}\left(\widehat{V}_{1}\right)^{\top},\cdots,\text{vec }\left(\widehat{V}_{k}\right)^{\top}\right]^{\top}\), where \(\widehat{V}_{j}:\mathbb{R}^{L_{j}\times L_{j+1}}\), for all \(j\in\left\{0,\cdots,k\right\}\), denote the weight estimates. The corresponding weight estimation error \(\tilde{\theta}:\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{\frac{k}{j\times 2}L_{j+1}}\) is defined as \(\tilde{\theta}\left(t\right)\triangleq\theta^{*}-\hat{\theta}\left(t\right)\). Using the weight estimates \(\hat{\theta}\), the adaptive estimate of \(f\left(x\right)\) can be represented as \(\Phi\left(x,R_{i},\hat{\theta}\right)\triangleq\left(R_{i,k}\widehat{V}_{k} \right)^{\top}\phi_{k}\circ\cdots\circ\left(R_{i,1}\widehat{V}_{1}\right)^{ \top}\phi_{1}\circ\left(R_{i,0}\widehat{V}_{0}\right)^{\top}x\). The estimated DNN architecture can be written in a recursive relation as
\[\widehat{\Phi}_{j}=\begin{cases}\left(R_{i,j}\widehat{V}_{j}\right)^{\top} \phi_{j}\left(\widehat{\Phi}_{j-1}\right),&j=\left\{1,...,k\right\},\\ \left(R_{i,0}\widehat{V}_{0}\right)^{\top}x,&j=0,\end{cases} \tag{7}\]
where \(\widehat{\Phi}_{j}\) is the shorthand notation for \(\widehat{\Phi}_{j}\triangleq\Phi_{j}\left(x,R_{i},\hat{\theta}\right)\), and \(\widehat{\Phi}=\widehat{\Phi}_{k}\). Based on the subsequent stability analysis, the adaptation law for DNN weight estimates is designed as
\[\hat{\theta}\triangleq\text{proj}\left(\Gamma_{\theta}\widehat{\Phi}^{\prime \top}e\right), \tag{8}\]
where \(\Gamma_{\theta}\in\mathbb{R}^{\frac{k}{j\times 2}L_{j}L_{j+1}\times\frac{k}{j}L_{j+1}}\) denotes a positive-definite adaptation gain matrix, and \(\widehat{\Phi}^{\prime}\) is a shorthand notation for the Jacobian \(\widehat{\Phi}^{\prime}\triangleq\frac{\partial\Phi\left(x,R_{i},\tilde{\theta }\right)}{\partial\tilde{\theta}}\). The Jacobian \(\widehat{\Phi}^{\prime}\) can be represented as \(\widehat{\Phi}^{\prime}\triangleq\left[\widehat{\Phi}^{\prime}_{0},...,\widehat{ \Phi}^{\prime}_{k}\right],\) where the shorthand notation \(\widehat{\Phi}^{\prime}_{j}\) is defined as \(\widehat{\Phi}^{\prime}_{j}\triangleq\frac{\partial\Phi_{j}\left(x,R_{i},\tilde{ \theta}\right)}{\partial\tilde{\theta}}\), for all \(j\in\left\{0,...,k\right\}\). The projection operator is incorporated in the update law to ensure that \(\hat{\theta}\left
where \(\hat{\phi}_{j}\) and the Jacobian \(\hat{\phi}_{j}^{\prime}\) are the short-hand notations for \(\hat{\phi}_{j}\triangleq\phi_{j}\left(\widehat{\Phi}_{j-1}\right)\) and \(\hat{\phi}_{j}^{\prime}\triangleq\phi_{j}^{\prime}\left(\widehat{\Phi}_{j-1} \right)=\frac{\partial\widehat{\Phi}_{j}}{\partial\widehat{\theta}}\), respectively.
_Remark 1_.: The presence of matrix \(R_{i}\) for all \(i\in\mathcal{I}\) in (9) mitigates co-adaptation by reducing the interdependency of weights in the adaptation law.
### _Closed-Loop Error System_
The designed DNN estimate is used in the developed controller to approximate the unknown drift vector field in (1). By incorporating the developed adaptive DNN estimate, the controller in (10) is designed such that the state \(x\) tracks the desired trajectory \(x_{d}\) despite inactivation of weights associated with a randomly selected batch of neurons. Based on the subsequent stability analysis, the control input is designed as
\[u\left(t\right)\triangleq\dot{x}_{d}-\widehat{\Phi}-k_{e}e-k_{s}\text{sgn} \left(e\right), \tag{10}\]
where \(k_{e},k_{s}\in\mathbb{R}_{>0}\) are constant control gains. Taking the time-derivative of (2) and substituting (1), (6), and the designed controller in (10) and canceling cross-terms yields the closed-loop error system as
\[\dot{e}\left(t\right)=\Phi\left(x,R_{i},\theta^{\ast}\right)-\widehat{\Phi}+ \varepsilon\left(x\right)-k_{s}\text{sgn}\left(e\right)-k_{e}e. \tag{11}\]
To address the technical challenges in deriving adaptation the DNN weights, many results use Taylor series approximation based techniques [3, 5, 7, 18, Eq. 22]. Applying a first-order Taylor series approximation-based error model on \(\Phi\left(x,R_{i},\theta^{\ast}\right)-\widehat{\Phi}\) yields
\[\Phi\left(x,R_{i},\theta^{\ast}\right)-\widehat{\Phi}=\widehat{\Phi}^{\prime} \widehat{\theta}+\mathcal{O}^{2}\left(\left\|\widehat{\theta}\right\|\right), \tag{12}\]
where \(\mathcal{O}\left(\left\|\widehat{\theta}\right\|\right)\) denotes the higher-order terms that can be bounded as \(\left\|\mathcal{O}^{2}\left(\left\|\widehat{\theta}\right\|\right)\right\|\leq\Delta\), where \(\Delta\in\mathbb{R}_{>0}\) denotes a known constant [5, Eq. 18]. Substituting (12) into (11) yields
\[\dot{e}=\widehat{\Phi}^{\prime}\widetilde{\theta}+\mathcal{O}^{2}\left(\left\| \widehat{\theta}\right\|\right)+\varepsilon\left(x\right)-k_{s}\text{sgn} \left(e\right)-k_{e}e. \tag{13}\]
To facilitate the subsequent stability analysis, let \(z:\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{\psi}\) denote the concatenated error system defined as
\[z\left(t\right)\triangleq\left[e^{\top}\left(t\right),\,\widetilde{\theta}^ {\top}\left(t\right)\right]^{\top}, \tag{14}\]
where \(\psi\triangleq n+\sum\limits_{j=0}^{k}\ L_{j}L_{j+1}\). Additionally, let \(\dot{z}=h\left(z,t\right)\), where \(h:\mathbb{R}^{\psi}\times\mathbb{R}_{\geq 0}\rightarrow\mathbb{R}^{\psi}\) is as
\[h\left(z,t\right) \triangleq \left[\begin{array}{c}\left(\begin{array}{c}\widehat{\Phi}^{ \prime}\tilde{\theta}+\mathcal{O}^{2}\left(\left\|\widehat{\theta}\right\| \right)\\ +\varepsilon\left(x\right)-k_{s}\text{sgn}\left(e\right)-k_{e}e\\ -\text{proj}\left(\Gamma_{\theta}\widehat{\Phi}^{\prime\top}e\right)\end{array} \right)\end{array}\right]. \tag{15}\]
## IV Stability Analysis
Let \(V_{L}:\mathbb{R}^{\psi}\rightarrow\mathbb{R}_{\geq 0}\) denote the Lyapunov function candidate defined as
\[V_{L}\left(z\right)\triangleq\frac{1}{2}e^{\top}e+\frac{1}{2}\bar{\theta}^{ \top}\Gamma_{\theta}^{-1}\tilde{\theta}. \tag{16}\]
Given the known constants \(\underline{\alpha},\overline{\alpha}\in\mathbb{R}_{>0}\), the Lyapunov function candidate satisfies the following inequality:
\[\underline{\alpha}\left\|z\right\|^{2}\leq V_{L}\left(z\right)\leq\overline{ \alpha}\left\|z\right\|^{2}. \tag{17}\]
Let the open and connected sets \(\mathcal{B}\in\mathbb{R}^{\psi}\) and \(\Upsilon\subseteq\mathcal{X}\) be defined as \(\mathcal{B}\triangleq\left\{\varsigma\in\mathbb{R}^{\psi}:\left\|\varsigma \right\|\leq\omega\sqrt[]{\underline{\alpha}/\overline{\alpha}}\right\}\) and \(\Upsilon\triangleq\left\{\varsigma\in\mathcal{X}:\left\|\varsigma\right\|< \overline{x_{d}}+\omega\right\}\). Theorem 1 uses the non-smooth analysis technique in [19] to establish the invariance properties of Fillipov solutions to \(\dot{z}\) and to guarantee asymptotic convergence of the tracking error, \(e\).
**Theorem 1**.: _The controller designed in (10) and the DNN update law developed in (8) guarantee asymptotic tracking error convergence for the dynamical system in (1) in the sense that \(\lim\limits_{t\rightarrow\infty}\left\|e\left(t\right)\right\|=0\), given \(\left\|z\left(t_{0}\right)\right\|\in\mathcal{B}\) and that the gain condition \(k_{s}>\overline{\varepsilon}+\Delta\) is satisfied._
Proof.: Let \(\partial V_{L}\) denote the Clarke gradient of \(V_{L}\) defined in [20, p. 39]. Since the Lyapunov function candidate is continuously differentiable, \(\partial V_{L}(z)=\{\nabla V_{L}(z)\}\), where \(\nabla\) denotes the standard gradient operator. From (15), it can be concluded that for all \(i\in\mathcal{I}\), \(V_{L}\) satisfies the following differential equation
\[\dot{V}_{L} \overset{\text{a.al.}}{=}\bigcap\limits_{\ell=0}^{\sigma\in \partial V_{L}(z)}\sigma^{\top}\text{K}\left[h\right]\left(z,t\right)\] \[=\nabla V_{L}^{\top}\left(z\right)\text{K}\left[h\right]\left(z,t\right)\] \[=e^{\top}\bigg{(}\widehat{\Phi}^{\prime}\tilde{\theta}+ \mathcal{O}^{2}\left(\left\|\widehat{\theta}\right\|\right)+\varepsilon \left(x\right)-k_{e}e\] \[\quad-k_{s}\text{K}\left[\text{sgn}\right]\left(e\right)\bigg{)}- \bar{\theta}^{\top}\Gamma_{\theta}^{-1}\text{K}\left[\text{proj}\right]\left( \Gamma_{\theta}\widehat{\Phi}^{\prime\top}e\right). \tag{18}\]
Using [16, Lemma E.1.IV], the bounds on \(\mathcal{O}^{2}\left(\left\|\widehat{\theta}\right\|\right)\) and \(\varepsilon\left(x\right)\), the fact that \(\text{K}\left[\text{proj}\right]\left(\cdot\right)\) is the set of convex combinations of \(\text{proj}\left(\cdot\right)\) and \(\left(\cdot\right)\), and therefore, \(-\tilde{\theta}^{\top}\Gamma_{\theta}^{-1}\text{K}\left[\text{proj}\right] \left(\Gamma_{\theta}\widehat{\Phi}^{\prime\top}e\right)\leq-\tilde{\theta}^{ \top}\widehat{\Phi}^{\prime\top}e\), and canceling cross terms, (18) can be upper-bounded as
\[\dot{V}_{L}\overset{\text{a.al.}}{\leq}-k_{e}\left\|e\right\|^{2}-k_{s}\left\|e \right\|+\left\|e\right\|\left(\Delta+\overline{\varepsilon}\right),\quad\forall i \in\mathcal{I}.\]
Selecting the gain \(k_{s}\) according to the gain condition in Theorem 1 yields
\[\dot{V}_{L}\overset{\text{a.al.}}{\leq}-k_{e}\left\|e\right\|^{2}. \tag{19}\]
From the inequality obtained in (19), [19, Corollary 1] can be invoked to conclude that \(z\in\mathcal{L}_{\infty}\) and \(\lim\limits_{t\rightarrow\infty}\left\|e\left(t\right)\right\|=0\). Due to the facts that \(\widehat{\Phi}\) is smooth for all \(i\in\mathcal{I}\), \(x\in\Omega\), and \(\left\|\widehat{\theta}\right\|\leq\overline{\theta}\), \(\widehat{\Phi}\in\mathcal{L}_{\infty}\). Since \(\dot{x}_{d}\in\mathcal{L}_{\infty}\), \(e\in\mathcal{L}_{\infty}\), and \(\widehat{\Phi}\in\mathcal{L}_{\infty}\), \(u\in\mathcal{L}_{\infty}\). To show that \(x\in\mathcal{X}\), and therefore the universal function approximation property holds, let \(\left\|z\left(t_{0}\right)\right\|\in\mathcal{B}\). Since \(\left\|z\left(t_{0}\right)\right\|\leq\omega\sqrt[]{\underline{\alpha}/\overline{ \alpha}}\), using (17), \(\left\|e\left(t\right)\right\|\leq\omega\). Hence, using (2), \(\left\|x\right\|\) can be bounded as \(\left\|x\right\|\leq\overline{x_{d}}+\omega\). Therefore, if \(z\left(t_{0}\right)\in\mathcal{B}\), then \(x\in\Upsilon\subseteq\mathcal{X}\).
## V Simulation
To demonstrate the efficacy of the Lb-DDNN adaptive controller, simulations are performed on a three-dimensional nonlinear system, and \(f\) in (1) is modeled as
\[f=\left[\begin{array}{c}x_{1}x_{2}^{2}\tanh\left(x_{2}\right)+\sin\left(x_{1}
where \(x\triangleq\left[x_{1},x_{2},x_{3}\right]^{\top}:\mathbb{R}_{\geq 0}\rightarrow \mathbb{R}^{3}\) denotes the system state. Three simulation experiments are performed for \(10\,\)sec with initial condition \(x\left(0\right)=\left[5,1,-5\right]^{\top}\). The desired trajectory is selected as \(x_{d}\left(t\right)=\left[\sin\left(2t\right),-\cos\left(t\right),\sin\left(3t \right)+\cos\left(-2t\right)\right]^{\top}\). The DNN used in the simulations has \(k=7\) inner layers with \(L=10\) neurons in each hidden layer and contained hyperbolic tangent activation functions. The first set of simulations are performed to compare the baseline DNN-based adaptive controller in [3] and the Lb-DDNN adaptive controller in (8) and (10). The second set of simulations are performed to examine the effect of \(\delta t\) on the performance of the propose method. The third set of simulations are performed to compare the performance in the absence and presence of dropout deactivation after the transient period. In all simulations, the DNN weight estimates are initialized randomly from the normal distribution \(\mathcal{N}\left(0,10\right)\). The control gains in (10) are selected as \(k_{e}=10.5\) and \(k_{s}=1.5\). The learning gain for the baseline DNN is selected as \(\Gamma_{\theta}=100I_{670\times 670}\). In the first two sets of simulations, the randomization is activated for the first \(2\,\)sec where the system is in the transient stage. After \(2\,\)sec, all the randomization matrices change to identity matrices. For the first \(2\,\)sec, the learning gain of the dropout DNN update law in (8) is selected as \(\Gamma_{\theta}=100I_{670\times 670}\), and after \(2\,\)sec, the learning gain changes to \(\Gamma_{\theta}=40I_{670\times 670}\). In the transient stage of the first and third set of simulations, the matrices \(R_{i}\) change to \(R_{i+1}\) every \(\delta t=0.1\,\)sec.
The performance results of the simulations are presented in Table I. As shown in the first subplot of Figure 2, the tracking error for the dropout DNN converges significantly faster than the baseline DNN. Specifically, the dropout DNN results in convergence to the final error after approximately \(0.5\,\)sec, roughly four times faster than that of the baseline controller. Despite the jump in the tracking error after the deactivation of the dropout of the DNN weights, the dropout DNN still yields the norm of the root mean square tracking error of \(0.81\), which shows a \(38.32\%\) improvement when compared to the baseline DNN adaptive controller. Moreover, the baseline DNN controller presents more oscillatory behavior within the transient period than the dropout DNN controller. The oscillatory behavior in the baseline DNN is due to interdependency of weights in the adaptation. However, as stated in Remark 1, the dropout DNN mitigates co-adaptation in the adaptation law, thus yielding less oscillatory behavior. As shown in the second subplot of Figure 2, the function approximation error for the dropout DNN controller rapidly converges after less than \(0.2\,\)sec but takes approximately \(2\,\)sec to converge with the baseline DNN controller. Although there is a jump in the function approximation error after the deactivation of the DNN, the dropout DNN controller demonstrated a \(53.67\%\) improvement in function approximation with the norm of the root mean square function approximation error of \(19.44\). Thus, the developed dropout adaptive DNN architecture resulted in better transient behavior and improved tracking and function approximation performance with a \(50.44\%\) lower control effort when compared to the baseline adaptive DNN controller developed in [3].
To examine the effect of selecting different \(\delta t\), simulations are performed with \(\delta t=0.2\,\)sec and \(\delta t=0.05\,\)sec using the Lb-DDNN controller. As shown in Figure 3, reducing \(\delta t\) causes more spikes in the tracking and function approximation performances. Although the differences between the the tracking and function approximation errors are not significant, reducing \(\delta t\) is found to cause more spikes in the plots, as shown in Figure 3.
The third set of simulations examine the performance of the developed dropout DNN controller under two cases; dropping out the neurons for the entire duration of the simulation, and deactivating dropout after \(1\,\)sec. As shown in Figure 4, for both cases, the difference between the tracking and function approximation performances are insignificant during the first second, as expected. Once the dropout is deactivated after \(1\,\)sec, there is an overshoot in both tracking and function approximation errors which does not occur when dropout is maintained throughout the simulation duration. However, not deactivating the dropout after the transient period leads to more spikes in both tracking and function approximation error in the steady state stage. Despite the increase in the the tracking error, deactivation of the dropout in the steady state leads to lower control input and function approximation error as shown in Table I.
## VI Conclusion
A dropout DNN-based adaptive controller is developed for general continuous nonlinear systems. Leveraging the stability-derived DNN update law in [3] and inspired by the dropout technique, the developed dropout DNN controller improves function approximation performance and yields faster learning when compared to the DNN controllers without dropout. A Lyapunov-based stability analysis is performed to guarantee stability in the sense that the tracking error asymptotically converges to zero. Simulation results show \(38.32\%\) and \(53.67\%\) improvement in the tracking error and function approximation error, respectively, with a \(50.44\%\) reduced control effort when compared to the baseline adaptive DNN controller. Additional simulations showed the effect of dropout during both transient and steady state periods and how modifying dropout parameters, i.e., \(\delta t\), can effect system performance. Using the established Lb-DDNN framework, future work can explore implementation questions related to the dropout regularization such as changes in \(\delta t\), the number of neurons that are randomly selected, and dropout deactivation strategies. |
2304.11237 | Effective Neural Network $L_0$ Regularization With BinMask | $L_0$ regularization of neural networks is a fundamental problem. In addition
to regularizing models for better generalizability, $L_0$ regularization also
applies to selecting input features and training sparse neural networks. There
is a large body of research on related topics, some with quite complicated
methods. In this paper, we show that a straightforward formulation, BinMask,
which multiplies weights with deterministic binary masks and uses the identity
straight-through estimator for backpropagation, is an effective $L_0$
regularizer. We evaluate BinMask on three tasks: feature selection, network
sparsification, and model regularization. Despite its simplicity, BinMask
achieves competitive performance on all the benchmarks without task-specific
tuning compared to methods designed for each task. Our results suggest that
decoupling weights from mask optimization, which has been widely adopted by
previous work, is a key component for effective $L_0$ regularization. | Kai Jia, Martin Rinard | 2023-04-21T20:08:57Z | http://arxiv.org/abs/2304.11237v1 | # Effective Neural Network \(L_{0}\) Regularization With BinMask
###### Abstract
\(L_{0}\) regularization of neural networks is a fundamental problem. In addition to regularizing models for better generalizability, \(L_{0}\) regularization also applies to selecting input features and training sparse neural networks. There is a large body of research on related topics, some with quite complicated methods. In this paper, we show that a straightforward formulation, BinMask, which multiplies weights with deterministic binary masks and uses the identity straight-through estimator for backpropagation, is an effective \(L_{0}\) regularizer. We evaluate BinMask on three tasks: feature selection, network sparsification, and model regularization. Despite its simplicity, BinMask achieves competitive performance on all the benchmarks without task-specific tuning compared to methods designed for each task. Our results suggest that decoupling weights from mask optimization, which has been widely adopted by previous work, is a key component for effective \(L_{0}\) regularization.
## 1 Introduction
Regularization is a long-standing topic in machine learning. While \(L_{1}\) and \(L_{2}\) regularization have received thorough theoretical treatment and been widely applied in machine learning, \(L_{0}\) regularization is still under active investigation due to the optimization challenges caused by its combinatorial nature. Given a vector \(\mathbf{W}\in\mathbb{R}^{n}\), \(L_{0}\) regularization penalizes \(\|\mathbf{W}\|_{0}\), the number of non-zero entries in \(\mathbf{W}\). One prominent application of \(L_{0}\) regularization is to induce sparse neural networks, potentially improving time and energy costs at inference with minimum impact on accuracy (Chen et al., 2020). When applied to the input features, \(L_{0}\) regularization can also select a subset of features important to the learning task.
Increasingly complicated methods have been proposed for \(L_{0}\) regularization of neural networks based on various relaxation formulations (Louizos et al., 2018; Yamada et al., 2020; Zhou et al., 2021). In this paper, we revisit a straightforward formulation, BinMask, that multiplies the weights with deterministic binary masks (Jia and Rinard, 2020). The masks are obtained by quantizing underlying real-valued weights, which are simultaneously updated with network weights during training. BinMask uses the identity straight-through estimator to propagate gradient through the quantization operator by treating it as an identity function during backpropagation. BinMask has demonstrated empirical success in training low-complexity sparse binarized neural networks (Jia and Rinard, 2020).
Unlike most research that only focuses on either feature selection or network sparsification, we evaluate BinMask on three different tasks: feature selection, network sparsification, and model regularization. We use the same BinMask implementation without task-specific hyperparameter tuning. BinMask achieves competitive performance on all three tasks compared to methods designed for each task. Our results suggest that the decoupled optimization of network weights and sparsity masks is a key component for effective \(L_{0}\) regularization. When combined with standard techniques for optimizing binary masks, such a formulation is sufficient to give impressive results. We will also open source our implementation, which supports automatically patching most existing PyTorch networks to use sparse weights with minimum additional code.
## 2 Related work
Xiao et al. (2019) and Jia & Rinard (2020) are most relevant to our work. They both use a similar formulation that multiplies weights with deterministic binary masks optimized via the straight-through estimator. However, Xiao et al. (2019) uses bi-level optimization with a custom optimizer to update weights and masks separately, which is computationally expensive. Their experiments focus on training sparse networks starting from pretrained networks without evaluating \(L_{0}\) regularization in other scenarios. Jia & Rinard (2020) proposes the name BinMask and uses it to train sparse binarized neural networks with more balanced layer-wise sparsities to achieve tractable verification. However, they do not evaluate BinMask on other applications or real-valued networks. By contrast, our method learns weights and masks simultaneously in each iteration from random initialization, and we evaluate our method on a diverse set of applications.
Another family of closely related methods exploits probabilistic reparameterization and relaxation to the \(L_{0}\) "norm" (Srinivas et al., 2017; Louizos et al., 2018; Zhou et al., 2021). They focus on sparse training and have not evaluated their methods for other applications. Among them, ProbMask (Zhou et al., 2021) achieves the best accuracies on sparse training. However, their method is tailored to network sparsification and is not directly applicable to feature selection or model regularization. A drawback of methods using probabilistic masks is the need to trade off between computation time and estimation variance. Louizos et al. (2018) uses one sample per minibatch despite larger variance. ProbMask uses multiple samples per minibatch at the cost of slower training. Sampling of masks also introduces distribution shift that requires finetuning network weights after fixing masks, as will be shown in our experiments for ProbMask. By contrast, BinMask uses deterministic masks, which is faster to train and can deliver well-performing models without finetuning.
\(L_{0}\) regularization has two critical applications: feature selection and sparse neural network training. There are enormous methods for both tasks that do not formulate them as \(L_{0}\) regularization problems. Feature selection algorithms can be divided into three categories (Tang et al., 2014). _Filter models_ select features according to ranks computed by some predefined criterion (Gu et al., 2011; Kira & Rendell, 1992; Vergara & Estevez, 2014). They are computationally efficient but deliver worse results due to the ignorance of the target learner to be used with selected features. _Wrapper models_ use heuristics to select a subset of features that maximize the performance of a given black-box learner (El Aboudi & Benhlima, 2016), which is computationally expensive because the target learner needs to be evaluated multiple times. _Embedded models_ attempt to address the drawbacks of the other two methods by simultaneously selecting features and solving the learning task (Liu & Yu, 2005; Ma & Huang, 2008). Recently, there has been an increasing interest in using neural network methods for feature selection (Lu et al., 2018; Zhang et al., 2019; Wojtas & Chen, 2020; Yamada et al., 2020; Lemhadri et al., 2021). Some utilize sparse neural networks to derive selected features from the sparsity patterns (Atashgashi et al., 2022; Atashgashi et al., 2022; Atashgashi et al., 2023). Yamada et al. (2020) is most relevant to our method, as they multiply the input features of neural networks with stochastic binary gates. However, they preserve continuous gate variables during training, which is different from how selected features are used at test time and thus causes lower performance. Their gate probabilities do not converge in our experiments.
Sparse neural networks promise faster and more energy-efficient inference, although there are software/hardware implementation challenges (Lu et al., 2019). Sparse networks can be obtained with diverse pruning methods that remove neurons from trained dense networks according to different importance criterion (Mozer & Smolensky, 1989; Han et al., 2015; Blalock et al., 2020). Those methods typically need more computation budget because a dense network must be trained before pruning. Another line of work learns weights and sparse connections simultaneously during training, typically via applying learnable masks on the weights or via thresholding the weights (Srinivas et al., 2017; Louizos et al., 2018; Xiao et al., 2019; Jia & Rinard, 2020; Zhou et al., 2021; Vanderschueren & De Vleeschouwer, 2023). It is also possible to train sparse weights from random initialization for certain tasks with proper sparse topology (Frankle & Carbin, 2019; Evci et al., 2019). Under specific settings, sparse networks have demonstrated superior performance than dense counterparts empirically, but the extent and the reason are still under investigation (Jin et al., 2022).
Many related methods, including this one, rely on the Straight-Through Estimator (STE) to define the gradient for quantization operators that generate the masks. Despite the lack of rigorous theoretical foundations (Shekhovtsov & Yanush, 2022), STE-based methods have demonstrated good empirical performance in
training binarized or quantized neural networks (Hubara et al., 2016; Krishnamoorthi, 2018; Bethge et al., 2019; Alizadeh et al., 2019; Meng et al., 2020).
## 3 The BinMask method
### General formulation
BinMask applies binary masks to the weights or inputs of neural networks. \(L_{0}\) regularization is accomplished via regularizing the norm of binary masks. This formulation decouples the optimization of weight values from the optimization of masks, which allows recovering removed weights to their values before they are masked out (except changes by weight decay). Such a formulation is favorable because: (i) allowing the growth of connections has been shown to yield better sparse networks (Evici et al., 2020); and (ii) recovering weights to previous values is compatible with the finding that tuning pruned networks with earlier weight values or learning rate schedule is beneficial (Renda et al., 2020).
Formally, given a function \(f:\mathbb{R}^{n}\mapsto\mathbb{R}^{m}\) representing the neural network with inputs and parameters packed as one argument, a loss functional \(L:(\mathbb{R}^{n}\mapsto\mathbb{R}^{m})\mapsto\mathbb{R}\) (i.e., a higher-order function that maps another function to a real value, which can include a training procedure of the neural network), an integer \(k\in[1,n]\) denoting the number of values allowed to be masked out, and a penalty coefficient \(\lambda\geq 0\), BinMask attempts to solve the following optimization problem:
\[\operatorname*{arg\,min}_{\mathbf{b}\in\{0,1\}^{k}} \tilde{L}\left(\mathbf{b}\right) \tag{1}\] \[\text{where }\tilde{L}\left(\mathbf{b}\right)\stackrel{{ \text{\tiny def}}}{{=}}L(f\circ g_{\mathbf{b}})+\lambda\|\mathbf{b}\|_{1}\] \[g_{\mathbf{b}}(\mathbf{x})\stackrel{{\text{\tiny def}}}{{= }}\mathbf{x}\odot[\mathbf{b};\mathbf{1}_{n-k}]\]
Assuming \(L(\cdot)\) and \(f(\cdot)\) can be evaluated in polynomial time, the corresponding decision problem of Eq. (1) (i.e., deciding if \(\exists\mathbf{b}:\;\tilde{L}\left(\mathbf{b}\right)<c\)) is \(\mathsf{NPC}\) because it takes polynomial time to encode a 3-SAT instance in \(L\) or verify a solution. Therefore, exactly solving Eq. (1) is \(\mathsf{NP}\)-hard.
Assuming \(\tilde{L}\left(\mathbf{b}\right)\) is differentiable with respect to \(\mathbf{b}\), we use a gradient-based optimizer to optimize real-valued latent weights \(\mathbf{b}_{r}\in\mathbb{R}^{k}\) that are deterministically quantized to obtain the binary mask \(\mathbf{b}\). We use the identity straight-through estimator to propagate gradient through the non-differentiable quantization operator, which has demonstrated good empirical performance in training binarized or quantized neural networks (Hubara et al., 2016; Krishnamoorthi, 2018). Formally, we transform Eq. (1) into the following problem:
\[\operatorname*{arg\,min}_{\mathbf{b}_{r}\in\mathbb{R}^{k}} \tilde{L}\left(q(\mathbf{b}_{r})\right) \tag{2}\] \[\text{where }q_{i}(\mathbf{b})\stackrel{{\text{\tiny def}}}{{= }}\left\{\begin{array}{ll}1&\text{ if }\mathbf{b}_{i}\geq 0\\ 0&\text{ if }\mathbf{b}_{i}<0\end{array}\right.\]
Eq. (2) is solved via a gradient-based optimizer. The identity straight-through estimator defines the gradient of \(q(\cdot)\): \(\frac{\partial L}{\partial\mathbf{b}_{r}}=\frac{\partial L}{\partial q(\mathbf{b}_{r})}\).
The loss functional \(L(\cdot)\) often includes an iterative optimization procedure of the network weights. We optimize \(\mathbf{b}_{r}\) and neural network weights simultaneously in such cases. Since it has been suggested that during initialization, the weights undergo volatile changes (Leclerc & Madry, 2020), and pruning at initialization is more challenging (Frankle et al., 2021), we freeze the binary masks during initial epochs. We initialize the BinMask weights \(\mathbf{b}_{r}\) with a constant value \(\alpha_{0}\) and clip its values between \([-\alpha_{1},\,\alpha_{1}]\) during training. To optimize \(\mathbf{b}_{r}\), we use the Adam optimizer (Kingma & Ba, 2014), whose use of the second moment has been shown to be crucial for training performant binarized neural networks (Alizadeh et al., 2019). We use cosine learning rate annealing to schedule learning rates (Loshchilov & Hutter, 2017). Since \(\|\mathbf{b}\|_{1}\) is not
differentiable at \(\mathbf{b}=0\) and \(\lambda\|\mathbf{b}\|_{1}=\frac{1}{2}\lambda\|\mathbf{b}\|_{2}^{2}\) for \(\mathbf{b}\in\{0,\,1\}^{k}\), we use the quadratic form in the implementation. Algorithm 1 summarizes our algorithm.
```
0: Dataset \(D\)
0: Neural network function \(f(\mathbf{x},\,\mathbf{W})\) with initial weights \(\mathbf{W}\) and loss function \(L(\mathbf{y},\,\hat{\mathbf{y}})\)
0: Total number of epochs \(E\)
0: Number of iterations per epoch \(T\)
0: An optimizer \(U(\mathbf{W},\,\nabla)\) for the neural network
0: A specification \(s\) describing to which weights and inputs should BinMask be applied
0: BinMask regularization coefficient \(\lambda\)
0: BinMask initialization \(\alpha_{0}\) (default: 0.3)
0: BinMask clip \(\alpha_{1}\) (default: 1)
0: BinMask initial learning rate \(\eta_{0}\) (default: \(10^{-3}\))
0: BinMask final learning rate \(\eta_{1}\) (default: \(10^{-5}\))
0: BinMask warmup epoch fraction \(E_{b}\) (default: 0.1)
0: Trained weights \(\mathbf{W}^{*}\) and BinMask values \(\mathbf{b}^{*}\in\{0,\,1\}^{|s|}\).
1:\(E_{b}^{\prime}\leftarrow\lfloor E_{b}E\rceil\)
2:\(\mathbf{b}_{r}\leftarrow\alpha_{0}\mathbf{1}_{|s|}\)\(\triangleright\) Initialize \(\mathbf{b}_{r}\) to be a constant vector corresponding to items described by \(s\)
3:for\(e\gets 0\)to\(E-1\)do
4:if\(e\geq E_{b}^{\prime}\)then
5:\(\eta_{b}\leftarrow\eta_{0}+\frac{\eta_{1}-\eta_{0}}{2}\left(\cos\left(\frac{e- E_{b}^{\prime}}{E-E_{b}^{\prime}-1}\pi\right)+1\right)\)\(\triangleright\) schedule BinMask learning rate
6:endif
7:for\(t\gets 0\)to\(T-1\)do
8: Sample \((\mathbf{x},\,\mathbf{y})\sim D\)
9:\(\mathbf{b}\gets q(\mathbf{b}_{r})\)\(\triangleright\)\(q(\cdot)\) defined in Eq. (2)
10:\((\mathbf{x}^{\prime},\,\mathbf{W}^{\prime})\leftarrow s(\mathbf{x},\,\mathbf{W},\,\mathbf{b})\)\(\triangleright\) Multiply binary masks with the weights or inputs specified by \(s\)
11:\(\mathbf{g}_{W}\leftarrow\frac{\partial}{\partial\mathbf{W}}L(f(\mathbf{x}^{\prime},\,\mathbf{W}^{ \prime}),\,\mathbf{y})\)
12:\(\mathbf{W}\gets U(\mathbf{W},\,\mathbf{g}_{W})\)\(\triangleright\) Update the weights with the user-provided optimizer
13:if\(e\geq E_{b}^{\prime}\)then
14:\(\mathbf{g}_{b}\leftarrow\left(\frac{\partial}{\partial\mathbf{b}}L(f(\mathbf{x}^{\prime},\,\mathbf{W}^{ \prime}),\,\mathbf{y})\right)+\lambda\mathbf{b}\)
15:\(\mathbf{b}_{r}^{\prime}\leftarrow\text{Adam}(\mathbf{b}_{r},\,\mathbf{g}_{b},\,\eta_{b})\)\(\triangleright\) Get updated BinMask weights with the Adam optimizer
16:\(\mathbf{b}_{r}\leftarrow\min\{\max\{\mathbf{b}_{r}^{\prime},\,-\alpha_{1}\},\,\alpha_{1}\}\)
17:endif
18:endfor
19:endfor
20:return\(\mathbf{W}^{*}\leftarrow\mathbf{W},\,\mathbf{b}^{*}\gets q(\mathbf{b}_{r})\)
```
**Algorithm 1** Training with BinMask
### Feature selection
We apply BinMask to the inputs of a network for feature selection. Note that if the first layer is fully connected, applying BinMask to the input is equivalent to applying BinMask to groups of the first layer weights, which is structural sparsification of the first layer by requiring that either all or none of the connections from each input to the neurons must be selected. Unfortunately, the BinMask algorithm described above is not ideal for practical feature selection for two reasons:
1. The binary mask may change after each iteration, making the result sensitive to the number of iterations.
2. Typical feature selection algorithms allow selecting a given number of features requested by the user rather than indirectly controlling the size of selected feature set through a regularization coefficient. However, it is challenging to control \(\lambda\) to select a precise number of features with BinMask, especially given the randomness in minibatch sampling during training.
To ameliorate those two problems, we introduce a smoothed mask, denoted as \(\hat{\mathbf{b}}\), for feature selection with BinMask. We compute the smoothed mask with moving average after line 9 in Algorithm 1:
\[\hat{\mathbf{b}}\leftarrow\gamma\hat{\mathbf{b}}+(1-\gamma)\mathbf{b} \tag{3}\]
We initialize \(\hat{\mathbf{b}}\) with zeros and set \(\gamma=0.9\) in our experiments. Let \(\hat{\mathbf{b}}(\lambda)\) denote the smoothed mask computed with regularization coefficient \(\lambda\). If the user provides a value of \(\lambda\) without specifying the number of selected features, we select the \(i^{\text{th}}\) feature if \(\hat{\mathbf{b}}_{i}(\lambda)\geq 0.5\). Of note, most of the smoothed mask values converge to either zero or one. When the user requests exactly \(k\) features, we need to find a \(\lambda\) value to not arbitrarily cut features in the convergent region. We search for \(\lambda^{*}\) and a threshold \(c_{\lambda^{*}}\) such that \(0.2\leq c_{\lambda^{*}}\leq 0.8\) and \(\left|\left\{i\,\middle|\,\hat{\mathbf{b}}_{i}(\lambda^{*})\geq c_{\lambda^{*}} \right\}\right|=k\). We use exponential search starting with \(\lambda_{0}=10^{-3}\). We select the \(i^{\text{th}}\) feature if \(\hat{\mathbf{b}}_{i}(\lambda^{*})\geq c_{\lambda^{*}}\).
## 4 Experiments
We evaluate the effectiveness of BinMask on three tasks: feature selection, network sparsification, and model regularization. We implement BinMask with a standalone Python module based on PyTorch (Paszke et al., 2019). Our implementation can be easily incorporated into other PyTorch projects and supports automatically patching most existing PyTorch networks to use BinMask for weight sparsification with minimum additional code. We will open source the implementation after paper review. We use the same implementation for all the experiments, with hyperparameters given in Algorithm 1 except for one change in feature selection.
### Feature selection
**Datasets**: We evaluate the capability of BinMask and other methods to select a subset of features that maximize classification accuracy on five datasets. AP-Breast-Ovary is a binary classification dataset with gene expression features. BASEHOCK is a text classification dataset. Dexter is a text classification task with purposely added noninformative features used as a feature selection benchmark at NeurIPS 2003 (Guyon et al., 2004). Isolet is a speech classification dataset. MNIST is a handwritten digit classification dataset with pixel values as inputs. Note that for MNIST, feature selection is selecting a set of pixel locations to maintain classification accuracy. Our comparison methods also use BASEHOCK, Isolet, and MNIST. We select the other two datasets by querying OpenML (Vanschoren et al., 2013) for classification datasets with no missing features and at least 512 instances. We then manually check the top few datasets with the lowest instance-to-feature ratio to select the two datasets with a nonempty description. Features of each dataset are linearly normalized to the range [0, 1]. We use the provided training/test split of MNIST and randomly select 20% instances as the test set for other datasets.
**Classifiers**: For MNIST, we consider two neural network architectures. One is an MLP with two hidden layers, each with 512 neurons and ReLU followed by batch normalization (Ioffe & Szegedy, 2015), denoted as MNIST-MLP in the results. The other is a LeNet5 convolutional neural network (LeCun et al., 1998) with batch normalization after convolutional layers, denoted as MNIST-CNN. For other datasets, we use an MLP with two hidden layers, each having 64 and 20 neurons with tanh, respectively. MNIST networks are trained for 10 epochs and other networks for 100 epochs. For all tasks, we use the SGD optimizer with momentum 0.9 and weight decay 5\(\times 10^{-4}\), with cosine learning rate annealing from 0.1 to \(10^{-5}\). Each minibatch has 256 instances. If a dataset is too small, the training set is duplicated to have at least 30 minibatches per epoch.
**BinMask setup**: Since with the default setting of Algorithm 1 and the small training sets, the networks easily overfit the training data before any feature is masked out, making the gradients with respect to inputs uninformative for mask optimization, we set the initialization \(\alpha_{0}=0.02\) to allow easier mask flip before overfitting. Other hyperparameters use their default values. For each task, we apply BinMask to the inputs of a network with the same architecture as the classification network for that task.
**Comparison**: We compare BinMask with three other methods. Fisher score is a classical filter model for supervised feature selection that aims to find a subset of features to maximize interclass distance while minimizing intraclass distance (Gu et al., 2011). We use the implementation provided by scikit-feature(Li et al., 2018). Fisher score produces a weight for each feature that can be ranked to select a given number of features. Stochastic gates (STG) uses a probabilistic relaxation to regularize the \(L_{0}\) "norm" of features while simultaneously learning a classifier (Yamada et al., 2020). We use the open-source implementation provided by the authors1. For each task, we apply the STG layer to the inputs of a network with the same architecture as the classification network for that task. We use their default hyperparameter settings. STG produces probabilities for selecting each input feature. Since the STG paper does not specify an algorithm to choose a probability cutoff threshold for feature selection, we use the same exponential search strategy outlined in Section 3.2 to find a suitable regularization coefficient for STG, starting with the default value \(0.1\) given by their implementation. LassoNet uses a neural network with skip connections and \(L_{1}\) regularization to simultaneously learn linear and nonlinear components for the task (Lemhadri et al., 2021). We use the open-source implementation provided by the authors2. We use their default hyperparameter settings and a one-hidden-layer neural network, as suggested by the authors. LassoNet produces a path of networks with decreasing numbers of features used. We choose from the path the feature set whose size is closest to the given number of features.
Figure 1: Feature selection results on various datasets. Bracketed numbers in the legends are mean accuracy over all numbers of features. The top horizontal axis, BinMask \(\lambda\) values, are the values of regularization coefficients found by exponential search to select a given number of features, where bracketed numbers are standard deviation over eight trials. Error bars and the transparent horizontal region indicate 95% CI computed over eight trials. For each dataset, \(n\) is the total number of data points, \(c\) is the number of classes, and \(d\) is the number of input features.
**Evaluation**: For a task \(t\), we first use BinMask with \(\lambda=0.001\) (\(\lambda=5\!\times\!10^{-4}\) for AP-Breast-Ovary) without feature number constraint to select a set of features. Let \(n_{t}\) be the number of features selected. We then run all methods to select \(n_{t}-i\lfloor n_{t}/5\rfloor\) features for \(0\leq i\leq 4\). Given a set of selected features by a method, we evaluate the accuracy of the classifier network corresponding to the task trained from new random initialization with selected features. We only keep selected features as network inputs, except for MNIST-CNN where we use zeros to replace unselected features so that convolutional layers receive two-dimensional inputs. We run eight trials with different dataset split and different weight initialization for each (dataset, method, number of features) configuration. We evaluate each method by its mean accuracy on the test set over eight trials. Since BinMask (with smoothed masks) and STG (Yamada et al., 2020) produce continuously valued masks that should converge to zero or one in the ideal situation, we also evaluate how likely the computed masks converge. A mask is defined to have converged if at most 20% of its values are within [0.15, 0.85].
**Results**: Fig. 1 presents the accuracies on the considered benchmarks, showing that BinMask, a generic \(L_{0}\) regularizer, exhibits competitive performance compared to other methods tailored to feature selection. BinMask achieves best average accuracies on five of the six benchmarks. STG (Yamada et al., 2020) uses 1.6 steps for the exponential search on average, and 8.86% of the computed masks converge. By comparison, BinMask uses 1.7 search steps, with 75.00% of the masks converging.
### Network sparsification
Figure 2: Network sparsification results on CIFAR10/CIFAR100. Error bars and the transparent horizontal region indicate 95% CI computed over four trials.
We apply BinMask to train sparse ResNet32 (He et al., 2016) and VGG19 (Simonyan and Zisserman, 2014) networks on CIFAR-10/100 datasets (Krizhevsky et al., 2009). We sparsify the weights (excluding biases) of convolutional and fully connected layers. We compare with ProbMask (Zhou et al., 2021), a state-of-the-art method for training sparse networks with a probabilistic relaxation to \(L_{0}\) constraint. We their authors' open-source implementation3. ProbMask gradually sparsifies the network during training to meet a predefined target sparsity. We use the same setting as ProbMask for weight optimization: SGD optimizer for 300 epochs with momentum of 0.9 and cosine learning rate annealing starting from 0.1. The ProbMask implementation finetunes the model for 20 epochs after training the masks. For a fair comparison, we also conduct finetuning for the dense models and BinMask models with fixed masks and report results before and after finetuning.
Footnote 3: [https://github.com/x-zho14/ProbMask-official](https://github.com/x-zho14/ProbMask-official)
For each network architecture and dataset, we train BinMask networks with \(\lambda\in\{1.6\!\times\!10^{-5},\,8\!\times\!10^{-6},\,4\!\times\!10^{-6},\,2 \!\times\!10^{-6},\,10^{-6},\,10^{-7},\,0\}\). We then train ProbMask networks with the same overall sparsity as BinMask networks. For each configuration, we run four trials and evaluate the mean accuracy on the test set.
Fig. 2 presents the test accuracies. One can immediately notice the significant performance drop experienced by ProbMask without finetuning. A primary reason is that resampling the probabilistic masks causes shift in the batch normalization statistics. Using per-minibatch statistics instead of the running mean/variance in batch normalization improves ProbMask's mean test accuracy by 12.9% to 17.8% in the four configurations. By contrast, BinMask uses deterministic masks and does not exhibit a large performance drop without finetuning. Notably, with \(\lambda\in\{0,\,10^{-7}\}\), BinMask produces sparse networks with up to 97% sparsity without statistically significant performance differences from the dense networks. BinMask delivers worse accuracies than ProbMask in a few CIFAR-100 configurations but constantly outperforms ProbMask in all high-sparsity cases. BinMask is computationally efficient. On a single NVIDIA Titan XP GPU, training with BinMask is 3.40% slower for ResNet32 and 10.97% slower for VGG19 than training the dense networks. By comparison, ProbMask is 1.4x and 1.9x slower than BinMask on ResNet32 and VGG19, respectively.
Fig. 3 presents the change of sparsity, test loss, and training loss during training. It shows that BinMask can improve sparsity quickly during training without notably impacting training or test loss.
### Model regularization
The above experiments have not shown any advantage of sparse networks regarding predictive power. This section evaluates BinMask's capability to regularize neural networks for better generalizability. We work with a dataset for early prediction of Pancreatic Duct Adenocarcinoma (PDAC) diagnosis, a type of pancreatic cancer, based on Electronic Health Records (EHR) (Jia et al., 2023). The PDAC dataset contains features extracted from EHR of millions of patients. The features are sparse representations of diagnosis, medication, and lab results before a cutoff date for each patient. The outcome variable is PDAC diagnosis within 6 to 18 months after the cutoff date. The PDAC dataset has 63,884 positive instances and 3,604,863 negative instances, with over five thousand features per instance (the exact number of features vary slightly depending on training/test split because the EHR codes for feature generation are selected based on a frequency
Figure 3: Metrics at each training step for selected BinMask \(\lambda\) values. Filled regions of each line are min/max values over four trials.
threshold on the training set). On average, each feature has a 94% chance of being zero. The dataset can be obtained under some collaboration agreement (details to be revealed after paper review). The dataset is split into training, validation, and test sets, with 75%, 10%, and 15% of the instances, respectively.
We train MLP neural networks with two hidden layers, each having 64 and 20 neurons with tanh, respectively. We use the AdamW (Loshchilov & Hutter, 2017a) optimizer and cosine learning rate annealing from 0.002 to 5\(\times\)10\({}^{-5}\) with 16 epochs. We consider four regularization methods: \(L_{0}\) regularization with BinMask, \(L_{1}\) regularization (a.k.a., Lasso regularization), \(L_{2}\) regularization (a.k.a., weight decay), and dropout (Srivastava et al., 2014). We test five regularization coefficients (or dropout probabilities) for each method. For methods other than \(L_{2}\) regularization, we also use a weight decay of 0.01. We adopt early stopping for all methods by selecting the model with the highest validation AUC after each epoch.
We evaluate model performance by computing their mean AUC on the test sets over eight trials with different dataset split and weight initialization. We also train Logistic Regression (LR) models for reference. Table 1 presents the results. Our results show that all the considered regularization methods can effectively regularize the corresponding weight norm, but only \(L_{0}\) regularization with BinMask and \(L_{1}\) regularization significantly improve network generalizability. While it has been suggested that in most clinical cases, NN provides marginal to no improvement over LR (Issitt et al., 2022; Appelbaum et al., 2021), our results suggest that with proper regularization, NN can achieve significant improvement in clinical applications.
\begin{table}
\begin{tabular}{l l c c c c} \hline \hline Metric & Method & \multicolumn{4}{c}{Values (95\% CI)} \\ \hline Regularization & BinMask & 3\(\times\)10\({}^{-5}\) & 4\(\times\)10\({}^{-5}\) & 2\(\times\)10\({}^{-5}\) & 5\(\times\)10\({}^{-5}\) & 10\({}^{-5}\) \\ coeff. / dropout & \(L_{1}\) & 10\({}^{-4}\) & 5\(\times\)10\({}^{-5}\) & 2\(\times\)10\({}^{-4}\) & 3\(\times\)10\({}^{-4}\) & 10\({}^{-5}\) \\ prob. & \(L_{2}\) & 0.01 & 0.1 & 10 & 1 & 50 \\ & Dropout & 0.5 & 0.3 & 0.7 & 0.1 & 0.9 \\ \hline \multirow{7}{*}{Training AUC} & BinMask & 0.858(\(\pm\)0.003) & 0.850(\(\pm\)0.003) & 0.874(\(\pm\)0.003) & 0.844(\(\pm\)0.007) & 0.907(\(\pm\)0.020) \\ & \(L_{1}\) & 0.859(\(\pm\)0.004) & 0.880(\(\pm\)0.008) & 0.846(\(\pm\)0.005) & 0.838(\(\pm\)0.003) & 0.892(\(\pm\)0.021) \\ & \(L_{2}\) & 0.878(\(\pm\)0.028) & 0.890(\(\pm\)0.038) & 0.831(\(\pm\)0.006) & 0.914(\(\pm\)0.041) & 0.796(\(\pm\)0.004) \\ & Dropout & 0.908(\(\pm\)0.003) & **0.942(\(\pm\)0.024)** & 0.862(\(\pm\)0.002) & 0.918(\(\pm\)0.043) & 0.804(\(\pm\)0.004) \\ & LR & & & 0.834(\(\pm\)0.004) & & \\ \hline \multirow{7}{*}{Test AUC} & BinMask & **0.834(\(\pm\)0.004)** & 0.832(\(\pm\)0.007) & 0.830(\(\pm\)0.007) & 0.830(\(\pm\)0.010) & 0.815(\(\pm\)0.009) \\ & \(L_{1}\) & **0.836(\(\pm\)0.007)** & 0.832(\(\pm\)0.007) & 0.831(\(\pm\)0.007) & 0.828(\(\pm\)0.007) & 0.823(\(\pm\)0.010) \\ & \(L_{2}\) & 0.820(\(\pm\)0.008) & 0.819(\(\pm\)0.009) & 0.816(\(\pm\)0.007) & 0.814(\(\pm\)0.017) & 0.793(\(\pm\)0.008) \\ & Dropout & 0.827(\(\pm\)0.006) & 0.824(\(\pm\)0.008) & 0.824(\(\pm\)0.006) & 0.820(\(\pm\)0.012) & 0.798(\(\pm\)0.007) \\ & LR & & & 0.819(\(\pm\)0.008) & & \\ \hline \multirow{7}{*}{Mean weight \(L_{0}\)} & BinMask & 0.018(\(\pm\)0.001) & 0.013(\(\pm\)0.001) & 0.027(\(\pm\)0.001) & 0.010(\(\pm\)0.001) & 0.178(\(\pm\)0.277) \\ & \(L_{1}\) & 0.071(\(\pm\)0.006) & 0.161(\(\pm\)0.073) & 0.044(\(\pm\)0.006) & 0.037(\(\pm\)0.002) & 0.966(\(\pm\)0.007) \\ & \(L_{2}\) & 0.999(\(\pm\)0.000) & 0.999(\(\pm\)0.000) & 0.967(\(\pm\)0.002) & 0.995(\(\pm\)0.001) & 0.960(\(\pm\)0.004) \\ & Dropout & 0.999(\(\pm\)0.000) & 0.999(\(\pm\)0.000) & 0.999(\(\pm\)0.000) & 0.999(\(\pm\)0.000) & 0.999(\(\pm\)0.000) \\ \hline \multirow{7}{*}{Mean weight \(L_{1}\)} & BinMask & 0.005(\(\pm\)0.000) & 0.003(\(\pm\)0.000) & 0.007(\(\pm\)0.000) & 0.003(\(\pm\)0.000) & 0.020(\(\pm\)0.009) \\ & \(L_{1}\) & 0.001(\(\pm\)0.000) & 0.002(\(\pm\)0.000) & 0.000(\(\pm\)0.000) & 0.000(\(\pm\)0.000) & 0.017(\(\pm\)0.001) \\ & \(L_{2}\) & 0.051(\(\pm\)0.009) & 0.056(\(\pm\)0.011) & 0.002(\(\pm\)0.000) & 0.017(\(\pm\)0.003) & 0.002(\(\pm\)0.000) \\ & Dropout & 0.118(\(\pm\)0.001) & 0.134(\(\pm\)0.007) & 0.103(\(\pm\)0.001) & 0.096(\(\pm\)0.020) & 0.088(\(\pm\)0.001) \\ \hline \multirow{7}{*}{Mean weight \(L_{2}\)} & BinMask & 0.044(\(\pm\)0.001) & 0.038(\(\pm\)0.001) & 0.055(\(\pm\)0.001) & 0.034(\(\pm\)0.001) & 0.077(\(\pm\)0.006) \\ & \(L_{1}\) & 0.009(\(\pm\)0.000) & 0.014(\(\pm\)0.000) & 0.006(\(\pm\)0.001) & 0.005(\(\pm\)0.000) & 0.039(\(\pm\)0.003) \\ & \(L_{2}\) & 0.068(\(\pm\)0.012) & 0.073(\(\pm\)0.014) & 0.004(\(\pm\)0.000) & 0.023(\(\pm\)0.003) & 0.003(\(\pm\)0.000) \\ & Dropout & 0.156(\(\pm\)0.001) & 0.176(\(\pm\)0.009) & 0.136(\(\pm\)0.001) & 0.125(\(\pm\)0.026) & 0.115(\(\pm\)0.001) \\ \hline \multicolumn{7}{l}{Notes:} \\ \multicolumn{7}{l}{* Columns are sorted by the test AUCs of each method.} \\ \multicolumn{7}{l}{* Bracketed numbers are 95% CI computed over eight trials.} \\ \multicolumn{7}{l}{* LR is logistic regression.} \\ \multicolumn{7}{l}{* Mean weight \(L_{0}\) is the fraction of weights whose absolute value is at least 10\({}^{-4}\).} \\ \multicolumn{7}{l}{* Let \(\mathbf{W}\in\mathbb{R}^{n}\) be the flattened weight. For \(p\geq 1\), mean weight \(L_{p}\) is \(\left(\frac{
## 5 Conclusion
This paper revisits a straightforward formulation, BinMask, for \(L_{0}\) regularization of neural networks. The critical insight is decoupled optimization of weights and binary masks. The binary mask is optimized via the identity straight-through estimator and the Adam optimizer, which are widely accepted choices for training binarized neural networks. We demonstrate competitive performance of BinMask on diverse benchmarks, including feature selection, network sparsification, and model regularization, without task-specific hyperparameter tuning.
|
2305.09779 | A Scalable Walsh-Hadamard Regularizer to Overcome the Low-degree
Spectral Bias of Neural Networks | Despite the capacity of neural nets to learn arbitrary functions, models
trained through gradient descent often exhibit a bias towards ``simpler''
functions. Various notions of simplicity have been introduced to characterize
this behavior. Here, we focus on the case of neural networks with discrete
(zero-one), high-dimensional, inputs through the lens of their Fourier
(Walsh-Hadamard) transforms, where the notion of simplicity can be captured
through the degree of the Fourier coefficients. We empirically show that neural
networks have a tendency to learn lower-degree frequencies. We show how this
spectral bias towards low-degree frequencies can in fact hurt the neural
network's generalization on real-world datasets. To remedy this we propose a
new scalable functional regularization scheme that aids the neural network to
learn higher degree frequencies. Our regularizer also helps avoid erroneous
identification of low-degree frequencies, which further improves
generalization. We extensively evaluate our regularizer on synthetic datasets
to gain insights into its behavior. Finally, we show significantly improved
generalization on four different datasets compared to standard neural networks
and other relevant baselines. | Ali Gorji, Andisheh Amrollahi, Andreas Krause | 2023-05-16T20:06:01Z | http://arxiv.org/abs/2305.09779v2 | # A Scalable Walsh-Hadamard Regularizer to Overcome the
###### Abstract
Despite the capacity of neural nets to learn arbitrary functions, models trained through gradient descent often exhibit a bias towards "simpler" functions. Various notions of simplicity have been introduced to characterize this behavior. Here, we focus on the case of neural networks with discrete (zero-one), high-dimensional, inputs through the lens of their Fourier (Walsh-Hadamard) transforms, where the notion of simplicity can be captured through the _degree_ of the Fourier coefficients. We empirically show that neural networks have a tendency to learn lower-degree frequencies. We show how this spectral bias towards low-degree frequencies can in fact _hurt_ the neural network's generalization on real-world datasets. To remedy this we propose a new scalable functional regularization scheme that aids the neural network to learn higher degree frequencies. Our regularizer also helps avoid erroneous identification of low-degree frequencies, which further improves generalization. We extensively evaluate our regularizer on synthetic datasets to gain insights into its behavior. Finally, we show significantly improved generalization on four different datasets compared to standard neural networks and other relevant baselines.
## 1 Introduction
Classical work on neural networks shows that deep fully connected neural networks have the capacity to approximate arbitrary functions (Hornik et al., 1989; Cybenko, 1989). However, in practice, neural networks trained through (stochastic) gradient descent have a "simplicity" bias. This notion of simplicity is not agreed upon and works such as (Arpit et al., 2017; Nakkiran et al., 2019; Valle-Perez et al., 2019; Kalimeris et al., 2019) each introduce a different notion of "simplicity". The simplicity bias can also be studied by considering the function the neural net represents (function space view) and modeling it as Gaussian processes (GP)(Rasmussen, 2004). Daniely et al. (2016); Lee et al. (2018) show that a wide, randomly initialized, neural network in function space is a sample from a GP with a kernel called the "Conjugate Kernel" (Daniely, 2017). Moreover, the evolution of gradient descent on a randomly initialized neural network can be described through the "Neural Tangent Kernel" Jacot et al. (2018); Lee et al. (2019). These works open up the road for analyzing the simplicity bias of neural nets in terms of a _spectral_ bias in Fourier space. Rahaman et al. (2019) show empirically that neural networks tend to learn sinusoids of lower frequencies earlier on in the training phase compared to those of higher frequencies. Through the GP perspective introduced by Jacot et al. (2018); Lee et al. (2019), among others, Ronen et al. (2019); Basri et al. (2020) were able to prove these empirical findings. These results focus on _continuous_ domains and mainly emphasize the case where the input and output are both _one-dimensional_.
Here, we focus on _discrete_ domains where the input is a _high-dimensional_ zero-one vector and we analyze the function learned by the neural network in terms of the amount of interactions among its input features in a quantitative manner. Our work is complementary to the majority of the aforementioned work that has been done on the spectral bias of neural networks in the setting of _continuous_, _one-dimensional_ inputs (Ronen et al., 2019; Basri et al., 2020; Rahaman et al., 2019). Yang and Salman (2020), Valle-Perez et al. (2019) are the first to provide spectral bias results for the discrete, higher dimensional, setting (our setting). By viewing a fully connected neural network as a function that maps zero-one vectors to real values, one can expand this function in terms of the Fourier -a.k.a Walsh-Hadamard - basis functions. The Walsh-Hadamard basis functions have a natural ordering in terms of their complexity called their
_degree_. The degree specifies how many features each basis function is dependent upon. For example, the zero-degree basis function is the constant function and the degree-one basis functions are functions that depend on exactly one feature. Through analysis of the NTK gram matrix on the Boolean cube, Yang and Salman (2020) theoretically show that, roughly speaking, neural networks learn the lower degree basis functions earlier in training.
This tendency to prioritize simpler functions in neural networks has been suggested as a cardinal reason for their remarkable generalization ability despite their over-parameterized nature (Neyshabur et al., 2017; Arpit et al., 2017; Kalimeris et al., 2019; Poggio et al., 2018). However, much less attention has been given to the case where the simplicity bias can _hurt_ generalization (Tancik et al., 2020; Shah et al., 2020). Tancik et al. (2020) show how transforming the features with random Fourier features embedding helps the neural network overcome its spectral bias and achieve better performance in a variety of tasks. They were able to explain, in a unified way, many empirical findings in computer vision research such as sinusoidal positional embeddings through the lens of overcoming the spectral bias. In the same spirit as these works, we show that the spectral bias towards low-degree functions can hurt generalization and how to remedy this through our proposed regularizer.
In more recent lines of work, regularization schemes have been proposed to directly impose priors on the function the neural network represents (Benjamin et al., 2019; Sun et al., 2019; Wang et al., 2019). This is in contrast to other methods such as dropout, batch normalization, or other methods that regularize the weight space. In this work, we also regularize neural networks in function space by imposing sparsity constraints on their Walsh-Hadamard transform. Closest to ours is the work of Aghazadeh et al. (2021). Inspired by studies showing that biological landscapes are sparse and contain high-degree frequencies (Sailer and Harms, 2017; Yang et al., 2019; Brookes et al., 2022; Ballal et al., 2020; Poelwijk et al., 2019), they propose a functional regularizer to enforce sparsity in the Fourier domain and report improvements in generalization scores.
**Our contributions:**
* We analyze the spectral behavior of a simple MLP during training through extensive experiments. We show that the standard (unregularized) network not only is unable to learn (more complex) high-degree frequencies but it also starts learning erroneous low-degree frequencies and hence overfitting on this part of the spectrum.
* HashWH (Hashed Walsh Hadamard)
- to remedy the aforementioned phenomenon. The regularizer acts as a "sparsifier" on the Fourier (Walsh-Hadamard) basis. In the most extreme cases, it reduces to simply imposing an \(L_{1}\)-norm on the Fourier transform of the neural network. Since computing the exact Fourier transform of the neural net is intractable, our regularizer hashes the Fourier coefficients to buckets and imposes an L1 norm on the buckets. By controlling the number of hash buckets, it offers a smooth trade-off between computational complexity and the quality of regularization.
* We empirically show that HashWH aids the neural network in avoiding erroneous low-degree frequencies and also learning relevant high-degree frequencies. The regularizer guides the training procedure to allocate more energy to the high-frequency part of the spectrum when needed and allocate less energy to the lower frequencies when they are not present in the dataset.
* We show on real-world datasets that, contrary to popular belief of simplicity biases for neural networks, fitting a low degree function does not imply better generalization. Rather, what is more important, is keeping the _higher amplitude_ coefficients regardless of their degree. We use our regularizer on four real-world datasets and provide state of the art results in terms of \(R^{2}\) score compared to standard neural networks and other baseline ML models, especially for the low-data regime.
## 2 Background
In this section, we first review Walsh Hadamard transforms, and notions of degree and sparsity in the Fourier (Walsh-Hadamard) domain (O'Donnell, 2014). Next, we review the notion of simplicity biases in neural networks and discuss why they are spectrally biased toward low-degree functions.
### Walsh Hadamard transforms
Let \(g:\{0,1\}^{n}\rightarrow\mathbb{R}\) be a function mapping Boolean zero-one vectors to the real numbers, also known as a "pseudo-boolean" function. The family of \(2^{n}\) functions \(\{\Psi_{f}:\{0,1\}^{n}\rightarrow\mathbb{R}\,|f\in\{0,1\}^{n}\}\) defined below consists of the Fourier basis functions. This family forms a basis over the vector space of all pseudo-boolean functions:
\[\Psi_{f}(x)=\frac{1}{\sqrt{2^{n}}}(-1)^{\langle f,x\rangle},f,x\in\{0,1\}^{n}\]
where \(\langle f,x\rangle=\sum_{i}f_{i}x_{i}\). Here, \(f\in\{0,1\}^{n}\) is called the _frequency_ of the basis function. For any frequency \(f\in\{0,1\}^{n}\) we denote its _degree_ by \(\text{deg}(f)\) which is defined as the number of non-zero elements. For example, \(f_{1}=[0,0,0,0,0]\) and \(f_{2}=[0,0,1,0,1]\) have degrees \(\text{deg}(f_{1})=0\) and \(\text{deg}(f_{2})=2\), respectively. One can think of the degree as a measure of the complexity of basis functions. For example, \(\Psi_{0}(x)\) is constant, and \(\Psi_{e_{i}}(x)\) where \(e_{i}\) is a standard basis vector (\(\text{deg}(e_{i})=1\)) only depends on feature \(i\) of the input. It is equal to \(+1\) when feature \(i\) is zero and equal to \(-1\) when feature \(i\) is one. More generally, a degree \(d\) basis function depends on exactly \(d\) input features.
Since the Fourier basis functions form a basis for the vector space of all pseudo-boolean functions, any function \(g:\{0,1\}^{n}\rightarrow\mathbb{R}\) can be written as a unique linear combination of these basis functions:
\[g(x)=\frac{1}{\sqrt{2^{n}}}\sum_{f\in\{0,1\}^{n}}\widehat{g}(f)(-1)^{\langle f, x\rangle}\]
The (unique) coefficients \(\widehat{g}(f)\) are called the "Fourier coefficients" or "Fourier amplitudes" and are computed as \(\widehat{g}(f)=\frac{1}{\sqrt{2^{n}}}\sum\limits_{x\in\{0,1\}^{n}}g(x)(-1)^{ \langle f,x\rangle}\). The _Fourier spectrum_ of \(g\) is the vector consisting of all of its \(2^{n}\) Fourier coefficients, which we denote by the bold symbol \(\widehat{\mathbf{g}}\in\mathbb{R}^{2^{n}}\). Assume \(\mathbf{X}\in\{0,1\}^{2^{n}\times n}\) to be the matrix of an enumeration over all possible \(n\)-dimensional binary sequences (\(\{0,1\}^{n}\)), and \(\mathbf{g}(\mathbf{X})\in\mathbb{R}^{2^{n}}\) to be the vector of \(g\) evaluated on the rows of \(\mathbf{X}\). We can compute the Fourier spectrum using Walsh-Hadamard transform as \(\widehat{\mathbf{g}}=\frac{1}{\sqrt{2^{n}}}\mathbf{H}_{n}\mathbf{g}(\mathbf{X})\), where \(\mathbf{H}_{n}\in\{\pm 1\}^{2^{n}\times 2^{n}}\) is the orthogonal Hadamard matrix (see Appendix A).
Lastly, we define the _support_ of \(g\) as the set of frequencies with non-zero Fourier amplitudes \(\text{supp}(g):=\{f\in\{0,1\}^{n}|\widehat{g}(f)\neq 0\}\). The function \(g\) is called \(k\)-_sparse_ if \(|\text{supp}(g)|\leq k\). The function \(g\) is called _of degree_\(d\) if all frequencies in its support have degree at most \(d\).
### Spectral Bias Theory
The function that a ReLU neural network represents at initialization can be seen as a sample from a GP \(N(0,K)\) in the infinite width limit (Daniely et al., 2016; Lee et al., 2018) (randomness is over the initialization of the weights and biases). The kernel \(K\) of the GP is called the "Conjugate Kernel" (Daniely et al., 2016) or the "nn-GP kernel" (Lee et al., 2018). Let the kernel Gram matrix \(\mathcal{K}\) be formed by evaluating the kernel on the Boolean cube i.e. \(\{0,1\}^{n}\) and let \(\mathcal{K}\) have the following spectral decomposition: \(\mathcal{K}=\sum\limits_{i=1}^{2^{n}}\lambda_{i}u_{i}u_{i}^{\top}\), where we assume that the eigenvalues \(\lambda_{1}\geq\cdots\geq\lambda_{2^{n}}\) are in decreasing order. Each sample of the GP can be obtained as \(\sum\limits_{i=1}^{2^{n}}\lambda_{i}\mathbf{w_{i}}u_{i},\mathbf{w_{i}}\sim\mathcal{N}( 0,1)\). Say that \(\lambda_{1}\gg\sum_{i\geq 2}\lambda_{i}\). Then a sample from the GP will, roughly speaking, look very much like \(u_{1}\).
Let \(u_{f},f\in\{0,1\}^{n}\) be obtained by evaluating the Fourier basis function \(\Psi_{f}\) at the \(2^{n}\) possible inputs on \(\{0,1\}^{n}\). Yang and Salman (2020) show that \(u_{f}\) is a eigenvector for \(\mathcal{K}\). Moreover, they show (weak) spectral bias results in terms of the degree of \(f\). Namely, the eigenvalues corresponding to higher degrees have smaller values 1. The result is _weak_ as they do not provide a _rate_ as to which the eigenvalues decrease with increasing degrees. Their results show that neural networks are similar to low-degree functions at initialization.
Footnote 1: To be more precise, they show that the eigenvalues corresponding to even and odd degree frequencies form decreasing sequences. That is, even and odd degrees are considered separately.
Other works show that in infinite-width neural networks weights after training via (stochastic) gradient descent do not end up too far from the initialization (Chizat et al., 2019; Jacot et al., 2018; Du et al., 2019; Allen-Zhu et al., 2019, 2019), referred to as "lazy training" by Chizat et al. (2019). Lee et al. (2018, 2019) show that training the last layer of a randomly initialized neural network via full batch gradient descent for an infinite amount of time corresponds to GP posterior inference with the kernel \(K\). Jacot et al. (2018); Lee et al. (2019) proved that when training _all_ the layers of a neural network (not just the final layer), the evolution can be described by a kernel called the "Neural Tangent Kernel" and the trained network yields the mean prediction of GP \(N(0,K_{NTK})\)(Yang and Salman, 2020) after an infinite amount of time. Yang and Salman (2020) again show that \(u_{f}\) are eigenvectors and weak spectral bias holds. Furthermore, Yang and Salman (2020) provides empirical results for the generalization of neural nets of different depths on datasets arising from \(k=1\)-sparse functions of varying degrees.
## 3 Low-degree Spectral Bias
In this section, we conduct experiments on synthetically generated datasets to show neural networks' spectral bias and their preference toward learning lower-degree functions over higher-degree ones. Firstly, we show that the neural network is not able to pick up the high-degree frequency components. Secondly, it can learn erroneous lower-degree frequency components. To address these issues, in Section 4, we introduce our regularization scheme called HashWH (Hashed Walsh Hadamard) and demonstrate how it can remedy both problems.
### Fourier Spectrum Evolution
We analyze the evolution of the function learned by neural networks during training. We train a neural network on a dataset arising from a synthetically generated sparse function with a low-dimensional input domain. Since the input is low-dimensional it allows us to calculate the Fourier spectrum of the network (exactly) at the end of each epoch.
**Setup.** Let \(g^{*}:\{0,1\}^{10}\rightarrow\mathbb{R}\) be a synthetic function with five frequencies in its support with degrees 1 to 5 (\(\text{supp}(g^{*})=\{f_{1},f_{2},f_{3},f_{4},f_{5}\},\text{deg}(f_{i})=i\)), all having equal Fourier amplitudes of \(\widehat{g}^{*}(f_{i})=1\). Each \(f_{i}\) is sampled uniformly at random from all possible frequencies of degree \(i\). The training set is formed by drawing uniform samples from the Boolean cube \(x\sim\mathcal{U}_{\{0,1\}^{10}}\) and evaluating \(g^{*}(x)\).
We draw five such target functions \(g^{*}\) (with random support frequencies). For each draw of the target function, we create five different datasets all with 200 training points and sampled uniformly from the input domain but with different random seeds. We then train a standard five-layer fully connected neural network using five different random seeds for the randomness in the training procedure (such as initialization weights and SGD). We aggregate the results over the \(125\) experiments by averaging. We experiment the same setting with three other training set sizes. Results with training set size other than 200 and further setup details are reported in Appendices F.1 and D, respectively.
**Results.** We first inspect the evolution of the learned Fourier spectrum over different epochs and limited to the target support (\(\text{supp}(g^{*})\)). Figure 0(a) shows the learned amplitudes for frequencies in the target support at each training epoch. Aligned with the literature on simplicity bias [22, 23], we observe that neural networks learn the low-degree frequencies earlier in the epochs. Moreover, we can see in the left-most figure in Figure 0(a) that despite eventually learning low-degree frequencies, the standard network is unable to learn high-degree frequencies.
Next, we expand the investigation to the whole Fourier spectrum instead of just focusing on the support frequencies. The first row of Figure 0(b) shows the evolution of the Fourier spectrum during training and compares it to the spectrum of the target function on the bottom row. We average the spectrum linked to one of the five target synthetic functions (over the randomness of the dataset sampling and training procedure) and report the other four in Appendix F.1. We observe that in addition to the network not being able to learn the high-degree frequencies, the standard network is prone to learning incorrect low-degree frequencies as well.
## 4 Overcoming the Spectral Bias via Regularization
Now, we introduce our regularization scheme HashWH (Hashed Walsh-Hadamard). Our regularizer is essentially a "sparsifier" in the Fourier domain. That is, it guides the neural network to have a sparse Fourier spectrum. We empirically show later how sparsifying the Fourier spectrum can both stop the network from learning erroneous low-degree frequencies and aid it in learning the higher-degree ones, hence remedying the two aforementioned problems.
Assume \(\mathcal{L}_{net}\) is the loss function that a standard neural network minimizes, e.g., the MSE loss in the above case. We modify it by adding a regularization term \(\lambda\mathcal{L}_{sparsity}\)
Figure 1: Evolution of the Fourier spectrum during training. Standard is the unregularized neural network. FullWH imposes \(L_{1}\)-norm regularization on the exact Fourier spectrum and is intractable. EN-S alternates between computing a sparse Fourier approximation (computationally very expensive) and regularization. HashWH (ours) imposes \(L_{1}\) regularization on the hashed spectrum. Figure (a) is limited to the target support. The standard neural network is unable to learn higher degree frequencies. Our regularizer fixes this. Figure (b) is on the whole spectrum. The standard neural network picks up erroneous low-degree frequencies while not being able to learn the higher-degree frequencies. Our regularizer fixes both problems.
Hence the total loss is given by: \(\mathcal{L}=\mathcal{L}_{net}+\lambda\mathcal{L}_{sparsity}\).
The most intuitive choice is \(\mathcal{L}_{sparsity}=\|\widehat{\mathbf{g_{N}}}\|_{0}\), where \(\widehat{\mathbf{g_{N}}}\) is the Fourier spectrum of the neural network function \(g_{N}:\{0,1\}^{n}\rightarrow\mathbb{R}\). Since the \(L_{0}\)-penalty's derivative is zero almost everywhere, one can use its tightest convex relaxation, the \(L_{1}\)-norm, which is also sparsity-inducing, as a surrogate loss. Aghazadeh et al. (2021) use this idea and name it as Epistatic-Net or "EN" regularization: \(\mathcal{L}_{EN}:=\mathcal{L}_{net}+\lambda\|\widehat{\mathbf{g_{N}}}\|_{1}\). In this work, we call this regularization FullWH (Full Walsh Hadamard transform).
FullWH requires the evaluation of the network output on all \(2^{n}\) possible inputs at each iteration of back-prop. Therefore, the computational complexity grows _exponentially_ with the number of dimensions \(n\), making it computationally intractable for \(n>20\) in all settings of practical importance.
Aghazadeh et al. (2021) also suggest a more scalable version of FullWH, called "EN-S", which roughly speaking, alternates between computing the sparse _approximate_ Fourier transform of the network at the end of each epoch and doing normal back-prop, as opposed to the exact computation of the exact Fourier spectrum when back-propagating the gradients. In our experiments, we show EN-S can be computationally expensive because the sparse Fourier approximation primitive can be time-consuming. For a comprehensive comparison see Appendix B.3. Later, we show that empirically, it is also less effective in overcoming the spectral bias as measured by achievable final generalization error.
### Hashwh
We avoid the exponentially complex burden of computing the exact Fourier spectrum of the network by employing a hashing technique to approximate the regularization term \(\lambda\|\widehat{\mathbf{g_{N}}}\|_{1}\). Let \(g:\{0,1\}^{n}\rightarrow\mathbb{R}\) be a pseudo-boolean function. We define the lower dimensional function \(u_{\sigma}:\{0,1\}^{b}\rightarrow\mathbb{R}\), where \(b\ll n\), by sub-sampling \(g\) on its domain: \(u_{\sigma}(\tilde{x})\triangleq\sqrt{\frac{2^{n}}{2^{b}}}\;g(\sigma\tilde{x}), \;\tilde{x}\in\{0,1\}^{b}\) where \(\sigma\in\{0,1\}^{n\times b}\) is some matrix which we call the _hashing matrix_. The matrix-vector multiplication \(\sigma\tilde{x}\)is taken modulo 2. \(u_{\sigma}\) is defined by sub-sampling \(g\) on all the points lying on the (at most) \(b\)-dimensional subspace spanned by the columns of the hashing matrix \(\sigma\). The special property of sub-sampling the input space from this subspace is in the arising Fourier transform of \(u_{\sigma}\) which we will explain next.
The Fourier transform of \(u_{\sigma}\) can be derived as (see Appendix B.1):
\[\widehat{u}_{\sigma}(\tilde{f})=\sum_{f\in\{0,1\}^{n}:\;\sigma^{\top}f=\tilde {f}}\widehat{g}(f),\;\tilde{f}\in\{0,1\}^{b} \tag{1}\]
One can view \(\widehat{u}_{\sigma}(\tilde{f})\) as a "bucket" containing the sum of all Fourier coefficients \(\widehat{g}(\tilde{f})\) that are "hashed" (mapped) into it by the linear hashing function \(h(f)=\sigma^{\top}f\). There are \(2^{b}\) such buckets and each bucket contains frequencies lying in the kernel (null space) of the hashing map plus some shift.
In practice, we let \(\sigma\sim\mathcal{U}_{\{0,1\}^{n\times b}}\) be a uniformly sampled hash matrix that is re-sampled after each iteration of back-prop. Let \(\mathbf{X}_{b}\in\{0,1\}^{2^{b}\times b}\) be a matrix containing as rows the enumeration over all points on the Boolean cube \(\{0,1\}^{b}\). Our regularization term approximates (4) and is given by:
\[\mathcal{L}_{\text{{\sc HashWH}}}\triangleq\mathcal{L}_{net}+\lambda\| \mathbf{H}_{b}\mathbf{g_{N}}(\mathbf{X}_{b}\sigma^{T})\|_{1}=\mathcal{L}_{net} +\lambda\|\widehat{\mathbf{u_{\sigma}}}\|_{1}\]
That is, instead of imposing the \(L_{1}\)-norm directly on the whole spectrum, this procedure imposes the norm on the "bucketed" (or partitioned) spectrum where each bucket (partition) contains sums of coefficients mapped to it. The larger \(b\) is the more partitions we have and the finer-grained the sparsity-inducing procedure is. Therefore, the quality of the approximation can be controlled by the choice of \(b\). Larger \(b\) allows for a finer-grained regularization but, of course, comes at a higher computational cost because a Walsh-Hadamard transform is computed for a higher dimensional sub-sampled function \(u\). Note that \(b=n\) corresponds to hashing to \(2^{n}\) buckets. As long as the hashing matrix is invertible, this precisely is the case of FullWH regularization.
The problem with the above procedure arises when, for example, two "important" frequencies \(f_{1}\) and \(f_{2}\) are hashed into the same bucket, i.e., \(\sigma^{\top}f_{1}=\sigma^{\top}f_{2}\), an event which we call a "collision". This can be problematic when the absolute values \(|\widehat{g}(f_{1})|\) and \(|\widehat{g}(f_{2})|\) are large (hence they are important frequencies) but their sum can cancel out due to differing signs. In this case, the hashing procedure can zero out the sum of these coefficients. We can reduce the probability of a collision by increasing the number of buckets, i.e., increasing \(b\)(Alon et al., 1999).
In Appendix B.2 we show that the expected number of collisions \(C\) is given by: \(\mathbb{E}[C]=\frac{(k-1)^{2}}{2^{b}}\) which decreases linearly with the number of buckets \(2^{b}\). Furthermore, we can upper bound the probability \(p\) that a given important frequency \(f_{i}\) collides with any other of the \(k-1\) important frequencies in one round of hashing. Since we are independently sampling a new hashing matrix \(\sigma\) at each round of back-prop, the number of collisions of a given frequency over the different rounds has a binomial distribution. In Appendix B.2 we show that picking \(b\geq\log_{2}(\frac{k-1}{\epsilon}),\epsilon>0\) guarantees that collision of a given frequency happens approx. an \(\epsilon\)-fraction of the \(T\) rounds, and not much more.
**Fourier spectrum evolution of different regularization methods.** We analyze the effect of regularizing the network with various Fourier sparsity regularizers in the setting of the previous section. Our regularizers of interest are FullWH, EN-S with \(m=5\) (\(2^{m}\) is the number of buckets their sparse Fourier approximation algorithm hashes into), and HashWH with \(b\in\{5,7,8\}\).
Returning to Figure 0(a), we see that despite the inability of
the standard neural network in picking up the _high-degree_ frequencies, all sparsity-inducing regularization methods display the capacity for learning them. FullWH is capable of perfectly learning the entire target support. It can also be seen that increasing the size of the hashing matrix in HashWH (ours) boosts the learning of high-degree frequencies. Furthermore, Figure 0(b) shows that in addition to the better performance of the sparsity-inducing methods in learning the target support, they are also better at filtering out non-relevant _low-degree_ frequencies.
We define a notion of approximation error which is basically the normalized energy of the error in the learned Fourier spectrum on an arbitrary subset of frequencies.
**Metric 4.1** (Spectral Approximation Error (SAE)).: _Let \(g_{N}:\{0,1\}^{n}\rightarrow\mathbb{R}\) be an approximation of the target function \(g^{*}:\{0,1\}^{n}\rightarrow\mathbb{R}\). Consider a subset of frequencies \(S\subseteq\{0,1\}^{n}\), and assume \(\widehat{\mathfrak{s}}_{\text{NS}}\) and \(\widehat{\mathfrak{s}^{*}}_{S}\) to be the vector of Fourier coefficients of frequencies in \(S\), for \(g_{N}\) and \(g^{*}\) respectively. As a measure of the distance between \(g_{N}\) and \(g\) on the subset of frequencies \(S\), we define Spectral Approximation Error as: SAE\(=\frac{\|\widehat{\mathfrak{s}}_{\text{NS}}-\widehat{\mathfrak{s}^{*}}_{S}\|_{2}^{2}}{\| \widehat{\mathfrak{s}^{*}}_{S}\|_{2}^{2}}\)_
Figure 2 shows the SAE of the trained network using different regularization methods over epochs, for both when \(S\) is target support as well as when \(S=\{0,1\}^{n}\) (whole Fourier spectrum). The standard network displays a significantly higher (worse) SAE on the whole Fourier spectrum compared to the target support, while Walsh-Hadamard regularizers exhibit consistent performance across both. This shows the importance of enforcing the neural network to have zero Fourier coefficients on the non-target frequencies. Moreover, we can see HashWH (ours) leads to a reduction in SAE that can be smoothly controlled by the size of its hashing matrix.
To gain more insight, we split the frequencies into subsets \(S\) consisting of frequencies with the same degree. We visualize the evolution of SAE and also the Fourier energy of the network defined as \(\|\widehat{\mathfrak{s}}_{\text{NS}}\|_{2}^{2}\) in Figure 3. Firstly, the energy of high-degree frequencies is essentially zero for the standard neural network when compared to the low-degree frequencies, which further substantiates the claim that standard neural network training does not learn any high-degree frequencies. We can see that our HashWH regularization scheme helps the neural network learn higher degree frequencies as there is more energy in the high degree components. Secondly, looking at the lower degrees 2 and 3 we can see that the standard neural network reduces the SAE up to some point but then starts overfitting. Looking at the energy plot one can attribute the overfitting to picking up irrelevant degree 2 and 3 frequencies. We see that the regularization scheme helps prevent the neural net from overfitting on the low-degree frequencies and their SAE reduces roughly monotonously. We observe that HashWH (ours) with a big enough hashing matrix size exhibits the best performance among tractable methods in terms of SAE on all degrees. Finally, we can see HashWH is distributing the energy to where it should be for this dataset: less in the low-degree and more in the high-degree frequencies.
Finally, it is worth noting that our regularizer makes the neural network behave more like a _decision tree_. It is well known that ensembles of decision tree models have a sparse and low-degree Fourier transform [11]. Namely, let \(g:\{0,1\}^{n}\rightarrow\mathbb{R}\) be a function that can be represented as an ensemble of \(T\) trees each of depth at most \(d\). Then \(g\) is \(k=O(T\cdot 4^{d})\)-sparse and of degree at most \(d\) (Appendix E.1). Importantly, their spectrum is _exactly sparse_ and unlike standard neural networks, which seem to "fill up" the spectrum on the low-degree end, i.e., learn irrelevant low-degree coefficients, decision trees avoid this. Decision trees are well-known to be effective on discrete/tabular data [1], and our regularizer prunes the spectrum of the neural network so it behaves similarly.
## 5 Experiments
In this section, we first evaluate our regularization method on higher dimensional input spaces (higher \(n\)) on synthetically generated datasets. In this setting, FullWH is not applicable due to its exponential runtime in \(n\). In addition, we allow varying training set sizes to showcase the efficacy of the regularizer in improving generalization at varying levels in terms of the number of training points in the dataset and especially in the low-data sample regime. Next, we move on to four real-world datasets. We first show the efficacy of our proposed regularizer hashWH on real-world datasets in terms of achieving better generalization errors, especially in the low-data sample regimes. Finally, using an ablation
Figure 2: Evolution of the spectral approximation error during training. The left plot limits the error to the target support, while the right one considers the whole Fourier spectrum. For the standard neural network, the SAE is considerably worse on the full spectrum which shows the importance of eliminating the erroneous frequencies that are not in the support of the target function. We also see the graceful scaling of SAE of HashWH (ours) with the hashing matrix size.
study, we experimentally convey that the low-degree bias does not result in lower generalization error.
### Synthetic Data
**Setup.** Again, we consider a synthetic pseudo-boolean target function \(g^{*}:\{0,1\}^{n}\rightarrow\mathbb{R}\), which has \(25\) frequencies in its support \(|\text{supp}(g^{*})|=25\), with the degree of maximum five, i.e., \(\forall f\in\text{supp}(g^{*}):\text{deg}(f)\leq 5\). To draw a \(g^{*}\), we sample each of its support frequencies \(f_{i}\) by first uniformly sampling its degree \(d\sim\mathcal{U}_{\{1,2,3,4,5\}}\), based on which we then sample \(f_{i}\sim\{f\in\{0,1\}^{n}|\text{deg}(f)=d\}\) and its corresponding amplitude uniformly \(\widehat{g^{*}}(f_{i})\sim\mathcal{U}_{[-1,1]}\).
We draw \(g^{*}\) as above for different input dimensions \(n\in\{25,50,100\}\). We pick points uniformly at random from the input domain \(\{0,1\}^{n}\) and evaluate \(g^{*}\) to generate datasets of various sizes: we generate five independently sampled datasets of size \(c\cdot 25n\), for different multipliers \(c\in\{1,..,8\}\) (40 datasets for each \(g^{*}\)). We train a 5-layer fully-connected neural network on each dataset using five different random seeds to account for the randomness in the training procedure. Therefore, for each \(g^{*}\) and dataset size, we train and average over 25 models to capture variance arising from the dataset generation, and also the training procedure.
**Results.** Figure 3(a) shows the generalization performance of different methods in terms of their \(R^{2}\) score on a hold-out dataset (details of dataset splits in Appendix D) for different dataset sizes. Our regularization method, HashWH, outperforms the standard network and EN-S in all possible combinations of input dimension, and dataset size. Here, EN-S does not show any significant improvements over the standard neural network, while HashWH (ours) improves generalization by a large margin. Moreover, its performance is tunable via the hashing matrix size \(b\).
To stress the computational scalability of HashWH (ours), Figure 3(b) shows the achievable \(R^{2}\)-score by the number of training epochs and training time for different methods, when \(n=50\) and \(c=5\) (see Appendix F.2 for other settings). The trade-off between the training time and generalization can be directly controlled with the choice of the hashing size \(b\). More importantly, comparing HashWH with EN-S, we see that for any given \(R^{2}\) we have runtimes that are orders of magnitude smaller. This is primarily due to the very time-consuming approximation of the Fourier transform of the network at each epoch in EN-S.
### Real Data
Next, we assess the performance of our regularization method on four different real-world datasets of varying nature and dimensionality. For baselines, we include not only standard neural networks and EN-S regularization, but also other popular machine learning methods that work well on discrete data, such as ensembles of trees. Three of our datasets are related to protein landscapes [19, 20, 21] which are identical to the ones used by the proposers of EN-S [1], and one is a GPU-tuning [20] dataset. See Appendix C for dataset details.
**Results.** Figure 4(a) displays the generalization performance of different models in learning the four datasets mentioned,
Figure 3: Evolution of the Spectral Approximation Error (SAE) and energy of the network during training, split by frequency degree. Firstly, in a standard neural network, the energy of high-degree frequencies is essentially zero compared to low-degree frequencies. Secondly, for low degrees (2 and 3) the energy continues to increase while the SAE exhibits overfitting behavior. This implies the neural network starts learning erroneous low-degree frequencies after some epochs. Our regularizer prevents overfitting in lower degrees and enforces higher energy on higher-degree frequencies. Regularized networks show lower energies for lower degrees and higher energy for higher degrees when compared to the standard neural network.
using training sets of small sizes. For each given dataset size we randomly sample the original dataset with five different random seeds to account for the randomness of the dataset sub-sampling. Next, we fit five models with different random seeds to account for the randomness of the training procedure. One standard deviation error bars and averages are plotted accordingly over the 25 runs. It can be seen that our regularization method significantly outperforms the standard neural network as well as popular baseline methods on nearly all datasets and dataset sizes. The margin, however, is somewhat smaller than on the synthetic experiments in some cases. This may be partially explained by the distribu
Figure 4: (a) Generalization performance on learning a synthetic function \(g^{*}:\{0,1\}^{n}\rightarrow\mathbb{R}\) with train set size: \(c\cdot 25n\) (b) Best achievable test \(R^{2}\) (I) at end of each epoch (II) up to a certain time (seconds). (III) Shows the early stopped \(R^{2}\) score vs. time (seconds). We provide significant improvements across all training sizes over EN-S and standard neural networks, while also showing an order of magnitude speed-up compared to EN-S.
Figure 5: (a) Generalization performance of standard and regularized neural networks and benchmark ML models on four real datasets. (b) Training times of different models on the GB1 dataset (c) Results of an ablation study on the potential effect of simplicity bias in the generalization error. This figure shows picking higher amplitude coefficients results in better generalization compared to picking the lower degree terms (d) Distribution of the energy over degree-based sets of frequencies in Entacmaea’s top 100 Fourier coefficients. This shows high-degree components constitute a non-negligible portion of the energy of the function.
tion of energy in a real dataset (Figure 5d), compared to the uniform distribution of energy over different degrees in our synthetic setting.
To highlight the importance of higher degree frequencies, we compute the exact Fourier spectrum of the Entacmaea dataset (which is possible, since all possible input combinations are evaluated in the dataset). Figure 5d shows the energy of 100 frequencies with the highest amplitude (out of 8192 total frequencies) categorized into varying degrees. This shows that the energy of the higher degree frequencies 3 and 4 is comparable to frequencies of degree 1. However, as we showed in the previous section, the standard neural network may not be able to pick up the higher degree frequencies due to its simplicity bias (while also learning erroneous low-degree frequencies).
We also study the relationship between the low-degree spectral bias and generalization in Figure 5c. The study is conducted on the two datasets "Entacmaea" and "SGEMM". We first fit a sparse Fourier function to our training data (see Appendix E). We then start deleting coefficients once according to their degree (highest to lowest and ties are broken randomly) and in another setting according to their amplitude (lowest to highest). To assess generalization, we evaluate the \(R^{2}\) of the resulting function on a hold-out (test) dataset. This study shows that among functions of equal complexity (in terms of size of support), functions that keep the higher amplitude frequencies as opposed to ones that keep the low-degree ones exhibit better generalization. This might seem evident according to Parseval's identity, which states that time energy and Fourier energy of a function are equal. However, considering the fact that the dataset distribution is not necessarily uniform, there is no reason for this to hold in practice. Furthermore, it shows the importance of our regularization scheme: deviating from low-degree functions and instead aiding the neural network to learn higher amplitude coefficients _regardless_ of the degree.
**Conclusion** We showed through extensive experiments how neural networks have a tendency to not learn high-degree frequencies and overfit in the low-degree part of the spectrum. We proposed a computationally efficient regularizer that aids the network in not overfitting in the low-degree frequencies and also picking up the high-degree frequencies. Finally, we exhibited significant improvements in terms of \(R^{2}\) score on four real-world datasets compared to various popular models in the low-data regime.
## Acknowledgements
This research was supported in part by the NCCR Catalysis (grant number 180544), a National Centre of Competence in Research funded by the Swiss National Science Foundation. We would also like to thank Lars Lorch and Viacheslav Borovitskiy for their detailed and valuable feedback in writing the paper.
|
2302.01382 | Mixed Precision Post Training Quantization of Neural Networks with
Sensitivity Guided Search | Serving large-scale machine learning (ML) models efficiently and with low
latency has become challenging owing to increasing model size and complexity.
Quantizing models can simultaneously reduce memory and compute requirements,
facilitating their widespread access. However, for large models not all layers
are equally amenable to the same numerical precision and aggressive
quantization can lead to unacceptable loss in model accuracy. One approach to
prevent this accuracy degradation is mixed-precision quantization, which allows
different tensors to be quantized to varying levels of numerical precision,
leveraging the capabilities of modern hardware. Such mixed-precision
quantiztaion can more effectively allocate numerical precision to different
tensors `as needed' to preserve model accuracy while reducing footprint and
compute latency. In this paper, we propose a method to efficiently determine
quantization configurations of different tensors in ML models using
post-training mixed precision quantization. We analyze three sensitivity
metrics and evaluate them for guiding configuration search of two algorithms.
We evaluate our method for computer vision and natural language processing and
demonstrate latency reductions of up to 27.59% and 34.31% compared to the
baseline 16-bit floating point model while guaranteeing no more than 1%
accuracy degradation. | Clemens JS Schaefer, Elfie Guo, Caitlin Stanton, Xiaofan Zhang, Tom Jablin, Navid Lambert-Shirzad, Jian Li, Chiachen Chou, Siddharth Joshi, Yu Emma Wang | 2023-02-02T19:30:00Z | http://arxiv.org/abs/2302.01382v2 | # Mixed Precision Post Training Quantization of Neural Networks with Sensitivity Guided Search
###### Abstract
Serving large-scale machine learning (ML) models efficiently and with low latency has become challenging owing to increasing model size and complexity. Quantizing models can simultaneously reduce memory and compute requirements, facilitating their widespread access. However, for large models not all layers are equally amenable to the same numerical precision and aggressive quantization can lead to unacceptable loss in model accuracy. One approach to prevent this accuracy degradation is mixed-precision quantization, which allows different tensors to be quantized to varying levels of numerical precision, leveraging the capabilities of modern hardware. Such mixed-precision quantiztaion can more effectively allocate numerical precision to different tensors 'as needed' to preserve model accuracy while reducing footprint and compute latency. In this paper, we propose a method to efficiently determine quantization configurations of different tensors in ML models using post-training mixed precision quantization. We analyze three sensitivity metrics and evaluate them for guiding configuration search of two algorithms. We evaluate our method for computer vision and natural language processing and demonstrate latency reductions of up to \(27.59\%\) and \(34.31\%\) compared to the baseline 16-bit floating point model while guaranteeing no more than \(1\%\) accuracy degradation.
Machine Learning, ICML
## 1 Introduction
Neural networks (NNs) are the driving force behind a long series of breakthroughs in artificial intelligence, delivering state-of-the-art performance across a wide range of tasks, most notably in computer vision (Zhai et al., 2022), natural language processing (Brown et al., 2020) and generative models for text (Thoppilan et al., 2022) or images (Ramesh et al., 2021). However, the remarkable capabilities of these state-of-the-art (SOTA) NNs incur substantial compute and memory costs, making them challenging to deploy at scale. These costs are additionally compounded by machine learning (ML) proliferating across a wider range of applications (Jumper et al., 2021). As a result, there is a need
Figure 1: Overview of our results in comparison to relevant prior work. Axis are normalized to the performance of a 16 bit floating point model. The shaded region indicates when model accuracy degrades below thresholds acceptable for production deployment (\(\rhd 1\%\)(Jouppi et al., 2021)). The curves show the performance of our methods given an accuracy target of 99% and 99.9% as well as the the floating point model performance (100% on both axis). Demonstrating the superiority of our Hessian-based greedy search with the random based greedy search in close proximity. Letters indicate results from related prior work: **a** Hubara et al. (2021), **b** Nahshan et al. (2021), **c** Nagel et al. (2020), **d** Wu et al. (2020), **e** Shen et al. (2020), **f** Jeon et al. (2022),
for ML models that can be practically deployed at low-cost while meeting stringent quality of service (QoS) metrics (e.g., latency and accuracy).
To fulfil this need and support the current pace of innovation and scaling of machine learning models, researchers have proposed various methods to reduce the computational cost of NNs, such as hardware-efficient NN designs (Tan and Le, 2019), pruning (Mishra et al., 2021) and quantization (Gholami et al., 2021). Among these, quantization can be model agnostic and be used in conjunction with other methods. By reducing the precision (bit-widths) of the weights and activations of a NN, quantization significantly reduces the memory footprint and enables the use of cheaper compute primitives, thereby increasing the NN inference speed (latency reduction) and reducing the compute-energy costs.
Other work in literature mitigates quantization induced accuracy degradation by additionally training NN models to compensate for reduced precision, typically referred to in literature as quantization aware training (QAT) (Dong et al., 2020; Wang et al., 2019). However, QAT requires substantial amounts of training data and necessitates profound changes to the model parameters, which might have unintended consequences when a model is deployed. Alternatively, post-training quantization (PTQ) approaches determine adequate quantization scales on small calibration data sets while minimizing the change to model parameters. This trades-off quantization complexity and model-revalidation against the model accuracy (Wu et al., 2020).
Additionally, modern hardware such as Google TPUs (Jouppi et al., 2021) or NVIDIA A100 (Nvidia, 2020) support quantized operations at various bit-widths, e.g. int4, int8, fp8, fp16, fp32 or fp64, to facilitate efficient NN inference. However, to exploit these hardware capabilities in practice, the different NN layers and operations must be performed at (or configured to) an optimal bit-width which balances model accuracy with efficiency. Since the search space of all possible bit-width (quantization) configurations is exponential with the number of layers, this represents a further challenge for optimal quantization. QAT tackles that challenge by: i) making the bit width a learnable parameter and training the bit width alongside other model parameters (given model size constraints) (Schaefer et al., 2022; Uhlich et al., 2019), ii) using unexplainable black-box reinforcement learning solutions to determine bit-widths (Wang et al., 2019), or iii) using an auxiliary metric to reduce the search space (Dong et al., 2020). Owing to the increased complexity encountered in PTQ, most PTQ approaches have only focused model-wide single-bit-width quantization and avoided finer-grained bit-width allocation.
In this work we develop a method for efficient PTQ that facilitates deploying floating-point machine learning models with minimal manual intervention (see Figure 2) on recent hardware with multi-precision support. We do so through the following contributions:
* **Quantization Sensitivity Metrics**: We conduct an in-depth analysis of three metrics to guide the quantization search quantization error, noise performance degradation, and second order information.
* **Guided Precision Configuration Search**: We propose two sensitivity-guided search algorithms (bisection and greedy) to identify optimal network quantization configurations which maintain a minimum accuracy level for PTQ.
* **Comprehensive Evaluation**: We evaluate our technique and experimentally show improvements over SOTA PTQ for model size reduction and latency on both a convolutional vision model and a transformer-based language model. Experimental results show latency reductions of up to \(27.59\%\) (ResNet50) and \(34.31\%\) (BERT), while outperforming prior work (Figure 1).
## 2 Related Work
There have been interesting and significant efforts to increase PTQ accuracies, such as Hubara et al. (2021) (**a** in Fig. 1) proposed a quantization method which updates model parameters to minimizes the error between the quantized layer output and full precision output and also fine-tune batchnorm parameters. Furthermore, they introduce a integer programming formulation to optimally allocate the bit-widths for each layer. This method changes the model weights as well as batchnorm parameters and can not guarantee QoS, thereby potentially complicating deployment and putting it on the border between PTQ and QAT. Coming from an analytical angle Nahshan et al. (2021) (**b** in Fig. 1) investigate the effect of quantization on the structure of the loss landscape and found flat separable structures for mild quantization and highly non-separable with steep curvature for low bit-width quantization. Inspired by their analysis they devise a three step method to improve PTQ for lower bit-widths: i) determine the quantization step that minimizes a norm of the quantization error of the individual layers, ii) use quadratic interpolation to approximate an optimum quantization scale, and iii) jointly optimize the parameters of all layers acquired on the previous step by applying a gradient-free optimization method. In a similar way Nagel et al. (2020) (**c** in Fig. 1) theoretically analyze the rounding decision of the quantization process and view the rounding decision (up or down) as a binary optimization problem. As a solution they propose a layer-wise local loss, which can be optimized with a soft relaxation, determining the rounding decision and improving PTQ accuracies.
In a larger empirical study Wu et al. (2020) (**d** in Fig. 1) evaluated various calibration techniques for PTQ and found that overall entropy based and percentile calibrations work well however the exact setting of the percentile calibration is model and data dependent.
Mixed precision quantization approaches need to determine how many bits to allocate to each layer. Wang et al. (2019) use reinforcement learning to automatically determine the quantization policy using feedback from a hardware accelerator. They demonstrate reductions of latency by \(1.4-1.95\times\) and the energy consumption by \(1.9\times\) compared to eight bit integer models with comparable accuracy. Other works (Schaefer et al., 2022) extend QAT to also train the bit-width of each layer along the model parameters and demonstrate the effectiveness of their method by extending the SOTA pareto frontier with models sized below 4.3MB for the ImageNet task. Similarly Jeon et al. (2022) also consider the quantization parameters, e.g. scaling factors and bit-codes, as learnable and jointly optimize them with the weights of transformer models (**f** in Fig. 1). Another approach is to determine layer importance or sensitivities and allocate bit widths accordingly. This so far has not been done for PTQ, however some works have applied this idea to QAT methods. For example Dong et al. (2020) propose to use the mean of the Hessian trace to determine layer sensitivity and subsequently employ a Pareto-frontier based technique to determine good quantization configurations. They reduce the size of a ResNet50 to 7.99MB which achieves 75.76% accuracy. Equivalently Shen et al. (2020) use a group-wise quantization scheme and Hessian based mik-precision method on BERT (**e** in Fig. 1). Yang et al. (2021) present a dynamical Hessian matrix based mixed-precision quantization scheme specifically for object detection, which iteratively selects a layer with the lowest sensitivity based on the Hessian matrix and downgrades its precision. Additionally they use a loss function that takes into account the joint effects of quantization on classification and regression loss. On the COCO task with a RetinaNet the scheme achieves 37.1% mean average precision with an average bit-width 3.99.
## 3 Methods
### Quantization
Fixed point quantization often termed integer quantization reduces the precision of numerical values in a model for a resulting decrease in storage and compute requirements. This is typically achieved by applying clipping and rounding operations to the original floating-point values, often formulated as:
\[Q(\mathbf{x})=\text{round}(\text{clip}(\alpha\cdot\mathbf{x})\cdot 2^{b-1}) \cdot 2^{-(b-1)}\cdot\gamma. \tag{1}\]
Here, \(Q\) is the quantization function, \(\mathbf{x}\) is the floating point value, the clipping function clips the value between -1 and 1, \(b\) is the bit width, and \(\alpha\) and \(\gamma\) are the quantization scales. While the majority of literature employs a single quantization scale (\(\gamma=\alpha^{-1}\)). Recent work has demonstrates superior results from employing two scaling parameters, to better align the pre- and post-quantized values (Park and Yoo, 2020). As part of PTQ determining the optimal values of these scale parameters need to be determined to minimize model accuracy degradation.
Quantization scales are estimated using a two-step process (Figure 2**(3)**). The first step (calibration) uses a calibration data set and calculates the maximum value in each tensor
Figure 2: Summary of our approach. On the left we show an illustration of the sensitivity metrics: (a) quantization error which extracts floating-point matrices from the network and quantizes them, (b) noise accuracy degradation which evaluates noise injected NNs and (c) second derivative information which computes the Hessian matrix of individual layers. In the middle of the Figure we sketch conceptually our two bit-width search algorithms i) bisection search and ii) greedy search. And on the right we present our PTQ approach, which uses calibrates the quantization scales with the maximum value first and then adapts them using overall network loss minimization.
in the model (e.g., weights and activations). We then set \(\alpha=1/\max(x)\) and \(\gamma=\max(x)\)), where \(x\) is the tensor of interest. In the second step (adjustment), we adapt the scales using backpropagation to minimize the model loss on the calibration dataset. Since this only adapts scales, we do not update the parameters of the original model, facilitating easy deployment.
### Sensitivity Measures
The space of possible tensor-precisions for a model is exponential with the number tensors. Consider a ResNet50 with three different configuration options just for the parameters (e.g. bit widths), this results in \(3^{50}\) possible quantization configurations. Evaluating all of these configurations, even with parallelization, represents a substantial computational workload. Consequently searching through this space efficiently is critical to deploying performant quantized models. The use of an informative sensitivity metric can reduce this vast space, making it practical to search for valid and performant configurations. Such a metric should encapsulate how the model accuracy might be impacted by quantizing different layers to inform the quantization process.
#### 3.2.1 Quantization Error (\(\mathcal{E}_{\text{QE}}\))
Quantization error (QE) forms a natural baseline sensitivity metric against which more complex metrics might be evaluated. We use the root-mean-square error, between a quantized and unquantized tensor, normalized by the maximum absolute value of the tensor as the QE for this tensor (\(\mathcal{E}_{QE}\)). This can be written as:
\[\mathcal{E}_{\text{QE}}=\sqrt{\mathbf{E}[(Q(\mathbf{x})-\mathbf{x})^{2}]}\cdot \frac{1}{\max|\mathbf{x}|}. \tag{2}\]
While QE can directly capture the impact of reduced precision operation for a single tensor, it may not fully capture the impact of quantization on the entire model. Consider the case where high QE at certain layers does not degrade model performance, while a comparatively small QE at other layers may have a larger impact. We refer the reader to Figure 4 in the appendix for a concrete example.
#### 3.2.2 Accuracy Degradation from Noise (\(\mathcal{E}_{\text{N}}\))
As an alternative to using QE, a tensor's resilience to perturbations might serve as a viable estimation of the tensor's sensitivity within the model. We inject Gaussian noise into a single tensor in the model and assess the model's performance on the calibration data set. We employ a Gaussian noise model building on related work Park et al. (2022) which observed superior performance for Gaussian noise as compared to the more conventionally used uniform distribution. We define the sensitivity metric (\(\mathcal{E}_{\text{N}}\)) as the difference in performance between the noise free model and noise injected model, expressed as:
\[\mathcal{E}_{\text{N}} =L(\mathbf{x},\mathbb{W}^{*})-L(\mathbf{x},\mathbb{W}), \tag{3}\] \[\mathbb{W}^{*} =\left\{\mathbb{W}\setminus\mathbf{w}_{\mathbf{i}},\mathbf{w}_{ \mathbf{i}}+\nu\right\},\] (4) \[\nu =\mathcal{N}(0,\lambda\max|\mathbf{w}_{\mathbf{i}}|). \tag{5}\]
Here, the first part of the equation represents the loss \(L\) of the model given the calibration data \(\mathbf{x}\) and the set of all weights including one perturbed weight (\(\mathbb{W}^{*}\)) and the second part represents the loss of a model without any perturbed weights (\(\mathbb{W}\)). \(\mathbb{W}^{*}\) is defined as the set of all weights (\(\mathbb{W}\)), with the exclusion of a single tensor (\(\mathbf{w}_{\mathbf{i}}\)), and the inclusion of a perturbed tensor (\(\mathbf{w}_{\mathbf{i}}+\nu\)). Since perturbations are Gaussian distributed, they can be written as a Normal distribution \(\mathcal{N}\) with \(0\) mean and a variance which is scale by an additional parameter \(\lambda\). This same formulation can be extended to other metrics such as model accuracy and other tensors in the model such as activations.
As formulated, \(\mathcal{E}_{\text{N}}\), assumes that the un-perturbed model performance will be higher than the performance after any perturbations. However, the limited discriminatory power of this metric can impact ordering the tensors by sensitivity, a critical requirement for successful mixed-precision mode; quantization.
#### 3.2.3 Second Derivative Information (\(\mathcal{E}_{\text{Hessian}}\))
We investigate second-order derivative information as a sensitivity measure, which pertains to the local curvature of a function. This choice is informed by theory that model accuracy is robust to perturbations in values that occupy flat regions of the loss function (low local curvature). However, for those values that occupy regions of high local curvature (sharp), small perturbations can have an exaggerated impact on model accuracy Dong et al. (2019); Rissanen (1978); Hochreiter and Schmidhuber (1997). One way of estimating the local curvature, uses the Hessian of the loss function, which comprises second-order partial derivatives of the loss.
Rather than directly evaluating the Hessian, which is computationally prohibitive, we approximate the Trace using Hutchinson's algorithm as seen in related work Dong et al. (2020); Lee et al. (2021). By discarding the off-diagonal elements, we trade off computational tractability against capturing cross-tensor interactions. We define a Hessian-based metric:
\[\mathcal{E}_{\text{Hessian}}=\mathbf{E}\Big{[}\mathrm{Tr}\Big{[}\frac{L( \mathbf{x},\mathbb{W})}{\partial\mathbf{w}_{i}^{2}}\Big{]}\Big{]}. \tag{6}\]
Where \(\mathrm{Tr}\) is the trace operator, \(L\) the loss function of the model, \(\mathbb{W}\) the set of all weights (this set could also be extended to the activations) and \(\mathbf{x}\) calibration data. Larger values of \(\mathcal{E}_{\text{Hessian}}\) indicate higher local curvature of the loss function and consequently greater sensitivity of the model's accuracy to lower-precision.
### Search for Quantization Configurations
These sensitivity metrics are not equally informative, in guiding bit-configuration search for multi-precision PTQ. Prior work has employed such sensitivity metrics to enable a partial or exhaustive search within the configuration space to develop a pareto frontier of model-performance (Dong et al., 2020). Other efforts at PTQ have avoided configuration search entirely (Lee et al., 2021). Here, we propose to use guided search algorithms to determine per-tensor precisions for a model that can maintain a target accuracy while minimizing latency and model footprint.
We propose two methods: a guided bisection search and a greedy approach. Both methods are progressive, starting with a floating-point model and gradually quantizing more or fewer layers based on the sensitivity metric. We iteratively reduce the bit widths of previously quantized layers to find the best configuration by using all available bit-widths. This approach is motivated by the observation that tensors insensitive to lower numerical precision can first be evaluated at higher precision, to cheaply encapsulate limited effects of cross-layer interactions. This can then be used to further shrink the search space for tensors insensitive to lower-precision quantization.
#### 3.3.1 Bisection Search
The bisection search is a well known root-finding method which we apply here to determine the ideal quantization configuration. We assume that there exists a threshold sensitivity value, above which layers cannot be quantized or can only be quantized to a limited bit width. To find this threshold, the bisection search iteratively quantizes subsets of layers, where ordering is determined by a sensitivity metric. We start with a configuration which quantizes the least-sensitive half of the set of tensors. We evaluate the model with that configuration and compare the accuracy against the accuracy target. The bisection search then proceeds to iteratively update the threshold value (and thereby the quantization configuration) by either increasing the number of layers when the accuracy target is met or decreasing the amount of quantized layers when the accuracy criteria is not fulfilled. Once the threshold sensitivity value is identified for the highest quantized precision, the method is repeated for each lower precision setting, in sequence. The method outlined with pseudo in Algorithm 1. The worst and average time complexity of this search is \(\mathcal{O}(b\log N)\), where \(N\) is the total number of layers and \(b\) the number of available bit widths. Bisection relies on accurate ordering to reduce the search space. Consequently, inaccuracies in the ordering due to sensitivity estimations negatively impact final model performance.
```
1:Input: data \(x\), sensitivity metric \(s\), accuracy target \(t\), available bit widths \(bs\), model \(f\).
2: Initialize working configuration \(w\) with \(\max(bs)\).
3: Initialize layer list \(ll\) with all layers of \(f\).
4: Sort \(ll\) by \(s\) in ascending order.
5:for\(b\)in\(bs\)do
6: Initialize threhsold \(thr=\text{length}(ll)/2\).
7: Initialize upper limit \(upl\) to \(\text{length}(ll)\).
8: Initialize lower limit \(lowl\) to \(0\).
9:repeat
10: Initialize local working config \(lw\) with \(w\).
11:\(lw[ll[0:thr]]\gets b\).
12: Evaluate \(f(x,lw)\) and save accuracy \(a\).
13:if\(a>=t\)then
14:\(lowl\gets thr\).
15:\(thr\gets thr+(upl-thr)/2\).
16:else
17:\(upl\gets thr\).
18:\(thr\gets thr-(thr-lowl)/2\).
19:endif
20:until\(thr\) is not changing.
21:\(w[ll[0:thr]]\gets b\).
22:\(ll\gets ll[0:thr]\).
23:endfor
24:Return: optimal working configuration \(w\).
```
**Algorithm 1** Bisection search for ideal quantization configuration. Worst and average time complexity is \(\mathcal{O}(b\log N)\) with \(b\) as the number of bit width choices and \(N\) the number of layers.
Since most metrics can only estimate sensitivity, alternative search techniques that are less sensitive to exact ordering can deliver higher final performance. We examine a guided greedy search to progressively build up an efficient ideal quantization configuration. We first initialize a working configuration to the baseline precision for all layers (usually floating point 16). We then iterate through each layer and evaluate it at a lower precision. If the model evaluation falls below the accuracy threshold, the layer is no longer considered a candidate for further quantization. We iterate across the different bit-widths until all eligible layers have been evaluated at the lowest precision. A pseudo code implementation of this is outlined in Algorithm 2. The average time complexity is \(\mathcal{O}((2-2^{-(b-1)})N)\) and the worst-case time complexity is \(\mathcal{O}(bN)\) where \(b\) is the number of bit width choices and \(N\) is the number of layers. As with typical unstructured discrete optimization problems, there is no guarantee of arriving at the optimal quantization configuration. In part, due to relaxed assumptions on cross-tensor interactions.
## 4 Experiments
We evaluate our proposed methods on the ImageNet (Russakovsky et al., 2015) and SQuaAD (Rajpurkar et al., 2016) datasets, using ResNet50 (He et al., 2016) and BERT (Devlin et al., 2018) respectively. These are commonly accepted dataset-model combinations from the MLPerf inference suite (Reddi et al., 2020).1 Because calibration and determining the sensitivity requires some data, we randomly sample 512 examples from the original training set to obtain sensitivity metrics and resample another 512 examples to calibrate and adjust the quantizers. We use a learning rate of \(1\times 10^{-5}\) for quantization scale adaptation with the batch size for models determined by memory considerations (128 for ResNet50 and 48 for BERT). Configuration search uses the complete validation set to assess quantization efficacy.
Footnote 1: [https://mlcommons.org/](https://mlcommons.org/)
Compute Latency EstimatesMost deep learning frameworks such as TensorFlow(Abadi et al., 2015), JAX (Bradbury et al., 2018), or PyTorch (Paszke et al., 2019) support quantization to 8-bit integers. More aggressive quantization, such as 4-bit integers, while supported in hardware (e.g., NVIDIA A100 (Nvidia, 2020)) have limited software support. In practice, modeling the benefits of executing quantized kernels in hardware is not trivial. This is in part due to complex interactions between memory hierarchy, bus-speeds, compute-utilization, and compiler optimizations. We capture these interactions by benchmarking the performance of key kernels such as gemm and conv2d across different numerical precisions on A100 GPUs, run for inference batch-size of one. The best performing kernels for a given tensor shape and precision were determined using the CUTLASS profiler and optimizer (Kerr et al., 2022). We then developed estimates for model deployment latencies by suitable combination of kernel latencies for different multi-precision models.
BaselinesWe provide absolute and relative model size, accuracy, and deployment latency results for different degrees of quantization for ResNet50 and BERT models in Table 1. We designate the 16-bit floating point model which meets MLPerf accuracy threshold as our baseline, for relative results. Quantized models all use the same bit-precision for all their weights and activations. Model size reduction scale linearly with the number of bits while latency reduction captures the complex interactions that real-world execution will encounter. Further software support for heavily quantized operations could further improve the compute latencies.
ble 1). We examine the improvement given two target accuracies (\(99\%\) and \(99.9\%\), with results for 90% in the appendix Table 3). Hessian-guided greedy search consistently outperforms all other methods, compressing both models by more than \(50\%\) while maintaining a target accuracy of \(99\%\) relative to the baseline. The results indicate that even though the models can be compressed by a similar factor, the different compute kernels do not see similar latency benefits. BERT benefits from a larger reduction in latency (\(65.69\%\) of the baseline latency) while ResNet50 only reduces to \(72.41\%\) of the baseline. More stringent accuracy constraints do not substantially change ResNet50 inference latency, while BERT sees a reduction to \(\approx 76\%\) relative to the baseline. The changes of latency and model size between the \(99\%\) and \(99.9\%\) target for the ResNet50 are small meanwhile for the BERT model changes \(>10\%\) highlighting the difference between the ease of quantizing these models. Figure 3 shows that for ResNet50 models targeting \(99\%\) (red) and the \(99.9\%\) (blue) accuracy, only a few additional layers can be quantized to 4-bits for a minimal improvement in latency.
Sensitivity Metrics EvaluationFigure 4 visualizes the layer orderings for ResNet50 and BERT, derived from the three sensitivity metrics. Solid lines denote the average of five trials and shaded areas show the magnitude of one standard deviation. The across trials, there is minimal variance between runs for both QE and the Hessian Trace (not visible in the figure). For ResNet50 both QE and the Hessian Trace indicate that earlier layers are more sensitive, while for Bert there is a repeating structure in the transformer blocks with varying sensitivity. We computed the Levenshtein distance (edit distance) between the resulting orderings of the layers and note that generally all metrics produce orderings which are far from each other, e.g. for ResNet50 the closest pair is \(\mathcal{E}_{QE}\) and \(\mathcal{E}_{\text{Hessian}}\) with an distance of \(48\) (the maximum distance here would be 54).
We first examine how much guidance from the sensitivity metric might be able to improve configuration search. We create a random ordering for the layers and implement both the bisection and greedy search on these. The results are evaluated over 5 trials with the expected relative latency and model compression and the standard deviation over these trials, reported in Table 2. For ResNet50 all sensitivity measures exhibit similar latency and model size reductions as the uninformed baseline (random), around 50% model compression for both accuracy targets. On the other hand BERT shows improvements from an informative search, with the random baseline achieving a model footprint that is \(\sim 53\%\) of the baseline for a target accuracy of \(99\%\). Both QE (\(\mathcal{E}_{\text{QE}}\)) and the Noise-based sensitivity estimates underperform the random 'guidance', with QE compressing model footprint to \(\sim 78\%\) of the baseline and Noise-based sensitivity achieving footprints that were \(\sim 72\%\) of the baseline. However, the inconsistent results from the uninformed guidance (see large standard deviation in Table 2 and Figure 4 in the appendix), indicate that this metric might be unsuitable deployment scenarios. Using the Hessian Trace for guidance, consistently outperforms the random baseline by 1-3% for all accuracy targets when using the greedy search. Indicating tangible benefits with additional computation.
\begin{table}
\begin{tabular}{r r r r r r r r r} \hline \hline \multirow{2}{*}{Accuracy Target} & \multicolumn{4}{c}{ResNet50} & \multicolumn{4}{c}{BERT} \\ \cline{2-9} & \multicolumn{2}{c}{99\%} & \multicolumn{2}{c}{99.9\%} & \multicolumn{2}{c}{99\%} & \multicolumn{2}{c}{99\%} & \multicolumn{2}{c}{99.9\%} \\ \cline{2-9} & Size & Latency & Size & Latency & Size & Latency & Size & Latency \\ \hline Search = Bisection & & & & & & & & \\ Random & 50.81\% & 74.11\% & 51.84\% & 74.10\% & 59.34\% & 72.27\% & 92.14\% & 95.04\% \\ \(\pm\sigma\) & 0.81\% & 0.56\% & 1.44\% & 0.51\% & 2.89\% & 2.06\% & 3.18\% & 1.65\% \\ \(\mathcal{E}_{\text{Hessian}}\) & 50.01\% & 73.98\% & 50.01\% & 73.98\% & 72.57\% & 77.61\% & 81.08\% & 84.65\% \\ \(\mathcal{E}_{\text{N}}\) & 52.00\% & 73.69\% & 58.94\% & 79.04\% & 54.77\% & 68.96\% & 81.42\% & 87.58\% \\ \(\mathcal{E}_{\text{QE}}\) & 50.02\% & 73.71\% & 50.02\% & 73.71\% & 88.20\% & 89.07\% & 93.75\% & 93.87\% \\ Search = Greedy & & & & & & & & \\ Random & 49.74\% & 73.05\% & 49.92\% & 73.30\% & 53.21\% & 67.45\% & 69.10\% & 78.51\% \\ \(\pm\sigma\) & 0.14\% & 0.28\% & 0.06\% & 0.18\% & 4.27\% & 2.44\% & 5.22\% & 3.77\% \\ \(\mathcal{E}_{\text{Hessian}}\) & **49.22\%** & **72.41\%** & **49.86\%** & **73.14\%** & **49.91\%** & **65.69\%** & **68.40\%** & **76.60\%** \\ \(\mathcal{E}_{\text{N}}\) & 49.73\% & 72.68\% & 49.94\% & 73.32\% & 55.21\% & 69.12\% & 72.05\% & 81.21\% \\ \(\mathcal{E}_{\text{QE}}\) & 49.94\% & 73.37\% & 49.86\% & 73.14\% & 70.92\% & 78.08\% & 78.30\% & 83.97\% \\ \hline \hline \end{tabular}
\end{table}
Table 2: Results for ResNet50 on ImageNet and BERT on SQuAD. All numbers are percentages relative to the size and latency of a floating point model with 16 bits which can be seen in Table 1. For random sensitivity (e.g. uninformed sensitivity) ordering we repeated the experiments five times with different random seeds to ensure a representative result.
Search Algorithm EvaluationFor both models (ResNet50 and BERT) Greedy search results in a more performant quantized model across sensitivity metrics (including the uninformed baseline). Although quantizing ResNet50 does not offer dramatic benefits. The benefits of the greedy approach become more apparent on examining the quantization results for BERT (Table 2), where a Greedy search improves model compression compared to bisection by \(10\%\) on average. Of the examined approaches, only models quantized using the greedy search consistently outperform the baselines. Figure 3 outlines how different layers are configured across some of the studied search methods. Greedy search for BERT (red in Figure 3 left) more aggressively configures layers to operate at 4b whereas bisection search leaves more layers at 16b for a \(99\%\) target accuracy.
Comparison to Prior WorkFigure 1 contextualizes our results with respect to other work. Most other PTQ efforts do not meet accuracies acceptable for easy deployment and typically use a single bit-width configurations across the entire model. For quantizing ResNet50, Wu et al. (2020) approaches the \(99\%\) accuracy threshold, however since they only apply single bit-configuration across the model they are unable to increase the precison of critical layers to to achieve the target accuracy. For quantizing BERT, only the work outlined in (Shen et al., 2020) provides competitive accuracy. Again, our multi-precision method delivers finer control over bit-width configuration enabling higher model accuracy at comparable model size.
## 5 Conclusions
In this paper we developed a practical quantization pipeline for efficient deployment of floating point NN using quantized tensor vector multiplications of various bit-widths. We use PTQ, which calibrates the quantizer scales on data and subsequently uses back-propagation to refine them, without changing any of the original model parameters. We are able to determine a suitable quantization configuration that can meet previously set accuracy expectations while still delivering model compression. This is crucial for practical deployment of large-scale models that can leverage the full quantization potential of modern ML accelerator hardware. We evaluate different sensitivity metrics to guide configuration search, and showed the benefits resulting from using a Hessian-based metric. We evaluate two guided search algorithms: bisection and greedy search that can rapidly search the large configuration space guided by the sensitivity metrics. The resulting configurations consistently outperformed state-of-the art PTQ, consistently meeting a \(99\%\) accuracy requirement with models compressed to \(\leq 50\%\) of the floating point baseline for both ResNet50 (evaluated on ImageNet) and BERT (evaluated on SQUAD). We demonstrate that most of the benefits for mixed-precision quantization can be obtained without any sensitivity guidance while using a progressive Greedy approach.
Figure 4: Sensitivity Metrics for ResNet50 and BERT: quantization Error \(\mathcal{E}_{\text{QE}}\), accuracy degradation from noise \(\mathcal{E}_{\text{N}}\), and second derivative information \(\mathcal{E}_{\text{Hessian}}\). Metrics were obtained over five trials and the shaded areas indicate one standard deviation. The noise based measure has a higher variability compared to both other metrics.
Figure 3: Illustrating per-layer bit width configurations for BERT and ResNet50. Left highlights when different configurations arise between bisection (blue) and greedy (red). Due to its sensitivity to ordering, bisection search configures substantially more layers to operate at 16 bits. Right shows the different bit allocation between a \(99\%\) (red) and \(99.9\%\) (blue) accuracy target for ResNet50 with the differences in bit width allocations arising from a few additional layers quantized to 4 bits.
AcknowledgementThe authors gratefully acknowledge the valuable and profound feedback from Daniel Finchelstein and Naveen Kumar.
|
2310.04955 | Information-Theoretic Bounds on The Removal of Attribute-Specific Bias
From Neural Networks | Ensuring a neural network is not relying on protected attributes (e.g., race,
sex, age) for predictions is crucial in advancing fair and trustworthy AI.
While several promising methods for removing attribute bias in neural networks
have been proposed, their limitations remain under-explored. In this work, we
mathematically and empirically reveal an important limitation of attribute bias
removal methods in presence of strong bias. Specifically, we derive a general
non-vacuous information-theoretical upper bound on the performance of any
attribute bias removal method in terms of the bias strength. We provide
extensive experiments on synthetic, image, and census datasets to verify the
theoretical bound and its consequences in practice. Our findings show that
existing attribute bias removal methods are effective only when the inherent
bias in the dataset is relatively weak, thus cautioning against the use of
these methods in smaller datasets where strong attribute bias can occur, and
advocating the need for methods that can overcome this limitation. | Jiazhi Li, Mahyar Khayatkhoei, Jiageng Zhu, Hanchen Xie, Mohamed E. Hussein, Wael AbdAlmageed | 2023-10-08T00:39:11Z | http://arxiv.org/abs/2310.04955v2 | # Information-Theoretic Bounds on The Removal of Attribute-Specific Bias From Neural Networks
###### Abstract
Ensuring a neural network is not relying on protected attributes (_e.g._, race, sex, age) for predictions is crucial in advancing fair and trustworthy AI. While several promising methods for removing attribute bias in neural networks have been proposed, their limitations remain under-explored. In this work, we mathematically and empirically reveal an important limitation of attribute bias removal methods in presence of strong bias. Specifically, we derive a general non-vacuous information-theoretical upper bound on the performance of any attribute bias removal method in terms of the bias strength. We provide extensive experiments on synthetic, image, and census datasets to verify the theoretical bound and its consequences in practice. Our findings show that existing attribute bias removal methods are effective only when the inherent bias in the dataset is relatively weak, thus cautioning against the use of these methods in smaller datasets where strong attribute bias can occur, and advocating the need for methods that can overcome this limitation.
## 1 Introduction
_Protected attributes_ is a term originating from Sociology [30] referring to a finite set of attributes that must not be used in decision-making to prevent exacerbating societal biases against specific demographic groups [9]. For example, in deciding whether or not someone should be qualified for a bank loan, race (as one of the protected attributes) must not influence the decision. Given the widespread use of neural networks in real-world decision-making, developing methods capable of explicitly excluding protected attributes from the decision process - more generally referred to as removing attribute bias [34] - is of paramount importance.
While many promising methods for removing attribute bias in neural networks have been proposed in the recent years [2; 20; 39; 29; 35; 41; 17], the limitations of these methods remain under-explored. In particular, existing studies explore the performance of these methods only in cases where the protected attribute (_e.g._, race) is _not strongly predictive_ of the prediction target (_e.g._, credit worthiness). However, this implicit assumption does not always hold in practice, especially in cases where training data is scarce. For example, in diagnosing Human Immunodeficiency Virus (HIV) from Magnetic Resonance Imaging (MRI), HIV subjects were found to be significantly older than control subjects, making age a strong attribute bias for this task [1]. Another example is the Pima Indians Diabetes Database which contains only 768 samples where several spurious attributes become strongly associated with diabetes diagnosis [33; 27]. Even the widely-used CelebA dataset [28] contains strong attribute biases: for example in predicting blond hair, sex is a strong predictor 1. Therefore, it is crucial to study the
performance of bias removal methods beyond the moderate bias region to understand their limitations and the necessary conditions for their effectiveness.
In Fig. 1, we will illustrate by a specific example the limitation in bias removal methods that we will later investigate theoretically and empirically in several real-world datasets. In this example, we conduct an extended version of a popular controlled experiment for evaluating the performance of attribute bias removal [20; 31; 41]. The task is to predict digits from colored MNIST images [20] where color is considered a protected attribute. During training, each digit is assigned a unique RGB color with a variance (_i.e._, the smaller the color variance, the more predictive the color is of the digit, and the stronger the attribute bias). To measure how much the trained model relies on the protected attribute in its predictions, model accuracy is reported on a held-out subset of MNIST with uniformly random color assignments (_i.e._, where the color is not predictive of the digit). While state-of-the-art methods [20; 31; 35; 41] report results for the color variance only in the range \([0.02,0.05]\) (without providing any justification for this particular range), we explore the results for the missing range of \([0,0.02]\), which we denote as the _strong bias region_. As shown in Fig. 1, in the strong bias region, we observe that the effectiveness of all existing methods sharply declines and that there exists a _breaking point_ in their effectiveness. The breaking point of a method is defined as the weakest bias strength at which its performance becomes indistinguishable from the baseline under a two-sample one-way Kolmogorov-Smirnov test with significance level of \(0.05\). The main goal of this paper is to study the cause and extent of this limitation empirically and theoretically.
## 2 Related Work
**Bias in Neural Networks.** Mitigating bias and improving fairness in neural networks has received considerable attention in recent years [14; 7; 22; 12; 8; 25]. The methods proposed for mitigating bias in neural networks can be broadly grouped into two categories: 1) methods that aim to mitigate the uneven performance of neural networks between majority and minority groups; and 2) methods that aim to reduce the dependence of neural network prediction on specific attributes. Most notable examples of the former group are methods for constructing balanced training set [6; 19], synthesizing additional samples from the minority group [4; 26], importance weighting the under-represented samples [37], and domain adaption techniques that adapt well-learnt representations from the majority group to the minority group [38; 13; 18]. In this work, our focus is on the second group of methods,
Figure 1: Accuracy of attribute bias removal methods under different levels of bias strength in Colored MNIST, showing results on the previously unexplored region of color variance \(<0.02\). The breaking point of each method, where its performance becomes statistically similar to the baseline classifier, is labeled with \(\blacktriangle\) on the x-axis. While all methods clearly outperform baseline in moderate bias region, their effectiveness sharply declines to baseline as bias strength increases. The plot shows average accuracy (lines) with one standard deviation error (shaded) over 15 randomized training runs.
which we will further divide into two subgroups discussed below: methods that implicitly or explicitly minimize the mutual information between learnt latent features and the specific protected attribute.
**Explicit Mutual Information Minimization.** Several methods aim to directly minimize mutual information (MI) between a latent representation for the target classification and the protected attributes, in order to learn a representation that is predictive of the target but independent of the protected attributes, hence removing attribute bias. These methods mainly differ in the way they estimate MI. Most notable examples include LNL [20] which minimizes the classification loss together with a MI regularization loss estimated by an auxiliary distribution; BackMI [31] which minimizes classification loss and MI estimated by a neural estimator [5] through the statistics network; and, CSAD [41] which minimizes MI estimated by [16] between a latent representation to predict target and another latent representation to predict the protected attributes.
**Implicit Mutual Information Minimization.** Another group of methods aims to remove attribute bias by constructing surrogate losses that implicitly reduce the mutual information between protected attributes and the target of classification. Most notably, LfF [29] proposes training two models simultaneously, where the first model will prioritize easy features for classification by amplifying the gradient of cross-entropy loss with the predictive confidence (softmax score), and the second model will down-weight the importance of samples that are confidently classified by the first model, therefore avoiding features that are learnt easily during training, which are likely to be spurious features leading to large MI with protected attributes; EnD [35] adds regularization terms to the typical cross-entropy loss that push apart the feature vectors of samples with the same protected attribute label to become orthogonal (thereby increasing the conditional entropy of them given the protected attribute); BlindEye [2] pushes the distribution obtained by the attribute classifier operating on latent features towards uniform distribution by minimizing the entropy between them; and, domain independent training (DI) [39] learns a shared representation with an ensemble of separate classifiers per domain to ensure that the prediction from the unified model is not biased towards any domain.
**Trade-offs between Bias Removal and Model Utility.** The trade-offs between fairness and accuracy in machine learning models have garnered significant discussion. Most notably, Kleinberg _et al_. [21] prove that except in highly constrained cases, no method can simultaneously satisfy three fairness conditions: _calibration within groups_ which requires that the expected number of individuals predicted as positive should be proportional to a group-specific fraction of individuals in each group, _balance for the negative class_ which requires that the average score of individuals predicted as negative should be equal across groups, and _balance for the positive class_ which requires the balance for the positive class across groups; and, Dutta _et al_. [11] theoretically demonstrate that, under certain conditions, it is possible to simultaneously achieve optimal accuracy and fairness in terms of _equal opportunity_[14] which requires even false negative rates or even true positive rates across groups. Different from the above-mentioned fairness criteria, we focus on another well-known fairness criterion, _demographic parity_[22; 12], which requires even prediction probability across groups, _i.e_., independence between model prediction and protected attributes. Regarding this criterion, Zhao and Gordon [40] show that any method designed to learn fair representations, while ensuring model predictions are independent of protected attributes, faces an information-theoretic lower bound on the joint error across groups. In contrast, we derive a general information-theoretic upper bound on the best attainable performance, which is not limited to the case where model predictions are independent of protected attributes and considers different levels of the retained protected attribute information in the learnt features.
## 3 Bounding the Performance of Attribute Bias Removal Methods
The observations in Fig. 1 revealed that the existing methods are not effective when the attribute bias is too strong, _i.e_., they all have a breaking point, and that there is a continuous connection between their effectiveness and the strength of the attribute bias. However, so far, these observations are limited to the particular Colored MNIST dataset. In this section, we show that this situation is in fact much more general. By deriving an upper bound on the classification performance of any attribute bias removal method in terms of the bias strength, regardless of the dataset and domain, we will elucidate the cause and extent of the limitation we observed in Fig. 1.
We first need to formalize the notions of performance, attribute bias strength, and attribute bias removal. Let \(X\) be a random variable representing the input (_e.g_., images) with support \(\mathcal{X}\), \(Y\) a random variable representing the prediction target (_e.g_., hair color) with support \(\mathcal{Y}\), and \(A\) a
random variable representing the protected attribute (_e.g._, sex). We define the attribute bias removal method as a function \(f:\mathcal{X}\rightarrow\mathcal{Z}\) that maps input data to a latent bottleneck feature space \(\mathcal{Z}\) inducing the random variable \(Z\), and consider the prediction model as a function \(g:\mathcal{Z}\rightarrow\mathcal{Y}\) inducing the random variable \(\hat{Y}\). According to the information bottleneck theory [36, 32], the goal of classification can be stated as maximizing the mutual information between prediction and target, namely \(I(\hat{Y};Y)\), which is itself bounded by the mutual information between feature and target due to the data processing inequality [10], _i.e._, \(I(\hat{Y};Y)\leq I(Z;Y)\). Intuitively, \(I(Z;Y)\) measures how informative the features learnt by the model are of the target, with \(I(Z;Y)=0\) indicating completely uninformative learnt features: the best attainable prediction performance is no better than chance. Therefore, the optimization objective of attribute bias removal methods can be formalized as learning \(f\) parameterized by \(\theta\) that minimizes mutual information between feature and attribute \(I(Z_{\theta};A)\), while maximizing mutual information between feature and target \(I(Z_{\theta};Y)\).
Given the above definitions, we can state our goal in this section concretely: to derive a connection between \(I(Z;Y)\) (the best attainable performance), \(H(Y|A)\) (the attribute bias strength measured by the conditional entropy of target given attribute), and \(I(Z;A)\) (the amount of remaining attribute bias in the learnt feature). Note that the stronger the attribute bias is, the better the attribute can predict the target, hence the lower \(H(Y|A)\). So the extreme attribute bias happens when \(H(Y|A)=0\). In this particular extreme setting, the following proposition shows that no classifier can outperform random guess if the attribute is removed from the feature, _i.e._, \(I(Z;A)=0\).
Figure 2: Empirically verifying the bound in Theorem 1 on CelebA. The x-axis shows \(H(Y|A)\), which we vary directly by adjusting the fraction of bias-conflicting images while ensuring a constant number of biased images in the training set. We empirically compute \(H(Y|A)\) based on the distribution of \(Y\) and \(A\) in the modified training set, and estimate mutual information using [5]. The bound \(0\leq I(Z;Y)\leq I(Z;A)+H(Y|A)\) holds in all cases.
**Proposition 1**.: _Given random variables \(Z,Y,A\), in case of the extreme attribute bias \(H(Y|A)=0\), if the attribute is removed from the feature \(I(Z;A)=0\), then \(I(Z;Y)=0\), i.e., no classifier can outperform random guess. 2_
Footnote 2: Proof in Appendix.
This proposition extends and explains the observation on the leftmost location of the x-axis in Fig. 1: when the color variance is zero, color is completely predictive of the digit, \(H(Y|A)=0\), and removing color from the latent feature, \(I(Z;A)=0\), makes the prediction uninformative, \(I(Z;Y)=0\). However, Proposition 1 does not explain the rest of the curve beyond just zero color variance. The following theorem closes this gap by deriving a bound on the performance of attribute bias removal methods in terms of the attribute bias strength, thus providing a more complete picture of the limitation of attribute bias removal, and elucidating the connection of performance and bias strength.
**Theorem 1**.: _Given random variables \(Z,Y,A\), the following inequality holds without exception: 3_
Footnote 3: _Proof in Appendix._
\[0\leq I(Z;Y)\leq I(Z;A)+H(Y|A) \tag{1}\]
**Remark 1**.: _In the extreme bias case \(H(Y|A)=0\), the bound in Eq. (1) shows that the model performance is bounded by the amount of protected attribute information that is retained in the feature, namely \(I(Z;Y)\leq I(Z;A)\). This puts the model in a trade-off: the more the attribute bias is removed, the lower the best attainable performance._
**Remark 2**.: _When the protected attribute is successfully removed from the feature \(I(Z;A)=0\), the bound in Eq. (1) shows that the model's performance is bounded by the strength of the attribute bias, namely \(I(Z;Y)\leq H(Y|A)\). This explains the gradual decline observed in Fig. 1 as we moved from the moderate to the strong bias region (from right to left towards zero color variance)._
**Remark 3**.: _When \(H(Y|A)=0\) and \(I(Z;A)=0\), Eq. (1) reduces to the result of Proposition 1, \(I(Z;Y)=0\), hence no classifier can outperform random guess._
**Remark 4**.: _We emphasize that the provided bound is placed on the best attainable performance. So while decreasing the bound will decrease performance, increasing the bound will not necessarily result in an increased performance. For example, consider the baseline classifier: even though there is no attribute bias removal performed and therefore the bound can be arbitrarily large, \(I(Z;A)\gg 0\), the model declines in the strong bias region since learning the highly predictive protected attribute is likely in the non-convex optimization._
To empirically test our theory in a real-world dataset, we compute the terms in Theorem 1 for several attribute bias removal methods in CelebA and plot the results in Fig. 2. In these experiments, blond hair is the target \(Y\), and sex is the protected attribute \(A\). We vary the bias strength \(H(Y|A)\) by increasing/decreasing the fraction of bias-conflicting images in the training set (images of females with non-blond hair and males with blond hair) while maintaining the number of biased images in the training set at 89754. Then, we compute \(H(Y|A)\) directly and estimate the mutual information terms \(I(Z;A)\) and \(I(Z;Y)\) using mutual information neural estimator [5]. We observe that the bound holds in accordance with Theorem 1 in all cases. Now that we have mathematically and empirically shown the existence of the bound, in the next section, we will investigate the extent of its consequences for attribute bias removal methods in image and census datasets, in addition to the consequence we have already observed in the synthetic Colored MNIST dataset in Fig. 1.
## 4 Experiments
In this section, we empirically study the performance of the existing attribute bias removal methods in the strong bias setting. We conduct experiments with an extensive list of existing state-of-the-art attribute bias removal methods [20; 39; 29; 35; 41; 17] on Colored MNIST as well as two real-world datasets: CelebA [28] and Adult [3]. For all results, we report average performance with one standard deviation over multiple trials (15 trials in Colored MNIST, 5 in CelebA, 25 in Adult).
**Colored MNIST Dataset** is an image dataset of handwritten digits, where each digit is assigned a unique RGB color with a certain variance, studied by these methods [20; 31; 35; 41]. The training set consists of 50000 images and the testing set of 10000 images with uniformly random color assignment. The color is considered the protected attribute \(A\) and the digit is the target \(Y\). The
variance of color in the training set determines the strength of the bias \(H(Y|A)\). The results on this dataset are reported in Fig. 1 and explained in Sec. 1.
**CelebA Dataset**[28] is an image dataset of human faces studied by these methods [20, 39, 29, 35, 41, 17]. Facial attributes are considered the prediction target \(Y\) (_e.g._, blond hair), and sex is the protected attribute \(A\). For each target, there is a notion of _biased samples_ - images in which \(Y\) is positively correlated with \(A\), _e.g._, images of females with blond hair and males without blond hair - and a notion of _bias-conflicting_ samples - images in which \(Y\) is negatively correlated with \(A\), _e.g._, images of females without blond hair and males with blond hair. The fraction of bias-conflicting images in the training set determines the strength of the bias \(H(Y|A)\). For training, we consider the original training set of CelebA denoted _TrainOri_ consisted of 162770 images with \(H(Y|A)=0.36\), and an extreme bias version in which the bias-conflicting samples are removed from the original training set denoted _TrainEx_ consisted of 89754 images with \(H(Y|A)=0\). Additionally, we construct 16 training sets between TrainOri and TrainEx by maintaining the number of biased samples and varying the fraction of bias-conflicting samples. For testing, we consider two versions of the original testing set: (1) _Unbiased_ consists of 720 images in which all pairs of target and protected attribute labels have the same number of samples, and (2) _Bias-conflicting_ consists of 360 images in which biased samples are excluded from the _Unbiased_ dataset (only bias-conflicting samples remain).
**Adult Dataset**[3] is a census dataset of income which is a well-known fairness benchmark. Income is considered the target \(Y\) and sex is the protected attribute \(A\). To construct training and testing sets, we follow the setup of CelebA explained above, but we further mitigate the effect of data imbalance and the variation in the total number of training samples. For training, we consider the balanced version of the original training set of Adult denoted _TrainOri_ consisted of 7076 records with \(H(Y|A)=0.69\), and an extreme bias version in which the bias-conflicting samples are removed from TrainOri and the same number of biased samples are appended denoted _TrainEx_ with \(H(Y|A)=0\) consisted of the same total number (7076) of records as TrainOri. Additionally, we construct 11 training sets in between TrainOri and TrainEx by varying the fraction of biased samples in TrainEx while maintaining the total size of training set. For testing, we consider two versions of the original testing set: (1) _Unbiased_ consists of 7076 records in which all pairs of target and protected attribute labels have the same number of samples, and (2) _Bias-conflicting_ consists of 3538 records in which biased samples are excluded from the _Unbiased_ dataset (only bias-conflicting samples remain).
**Training Details.** For digit classification on Colored MNIST, we use Lenet-5 [24] as the baseline classifier. For facial attribute classification on CelebA, following CSAD [41], we use ResNet-18 [15] as the baseline classifier. For income prediction on Adult dataset, we use a three-layer MLP as the baseline classifier. For all experiments, we set learning rate to 0.001, batch size to 32, and Adam optimizer with \(\beta_{1}=0.9\) and \(\beta_{2}=0.999\). All hyperparameters are set according to respective papers.
### Analysis of the Extreme Bias Point \(H(y|a)=0\)
In this section, we investigate the consequences of applying existing attribute bias removal methods at the extreme bias point \(H(Y|A)=0\). We study two aspects of each method, the classification
\begin{table}
\begin{tabular}{l c c c c} \hline \hline \multirow{2}{*}{Method} & \multicolumn{2}{c}{Test Accuracy} & \multicolumn{2}{c}{Mutual Information} \\ \cline{2-5} & Unbiased \(\uparrow\) & Bias-conflicting \(\uparrow\) & \(I(Z;A)\downarrow\) & \(\Delta\) (\%) \(\uparrow\) \\ \hline Random guess & 50.00 & 50.00 & 0.57 & 0.00 \\ Baseline & 66.11\(\pm\)0.32 & 33.89\(\pm\)0.45 & 0.57\(\pm\)0.01 & 0.00 \\ \hline LNL [20] & 64.81\(\pm\)0.17 & 29.72\(\pm\)0.26 & 0.56\(\pm\)0.06 & 1.75 \\ DI [39] & 66.83\(\pm\)0.44 & 33.94\(\pm\)0.65 & 0.55\(\pm\)0.02 & 3.51 \\ LfF [29] & 64.43\(\pm\)0.43 & 30.45\(\pm\)1.63 & 0.57\(\pm\)0.03 & 0.00 \\ EnD [35] & 66.53\(\pm\)0.23 & 31.34\(\pm\)0.89 & 0.57\(\pm\)0.05 & 0.00 \\ CSAD [41] & 63.24\(\pm\)2.36 & 29.13\(\pm\)1.26 & 0.55\(\pm\)0.04 & 3.51 \\ BCL [17] & 65.30\(\pm\)0.51 & 33.44\(\pm\)1.31 & 0.56\(\pm\)0.07 & 1.75 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Performance of attribute bias removal methods trained under extreme bias in CelebA (_TrainEx_ training set) to predict _blond hair_. \(\Delta\) indicates the difference from baseline. None of the methods can effectively remove the bias \(I(Z;A)\) compared to baseline.
performance (measured by accuracy on Unbiased and Bias-conflicting settings) and its ability to remove bias (measured by estimating \(I(Z;A)\) using [5] on the training set). Ideally, a method must achieve on-par or better accuracy than the baseline while learning a representation \(Z\) that does not reflect the attribute bias present in the training set (\(I(Z;A)=0\)), hence successfully removing the bias. However, in Tab. 1, we observe that none of the existing methods applied to CelebA can significantly reduce the bias \(I(Z;A)\) in the extreme bias setting. Similarly, in Tab. 2, we observe that none of the methods applied to Adult dataset can reduce \(I(Z;A)\). These observations are explained by Proposition 1 which states that maintaining classification performance above random guess while achieving \(I(Z;A)=0\) at \(H(Y|A)=0\) is impossible.
\begin{table}
\begin{tabular}{l c c c c} \hline \hline \multirow{2}{*}{Method} & \multicolumn{2}{c}{Test Accuracy} & \multicolumn{2}{c}{Mutual Information} \\ \cline{2-5} & Unbiased \(\uparrow\) & Bias-conflicting \(\uparrow\) & \(I(Z;A)\downarrow\) & \(\Delta\) (\%) \(\uparrow\) \\ \hline Random guess & 50.00 & 50.00 & 0.69 & 0.00 \\ Baseline & 50.59\(\pm\)0.54 & 1.19\(\pm\)0.83 & 0.69\(\pm\)0.00 & 0.00 \\ \hline LNL [20] & 50.10\(\pm\)0.18 & 0.43\(\pm\)0.46 & 0.69\(\pm\)0.01 & 0.00 \\ DI [39] & 50.61\(\pm\)0.28 & 0.65\(\pm\)0.64 & 0.69\(\pm\)0.01 & 0.00 \\ LfF [29] & 50.33\(\pm\)0.34 & 0.78\(\pm\)0.65 & 0.69\(\pm\)0.01 & 0.00 \\ EnD [35] & 50.59\(\pm\)0.75 & 1.18\(\pm\)0.96 & 0.69\(\pm\)0.00 & 0.00 \\ CSAD [41] & 50.76\(\pm\)2.22 & 1.43\(\pm\)2.46 & 0.69\(\pm\)0.01 & 0.00 \\ BCL [17] & 50.83\(\pm\)1.34 & 0.52\(\pm\)0.83 & 0.69\(\pm\)0.00 & 0.00 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Performance of attribute bias removal methods trained under extreme bias in Adult (_TrainEx_ training set) to predict income. \(\Delta\) indicates the difference from baseline. None of the methods can effectively remove the bias \(I(Z;A)\) compared to baseline.
Figure 3: Accuracy and mutual information under different bias strengths in CelebA. As bias strength increases (moving from right to left), the performance of all methods degrades and sharply declines to baseline at the breaking point (labeled by \(\blacktriangle\)).
In Tab. 1, we also observe a trade-off between \(I(Z;A)\) and accuracy, where reducing the bias (when \(\Delta>0\)) results in a reduction in accuracy. This is explained by Theorem 1, which states that when \(H(Y|A)=0\), the amount of remained bias in the learnt feature \(Z\) is an upper bound to the best performance, _i.e._, \(I(Z;Y)\leq I(Z;A)\), and therefore removing more bias can result in lower performance. The only exception to this trade-off seems to be DI [39]. We conjecture that this is due to its enhanced ability in achieving the best attainable classification performance (see Remark 4).
### Analysis of the Strong Bias Region \(H(y|a)>0\)
In this section, we go beyond the extreme bias point, and more generally investigate the consequences of applying existing bias removal methods on the entire range of bias strength, _i.e._, connecting the extreme bias training setting (TrainEx) we studied in Sec. 4.1 to the moderate bias in the original training setting (TrainOri) commonly studied in existing methods. We again study two aspects of each method, its classification performance (measured by accuracy on Unbiased and Bias-conflicting settings) and its ability to remove bias (measured by estimating \(I(Z;A)\) using [5] on the training set). In Figs. 3 and 4, we observe a decline in the performance of all methods as the bias becomes stronger, in both CelebA and Adult datasets, similar to our observation in Colored MNIST in Fig. 1. This observation is consistent with Theorem 1, which states that the bias strength determines an upper bound on the best performance of bias removal methods, regardless of the dataset and method.
In Figs. 2(c) and 3(c), we use breaking points to approximately divide the strong bias region into three phases and explain the observed changes in the performance of methods from the perceptive of Theorem 1. In phase 1, as \(H(Y|A)\) increases from zero to the breaking point (bias strength decreases), we observe that the attribute bias \(I(Z;A)\) is not minimized because of the trade-off between best attainable performance \(I(Z;Y)\) and attribute bias removal when bias is very strong: the methods choose to increase accuracy towards the best attainable accuracy \(I(Z;Y)\) rather than removing attribute bias (this choice is most likely due to the larger weight on the accuracy term in
Figure 4: Accuracy and mutual information under different bias strengths in Adult. As bias strength increases (moving from right to left), the performance of all methods degrades and sharply declines to baseline at the breaking point (labeled by \(\blacktriangle\)).
their objectives). Then, in phase 2, as \(H(Y|A)\) increases through the breaking point (bias strength decreases further), the methods start to minimize attribute bias \(I(Z;A)\) because the upper bound on best attainable performance \(I(Z;Y)\) is now large enough to avoid the trade-off between accuracy and attribute bias removal. Finally, in phase 3, as \(H(Y|A)\) further departs from the breaking point, accuracy gradually approaches its best attainable performance, while attribute bias \(I(Z;A)\) is minimized further below that of the baseline because the weaker bias strength now allows the model to distinguish \(Y\) from \(A\) so that minimizing attribute bias and maximizing accuracy do not compete.
## 5 Conclusion and Future Work
In this work, we mathematically and empirically showed the sensitivity of state-of-the-art attribute bias removal methods to the bias strength. This highlights a previously overlooked limitation of these methods. In particular, we empirically demonstrated that when a protected attribute is strongly predictive of a target, these methods become ineffective. To understand the cause and extent of these findings, we derived an information-theoretical upper bound on the performance of any attribute bias removal method, and verified it in experiments on synthetic, image, and census datasets. These findings not only caution against the use of existing attribute bias removal methods in datasets with potentially strong bias (_e.g._, small datasets), but also motivate the design of future methods that can work even in strong bias situations, for example by utilizing external unlabelled datasets to relax the upper bound. Additionally, investigating the role of bias strength in removing attribute bias from generative models is another interesting direction for future research.
## Acknowledgement
This research is based upon work supported in part by the Office of the Director of National Intelligence (ODNI), Intelligence Advanced Research Projects Activity (IARPA), via [2022-21102100007]. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies, either expressed or implied, of ODNI, IARPA, or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for governmental purposes notwithstanding any copyright annotation therein.
|
2307.04356 | InfLoR-SNN: Reducing Information Loss for Spiking Neural Networks | The Spiking Neural Network (SNN) has attracted more and more attention
recently. It adopts binary spike signals to transmit information. Benefitting
from the information passing paradigm of SNNs, the multiplications of
activations and weights can be replaced by additions, which are more
energy-efficient. However, its "Hard Reset" mechanism for the firing activity
would ignore the difference among membrane potentials when the membrane
potential is above the firing threshold, causing information loss. Meanwhile,
quantifying the membrane potential to 0/1 spikes at the firing instants will
inevitably introduce the quantization error thus bringing about information
loss too. To address these problems, we propose to use the "Soft Reset"
mechanism for the supervised training-based SNNs, which will drive the membrane
potential to a dynamic reset potential according to its magnitude, and Membrane
Potential Rectifier (MPR) to reduce the quantization error via redistributing
the membrane potential to a range close to the spikes. Results show that the
SNNs with the "Soft Reset" mechanism and MPR outperform their vanilla
counterparts on both static and dynamic datasets. | Yufei Guo, Yuanpei Chen, Liwen Zhang, Xiaode Liu, Xinyi Tong, Yuanyuan Ou, Xuhui Huang, Zhe Ma | 2023-07-10T05:49:20Z | http://arxiv.org/abs/2307.04356v2 | # InfLoR-SNN: Reducing Information Loss for Spiking Neural Networks
###### Abstract
The Spiking Neural Network (SNN) has attracted more and more attention recently. It adopts binary spike signals to transmit information. Benefitting from the information passing paradigm of SNNs, the multiplications of activations and weights can be replaced by additions, which are more energy-efficient. However, its "Hard Reset" mechanism for the firing activity would ignore the difference among membrane potentials when the membrane potential is above the firing threshold, causing information loss. Meanwhile, quantifying the membrane potential to 0/1 spikes at the firing instants will inevitably introduce the quantization error thus bringing about information loss too. To address these problems, we propose to use the "Soft Reset" mechanism for the supervised training-based SNNs, which will drive the membrane potential to a dynamic reset potential according to its magnitude, and Membrane Potential Rectifier (MPR) to reduce the quantization error via redistributing the membrane potential to a range close to the spikes. Results show that the SNNs with the "Soft Reset" mechanism and MPR outperform their vanilla counterparts on both static and dynamic datasets.
Keywords:Spiking Neural Network; Information Loss; Soft Reset; Quantization Error; Membrane Potential rectificar.
## 1 Introduction
Deep Neural Networks (DNNs) have greatly improved many applications in computational vision, _e.g_., object detection and recognition [20], object segmentation [44], object tracking [2], etc. In pursuit of models with better performance, more and more complex networks are proposed. However, the increasing complexity poses a new challenge to model deployment on power-constrained devices, thus becoming an impediment to the applications of these advanced complex models. There have been several approaches to address this problem, such as quantization [12, 31, 32], pruning [21], knowledge distillation [41], spiking neural networks (SNNs) [11, 47, 30, 33, 16, 14, 17, 13, 15], and so on. Among these approaches,
the biology-inspired method, SNNs provide a unique way to reduce energy consumption by mimicking the spiking nature of brain neurons. A spiking neuron integrates the inputs over time and fires a spike output whenever the membrane potential exceeds the firing threshold. And using 0/1 spike to transmit information makes SNNs enjoy the advantage of multiplication-free inference by converting multiplication to additions. Furthermore, SNNs are energy-efficient on neuromorphic hardwares, such as SpiNNaker [22], TrueNorth [1], Darwin [36], Tianjic [40], and Loihi [5].
Despite the attractive benefits, there is still a huge performance gap between existing SNN models and their DNN counterparts. We argue that the reason for the low accuracy is there exists information loss in SNNs. First, the information processing of neurons in supervised training-based SNNs are generally following the rules of the Integrate-and-Fire (IF) model or Leaky IF (LIF) model, where once a membrane potential exceeds the firing threshold, a "Hard Reset" operation will force the "residual" potential to be set to 0, _i.e._, once fired, all the information will be taken away. Obviously, this mechanism of "residual" membrane potential-ignored reset mode would fail to preserve the diversity of various membrane potentials. Hence the information encoding capacity of the network is compromised, such that the risk of information loss increases accordingly. Second, although the 0/1 spike information processing paradigm enables SNNs to enjoy the advantage of high efficiency, quantifying the real-valued membrane potential to 0/1 spikes will inevitably introduce the quantization error, which also brings about information loss.
To address the information loss problem, we propose a "Soft Reset"-based IF (SRIF) neuron model that retains the "residual" membrane potential from subtracting its spike value at the firing instants. Hence the diversity of the membrane potentials that exceed the firing threshold will be preserved. Though "Soft Reset" is commonly used in converting methods from ANN to SNN (ANN2SNN) [19, 18, 30, 24] methods, rarely applied in supervised SNNs [27], and has not been
Figure 1: The difference of our “Soft Reset”-based neuron and vanilla “Hard Reset”-based neuron. The membrane potential will be redistributed to reduce the quantization error in our neuron with MPR while not in the vanilla neuron.
discussed in SNN enhancement from the perspective of information loss reducing. In addition, for alleviating quantization error, the Membrane Potential Rectifier (MPR) is proposed, which is performed before the firing activity to adjust the membrane potentials towards the spike values (_i.e._, 0/1). With MPR, the membrane potential will be decoupled as an original one and a modulated one. The original one can keep the mechanism of a neuron and the modulated one enjoys less quantization error than the original one without suffering from any negative effects. The difference between our neuron and the vanilla neuron is illustrated in Fig. 1. Our main contributions are as follows:
* We propose using the SRIF model for supervised training-based SNNs. By retaining the "residual" membrane potential, SRIF enables the networks to distinguish the differences among those membrane potentials that exceed the firing threshold via subtracting their spike values thus enhancing the information encoding capacity of supervised training-based SNNs.
* We present MPR to mitigate the quantization error. By utilizing a non-linear function to modulate the membrane potential close to 0/1 before firing activity triggers, the gap between the potential and its corresponding 0/1 spike value is minified while maintaining the sparse spike activation mechanism of SNNs. To our best knowledge, few works have noticed the quantization error in SNNs, and a simple but effective method for addressing this problem is presented.
* Extensive experiments on both static and dynamic datasets were conducted to verify our method. Results show that the SNN trained with the proposed method is highly effective and efficient compared with other state-of-the-art SNN models, _e.g._, 96.49% top-1 accuracy and 79.41% top-1 accuracy are achieved on the CIFAR-10 and CIFAR-100. These results of our models even outperform their DNN counterparts surprisingly, and it is very rare that SNNs may have a chance to surpass their DNN counterparts.
## 2 Related Work
### Learning Methods of Spiking Neural Networks
The training methods of SNNs can be divided into two categories. The first one is ANN2SNN [19, 18, 30, 24]. ANN2SNN yields the same input-output mapping for the ANN-SNN pair via approximating the continuous activation values of an ANN using ReLU by averaging the firing rate of an SNN under the rate-coding scheme. Since the ANN has achieved great success in many fields, ANN2SNN can maintain the smallest gap with ANNs in terms of performance and can be generalized to large-scale structures. However, being restricted to rate-coding, ANN2SNN usually requires dozens or even hundreds of timesteps to obtain well-performed networks. Lots of efforts have been done to reduce the long inference time, such as weight normalization [9], threshold rescaling [45], soft reset [19], threshold shift [30], and the quantization clip-floor-shift activation function [3], it is still hard to obtain high-performance SNNs with ultra-low latency.
The second one is supervised learning-based SNNs. SNNs quantize the real-valued membrane potentials into 0/1 spikes via the firing activity. Since the gradient of the firing activity function is zero almost everywhere, the gradient descent-based optimizer can not be directly used for the training of SNNs. To alleviate the optimization difficulty, the approximate gradient-based strategy is commonly used, and some related approaches had been proposed to achieve trainable SNNs with high performance. For example, by regarding the SNN as a special RNN, a training method of back-propagation through time with different kinds of surrogate gradient was proposed [37]. The spatio-temporal back-propagation (STBP) [46] method enables SNNs to be trained on the ANN programming platform, which also significantly promotes the direct training research of SNNs. Differentiable spike which can match the finite difference gradient of SNNs well was proposed in [33]. The temporal efficient training (TET) [7] method with a novel loss and a gradient descent regime that succeeds in obtaining more generalized SNNs, has also attracted much attention. In RecDissNN [16], a new perspective to understand the difficulty of training SNNs by analyzing undesired membrane potential shifts is presented and the MPD-Loss to penalize the undesired shifts is proposed. Numerous works verify that supervised learning can greatly reduce the number of timesteps and handle dynamic datasets. It has increasingly aroused researchers' interest in recent years. In this work, we focus on improving the performance of the supervised learning-based SNNs by repressing information loss, which is rarely mentioned in other works.
### Threshold-dependent Batch Normalization
Batch Normalization (BN) is one of the most widely used normalization technologies, which is initially designed for very deep Convolutional Neural Networks (CNNs). As it only focuses on normalizing the spatial feature maps, directly applying BN to SNNs would damage the temporal characteristic of SNNs, which stand with spatio-temporal feature maps, leading to low accuracy. To address this issue, some specially-designed normalization methods for SNNs were proposed recently. Typically, to simultaneously balance neural selectivity and normalize the neuron activity, NeuNorm [46] was proposed. Then, a more effective normalization technique that can take good care of the firing threshold, named threshold-dependent Batch Normalization (tdBN) was further proposed in [49]. It can normalize the feature maps of SNNs in both spatial and temporal domains [49]. Specifically, let \(\mathbf{X}_{t}\in\mathbb{R}^{B\times C\times H\times W}\) represent the input maps at each timestep, where \(t=1,\ldots,T\) (\(B\): batch size; \(C\): channel; \((H,W)\): spatial domain). Then for each channel \(c\), the spatio-temporal sequence \(\mathbf{X}^{(c)}=\{\mathbf{X}_{1}^{(c)},\cdots,\mathbf{X}_{T}^{(c)}\}\) is normalized by tdBN as follows,
\[\tilde{\mathbf{X}}^{(c)}=\lambda\cdot\frac{\alpha V_{th}(\mathbf{X}^{(c)}- \bar{x}^{(c)})}{\sqrt{\text{mean}((\mathbf{X}^{(c)}-\bar{x}^{(c)})^{2})+ \epsilon}}+\beta, \tag{1}\]
where \(V_{th}\) is the firing threshold, \(\alpha\) is a network-structure-dependent hyperparameter, \(\epsilon\) is a tiny constant, \(\lambda\) and \(\beta\) are two learnable parameters,
mean(\(\mathbf{X}^{(c)}\)) is the mean value of \(\mathbf{X}^{(c)}\), \(\tilde{\mathbf{X}}^{(c)}\) is the normalized maps. In this paper, tdBN is also adopted considering its spatio-temporal normalization mechanism.
## 3 Preliminary and Methodology
To avoid the information loss in supervised training-based SNNs, we propose the "Soft Reset" IF (SRIF) model and Membrane Potential Rectificater (MPR).
### "Soft Reset" IF Model
An SNN adopts a biology-inspired spiking neuron that accumulates inputs along the time dimension as its membrane potential and fires a spike when the potential exceeds the firing threshold. This mechanism makes it much different from its DNN counterpart. For better introducing the proposed SRIF neuron, a unified form defined by a recent work [11], is given to describe the dynamics of all kinds of spiking neurons as follows,
\[H[t]=f(U[t-1],X[t]), \tag{2}\]
\[O[t]=\Theta(H[t]-V_{th}), \tag{3}\]
\[U[t]=H[t](1-O[t])+V_{reset}O[t], \tag{4}\]
where \(X[t]\), \(H[t]\), \(U[t]\), and \(O[t]\) are the input, membrane potentials before and after the trigger of a spike, and output spike at the timestep \(t\), respectively. \(V_{th}\) is the firing threshold, and is usually set to 0.5. \(\Theta(\cdot)\) is the step function defined by \(\Theta(x)=1\) for \(x\geq 0\) and \(\Theta(x)=0\) for \(x<0\). \(V_{reset}\) denotes the reset potential, which is set as 0. The function \(f(\cdot)\) describes the neuronal dynamics of spiking neuron models, for the commonly used IF neuron and LIF neuron, \(f(\cdot)\) can be respectively defined as follows,
\[H[t]=U[t-1]+X[t], \tag{5}\]
\[H[t]=\tau U[t-1]+X[t], \tag{6}\]
where \(\tau\) denotes the membrane time constant.
Both LIF and IF neurons have some unique advantages, with decay characteristics introduced by the membrane time constant, LIF neuron behaves more biologically compared with IF neuron, while IF neuron is more efficient due to its addition-only processing manner. In terms of accuracy performance, neither of them show an overwhelming advantage, and more detailed experimental results of these two neurons are provided in Section 4. Considering the subtle gap in performance, we prefer to use LIF model due to its neurodynamic characteristic, from the perspective of brain science research. Conversely, from the perspective
of computer science research, we recommend using IF model, since it is more friendly to hardwares.
However, both the IF model and LIF model might undertake a greater or lesser risk of information loss by the "Hard Reset" mechanism, _i.e._, when the input membrane potentials exceed the firing threshold, the neurons will force the membrane potentials to a fixed value. Such mechanism ignores the "residual" parts of those fired membrane potentials. These "residual" parts contain the diversity of the input potentials, and we argue that a neuron model which can preserve the diversity or differences of these membrane potentials that cause the firing is more suitable.
To this end, along with the consideration of efficiency, we propose using a "Soft Reset" mechanism-based IF neuron, SRIF, which can keep the diversity of the membrane potentials by subtracting their firing spike values from themselves at the time where the threshold is exceeded. Though this similar "Soft Reset" mechanism has been widely used in ANN2SNN [19, 18, 30, 24], there are few works to use it in supervised learning-based SNNs [27]. We found its value in this field from a new perspective to reduce information loss. In SRIF neuron, Eq. (4) is updated as
\[U[t]=H[t](1-O[t])+(H[t]-O[t])O[t]. \tag{7}\]
It can be further simplified as
\[U[t]=H[t]-O[t]. \tag{8}\]
It can be seen that, similar to IF neuron, SRIF is also an addition-only model, thus enjoying computational efficiency when implementing on hardwares. Fig. 2 compares the difference between IF neuron and SRIF neuron in an intuitive way. Suppose that both models receive weighted input sequence of \(1.5V_{th}\), \(1.2V_{th}\), \(1.5V_{th}\), \(0.9V_{th}\), and \(1.4V_{th}\) across 5 consecutive timesteps. Our SRIF neuron will produce three spikes by retaining the residual potentials at the firing instants as depicted in Fig. 2. Whereas, the IF neuron will produce four spikes.
### Membrane Potential Rectificater
To further mitigate the information loss, we present a non-linear function, called MPR by reducing the quantization error. MPR aims to redistribute the membrane potential before it is operated by the step function. It only modulates the membrane potential that is presented to the step function but does not modify the value of membrane potential, which receives and accumulates spikes from other neurons. Specifically, we further distinguish the membrane potentials as the original one, \(H\) as in Eq. (2) and the modulated one, \(\hat{H}\), which is the membrane potential that will be presented to the step function. In all previous works, \(H\) and \(\hat{H}\) are treated as the same. While in this paper, we would like to provide a new perspective that using a decoupling function to separate \(H\) and \(\hat{H}\) can be helpful. Specifically, \(H\) manages the original tasks as in other work, \(\hat{H}\) derives from \(H\) with a non-linear function, \(\varphi(\cdot)\), and it will be fed into the step function with a modulated form that can shrink the quantization error. With
this decoupling mechanism, a neuron model can not only keep the membrane potential updating rule but also enjoy less quantization error.
Before giving the full details of the MPR, we try to formulate the quantization error first. It is clear that the quantization errors corresponding to different membrane potentials should be different. Hence, a value closer to its quantization spike, \(o\), enjoys less quantization error. In specific, the firing threshold divides the membrane potentials into two parts, the part with smaller values is assigned to "0" spike, and the other with larger values is assigned to "1" spike. Then the quantization error depends on the margin between the membrane potential and its corresponding spike. Therefore, the quantization error can be defined as the square of the difference between the membrane potential and its corresponding quantization spike value as follows:
\[\mathcal{L}_{q}=(u-o)^{2}, \tag{9}\]
where \(u\) is the membrane potential and \(o\in\{0,1\}\). when \(u\) is below the firing threshold, \(o\) is 0, otherwise, 1.
Hence, the design of MPR should obey the following two principles:
* **Spike-approaching**: the modulated membrane potential, \(\hat{H}\) should be closer to the 0/1 spikes than the original membrane potential, \(H\). This principle ensures quantization error reduction.
* **Firing-invariance**: for the \(H\) less than \(V_{th}\), the MPR should not produce the \(\hat{H}\) greater than \(V_{th}\) and vice versa. This principle ensures the neuron output be consistent with or without using MPR.
Figure 2: The difference of “Hard Reset” IF neuron and “Soft Reset” IF (SRIF) neuron.
Based on the above two principles, we define the MPR as the following symmetrical function:
\[\varphi(u)=\left\{\begin{array}{ll}-(1-u)^{1/3}+1,&u{<}0,\\ \frac{1}{2tanh(3/2)}tanh(3(u-1/2))+1/2,&0\leq u\leq 1,\\ (u)^{1/3},&u{>}1.\end{array}\right. \tag{10}\]
Fig. 3 shows the response curve of the designed MPR function following the principles of spike-approaching and firing-invariance.
According to [49], the membrane potential follows a Gaussian distribution, \(\mathcal{N}(\mu;\sigma)\). Hence, to visualize the effect of the MPR, we sample 1000,00 values from a Gaussian distribution with \(\mathcal{N}(1/2;1)\), and present them to the MPR. Then the distribution of these 1000,00 MPR outputs is drawn in Fig. 4. It can be seen that the unimodal distribution, \(\mathcal{N}(1/2;1)\) is adjusted to a bimodal distribution which is with less quantization error since it can naturally gather the membrane potentials near "0" and "1".
Moreover, it is worth noting that, the redistributed membrane potential, \(\hat{H}\) by MPR is only used for narrowing the gap between the true membrane potential, \(H\) and its quantization spike. It will not replace the original \(H\) in our
Figure 4: The effect of the MPR. The original membrane potential distribution (left). The redistributed membrane potential distribution by MPR (right).
Figure 3: The MPR function.
SRIF neuron model. Then the complete new dynamics of the SRIF model can be described as follows,
\[H[t]=U[t-1]+X[t], \tag{11}\]
\[\hat{H}[t]=\varphi(H[t]), \tag{12}\]
\[O[t]=\Theta(\hat{H}[t]-V_{th}), \tag{13}\]
\[U[t]=H[t]-O[t]. \tag{14}\]
The detailed Feed-Forward procedure for the SRIF neuron with MPR is given in Algo.1.
## 4 Experiment
The proposed methods were evaluated on various static datasets (CIFAR-10 [25], CIFAR-100 [25], ImageNet [6]) and one neuromorphic dataset (CIFAR10-DVS [29]) with widely-used spiking archetectures including ResNet20 [42, 45], VGG16 [42], ResNet18 [10], ResNet19 [49], and ResNet34 [10].
### Datasets and Settings
**Datasets.** The CIFAR-10(100) dataset consists of 60,000 images in 10(100) classes with \(32\times 32\) pixels. The number of the training images is 50,000, and that of the test images is 10,000. The CIFAR10-DVS dataset is the neuromorphic version of the CIFAR-10 dataset. It is composed of 10,000 images in 10 classes, with 1000 images per class. ImageNet dataset has more than 1,250,000 training images and 50,000 test images.
**Preprocessing.** Data normalization is applied on all static datasets to ensure that input images have 0 mean and 1 variance. Besides, the random horizontal flipping and cropping on these datasets were conducted to avoid overfitting. For CIFAR-10, the AutoAugment [4] and Cutout [8] were used for data augmentation. For the neuromorphic dataset, since the CIFAR10-DVS dataset does not separate data into training and testing sets, we split the dataset into 9000 training images and 1000 test images similar to [47]. For data preprocessing and augmentation, we resized the training image frames to \(48\times 48\) as in [49] and adopted random horizontal flip and random roll within 5 pixels. And the test images are just resized to \(48\times 48\) without any additional processing.
**Training setup.** For all the datasets, the firing threshold \(V_{th}\) was set as 0.5 and \(V_{reset}\) as 0. For static image datasets, the images were encoded to binary spike using the first layer of the SNN, as in recent works [42, 11, 10]. This is similar to rate-coding. For the neuromorphic image dataset, we used the 0/1 spike format directly. The neuron models in the output layer accumulated the incoming inputs without generating any spike as the output like in [42]. For CIFAR-10(100) and CIFAR10-DVS datasets, the SGD optimizer with the momentum of 0.9 and learning rate of 0.01 with cosine decayed [34] to 0. All models were trained within 400 epochs with the same batch size of 128. For the ImageNet dataset, the SGD optimizer with a momentum set as 0.9 and a learning rate of 0.1 with cosine decayed [34] to 0. All models are trained within 320 epochs as in [10]. The batch size is set to 64.
### Ablation Study for Different Neuron Models
We first conducted a set of ablation experiments to verify the effectiveness of the proposed SRIF model on CIFAR-10(100) using ResNet20 as the backbone under various timesteps without MPR. The results are shown in Tab. 1.
It can be seen that whether on CIFAR-10 or CIFAR-100, the SRIF neuron always obtains the best result ranging from 2 timesteps to 8 timesteps. This indicates the superiority of the SRIF neuron. On the other hand, the LIF neuron performs better than the "Hard Reset" IF neuron on CIFAR-10, while the IF neuron performs better on CIFAR-100, even though the LIF neuron is more like a biological neuron. This comparison also shows that, although SNNs are proposed to imitate the biological neural networks, for the implementation of large-scale networks, they still need to rely on computer hardwares. Hence, the characteristics of computational science should also be considered. In this respect, the SRIF neuron is more suitable for its advantage of low power consumption and capacity of reducing information loss.
### Addition of MPR
Then, a set of ablation experiments for the MPR were conducted on CIFAR-10(100) using ResNet20 and ResNet19 as backbones within 4 timesteps. Results in Tab. 2 show that the MPR can greatly improve performance. Especially on
CIFAR-100, where ResNet20 with MPR increases the accuracy by 2.73%. These results verify the effectiveness of MPR in terms of performance improvement.
We also computed the average quantization error of the first layer of the second block in the ResNet20/19 before and after MPR on the test set of CIFAR-10(100), respectively. Results in Tab. 3 show that the quantization error is obviously reduced by the MPR. The overall original membrane potential distribution and modulated membrane potential distribution by MPR of the first layer of the second block in ResNet20 on CIFAR-10 and CIFAR-100 test sets are shown in Fig. 5. It shows that the MPR adjusts the membrane potential distribution near "0" and "1", which is closer to its quantization spike. Put together, these results quantitatively support the effectiveness of MPR in reducing quantization error.
### Comparisons with Other Methods
Our method was further compared with other state-of-the-art SNNs on static and neuromorphic datasets. Results are shown in Tab. 4, where for each run, the mean accuracy and standard deviation of 3 trials are listed. For simplification, **InfLoR** (_i.e._, short for **Inf**ormation **Loss** **R**educing) is used to denote the combination of SRIF and MPR.
\begin{table}
\begin{tabular}{c c c c} \hline \hline Dataset & Neuron model & Timestep & Accuracy \\ \hline \multirow{10}{*}{CIFAR-10} & “Hard Reset” LIF & 2 & 90.36\% \\ & “Hard Reset” IF & 2 & 90.07\% \\ & “Soft Reset” IF (SRIF) & 2 & **90.38\%** \\ \cline{2-4} & “Hard Reset” LIF & 4 & 92.22\% \\ & “Hard Reset” IF (SRIF) & 4 & **92.46\%** \\ \cline{2-4} & “Hard Reset” LIF & 6 & 92.66\% \\ & “Hard Reset” IF (SRIF) & 6 & **93.40\%** \\ \cline{2-4} & “Hard Reset” LIF & 8 & 92.90\% \\ & “Hard Reset” IF & 8 & 92.86\% \\ & “Soft Reset” IF (SRIF) & 8 & **94.09\%** \\ \hline \multirow{10}{*}{CIFAR-100} & “Hard Reset” LIF & 2 & 62.67\% \\ & “Hard Reset” IF & 2 & 63.43\% \\ \cline{2-4} & “Soft Reset” IF (SRIF) & 2 & **63.85\%** \\ \cline{2-4} & “Hard Reset” LIF & 4 & 66.00\% \\ & “Hard Reset” IF & 4 & 66.95\% \\ & “Soft Reset” IF (SRIF) & 4 & **67.90\%** \\ \cline{2-4} & “Hard Reset” LIF & 6 & 67.44\% \\ & “Hard Reset” IF & 6 & 68.31\% \\ & “Soft Reset” IF (SRIF) & 6 & **69.59\%** \\ \cline{2-4} & “Hard Reset” LIF & 8 & 67.85\% \\ & “Hard Reset” IF & 8 & 69.14\% \\ & “Soft Reset” IF (SRIF) & 8 & **69.90\%** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Ablation study for different neuron models without MPR.
**CIFAR-10(100).** For CIFAR-10, our method improves network performance across all commonly used backbones in SNNs. ResNet19-based InfLoR-SNN achieved 96.49% top-1 accuracy with 6 timesteps, which outperforms its STBP-tdBN counterpart with 3.33% higher accuracy and its ANN counterpart 0.20% higher accuracy even. The ResNet20-based InfLoR-SNN can reach to 93.65%, while only 92.54% in [42]. And our VGG16-based network also shows higher accuracy than other methods with fewer timesteps. On CIFAR-100, InfLoR-SNN also performs better and achieves a 1.89% increment on VGG16. Noteworthy, InfLoR-SNN significantly surpasses Diet-SNN [42] with 7.12% higher accuracy, which is not easy to achieve in the SNN field. Again, our ResNet19 also outperforms its ANN counterpart. To our best knowledge, it is the first time that the SNN can outperform its ANN counterpart.
**ImageNet.** For the ImageNet dataset, ResNet18 and ResNet34 were used as the backbones. Results show that our ResNet18 achieves a 1.60% increment on SEW ResNet18 and a 2.46% increment on Spiking ResNet18. The accuracy of our ResNet34 does not exceed SEW ResNet34. However, SEW ResNet34 [10] transmits information with integers, which is not a typical SNN. For a fair comparison, we also report the result of Spiking ResNet34 in [10] which is worse than our method. Moreover, our InfLoR-based ResNet34 with 4 timesteps still obviously outperforms STBP-tdBN-based RersNet34 with 6 timesteps.
\begin{table}
\begin{tabular}{l l l c c} \hline \hline Dataset & Architecture & Method & Timestep & Accuracy \\ \hline \multirow{4}{*}{CIFAR-10} & ResNet20 & SRIF w/o MPR & 4 & 92.46\% \\ & & SRIF w/ MPR & 4 & **92.94\%** \\ \cline{2-5} & ResNet19 & SRIF w/o MPR & 4 & 95.44\% \\ & & SRIF w/ MPR & 4 & **96.27\%** \\ \hline \multirow{4}{*}{CIFAR-100} & ResNet20 & SRIF w/o MPR & 4 & 67.90\% \\ & & SRIF w/ MPR & 4 & **70.63\%** \\ \cline{2-5} & ResNet19 & SRIF w/o MPR & 4 & 77.85\% \\ \cline{2-5} & ResNet19 & SRIF w/ MPR & 4 & **78.42\%** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Ablation study for MPR.
\begin{table}
\begin{tabular}{l l l l c} \hline \hline Dataset & Architecture & Method & Timestep & Avg. error \\ \hline \multirow{4}{*}{CIFAR-10} & ResNet20 & Before MPR & 4 & 0.28 \\ & After MPR & 4 & **0.04** \\ \cline{2-5} & ResNet19 & Before MPR & 4 & 0.20 \\ & & After MPR & 4 & **0.03** \\ \hline \multirow{4}{*}{CIFAR-100} & ResNet20 & Before MPR & 4 & 0.38 \\ & & After MPR & 4 & **0.05** \\ \cline{1-1} \cline{2-5} & ResNet19 & Before MPR & 4 & 0.32 \\ \cline{1-1} & & After MPR & 4 & **0.04** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Quantization error.
\begin{table}
\begin{tabular}{l l l l l l} \hline \hline Dataset & Method & Type & Architecture & Timestep & Accuracy \\ \hline \multirow{8}{*}{CIFAR-10} & SpikeNorm [45] & ANN2SNN & VGG16 & 2500 & 91.55\% \\ & Hybrid-Train [43] & Hybrid & VGG16 & 200 & 92.02\% \\ & Spike-basedBP [28] & SNN training & ResNet11 & 100 & 90.95\% \\ & STBP [47] & SNN training & CIFARNet & 12 & 90.53\% \\ & TSSL-BP [48] & SNN training & CIFARNet & 5 & 91.41\% \\ & PLIF [11] & SNN training & PLIFNet & 8 & 93.50\% \\ \cline{2-6} & \multirow{4}{*}{SNN training} & VGG16 & 5 & 92.70\% \\ & & & 10 & 93.44\% \\ \cline{2-6} & & ResNet20 & 5 & 91.78\% \\ \cline{2-6} & & & 10 & 92.54\% \\ \cline{2-6} & \multirow{4}{*}{SNN training} & \multirow{4}{*}{ResNet19} & 2 & 92.34\% \\ & & & 4 & 92.92\% \\ & & & 6 & 93.16\% \\ \cline{2-6} & ANN* & ResNet19 & 1 & 96.29\% \\ \cline{2-6} & & & 2 & **94.44\%**\(\pm\)0.08 \\ & & & 4 & **96.27\%**\(\pm\)0.07 \\ & & & 6 & **96.49\%**\(\pm\)0.08 \\ \cline{2-6} & \multirow{4}{*}{SNN training} & ResNet20 & 5 & **93.01\%**\(\pm\)0.06 \\ & & & 10 & **93.65\%**\(\pm\)0.04 \\ \cline{2-6} & & VGG16 & 5 & **94.06\%**\(\pm\)0.08 \\ \cline{2-6} & BinarySNN [35] & ANN2SNN & VGG15 & 62 & 63.20\% \\ & Hybrid-Train [43] & Hybrid & VGG11 & 125 & 67.90\% \\ & T2FSNN [39] & ANN2SNN & VGG16 & 680 & 68.80\% \\ & Burst-coding [38] & ANN2SNN & VGG16 & 3100 & 68.77\% \\ & Phase-coding [23] & ANN2SNN & VGG16 & 8950 & 68.60\% \\ \cline{2-6} & \multirow{4}{*}{SNN training} & ResNet20 & 5 & 64.07\% \\ & & & VGG16 & 5 & 69.67\% \\ \cline{2-6} & ANN* & ANN & ResNet19 & 1 & 78.61\% \\ \cline{2-6} & & & ResNet20 & 5 & **71.19\%**\(\pm\)0.09 \\ \cline{2-6} & & & & 10 & **73.17\%**\(\pm\)0.08 \\ \cline{2-6} & \multirow{4}{*}{SNN training} & \multirow{4}{*}{ResNet19} & 2 & **75.56\%**\(\pm\)0.11 \\ & & & 4 & **78.42\%**\(\pm\)0.09 \\ & & & 6 & **79.51\%**\(\pm\)0.06 \\ \hline \multirow{8}{*}{ImageNet} & Hybrid-Train [43] & Hybrid & ResNet34 & 250 & 61.48\% \\ & SpikeNorm [45] & ANN2SNN & ResNet34 & 2500 & 69.96\% \\ \cline{2-6} & STBP-tdBN [49] & SNN training & ResNet34 & 6 & 63.72\% \\ \cline{2-6} & SEW ResNet [10] & SNN training & ResNet18 & 4 & 63.18\% \\ \cline{2-6} & \multirow{4}{*}{S spiking ResNet [10]} & ResNet34 & 4 & 67.04\% \\ \cline{2-6} & & ResNet18 & 4 & 62.32\% \\ \cline{2-6} & & ResNet34 & 4 & 61.86\% \\ \cline{2-6} & **InfLoR-SNN** & SNN training & ResNet18 & 4 & **64.78\%**\(\pm\)0.07 \\ \cline{2-6} & & ResNet34 & 4 & 65.54\%\(\pm\)0.08 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Comparison with SoTA methods.* denotes self-implementation results.
**CIFAR10-DVS.** For the neuromorphic dataset, CIFAR10-DVS, InfLoR-SNN achieves the best performance with 75.50% and 75.10% top-1 accuracy in 10 timesteps with ResNet19 and ResNet18 as backbones, and obtains 7.80% improvement compared with STBP-tdBN for ResNet19. It's worth noting that, as a more complex model, ResNet19 only performs a little better than ResNet20 on CIFAR10-DVS. It might be that this neuromorphic dataset suffers much more noise than static ones, thus a more complex model is easier to overfit.
## 5 Conclusions
This work aims at addressing the information loss problem caused by the "Hard Reset" mechanism of neurons and the 0/1 spike quantification. Then, the SRIF model, which will drive the membrane potential to a dynamic reset potential, and the MPR that can adjust the membrane potential to a new value closer to quantification spikes than itself are proposed. A detailed analysis of why the SRIF and MPR can reduce the information loss is provided. Furthermore, abundant ablation studies of the proposed methods are given. Combining these two methods, our SNNs outperform other state-of-the-art methods.
Figure 5: The effect of MPR. The overall original membrane potential distribution (left) and the redistributed membrane potential distribution by MPR (right) of the first layer of the second block in ResNet20 on CIFAR-10 and CIFAR-100 test sets.
\begin{table}
\begin{tabular}{l l l l l l} \hline \hline Dataset & Method & Type & Architecture & Timestep & Accuracy \\ \hline \multirow{4}{*}{CIFAR10-DVS} & Rollout [26] & Rollout & DenseNet & 10 & 66.80\% \\ & STBP-tdBN [49] & SNN training & ResNet19 & 10 & 67.80\% \\ \cline{2-6} & **InfLoR** & SNN training & ResNet19 & 10 & **75.50\%**\(\pm\)0.12 \\ \cline{1-1} \cline{2-6} & & ResNet20 & 10 & **75.10\%**\(\pm\)0.09 \\ \hline \hline \end{tabular}
\end{table}
Table 5: Training Spiking Neural Networks on CIFAR10-DVS. |
2303.10993 | A Survey on Oversmoothing in Graph Neural Networks | Node features of graph neural networks (GNNs) tend to become more similar
with the increase of the network depth. This effect is known as over-smoothing,
which we axiomatically define as the exponential convergence of suitable
similarity measures on the node features. Our definition unifies previous
approaches and gives rise to new quantitative measures of over-smoothing.
Moreover, we empirically demonstrate this behavior for several over-smoothing
measures on different graphs (small-, medium-, and large-scale). We also review
several approaches for mitigating over-smoothing and empirically test their
effectiveness on real-world graph datasets. Through illustrative examples, we
demonstrate that mitigating over-smoothing is a necessary but not sufficient
condition for building deep GNNs that are expressive on a wide range of graph
learning tasks. Finally, we extend our definition of over-smoothing to the
rapidly emerging field of continuous-time GNNs. | T. Konstantin Rusch, Michael M. Bronstein, Siddhartha Mishra | 2023-03-20T10:21:29Z | http://arxiv.org/abs/2303.10993v1 | # A Survey on Oversmoothing in Graph Neural Networks
###### Abstract
Node features of graph neural networks (GNNs) tend to become more similar with the increase of the network depth. This effect is known as _over-smoothing_, which we axiomatically define as the exponential convergence of suitable similarity measures on the node features. Our definition unifies previous approaches and gives rise to new quantitative measures of over-smoothing. Moreover, we empirically demonstrate this behavior for several over-smoothing measures on different graphs (small-, medium-, and large-scale). We also review several approaches for mitigating over-smoothing and empirically test their effectiveness on real-world graph datasets. Through illustrative examples, we demonstrate that mitigating over-smoothing is a necessary but not sufficient condition for building deep GNNs that are expressive on a wide range of graph learning tasks. Finally, we extend our definition of over-smoothing to the rapidly emerging field of continuous-time GNNs.
## 1 Introduction
Graph Neural Networks (GNNs) (Sperduti, 1994; Goller & Kuchler, 1996; Sperduti & Starita, 1997; Frasconi et al., 1998; Gori et al., 2005; Scarselli et al., 2008; Bruna et al., 2014; Defferrard et al., 2016; Kipf & Welling, 2017; Monti et al., 2017; Gilmer et al., 2017) have emerged as a powerful tool for learning on relational and interaction data. These models have been successfully applied on a variety of different tasks, e.g. in computer vision and graphics Monti et al. (2017), recommender systems Ying et al. (2018), transportation Derrw-Pinion et al. (2021), computational chemistry (Gilmer et al., 2017), drug discovery Gaudelet et al. (2021), particle physics (Shlomi et al., 2020), and analysis of social networks (see Zhou et al. (2019); Bronstein et al. (2021) for additional applications).
The number of layers in a neural network (referred to as "depth" and giving the name to the entire field of "deep learning") is often considered to be crucial for its performance on real-world tasks. For example, convolutional neural networks (CNNs) used in computer vision, often use tens or even hundreds of layers. In contrast, most GNNs encountered in applications are relatively shallow and often have just few layers. This is related to several issues impairing the performance of deep GNNs in realistic graph-learning settings: graph bottlenecks (Alon & Yahav, 2021), over-squashing (Topping et al., 2021; Deac et al., 2022), and over-smoothing (Li et al., 2018; Nt & Maehara, 2019; Oono & Suzuki, 2020). In this article we focus on the over-smoothing phenomenon, which _loosely_ refers to the exponential convergence of all node features towards the same constant value as the number of layers in the GNN increases. While it has been shown that small amounts of smoothing are desirable for regression and classification tasks (Keriven, 2022), excessive smoothing (or 'over-smoothing') results in convergence to a non-informative limit. Besides being a key limitation in the development of deep multi-layer GNNs, over-smoothing can also severely impact the ability of GNNs to handle _heterophilic_ graphs (Zhu et al., 2020), in which node labels tend to differ from the labels of the neighbors and thus long-term interactions have to be learned.
Recent literature has focused on precisely defining over-smoothing through measures of node feature similarities such as the the graph Dirichlet (Rusch et al., 2022; Cai & Wang, 2020; Zhao & Akoglu, 2019; Zhou et al., 2021), cosine similarity (Chen et al., 2020), and other related similarity scores (Zhou et al., 2020). With the abundance of such measures, however, there is currently still a conceptual gap in a general definition of over-smoothing that would provide a unification of existing approaches. Moreover, previous work mostly measures the similarity of node features and does not explicitly consider the rate of convergence of over-smoothing measures with respect to an increasing number of GNN layers.
In this article, we aim to unify several recent approaches and define over-smoothing in a formal and tractable manner through an axiomatic construction. Through our definition, we rule out problematic measures such as the Mean Average Distance that does not provide a sufficient condition for over-smoothing. We then review several approaches to mitigate over-smoothing and provide their extensive empirical evaluation. These empirical studies lead to the insight that meaningfully solving over-smoothing in deep GNNs is more elaborate than simply forcing the node features not to converge towards the same node value when the number of layers is increased. Rather, there needs to be a subtle balance between the expressive power of the deep GNN and its ability to preserve the diversity of node features in the graph. Finally, we extend our definition to the rapidly emerging sub-field of continuous-time GNNs (Chamberlain et al., 2021, 2021, 2022, 2023; Bodnar et al., 2022; Di Giovanni et al., 2022).
## 2 Definition of over-smoothing
Let \(\mathcal{G}=(\mathcal{V},\mathcal{E}\subseteq\mathcal{V}\times\mathcal{V})\) be an undirected graph with \(|\mathcal{V}|=v\) nodes and \(|\mathcal{E}|=e\) edges (unordered pairs of nodes \(\{i,j\}\) denoted \(i\sim j\)). The \(1\)-_neighborhood_ of a node \(i\) is denoted \(\mathcal{N}_{i}=\{j\in\mathcal{V}:i\sim j\}\). Furthermore, each node \(i\) is endowed with an \(m\)-dimensional feature vector \(\mathbf{X}_{i}\); the node features are arranged into a \(v\times m\) matrix \(\mathbf{X}=(\mathbf{X}_{ik})\) with \(i=1,\ldots,v\) and \(k=1,\ldots,m\).
Message-Passing GNN (MPNN) updates the node features by performing several iterations of the form,
\[\mathbf{X}^{n}=\sigma(\mathbf{F}_{\theta^{n}}(\mathbf{X}^{n-1},\mathcal{G})),\quad\forall n=1,\ldots,N, \tag{1}\]
where \(\mathbf{F}_{\theta^{n}}\) is a _learnable_ function with parameters \(\theta^{n}\), \(\mathbf{X}^{n}\in\mathbb{R}^{v\times m_{n}}\) are the \(m\)-dimensional hidden node features, and \(\sigma\) is an element-wise non-linear activation function. Here, \(n\geq 1\) denotes the \(n\)-th layer with \(n=0\) being the input layer and \(N\) the total number of layers (depth). In particular, we consider local (1-neighborhood) coupling of the form \((\mathbf{F}(\mathbf{X},\mathcal{G}))_{i}=\mathbf{F}(\mathbf{X}_{i},\mathbf{X }_{j\in\mathcal{N}_{i}})\) operating on the multiset of 1-neighbors of each node. Examples of such functions used in the graph machine learning literature (Bronstein et al., 2021) include _graph convolutions_(Kipf and Welling, 2017) and _attentional message passing_(Velickovic et al., 2018).
There exist a variety of different approaches to quantify over-smoothing in deep GNNs, e.g. measures based on the Dirichlet energy on graphs (Rusch et al., 2022; Cai and Wang, 2020; Zhao and Akoglu, 2019; Zhou et al., 2021), as well as measures based on the mean-average distance (MAD) (Chen et al., 2020; Zhou et al., 2020), and references therein. However, most previous approaches lack a formal definition of over-smoothing as well as provide approaches to measure over-smoothing which are not sufficient to quantify this issue. Thus, the aim of this survey is to establish a unified, rigorous, and tractable definition of over-smoothing, which we provide in the following.
**Definition 1** (Over-smoothing).: _Let \(\mathcal{G}\) be an undirected, connected graph and \(\mathbf{X}^{n}\in\mathbb{R}^{v\times m}\) denote the \(n\)-th layer hidden features of an \(N\)-layer GNN defined on \(\mathcal{G}\). Moreover, we call \(\mu:\mathbb{R}^{v\times m}\longrightarrow\mathbb{R}_{\geq 0}\) a **node-similarity measure** if it satisfies the following axioms:_
1. \(\exists\mathbf{c}\in\mathbb{R}^{m}\) _with_ \(\mathbf{X}_{i}=\mathbf{c}\) _for all nodes_ \(i\in\mathcal{V}\Leftrightarrow\mu(\mathbf{X})=0\)_, for_ \(\mathbf{X}\in\mathbb{R}^{v\times m}\)__
2. \(\mu(\mathbf{X}+\mathbf{Y})\leq\mu(\mathbf{X})+\mu(\mathbf{Y})\)_, for all_ \(\mathbf{X},\mathbf{Y}\in\mathbb{R}^{v\times m}\)__
_We then define_ **over-smoothing with respect to \(\mu\)** _as the layer-wise exponential convergence of the node-similarity measure_ \(\mu\) _to zero, i.e.,_
1. \(\mu(\mathbf{X}^{n})\leq C_{1}e^{-C_{2}n}\)_, for_ \(n=0,\ldots,N\) _with some constants_ \(C_{1},C_{2}>0\)_._
Note that without loss of generality we assume that the node-similarity measure \(\mu\) converges to zero (any node-similarity measure that converges towards a non-zero constant can easily be recast). Further remarks about Definition 1 are in order.
**Remark 2.1**.: _Condition 1 in Definition 1 simply formalizes the widely accepted notion that over-smoothing is caused by node features converging to a constant node vector whereas condition 3 provides a more stringent, quantitative measure of this convergence. Note that the triangle inequality or subadditivity (condition 2) rules out degenerate choices of similarity measures._
**Remark 2.2**.: _Definition 1 only considers the case of connected graphs. However, this definition can be directly generalized to disconnected graphs, where we apply a node-similarity measure \(\mu_{S}\) on every connected component \(S\subseteq\mathcal{V}\), and define the global similarity measure as the sum of the node-similarity measures on each connected component, i.e., \(\mu=\sum_{S}\mu_{S}\). This way we ensure to cover the case of different connected components converging to different constant node values._
## 3 Over-smoothing measures
Existing approaches to measure over-smoothing in deep GNNs have mainly been based on concept of _Dirichlet energy_ on graphs,
\[\mathcal{E}(\mathbf{X}^{n})=\frac{1}{v}\sum_{i\in\mathcal{V}}\sum_{j\in\mathcal{ N}_{i}}\|\mathbf{X}^{n}_{i}-\mathbf{X}^{n}_{j}\|_{2}^{2}, \tag{2}\]
(note that instead of normalizing by \(1/v\) we can equivalently normalize the terms inside the norm based on the node degrees \(d_{i}\), i.e. \(\|\frac{\mathbf{X}^{n}_{i}}{\sqrt{1+d_{i}}}-\frac{\mathbf{X}^{n}_{j}}{\sqrt{1+d _{j}}}\|_{2}^{2}\)). It is straightforward to check that the measure,
\[\mu(\mathbf{X}^{n})=\sqrt{\mathcal{E}(\mathbf{X}^{n})}, \tag{3}\]
satisfies the conditions 1 and 2 in the definition 1 and thus, constitutes a bona fide node-similarity measure. Note that in the remainder of this article, we will refer to the square root of the Dirichlet energy simply as the Dirichlet energy.
In the literature, _Mean Average Distance_ (MAD),
\[\mu(\mathbf{X}^{n})=\frac{1}{v}\sum_{i\in\mathcal{V}}\sum_{j\in\mathcal{N}_{i }}1-\frac{\mathbf{X}^{n\,\top}_{i}\mathbf{X}^{n}_{j}}{\|\mathbf{X}^{n}_{i}\| \mathbf{X}^{n}_{j}\|}. \tag{4}\]
has often been suggested as a measure of over-smoothing. We see that in contrast to the Dirichlet energy, _MAD is not a node-similarity measure_, as it does not fulfill condition 1 nor condition 2 of the over-smoothing definition 1. In fact, MAD is always zero in the scalar case, where all node features share the same sign for each feature dimension. This makes MAD a very problematic measure for over-smoothing as \(\mu(\mathbf{X})=0\) does not represent a sufficient condition for over-smoothing to happen. However, as we will see in the subsequent section, in the multi-dimensional case (\(m>1\)) MAD does converge exponentially to zero for increasing number of layers if the GNN over-smooths and thus fulfills condition 3 of the over-smoothing definition 1. Therefore, we conclude that under careful considerations of the specific use-case, MAD may be used as a measure for over-smoothing. However, since the Dirichlet energy fulfills all three conditions of Definition 1 and is numerically more stable to compute, it should always be favored over MAD.
It is natural to ask if there exist other measures that constitute a node-similarity measure as of Definition 1 and can thus be used to define over-smoothing. While the Dirichlet energy denotes a canonical choice in this context, there are other measures that can be used. For instance, instead of basing the Dirichlet energy in (2) on the \(L^{2}\) norm, any other \(L^{p}\)-norm (\(p>1\)) can be used.
### Empirical evaluation of different measures for over-smoothing
Rusch et al. (2022) have empirically demonstrated the qualitative behavior described in Definition 1 on a \(10\times 10\) regular 2-dimensional grid with one-dimensional uniform random (hidden) node features. We extend this empirical study in two directions, first to higher dimensional node features and also to real-world graphs, namely Texas (Pei et al., 2020), Cora (McCallum et al., 2000), and Cornell5 (Facebook 100 dataset). Note that as mentioned above, the extension to higher dimensional node features is necessary in order to empirically evaluate MAD, as MAD is zero for any one-dimensional node features sharing the same sign.
Since we are interested only in the dynamics of the Dirichlet energy and MAD associated with the propagation of node features through different GNN architectures, we omit the original input node features of the real-world graph dataset Cora and exchange them for standard normal random variables, i.e., \(\mathbf{X}_{jk}\sim\mathcal{N}(0,1)\) for all nodes \(j\) and every feature \(k\). In Fig. 1 we set the input and hidden dimension of the node features to \(128\) and plot the (logarithm of) the Dirichlet energy (2) and MAD (4)) of each layer's node features with respect to the (logarithm of) layer number for three popular GNN models, i.e., GCN, GAT and the GraphSAGE architecture of Hamilton et al. (2017). We can see that all three GNN architectures _over-smooth_, with both layer-wise measures converging exponentially fast to zero for increasing number of layers. Moreover, we observe that this behavior is not just restricted to the structured and regular grid dataset of Rusch et al. (2022), but the same behavior (i.e., exponential convergence of the measures with respect to increasing number of layers) can be seen on all the three real-world graph datasets considered here.
It is important to emphasize the importance of the **exponential convergence** of the layer-wise over-smoothing measure \(\mu\) to zero in Definition 1. Algebraic convergence is not sufficient for the GNN to suffer from over-smoothing. This can be seen in Fig. 1, where for instance the Dirichlet energy of GCN, GraphSAGE and GAT reach machine-precision zero after a maximum of \(64\) layers, while for instance a linear convergence of the Dirichlet energy would still have a Dirichlet energy of around \(1\) for an initial energy of around \(100\), even after \(128\) hidden layers.
## 4 Reducing over-smoothing
### Methods
Several methods to mitigate (or at least reduce) the effect of over-smoothing in deep GNNs have recently been proposed. While we do not discuss each individual approach, we highlight several recent methods in this context, all of which can be classified into one of the following classes.
Normalization and RegularizationA proven way to reduce the over-smoothing effect in deep GNNs is to regularize the training procedure. This can be done either explicitly by penalizing deviations of over-smoothing measures during training or implicitly by normalizing the node feature embeddings and by adding noise to the optimization process. An example of explicit regularization techniques can be found in Energetic Graph Neural Networks (EGNNs) (Zhou et al., 2021), where the authors measure over-smoothing using the Dirichlet energy and propose to optimize a GNN within a constrained range of the underlying layer-wise Dirichlet energy. DropEdge (Rong et al., 2020) on the other hand represents an example of implicit regularization by adding noise to the optimization process. This is done by randomly dropping edges of the underlying graph during training. Graph DropConnect (GDC) (Hasanzadeh et al., 2020) generalizes this approach by allowing the GNNs to draw different random masks for each channel and edge independently. Another example of implicit regularization is PairNorm (Zhao and Akoglu, 2019), where the pairwise distances are set to be constant throughout every layer in the deep GNN. This is obtained by performing the following normalization on the node features \(\mathbf{X}\) after each GNN layer,
\[\hat{\mathbf{X}}_{i} =\mathbf{X}_{i}-\frac{1}{v}\sum_{j=1}^{v}\mathbf{X}_{j}, \tag{5}\] \[\mathbf{X}_{i} =\frac{s\hat{\mathbf{X}}_{i}}{\sqrt{\frac{1}{v}\sum_{j=1}^{v} \|\hat{\mathbf{X}}_{j}\|_{2}^{2}}},\]
where \(s>0\) is a hyperparameter. Similarly, Zhou et al. (2020) have suggested to normalize within groups of the same labeled nodes, leading to Differentiable Group Normalization (DGN). Moreover, Zhou et al. (2021) have suggested to node-wise normalize each feature vector, yielding NodeNorm.
Change of GNN dynamicsA rapidly emerging strategy to mitigate over-smoothing for deep GNNs is by qualitatively changing the (discrete or continuous) dynamics of the message-passing propagation. A recent example is the use of non-linear oscillators which are coupled through the graph structure yielding Graph-Coupled Oscillator Network (GraphCON) (Rusch et al., 2022),
\[\mathbf{Y}^{n} =\mathbf{Y}^{n-1}+\Delta t[\sigma(\mathbf{F}_{\theta^{n}}(\mathbf{X} ^{n-1},\mathcal{G}))-\gamma\mathbf{X}^{n-1}-\alpha\mathbf{Y}^{n-1}], \tag{6}\] \[\mathbf{X}^{n} =\mathbf{X}^{n-1}+\Delta t\mathbf{Y}^{n},\]
where \(\mathbf{Y}^{n}\) are auxiliary node features and \(\Delta t>0\) denotes the time-step (usually set to \(\Delta t=1\)). The idea of this work is to exchange the diffusion-like dynamics of GCNs (and its variants) to that of non-linear oscillators, which can provably be guaranteed to have a Dirichlet energy that does not exponentially vanish (as of Definition 1). A similar approach has been taken in Eliasof et al. (2021), where the dynamics of a deep GCN is modelled as a wave-type partial differential equation (PDE) on graphs, yielding PDE-GCN. Another approach inspired by physical systems is Allen-Cahn Message Passing (ACMP) (Wang et al., 2022), where the dynamics is constructed based on the Allen-Cahn
Figure 1: Dirichlet energy and Mean Average Distance (MAD) of layer-wise node features \(\mathbf{X}^{n}\) propagated through a GAT, GCN and GraphSAGE for three different graph datasets, **(left)** small-scale Texas graph, **(middle)** medium-scale Cora citation network, **(right)** large-scale Facebook network (Cornell5).
equation modeling interacting particle system with attractive and repulsive forces. A related effort is the Gradient Flow Framework (GRAFF) (Di Giovanni et al., 2022), where the proposed GNN framework can be interpreted as attractive respectively repulsive forces between adjacent features.
A recent example in this direction, that is not directly inspired by physical systems, is that of Gradient Gating (\(\mathbf{G}^{2}\)) (Rusch et al., 2023), where a learnable node-wise early-stopping mechanism is realized through a gating function leveraging the graph-gradient,
\[\begin{split}\hat{\mathbf{\tau}}^{n}&=\sigma(\hat{ \mathbf{F}}_{\theta^{n}}(\mathbf{X}^{n-1},\mathcal{G})),\\ \mathbf{\tau}^{n}_{ik}&=\tanh\left(\sum_{j\in\mathcal{ N}_{i}}|\hat{\mathbf{\tau}}^{n}_{jk}-\hat{\mathbf{\tau}}^{n}_{ik}|^{p}\right),\\ \mathbf{X}^{n}&=(1-\mathbf{\tau}^{n})\odot\mathbf{X}^{n -1}+\mathbf{\tau}^{n}\odot\sigma(\mathbf{F}_{\theta^{n}}(\mathbf{X}^{n-1},\mathcal{ G})),\end{split} \tag{7}\]
with \(p\geq 0\). This mechanism slows down the message-passing propagation corresponding to each individual node (and each individual channel) as \(\hat{\mathbf{\tau}}^{n}_{ij}\) goes to zero before local over-smoothing occurs in the \(j\)-th channel on a node \(i\).
Residual connectionsMotivated by the success of residual neural networks (ResNets) (He et al., 2016) in conventional deep learning, there has been many suggestions of adding residual connections to deep GNNs. An early example includes Li et al. (2019), where the authors equip a GNN with a residual connection He et al. (2016), i.e.,
\[\mathbf{X}^{n}=\mathbf{X}^{n-1}+\mathbf{F}_{\theta^{n}}(\mathbf{X}^{n-1}, \mathcal{G}). \tag{8}\]
By instantiating the GNN in (8) with a GCN, this leads to major improvements over competing methods. Another example is GCNII (Chen et al., 2020) where a scaled residual connection of the initial node features is added to every layer of a GCN,
\[\mathbf{X}^{n}=\sigma\left[\left((1-\alpha_{n})\hat{\mathbf{D}}^{-\frac{1}{2}} \hat{\mathbf{A}}\hat{\mathbf{D}}^{-\frac{1}{2}}\mathbf{X}^{n-1}+\alpha_{n} \mathbf{X}^{0}\right)((1-\beta_{n})\mathrm{I}+\beta_{n}\mathbf{W}^{n})\right], \tag{9}\]
where \(\alpha_{n},\beta_{n}\in[0,1]\) are fixed hyperparameters for all \(n=1,\dots,N\). This allows for constructing very deep GCNs, outperforming competing methods on several benchmark tasks. Similar approaches aggregate not just the initial node features but all node features of every layer of a deep GNN at the final layer. Examples of such models include Jumping Knowledge Networks (JKNets) (Xu et al., 2018) and Deep Adaptive Graph Neural Networks (DAGNNs) (Liu et al., 2020)
### Empirical evaluation
In order to evaluate the effectiveness of the different methods that have been suggested to mitigate over-smoothing in deep GNNs, we follow the experimental set-up of section 3. To this end, we choose two representative methods of each of the different strategies to overcome over-smoothing, namely DropEdge and PairNorm as representatives from "normalization and regularization" strategies, GraphCON and \(\mathbf{G}^{2}\) from "change of GNN dynamics", and Residual GCN (Res-GCN) and GCNII from "residual connections". We consider the same three different graphs as in section 3, namely small-scale Texas, medium-scale Cora and larger-scale Cornell5 graph. Since we are only interested in the qualitative behavior of the different methods, we fix one node-similarity measure, namely the Dirichlet energy. Thereby, we can see in Fig. 2 that DropEdge-GCN and Res-GCN suffer from an exponential convergence of the layer-wise Dirichlet energy to zero (and thus from over-smoothing) on all three graphs. In contrast to that, all other methods we consider here mitigate over-smoothing by keeping the layer-wise Dirichlet energy approximately constant.
Figure 2: Layer-wise Dirichlet energy of hidden node features propagated through \(\mathbf{G}^{2}\)-GCN, GraphCON-GCN, PairNorm, GCNII, DropEdge-GCN and Res-GCN on three different graphs, i.e., **(left)** small-scale Texas graph, **(middle)** medium-scale Cora citation network, **(right)** large-scale Facebook (Cornell5) network.
## 5 Risk of sacrificing expressivity to mitigate over-smoothing
Since several of the previously suggested methods designed to mitigate over-smoothing successfully prevent the layer-wise Dirichlet energy (and other node-similarity measures) from converging exponentially fast to zero, it is natural to ask if this is already sufficient to construct (possibly very) deep GNNs which also efficiently solve the learning task at hand. To answer this question, we start by constructing a deep GCN which keeps the Dirichlet energy constant while at the same time its performance on a learning task is as poor as a standard deep multi-layer GCN.
It turns out that simply adding a bias vector to a deep GCN with shared parameters among layers, i.e.,
\[\mathbf{X}^{n}=\sigma(\hat{\mathbf{D}}^{-\frac{1}{2}}\hat{\mathbf{A}}\hat{ \mathbf{D}}^{-\frac{1}{2}}\mathbf{X}^{n-1}\mathbf{W}+\mathbf{b}),\quad\forall n =1,\ldots,N,\]
with weights \(\mathbf{W}\in\mathbb{R}^{m\times m}\) and bias \(\mathbf{b}\in\mathbb{R}^{m}\), is sufficient for the optimizer to keep the resulting layer-wise Dirichlet energy of the model approximately constant. This can be seen in Fig. 3 where the layer-wise Dirichlet energy is shown (among others) for a standard GCN as well as a GCN with an additional bias term after training on the Cora graph dataset in the fully supervised setting. We observe that while the Dirichlet energy converges exponentially fast to zero for the standard GCN, simply adding a bias term results in an approximately constant layer-wise Dirichlet energy. Moreover, Fig. 3 shows the test accuracy of the same models for different number of layers. We can see that both the standard GCN as well as the GCN with bias vector suffer from a significant decrease of performance for increasing number of layers. Interestingly, while GCN with bias keeps the Dirichlet energy perfectly constant and GCN without bias exhibits a Dirichlet energy converging exponentially fast to zero, both models suffer similarly from drastic impairment of performance (in terms of test accuracy) for increasing number of layers. We thus observe that simply constructing a deep GNN that keeps the node-similarity measure constant (around \(1\)) is not sufficient in order to successfully construct deep GNNs.
This observation is further supported in Fig. 3 by looking at the Dirichlet energy of the PairNorm method which behaves similarly to the Dirichlet energy of GCN with bias, i.e., approximately constant around \(1\). However, the performance in terms of test accuracy on the Cora graph dataset drops exponentially after using more than \(32\) layers. Interestingly, \(\mathbf{G}^{2}\)-GCN exhibits an approximately constant layer-wise Dirichlet energy and at the same time does not decrease its performance by increasing number of layers. In fact the performance of \(\mathbf{G}^{2}\)-GCN increases slightly by increasing number of layers.
Therefore, we argue that solving the over-smoothing issue defined in Definition 1 is necessary in order to construct well performing deep GNNs. Otherwise the network is not able to learn any meaningful function defined on the graph. However, as can be seen from this experiment it is not sufficient. Therefore, based on this experiment we conclude that a major pitfall in designing deep GNNs that mitigate over-smoothing is to sacrifice the expressive power of the GNN only to keep the node-similarity measure approximately constant. In fact, based on our experiments, only \(\mathbf{G}^{2}\) (among the considered models here) fully mitigates the over-smoothing issue by keeping the node-similarity measure approximately constant, while at the same time increasing its expressive power for increasing number of layers.
Figure 3: Trained \(\mathbf{G}^{2}\)-GCN, PairNorm, GCN with bias and GCN without bias on the fully-supervised Cora graph dataset using the pre-defined \(10\) splits from Pei et al. (2020), showing two different measures for increasing number of layers ranging from \(1\) to \(128\): **(left)** Dirichlet energy of the layer-wise node features, **(right)** test accuracies.
## 6 Extension to continuous-time GNNs
A rapidly growing sub-field of graph representation learning deals with GNNs that are continuous in depth. This is performed by formulating the message-passing propagation in terms of graph dynamical systems modelled by (neural (Chen et al., 2018)) Ordinary Differential Equations (ODEs) or Partial Differential Equations (PDEs), i.e., message-passing framework (1), where the forward propagation is modeled by a differential equation:
\[\mathbf{X}^{\prime}(t)=\sigma(\mathbf{F}_{\theta}(\mathbf{X}(t),\mathcal{G})), \tag{10}\]
with \(\mathbf{X}(t)\) referring to the node features at time \(t\geq 0\). Different choices of the vector field (i.e., right-hand side of (10)) yields different architectures. Moreover, we note that the right-hand side in (10) can potentially arise from a discretization of a differential operator defined on a graph leading to a PDE-inspired architecture. We refer to this class of graph-learning models as _continuous-time GNNs_. Early examples of continuous-time GNNs include Graph Neural Ordinary Differential Equations (GDEs) (Poli et al., 2019) and Continuous Graph Neural Networks (CGNN) (Xhonneux et al., 2020). More recent examples include Graph-Coupled Oscillator Networks (GraphCON) (Rusch et al., 2022), Graph Neural Diffusion (GRAND) (Chamberlain et al., 2021), Beltrami Neural Diffusion (BLEND) (Chamberlain et al., 2021), Neural Sheaf Diffusion (NSD) (Bodnar et al., 2022), and Gradient Glow Framework (GRAFF) (Di Giovanni et al., 2022). Based on this framework, we can easily extend our definition of over-smoothing 1 to continuous-time GNNs, by defining over-smoothing as the exponential convergence in time of a node-similarity measure. More concretely, we define it as follows.
**Definition 2** (Continuous-time over-smoothing).: _Let \(\mathcal{G}\) be an undirected, connected graph and \(\mathbf{X}(t)\in\mathbb{R}^{v\times m}\) denote the hidden node features of a continuous-time GNN (10) at time \(t\geq 0\) defined on \(\mathcal{G}\). Moreover, \(\mu\) is a node-similarity measure as of Definition 1. We then define over-smoothing with respect to \(\mu\) as the exponential convergence in time of the node-similarity measure \(\mu\) to zero, i.e.,_
\[\mu(\mathbf{X}(t))\leq C_{1}e^{-C_{2}t}\text{, for }t\geq 0\text{ with some constants }C_{1},C_{2}>0.\]
## 7 Conclusion
Stacking multiple message-passing layers (i.e., a deep GNN) is necessary in order to effectively process information on relational data where the underlying computational graph exhibits (higher-order) long-range interactions. This is of particular importance for learning heterophilic graph data, where node labels may differ significantly from those of their neighbors. Besides several other identified problems (e.g., over-squashing, exploding and vanishing gradients problem), the over-smoothing issue denotes a central challenge in constructing deep GNNs.
Since previous work has measured over-smoothing in various ways, we unify those approaches by providing an axiomatic definition of over-smoothing through the layer-wise _exponential convergence_ of _similarity measures_ on the node features. Moreover, we review recent measures for over-smoothing and, based on our definition, rule out the commonly used MAD in the context of measuring over-smoothing. Additionally, we test the qualitative behavior of those measures on three different graph datasets, i.e., small-scale Texas graph, medium-scale Cora graph, and large-scale Cornell5 graph, and observe an exponential convergence to zero of all measures for standard GNN models (i.e., GCN, GAT, and GraphSAGE). We further review prominent approaches to mitigate over-smoothing and empirically test whether these methods are able to successfully overcome over-smoothing by plotting the layer-wise Dirichlet energy on different graph datasets.
We conclude by highlighting the need for balancing the ability of models to mitigate over-smoothing, but without sacrificing the expressive power of the underlying deep GNN. This phenomenon was illustrated by the example of a simple deep GCN with shared parameters among all layers as well as a bias, where the optimizer rapidly finds a state of parameters during training that leads to a mitigation of over-smoothing (i.e., approximately constant Dirichlet energy). However, in terms of performance (or accuracy) on the Cora graph-learning task, this model fails to outperform its underlying baseline (i.e., same GCN model without a bias) which suffers from over-smoothing. This behavior is further observed in other methods that are particularly designed to mitigate over-smoothing, where the over-smoothing measure remains approximately constant but at the same time the accuracy of the model drops significantly for increasing number of layers. However, we also want to highlight that there exist methods that are able to mitigate over-smoothing while at the same time maintaining its expressive power on our task, i.e., \(\mathbf{G}^{2}\). We thus conclude that _mitigating over-smoothing is only a necessary condition_, among many others, for building deep GNNs, while a particular focus in designing methods in this context has to be on the maintenance or potential enhancement of the expressive power of the underlying model.
## Acknowledgement
The authors would like to thank Dr. Petar Velickovic (DeepMind/University of Cambridge) for his insightful feedback and constructive suggestions.
|
2303.05420 | Kernel Regression with Infinite-Width Neural Networks on Millions of
Examples | Neural kernels have drastically increased performance on diverse and
nonstandard data modalities but require significantly more compute, which
previously limited their application to smaller datasets. In this work, we
address this by massively parallelizing their computation across many GPUs. We
combine this with a distributed, preconditioned conjugate gradients algorithm
to enable kernel regression at a large scale (i.e. up to five million
examples). Using this approach, we study scaling laws of several neural kernels
across many orders of magnitude for the CIFAR-5m dataset. Using data
augmentation to expand the original CIFAR-10 training dataset by a factor of
20, we obtain a test accuracy of 91.2\% (SotA for a pure kernel method).
Moreover, we explore neural kernels on other data modalities, obtaining results
on protein and small molecule prediction tasks that are competitive with SotA
methods. | Ben Adlam, Jaehoon Lee, Shreyas Padhy, Zachary Nado, Jasper Snoek | 2023-03-09T17:11:31Z | http://arxiv.org/abs/2303.05420v1 | # Kernel Regression with Infinite-Width Neural Networks
###### Abstract
Neural kernels have drastically increased performance on diverse and nonstandard data modalities but require significantly more compute, which previously limited their application to smaller datasets. In this work, we address this by massively parallelizing their computation across many GPUs. We combine this with a distributed, preconditioned conjugate gradients algorithm to enable kernel regression at a large scale (i.e. up to five million examples). Using this approach, we study scaling laws of several neural kernels across many orders of magnitude for the CIFAR-5m dataset. Using data augmentation to expand the original CIFAR-10 training dataset by a factor of 20, we obtain a test accuracy of 91.2% (SotA for a pure kernel method). Moreover, we explore neural kernels on other data modalities, obtaining results on protein and small molecule prediction tasks that are competitive with SotA methods.
## 1 Introduction
Kernel methods are often contrasted with deep learning, but recent advances in machine learning have identified and developed exciting correspondences (Lee et al., 2018; Matthews et al., 2018; Jacot et al., 2018). While a useful method in its own right, kernel regression has been used to better understand neural networks and deep learning. More specifically, if the parameters of a neural network are treated as random variables whose distribution is set by the initialization, we can view the neural network as a random function. Then as the width of the network becomes large, the distribution of this random function is a Gaussian process with a specific covariance function or kernel. We refer to kernels that arise from this connection with infinite-width neural networks as _neural kernels_. The specific kernel is determined by the architecture, inference type, and other hyperparameters of the neural network.
Moreover, the connection between neural networks and Gaussian processes has generated many high-performance kernels for diverse or nonstandard data modalities, such as images, sequences, and graphs. This performance often comes at a cost, as the kernels require significantly more compute than standard kernels such as RBFs. For example, computing the entire kernel for the CIFAR-10
dataset takes less than 1 GPU minute for an RBF kernel but around 300 GPU hours for the Myrtle kernel (Shankar et al., 2020; Lee et al., 2020). However, this increase in compute significantly decreases the test error rate from around 40% to 10%. The added demands of simply computing entries of the kernel is in addition to challenges posed from the cubic scaling in time and quadratic scaling in memory of inference for kernel regression with dataset size. Approximate inference methods frequently reduce memory requirements by recomputing kernel entries on the fly, which is infeasible for these expensive kernels. Such challenges have limited our understanding of infinite-width models to small datasets. In particular, while scaling laws have been studied across many orders of magnitude for neural networks, the same is not true of their corresponding kernels. Similarly, while it is common to augment training datasets in neural networks, significantly expanding their size, the benefits for kernel methods have not been as thoroughly explored.
### Contributions
In this work, we address these two main computational challenges (computing large, complex kernels and using them for kernel regression) by parallelizing and scaling up existing algorithms to many more machines. This enables us to consider significantly larger datasets, currently up to five million examples, and therefore study how performance changes as more data are added over many orders of magnitude. While similar studies have been performed for neural networks, they have been lacking for neural kernels. In addition to scaling to larger datasets, we also consider high resolution images from the Tiny Imagenet dataset, where additional pixels also require more compute. Moreover, our approach is not restricted to image data. In fact, we obtain results for both protein sequence and small molecule datasets and demonstrate that neural kernels are a promising method for medium sized datasets from basic science.
Our contributions include:
* By massively parallelizing the computation of the neural kernels, we study kernels on significantly larger (by approximately two orders of magnitude) datasets;
* We use a distributed, preconditioned conjugate gradients algorithm to perform inference for these kernels (with code provided in the supplementary materials);
* We demonstrate scaling laws across several orders of magnitude for fully-connected, CNN-Vec, and Myrtle kernels on the CIFAR-5m dataset;
* We study the loss in performance incurred by approximating the linear system from inference compared to conjugate gradients;
* Using data augmentation to expand the original CIFAR-10 training dataset by a factor of 20, we obtain a test accuracy of 91.2% (SotA for a pure kernel method);
* We explore other data modalities, obtaining results on protein and small molecule prediction tasks that are competitive with SotA methods.
### Related work
The contributions of this work are made possible by recent advances in large scale inference for Gaussian processes and kernel regression and advances in the understanding of the relationship between GPs and deep neural networks.
Wang et al. (2019) showed how to solve the large-scale linear systems within GPs using conjugate gradients (CG), which requires only matrix-vector operations with the kernel and doesn't require storing the full kernel in memory. Wang et al. (2019) and Maddox et al. (2022) identify the importance of using a pre-conditioner (a partially-pivoted Cholesky decomposition) to solve the system with finite
precision. We use a similar CG algorithm to solve our systems and found that the pre-conditioner was critical to convergence, particularly for the non-stationary neural kernels. Due to their eigenspectra, we unfortunately found we required high precision on CPU. In this work, we use these methods to solve even larger systems, up to 5 million examples, but emphasize that the most computationally expensive component is computing the expressive neural kernels.
Many methods have been developed to approximate Gaussian processes on larger datasets. Rahimi and Recht (2007) show that stationary kernels can be approximated using a finite set of random basis functions. Recently there has been progress in random-feature approximations for expressive, non-stationary kernels using sketching (Zandieh et al., 2021; Han et al., 2022). While this method provides efficient ways for approximating neural kernels, often there is speed-performance tradeoff (Han et al., 2022), thus our work focuses on exact computation. Stochastic variational inference (SVI) (Hensman et al., 2013) is a tremendously promising approach to scale GPs by optimizing a set of inducing points to approximate the full GP posterior. However, Wang et al. (2019) found that their SVI baseline underperformed exact GP inference in their experiments. We found that SVI was computationally infeasible due to taking gradients through the neural kernels, and using subsets of data as inducing points was less-effective than the full kernel. Other approaches, such as KISS-GP (Wilson and Nickisch, 2015; Stanton et al., 2021), cleverly interpolate over a grid of inducing points, taking advantage of Toeplitz structure, to drastically reduce computational cost.
Rudi et al. (2017) develop FALKON, which uses Nystrom and random feature approximations with pre-conditioning to scale up kernel regression to millions of examples with theoretical guarantees on performance. This is extended to potentially billions of examples by Meanti et al. (2020), through distributed GPU acceleration and various optimizations. EigenPro and EigenPro2 (Ma and Belkin, 2017, 2019) accelerate and scale up kernel regression by developing pre-conditioned stochastic gradient descent. While we observe that neural kernels scale remarkably well in terms of predictive performance, using these methods could make them more computationally practical. However, we found that we have required the full kernel at high precision to obtain high performance.
The correspondence between random functions from the initialization of infinite-width neural networks and Gaussian processes, called the neural network Gaussian process (NNGP), was first noted by Neal (1994) and analytically derived by Williams (1996) for single-hidden layer, fully-connected networks. More recently this was extended to deep neural networks for fully-connected (Lee et al., 2018; Matthews et al., 2018) and convolutional architectures (Novak et al., 2019; Garriga-Alonso et al., 2019). This correspondence to Gaussian processes can be extended to infinite-width networks trained by gradient descent via the Neural Tangent Kernel (NTK) (Jacot et al., 2018) and to many other architectures, (Yang, 2019, 2020) including self-attention layers (Hron et al., 2020) and simple graph neural networks (Du et al., 2019). The covariance functions or kernels associated to these Gaussian processes are determined by the neural network's architecture and other hyperparameters from initialization, and we refer to them as neural kernels.
While these kernels are theoretically useful to better understand the functional prior of neural networks, including their uncertainty properties (Adlam et al., 2020), they have also been used more practically. The NTK for convolutional architectures has been applied to image data (Arora et al., 2019; Li et al., 2019; Shankar et al., 2020) and offers unique solutions to practical deep learning problems such as data distillation (Nguyen et al., 2021, 2021). The JAX-based (Bradbury et al., 2018) python library, Neural Tangents (Novak et al., 2020), has helped to enable these practical applications by providing efficient computation of neural kernels on CPU, GPU and TPU.
## 2 Approaches to large-scale kernel methods
In this section, we review the different approaches to large-scale kernel regression. We discuss the particular challenges introduced by neural kernels and how we addressed them. Finally, we compare the performance for the CIFAR-5m dataset with 10-layer Myrtle NTK.
There are two main approaches to applying kernel methods to larger datasets, i.e. to solve a large linear system. First, the original linear system can be replaced by an alternative linear system that has a particular algebraic form that can be solved exactly and efficiently. Second, the original linear system can be maintained but only solved approximately.1 These approximate solvers are often anytime algorithms, where the current solution can be returned at anytime--typically when its residual is sufficiently small.
Footnote 1: Note that some approaches can be interpreted in both ways.
Approximations to the linear system:Many methods fall under this category. Here we focus on four different types. First, there are the low-rank approximations, _Nystrom_ and _subset of regressors_, that can be inverted in time \(\mathcal{O}(r^{2}n)\) where \(r\) is the rank and \(n\) is the number of training examples [Williams and Rasmussen, 2006].
Figure 1: **(Top)** An upper diagonal of large kernel matrix is split into smaller, dimension 5,000\(\times\)5,000 blocks for multi-threading of IO. When computing the kernel, the blocks can be computed independently by machines that need not be co-located. Each block is then batched further (to meet device memory limitations) and computed by the Neural Tangents library on several GPUs. **(Bottom left)** It is natural to split the kernel by rows across the workers, then each worker can receive the vector from the host, compute the matrix product between the rows in its memory with the vector, and return this chunk of the result to the host. The host can then aggregate the results from the workers by concatenating. However, for larger systems with many workers, simply communicating a large vector to all workers becomes a bottleneck. Instead the kernel can also be partitioned over columns. This means that each worker \((j,i)\) only needs a subset of the vector entries \(\mathbf{v}_{i}\) and computes \(\mathbf{K}_{ji}\mathbf{v}_{i}\), and we found this dramatically decreased communication time. The cost of this approach is that slightly more complex aggregation is required on the host. **(Bottom right)** Classification error rate as a function of rank or partition size for four different kernel approximations. The kernel used is a 10-layer Myrtle NTK for 1.6 million examples of the CIFAR-5m dataset. The performance of CG is shown as a dashed line for comparison and exceeds all other results.
Second, there is the _block diagonal_ approximation that sets all kernel entries outside of some blocks along the diagonal to zero. Due to its algebraic form, this kernel is easy to invert and takes time \(\mathcal{O}(r^{2}n)\) where \(r\) is the block or partition size. Even without parallelization, this reduces the running time by a factor of the number of blocks squared.
Finally, the _Bayesian committee machine_(Tresp, 2000; Williams and Rasmussen, 2006) is an approximation to the likelihood of a Gaussian process that partitions the dataset, fitting separate regressors to the partitions under assumptions of independence. Here we use the posterior mean under this approximation, which can be computed efficiently. Since this is a transductive method, the time complexity depends on the size of the test set but is comparable to the methods above when the number of test examples equals the partition size.
One advantage of these methods is that they do not require access to all kernel entries, and so can avoid the quadratic scaling from computing and storing the entire kernel. The primary additional hyperparameters in these methods are the rank or partition size. Typically increasing these hyperparameters improves performance at the cost of additional compute (see Fig. 1). However, in addition to their size, exactly which examples are included in the low-rank approximation or how the data are partitioned can affect performance. While several methods are available to select these examples more optimally, the most common approach is still to select uniformly at random, which we do here also. In addition, it was necessary to tune the jitter term in the _Nystrom_ approximation, since setting to the default value of \(10^{-6}\) we used elsewhere yielded poor results.
Iterative solvers:Rather than solving the linear system to machine precision, we might be satisfied with a solution that has a sufficiently small residual--especially because the predictions are unlikely to change significantly. Conjugate gradients (CG) is one approach to this (Shewchuk et al., 1994; Wang et al., 2019; Meanti et al., 2020). CG iteratively finds the best solution in a subspace of dimension equal to the number of steps. This subspace is defined by a sequence of vectors that are conjugate with respect to the kernel. Each step of CG takes quadratic time, and in the worst case a linear number of steps must be performed, but this is normally not necessary. To avoid this worst-case performance, pre-conditioning is essential. We used the standard partial pivoted Cholesky pre-conditioner (Wang et al., 2019) and found it significantly decreased the number of steps required to reach a small residual.
A key subroutine in CG is the computation of kernel-vector products and is the only place the kernel occurs directly. This presents opportunities for parallelization. In particular, we use a host CPU to run the main CG algorithm and act as a server to control worker CPUs who compute kernel-vector products (see Fig. 1, bottom left, for details).
Additional challenges from neural kernels:Previous large-scale implementations of CG have traded off memory and time by never storing the whole kernel in memory and instead recomputing it on the fly. While this approach works well for simple kernels, such as RBFs, it is infeasible for neural kernels. In particular, computing the kernel once represents the majority of the compute compared to running CG for inference. Indeed reducing the computational burden of neural kernels is a topic of current research and can be faster without decreasing performance (Zandieh et al., 2021; Han et al., 2021), though often there is a speed-performance tradeoff (Han et al., 2021). The problem has not been completely solved. Moreover, there is evidence that even computing them at float32 precision compared to float64 precision degrades performance (Lee et al., 2020). Thus the approach we take here to obtaining the kernel for larger datasets is to parallelize their computation across many machines (see Fig. 1, top, for details). Fortunately very little communication or coordination is needed across machines, and preemption-safe routines are easy to design. The kernel can then be computed once and stored on disk in a collection of sub-blocks for faster, multi-threaded IO. During CG, the kernel must be stored either completely in RAM, which is fastest but requires many
machines for large kernels, or can be stored on disk with very fast IO to load chunks of the kernel into RAM.2
Footnote 2: For example, our 5 million examples kernel computed in float64 precision, storage on disk alone is about 100 terabytes distributed over \(\sim\)500,000 blocks.
The spectra of neural kernels can be incredibly ill-conditioned (Lee et al., 2020), which presents challenges for inference and reinforces the need for pre-conditioning. Often the spectra are very diffuse, spanning several orders of magnitude and showing power-law decay.
Performance comparison:In Fig. 1, we compare the accuracy of the different methods for the 10 layer Myrtle NTK on 1.6 million training examples from the CIFAR-5m dataset.3 We find that as the rank or partition size increases, the performance of all methods improves with subset of regressors and Nystrom performing best. We did not increase above 50,000 as this is close to the limit of the largest linear system that can be solved on a standard CPU. Note that while the gap to CG is reduced, there is still a large reduction in performance.
Footnote 3: See the next section for more details on this dataset.
## 3 Scaling laws for neural kernels
Known as _neural scaling laws_, there has been substantial recent interest in how the performance of neural networks improves as more data are available for training and their number of parameters increases (Hestness et al., 2017; Kaplan et al., 2020; Rosenfeld et al., 2019; Rosenfeld, 2021; Bahri et al., 2021). Frequently, these quantities increase in tandem. Empirically, it has been found that performance improves as a power law, for which many works seek to estimate the exponent. Projecting the potential improvement in performance from scaling up neural networks is especially important in the large model era, where training such models is costly.
It is natural to ask whether other models also scale as a power law, and if so, how their exponents compare to those of neural networks. Such studies help identify the origin of the power-law scaling, as currently it is unclear whether it originates from the data or the model choice. These comparison are particularly natural for neural kernels. Moreover, since neural kernels are nonparametric, their capacity scales automatically as more data are added. From the language of Bahri et al. (2021), dataset scaling for neural kernels is in the _resolution-limited_ regime, which is arguably a more interesting scaling regime.
Scaling experiments for neural networks typically cover datasets over many orders of magnitude, which is challenging for kernel regression. In this section, we consider kernel regression for three different neural kernels: fully-connected neural networks, convolution neural networks without pooling operations, and the Myrtle convolutional networks. The kernels in that order increase in performance and computational burden, and all have been well tuned for the CIFAR-10 (Lee et al., 2020).
Of course, CIFAR-10 is limited in size with only 60k examples (50k train, 10k test). To enable a larger scaling study, instead we use the CIFAR-5m dataset (Nakkiran et al., 2021), which consists of samples from a generative model trained on CIFAR-10. Using CIFAR-5m, we can extend our analysis over 2 more orders of magnitude while ensuring the additional data are sampled i.i.d. For generalization performance, in addition to evaluation on the i.i.d. CIFAR-5m held out data, we consider the CIFAR-10 and 10.1 test sets. Evaluation on these test sets is standard and allows for comparison against existing results.
In Fig. 2, we observe persistent dataset scaling laws as we vary architecture and evaluation data. For extremely small dataset sizes (10-100), all cases commonly show a lower slope and then transition into a more consistent, higher slope, indicating power-law behavior across 4-5 orders of magnitude. We measure the dataset scaling exponent \(\alpha_{D}\) for the test loss and observe that, as one increases the complexity of the kernel, the scaling exponent increases. Also, for the same architecture, evaluation data that are closer in distribution to the training data have a higher scaling exponent. Since the
training data are drawn i.i.d from CIFAR-5m, the order of in-distribution to out-of-distribution for the test sets should be thought of as CIFAR-5m, CIFAR-10, and then CIFAR-10.1.4
Footnote 4: This is because the generative model to generate CIFAR-5m was trained on the CIFAR-10 training set.
Figure 3: **Dataset scaling for Myrtle on Tiny ImageNet.** At full resolution (64\(\times\)64), we achieve a best accuracy of 44.7%. Higher resolution inputs result in better classification accuracy and higher scaling exponent(\(\alpha_{D}\)).
Figure 2: **Dataset size scaling for neural kernels on CIFAR-5m. Using CIFAR-5m as training data, we explore dataset scaling spanning 6 orders of magnitude. Each column corresponds to different neural architectures: 3-layer fully-connected neural network (FC3), 8-layer convolutional neural network with output vectorization (CV8), and 10-layer Myrtle convolutional neural network with average pooling (Myrtle). Evaluations on three different held-out test sets, CIFAR-5m validation, CIFAR-10 test set, and CIFAR-10.1 test set, are shown. Scaling exponents on mean squared error are larger (thus faster improvement with more data) for more complex and computationally intensive kernels and for more in-distribution held out data (CIFAR-5m \(>\) CIFAR-10 \(>\) CIFAR-10.1).**
Tiny ImageNet: Towards ImageNet with neural kernels.With our ability to compute massive kernels and use them for inference, ImageNet is not far from reach. ImageNet at 1.2 million examples is actually smaller than some datasets considered here--although augmentation beyond horizontal flips maybe challenging. However, at least two issues remain. First, the large number of output classes. Compared to the 10 classes in CIFAR-10 or CIFAR-5m, a one-hot label of 1k classes expands the linear systems to be solved by a factor of 100. Second, the resolution of ImageNet in standard deep learning architecture is 224\(\times\)224, if not larger (c.f. EfficientNet Tan and Le (2019, 2021)). For neural kernels with pooling, such as the Myrtle kernel, compute scales quadratically with the total number of pixels. Thus compared to 32\(\times\)32 CIFAR-10 images, each data point requires \(7^{4}=2401\) times more compute.
As a step toward ImageNet, we consider the Myrtle kernel for the Tiny ImageNet dataset (Le and Yang, 2015). Tiny ImageNet consists of 200 subclasses of ImageNet with 500 images per class, i.e. 100k total training images at a lower resolution of 64\(\times\)64.5 Dataset scaling results are shown in Fig. 3. Similar to CIFAR-5m scaling, from a sufficiently large dataset size there is consistent power-law scaling. To the best of our knowledge, this is the first evaluation of neural kernels on Tiny Imagenet. We achieve at best classification accuracy of 44.7% on the test set. Comparing to finite networks, among very few references quoting results without data augmentation, Jeevan et al. (2022) obtained 43.1% for ResNet-18 and 45.39% for ConvMixer-16, indicating our result from neural kernel is competitive to modern finite neural network architectures without data augmentation.
Footnote 5: We experimented with downsizing to 32\(\times\)32 resolution.
## 4 Data augmentation
Data augmentation is widely used in deep learning applied to image data. For example, for CIFAR-10 or ImageNet classification, most if not all models are trained using random crops and horizontal flips. More effective augmentation strategies such as AutoAug (Cubuk et al., 2019), RandAug (Cubuk et al., 2020) have been found and used in SotA vision models.
Figure 4: **Neural kernel performance on CIFAR-10 with data augmentation**. Using horizontal flip and RandAug, we measure scaling of neural kernels’ classification error for 3 different architectures and 2 test sets (CIFAR-10 as well as CIFAR-10.1). Data augmentation factors smaller than 1.0 (light blue shaded region) denotes a subset of original training set, so additional i.i.d. data can be compared with augmented data. The augmentation factor 2\(\times\) includes horizontal flips, whereas factors larger than 2\(\times\) use RandAug combined with random crop and flips. While data augmentation consistently improves scaling, there is a noticeable change in slope around 1.0 for FC3 and Tuned Myrtle kernels (see Appendix C). For augmentation factors of 10\(\times\) and 20\(\times\), the Tuned Myrtle kernel achieves less than 10% classification error (8.8% with 20\(\times\)). (See Table 1 for detailed comparison.)
The idea of data augmentation has a long history (Niyogi et al., 1998)-- including in SVMs where they are called virtual examples (Scholkopf et al., 1996). However, despite the broad application of data augmentation in deep learning, recently it has been used little in kernel methods due to their limitations on large datasets. For example, Li et al. (2019) and Shankar et al. (2020) used horizontal flips to double the training set size for convolutional kernels. In Lee et al. (2020), an ensemble of kernel predictors, where each training set was augmented randomly, were used as a means of data augmentation.6 Because of this, exactly how much of the performance gap between neural networks and kernel methods can be accounted for by data augmentation on image data remains unknown.
Footnote 6: In effect, this is performing a block diagonal approximation on the augmented dataset.
In this section, we use our massively parallelized computation of neural kernels and distributed CG solver to explore the effect of data augmentation in neural kernels to a regime far beyond prior work. In our experiments, we focus on the CIFAR-10 dataset. We call the ratio between the sizes of the original training set and the training set after augmentation the _augmentation factor_. Our augmentation strategy is to expand the 50k training set by applying various augmentations. Following Li et al. (2019), Shankar et al. (2020), a \(2\times\) augmentation factor is given by horizontally flipping all images. Beyond that, up to a \(20\times\) augmentation factor, we used RandAug (Cubuk et al., 2020) as used in Shankar et al. (2020). In particular for each image in the training set, we sample one (\(N=1\)) random augmentation op among ['FlipLR', 'Solarize', 'Color', 'Brightness', 'Contrast', 'Sharpness', 'Posterize', 'Equalize', 'Identity']7 and apply with magnitude \(M=2\). After applying a random augmentation, we apply a random crop of 4 pixels as well as a random flip. We do not use cutout augmentation. With the strategy, we are able to achieve an accuracy of 91.2% (see Fig. 4). To our knowledge this is the highest published accuracy for a kernel method. Note that while the gap in accuracy between kernels and finite neural networks is reduced, it still remains (see Table 1).
\begin{table}
\begin{tabular}{l l l l l l} \hline \hline Architecture & & Method & CIFAR-10 & CIFAR-10.1 & CIFAR-5m \\ \hline \hline \multirow{4}{*}{FC} & \multirow{2}{*}{Kernel} & DA Ensemble (Lee et al., 2020) & 62.4 & - & - \\ & & DA CG (20x, this work) & 64.1 & 49.1 & - \\ & & CIFAR-5m CG (2M, this work) & **69.9** & **54.1** & 78.6 \\ \cline{2-5} & \multirow{2}{*}{Finite NN} & DA, Small LR, no L2 (Lee et al., 2020) & 65.3 & - & - \\ & & DA, Large LR, L2 (Lee et al., 2020) & 69.4 & & \\ \hline \multirow{4}{*}{CNN-VEC} & \multirow{2}{*}{Kernel} & Flip (Li et al., 2019) & 70.5 & - & - \\ & & DA Ensemble (Lee et al., 2020) & 73.2 & - & - \\ & & DA CG (20x, this work) & 81.3 & 66.3 & - \\ & & CIFAR-5m CG (5M, this work) & **83.4** & **71.9** & 86.5 \\ \cline{2-5} & \multirow{2}{*}{Finite NN} & DA, Small LR, no L2 (Lee et al., 2020) & 83.9 & - & - \\ & & DA, Large LR, L2 (Lee et al., 2020) & 85.6 & & \\ \hline \multirow{4}{*}{CNN-Pool} & \multirow{4}{*}{Kernel} & CNN-LAP Flip (Li et al., 2019) & 82.2 & - & - \\ & & CNN-GAP DA Ensemble (Lee et al., 2020) & 84.8 & - & - \\ \cline{1-1} & & Myttle10-Gaussian Flip (Shankar et al., 2020) & 89.8 & 78.3 & - \\ \cline{1-1} & & Tuned Myrtle10 DA CG (20x, this work) & **91.2** & **79.4** & - \\ \cline{1-1} & & Myrtle10 CIFAR-5m CG (1.6M, this work) & 89.1 & 79.1 & 89.5 \\ \cline{1-1} \cline{2-5} & \multirow{4}{*}{Finite NN} & ResNet18 CIFAR-5m (Nakiran et al., 2021) & 89.0 & - & 89.4 \\ \cline{1-1} & & CNN-GAP DA, Small LR, no L2 (Lee et al., 2020) & 84.4 & - & - \\ \cline{1-1} & & CNN-GAP DA Large LR, L2 (Lee et al., 2020) & 86.7 & & - \\ \cline{1-1} & & Myrtle10 DA (Shankar et al., 2020) & 96.0 & 89.8 & - \\ \hline \hline \end{tabular}
\end{table}
Table 1: CIFAR-10 test accuracy for kernels and finite neural networks of the corresponding architecture type.
Sequence and graph data
In this section, we continue to develop neural kernels as a method in their own right. We consider their performance on structured data modalities other than images. Kernels are particularly exciting for such data modalities because we lack inductive biases to take advantage of, and kernel methods such as Gaussian processes are the standard approach for guided experimental design.
First, we consider a protein function prediction benchmark motivated by protein design for targeted gene therapy. There is significant interest in engineering Adeno-associated virus (AAV) capsid proteins to cause the virus to integrate specific DNA into a target cell [14]. We perform kernel regression to predict the fitness of mutations across a 28 amino acid window of these proteins, by training and evaluating across all splits, ranging from 82k to 284k examples, of a dataset assaying VP-1 AAV protein variants [13]. Predictions are evaluated using Spearman correlation on the testsets. For more details see Sec. B.2
Second, we consider a small molecule dataset, called ogbg-molpcba, from the Open Graph Benchmark Hu et al. [2020, 2021], Wu et al. [2018]. This dataset contains approximately 400K molecules represented as graphs with 9-dimensional node features and 3-dimensional edge features that have been assayed in a variety of ways for biological activity. Not all assays were performed for each molecule, meaning the kernel regression must be adapted to handle missing data. To model this graph structured data, we derive kernels for deep graph neural networks, and fit these to the training set of 350K examples. Predictions are evaluated using mean average precision over the different assay tasks on the testset. For more details see Sec. B.3.
Developing specific kernels for such data is critical, since traditional covariance functions do not capture task-relevant similarities in high-dimensional inputs with complex structure. The connection between neural networks and neural kernels in the infinite-width limit provides one promising direction to exploit the progress in neural network architecture design. For example, convolutional operations are common in neural networks used on protein sequence data. Similarly, for graph data like molecules, graph convolution operations have grown in popularity. Any such operation has a corresponding kernel that can be used in our approach to kernel regression.
In this vein, for the AAV dataset we considered deep, 1D-convolutional architectures and for ogbg-molpcba we considered deep, graph convolutional architectures. The 1D-convolutional architecture has depth, weight and bias initialization variance, activation function, diagonal regularization, the type of pooling function, filter size, and whether to use the NNGP kernel or the NTK as hyperparamters. The graph convolution architecture has the same hyperparameters except filter size is replaced by whether self-loops are used. To tune hyperparameters, we used 1k trials of different hyperparameters on the Google Vizier service [12]. Tuning hyperparameters using the whole training and validation sets is not feasible, since the kernel must be recomputed each time. Instead, for the AAV dataset, we used only 2k examples from the training set and selected the hyperparameters with the best MSE (i.e. not Spearman correlation) on 1k examples from the validation set. For ogbg-molpcba, we used 2.5K examples for training and selected the hyperparameters with the best average mean precision on 2.5k examples from the validation set. For additional details on hyperparameters and their tuning, see Appendix C.
After selecting hyperparamters, we ran inference on ogbg-molpcba and all splits of the AAV dataset (see Table. 2). In all cases, we find our method is either better or competitive with prior methods across all splits. Specifically, for ogbg-molpcba our simple GNN kernel achieved a average precision (AP) of 0.2651. The current SotA AP without additional data is 0.30128 Wei et al. [2021] and a finite-width GNN without additional tricks achieves AP of 0.2020 using Kipf and Welling [2016] and 0.2266 utilizing Xu et al. [2018]. Thus, while our model falls short of SotA on ogbg-molpcba, it improves substantially on a comparable finite-width GNN.
## 6 Limitations and future directions
In this work we probe the performance of kernel regression across two dimensions of scale, in the number of examples and the complexity of the kernel. We distributed the computation of large neural kernels with up to 5 million examples and then used distributed conjugate gradients to solve the corresponding linear systems. In doing so, we not only set a new SotA for kernel methods on CIFAR-10 but also outperform highly tuned deep learning methods on a protein design problem and are competitive on a graph-structured, molecular screening problem. Computational considerations aside, we see that these neural kernels scale remarkably well in terms of predictive performance. Extrapolating from our scaling curves, it appears that significant improvements could still be made by adding more data. These infinitely-wide instantiations of deep neural networks offer some exciting properties and advantages over the parametric, SGD trained alternatives. They offer stable solutions with relatively little optimization and hyperparameter tuning. In the context of Gaussian processes, they represent a distribution over deep networks, with corresponding uncertainty that can be used across decision making tasks such as experimental design. Indeed, our SotA results on protein function prediction for targeted gene therapy and molecule toxicity prediction suggest that these kernels may be very well suited to exciting structured design problems. While computing quantities such as the marginal likelihood or test variances involves additional challenges, one can readily draw samples from the corresponding GP to be used, for example, with Thompson sampling approaches.
The computational cost of computing the neural kernels and solving the corresponding linear systems remains a limitation to scaling further. While there is a significant literature on approximating the kernels with regard to their scaling in the number of examples, approximations of the pairwise kernel computation itself similar to Zandieh et al. (2021), Han et al. (2022) seems necessary.
## Acknowledgements
We would like to give a special thanks to Jascha Sohl-Dickstein, who proposed block-wise kernel sharding, which enabled efficient communication over many compute nodes. We would also like to thank Andreea Gane, Kehang Han, and Benjamin Sanchez-Lengeling for helping us understand molecular and sequence datasets. We are also grateful to Roman Novak, Jeffrey Pennington, Samuel S. Schoenholz and Lechao Xiao for helpful discussions throughout the project.
|
2302.06572 | EnergyShield: Provably-Safe Offloading of Neural Network Controllers for
Energy Efficiency | To mitigate the high energy demand of Neural Network (NN) based Autonomous
Driving Systems (ADSs), we consider the problem of offloading NN controllers
from the ADS to nearby edge-computing infrastructure, but in such a way that
formal vehicle safety properties are guaranteed. In particular, we propose the
EnergyShield framework, which repurposes a controller ''shield'' as a low-power
runtime safety monitor for the ADS vehicle. Specifically, the shield in
EnergyShield provides not only safety interventions but also a formal,
state-based quantification of the tolerable edge response time before vehicle
safety is compromised. Using EnergyShield, an ADS can then save energy by
wirelessly offloading NN computations to edge computers, while still
maintaining a formal guarantee of safety until it receives a response
(on-vehicle hardware provides a just-in-time fail safe). To validate the
benefits of EnergyShield, we implemented and tested it in the Carla simulation
environment. Our results show that EnergyShield maintains safe vehicle
operation while providing significant energy savings compared to on-vehicle NN
evaluation: from 24% to 54% less energy across a range of wireless conditions
and edge delays. | Mohanad Odema, James Ferlez, Goli Vaisi, Yasser Shoukry, Mohammad Abdullah Al Faruque | 2023-02-13T18:14:05Z | http://arxiv.org/abs/2302.06572v1 | # EnergyShield: Provably-Safe Offloading of Neural Network Controllers for Energy Efficiency
###### Abstract.
To mitigate the high energy demand of Neural Network (NN) based Autonomous Driving Systems (ADSs), we consider the problem of offloading NN controllers from the ADS to nearby edge-computing infrastructure, but in such a way that formal _s_afety properties are guaranteed. In particular, we propose the EnergyShield framework, which repurposes a controller "shield" as a low-power runtime safety monitor for the ADS vehicle. Specifically, the shield in EnergyShield provides not only safety interventions but also a formal, state-based quantification of the tolerable edge response time before vehicle safety is compromised. Using EnergyShield, an ADS can then save energy by wirelessly offloading NN computations to edge computers, while still maintaining a formal guarantee of safety until it receives a response (on-vehicle hardware provides a just-in-time fail safe). To validate the benefits of EnergyShield, we implemented and tested it in the Carla simulation environment. Our results show that EnergyShield maintains safe vehicle operation while providing significant energy savings compared to on-vehicle NN evaluation: from 24% to 54% less energy across a range of wireless conditions and edge delays.
Formal Methods, Vehicular, Edge Computing, Autonomous Vehicles, Provable safety, Offloading, Autonomous Driving Systems +
Footnote †: journal: J. Accepted 2023, May 09-12, 2023, San Antonio, TX
+
Footnote †: journal: J.
In the event that the edge resources don't provide a response within this time, on-board local compute proceeds to evaluate the relevant DNNs before vehicle safety is no longer assured. Further energy savings are obtained by incorporating an estimator to anticipate edge-compute load and wireless network throughput; a more intelligent offloading decision is made by comparing this estimate against the tolerable edge-compute delay provided by the runtime safety monitor - thus preventing offloads that are likely to fail.
The main technical novelty of EnergyShield is its shield-based runtime safety monitor mentioned above. Although controller "shielding" is a well-known methodology to render generic controllers safe, the shielding aspect of EnergyShield contains two important novel contributions of its own: first, in the use of a shield not only to enforce safety but also as a runtime safety monitor to quantify the _time until the system is unsafe_, and second, in the specific design of that runtime monitor with regard to implementation complexity and energy considerations. In the first case, EnergyShield extends existing notions wherein the _current value_ of a (Zeroing-)Barrier Function (ZBF) is used as a runtime monitor to quantify the safety of an agent: in particular, it is novel in EnergyShield to instead use the current value of the ZBF to derive a _sound_ quantification of the _time_ until the agent becomes unsafe. Moreover, EnergyShield implements this quantification in an extremely energy efficient way: i.e., via a small lookup table that requires only a small number of FLOPS to obtain a guaranteed time-until-unsafe. This particular aspect of the runtime safety monitor is also facilitated by a using a particular, but known, ZBF and shield (Gelman et al., 2015) in EnergyShield: these components are both extremely simple, and so implementable using small, energy efficient NNs (Gelman et al., 2015). Together, these design choices ensures that any energy saved by offloading is not subsequently expended in the implementation of EnergyShield itself.
We conclude the paper with a significant sequence of experiments to validate both the safety and energy savings provided by the EnergyShield framework. In particular, we tested EnergyShield in the Carla simulation environment (Gelman et al., 2015) with several Reinforcement Learning (RL)-trained agents. Our experiments showed that EnergyShield entirely eliminated obstacle collisions for the RL agents we considered - i.e. made them safe - while simultaneously reducing NN energy consumption by as much as 54%. Additionally, we showed that EnergyShield has intuitive, safety-conscious offloading behavior: when the ADS is near an obstacle - and hence less safe - EnergyShield's runtime safety monitor effectively forced exclusively on-vehicle NN evaluation; when the ADS was further from an obstacle - and hence more safe - EnergyShield's runtime safety monitor allowed more offloading, and hence more energy savings.
**Related Work:**_Formal Methods for Data-Trained Controllers_. A number of approaches exist to assert the safety of data-trained controllers with formal guarantees; in most, ideas from control theory are used in some way to augment the trained controllers to this end. A good survey of these methods is (Gelman et al., 2015). Examples of this approach include the use of Lyapunov methods (Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015), safe model predictive control (Gelman et al., 2015), reachability analysis (Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015), barrier certificates (Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015), and online learning of uncertainties (Gelman et al., 2015). Controller "shielding" (Gelman et al., 2015) is another technique that often falls in the barrier function category (Gelman et al., 2015). Another approach tries to verify the formal safety properties of learned controllers using formal verification techniques (e.g., model checking): e.g., through the use of SMT-like solvers (Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015) or hybrid-system verification (Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015). However, these techniques only assess the safety of a given controller rather than design or train a safe agent.
_Edge Computing for Autonomous Systems_. A number of different edge/cloud offloading schemes have been proposed for ADSs, however none to date has provided formal guarantees. Some have focused on scheduling techniques and network topology to achieve effective offloading (Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015). Others focused on split and other NN architectures to make offloading more efficient (Gelman et al., 2015; Gelman et al., 2015; Gelman et al., 2015).
## 2. Preliminaries
### Notation
Let \(\mathbb{R}\) denote the real numbers; \(\mathbb{R}^{+}\) the non-negative real numbers; \(\mathbb{N}\) the natural numbers; and \(\mathbb{Z}\) the integers. For a continuous-time signal, \(x(t),t\geq 0\), denote its discrete-time sampled version as \(x[n]\) for some fixed sample period \(T\) (in seconds); i.e. let \(x[n]\triangleq x(n\cdot T)\) for \(n\in\mathbb{Z}\). Let \(\mathbf{1}_{a}:\mathbb{R}\rightarrow\{a\}\) be the constant function with value \(a\); i.e., \(\mathbf{1}_{a}(x)=a\) for all \(x\in\mathbb{R}\) (interpreted as a sequence where necessary). Finally, let \(\hat{x}=f(x,u)\) be a generic control system with \(x\in\mathbb{R}^{n}\) and \(u\in\mathbb{R}^{m}\), and let \(\pi:\mathbb{R}\times\mathbb{R}^{n}\rightarrow\mathbb{R}^{m}\) be a (possibly) time-varying controller. For this system and controller, consider a time \(\tau\geq 0\) and state \(x_{0}\), and denote by \(\xi_{\pi}^{t_{0},x_{0}}:\mathbb{R}^{+}\rightarrow\mathbb{R}^{n}\) the _to_-shifted state evolution of this system under controller \(\pi\) assuming \(x(t_{0})=x_{0}\). Let \(\xi_{\pi}^{t_{0},x_{0}}[n]\) indicate the same, except in discrete-time and with zero-order hold application of \(\pi\). \(\lVert\cdot\rVert\) and \(\lVert\cdot\rVert_{2}\) will denote the max and two-norms on \(\mathbb{R}^{n}\), respectively.
### Kinematic Bicycle Model
Throughout this paper, we will use the kinematic bicycle model (KBM) as the formal dynamical model for our autonomous vehicle (KBM). However, we consider the KBM model in terms of state variables relative to a fixed point in the plane, rather than absolute Cartesian coordinates. That is, the states are the distance to a fixed point, \(\lVert\vec{r}\rVert\), and orientation angle, \(\xi\), of the vehicle with respect to the same. These quantities describe a state-space model:
\[\left(\begin{smallmatrix}\xi\\ \xi\\ \end{smallmatrix}\right)=\left(\begin{smallmatrix}v\cos(\xi-\beta)\\ -\frac{1}{\rho}\sin(\xi-\beta)-\frac{\mu}{\ell_{\rho}}\sin(\beta)\\ a\end{smallmatrix}\right);\quad\beta\triangleq\tan^{-1}(\frac{\ell_{\rho}}{f _{\pi}+\ell_{\rho}}\tan(\delta_{f})) \tag{1}\]
where \(r(t)\) is distance to the origin; \(a\) is the linear acceleration input; \(\delta_{f}\) is the front-wheel steering angle input; and \(\psi+\xi=\tan^{-1}(y/x)\). We note a few special states for convenience: at \(\xi=\pm\pi/2\), the
Figure 2. Obstacle specification and minimum barrier distance as a function of relative vehicle orientation, \(\xi\).
vehicle is oriented tangentially to the obstacle, and at \(\xi=\pi\) or \(0\), the vehicle is pointing directly at or away from the origin, respectively (Figure 2). \(\beta\) is an _invertible function_ of the steering control, \(\delta_{f}\).
We also assume that the KBM has a steering constraint so that \(\delta_{f}\in[-\delta_{f}\max,\delta_{f\max}]\). For simplicity, we will consider \(\beta\) directly as a control variable; this is without loss of generality, for the reason noted above. Thus, \(\beta\) is also constrained: \(\beta\in[-\beta_{\max},\beta_{\max}]\). Finally, we define the state and control vectors for the KBM as: \(\chi\triangleq(\xi,r,\alpha)\) and \(\omega\triangleq(a,\beta)\), where \(\omega\in\Omega_{\text{admis}}\triangleq\mathbb{R}\times[-\beta_{\max},\beta_ {\max}]\), the set of admissible controls. Thus, the dynamics of the KBM are given by \(\dot{\chi}=f_{\text{KBM}}(\chi,\omega)\) with \(f_{\text{KBM}}\) defined according to (1).
### Barrier Functions and Shielding
In the sequel, we will use a controller "shield", which is a methodology for instantaneously correcting the outputs produced by a controller in closed loop; the objective is to make corrections such that the original controller, however it was designed or implemented, becomes safe - hence the "shield" moniker. Specifically, a controller shield is designed around a real-valued function over the state space of interest, called a (Zeroing-) Barrier Function (ZBF). The ZBF directly specifies a set safe states by its sign: states for which the ZBF is nonnegative are taken to be safe. The ZBF in turn indirectly specifies safe controls (as a function of state) in such a way that the sign of the ZBF is invariant along trajectories of the dynamics.
Formally, consider a control system \(\dot{x}=f(x,u)\) in closed loop with a state-feedback controller \(\pi:x\mapsto u\). In this scenario, a feedback controller in closed loop converts the control system into an autonomous one - the autonomous vector field \(f(\cdot,\pi(\cdot))\). In the context of an autonomous system, then, we recall the following definition for a Zeroing-Barrier Function (ZBF):
Definition 1 (Zeroing Barrier Function (ZBF) (Zff, Definition 2)).: _Let \(\dot{x}=f(x,\pi(x))\) be the aforementioned closed-loop, autonomous system with \(x(t)\in\mathbb{R}^{n}\). Also, let \(h:\mathbb{R}^{n}\to\mathbb{R}\), and define \(\mathcal{C}\triangleq\{x\in\mathbb{R}^{n}:h(x)\geq 0\}\). If there exists a locally Lipschitz, extended-class-\(K\) function, \(\alpha\) such that:_
\[\nabla_{x}h(x)\cdot f(x,\pi(x))\geq-\alpha(h(x))\text{ for all }x\in\mathcal{C} \tag{2}\]
_then \(h\) is said to be a **zeroing barrier function (ZBF)**._
Moreover, the conditions for a barrier function above can be translated into a set membership problem for the outputs of such a feedback controller. This is explained in the following corollary.
Proposition 1 ().: _Let \(\dot{x}=f(x,u)\) be a control system that is Lipschitz continuous in both of its arguments on a set \(\mathcal{D}\times\Omega_{\text{admis}}\): furthermore, let \(h:\mathbb{R}^{n}\to\mathbb{R}\) with \(C_{h}\triangleq\{x\in\mathbb{R}^{n}|h(x)\geq 0\}\subseteq\mathcal{D}\), and let \(\alpha\) be a class \(\mathcal{K}\) function. If the set_
\[R_{h,\alpha}(x)\triangleq\{u\in\Omega_{\text{admis}}|\nabla_{x}^{T}h(x)\cdot f (x,u)+\alpha(h(x))\geq 0\} \tag{3}\]
_is non-empty for each \(x\in\mathcal{D}\), and a Lipschitz continuous feedback controller \(\pi:x\mapsto u\) satisfies_
\[\pi(x)\in R_{h,\alpha}(x)\quad\forall x\in\mathcal{D} \tag{4}\]
_then \(C_{h}\) is forward invariant for the closed-loop dynamics \(f(\cdot,\pi(\cdot))\)._
_In particular, if \(\pi\) satisfies (4) and \(x(t)\) is a trajectory of \(\dot{x}=f(x,\pi(x))\) with \(h(x(0))\geq 0\), then \(h(x(t))\geq 0\) for all \(t\geq 0\)._
Proof.: This follows directly from an application of zeroing barrier functions (Zff, Theorem 1).
Proposition 1 is the foundation for controller shielding: (3) and (4) establish that \(h\) (and associated \(\alpha\)) forms a ZBF for the closed-loop, autonomous dynamics \(f(\cdot,\pi(\cdot))\). Note also that there is no need to distinguish between a closed-loop feedback controller \(\pi\), and a composite of \(\pi\) with a function that _shields_ (or filters) its output based on the current state. Hence, the following definition:
Definition 2 (Controller Shield).: _Let \(\dot{x}=f(x,u)\), \(h\), \(\mathfrak{C}_{h}\), \(\alpha\) and \(\mathcal{D}\times\Omega_{\text{admis}}\) be as in Proposition 1. Then a **controller shield** is a Lipschitz continuous function \(\mathfrak{S}:\mathcal{D}\times\Omega_{\text{admis}}\to\Omega_{\text{admis}}\) such that_
\[\forall(x,u)\in\mathcal{D}\times\Omega_{\text{admis}}.\mathfrak{S}(x,u)\in R_{ h,\alpha}(x). \tag{5}\]
### A Controller Shield for the KBM
In this paper, we will make use of the existing ZBF and controller shield designed for the KBM in (K
signal, \(y\). Further assume that, by virtue of its size, computing an output of \(\mathcal{NN}_{c}\) with on-vehicle hardware consumes significant energy. Thus, it would be advantageous, energy-wise, to _offload_ evaluations of \(\mathcal{NN}_{c}\) to edge computing infrastructure: in other words, wirelessly transmit a particular sensor measurement, \(y\), to off-vehicle edge computers, where the output \(u=\mathcal{NN}_{c}(y)\) is computed and returned to the requesting ADS.
The problem with this approach is largely from a safety point of view. In particular, the controller \(\mathcal{NN}_{c}\) was designed to operate _in real time and in closed-loop_: i.e. the control action at discrete-time sample \(n\) is intended to be computed from the sensor measurement at the _same_ time sample. In the notation of discrete-time signals (see Section 2.1), this means: \(u[n]=\mathcal{NN}_{c}(y[n])\). However, offloading a sensor measurement, \(y[n]\), to the edge entails that the correct output of \(\mathcal{NN}_{c}(y[n])\) will not be back on-vehicle before some non-zero number of samples, say \(\Delta\). Thus, \(\mathcal{NN}_{c}(y[n])\) will not be available at time \(n\) to set \(u[n]=\mathcal{NN}_{c}(y[n])\) as intended; rather, the soon-set possible use of the output \(\mathcal{NN}_{c}(y[n])\) will be at time \(n+\Delta\), or \(u[n+\Delta]=\mathcal{NN}_{c}(y[n])\). This delay creates obvious safety issues, since the state of the vehicle - and hence the correct control to apply - will have changed in the intervening \(\Delta\) time samples. More importantly, even the "correct" control action applied at \(n+\Delta\) may be insufficient to ensure safety: e.g., after \(\Delta\) samples have elapsed, it may be too late to apply adequate evasive steering.
### EnergyShield Structure
If we assume that the ADS itself has enough on-vehicle compute to obtain an output \(\mathcal{NN}_{c}(y[n])\)_in real time_, then this safety problem above becomes one of making an _offloading decision_: ideally one that saves energy without compromising safety. That is, should a particular computation of \(\mathcal{NN}_{c}\) be offloaded to the edge? And how long should the ADS wait for a response so as to ensure the situation is correctable?
The nature of the offloading decision means that EnergyShield must address two essential and intertwined issues in order to ensure safety of the ADS vehicle during offloading. On the one hand, EnergyShield must be able to _correct_ the control actions provided by \(\mathcal{NN}_{c}\) after an offload decision (see explanation above). On the other hand, EnergyShield must limit the duration it waits for each offloading request, so that actions provided by \(\mathcal{NN}_{c}\)_can_ be corrected in the first place; i.e., among all possible offloading delays, \(\Delta\), it is not immediate which may be corrected and which may not (loosely speaking, \(\Delta=\infty\) is one delay that likely cannot be corrected). In this sense, knowing that a particular response-delay, \(\Delta^{\prime}\) is correctable essentially characterizes how to take an offloading decision, since it provides an _expiration on safety_: i.e., proceed to offload, and wait for a response until \(\Delta^{\prime}\) samples have elapsed - at which point resume local evaluation of \(\mathcal{NN}_{c}\).
In particular, EnergyShield has two central components to achieve these ends:
**C1: Controller Shield**. EnergyShield contains a controller shield (see Section 2.3), which ensures that safety is maintained irrespective of offloading-delayed controller outputs; in other words, it corrects unsafe behavior of \(\mathcal{NN}_{c}\) that results from unanticipated (to \(\mathcal{NN}_{c}\)) changes in vehicle state during offloading delays.
**C2: Runtime Safety Monitor**. EnergyShield contains a runtime safety monitor that provides the ADS an upper bound, \(\Delta_{\max}\) (in samples), on how long it should wait for a response to one of its offloading requests to maintain safety, _assuming no updates to the control action in the meantime_; i.e., provided the offload delay is \(\Delta\leq\Delta_{\max}\), then **C1**, the controller shield, can guarantee safe recovery after holding the last control signal update through offload delay period (**C1** may use on-vehicle computation if necessary). _In other words, \(\Delta_{\max}\) specifies and expiration for the safety guarantee provided by_**C1**_using on-vehicle computation._
Naturally, **C1** and **C2** need to be designed together, since their objectives are mutually informed. Indeed, in the specific design of EnergyShield, these components are designed from the same ZBF (defined in Section 2.3): see Section 4 for formal details.
Unfortunately, neither of the components **C1** nor **C2** can operate effectively on the same raw sensor measurements, \(y[n]\), used by the controller; this is especially true given our intention to implement them via ZBFs and controller shields. In particular, both require some (limited) state information about the ADS in order to perform their tasks. Thus, EnergyShield requires a perception/estimator component to provide state information to **C1** and **C2**. Note that we deliberately exclude the design of such an estimator from the EnergyShield framework in order to provide additional flexibility: in particular, since the controller \(\mathcal{NN}_{c}\) may effectively contain an estimator, we wish to allow for estimation to be offloaded, too - provided it is executed locally just-in-time before informing **C1** and **C2** (see Section 3.3). Nevertheless such an estimator is necessary for EnergyShield, so we include it as component:
**C3: State Estimator**. EnergyShield requires (minimal) state estimates be provided as input to **C1** and **C2**. By convention, this estimator will be a NN denoted by \(\mathcal{NN}_{p}:y\mapsto x\). _We assume that \(\mathcal{NN}_{p}\) can be computed by on-vehicle hardware in one sample period._
The interface of **C3** with both **C1** and **C2** makes the latter two components (state-)context aware. _That is, EnergyShield makes context-aware offloading decisions based on the current vehicle state_. Moreover, it is important to note that since the prior control action will be held during offload \(\Delta_{\max}\), the output of **C2**, control in addition to state dependent: that is, **C2** actually produces an output \(\Delta_{\max}(\hat{x},u)\) for (arbitrary) state \(\hat{x}\) and the control \(u\) applied just before offload.
EnergyShield has one further important component, but one that is motivated purely by energy savings with no effect on safety. Crucially the known expiration of safety provided by **C2**, i.e. \(\Delta_{\max}(x)\), affords the opportunity to use additional information in making an offload decision. In particular, an estimate of the anticipated edge response time, \(\hat{\Delta}\), can be used to _forego_ offloads that are unlikely to complete before the expiration of the safety deadline, \(\Delta_{\max}(x)\). For this reason, EnergyShield contains an estimator of edge response time to preemptively skip offloads that are likely to fail:
**C4: Edge-Response Estimator**. EnergyShield specifies that an estimate of the current edge response time, \(\hat{\Delta}\), is provided to inform offloading decisions.
We note, however, that _EnergyShield doesn't specify a particular estimator to be used in this component_: any number of different estimators may be appropriate, and each estimator may lead to different energy profiles depending on its efficacy. Moreover, since \(\hat{\Delta}\) is never used to override \(\Delta_{\max}(x)\), safety is preserved irrespective of the specific estimator used.
The interconnection of the components **C1** through **C4** in EnergyShield is illustrated in Figure 3. Note that component **C3**, the state estimator, is connected to components **C1** and **C2**, the controller shield and safety runtime monitor, respectively. Also note that the output of **C2** provides a signal \(\Delta_{\max}(x)\) to the offloading decision switch; also informing that decision is the estimate of immediate edge-response times provided by component **C4**.
### Semantics of an EnergyShield Offloading Decision
In this subsection, we consider the timeline of a single, hypothetical EnergyShield offloading decision to illustrate the details of the interplay between the components described in Section 3.2. In particular, suppose that an offloading interval has just been completed, and at time index \(n_{0}\) a new offloading decision is to be taken.
We call the time between the initialization of an offloading decision and the time that offloading decision has been resolved an _offloading period_ (the resolution is either by a response from the edge or a fail-over to on-vehicle compute).
_Timeline:_
1. \(n_{0}-1\) _Last time index of previous offload period._
2. Assumption: \(\hat{x}[n_{0}]\pm x[n_{0}-1]=\mathcal{NN}_{p}(y[n_{0}-1])\) is always computed locally in the last sample of the previous offloading period.
3. \(n_{0}\) _Initial time index of new offload period._
4. The first sample of the new offload period inherits a locally computed \(\hat{x}[n_{0}]\) from the previous offloading period.
5. \(\hat{x}[n_{0}]\) is provided to **C1** to correct \(u[n_{0}]\) as calculated by the previous offloading. Let this correct control action be \(\hat{u}[n_{0}]\)
6. Fix control action applied at \(n_{0}\): i.e. \(u_{\text{0-h}}=\hat{u}[n_{0}]\), with \(\hat{u}[n_{0}]\) as calculated above.
7. \(\hat{x}[n_{0}]\) and \(u_{\text{0-h}}\) are provided to **C2**, the runtime safety monitor, to generate \(\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})\)
8. **C4** generates an estimate for the edge response time, \(\hat{\Delta}\) based on all packets exchanged so far.
9. _Offloading Decision:_ * _Proceed with offload, if_ \(\hat{\Delta}\leq\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})\) _AND_ \(\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})\geq 1\); i.e., proceed to transmit \(y[n_{0}]\) to the edge. Initialize offload duration counter: \(\Delta_{\text{cnt}}=1\)
1. _Otherwise, terminate offload period, and use local fail-safe._ Skip to _Unsuccessful Offload_ with \(\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})\)=1.
1. \(\vdots\) \(\vdots\) \(\vdots\)
1. \([n_{0}+\Delta_{\text{cnt}}]\) _Offload in progress; no edge response and_ \(\Delta_{\text{cnt}}<\frac{\Delta_{\max}(\hat{x}[n_{0}])}{\Delta_{\max}(\hat{x} [n_{0}])}\)
2. Maintain zero-order hold of \(u[n_{0}+\Delta_{\text{cnt}}]=u_{\text{0-h}}\).
3. Increment \(\Delta_{\text{cnt}}\colon\Delta_{\text{cnt}}\leftarrow\Delta_{\text{cnt}}+1\).
4. \(\vdots\) \(\vdots\) \(\vdots\)
**Now, the current offload period ends in one of two ways:**
_I) Successful Offload: (resume timeline from_ \(n_{0}+\Delta_{\text{cnt}}\) _)_
1. \([n_{0}+\Delta\;]\) _Edge response received;_ \(\Delta=\Delta_{\text{cnt}}\leq\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})\)
2. Apply received control action \(u[n_{0}+\Delta]=\mathcal{NN}_{c}(y[n_{0}])\).
3. Initiate local evaluation of \(\mathcal{NN}_{c}\) for next time interval.
4. Initiate local evaluation of \(\mathcal{NN}_{p}\) for next time interval.
5. \(n_{0}-\Delta\) becomes time \(n_{1}-1\) for the starting index of the next offload period. (See \(n_{0}-1\) time index above.)
_II) Unsuccessful Offload: (resume timeline from_ \(n_{0}+\Delta_{\text{cnt}}\))
1. \([n_{0}+\Delta_{\max}]\) _No edge response received, and safety expired;_ \(\frac{\Delta_{\text{cnt}}=\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})}{\Delta_{ \text{cnt}}=\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})}\)
2. Maintain original zero-order hold control \(u[n_{0}+\Delta_{\max}(\hat{x}[n_{0}],u_{\text{0-h}})]=u_{\text{0-h}}\) (there have been no updates.)
3. Initiate local evaluation of \(\mathcal{NN}_{c}\) for next time interval.
4. Initiate local evaluation of \(\mathcal{NN}_{p}\) for next time interval.
5. \(n_{0}-\Delta_{\max}(\hat{x}[n_{0}])\) becomes time \(n_{1}-1\) for the starting index of the next offload period. (See \(n_{0}-1\) time index above.)
In particular, note two crucial facts. First, if **C2** returns \(\Delta_{\max}(\hat{x},u)=0\), then it effectively forces pure on-vehicle evaluation of \(\mathcal{NN}_{c}\) and \(\mathcal{NN}_{p}\). Second, we ensured that an up-to-date estimate of the state is always available for both **C1** and **C2** before they have to act.
## 4. EnergyShield: Provably Safe Offloading
### Main Formal Result
#### 4.1.1. Formal Assumptions
We begin this section with a list of formal assumptions about the ADS. These are largely based around the structure of EnergyShield, as described in Section 3.
Assumption 1 (ADS Safety).: _Consider a fixed point in the plane as a stationary obstacle to be avoided by the ADS, and a disk or radius \(\bar{r}\) around the origin to be a set of unsafe states; see Figure 2._
Figure 3. EnergyShield Framework
**Assumption 2** (ADS Model).: _Let Assumption 1 hold. Thus, suppose that the ADS vehicle is modeled by the KBM dynamics in (1). Suppose further that interactions with this model happen in discrete time with zero-order hold. Let \(T\) be the sampling period._
**Assumption 3** (ADS Sensors).: _Let Assumptions 1 and 2 hold. Suppose the KBM-modeled ADS has access to samples of a sensor signal, \(s[n]\in\mathbb{R}^{N}\), at each discrete time step, and there is a perception NN, \(\mathcal{N}\nabla_{p}:s[n]\mapsto\chi[n]\), which maps the sensor signal at each discrete time to the (exact) KBM state at the same time instant, \(\chi[n]\)._
**Assumption 4** (ADS Control).: _Let Assumptions 1 - 3 hold. Suppose this KBM-modeled ADS vehicle has a NN controller, \(\mathcal{N}\nabla_{c}:s\mapsto\omega\), which at each sample has access to the sensor measurement \(s\)._
**Assumption 5** (ADS Local Computation).: _Let Assumptions 1 - 4 hold. Suppose that the output of \(\mathcal{N}\nabla_{p}\) and \(\mathcal{N}\nabla_{c}\) can be computed by ADS on-vehicle hardware in less than \(T\) seconds - i.e., not instantaneously. Thus, suppose that the control action is obtained with a one-sample computation delay when using on-vehicle hardware: i.e., the control action applied at sample \(n+1\) is \(\omega[n+1]=\mathcal{N}\nabla_{c}(s[n])\)._
#### 4.1.2. Component Design Problems
There are two central problems that need to be solved: i.e., corresponding to the design of the two main components of EnergyShield, **C1** and **C2** (see Section 3).
The solutions to these problems are deferred to Sections 4.2 and Section 4.3, respectively. We state them here in order to facilitate the statement of our main result in the next subsection.
**Problem 1** (Controller Shield Design (**C1**)).: _Let Assumptions 1 - 5 hold. Then the problem is to design: first, design functions \(h\) and \(\alpha\) such that they constitute a ZBF for the KBM (see); and then using this ZBF, design a controller shield, \(\mathfrak{S}\) for the KBM model. The resulting controller shield must have the following additional property for **a discrete-time version of the KBM** with zero-order-hold inputs:_
* _Let_ \(\chi[n_{0}-1]\) _and_ \(\chi[n_{0}]\) _be KBM states such that_ \(h(\chi[n_{0}-1]),h(\chi[n_{0}])>0\)_, and let_ \(\chi[n_{0}]\) _result from a feasible input_ \(\hat{\omega}[n_{0}-1]\) _applied in state_ \(\chi[n_{0}-1]\)_. Then the control action_ \[\hat{\omega}[n_{0}]=\mathfrak{S}(\chi[n_{0}-1],\omega[n_{0}])\] (9) _must yield a state_ \(\chi[n_{0}+1]\) _such that_ \(h(\chi[n_{0}+1])>0\)_; i.e., the controller shield preserves safety under discretization of the KBM and one-step estimation delay (associated with_ \(\mathcal{N}\nabla_{p}\)_), as in the case of no computations being offloaded._
**Problem 2** (Runtime Safety Monitor Design (**C2**)).: _Let Assumptions 1 - 5 hold, and assume that \(h\), \(\alpha\) and \(\mathfrak{S}\) solve Problem 1. Then the problem is to design a runtime safety monitor:_
\[\Delta_{max}:\mathbb{R}^{3}\times\Omega_{adm\text{irs}}\rightarrow\mathbb{N} \tag{10}\]
_with the following property:_
* _Let_ \(\chi[n_{0}-1]\) _be such that_ \(h(\chi[n_{0}-1])>0\)_. Then for constant control,_ \(\omega=\omega[n_{0}]\)_, applied to the discretized KBM starting from_ \(\chi[n_{0}-1]\) _the following is true:_ \[\forall n=0,\dots,\Delta_{max}(\chi[n_{0}-1],\omega[n_{0}])\cdot h(\chi[n_{0}- 1+n])>0\] (11) _i.e. the constant control_ \(\omega=\omega[n_{0}]\) _preserves safety for at least_ \(\Delta_{max}(\chi[n_{0}-1],\omega[n_{0}])\) _samples from state_ \(\chi[n_{0}-1]\)_._
_(The delay in \(\chi[n_{0}-1]\) accounts for the computation time of \(\mathcal{N}\nabla_{p}\).)_
#### 4.1.3. Main Result
Given solutions to these problems, it is straightforward to conclude our main formal result.
**Theorem 1**.: _Let Assumptions 1 - 5 hold, and assume a ZBF for the KBM dynamics, using which Problem 1 and Problem 2 can be solved._
_Then the offloading policy described in Section 3.3 preserves safety of the KBM-modeled ADS (Assumptions 1 and 2)._
The proof follows largely by construction. Each offload period is limited in duration by the runtime safety monitor; thus, a safety monitor that solves Problem 2 will ensure safety under the specified constant control action during the offload period. Then by the additional property of the controller shield in Problem 1, safety can be maintained after the offloading period ends: i.e., either by a deciding to perform a new offload if there remains significant safety margin, or by executing the shield in closed loop because there is no offload safety margin.
**Corollary 1**.: _Let Assumptions 1 - 5 hold, and consider the ZBF for the KBM dynamics specified in Section 2.4. Then the controller shield in Section 4.2 uses this ZBF and solves Problem 1; likewise, the runtime monitor in Section 4.3 uses this ZBF and solves Problem 2. Hence, our implementation of EnergyShield is safe._
### KBM Controller Shield
Fortunately, we have access to a preexisting ZBF and controller shield designed for the KBM: see Section 2.4(C). That is, the ZBF is available after using the design methodology in (C) to choose the parameter \(\sigma\) (see Section 2.4); for simplicity, we will omit further discussion this design process. Thus for this section, we refer to a fully implemented controller shield as \(\mathfrak{S}_{\text{KBM}}\), with the understanding that it has been designed for the relevant KBM model and safety parameter \(\bar{r}\) (see Figure 2); viz. Assumptions 1 and 2.
Thus, the main requirement of this section is to alter \(\mathfrak{S}_{\text{KBM}}\) as necessary so that it satisfies the additional property required in Problem 1. This is the subject of the following Lemma, which also defines the alterations in question.
**Lemma 1**.: _Let Assumptions 1 - 5 hold as usual, and let \(\mathfrak{S}_{\text{KBM}}\) be a controller shield designed under these assumptions as per Section 2.4._
_Then there exists a \(\rho>0\) such that the following controller shield:_
\[\mathfrak{S}_{\text{KBM}}^{\rho}:((r,\xi,\upsilon),\omega)\mapsto\begin{cases} \mathfrak{S}_{\text{KBM}}((r-\rho,\xi,\upsilon),\omega)&r-\rho\geq r_{\min}(\xi) \\ \beta_{max}&r-\rho\geq r_{\min}(\xi)\wedge\xi\geq 0\\ -\beta_{max}&r-\rho\geq r_{\min}(\xi)\wedge\xi<0.\end{cases} \tag{12}\]
_solves Problem 1._
The proof of this Lemma is deferred to Appendix A.
A further remark is in order about Lemma 1. Note that the altered controller shield \(\mathfrak{S}_{\text{KBM}}^{\rho}\) maintains the energy efficient implementation of the controller shield \(\mathfrak{S}_{\text{KBM}}\) as designed in (C); indeed only two additional ReLU units are required, which amounts to a trivial per-evaluation increase in energy consumption.
### KBM Runtime Safety Monitor: Generating Safety Expiration Times
Recall that the runtime safety monitor of EnergyShield must provide an _expiration_ on the safety of the vehicle during an offload period,
throughout which only a single, fixed control input is applied. This expiration must come with a _provable guarantee_ that the vehicle safety is not compromised in the interim. In the formulation of EnergyShield and Problem 2, this means only that \(h_{\vec{r},\sigma}\) must remain non-negative until the expiration of the deadline provided by the runtime safety monitor: see the condition (11) of Problem 2.
This formulation is convenient because it means that the problem can again be analyzed in continuous time, unlike our consideration of Problem 1 above: the conversion back to discrete time involves a floor operation; and compensating for the one-sample state delay induced by computing \(\mathcal{NN}_{p}\) involves subtracting one sample from the result. That is, to solve Problem 2 and design an EnergyShield-safety monitor, it is sufficient provide a (real) time, \(v\), s.t.:
\[\forall t\in[0,v]\.\ h\big{(}\xi_{\alpha_{\alpha}[n_{0}]}^{\alpha,\text{dyn} \alpha_{\alpha}]}(t)\big{)}>0. \tag{13}\]
In other words, the flow of \(f_{\text{KBM}}\) started from \(\chi[n_{0}-1]\) and using constant control \(\omega[n_{0}]\) maintains \(h>0\) for the duration \([0,v]\). We emphasize again that such a \(v\) can be converted into the correct sample units expected for the output \(\Delta_{\max}(\chi[n_{0}-1],\omega[n_{0}])\) by using a floor operation and subtracting one. With this context, we have the following Lemma, which solves Problem 2.
Lemma 2 ().: _Let Assumptions 1 - 5 hold as usual. Let_
\[\Delta_{max}(\chi[n_{0}-1,\omega[n_{0}])\triangleq\max(\lfloor v(\chi[n_{0} -1],\omega[n_{0}])\rfloor-1,0) \tag{14}\]
_where \(v=v(\chi[n_{0}-1],\omega[n_{0}])\) solves the equation:_
\[\sqrt{2}\cdot L_{h_{\vec{r},\sigma}}\cdot\lVert f_{\text{KBM}}(\chi[n_{0}-1], \omega[n_{0}])\rVert_{2}\cdot v\cdot e^{L_{\text{KBM}}\cdot v}=\hbar(\chi[n_{ 0}-1]) \tag{15}\]
_for \(L_{h_{\vec{r},\sigma}}\) and \(L_{f_{\text{KBM}}}\) upper bounds on the Lipschitz constants of \(h_{\vec{r},\sigma}\) and \(f_{\text{KBM}}\), respectively._
_Then \(\Delta_{max}(\chi[n_{0}-1,\omega[n_{0}])\) so defined solves Problem 2._
The proof of Lemma 2 is deferred to Appendix B.
Lemma 2 specifies a complete solution to Problem 2, as claimed. However in its immediate form, it requires numerically solving (15) with each evaluation of \(\Delta_{\max}(\chi[n_{0}-1],\omega[n_{0}])\); i.e., each time a safety expiration time is requested from the runtime safety monitor (every sample in the case where the offloading period is terminated before offload). The nature of (15) is such that solving it numerically is not especially burdensome - especially compared to the NN evaluations it replaces; however, as a practical matter it is also possible to implement it as a LUT to achieve greater energy efficiency.
## 5. Experiments and findings
The purpose of this section is to assess the following key aspects of EnergyShield: (_i_) the extent of energy savings achievable compared to the conventional continuous local execution mode given a wide variety of network conditions and server delays, (_ii_) its ability to enforce the safety through obstacle collision avoidance, (_iii_) how representative the upper bounds of the edge response time (\(\Delta_{max}\)) are of the inherent risks existing in the corresponding driving context, and (_iv_) its generality when integrated with controllers of distinctive behavioral characteristics, in particular when it comes to different learnt driving policies.
### Experimental Setup
#### 5.1.1. Operational Policies
In addition to the baseline continuous local execution, we designate two EnergyShield offloading modes:
* _Eager:_ in which a new offloading interval is immediately started if either edge responses have been received at the ADS or \(\Delta_{max}\) expired.
* _Uniform:_ in which the start of a new offloading interval is always delayed until \(\Delta_{max}\) expires, regardless of whether edge responses have been received or not.
We define both these modes to reflect the attainable behavioral trade-offs of EnergyShield with regards to realizing an ideal control behavior or maximizing energy efficiency. This distinction is illustrated through the first offloading interval in Figure 4 in which the uniform EnergyShield tiles upon its retrieval of the edge responses until \(\Delta_{max}\) expires unlike the eager EnergyShield mode.
#### 5.1.2. Experimental Scenario
We perform our experiments using the CARLA open-source simulator for autonomous driving research (Garfani et al., 2018). We follow the setup proposed in (Krishna et al., 2018), and implement a similar experimental scenario. Basically, the scenario involves a four-wheel vehicle travelling from a starting position A to destination B along a 100m motorway track with 4 pedestrian obstacles in its path. The first obstacle spawns after 40m of the track, while the remaining spawning positions are uniformly spaced between the first obstacle's position and that of the final destination - with a potential \(\pm 10m\) variation along the longitudinal axis.
#### 5.1.3. Experimental Settings
Throughout this section, _all_ of our experiments are conducted under different combinations of the following two binary configuration parameters:
* **S**: this binary variable indicates whether the Controller Shield component is _active_ (see Section 3.2).
* **N**: this binary variable indicates whether this is a more challenging, "noisy" version of the experimental test case.
In particular, the noisy version entails perturbing the obstacles' spawning positions by additional values sampled from a normal distribution \(\mathcal{N}(0,1.5m)\) along both the longitudinal and latitudinal axis. For example, the configuration settings (S = 1, N = 0) indicate that the experiment was performed with Controller Shield active and with no perturbations in the obstacles' spawning positions.
#### 5.1.4. Simulation Setup
For the controller model, its first stage entails two concurrent modules: an object detector as the large NN model of the ADS and a \(\beta\) Variational Autoencoder (\(\beta\)-VAE) providing additional latent feature representations of the driving scene. Both components operate on 160\(\times\)80 RGB images from the vehicle's attached front-facing camera. In the subsequent stage, a Reinforcement Learning (RL) agent aggregates the detector's bounding box predictions, latent features, and the inertial measurements (\(\delta_{f}^{c}\), \(v\), and \(a\)) to predict vehicle control actions (steering angle and throttle).
Figure 4. The operational policies in our experiments given base time window \(\tau\). Darker instances imply local execution.
The inertial measurements can be fetched directly from CARLA, whose positional and orientation measurements are also used directly to calculate \(r\) and \(\xi\) relative the vehicle's current nearest obstacle for obstacle state estimation. We trained the RL controller agents using a reward function, \(\mathcal{R}\), that aims to maximize track completion rates through collision avoidance while minimizing the vehicle's center deviance from the primary track. For the definition of \(\mathcal{R}\) as well as details of the RL agents see Appendix C.
#### 5.1.5. Performance Evaluations
We use a pretrained ResNet-152 for our object detector and benchmark its performance in terms of latency and energy consumption when deployed on the industry-grade Nvidia Drive PX2 Autochaurfer ADS. We found that a single inference pass on the ResNet-152 took \(\approx\) 16 ms, and accordingly, we fixed the time-step in CARLA at 20 ms since the detector-in-the-loop was the simulation's computational bottleneck. To evaluate the wireless transmission power, we use the data transfer power models in (Kang et al., 2018) and assume a Wi-Fi communication link.
#### 5.1.6. Wireless Channel Model
We model the communication overheads between the ego vehicle and edge server as:
\[L_{comm}=L_{Tx}+L_{que}\ \ s.t.,\ L_{Tx}=\frac{data\ size}{\phi}, \tag{16}\]
where \(L_{que}\) represents potential queuing delays at the server whereas \(L_{Tx}\) is the transmission latency defined by the size of the transmission data, \(data\_size\), over the experienced channel throughput, \(\phi\). Here, we assume \(\phi\) as the "effective" channel throughput experienced at the ego vehicle, which takes into consideration potential packet drops, retransmissions, etc. We leverage a Rayleigh distribution model as in (Kang et al., 2018) to sample throughput values \(\phi\) - \(Rayleigh(0,\sigma_{\phi})\) with zero mean and \(\sigma_{\phi}\) scale (default \(\sigma_{\phi}\)=20 Mbps). Details on the modelling of queuing delays, \(q\), and the server response time estimation (i.e., \(\hat{\Delta}\)) are provided in Appendix C.
### EnergyShield Evaluations
The purpose of this experiment is to assess the controller's performance when supplemented with EnergyShield in terms of energy efficiency and safety. For every configuration of S and N, we run the test scenario for 35 episodes and aggregate their combined results.
**Energy Efficiency:** We first assess the energy efficiency gains offered by EnergyShield compared to the baseline continuous local execution. As illustrated Figure 5, the left barplot demonstrates that both modes of EnergyShield substantially reduce the energy consumption footprint of the NN compared to local execution across all S and N configurations. For instance, under the default configuration (S = 0, N = 0), EnergyShield energy reductions reach 20% and 40.4% for the eager and uniform modes, respectively. These numbers further improve for the subsequent configurations in which N = 1 or S = 1. Upon inspection, we find that this is the result of the ego vehicle encountering more instances in which obstacles are not in the direct line-of-sight of its heading. The reasons being that at N = 1, some obstacles can be displaced out of the primary lane that the ego vehicle follows to complete the track, whereas at S = 1, such instances result from the Controller Shield applying corrective behaviors on the NN's predicted steering outputs, resulting in more tangential orientations of the vehicle with respect to the obstacles (i.e., \(\xi\rightarrow\pm\pi/2\)). Accordingly, large values of \(\Delta_{max}\) - about 4-5 time samples (equivalent to 80-100 ms) - are increasingly sampled, and that automatically translates into more offloading decisions. For instance at (S = 1, N = 0), the energy efficiency gains reach 24.3% and 54.6% for the respective eager and uniform modes.
**Safety Evaluation:** To assess the EnergyShield's ability to enforce safety, we designate track completion rates (TCR %) as a comparison metric to signify the proportion of times the vehicle was able to complete the track without collisions. Taking the local execution mode as the test scenario, the right barplot of Figure 5 shows that without an active Controller Shield (S = 0), collisions with the pedestrian obstacles cause the TCR% to be 65.7% at N = 0, and even less at 22.9% for the noisy test case (N = 1). However, when the Controller Shield is active (S = 1), collisions are completely avoided and the TCR (%) values jump to 100% for both cases. This is also visible through the respective improvements in \(\mathcal{R}\) which reached 13.3% and 61.1%. To further demonstrate such occurrences, we analyze in Figure 6 the ego vehicle's chosen trajectories across 3 episodes of dissimilar (S, N) configurations. As shown, the (S = 0, N = 0) instance incurs a collision with the pedestrian object and does not complete the track. An active Controller Shield (S = 1), however, enforces a left or right corrective maneuvering action for obstacle avoidance and maintaining safety. Pictorial illustrations of these actions are also provided in the Figure.
**Energy vs. Distance:** To assess how representative the \(\Delta_{max}\) upper bounds provided by the Runtime Safety Monitor are of the corresponding driving scene context, we examine EnergyShield's energy consumption at different distances from the nearest obstacle (\(r\)). The hypothesis is that larger \(r\) values imply relatively "safer" driving situations, which would result in larger values of \(\Delta_{max}\) to be sampled, and accordingly more offloading instances enhancing the NN's energy efficiency. As shown in Figure 7, we plot the average experienced normalized energy ratings of the two modes of EnergyShield with respect to local execution against \(r\) across every configuration's set of 35 episodes. Each tick on the horizontal axis accounts for an entire range of 1m distances rather than a single value - e.g., a value of 2 on the horizontal axis encompasses all distances in the range [2 - 3). At close distances (\(r\) < 4m), we find that EnergyShield modes incur almost the same energy consumption overhead as that from the default local execution. This is mainly accredited to the Runtime Safety Monitor recognizing the higher risks associated with the close proximity from the objects, and accordingly outputting smaller values of \(\Delta_{max}\) that can only be satisfied by local execution. As the distance from obstacles increases, so do the values of \(\Delta_{max}\), causing a gradual increase in the number of offloading instances, followed by a progressive reduction in energy consumption. For instance, the eager and uniform modes
Figure 5. EnergyShield’s energy efficiency gains with respect to continuous local execution (left) and safety analysis in terms of the \(\mathcal{R}\) evaluation and % TCR (right).
achieve 32% and 66% respective reductions in energy consumption at \(r=13\) m for the (S = 1, N = 1) configuration. Even more so, all configurations of the respective eager and uniform modes at the (\(r\) > 20m) bracket realize 33% and 67% respective energy gains.
### Wireless Channel Variations
In this experiment, we assess how the performance gains of EnergyShield are affected given variations of the wireless channel conditions. Specifically, given potential changes in the channel throughput, \(\phi\), or the queuing delays, \(q\), we investigate to what extent do the energy savings offered by EnergyShield vary. Additionally, we examine for every set of experimental runs what percentage of their total elapsed time windows were extra transition windows needed to complete a single offloading instance, which we denote by the % _Extra Transit Windows_ metric. From here, we first analyze such effects when varying \(\sigma_{\phi}\in\{20,10,5\}\) Mbps given a fixed \(q=1\) ms, and then when varying \(q\in\{10,20,50\}\) ms given a fixed \(\sigma_{\phi}=10\) Mbps. For the uniform EnergyShield, we notice in Figure 8 that the % _Extra Transit Windows_ drops for the contrasting conditions of high throughput (\(\sigma_{\phi}=20\) Mbps) and high queuing delays (\(q=50\) ms), reaching medians of 7% and 8%, respectively. This can be justified in light of how the benign channel conditions (\(\sigma_{\phi}=20\) Mbps) indicate that the majority of offloading instances are concluded in a single time window with no considerable need for extra transmission windows. Whereas at unfavorable wireless conditions (\(q=50\) ms), \(\hat{\Delta}\) values often exceed \(\Delta_{max}\), leading EnergyShield to opt for local execution more often so as to avoid wireless uncertainty, lowering the total number of transmission windows alltogether. Such effects are also visible in the twin Figure 9 as EnergyShield's energy consumption varies across these contrasting conditions, reaching respective medians of 45% and 93% of the local execution energy at \(\sigma_{\phi}\)=20 and \(q\)=50.
### Generality
To assess the generality of EnergyShield, we train 3 additional RL controllers to evaluate how consistent EnergyShield is with regards to maintaining safety guarantees, and how the energy efficiency gains would vary given a distinctive driving behavior for each agent. Hence, we repeat the primary test runs for the additional controllers in which we average the energy consumption and TCR across 35 episodes of each viable (S, N) configuration. We also report the average center deviance (CD) experienced by the ego vehicle from the primary track lane as a metric to characterize the different driving behaviors of each controller. In our experimental test case, larger CD imply larger \(r\) values, that is, controllers with low values of CD tend to drive closer to the obstacles at higher risks of collisions (maximizing \(\mathcal{R}\) through minimizing CD), whereas larger values of CD indicate the agents have learnt to take the farther lanes of the track in order to maximize track completions through prioritizing collision avoidance (maximizing \(\mathcal{R}\) through maximizing TCR). In the following, we highlight the key findings and refer the reader to Table 1 in Appendix C for the detailed results.
Figure 8. Analyzing the % extra transit windows over 35 episodes of uniform EnergyShield given various \(\sigma_{\phi}\) and \(q\).
Figure 6. Top: Example trajectories followed by the ego vehicle with the start point at the top. Bottom: illustration of how the ego vehicle under the aforementioned operational modes behaved in reaction to the first encountered obstacle.
Figure 7. Normalized Energy Gains for the eager (_solid_) and uniform (_dashed_) EnergyShield modes with respect to the distance from obstacle (\(r\)) in m.
Figure 9. Analyzing the Normalized Energy cons. over 35 episodes of uniform EnergyShield given various \(\sigma_{\phi}\) and \(q\).
Our first key finding is that given S = 0, TCR (%) is dependent on CD ratings as only the controllers with CD \(>\) 5m consistently achieve the 100% TCR. At S = 1, however, this dependency no longer holds at S = 1 when the Controller Shield enforces the obstacle avoidance safety guarantees, pushing all controllers to achieve 100% TCR irrespective of CD values. The other interesting finding here is that across both modes of EnergyShield, the average energy consumption is less for controllers with larger CD ratings. For instance at (S = 1, N = 1), when the RL controllers are arranged in an increasing order of their CD values 2.8\(\rightarrow\)3.6\(\rightarrow\)5.4\(\rightarrow\)5.7 m, the average energy consumption per inference decreases in the respective order 53.1\(\rightarrow\)45.7\(\rightarrow\)42.1\(\rightarrow\)39.8 mJ. Indeed, this highlights EnergyShield's capability of conducting _safe_ and _effective_ context-aware offloading, especially given how the Runtime Safety Monitor provides large \(\Delta_{max}\) to realize more energy gains in the safer situations (e.g., larger distances from obstacles), and how the Controller Shield always maintains safety guarantees independent of offloading decisions.
|
2310.17646 | Learning the dynamics of a one-dimensional plasma model with graph
neural networks | We explore the possibility of fully replacing a plasma physics kinetic
simulator with a graph neural network-based simulator. We focus on this class
of surrogate models given the similarity between their message-passing update
mechanism and the traditional physics solver update, and the possibility of
enforcing known physical priors into the graph construction and update. We show
that our model learns the kinetic plasma dynamics of the one-dimensional plasma
model, a predecessor of contemporary kinetic plasma simulation codes, and
recovers a wide range of well-known kinetic plasma processes, including plasma
thermalization, electrostatic fluctuations about thermal equilibrium, and the
drag on a fast sheet and Landau damping. We compare the performance against the
original plasma model in terms of run-time, conservation laws, and temporal
evolution of key physical quantities. The limitations of the model are
presented and possible directions for higher-dimensional surrogate models for
kinetic plasmas are discussed. | Diogo D Carvalho, Diogo R Ferreira, Luis O Silva | 2023-10-26T17:58:12Z | http://arxiv.org/abs/2310.17646v3 | Do Graph Neural Networks Dream of Landau Damping? Insights from Kinetic Simulations of a Plasma Sheet Model
###### Abstract
We explore the possibility of fully replacing a plasma physics kinetic simulator with a graph neural network-based simulator. We focus on this class of surrogate models given the similarity between their message-passing update mechanism and the traditional physics solver update, and the possibility of enforcing known physical priors into the graph construction and update. We show that our model learns the kinetic plasma dynamics of the one-dimensional plasma model, a predecessor of contemporary kinetic plasma simulation codes, and recovers a wide range of well-known kinetic plasma processes, including plasma thermalization, electrostatic fluctuations about thermal equilibrium, and the drag on a fast sheet and Landau damping. We compare the performance against the original plasma model in terms of run-time, conservation laws, and temporal evolution of key physical quantities. The limitations of the model are presented and possible directions for higher-dimensional surrogate models for kinetic plasmas are discussed.
_Keywords: Plasma Physics, Machine Learning, Graph Neural Networks_
## 1 Introduction
Simulating the kinetic behavior of a plasma [1] is a complex and computationally demanding task. Fully relativistic massively-parallelized Particle-in-Cell (PIC) codes are commonly used to model these phenomena and have been shown to correctly recover and predict plasma collective behavior [2, 3, 4].
To obtain computational speed-ups, there have been recent attempts to combine existing PIC codes with machine learning surrogate models. These efforts include approaches to accelerate [5] or fully replace [6] the field solver block, or the integration of surrogate models into advanced physics extensions [7]. However, how to simultaneously obtain a significant computational gain, while enforcing known physics constraints is still an open research question.
Developments in machine learning introduced several physics-inspired surrogate models as an alternative to standard differential equation solvers [8, 9, 10, 11] and \(n\)-body or mesh-based simulators [12, 13, 14, 15, 16, 17].
From the broad set of available surrogate models, one class of algorithms that can be of particular interest for kinetic plasma simulations are graph neural network-based approaches [18, 19], because of their capability to model both particle-particle [12] and particle-mesh interactions [13], as well as the possibility of enforcing known invariances or symmetries into the network architecture [15, 16, 19]. These approaches have been successfully applied to fluid [12, 13], rigid body [13, 20], and charged particle dynamics [15, 16, 21]. However, to the best of our knowledge, their applicability to model kinetic plasma simulations is still to be demonstrated.
In this work we aim to model the predecessor of the PIC loop, the one-dimensional electrostatic sheet plasma model introduced by Dawson [22, 23]. This is an ideal initial testbench since it provides a simpler scenario, in terms of the problem structure and possible computational gains, while capturing a wide range of kinetic plasma physics phenomena, that go beyond "collisionless" physics, including Coulomb collisions, and collisional thermalization [22, 23, 24, 25, 26]. Moreover, recent studies in the fundamental statistical physics processes in plasmas have been using the sheet model and/or direct extensions [27]. We show how to leverage previous work on graph neural network-based simulators by Sanchez-Gonzalez et al. [12] to kinetic plasma simulations and to the one-dimensional sheet model by introducing domain knowledge into the graph construction and simulator update mechanisms which enforce the desired symmetries and invariances. We discuss the advantages and disadvantages of using our surrogate model when compared to the standard physics simulator in terms of accuracy, run-time, energy conservation, and generalization capabilities. Finally, based on our findings, we comment on the expected impact of graph neural network-based simulators for the multi-dimensional PIC scenario.
## 2 Electrostatic Sheet Model
The single-species one-dimensional electrostatic sheet model introduced by Dawson [22, 23] represents a plasma as a group of equally negatively charged sheets, moving freely over a uniformly neutralizing ion background (see figure 1). In a one-dimensional system, this model is exact and describes, within classical physics, the dynamics of an arbitrary non-relativistic plasma.
The system is in equilibrium if the sheets are at rest and equally spaced. In such a scenario, the electric field at a given sheet is zero, and the field profile is represented by a sawtooth function; it varies linearly along the x-axis by a factor of \(4\pi en_{0}\), where \(e\) represents the electron charge and \(n_{0}\) the background ion number density, and jumps by a factor of \(-4\pi en_{0}\delta\) at each sheet, where \(\delta=L/N_{sheets}\) represents the inter-sheet spacing at equilibrium, \(L\) the box length and \(N_{sheets}\) the number of sheets.
If one sheet moves a certain distance \(\xi\) from its equilibrium position, it will
experience an electric field \(E=4\pi en_{0}\xi\), resulting in an equation of motion given by:
\[\ddot{\xi}=-\omega_{p}^{2}\xi \tag{1}\]
where \(m_{e}\) represents the electron mass, and \(\omega_{p}=\sqrt{4\pi n_{0}e^{2}/m_{e}}\) is the plasma frequency. This result implies that, for small displacements, each sheet behaves as an independent harmonic oscillator.
For larger displacements, it is possible that consecutive sheets cross each other, corresponding to a one-dimensional Coulomb collision, meaning their equilibrium positions switch. Alternatively, this interaction can be modeled as an elastic collision, i.e. one can simply switch the velocities of the sheets at the instant of crossing (instead of their equilibrium positions) as it results from the conservation of energy and momentum. An illustration of the difference in the resulting individual trajectories is provided in figure 2.
To simulate this system, two computational directions can be used [23]: a synchronous method, and an asynchronous method. The synchronous method first updates the sheet dynamics according to (1) considering a fixed \(\Delta t\). It then detects crossings by testing the condition \(x_{i}^{t+1}>x_{j}^{t+1}\) for \(j>i\), and proceeds to use an iterative method to estimate the crossing times and correct the motion of the corresponding sheets. This method does not correctly resolve crossings involving more than two sheets in a single time step, which leads to an overall energy loss in the system if the time step is too large compared with the inverse of the typical collision frequency. For this reason, for higher sheet velocities it is necessary to use smaller simulation time steps (the collision frequency increases with increasing thermal velocity).
On the other hand, the asynchronous method advances the simulation until the next crossing. The next crossing time can be predicted analytically from (1) by solving for \(x_{i}(t)=x_{j}(t)\) with respect to \(t\) for all pairs of adjacent sheets. This algorithm guarantees energy conservation but implies additional computational effort since a sorted table containing all expected crossing times between neighboring sheets must be pre-computed and updated after each crossing is resolved.
Figure 1: Schematic of the 1D single species electrostatic sheet model. In equilibrium, the negatively charged sheets (red) are equally spaced inside the box. If one sheet is displaced from its equilibrium position, the average electric field the sheet feels is not zero, due to the charge imbalance. Adapted from Dawson [22].
Since the Graph Network Simulator (GNS) is a synchronous model, we use the synchronous sheet model algorithm (illustrated in figure 3) for both data generation and testing purposes to allow for model accuracy comparisons at equivalent simulation time steps.
## 3 Graph Network Simulator
The GNS architecture used here is inspired by the work of Sanchez-Gonzalez et al. [12] while taking into consideration the specifics of the electrostatic sheet model. The main building blocks are presented in figure 3.
Based on the sheet positions \(\mathbf{x}^{t}\), velocities \(\mathbf{v}^{t}\), equilibrium positions \(\mathbf{x}^{t}_{eq}\), and boundary conditions, we generate a graph representation \(\mathcal{G}\) of the plasma. A Graph Neural Network (GNN) predicts each individual sheet acceleration \(\mathbf{a}^{t}\), which will be used to update the positions \(\mathbf{x}^{t}\) and velocities \(\mathbf{v}^{t}\). We enforce the boundary conditions by
Figure 2: Comparison of charged sheet trajectories when considering sheet interactions as crossings (top) _versus_ binary collisions (bottom). The represented system consists of 10 sheets (represented by different colors) moving on a periodic box of length \(L\). Initial velocities were randomly chosen. We will learn to model the dynamics of the first case (crossings) as this is considerably easier, mainly due to the smoothness of the sheet trajectories. More details on the difficulties that arise when attempting to learn collisional dynamics are provided in Appendix A.
re-injecting particles that crossed the boundary, sorting the particles by their position, and updating their equilibrium positions. This process can be repeated to generate longer simulation rollouts.
Our GNS does not treat particle interaction as binary collisions. Instead, we learn to predict the changes in velocity as sheets move through one another. This choice makes it significantly easier for the network to learn the dynamics of the system and also reduces the graph and model complexity. We provide this comparison, as well as the structural changes required to the simulator when considering crossings as collisions, in A.
### Graph Representation
The plasma is represented as a graph by a set of nodes \(\{\mathbf{n}_{i}\}\) representing the negatively charged sheets, and a set of directed edges \(\{\mathbf{r}_{ij}\}\) which connect neighboring sheets. In our case, for simplicity and performance reasons we opted to connect only the first neighbors (additional comments on the impact of higher connectivity are provided throughout the paper). Each node vector \(\mathbf{n}_{i}\) contains the information relative to the corresponding negatively charged sheet, while each edge vector \(\mathbf{r}_{ij}\) contains information about the relative displacement of node \(i\) in relation to node \(j\). They are defined as:
\[\begin{split}\mathbf{n}_{i}^{t}&=\left[\xi_{i}^{t}, v_{i}^{t}\right]\\ \mathbf{r}_{ij}^{t}&=\left[x_{j}^{t}-x_{i}^{t}\right] \end{split} \tag{2}\]
where \(\xi_{i}^{t}\) corresponds to the displacement of the \(i\)th sheet from its equilibrium position \(\left(x_{i}^{t}-x_{eq_{i}}^{t}\right)\), and \(v_{i}^{t}\) the finite difference velocity \(\left(x_{i}^{t}-x_{i}^{t-1}\right)/\Delta t\). To allow the model to generalize to different box sizes and number of sheets, we normalize all distances and velocities by the intersheet distance at equilibrium \(\delta\). This transformation makes
Figure 3: Schematic representations of the synchronous Electrostatic Sheet Model algorithm [23] and the Graph Network Simulator used.
the inputs of the network invariant to the system size (box length and number of particles). This is also the reason why we include in the node vector the displacement from equilibrium instead of the sheet position inside the box, which additionally enforces an invariance to the sheet rank.
When considering reflecting boundary conditions, extra nodes representing mirrored versions of the boundary sheets are added to the graph (figure 4). Ideally, the number of mirror sheets should be large enough so that no boundary sheet crosses all mirror sheets in a single time step (in our case we set it to the number of message-passing steps, which we cover in Section 3.2). On the other hand, for periodic boundaries the graph becomes cyclic and we consider the distance between boundary sheets to be equal to the distance through the simulation box walls. In subsequent sections, we will show that representing boundaries in this way allows the GNN model to be applied to different boundary conditions than the ones it was trained on since it learns interactions between pairs of sheets (not interactions with the wall). However, this comes at the cost of an extra hard-coded step, that re-injects particles that crossed the boundary (procedure to be explained in more detail in later sections).
We experimented with several other possible representations of the system, (e.g. different boundary representations, node and edge parameters, connect \(n\)-nearest neighbors) but these variants either produced worse results (in terms of accuracy or generalization capabilities) or introduced extra complexity and memory requirements that did not result in meaningful accuracy and/or speed-up improvements for the tested scenarios.
### Graph Neural Network Architecture
The GNN module follows an encoder-processor-decoder architecture as introduced by Battaglia et al. [18]. A slight modification is used, which includes the sent edges in the node update mechanism of the processor block (equivalent to the Graph Network implementation available in Jraph [28]). The main building blocks are as follows:
**Encoder**: The encoder transforms each node \(\mathbf{n}_{i}\) and edge \(\mathbf{r}_{ij}\) vectors into a latent space node \(\mathbf{v}_{i}\) and edge \(\mathbf{e}_{ij}\) representation according to:
\[\mathbf{v}_{i}=\varepsilon^{v}\left(\mathbf{n}_{i}\right) \tag{3}\] \[\mathbf{e}_{ij}=\varepsilon^{e}\left(\mathbf{r}_{ij}\right)\]
Figure 4: Graph representation of a four-sheet system for different boundary conditions. The number of mirror sheets used for reflecting boundaries is not necessarily one, and, if necessary, can be larger than the number of sheets inside the box.
where \(\varepsilon^{v}\) and \(\varepsilon^{e}\) are learnable functions.
**Processor**: The processor consists of a series of \(M\) slightly modified Graph Network (GN) blocks [18, 28] which sequentially update the node and edge values according to:
\[\begin{split}\mathbf{e}_{ij}^{m+1}&=\phi^{e}\left( \mathbf{e}_{ij}^{m},\mathbf{v}_{i}^{m},\boldsymbol{\cdot}\mathbf{v}_{j}^{m} \right)\\ \overline{\mathbf{e}}_{r_{i}}^{m+1}&=\sum_{j\in \mathcal{N}(i)}\mathbf{e}_{ij}^{m+1}\\ \overline{\mathbf{e}}_{s_{i}}^{m+1}&=\sum_{j\in \mathcal{N}(i)}\mathbf{e}_{ji}^{m+1}\\ \mathbf{v}_{i}^{m+1}&=\phi^{v}\left(\overline{ \mathbf{e}}_{r_{i}}^{m+1},\overline{\mathbf{e}}_{s_{i}}^{m+1},\mathbf{v}_{i}^ {m}\right)\end{split} \tag{4}\]
where the superscript denotes the block number, \(\mathcal{N}(i)\) the set of nodes connected to \(i\), and \(\phi^{v}\), \(\phi^{e}\) are learnable functions. The value of \(M\) is set depending on the training time step and the maximum velocity of the particles present in the training simulations. Ideally, \(M\) should be larger than the maximum number of neighboring sheets that a given sheet crosses in any particular time step, since a graph node will at most receive/send information from/to the \(M^{\text{th}}\) neighbor. This condition can be relaxed if the \(N\)-nearest neighboring nodes are directly connected (with the cost of additional memory requirements), and we have observed similar performance in our tested scenarios for models with an equivalent \(M\times N\) factor. However, for higher crossing frequencies than the ones presented in this work, it might be preferable to increase \(N\) to avoid possible information bottlenecks [29].
**Decoder**: The decoder block transforms the latent node representations of the last layer into the output vector:
\[\mathbf{y}_{i}=\delta^{v}\left(\mathbf{v}_{i}^{M}\right) \tag{5}\]
where \(\delta^{v}\) is a learnable function. In our case, the output vector \(\mathbf{y}_{i}\) is a single real value that corresponds to an estimate of the individual finite difference particle acceleration \(a_{i}^{t}=(v^{t+1}-v^{t})/\Delta t=(x^{t+1}-2x^{t}-x^{t-1})/\Delta t\) normalized to the intersheet spacing \(\delta\).
We parameterize the encoder and decoder functions \((\varepsilon^{e},\varepsilon^{v},\delta^{v})\) as linear transformations. As for the processor functions \((\phi^{e},\phi^{v})\), they are given by a two-layer dense neural network following: Input \(\rightarrow\{\text{LinearLayer}()\rightarrow\text{ReLU}\rightarrow\text{ LinearLayer}()\}\)\(\rightarrow\) Output. In every block (encoder, processor, and decoder), we use a latent space of size 128. A summary of the hyper-parameter tuning experiments that led to these final values is provided in Appendix B.
Although this GNN architecture does not enforce equivariance with respect to reflections (a symmetry present in the sheet model, i.e. if the simulation box is flipped the absolute value of the predicted accelerations should simply switch signs), we observed that the network was nonetheless capable of correctly approximating this symmetry within the training data range. In fact, we developed an alternative architecture
that enforced this equivariance but did not observe relevant gains concerning the required number of training simulations nor improved rollout accuracy or energy conservation capabilities (in fact we observed a deterioration for considerable out-of-training data distribution values). Similarly, not using the sent messages for the node update mechanism led to poorer energy conservation for (considerably) out-of-training data distribution values. More details about these comparisons and the equivariant architecture are provided in C.
### Position and Velocity Update
To update the particle positions and velocities we use a semi-implicit first-order Euler integration scheme as follows:
\[\begin{split}\tilde{v}^{t+1}&=v^{t}+a^{t}\Delta t \\ \tilde{x}^{t+1}&=x^{t}+\tilde{v}^{t+1}\Delta t. \end{split} \tag{6}\]
After this update, we resolve the boundary crossings. When considering reflecting boundary conditions, we flip the position and velocity of the particles that left the simulation box. No change is applied to their equilibrium positions. When considering periodic boundaries, we instead re-insert the particles through the opposite boundary without changing their velocities. Additionally, the equilibrium positions are updated to take into consideration particles that crossed the boundaries (additional information is provided in D).
Finally, we sort particles by their position inside the box. This step is required to correctly attribute equilibrium positions and ensure the necessary relative ordering for graph construction.
## 4 Implementation
For reference, we implemented the synchronous version of the original electrostatic sheet model [22, 23] in Python, using NumPy [30]. This code is used to generate all ground truth training and test data at a high temporal resolution. The GNS was also implemented in Python using JAX [31], Jraph [28], and Haiku [32].
Additionally, from here onwards we will adopt a system of units similar to Dawson [22]. Time will be shown in units of the plasma period \(\omega_{p}^{-1}\) (with \(\omega_{p}\) as defined in (1)), distances will be presented in units of the intersheet spacing in equilibrium \(\delta\), resulting in velocities in units of \(\delta\!\cdot\!\omega_{p}\) and accelerations in units of \(\delta\!\cdot\!\omega_{p}^{2}\). Note that in the adopted units the Debye length \(\lambda_{D}\) is equivalent to the thermal velocity since, by definition, \(v_{th}=\lambda_{D}\omega_{p}\)[1], and the length of the simulation box \(L\) is equivalent to the number of sheets since \(L=N_{sheets}\delta\).
### Generating the ground truth data
Using the electrostatic sheet model, we generate 10,000 simulations of systems consisting of 10 sheets moving inside a periodic box. All simulations are run for a duration of \(t_{max}=10\ \omega_{p}^{-1}\) using a time step of \(\Delta t_{sim}=10^{-4}\ \omega_{p}^{-1}\). The initial displacements from the equilibrium positions and velocities of the sheets are randomly sampled from uniform distributions. The maximum initial displacement equals \(\xi_{max}^{0}=0.2\ \delta\) and the maximum initial velocity is \(v_{max}^{0}=10\ \delta\!\cdot\!\omega_{p}\). In addition, we ensured that the total energy of the system did not vary more than a predefined threshold (\(\Delta\varepsilon/\varepsilon_{0}\!=\!10^{-6}\)) during the full simulation by discarding simulations that did not fulfill this criterion. This guarantees that all crossings are well resolved by the sheet model.
### Data preprocessing and augmentation
Before training the GNN models, we apply the following preprocessing steps. First, we downsample the data to the desired training time step (e.g. \(\Delta t_{train}=10^{-2}\ \omega_{p}^{-1}\)). To take advantage of the system symmetries, we proceed to augment the training dataset by mirroring the simulations along the x and time axis (the latter is not equivalent to simply changing the sign of the velocities since we are using the finite difference velocity). We proceed to generate pairs of input graphs and output target accelerations, where each input graph corresponds to a full simulation rollout (and corresponding augmented versions). More details on the impact of the impact of the training dataset size and data augmentation are provided in Appendix E.
### Training
To train the models, we hold out 100 simulations for validation purposes. We proceed to minimize the mean squared error between the predicted and target accelerations using the Adam optimizer. We use an exponential learning rate scheduler, similarly to Sanchez-Gonzalez et al. [12], for which \(\alpha(j)=\alpha_{final}+(\alpha_{start}-\alpha_{final})\cdot 0.1^{j\cdot 10^{6}}\), where \(j\) represents the gradient update step, and the initial and final learning rates are given by \(\alpha_{start}=10^{-4}\) and \(\alpha_{final}=10^{-6}\). We set the batch size to 1 (one graph corresponds to a full simulation) and compute the validation loss on the full validation set once a full cycle over the training dataset is completed. The training procedure is then run to a maximum of \(1\times 10^{6}\) gradient updates for \(\Delta t_{train}=10^{-1}\ \omega_{p}^{-1}\), and \(1.5\times 10^{6}\) gradient updates for \(\Delta t_{train}=10^{-2}\ \omega_{p}^{-1}\). The final weights of the model are those obtained for the smallest recorded validation loss. The full training procedure lasts approximately 4 hours for \(\Delta t_{train}=10^{-1}\ \omega_{p}^{-1}\) and \(M=5\), and 1 day for \(\Delta t_{train}=10^{-2}\ \omega_{p}^{-1}\) and \(M=3\), using a single Nvidia Titan X GPU. For each value of \(\Delta t_{train}\) we train 5 equivalent models using different random seeds in order to assess the dependence of performance on weight initialization.
## 5 Model Benchmark
In this section, we assess the capability of the GNS to predict individual sheet trajectories. We showcase the generalization capabilities already hinted at in Section 3.1 by evaluating the model accuracy for systems of different sizes and boundary conditions. Additionally, we compare its energy conservation capabilities and run-time against the Sheet Model (SM) and discuss the identified GNS limitations.
### Trajectory Prediction Error
In order to benchmark the rollout accuracy and generalization capabilities of the GNS, we evaluate its accuracy on multiple test sets consisting of systems with different numbers of sheets and boundary conditions. Each test set contains 100 simulations with a similar duration, temporal resolution, maximum initial displacement and velocity as the ones present in the training set. Our evaluation metrics are the rollout mean absolute error (MAE) and the earth mover's distance (EMD) [33] between the predicted and the ground truth sheet trajectories, calculated, for each time step, as
\[\begin{split}\text{MAE}=&\ \frac{1}{N}\sum_{i} \left|x_{i}^{GNS}-x_{i}^{True}\right|\\ \text{EMD}=&\ \min\frac{1}{N}\sum_{i}^{N}\sum_{j}^{N} \left|x_{i}^{GNS}-x_{j}^{True}\right|\cdot c_{ij},\\ &\ \text{subject to}\ \sum_{i}c_{ij}=1\,\ \sum_{j}c_{ij}=1\,\ \text{and}\ c_{ij}\in\{0,1\}\end{split} \tag{7}\]
and then average over the full simulation rollout. In the case of periodic boundaries, we modify both metrics to consider the absolute distance to be the minimum of the distances through the box or through the walls.
The results presented in figure 5 allow us to draw some conclusions. We observe the rollout errors obtained are considerably small (note that they are presented in units of the intersheet spacing \(\delta\)) demonstrating that, despite training solely on single-step acceleration prediction, we achieve a stable rollout accuracy. To provide additional insight into the small scale of the errors, we showcase in figure 6 the worst test simulation rollouts (highest rollout EMD across all models) for different time steps and boundary conditions.
We also observe the simulator accuracy is independent of the number of sheets and boundary conditions, without additional re-training/fine-tuning. These invariances, already hinted at in Section 3.1, are a direct consequence of the chosen graph representation of the system.
Finally, figure 5 illustrates the importance of using both the MAE and the EMD as complementary evaluation metrics. The larger intervals associated with the MAE are produced by a small set of simulations where, due to the accumulation of small prediction errors, two particles switch their expected relative order during a tangential
crossing (i.e. when they are moving in the same direction with very similar velocities). This results in a permutation of their predicted trajectories with respect to their ground truth, leading to larger MAE values (see for example figure 6 for reflecting boundary, around \(t=2\)\(\omega_{p}^{-1}\) the orange and dark blue trajectories permute after reflection). The reason why the error intervals decrease significantly for the EMD case is because this metric is invariant to permutations of sheet trajectories. This invariance (which the MAE does not provide) is an important property for our case study since a simple permutation of sheet trajectories does not change the distribution function of the system (i.e. the systems are equivalent). Therefore, the EMD provides a better assessment of the accuracy of the simulator to model the collective plasma dynamics.
We observed that, overall, equivalent models trained with different random seeds converge to very similar rollout errors (detailed comparisons provided in F). The only exception was one of the models trained for \(\Delta t=10^{-2}\)\(\omega_{p}^{-1}\) which revealed a slightly worse rollout performance. We attribute this larger error to its worse single-step prediction capabilities given the validation loss at train time was approximately \(2\times\) that of equivalent models.
Figure 5: Rollout error metrics for the GNS in the test set simulations. For each value of \(\Delta t\) we compute the metrics for 5 equivalent GNNs trained using different random seeds. The presented mean values are computed by averaging over sheets, time steps, simulations, and GNN models (for a detailed comparison between different models see F). The error bars represent the minimum and maximum rollout error achieved for the corresponding set of test simulations across all models. The results demonstrate that even though the training data contains solely systems consisting of 10 sheets moving over a periodic box, the GNS is capable of generalizing to smaller/larger system sizes and different boundary conditions. Furthermore, the reported errors are considerably small.
Figure 6: Example of simulation rollouts observed for test simulations of 10 sheet systems. These examples correspond to the worst-performing rollouts (largest EMD across all models) for the indicated simulator time step and boundary conditions. The predicted and ground truth trajectories and the MAE/EMD evolution are shown (per time step average over sheets). In both cases, the ground truth trajectories (obtained with the Sheet Model using \(\Delta t=10^{-4}\)\(\omega_{p}^{-1}\)) are downsampled to the same simulation time step as the GNS. We plot the ground truth trajectories with a larger marker size in order to be possible to distinguish them with respect to the prediction. It is clear that the GNS is capable of correctly modeling the sheet trajectories for longer rollouts, even though it was solely trained on single-step prediction.
### Energy Conservation
In order to check for energy conservation, we run simulations using two types of initial velocity distributions: thermal - velocities sampled from a normal distribution with standard deviation equal to \(v_{th}\); oscillation - sheets share the same initial velocity \(v_{0}\) (no crossings should occur). For both initial conditions, we perform a scan over the initial thermal/oscillating velocity (one simulation per value). All simulations consider a system of \(10^{3}\) sheets moving over a periodic box for a total of \(t_{max}=5\times 2\pi\)\(\omega_{p}^{-1}\).
While for the sheet model the energy decreases monotonically, we observed this was not the case for the GNS (energy might increase, decrease, or oscillate, examples are provided in F). Furthermore, since the GNS uses the finite difference velocities instead of the instantaneous velocities, there is an oscillation associated with the plasma period (the period is equal to half a plasma period) which is clearly dominant for lower thermal velocities. This oscillation is merely an artifact of the finite different velocities used to compute the energy of the system.
To allow for a fair comparison between the sheet model and GNS we then compute the total energy variation as follows: we skip the first plasma oscillation, apply a moving average with a window size of \(\Delta t=2\pi\)\(\omega_{p}^{-1}\) to the remaining datapoints and retrieve the maximum deviation from the initial energy of the system (all steps are further justified in F). For each time step the energy of the system \(\epsilon\) is computed according to:
\[\epsilon=\frac{1}{2}m_{e}\sum_{i}^{N}\left(v_{i}^{2}+\omega_{p}^{2}\xi_{i}^{2 }\right). \tag{8}\]
The final results containing scans performed for different initial velocities distributions and simulation time steps are presented in figure 7. It is observed that as the initial thermal velocity increases, the GNS showcases a gain of one or two orders of magnitude in terms of energy conservation when compared to the Sheet Model (SM) algorithm running at a similar time step. This happens since the GNS captures more accurately crossings involving \(n>2\) sheets.
The accuracy of the GNS models remains approximately constant for the thermal velocities for which it was trained (\(v_{th}\leq v_{th}^{train}\)). However, for out-of-distribution scenarios the energy variation starts increasing, more noticeable for \(\Delta t=10^{-2}\)\(\omega_{p}^{-1}\). This behavior is not visible for the oscillatory initial conditions, where we observe a very stable energy loss rate across all models for \(v_{0}\leq v_{max}^{train}\). Therefore, the lower performance for higher \(v_{th}\) should be attributed to a failure in correctly modeling all crossing events in such conditions.
A performance degradation is expected since: a) the number of message-passing steps associated with each model (\(M=3\) for \(\Delta t=10^{-2}\)\(\omega_{p}^{-1}\), \(M=5\) for \(\Delta t=10^{-1}\)\(\omega_{p}^{-1}\)) limits the GNS capability to correctly resolve crossings involving a larger number of sheets (which are more likely to occur at larger values of \(v_{th}\)); b) the GNN is only trained on crossings involving \(n\leq n_{max}\), where \(n_{max}\) is the maximum number of sheets involved in any crossing within the training data. However, this does not explain why
outside the training data the performance of the GNS at different time resolutions is equivalent. We attribute this behavior to three main effects.
Firstly, there is one particular GNN model that consistently performed worse across all metrics (validation loss, rollout accuracy, and energy conservation) which biased significantly the average value of the energy variation rate. Removing this model from the average calculation changes considerably the behavior for \(v_{th}^{train}<v_{th}<v_{train}^{max}\) (more details in Appendix F).
Secondly, the percentage of training data points containing crossings at higher temporal resolution is, at least, \(10\times\) smaller than that of the lower resolution scenario. This can bias the training procedure to reduce the prediction error for events that do not involve crossings to the detriment of the (smaller) subset that contains crossings (which becomes problematic at test time for scenarios where crossings dominate the overall dynamics). Additional support for this claim is the fact that the higher temporal resolution models seem to be "overfitting" the purely oscillatory dynamics within the training data range since they fail to generalize to larger oscillation amplitudes (note the steep increase in energy variation for the oscillating initial conditions for \(v_{0}>v_{max}^{train}\)).
Finally, since we are performing an increased number of updates for the same time
Figure 7: Energy variation rate for simulations of \(10^{3}\) sheets moving over a periodic box for \(t_{max}=5\times 2\pi\)\(\omega_{p}^{-1}\). Initial sheet velocities are sampled from a normal distribution (thermal), or all equal to \(v_{0}\) (oscillation). For the Sheet Model (SM) we run a single simulation per set of initial conditions and simulation time step \(\Delta t\). For the GNS we run, per trained \(\Delta t\), the exact same simulations using 5 equivalent GNN models (trained with different random seeds). The mean values across GNN models are presented in full line, and the min/max values are represented by the shaded region (for a detailed comparison between different seeds see Appendix F). No lines are shown for the SM in the oscillation regime since it conserves perfectly the energy when no crossings occur. For dynamics that involve sheet crossings, the GNS either performs significantly better or is on pair with the SM running at an equivalent simulation step.
interval, the prediction errors for the out-of-distribution data might be accumulating faster. The impact of the aforementioned effects could be investigated in future work (and mitigated if necessary) by using alternative data sampling strategies and/or optimizing for multi-step accuracy at train time [17]. However, the main focus should be the improvement of the performance for lower temporal resolutions since this is where larger computational gains are expected.
It would also be important to study, in future work, why some models are capable of achieving better energy conservation capabilities at larger \(v_{th}\) (which might indicate that they learn a more robust crossing resolution algorithm) and how to consistently achieve this level of performance (e.g. by using a regularizing penalty [21]). Additional evaluation metrics/tests should also be devised since neither the validation loss nor the current rollout accuracy tests seem to be good predictors for improved energy conservation capabilities. These new tests could include, for instance, measurements of rollout accuracy for significantly longer simulations and higher thermal velocities.
### Run-time
Using the same setup for thermal initial conditions, we analyzed the run-time of the sheet model _versus_ the GNS. The results obtained are presented in figure 8. It is clear that the sheet model run-time increases with the crossing frequency, while the GNS does not. This difference in behavior coupled with the gain in energy conservation at higher thermal velocities makes a stronger case for the suitability of the GNS when modeling these scenarios. For example, when considering \(v_{th}=10\ \delta\omega_{p}\ (\lambda_{D}=10\ \delta)\), the GNS using \(\Delta t=10^{-1}\ \omega_{p}^{-1}\) obtains an order of magnitude improvement in both energy conservation and run-time when compared to the sheet model using \(\Delta t=10^{-2}\ \omega_{p}^{-1}\).
However, it is important to highlight that the different models are implemented with different packages (NumPy _vs_ JAX) and running on different hardware (CPU _vs_ GPU) which influences their respective run-time. Furthermore, we make no claims that our implementations are optimal, meaning they could both benefit from further speed-ups. Nonetheless, the qualitatively different behaviour of both algorithms, coupled with differences in accuracy of orders of magnitude on both energy conservation and run-time, leads us to believe that there is a computational gain to be expected in using the GNS for larger simulation steps with higher crossing rates.
### Limitations
The main limitations that we identified for the GNS are the requirement to use a fixed simulation step (equal to the training simulation step) and the performance degradation on out-of-training data distribution scenarios (as demonstrated in figure 7).
The first constraint is solely due to the fact that the network has to learn to predict sheet crossings, which implicitly forces it to know what is the simulation step. If one wishes to train a single model for different simulation steps, it would be necessary to provide \(\Delta t\) as an input to the network (in the GNS the time step only appears
explicitly in the ODE integrator). Alternatively, as we have shown, different models can be trained, one per \(\Delta t\). As long as enough training data is provided and the model architecture is scaled accordingly (e.g. by increasing the number of message passing steps for larger \(\Delta t\) or connecting the \(n^{\text{th}}\)-closest neighbors) there is no limitation on the time step which can be used to train the model.
Regarding the second constraint, note that the GNS still performs better than the sheet model at equivalent simulation steps for out-of-training distribution \(v_{th}\) values. Additionally, high-fidelity simulations for larger values of \(v_{th}\) can be generated in order to fine-tune or retrain models for a broader dynamic range.
## 6 Recovering Known Kinetic Plasma Processes
In order to provide stronger evidence of the GNS generalization capabilities, we now showcase a broad range of known kinetic plasma processes that the simulator is able to recover. These examples, present in both the original sheet model benchmarks [22, 23, 24, 25, 26] and other kinetic codes benchmarks [2, 3, 27, 34], aim to demonstrate the capability of the GNS to simulate collective behavior in accordance with known kinetic theory. An important point to stress is that the surrogate simulator was not explicitly trained to
Figure 8: Run-time of the Sheet Model (SM) _vs._ the GNS for systems of \(10^{3}\) sheets moving on a periodic box over the period of a single plasma oscillation (\(t_{max}=2\pi\ \omega_{p}^{-1}\)). Values shown are averages over 5 simulations. For a fairer comparison among different time resolutions, the rollout data is only saved to a buffer every \(\Delta t=10^{-1}\ \omega_{p}^{-1}\). The just-in-time compilation time for the GNS is not included since it is a fixed cost that does not change for longer simulations (where it is considerably diluted). It amounts to \(t_{JIT}=1.2\) s for \(\Delta t_{GNS}=10^{-2}\ \omega_{p}^{-1}\) and \(t_{JIT}=2.3\) s for \(\Delta t_{GNS}=10^{-1}\ \omega_{p}^{-1}\). The results demonstrate that the SM run-time increases with \(v_{th}\) (higher number of crossings) while the GNS run-time is constant. By comparing these results with those of figure 7 it is observed that the GNS is faster than the SM at equivalent energy variation rates.
reproduce these effects. The GNN only learned to (correctly) model single-step updates over a reduced system size (10 sheets). However, when we apply it to larger system sizes and longer time durations, we observe the emergence of the expected kinetic collective plasma dynamics.
The results presented hereafter are produced using the GNN trained for \(\Delta t=10^{-1}\)\(\omega_{p}^{-1}\) which showcased the best energy conservation capabilities (Model #4 in Appendix F). The same collective plasma dynamics are recovered for the equivalent GNN models trained using different random seeds, and those trained using the larger time step \(\Delta t=10^{-2}\)\(\omega_{p}^{-1}\).
### Plasma Thermalization
In [22, 25], Dawson demonstrated that, independently of the initial velocity distribution of the sheets, it is expected that over time the system will move towards thermal equilibrium, and that this happens due to crossings/collisions involving more than 2 sheets [25] (cf. Section 2 for a discussion on the physics of \(n=2\) crossing/elastic collisions and why they do not modify the distribution function). The distribution function of the sheet velocities is expected to converge to a normal distribution whose standard deviation corresponds to the thermal velocity of the plasma.
We demonstrate this behavior by performing 50 simulations of systems consisting of \(10^{3}\) sheets with initial velocities randomly sampled from a uniform distribution (\(v\ \in\ [-5,5]\ \delta\cdot\omega_{p}\)). We provide snapshots of the evolution of the distribution function (averaged over simulations) in figure 9.
It is clear that the system does indeed thermalize, and that the measured thermal velocity \(v_{th}=2.671\ \delta\cdot\omega_{p}\) is in accordance with the expected value \(v_{th}=2.679\ \delta\cdot\omega_{p}\). The latter is computed according to \(v_{th}^{2}=1/3\ v_{max}^{2}r_{kin}\)[23], where \(v_{max}\) corresponds to the initial uniform distribution maximum value, and \(r_{kin}\) represents the ratio of the available kinetic energy with respect to the total energy of the system (estimated by averaging over time steps and simulations) since a percentage of the initial kinetic energy is deposited in the fields.
Additionally, using a diagnostic similar to the one introduced by Liang et al. [35], figure 9 demonstrates that there is a steep increase in the entropy (\(S\)) of the system until \(t\approx 1.25\ \omega_{p}^{-1}\). This increase is associated with the establishment of correlations between sheets as crossings start to occur, and the length of this time interval is actually independent of the initial velocity range [25].
### Debye Shielding
Another fundamental property of plasmas is their quasi-neutrality [1], i.e. on a macroscopic scale the overall charge density of positive and negative particles will cancel out. However, within local regions of characteristic length \(\lambda_{D}=v_{th}/\omega_{p}\) (referred to as the Debye length) the local electric fields generated by a charged particle will not be fully screened by the oppositely charged particles. We expect to observe the same behavior
Figure 9: Evolution of the velocity and displacement from the equilibrium position density functions, and the entropy (\(S\)) of the system. Histograms represent the density function ensemble averaged over 50 simulations at the corresponding time. The entropy variation of the different phase-space components (\(\xi\), \(v\)) is obtained using a diagnostic similar to the one implemented by Liang et al. [35]. For the calculation of the distribution functions, we discretized the (\(\xi\), \(v\)) phase-space for the range \(\xi\in[-6.5,6.5]\,\,\delta\) and \(v\in[-12.6,12.6]\,\,\delta\cdot\omega_{p}\) using 51 bins along each axis. These results demonstrate that the GNS is capable of correctly modeling the process of plasma thermalization from a non-equilibrium state, with the thermal velocity of the system in equilibrium \(v_{th}=2.671\,\,\delta\cdot\omega_{p}\) (measured by fitting a Gaussian to the final distribution) in excellent agreement with the theoretical prediction \(v_{th}=2.679\,\,\delta\cdot\omega_{p}\).
for the sheet model. More precisely, the density of sheets at a certain distance from a test position is expected to follow [22]:
\[n(x)=n_{0}\left(1-\frac{\delta}{2\lambda_{D}}e^{-|x|/\lambda_{D}}\right). \tag{9}\]
To test the GNS, we initialize systems of \(10^{4}\) sheets following different initial thermal distributions (\(v_{th}=[1.5,\ 2.5,\ 5.0]\ \delta\cdot\omega_{p}\)). The simulations are run for \(t_{max}=80\tau_{relax}\), where \(\tau_{relax}=\sqrt{2\pi}\lambda_{D}/\delta\ \omega_{P}^{-1}\) is an estimate of the relaxation time of the system [22], i.e. the time it takes for the system to forget its current state.
To compute the sheet density profiles shown in figure 10, we follow a similar procedure as Dawson [22]. We choose a set of equally spaced test sheets and, for each of them, measure the number of neighboring sheets within a pre-defined range of increasing distances. In our case, we compute the number of sheets within a distance \(d\in\,]0.2i,0.2(i+1)]\lambda_{D}\) up to \(3\lambda_{D}\) (\(i=15\)). We repeat this procedure for every \((3\lambda_{D}/\delta)\)-th sheet, over multiple independent time steps (\(t_{j}=j\cdot\tau_{relax}\) for \(j>0\)). The counts are then averaged over the number of test sheets, and time steps.
It is clear from the results presented in figure 10, that the expected behavior is recovered.
### Electrostatic fluctuations
Although the plasma is in thermal equilibrium, there are constant exchanges of energy between the sheets and the (electrostatic) waves propagating inside the plasma. This leads to the appearance of electrostatic fluctuations, with an average power spectrum that follows [2]:
\[\frac{\langle E^{2}(k)\rangle}{8\pi}\ =\frac{k_{B}T}{2L\left(1+k^{2}\lambda_{D}^ {2}\right)} \tag{10}\]
Figure 10: Example of Debye shielding for systems with different Debye lengths. The GNS can correctly recover the expected density profiles for all the tested scenarios.
where \(k\) represents the wave vector, \(k_{B}\) the Boltzmann constant, \(T\) the plasma temperature (\(k_{B}T=mv_{th}^{2}\)), and \(\langle\cdot\rangle\) the time average.
In figure 11 we recover this spectrum for a system of \(10^{3}\) sheets with \(\lambda_{D}=5\ \delta\). We make use of the ergodic theorem [36] to compute the statistical average of the power spectrum by averaging over independent time steps (separated by \(\Delta t=\tau_{relax}\)).
### Drag on a Fast Sheet
A fast sheet (\(v_{sheet}\gg v_{th}\)) moving through the plasma is expected to feel a constant drag given by [22]:
\[\frac{dv}{dt}=-\frac{\omega_{p}^{2}\delta}{2}. \tag{11}\]
This drag is independent of the velocity of the sheet and is caused by the excitation of a electrostatic wake on the rear of the fast sheet, i.e. the sheet transfers energy to the electrostatic wake.
In figure 12 we demonstrate this behavior. The results were obtained by performing simulations of periodic systems of 100 sheets with \(\lambda_{D}=5\ \delta\) (\(v_{th}=5\ \delta\cdot\omega_{p}\)) over a period of \(t_{max}=5\ \omega_{p}^{-1}\). For each simulation, we set the initial velocity of the first sheet to \(v_{0}=\pm\alpha v_{th}\) and track its evolution over time. We then average over simulations, 1000 for each initial sheet velocity (accounting for the sign change).
Figure 11: Electric field power spectrum for a system in thermal equilibrium. The power spectrum for the last time step and the temporal average (computed over relaxation periods \(\Delta t=\tau_{relax}\approx 13\ \omega_{p}^{-1}\)) are shown. The time-averaged power spectrum retrieved from the GNS simulation matches the theoretical curve, thus demonstrating that it correctly models the electrostatic fluctuations around thermal equilibrium.
### Landau Damping
While fast sheets are able to excite an electrostatic wake in their rear, the resulting electrostatic wake can also accelerate sheets moving slightly slower than its phase velocity [1, 22]. Electrostatic modes are therefore self-consistently generated by particles moving close to its phase velocity, while being damped by particles moving slightly slower. However, since a plasma in thermal equilibrium follows a Maxwellian distribution in velocity space, there exist on average more particles moving faster than the wave, than those moving slower. Therefore, on average, the modes will be damped. This mechanism is known as Landau damping [1] and is an inherently collisionless kinetic process that the sheet model has been shown to recover [22].
For a given mode \(m\), with a wavelength \(\lambda_{m}=2L/m\) and wave vector \(k_{m}=2\pi/\lambda_{m}\), we can compute its wave frequency and damping time by finding numerically the roots of the dispersion relation for \(k=k_{m}\)[37]:
\[1=\frac{\omega_{p}^{2}}{k^{2}}\int_{-\infty}^{\infty}\frac{\partial\hat{f}_{0} /\partial v}{v-(\omega/k)}dv \tag{12}\]
where \(\hat{f}_{0}\) corresponds to the distribution function in velocity space. The solution will have both a real and imaginary part. The real part corresponds to the wave angular frequency, while the imaginary part corresponds to the inverse of the damping time.
To reproduce the expected damping behavior we follow a similar procedure to that of Dawson [22]. We produce 50 simulations, each with a duration of \(t_{max}=500\)\(\omega_{p}^{-1}\), of thermal plasmas consisting of \(10^{3}\) sheets for \(\lambda_{D}=5\)\(\delta\) and reflecting boundaries. For each simulation time step we compute the mode "amplitude" \(A_{m}\) and its rate of change
Figure 12: Average drag on fast sheets of different initial velocities (\(v_{0}\gg v_{th}=5\)\(\delta\) \(\cdot\)\(\omega_{p}\)). The GNS recovers the expected drag felt by the fast sheets independently of their initial velocity and propagation direction.
\(\dot{A}_{m}\) using the cross-correlation:
\[\begin{split} A_{m}^{t}&=\frac{2}{N}\sum_{i=0}^{N-1} \left(x_{i}^{t}-x_{eq_{i}}^{t}\right)\ \sin\left(\frac{m\pi}{N}\left(i+\frac{1}{2}\right)\right)\\ \dot{A}_{m}^{t}&=\frac{A_{m}^{t}-A_{m}^{t-1}}{\Delta t }\end{split} \tag{13}\]
where the index \(i\) indicates the relative ordering of the sheets in the box.
We then collect trajectories of equal time length every time the mode crosses the region of phase-space \((A_{m},\dot{A}_{m})\) defined by a ring of radius \(R\) and thickness \(dR\) (\(dR\ll R\)). Finally, we rotate the trajectories so that they all start on the same position in phase-space, and compute their average.
In figure 13 we showcase the results obtained for several modes. It is possible to see that, although for some trajectories the mode is still growing, on average it decreases according to the expected damping time. This demonstrates that the GNS is capable of correctly modeling Landau damping, an inherently kinetic mechanism associated with the collective collisionless dynamics of a plasma.
### Two-stream Instability
As a final example, we show the two-stream instability in the cold beam regime [1, 24]. For this scenario, two counter-propagating beams with velocities \(\pm v_{0}\) and no energy spread excite a wave that grows exponentially until all particles are trapped inside the electric field, at which point the instability saturates.
Figure 13: Damping of different modes. The initial mode amplitudes are normalized to \(R=0.3\ \delta\). Individual trajectories length is \(\Delta t_{traj}=50\ \omega_{p}^{-1}\). Damping times are respectively \(\tau_{28}=10.25\ \omega_{p}^{-1}\), \(\tau_{30}=7.97\ \omega_{p}^{-1}\), and \(\tau_{32}=6.41\ \omega_{p}^{-1}\). The agreement between the theoretical curves and the average mode trajectories demonstrates that the GNS is capable of correctly modeling Landau damping, an inherently kinetic mechanism.
From linear theory [1, 24], we expect that for two-cold beams with density \(n_{beams}=n_{0}/2\), the fastest growing mode will correspond to \(k=\sqrt{3/8}\cdot\omega_{p}/v_{0}\) with a corresponding growth rate of \(\gamma=\omega_{p}/\sqrt{8}\). Therefore, to excite mode \(m\) we need to set \(v_{0_{m}}=\sqrt{3/8}\cdot\omega_{p}\delta/m\pi\cdot N_{sheets}\). Furthermore, the number of sheets per wavelength of this mode is given by \(N_{\lambda_{m}}=\lambda_{m}/\delta=2/m\cdot N_{sheets}\). Note that both \(v_{0_{m}}\) and \(N_{\lambda_{m}}\) are proportional to the number of sheets used. Therefore, to excite a mode whose wavelength can be resolved by a significant amount of sheets, we need to increase \(v_{0}\) proportionally.
For a system of \(10^{4}\) sheets and \(m=4\), we obtain \(v_{0_{m}}=486\)\(\delta\cdot\omega_{p}\) and \(N_{\lambda_{m}}=5\times 10^{3}\). The chosen velocity is considerably out of the training data range, therefore we expect the energy loss of the GNS to be slightly higher than the one observed for the training scenarios (as shown in figure 7). Nonetheless, we will see that the GNS is still able to capture the macrophysics. Additionally, these (significantly) out-of-training distribution values allow us to once again highlight the potential of the GNS to achieve better energy conservation than the sheet model algorithm at comparable simulation time steps.
In figure 14 we provide a comparison between the evolution of the phase-space and the potential energy for the sheet model at high (\(\Delta t=10^{-3}\)\(\omega_{p}^{-1}\)) and low (\(\Delta t=10^{-1}\)\(\omega_{p}^{-1}\)) temporal resolution and the GNS at the same low temporal resolution. The energy variation during the full simulation was approximately 0.1% for the sheet model at \(\Delta t=10^{-3}\)\(\omega_{p}^{-1}\) and 73% at \(\Delta t=10^{-1}\)\(\omega_{p}^{-1}\), while for the GNS it was approximately 2%. These values are in accordance with what was measured in figure 7.
It is observed that the GNS recovers similar macrophysics when compared to the higher temporal resolution simulation (which we consider as a good approximation of the ground truth) during the linear phase and up to the saturation time. An extra diffusion in phase-space is observed for the GNS, which is associated with the aforementioned higher energy variation. This is expected since the GNN is not capable of correctly resolving crossings involving more than \(2M+1=11\) sheets, and, on average, a sheet moving with \(v_{0_{m}}=486\)\(\delta\cdot\omega_{p}\) should cross \(\approx 49\) neighbors just in the first timestep (since when the simulation starts all sheets are equally spaced by \(\delta\) and, on average, half of the nearest neighbors are counter-propagating with the same absolute velocity). Nonetheless, the overall phase-space structure and growth rates are similar, which provides further support for the generalization capabilities of the model. Additionally, when using the sheet model at a comparable time resolution the results are strikingly different, which reinforces the conclusions derived in Section 5.2 that the GNS is capable of significantly improving simulation results at larger time steps.
Finally, we provide in Appendix G further comparisons for higher order modes (lower \(v_{0_{m}}\)), larger simulation steps (\(\Delta t=10^{-2}\)\(\omega_{p}^{-1}\)), as well as results for the remaining GNNs trained with different seeds (with worse energy conservation capabilities at high \(v_{th}\)). These results further support the claim that the GNS is consistently able to correctly model the overall dynamics of the instability.
## 7 Conclusions
In this work, we demonstrated that graph neural network-based simulators are capable of fully replacing a one dimensional kinetic plasma physics simulator. By introducing domain knowledge into the graph representation and the overall structure of the simulator, we showed that the GNS is capable of generalizing to a broad range of scenarios and is limited only by its training data distribution and a fixed simulation step. Furthermore, we showed that the GNS, when trained on high-fidelity data, conserves energy better than the synchronous algorithm of the sheet model, for larger simulation steps.
In future work, the accuracy of the simulator for higher thermal velocity values
Figure 14: Comparison of the phase-space and potential energy evolution for the Sheet Model (SM) and the GNS in the two counter-propagating cold beams scenario. The GNS is able to recover the same macrophysics as the sheet model at a significantly higher temporal resolution and conserves the system energy significantly better than the SM at an equivalent time resolution.
can be improved by generating additional ground truth data, ideally using the asynchronous version of the sheet model, which is guaranteed to perfectly resolve crossings. Additionally, although not explored, the developed simulator is fully differentiable, which opens the way to explore gradient-based optimization strategies for the discovery of new physics of interest [38].
This work also indicates that it would be possible to accurately model the standard PIC loop. However, we do not believe that this would result in meaningful computational gains since the standard PIC loop implemented in modern architectures is extremely optimized and does not suffer from the issues that are present in the sheet model scenario (e.g. time-consuming serial routines). The usage of graph neural networks can be relevant to model multi-scale plasma dynamics or extra physics modules. This will be explored in future publications.
## Data availability statement
The code used for this project is made available through a git repository: (to be disclosed). The training and test data, as well as a set of the final model weights are available in a zenodo repository: (to be disclosed)
## Conflict of interest
The authors declare no conflict of interest.
## Acknowledgments
The authors would like to thank P. J. Bilbao, T. Grismayer, A. Joglekar, and E. P. Alves for helpful discussions. This work was supported by the FCT (Portugal) under the Project No 2022.02230.PTDC (X-MASER) and PhD Fellowship Grant 2022.13261.BD and has received funding from the European Union's H2020 programme through the project IMPULSE (grant agreement No 871161). The graphics processing units (GPUs) used in this work were donated by NVIDIA Corporation.
|
2308.02001 | Memory capacity of two layer neural networks with smooth activations | Determining the memory capacity of two layer neural networks with $m$ hidden
neurons and input dimension $d$ (i.e., $md+2m$ total trainable parameters),
which refers to the largest size of general data the network can memorize, is a
fundamental machine learning question. For activations that are real analytic
at a point and, if restricting to a polynomial there, have sufficiently high
degree, we establish a lower bound of $\lfloor md/2\rfloor$ and optimality up
to a factor of approximately $2$. All practical activations, such as sigmoids,
Heaviside, and the rectified linear unit (ReLU), are real analytic at a point.
Furthermore, the degree condition is mild, requiring, for example, that
$\binom{k+d-1}{d-1}\ge n$ if the activation is $x^k$. Analogous prior results
were limited to Heaviside and ReLU activations -- our result covers almost
everything else. In order to analyze general activations, we derive the precise
generic rank of the network's Jacobian, which can be written in terms of
Hadamard powers and the Khatri-Rao product. Our analysis extends classical
linear algebraic facts about the rank of Hadamard powers. Overall, our approach
differs from prior works on memory capacity and holds promise for extending to
deeper models and other architectures. | Liam Madden, Christos Thrampoulidis | 2023-08-03T19:31:15Z | http://arxiv.org/abs/2308.02001v3 | # Memory capacity of two layer neural networks
###### Abstract
Determining the memory capacity of two layer neural networks with \(m\) hidden neurons and input dimension \(d\) (i.e., \(md+m\) total trainable parameters), which refers to the largest size of general data the network can memorize, is a fundamental machine learning question. For polynomial activations of sufficiently high degree, such as \(x^{k}\) with \(\binom{d+k}{d-1}\geq n\), and real analytic activations, such as sigmoids and smoothed rectified linear units (smoothed ReLUs), we establish a lower bound of \(\lfloor md/2\rfloor\) and optimality up to a factor of approximately \(2\). Analogous prior results were limited to Heaviside and ReLU activations. In order to analyze general real analytic activations, we derive the precise generic rank of the network's Jacobian, which can be written in terms of Hadamard powers and the Khatri-Rao product. Our analysis extends classical linear algebraic facts about the rank of Hadamard powers. Overall, our approach differs from prior works on memory capacity and holds promise for extending to deeper models and other architectures.
**Keywords: Neural networks, Memory capacity, Hadamard powers, Khatri-Rao products, Kruskal rank**
**MSC Classification: 15A03, 26B10**
## 1 Introduction
Machine learning models, such as neural networks, have become increasingly adept at performing tasks, such as image classification and natural language processing, but
also increasingly opaque in terms of their underlying mechanisms. And the intuition that experts employ to construct such models, while useful now, may be based on an erroneous understanding of those underlying mechanisms, much as a field specialist in an engineering firm may come up with explanations that are useful in the field but contradict the underlying physics. It is important that we understand the underlying mechanisms in machine learning so that we can mitigate inherent biases and avoid potential failures.
Neural networks, despite their simplicity, are still not fully understood. From the perspective of traditional optimization, they should be extremely hard to train due to the nonconvexity of their associated training objectives. However, even simple algorithms like stochastic gradient descent are able to find global minima to these training objectives. At the heart of this phenomena is the fact that neural networks are expressive enough to interpolate data sets. But, from the perspective of traditional statistical learning theory then, they should not generalize well to unseen data. Nevertheless, they do generalize well to unseen data, interpolating without merely memorizing the seen data. Thus, the expressive power of neural networks is integral to both the convergence and generalization properties of neural networks, and so we take it as the theme of the present paper.
The output of the two layer neural network model with data matrix \(X\in\mathbb{R}^{d\times n}\), first layer weight matrix \(W\in\mathbb{R}^{d\times m}\), second layer weight vector \(v\in\mathbb{R}^{m}\), and activation function \(\psi\) is
\[h(W,v,X)=\psi\left(X^{T}W\right)v\in\mathbb{R}^{n},\]
where \(\psi\) is applied coordinate-wise. The columns of \(W\) correspond to \(m\) hidden neurons, \(\psi(W^{T}X)\) embeds the data into \(\mathbb{R}^{m}\), \(m\) is the embedding dimension, and \(v\) corresponds to a linear model applied to the embedded data. For fixed \(m\), the memory capacity of \(h\) is the largest \(n\) such that \(h(\cdot,\cdot,X)\) is surjective for generic \(X\)[7]. By "generic" we mean that \(X\) comes from a set whose complement is contained in the zero set of a non-identically zero real analytic function; in particular, this implies that the complement is measure zero and closed. Given \(n\), we are interested in how large \(m\) has to be in order for the memory capacity of \(h\) to be at least \(n\). We consider general real analytic activation functions, which includes polynomials; sigmoids, such as the logistic function, \(\tanh\), and \(\arctan\); and smoothed rectified linear units, such as GELU.
In Theorem 11, we show that for any data matrix and any machine learning model that consists of a linear model/layer applied to a smooth embedding, if the rank of the Jacobian is \(n\) at any point, then the "doubled model" with twice the number of parameters is surjective. The doubled model may or may not be in the model class, but for neural networks, including deep networks, we show that it is.
Thus, the question of memory capacity reduces to a question of Jacobian rank. In the case of a two layer neural network, the transpose of the Jacobian of \(h(\mathrm{vec}^{-1}(\cdot),v,X):\mathbb{R}^{md}\rightarrow\mathbb{R}^{n}\), where \(\mathrm{vec}^{-1}\) denotes column-wise reshaping, can be written \(\Phi=\mathrm{diag}(v)\psi^{\prime}\left(W^{T}X\right)\odot X\in\mathbb{R}^{md \times n}\), where \(\odot\) is the Khatri-Rao product [16, Sec. VI.A]. Given \(X\), we just need a single \((W,v)\) such that \(\mathrm{rank}(\Phi)=n\) in order to get surjectivity for \(h(\cdot,\cdot,X)\) with embedding dimension \(2m\) instead of \(m\). The main contribution of the present paper is proving that \(\mathrm{rank}(\Phi)\) actually equals \(\min\{md,n\}\)
for generic \((W,v,X)\). We then combine this with Theorem 11 to prove the following memory capacity result, and show that the result is tight up to a factor of \(\approx 2\):
* Theorem 12: If \(md\geq 2n\) and \(m\) is even, then \(h(\cdot,\cdot,X)\) is surjective for generic \(X\).
* Theorem 13: If \(m(d+1)<n\), then, for all \(X\), \(h(\cdot,\cdot,X)\) is not surjective.
As mentioned, the main work of the present paper is in showing that \(\Phi\) is generically full rank. We abstract this to the problem of showing that the matrix \(B^{T}\odot\phi(AB^{T})\) is generically full Kruskal rank. Specifically, consider \(A\in\mathbb{R}^{m\times d}\) and \(B\in\mathbb{R}^{n\times d}\) and let \((c_{k})\subset\mathbb{R}\) and \(\phi:\mathbb{R}\rightarrow\mathbb{R}\) be non-polynomial real analytic. Then we prove the following results, where the exponent \((k)\) denotes the \(k\)th Hadamard power:
* Theorem 3: All order \(\min\{m,n,\binom{k+d-1}{k}\}\) or less minors of \((AB^{T})^{(k)}\) are nonzero for generic \((A,B)\).
* Theorem 4: All order \[\min\left\{m,n,\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\binom{k+d-1}{k }\right\}\text{ or less minors of }\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{(k)}\] are nonzero for generic \((A,B)\).
* Theorem 6: \(B^{T}\odot(AB^{T})^{(k)}\) has Kruskal rank \(\min\{md,n,\binom{k+d}{k+1}\}\) for generic \((A,B)\).
* Theorem 7: \[B^{T}\odot\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{(k)}\text{ has Kruskal rank }\min\left\{md,n,\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\binom{k+d }{k+1}\right\}\] for generic \((A,B)\).
* Theorem 8: All order \(\min\{m,n\}\) or less minors of \(\phi(AB^{T})\) are nonzero for generic \((A,B)\).
* Theorem 9: \(B^{T}\odot\phi(AB^{T})\) has Kruskal rank \(\min\{md,n\}\) for generic \((A,B)\).
It may be helpful to see the relevant objects in the above diagram, which has arrows indicating particular proof extensions.
Theorems 6, 7, and 9 are our main contributions (in addition to Theorems 11-13). Theorem 3 was proved in [8] but we give a novel proof that allows us to extend to the other results. The second proof extension, shown in the diagram by the arrows labeled "2," follows almost immediately thanks to the structure of our proof. The first proof extension, shown in the diagram by the arrows labeled "1," is the most involved and requires a novel decomposition of \(B^{T}\odot(AB^{T})^{(k)}\). The third proof extension, shown in the diagram by the arrows labeled "3," is not difficult but subtle and involves reducing to the polynomial setting using Taylor's theorem.
### Related work
Recall that the transpose of the Jacobian of the two layer neural network model, with respect to the hidden layer, is \(\Phi=\operatorname{diag}(v)\psi^{\prime}\left(W^{T}X\right)\odot X\). If \(\operatorname{rank}(\Phi)=n\) at \((W_{0},v_{0},X)\), then, given a label vector \(y\in\mathbb{R}^{n}\), we can solve for \(U_{0}\in\mathbb{R}^{d\times m}\) in the linear equation
\[\begin{split} y&=\left(\operatorname{diag}(v_{0}) \psi^{\prime}\left(W_{0}^{T}X\right)\odot X\right)^{T}\operatorname{vec}(U_{0 })\\ \text{and use }&=\lim_{\epsilon\to 0}\;\psi\left(X^{T}[W_{0}+ \epsilon U_{0}\;W_{0}]\right)[v_{0}/\epsilon;-v_{0}/\epsilon]\end{split} \tag{1}\]
to show that the image of \(h(\cdot,\cdot,X)\) with embedding dimension \(2m\) is dense [6, Prop. 4]. Bubeck et al [6] used this trick to show that if \(\psi\) is ReLU (i.e. \(\psi(x)=\max\{0,x\}\)), then \(m\geq 4\lceil n/d\rceil\) is sufficient to guarantee that, for all \(X\) in general linear position, \(h(\cdot,\cdot,X)\) is surjective (since in this case we don't have to take \(\epsilon\) all the way to zero). Baum [4] had already proved a similar result if \(\psi\) is the Heaviside function (i.e. \(\psi(x)=\mathbb{I}\left\{x\geq 0\right\}\)) and the image of \(h(\cdot,\cdot,X)\) only needs to contain \(\{0,1\}^{n}\), and Yun et al [20] had extended this to ReLU.
Recently, Zhang et al [21] used the Inverse Function Theorem to generalize Eq. (1), demonstrating that if \(\psi\) is smooth and if \(\operatorname{rank}(\Phi)=n\) at some \((W_{0},v_{0},X)\), then \(h(\cdot,\cdot,X)\) with embedding dimension \(2m\) is surjective. Their approach inspired our Theorem 11, which further extends their result to encompass a broader range of machine learning models.
Regarding the conditions that ensure \(\operatorname{rank}(\Phi)=n\) for smooth activations, it is shown in Corollary 3.1 of [15] that, given \(n\in\mathbb{N}\), there exists \(C(n)>0\) such that \(md/\log^{C(n)}(md)\geq n\) is sufficient to guarantee that, with high probability over random \(X\), \(h(\cdot,\cdot,X)\) is surjective. Ignoring the dependence of \(C(n)\) on \(n\), this bound has extra log factors and only holds for \(X\) with high probability. Thus, our results represent an improvement in both these aspects. To better understand the basis for these improvements, it's helpful to delve into the origins of their result, which is actually a corollary of an intermediate step in the proof of a convergence result, as elaborated below. In order to prove that \(\operatorname{rank}(\Phi)=n\), they show that the smallest eigenvalue of \(\Phi^{T}\Phi\) is positive by bounding the minimum eigenvalue of \(\mathbb{E}_{W,v}[\Phi^{T}\Phi]\) away from zero and applying the matrix Chernoff inequality. For example, letting \(\lambda\) denote \(\lambda_{\min}(\mathbb{E}_{W,v}[\Phi^{T}\Phi/m])\)
then applying Remark 5.3 of [18] gives the following: if
\[m\geq\frac{2\|X\|_{2}^{2}\log(n/\delta)}{\lambda}\]
then, with probability greater than \(1-\delta\),
\[\lambda_{\min}(\Phi^{T}\Phi/m)\geq\lambda-\frac{\|X\|_{2}}{\sqrt{m}}\sqrt{2 \lambda\log(n/\delta)}.\]
This bound on \(\lambda_{\min}(\Phi^{T}\Phi/m)\) was first proved in [16], a paper which, along with [17], tightened the analysis of the landmark paper [9]. Subsequently, [15] established a lower bound on \(\lambda\), which aligns with empirical investigations outlined in [19]. But, while bounding the distance of \(\Phi^{T}\Phi\) from \(\mathbb{E}_{W,v}[\Phi^{T}\Phi]\) ends up being useful for the convergence analysis, it is unnatural for memory capacity analysis: there is no reason why \(\Phi^{T}\Phi\) needs to be close to \(\mathbb{E}_{W,v}[\Phi^{T}\Phi]\) in order for \(\operatorname{rank}(\Phi)=n\), since, as we show, \(\operatorname{rank}(\Phi)=n\) generically.
For the rank results without the Khatri-Rao product, while [8] recently derived the generic rank of \((AB^{T})^{(k)}\), it seems the generic rank of \(\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}\) has actually been known for some time, though it is difficult to find precise statements of equality rather than upper bounds. For example, Lemma 2.3 of [1] proved in four lines that the rank of \((AB^{T})^{(k)}\) and \(\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}\) are bounded by \(\binom{k+d-1}{k}\) and \(\binom{K+d}{K}\) respectively. Lemma 4.4 of [3] proved the latter bound, calling it a "standard linear algebra fact." Moreover, if we slightly modify his proof by including the coefficients \(\mathbb{I}\left\{\alpha_{m}\neq 0\right\}\) in the final expression, then a little more work proves our Theorem 4. We include this alternative proof in Appendix B in order to explain why it cannot be extended to Khatri-Rao products.
Finally, for the rank results involving the Khatri-Rao product, the only previous result, other than corollaries of convergence results, was Lemma E.1 of [21], which corresponds to our Theorem 9. Upon a careful examination of their proof, we encountered inconsistencies that appeared unresolvable. Only after the initial release of our preprint, a correspondence with the authors of [21] revealed that these inconsistencies stemmed from typos and convoluted presentation of their methodology. During this discussion, we realized that their idea behind their proof is actually correct and can, in fact, be presented in a rather transparent manner, which we do in Appendix A for completeness. Overall, our proof technique is independent and entirely distinct from theirs. We believe our approach provides a more comprehensive and in-depth understanding of the matter since it computes the generic rank of \(B^{T}\odot\phi(AB^{T})\) for all real analytic \(\phi\), including polynomials. The proof in [21] can be extended to polynomials as well, as we show in Appendix A, but it provides a loose lower bound on the generic rank rather than giving the precise generic rank. In particular, it can only be used to justify using polynomials with an extremely large number of nonzero coefficients.
### Organization
Our paper is organized as follows. In Section 2, we go through the necessary preliminaries. In Section 3, we present our main proof idea and prove Theorems 3 and 4. In Section 4, we prove Theorems 6-9. In Section 5, we prove Theorems 11 and 12. In Section 6, we conclude. In the appendix we go into further details about some of the related work.
## 2 Preliminaries
In this section we discuss the necessary preliminaries. In Section 2.1 we define the different notions of rank and discuss the linear algebra tools that we will employ. In Section 2.2, we discuss some notions from the theory of analytic functions of several variables. In Section 2.3, we discuss some basic facts about weak compositions, which we will index some of our matrices by.
Throughout the present paper, the following notation will be used: \(\mathbb{Z}_{+}\) denotes \(\mathbb{N}\cup\{0\}\), \([n]\) denotes \(\{1,2,\ldots,n\}\), \(\binom{A}{n}\) denotes \(\{B\subset A\mid|B|=n\}\), \(\circ\) denotes the Hadamard product (and function composition), \(\odot\) denotes the Khatri-Rao product, the exponent \((k)\) denotes the \(k\)th Hadamard power, and "Hadamard function" refers to univariate functions applied coordinate-wise.
Let \(A\in\mathbb{R}^{m\times n}\). We use \(a_{i}\) to denote the \(i\)th column of \(A\) and \(a_{i,j}\) to denote the \((i,j)\)th entry of \(A\). Given \(I\subset[m]\), and \(J\subset[n]\), we denote the submatrix formed from the rows \(I\) and columns \(J\) of \(A\) as \(A_{I,J}\). We use \(\mathfrak{S}_{n}\) to denote the symmetric group of degree \(n\). Note that we can write \(\mathfrak{S}_{n}=\{\sigma:[n]\hookrightarrow[n]\}\). More generally, consider a matrix \(A\) with rows indexed by a set \(I\) with \(|I|=m\) and columns indexed by a set \(J\) with \(|J|=n\). We order \(I\) and \(J\) lexicographically if they consist of pairs, i.e. the first entry in the pair changes slower than the second entry.
Finally, we say a property holds for generic \(x\) if it holds for all \(x\in\mathbb{R}^{n}\) except on the zero set of a non-identically zero real analytic function.
### Rank of a matrix
Let \(A\in\mathbb{R}^{m\times n}\). The rank of \(A\) is the dimension of its column space or, equivalently, its row space. Let \(I\subset[m]\) and \(J\subset[n]\) with \(|I|=|J|\leq\min\{m,n\}\). Then the \((I,J)\) minor of \(A\), denoted \(\det_{I,J}(A)\), is the determinant of the submatrix \(A_{I,J}\). The order of the minor is \(|I|\). Using minors, the rank of \(A\) can be equivalently defined as the largest \(r\) such that there is a nonzero minor of order \(r\). This allows us to write the following rank condition:
\[\operatorname{rank}(A)\geq r\iff\sum_{\begin{subarray}{c}(I,J)\subset[m] \times[n]\\ |I|=|J|=r\end{subarray}}\det_{I,J}(A)^{2}\neq 0.\]
Note that
\[\sum_{\begin{subarray}{c}(I,J)\subset[m]\times[n]\\ |I|=|J|=r\end{subarray}}\det_{I,J}(A)^{2}\]
is a multivariate polynomial in the entries of \(A\). If we replace \(A\) with a matrix-valued real analytic function of several variables \(A(x)\), then the composition of the polynomial with \(A\) is a real analytic function. We call this composite function the "rank condition function of order \(r\) associated with \(A\)". Thus, we have that \(\operatorname{rank}(A(x))\geq r\) if and only if \(x\) is not in the zero set of the rank condition function of \(r\) associated with \(A\). If the zero set is not the whole domain (i.e. if the rank condition function is not identically zero), then it is very limited as we will explain in Section 2.2 (in particular, it is measure zero and closed). So, our task lies in showing that the rank condition function is not identically zero. To do so we use Leibniz's determinant formula [2, Def. 10.33],
\[\det(A)=\sum_{\sigma\in\mathfrak{S}_{n}}\operatorname{sgn}(\sigma)\prod_{i=1 }^{n}a_{i,\sigma(i)}=\sum_{\sigma\in\mathfrak{S}_{n}}\operatorname{sgn}( \sigma)\prod_{i=1}^{n}a_{\sigma(i),i}\text{ for }A\in\mathbb{R}^{n\times n},\]
and the Cauchy-Binet formula [10, Sec. I.2.4],
\[\det(AB^{T})=\sum_{S\in\binom{[n]}{m}}\det_{[m],S}(A)\det_{[m],S}(B)\text{ for }A,B\in\mathbb{R}^{m\times n}\ (n\geq m).\]
Specifically, we use the following corollary of the Cauchy-Binet formula.
**Lemma 1**: _Let \(A\in\mathbb{R}^{m\times N}\) and \(B\in\mathbb{R}^{n\times N}\), and let \(D\in\mathbb{R}^{N\times N}\) be diagonal. Let \(I\subset[m]\) and \(J\subset[n]\) such that \(|I|=|J|=s\leq\min\{m,n,N\}\). Then_
\[\det_{I,J}\left(ADB^{T}\right)=\sum_{S\in\binom{[N]}{s}}\left(\prod_{\ell\in S }D_{\ell}\right)\det_{I,S}(A)\det_{J,S}(B).\]
_Proof_ Applying the Cauchy-Binet formula, we get
\[\det_{I,J}\left(ADB^{T}\right) =\sum_{S\in\binom{[N]}{s}}\det_{I,S}(A)\det_{S,J}\left(DB^{T}\right)\] \[=\sum_{S,S^{\prime}\in\binom{[N]}{s}}\det_{I,S}(A)\det_{S,S^{ \prime}}(D)\det_{J,S^{\prime}}(B)\]
but, since \(D\) is diagonal, \(\det(D_{S,S^{\prime}})=0\) unless \(S=S^{\prime}\), in which case it equals \(\prod_{\ell\in S}D_{\ell}\) and so the result follows. \(\Box\)
These are powerful tools because they can be used to write the minor of a matrix-valued polynomial as a sum of polynomials. Thus, the question of rank becomes a question of the linear independence of multivariate polynomials.
In addition to the usual notion of rank, there are stronger notions of rank. For example, the Kruskal rank of \(A\) is the largest \(r\) such that every subset of \(r\) columns of \(A\) is linearly independent [12]. Given \(J\subset[n]\) such that \(|J|=r\leq m\), the columns of \(A_{[m],J}\) are linearly independent if and only if the rank of \(A_{[m],J}\) is \(r\). Thus, we have the following Kruskal rank condition:
\[\text{the Kruskal rank of }A\geq r\iff\prod_{\begin{subarray}{c}J\subset[n] \\ |J|=r\end{subarray}}\sum_{\begin{subarray}{c}I\subset[m]\\ |I|=r\end{subarray}}\det_{I,J}(A)^{2}\neq 0.\]
This naturally extends to an even stronger notion of rank defined as the largest \(r\) such that
\[\prod_{\begin{subarray}{c}(I,J)\subset[m]\times[n]\\ |I|=|J|=r\end{subarray}}\det_{I,J}(A)\neq 0.\]
### Real analytic functions of several variables
We will use properties of analytic functions to (1) extend our results from polynomial \(A\) to real analytic \(A\) and (2) to interpret the rank being deficient on the zero set of a non-identically zero analytic function.
First, an analytic function is uniquely determined by the coefficients of its power series expansion at each point. This is a corollary of Taylor's theorem, which gives these coefficients in terms of the partial derivatives (of all orders) of the function at a point. Thus, to show that the rank condition associated with \(A\) is not identically zero, we only have to show that a subset of its coefficients are not all zero.
Second, the zero set of a non-identically zero analytic function is measure zero by Corollary 10 of [11], a corollary of the identity theorem [11, Thm. 6] and Jensen's inequality [11, Thm. 9]. The identity theorem states that if \(f\) and \(g\) are analytic on an open connected domain and \(f=g\) on a nonempty open subset, then \(f=g\) on the whole domain. The identity theorem and its corollary hold for real analytic functions as well (this is clear from the proofs), so we have shown the measure zero part of the following proposition. To show the closed part, just use that the pre-image of \(\mathbb{R}\backslash\{0\}\) is open since \(f:\mathbb{R}^{n}\rightarrow\mathbb{R}\) is continuous.
**Lemma 2**: _The zero set of a non-identically zero real analytic function is measure zero and closed._
### Weak compositions
We will index our decompositions by weak compositions. There is a well-known bijection between multisets of cardinality \(k\) taken from \([d]\)--\(i_{1},\ldots,i_{k}\in[d]\) such that \(i_{1}\leq\ldots\leq i_{k}\)--and \(d\)-tuples of non-negative integers whose sum is \(k\), i.e. weak compositions of \(k\) into \(d\) parts--\(k_{1},\ldots,k_{d}\in\mathbb{Z}_{+}\) such that \(k_{1}+\cdots+k_{d}=k\). It can be seen
by viewing \(k_{i}\) as the multiplicity of \(i\), i.e. \(k_{i}=|\{\ell\in[k]\mid i=i_{\ell}\}|\). The total number of either is \(\binom{d}{k}=\binom{k+d-1}{k}=\binom{k+d-1}{d-1}\) by stars and bars [5, Thm. 2.5.1].
Let
\[\lambda(k) =\Big{\{}\vec{k}\in\mathbb{Z}_{+}^{d}\mid k_{1}+\cdots+k_{d}=k \Big{\}}\] \[\text{and }\Lambda(K) =\Big{\{}\vec{k}\in\mathbb{Z}_{+}^{d}\mid k_{1}+\cdots+k_{d}\leq K \Big{\}}.\]
Note that
\[|\Lambda(K)|=\sum_{k=0}^{K}\binom{d}{k}=\sum_{k=0}^{K}\binom{k+d-1}{d-1}=\sum_ {i=d-1}^{K+d-1}\binom{i}{d-1}=\binom{K+d}{d}\]
by Zhu's Theorem [14, Thm. 1.5.2], which was published by Zhu Shijie in 1303 [22].
## 3 Results involving Hadamard powers
Here we present the main idea that allows us to prove the generic full rankness of \(B^{T}\odot\phi(AB^{T})\). First, we sketch the proof idea in Section 3.1. Then, we apply the proof technique to \(AB^{T}\) in Section 3.2, \((AB^{T})^{(k)}\) in Section 3.3, and \(\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}\) in Section 3.4.
### Proof sketch
Let \(f:\mathbb{R}^{d}\to\mathbb{R}^{m\times n}\) be real analytic. For all \(I\subset[m]\) and \(J\subset[n]\) such that \(|I|=|J|\leq\min\{m,n\}\), define
\[g_{I,J}:\mathbb{R}^{d} \to\mathbb{R}\] \[x \mapsto\det_{I,J}(f(x)). \tag{2}\]
Let \(g\) be a product of \(g_{I,J}\)'s or a product of sums of \(g_{I,J}\)'s. Then \(g\) is real analytic. We would like to show that it is not identically zero so that we can apply Lemma 2.
To start with, consider polynomial \(f\). Then we want to find an appropriate decomposition \(f(x)=A(x)DB(x)^{T}\) where \(A\) and \(B\) are matrix-valued real analytic functions and \(D\in\mathbb{R}^{N\times N}\) is a diagonal matrix with no zeros. Let \(|I|=|J|=s\leq\min\{m,n,N\}\) and enumerate \(I\) as \(\{i_{1},\ldots,i_{s}\}\) and \(J\) as \(\{j_{1},\ldots,j_{s}\}\). Then, by the Cauchy-Binet formula,
\[\det_{I,J}\big{(}A(x)DB(x)^{T}\big{)} =\sum_{S\in\binom{[N]}{s}}\left(\prod_{\ell\in S}D_{\ell}\right) \det_{I,S}(A(x))\det_{J,S}(B(x))\] \[:=\sum_{S\in\binom{[N]}{s}}\left(\prod_{\ell\in S}D_{\ell}\right) p_{S}(x),\]
and by Leibniz's determinant formula,
\[p_{S}(x) =\left(\sum_{\sigma:I\hookrightarrow S}\operatorname{sgn}(\sigma) \prod_{t=1}^{s}a_{i_{t},\sigma(i_{t})}(x)\right)\left(\sum_{\tau:J \hookrightarrow S}\operatorname{sgn}(\tau)\prod_{t=1}^{s}b_{i_{t},\tau(i_{t})}( x)\right)\] \[\coloneqq p_{A}(x)p_{B}(x)\] \[=\sum_{\sigma:I\hookrightarrow S}\sum_{\tau:J\hookrightarrow S} \operatorname{sgn}(\sigma)\operatorname{sgn}(\tau)\prod_{t=1}^{s}a_{i_{t}, \sigma(i_{t})}(x)b_{j_{t},\tau(j_{t})}(x).\]
We call the monomials corresponding to the individual terms in each sum the "Leibniz monomials" of \(p_{A}\), \(p_{B}\), and \(p_{S}\) respectively. Note that these monomials may or may not be in their corresponding polynomial depending on whether they cancel or not.
We want to show that the non-identically zero \(p_{S}\) are linearly independent and that there is at least one of them.
One way we will do this is by showing that, for all \(S\in\binom{[N]}{s}\), \(p_{S}\) has distinct Leibniz monomials (so they don't cancel) that do not appear in any other \(p_{S^{\prime}}\).
The other way we will show it is a little more involved. We will show that \(p_{A}\) is not identically zero if and only if \(S\) is in a particular set, that \(p_{B}\) is not identically zero if and only if \(S\) is in another particular set, that \(p_{B}\) has distinct Leibniz monomials for \(S\) in that set, that those monomials do not appear in \(p_{B}\) for any other \(S^{\prime}\), and that the two sets of \(S\) have non-empty intersection. Let \(\widetilde{N}\) denote the maximum size of \(S\) in the intersection.
If the non-identically zero \(p_{S}\) are linearly independent and there is at least one of them, then \(g_{I,J}\) is identically zero if and only if \(\prod_{\ell\in S}D_{\ell}=0\) for all \(S\) such that \(p_{S}\) is not identically zero, which can't happen if \(D\) has no zeros. Thus, \(g\) equal to the product of all \(g_{I,J}\) such that \(|I|=|J|\leq\min\{m,n,N\}\) is not identically zero. And so, all order \(\min\{m,n,N\}\) or less minors of \(f(x)\) are nonzero for generic \(x\).
If, instead, there is a restriction on \(I\) for \(g_{I,J}\) to not be identically zero, then
\[g=\prod_{\begin{subarray}{c}J\subset[n]\\ |J|\leq\min\{m,n,\widetilde{N}\}\end{subarray}}\sum_{\begin{subarray}{c}I \subset[m]\\ |I|=|J|\end{subarray}}g_{I,J}^{2},\]
is not identically zero. And so, \(f(x)\) has Kruskal rank at least \(\min\{m,n,\widetilde{N}\}\) for generic \(x\).
Now, consider the setting where \(f\) is not a polynomial. Since \(g_{I,J}\) is real analytic, it is uniquely determined around zero by its power series expansion there (by Taylor's theorem). For any \(K\in\mathbb{N}\), let \(g_{I,J}^{K}\) be the sum of the monomials in the Taylor series of \(g_{I,J}\) that we get by truncating the Taylor series of \(f\) to only degree \(K\) monomials. Then we can take \(K\) as high as we want and reduce to the corresponding result for polynomial \(f\).
### Matrix products
First let's demonstrate the proof technique for matrix products. Let \(A\in\mathbb{R}^{m\times d}\) and \(B\in\mathbb{R}^{n\times d}\). Let \(I\subset[m]\) and \(J\subset[n]\) such that \(|I|=|J|=s\leq\min\{m,n,d\}\). Enumerate \(I\) as \(\{i_{1},\ldots,i_{s}\}\) and \(J\) as \(\{j_{1},\ldots,j_{s}\}\). We want to show that the \((I,J)\) minor of \(AB^{T}\) is not identically zero. By the Cauchy-Binet formula,
\[p(a_{i_{t},\ell},b_{j_{t},\ell}) \coloneqq\det_{I,J}\left(AB^{T}\right)\] \[=\sum_{S\in\binom{[d]}{s}}\det_{I,S}(A)\det_{J,S}(B)\] \[\coloneqq\sum_{S\in\binom{[d]}{s}}p_{S}(a_{i_{t},\ell},b_{j_{t}, \ell}),\]
and by Leibniz's determinant formula,
\[p_{S}=\sum_{\sigma:I\hookrightarrow S}\sum_{\tau:J\hookrightarrow S}\text{ sgn}(\sigma)\text{sgn}(\tau)\prod_{t=1}^{s}a_{i_{t},\sigma(i_{t})}b_{j_{t},\tau(j_{t})}.\]
The \((\sigma,\tau)\) Leibniz monomial is the only one that involves \(a_{i_{1},\sigma(i_{1})},\ldots,a_{i_{s},\sigma(i_{s})}\) and
\(b_{i_{1},\tau(i_{1})},\ldots,b_{i_{s},\tau(i_{s})}\) and so it is distinct. Thus, it does not cancel in \(p_{S}\). Moreover, if it is the same monomial as the \((\sigma^{\prime},\tau^{\prime})\) term in \(p_{S^{\prime}}\), then \(S=\sigma(I)=\sigma^{\prime}(I)=S^{\prime}\) where we view \(\sigma:I\hookrightarrow\binom{\Lambda(K)}{s}\). Thus, distinct \(p_{S}\) have distinct monomials and so the \(p_{S}\) are linearly independent. Thus, \(p\) is not identically zero and so all order \(\min\{m,n,d\}\) or less minors of \(AB^{T}\) are nonzero for generic \((A,B)\). We discuss further implications of this in Appendix B.
### Hadamard powers
To show how to extend from \((AB^{T})^{(k)}\) to \(B^{T}\odot(AB^{T})^{(k)}\), we first demonstrate our proof technique on the former.
**Theorem 3**: _Let \(k\in\mathbb{N}\). Then all order \(\min\{m,n,\binom{d}{k}\}\) or less minors of \((AB^{T})^{(k)}\) are nonzero for generic \((A,B)\in\mathbb{R}^{m\times d}\times\mathbb{R}^{n\times d}\)._
Proof: First,
\[\left(AB^{T}\right)^{(k)} =\left(\sum_{i=1}^{d}a_{i}b_{i}^{T}\right)^{(k)}\] \[=\sum_{i_{1},\ldots,i_{k}=1}^{d}\left(a_{i_{1}}b_{i_{1}}^{T} \right)\circ\cdots\circ\left(a_{i_{k}}b_{i_{k}}^{T}\right)\]
\[=\sum_{i_{1},\ldots,i_{k}=1}^{d}(a_{i_{1}}\circ\cdots\circ a_{i_{k}})(b_{i_{1}} \circ\cdots\circ b_{i_{k}})^{T}\]
\[\stackrel{{ s}}{{=}}\sum_{\vec{k}\in\lambda(k)}\binom{k}{k_{1}, \ldots,k_{d}}\left(a_{1}^{(k_{1})}\circ\cdots\circ a_{d}^{(k_{d})}\right)\left( b_{1}^{(k_{1})}\circ\cdots\circ b_{d}^{(k_{d})}\right)^{T}\]
\[=\widetilde{A}D\widetilde{B}^{T}\]
where \(A=[a_{1}|\cdots|a_{d}]\), \(B=[b_{1}|\cdots|b_{d}]\), \((*)\) follows from the commutativity of the Hadamard product, the columns of \(\widetilde{A}\) are the unique Hadamard products of the columns of \(A\), the columns of \(\widetilde{B}\) are the unique Hadamard products of the columns of \(B\), and \(D\) is a diagonal matrix with the corresponding multinomial coefficients. Note that
\[\widetilde{A}=\left[\prod_{\ell=1}^{d}a_{i,\ell}^{k_{\ell}}\right]_{(i,\vec{ k})\in[m]\times\lambda(k)}\text{ and }\widetilde{B}=\left[\prod_{\ell=1}^{d}b_{i,\ell}^{k_{\ell}}\right]_{(i,\vec{k}) \in[n]\times\lambda(k)}.\]
The inner dimension is \(N=|\lambda(k)|=\binom{(d)}{k}\). Let \(I\subset[m]\) and \(J\subset[n]\) such that \(|I|=|J|=s\leq\min\{m,n,N\}\). Enumerate \(I\) as \(\{i_{1},\ldots,i_{s}\}\) and \(J\) as \(\{j_{1},\ldots,j_{s}\}\). We want to show that the \((I,J)\) minor is not identically zero. By the Cauchy-Binet formula,
\[p(a_{i_{t},\ell},b_{j_{t},\ell}) \coloneqq\det_{I,J}\left(\widetilde{A}D\widetilde{B}^{T}\right)\] \[=\sum_{S\in\binom{\lambda(k)}{s}}\left(\prod_{\ell\in S}D_{\ell} \right)\det_{I,S}\left(\widetilde{A}\right)\det_{J,S}\left(\widetilde{B}\right)\] \[\coloneqq\sum_{S\in\binom{\lambda(k)}{s}}\left(\prod_{\ell\in S}D _{\ell}\right)p_{S}(a_{i_{t},\ell},b_{j_{t},\ell}),\]
and by Leibniz's determinant formula,
\[p_{S}=\sum_{\sigma:I\hookrightarrow S}\sum_{\tau:J\hookrightarrow S}\text{ sgn}(\sigma)\text{sgn}(\tau)\prod_{t=1}^{s}\prod_{\ell=1}^{d}a_{i_{t},\ell}^{ \sigma(i_{t})_{\ell}}b_{j_{t},\ell}^{\tau(j_{t})_{\ell}}.\]
Consider the \((\sigma,\tau)\) Leibniz monomial. Suppose it is equal to the \((\sigma^{\prime},\tau^{\prime})\) Leibniz monomial. Let \(t\in[s]\). The \(a_{i_{t},1},\ldots,a_{i_{t},d}\) have degrees \(\sigma(i_{t})_{1}=\sigma^{\prime}(i_{t})_{1},\ldots,\sigma(i_{t})_{d}=\sigma^ {\prime}(i_{t})_{d}\) respectively, therefore \(\sigma(i_{t})=\sigma^{\prime}(i_{t})\). Since this was for arbitrary \(t\in[s]\), we have shown \(\sigma=\sigma^{\prime}\). Similarly, it is the case that \(\tau=\tau^{\prime}\). Thus, the Leibniz monomials are distinct, so they don't cancel in \(p_{S}\).
Similarly, if the \((\sigma,\tau)\) monomial in \(p_{S}\) is the same as the \((\sigma^{\prime},\tau^{\prime})\) monomial in \(p_{S^{\prime}}\), then \(S=\sigma(I)=\sigma^{\prime}(I)=S^{\prime}\) where we view \(\sigma:I\hookrightarrow\binom{\lambda(k)}{s}\). Thus, distinct \(p_{S}\) have distinct monomials and so the \(p_{S}\) are linearly independent. Thus, \(p\) is not identically zero and so all order \(\min\{m,n,\binom{d}{k}\}\) or less minors of \((AB^{T})^{(k)}\) are nonzero for generic \((A,B)\). \(\Box\)
### Polynomial Hadamard functions
The proof of the previous section easily extends to \(\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}\).
**Theorem 4**: _Let \(K\in\mathbb{N}\) and \((c_{k})\subset\mathbb{R}\). Then all order_
\[\min\left\{m,n,\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\left( \binom{d}{k}\right)\right\}\]
_or less minors of_
\[\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{(k)}\]
_are nonzero for generic \((A,B)\in\mathbb{R}^{m\times d}\times\mathbb{R}^{n\times d}\)._
Proof: First, our decomposition is
\[\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{(k)}\] \[=\sum_{\begin{subarray}{c}k=0,\ldots,K\\ c_{k}\neq 0\end{subarray}}c_{k}\sum_{\begin{subarray}{c}k\in\lambda(k)\\ k_{1},\ldots,k_{d}\end{subarray}}\left(a_{1}^{(k_{1})}\circ\cdots\circ a_{d}^{ (k_{d})}\right)\left(b_{1}^{(k_{1})}\circ\cdots\circ b_{d}^{(k_{d})}\right)^{T}\] \[\coloneqq\widetilde{A}D\widetilde{B}^{T}\]
with inner indices in
\[\Lambda(K,(c_{k}))\coloneqq\{\vec{k}\in\mathbb{Z}_{+}^{d}\mid k_{1}+\cdots+k_ {d}\leq K,c_{k_{1}+\cdots+k_{d}}\neq 0\}.\]
which has size
\[N=\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\left(\binom{d}{k}\right).\]
The rest of the proof proceeds exactly as in the proof of Theorem 3, except with \(\lambda(k)\) replaced with \(\Lambda(K,(c_{k}))\).
## 4 Results involving the Khatri-Rao product
Here we prove the generic rank of the objects \(B^{T}\odot(AB^{T})^{(k)}\), \(B^{T}\odot\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}\), \(\phi(AB^{T})\), and \(B^{T}\odot\phi(AB^{T})\) in Sections 4.1, 4.2, 4.3, and 4.3 respectively.
To do so, we will employ the fact that the non-identically zero minors of "rectangular block diagonal" matrices are precisely the ones corresponding to (square) block diagonal submatrices, in which case the determinant is the product of the determinants of the blocks.
**Lemma 5**: _Let \(A_{\ell}\in\mathbb{R}^{m\times n}\)\(\forall\ell\in[d]\) and let_
\[A=\begin{bmatrix}A_{1}&&\\ &\ddots&\\ &&A_{d}\end{bmatrix}\]
_with everything else zero. Let \(I_{\ell}\subset[m(\ell-1)+1:m\ell]\) and \(J_{\ell}\subset[n(\ell-1)+1:n\ell]\) for all \(\ell\in[d]\). Let \(I=\cup_{\ell=1}^{d}I_{\ell}\) and \(J=\cup_{\ell=1}^{d}J_{\ell}\). Suppose \(|I|=|J|\leq\min\{md,nd\}\). Then \(|I_{\ell}|=|J_{\ell}|\) for all \(\ell\in[d]\) is necessary for \(\det_{I,J}(A)\) to be nonzero and sufficient for \(\det_{I,J}(A)\) to be equal to_
\[\prod_{\ell=1}^{d}\det_{I_{\ell},J_{\ell}}(A_{\ell}).\]
Proof: To prove the necessary part, suppose \(|I_{\ell}|\neq|J_{\ell}|\) for some \(\ell\in[d].\) If \(|I_{\ell}|<|J_{\ell}|,\) then the columns corresponding to \(A_{\ell}\) in the \((I,J)\) submatrix are linearly dependent; if \(|I_{\ell}|>|J_{\ell}|\) then the rows are; either way, \(\det_{I,J}(A)=0.\) The sufficient part is a well known fact and can be proved with Leibniz's determinant formula: the only permutations that give non-zero products are the ones that permute within each \(A_{\ell}\) separately, and so we can factor out \(\det_{I_{\ell},J_{\ell}}(A_{\ell})\) for each \(\ell\in[d].\)
### Hadamard powers with Khatri-Rao products
**Theorem 6**: _Let \(k\in\mathbb{N}.\) Then \(B^{T}\odot(AB^{T})^{(k)}\) has Kruskal rank at least \(\min\{md,n,\left(\binom{d}{k+1}\right)\}\) for generic \((A,B)\in\mathbb{R}^{m\times d}\times\mathbb{R}^{n\times d}.\) Moreover, the rank is bounded above by the same for all \((A,B).\)_
Proof: Let \(u\in\mathbb{R}^{m},\)\(v\in\mathbb{R}^{n},\) and \(W=[w_{1}|\cdots|w_{d}]\in\mathbb{R}^{n\times d}.\) Then
\[W^{T}\odot w^{T} =[w_{j,i_{1}}u_{i_{2}}v_{j}]_{(i_{1},i_{2}),j}\] \[=[e_{1}\otimes u|\cdots|e_{d}\otimes u][v\circ w_{1}|\cdots|v \circ w_{d}]^{T}\] \[=\sum_{\ell=1}^{d}(e_{\ell}\otimes u)(v\circ w_{\ell})^{T}\]
where the \(e_{\ell}\) denote the basis vectors of \(\mathbb{R}^{d}.\) Thus,
\[B^{T}\odot\left(AB^{T}\right)^{(k)}\] \[=B^{T}\odot\sum_{\vec{k}\in\lambda(k)}\binom{k}{k_{1},\ldots,k_{d }}\left(a_{1}^{(k_{1})}\circ\cdots\circ a_{d}^{(k_{d})}\right)\left(b_{1}^{(k _{1})}\circ\cdots\circ b_{d}^{(k_{d})}\right)^{T}\] \[=\sum_{\ell=1}^{d}\sum_{\vec{k}\in\lambda(k)}\binom{k}{k_{1}, \ldots,k_{d}}\left(e_{\ell}\otimes a_{1}^{(k_{1})}\circ\cdots\circ a_{d}^{(k _{d})}\right)\left(b_{\ell}\circ b_{1}^{(k_{1})}\circ\cdots\circ b_{d}^{(k_{d })}\right)^{T}\] \[\coloneqq\overline{A}D\overline{B}^{T}\]
where \(\overline{A}\) is rectangular block diagonal with \(d\) identical blocks
\[\widetilde{A}=\left[\prod_{\ell=1}^{d}a_{i,\ell}^{k_{\ell}}\right]_{i\in[m], \vec{k}\in\lambda(k)}\quad\text{ and }\quad\quad\overline{B}=\left[b_{i,j}\prod_{\ell=1}^{d}b_{i,\ell}^{k_{\ell}} \right]_{i\in[n],(j,\vec{k})\in[d]\times\lambda(k)}.\]
The inner dimension is \(Nd=\binom{d}{(k)}d.\) Let \(I\subset[md]\) and \(J\subset[n]\) such that \(|I|=|J|=s\leq\min\{md,n,\left(\binom{d}{k+1}\right)\}.\) Enumerate \(I\) as \(\{i_{1},\ldots,i_{s}\}\) and \(J\) as \(\{j_{1},\ldots,j_{s}\}.\) We want to show that the \((I,J)\) minor is not identically zero. By the Cauchy-Binet formula,
\[p(a_{i_{\ell},\ell},b_{j_{\ell},\ell}) \coloneqq\det_{I,J}\left(\overline{A}D\overline{B}^{T}\right)\] \[=\sum_{S\in\binom{[d]\times\lambda(k)}{s}}\left(\prod_{\ell\in S }D_{\ell}\right)\det_{\underbrace{I,S}_{\cdot=PAPB=p_{S}}}.\]
Decompose \(I\) and \(S\) into \(\cup_{\ell=1}^{d}I_{\ell}\) and \(\cup_{\ell=1}^{d}S_{\ell}\) respectively, where \(I_{\ell}\in[m(\ell-1)+1:m\ell]\) and \(S_{\ell}\in[N(\ell-1)+1:N\ell].\) Then, by Lemma 5, \(\det_{I,S}(\overline{A})\) can only be non-identically zero if
\(|I_{\ell}|=|S_{\ell}|\) for all \(\ell\in[d]\). In this case, \(\overline{A}_{I,S}\) is block diagonal and so its determinant is the product of the determinants of its blocks, none of which are identically zero since the blocks are square submatrices of \(\widetilde{A}\) from the proof of Theorem 3. Thus, \(p_{A}\) is not identically zero if and only if \(|I_{\ell}|=|S_{\ell}|\) for all \(\ell\in[d]\).
On the other hand, \(\overline{B}\) has repeated columns. In particular, distinct columns \((i,\vec{k})\) and \((j,\vec{r})\) are equal if and only if \(\vec{k}+e_{i}=\vec{r}+e_{j}\). Thus, we can break \([d]\times\lambda(k)\) up into the distinct preimages of \(\varphi:[d]\times\lambda(k)\allowbreak\mathrel{\mathop{\kern 0.0pt\hbox to 0.0pt{\vrule heig ht ight 6.0pt height 6.0pt height 6.0pt depth -0.2pt\hss\raise 0.43pt\hbox{$\rightarrow$}}} \limits}\lambda(k+1):(i,\vec{k})\mapsto\vec{k}+e_{i}\). Then, \(p_{B}\) is not identically zero if and only if \(\varphi(S)\) has distinct elements. Suppose \(\varphi(S)\) has distinct elements and consider \(p_{B}\). By Leibniz's determinant formula
\[p_{B}=\sum_{\tau:J\mapsto S}\operatorname{sgn}(\tau)\prod_{t=1}^{s}\prod_{ \ell=1}^{d}b_{i_{t},\ell}^{\varphi(\tau(i_{t}))_{\ell}}.\]
Consider the \(\tau\) Leibniz monomial. Suppose it is equal to the \(\tau^{\prime}\) Leibniz monomial. Let \(t\in[s]\). The \(b_{i_{t},1},\ldots,b_{i_{t},d}\) have degrees \(\varphi(\tau(i_{t}))_{1}=\varphi(\tau^{\prime}(i_{t}))_{1},\ldots,\varphi(\tau (i_{t}))_{d}=\varphi(\tau^{\prime}(i_{t}))_{d}\) respectively, therefore \(\varphi(\tau(i_{t}))=\varphi(\tau^{\prime}(i_{t}))\). Since \(\varphi(S)\) has distinct elements, \(\tau(i_{t})=\tau^{\prime}(i_{t})\). And since this was for arbitrary \(t\in[s]\), we have shown \(\tau=\tau^{\prime}\).
Similarly, if \(\varphi(S)\) has distinct elements and \(\varphi(S^{\prime})\) has distinct elements, and if the \(\tau\) monomial in \(p_{B}\) with \(S\) is the same as the \(\tau^{\prime}\) monomial in \(p_{B}\) with \(S^{\prime}\), then \(S=\tau(J)=\tau^{\prime}(J)=S^{\prime}\) where we view \(\tau:J\hookrightarrow\binom{[d]\times\lambda(k)}{s}\).
Thus, if \(\varphi(S)\) has distinct elements, then \(p_{B}\) has distinct Leibniz monomials and those monomials do not appear in \(p_{B}\) for any other \(S^{\prime}\).
All that is left to show is that there is at least one \(S\in\binom{[d]\times\lambda(k)}{s}\) such that \(|S_{\ell}|=|I_{\ell}|\ \forall\ell\in[d]\) and \(\varphi(S)\) has distinct elements. Since \(s\leq\binom{d}{k+1}\), there is at least one \(S\) such that \(\varphi(S)\) has unique elements and so we just need to restrict to \(I\) such that \(|S_{\ell}|=|I_{\ell}|\ \forall\ell\in[d]\). Thus, for all \(J\subset[n]\) such that \(|J|=s\), there is at least one \(I\subset[m]\) such that \(|I|=s\) and \(g_{I,J}\) is not identically zero, returning to the notation of Section 3.1. Let \(s=\min\{md,n,\binom{d}{k+1}\}\). Then we have show that
\[g=\prod_{\begin{subarray}{c}J\subset[n]\\ |J|\leq s\end{subarray}}\sum_{\begin{subarray}{c}I\subset[md]\\ |I|=|J\end{subarray}}g_{I,J}^{2}\]
is not identically zero. Thus, \(B^{T}\odot(AB^{T})^{(k)}\) has Kruskal rank at least \(\min\{m,n,\binom{d}{k+1}\}\) for generic \((A,B)\). The upper bound follows from the decomposition. \(\Box\)
### Polynomial Hadamard functions with Khatri-Rao products
Now we would like to combine the proofs of Theorems 4 and 6 to prove the following theorem.
**Theorem 7**: _Let \(K\in\mathbb{N}\) and \((c_{k})\subset\mathbb{R}\). Then_
\[B^{T}\odot\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{(k)}\]
_has Kruskal rank at least_
\[\min\left\{md,n,\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\left( \binom{d}{k+1}\right)\right\}\]
_for generic \((A,B)\in\mathbb{R}^{m\times d}\times\mathbb{R}^{n\times d}\). Moreover, the rank is bounded above by the same for all \((A,B)\)._
Proof: Here, our decomposition is
\[B^{T}\odot\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{(k)}\] \[= \sum_{\ell=1}^{d}\sum_{\begin{subarray}{c}k=0,\ldots,K\\ c_{k}\neq 0\end{subarray}}c_{k}\sum_{\tilde{k}\in\lambda(k)}\binom{k}{k_{1}, \ldots,k_{d}}\left(e_{\ell}\otimes a_{1}^{(k_{1})}\circ\cdots\circ a_{d}^{(k_{ d})}\right)\left(b_{\ell}\circ b_{1}^{(k_{1})}\circ\cdots\circ b_{d}^{(k_{d})} \right)^{T}\] \[\coloneqq\overline{A}D\overline{B}^{T}\]
with inner indices in \([d]\times\Lambda(K,(c_{k}))\) which has size
\[Nd=d\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\binom{\left(d\right)}{k}.\]
The rest of the proof proceeds exactly as in the proof of Theorem 6, except with \(\lambda(k)\) replaced with \(\Lambda(K,(c_{k}))\), \(\binom{d}{\binom{d}{k+1}}\) replaced with
\[\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\binom{d}{k+1},\]
and \(\lambda(k+1)\) replaced with
\[\{\vec{k}\in\mathbb{Z}_{+}^{d}\ |\ 1\leq k_{1}+\cdots+k_{d}\leq K+1,c_{k_{1}+ \cdots+k_{d}-1}\neq 0\},\]
which has size equal to the previous expression.
### Extension to real analytic Hadamard functions
Let \(\phi\) be a real analytic Hadamard function. Then, in particular, it has a convergent power series expansion centered at zero. Let \(c_{k}\) be the corresponding coefficients and let \(r\) be the radius of convergence. Define \(R\) as the set of \((A,B)\) such that all the entries of \(AB^{T}\) have absolute value smaller than \(r\). This is clearly open. Let \(I\subset[m]\) and \(J\subset[n]\) such that \(|I|=|J|=s\leq\min\{m,n\}\). Let \(K\in\mathbb{N}\). Define
\[g_{I,J}:R\rightarrow\mathbb{R}:(A,B) \mapsto\det_{I,J}\left(\sum_{k=0}^{\infty}c_{k}\left(AB^{T} \right)^{(k)}\right)\] \[\text{and }\tilde{g}_{I,J}:R\rightarrow\mathbb{R}:(A,B) \mapsto\det_{I,J}\left(\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{( k)}\right).\]
Let \(g_{I,J}^{K}\) be the Taylor expansion around zero of \(g_{I,J}\) with only the monomials that are in \(\tilde{g}_{I,J}\). By uniqueness, \(g_{I,J}^{K}=\tilde{g}_{I,J}\). By Theorem 4, if
\[s\leq\min\Bigg{\{}m,n,\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\} \binom{d}{k}\Bigg{\}},\]
then \(\tilde{g}_{I,J}\) is not identically zero. Thus, if we pick \(K\) such that
\[\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\left(\binom{d}{k}\right)\geq \min\{m,n\},\]
then \(g_{I,J}\) is not identically zero. Thus,
\[\bar{g}_{I,J}:\mathbb{R}^{m\times d}\times\mathbb{R}^{n\times d}\to\mathbb{R}: (A,B)\mapsto\det_{I,J}\phi\left(AB^{T}\right)\]
is not identically zero, and so \(g\), the product of all \(\bar{g}_{I,J}\) such that \(|I|=|J|\leq\min\{m,n\}\), is not identically zero. So, we have proved the following theorem.
**Theorem 8**: _If \(A\in\mathbb{R}^{m\times d}\), \(B\in\mathbb{R}^{n\times d}\), and \(\phi\) is real analytic but not a polynomial, then all order \(\min\{m,n\}\) or less minors of \(\phi(AB^{T})\) are nonzero for generic \((A,B)\)._
Now let \(I\subset[md]\) and \(J\subset[n]\) such that \(|I|=|J|=s\leq\min\{md,n\}\). Let \(K\in\mathbb{N}\). Define
\[g_{I,J}:R\to\mathbb{R}:(A,B)\mapsto\det_{I,J}\left(B^{T}\odot \sum_{k=0}^{\infty}c_{k}\left(AB^{T}\right)^{(k)}\right)\] \[\text{and }\tilde{g}_{I,J}:R\to\mathbb{R}:(A,B)\mapsto\det_{I,J} \left(B^{T}\odot\sum_{k=0}^{K}c_{k}\left(AB^{T}\right)^{(k)}\right).\]
Proceeding similarly, we get, by Theorem 7, that if we pick \(K\) such that
\[\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\left(\binom{d}{k}\right)\geq \min\{m,n\},\]
then there is an \(I\) such that \(g_{I,J}\) is not identically zero, and so
\[g=\prod_{\begin{subarray}{c}J\subset[n]\\ |J|\leq\min\{md,n\}\end{subarray}}\sum_{\begin{subarray}{c}I\subset[md]\\ |I|=|J|\end{subarray}}\det_{I,J}\left(B^{T}\odot\phi\left(AB^{T}\right)\right)\]
is not identically zero. So, we have proved the following theorem.
**Theorem 9**: _If \(A\in\mathbb{R}^{m\times d}\), \(B\in\mathbb{R}^{n\times d}\), and \(\phi\) is real analytic but not a polynomial, then \(B^{T}\odot\phi(AB^{T})\) has Kruskal rank \(\min\{md,n\}\) for generic \((A,B)\)._
## 5 Application to machine learning models
Here we apply the results about the rank of Khatri-Rao products of Hadamard functions to the memory capacity of machine learning models. In Section 5.1 we show that for any model that consists of a linear model applied to an embedding, if there is a point where the derivative is surjective, then the "doubled model" with twice the number of parameters is surjective. In Section 5.2 we combine this with the fact that the Jacobian of the two layer neural network has generically full rank to show that two layer neural networks have memory capacity equal to at least half their number of parameters.
### Memory capacity from Jacobian rank
Consider an embedding \(\bar{f}:\mathbb{R}^{k}\times\mathbb{R}^{d}\rightarrow\mathbb{R}^{m}\), which maps feature vectors \(x\in\mathbb{R}^{d}\) to embedding vectors \(\hat{x}\in\mathbb{R}^{m}\) based on parameters \(w\in\mathbb{R}^{k}\). Define the model \(\bar{F}:\mathbb{R}^{k}\times\mathbb{R}^{m}\times\mathbb{R}^{d}\rightarrow \mathbb{R}:(w,v,x)\mapsto\langle v,\bar{f}(w,x)\rangle\), which applies a linear model to embedding vectors. Also define the batch versions of these: \(f:\mathbb{R}^{k}\times\mathbb{R}^{d\times n}\rightarrow\mathbb{R}^{m\times n }:(w,X)\mapsto[f(w,x_{1})|\cdots|f(w,x_{n})]\) and \(F:\mathbb{R}^{k}\times\mathbb{R}^{m}\times\mathbb{R}^{d\times n}\rightarrow \mathbb{R}^{n}:(w,v,X)\mapsto v^{T}f(w,X)\).
As an example, for the two layer neural network model, we have \(\bar{f}:\mathbb{R}^{d\times m}\times\mathbb{R}^{d}\rightarrow\mathbb{R}^{m}:( W,x)\mapsto\psi(W^{T}x)\). Suppose that the derivative (i.e. Jacobian) with respect to the hidden layer \(\partial_{W}F\), is surjective at a point \((W_{0},v_{0},X)\), i.e. \(\text{rank}(\partial_{W}F(W_{0},v_{0},X))=n\). It turns out that we can actually show surjectivity of the model from this by doubling the number of parameters. Specifically, define \(\bar{g}:\mathbb{R}^{d\times 2m}\times\mathbb{R}^{d}\rightarrow\mathbb{R}^{2m}:([W \ U],x)\mapsto\psi([W\ U]^{T}x)=[\bar{f}(W,x);\bar{f}(U,x)]\) and \(\bar{G}:\mathbb{R}^{d\times 2m}\times\mathbb{R}^{2m}\times\mathbb{R}^{d} \rightarrow\mathbb{R}:([W\ U],[v;z],x)\mapsto\langle[v;z],\bar{g}([W\ U],x) \rangle=\bar{F}(W,v,x)+\bar{F}(U,z,x)\). Define their batch versions \(g\) and \(G\) as well. Then we have that \(G([W_{0}\ W_{0}],[v_{0};-v_{0}],X)=0\) and \(\text{rank}(\partial_{[W\ U]}G([W_{0}\ W_{0}],[v_{0};-v_{0}],X))=n\). The latter fact allows us to apply the Constant Rank Theorem [13, 4.12], which, along with the former fact, allows us to scale any \(y\in\mathbb{R}^{n}\) to be in the image of \(G(\cdot,[v_{0};-v_{0}],X)\). The scaling can then be absorbed into the linear model so that \(y\) is in the image of \(G(\cdot,[v;-v],X)\) for some \(v\). Thus, \(G(\cdot,\cdot,X)\) is surjective.
Going back to the general framework, we can define \(\bar{g}:\mathbb{R}^{2k}\times\mathbb{R}^{d}\rightarrow\mathbb{R}^{2m}:([w;u], x)\mapsto[\bar{f}(w,x);\bar{f}(u,x)]\) and \(\bar{G}:\mathbb{R}^{2k}\times\mathbb{R}^{2m}\times\mathbb{R}^{d}\rightarrow \mathbb{R}:([w;u],[v;z],x)\mapsto\langle[v;z],\bar{g}([w;u],[v;z],x)\rangle= \bar{F}(w,v,x)+\bar{F}(u,z,x)\) to get the same surjectivity result. But in order to apply the result, we need \(\bar{G}\) to actually be in the model class, as it is for the two layer neural network example.
Another example where the doubled model is actually in the model class is for deep neural networks. Let \(m_{0}=d\) and for \(\ell\in[L]\) define \(\bar{f}_{\ell}:\mathbb{R}^{m_{\ell-1}\times m_{\ell}}\times\mathbb{R}^{m_{ \ell-1}}\rightarrow\mathbb{R}^{m_{\ell}}:(W,x)\mapsto\psi(W^{T}x)\). Define \(\bar{f}:(W_{1},\ldots,W_{L},x)\mapsto\bar{f}_{L}(W_{L},\cdot)\circ\cdots\circ \bar{f}_{1}(W_{1},\cdot)(x)\). Then we can define \(\bar{g}_{1}:\mathbb{R}^{d\times 2m_{1}}\times\mathbb{R}^{d}\rightarrow\mathbb{R}^{2m_{1}}: ([W\ U],x)\mapsto[\bar{f}_{1}(W,x);\bar{f}_{1}(U,x)]\) and, for all \(\ell\in\{2,\ldots,L\}\), we can define \(\bar{g}_{\ell}:\mathbb{R}^{2m_{\ell-1}\times 2m_{\ell}}\times\mathbb{R}^{2m_{\ell-1}} \rightarrow\mathbb{R}^{2m_{\ell}}:(W\oplus U,[x;x^{\prime}])\mapsto[\bar{f}_{ \ell}(W,x);\bar{f}_{\ell}(U,x^{\prime})]\). Define \(\bar{g}:([W_{1}\ U_{1}],W_{2}\oplus U_{2},\ldots,W_{L}\oplus U_{L},x)\mapsto \bar{g}_{L}(W_{L}\oplus U_{L},\cdot)\circ\cdots\circ\bar{g}_{2}(W_{2}\oplus U _{2},\cdot)\circ\bar{g}_{1}([W_{1}\ U_{1}],\cdot)(x)\). Note that the surjectivity result we get is for a model with twice the number of parameters, but it is not the most general neural network model since the parameters for the middle layers are block-diagonal, i.e. \(W\oplus U\). However, surjectivity of this model clearly implies surjectivity
of the more general model, which has \(2m_{1}d+4\sum_{\ell=2}^{L}m_{\ell}m_{\ell-1}+2m_{L}\) parameters as opposed to the original \(m_{1}d+\sum_{\ell=2}^{L}m_{\ell}m_{\ell-1}+m_{L}\).
To summarize, for any model composed of an embedding followed by a linear model, surjectivity of the derivative at a single point implies surjectivity of its doubled model, which then has to be interpreted based on the structure of the model. This result, Theorem 11, follows from the following corollary of the Constant Rank Theorem.
**Lemma 10**: _Let \(F:\mathbb{R}^{k}\to\mathbb{R}^{n}\) be \(C^{1}\). If there exists \(x_{0}\in\mathbb{R}^{k}\) such that \(F(x_{0})=0\) and \(\text{rank}(DF(x_{0}))=n\), then for all \(y\in\mathbb{R}^{n}\) there are \(\epsilon>0\) and \(x\in\mathbb{R}^{k}\) such that \(F(x)=\epsilon y\)._
_Proof_ First, since \(n\) is the highest possible rank, the set of \(x\) such that \(\text{rank}(DF(x))=n\) is the pre-image of \(\mathbb{R}\backslash\{0\}\) under the rank condition function (the sum of the squares of the minors of order \(n\))--the rank condition function is continuous since \(F\) is \(C^{1}\) so this set is open. Thus, \(\text{rank}(DF(x))=n\) for all \(x\) near \(x_{0}\). In other words, \(F\) is a local \(C^{1}\)-submersion, so, by the Constant Rank Theorem [13, 4.12], there exist \(C^{1}\)-charts \((A,\theta)\) and \((B,\varphi)\) centered at \(x_{0}\) and \(F(x_{0})=0\) respectively, such that \(F(A)\subset B\) and \(\varphi\circ F\circ\theta^{-1}(x^{1},\ldots,x^{k})=(x^{1},\ldots,x^{n})\). This is shown in the following diagram.
\(\theta\) and \(\varphi\) are \(C^{1}\)-diffeomorphisms; \(A\), \(B\), \(\theta(A)\), and \(\varphi(B)\) are open; \(\theta(x_{0})=0\), \(F(x_{0})=0\), and \(\varphi(0)=0\); \(\hat{F}(x^{1},\ldots,x^{k})=(x^{1},\ldots,x^{n})\); and the diagram commutes. Thus, \(F(A)=B\) (since \(\theta\) and \(\varphi\) are bijective and \(\hat{F}\) is surjective). Let \(y\in\mathbb{R}^{n}\). Since \(0\in B\), there exists \(\epsilon>0\) such that \(\epsilon y\in B\) and so there exists \(x\in A\) such that \(F(x)=\epsilon y\). \(\square\)
**Theorem 11**: _Let \(f:\mathbb{R}^{k}\to\mathbb{R}^{n\times m}\) be \(C^{1}\). Define \(g:\mathbb{R}^{k}\times\mathbb{R}^{k}\to\mathbb{R}^{n\times 2m}:(w,u)\mapsto[f(w)\ f(u)]\). For all \(v,z\in\mathbb{R}^{m}\), define \(F_{v}:\mathbb{R}^{k}\to\mathbb{R}^{n}:w\mapsto f(w)v\) and \(G_{v,z}:\mathbb{R}^{k}\times\mathbb{R}^{k}\to\mathbb{R}^{n}:(w,u)\mapsto g(w, u)[v;z]\). If there exists \(v_{0}\) and \(w_{0}\) such that \(\text{rank}(DF_{v_{0}}(w_{0}))=n\), then \(G\) is surjective as a function of \((v,z)\) and \((w,u)\)._
_Proof_ Let \(y\in\mathbb{R}^{n}\). Observe
\[G_{v,z}(w,u) =g(w,u)[v;z]\] \[=f(w)v+f(u)z\] \[=F_{v}(w)+F_{z}(u).\]
So \(G_{v_{0},-v_{0}}(w_{0},w_{0})=0\) and \(\text{rank}(DG_{v_{0},-v_{0}}(w_{0},w_{0}))=n\). Applying Lemma 10, there exists \(\epsilon>0\) and \((w,u)\) such that \(G_{v_{0},-v_{0}}(w,u)=\epsilon y\). Set \(v=v_{0}/\epsilon\) and \(z=-v_{0}/\epsilon\). Then \(G_{v,z}(w,u)=y\). \(\square\)
### Memory capacity of two layer neural network
In Theorems 7 and 9 we derived the generic rank of the Jacobian of the two layer neural network, with respect to the hidden layer, for real analytic activation function. In Theorem 11 we showed that for many models, including two layer neural networks, surjectivity of the derivative at a point implies surjectivity of the doubled model. Combining these, we get the following result about the memory capacity of two layer neural networks.
**Theorem 12**: _Define \(h:\mathbb{R}^{d\times m}\times\mathbb{R}^{m}\times\mathbb{R}^{d\times n}:(W,v,X )\mapsto\psi(X^{T}W)v\) where \(\psi\) is a real analytic function applied coordinate-wise. In the special case of \(\psi(x)=\sum_{k=0}^{K}c_{k}x^{k}\), assume \(\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\left(\binom{d}{k+1}\right)\geq n\). If \(md\geq 2n\) and \(m\) is even, then \(h(\cdot,\cdot,X)\) is surjective for all \(X\) except on a measure zero and closed set._
_Proof_ By Theorem 7 or 9, the set of \((W,X)\in\mathbb{R}^{d\times m/2}\times\mathbb{R}^{d\times n}\) for which \(\psi^{\prime}(W^{T}X)\odot X\) has rank \(<n\) is measure zero and closed. Letting \(v_{0}\in\mathbb{R}^{m/2}\) be the vector of ones and applying Theorem 11 proves the result. \(\Box\)
Note that the additional assumption when \(\psi\) is a polynomial is actually quite mild. If \(\psi\) is a polynomial with all of its coefficients nonzero, then the assumption becomes \(\binom{d+K+1}{d}\geq n+1\) by Zhu's Theorem (see Section 2.3). Or, if \(\psi\) is the monomial \(x^{K}\), then the assumption becomes \(\binom{d+K}{d-1}\geq n\). As an example, the assumption is satisfied if \(d=1e2\), \(n=1e5\), and \(\psi=x^{2}\).
Also, Theorem 12 is actually tight up to a factor of \(2(1+1/d)\approx 2\) by Sard's theorem.
**Theorem 13**: _Define \(h:\mathbb{R}^{d\times m}\times\mathbb{R}^{m}\times\mathbb{R}^{d\times n}:(W,v,X )\mapsto\psi(X^{T}W)v\) where \(\psi\) is a continuously differentiable function applied coordinate-wise. If \(m(d+1)<n\), then, for all \(X\), \(h(\cdot,\cdot,X)\) is not surjective._
_Proof_ If \(m(d+1)<n\) then, by Sard's theorem [13, Thm. 6.10], the image of \(h(\cdot,\cdot,X)\) has measure zero in \(\mathbb{R}^{n}\). In particular, this implies the result. \(\Box\)
## 6 Conclusion
In this paper we proved results about the ranks of \(\phi(W^{T}X)\) and \(\phi(W^{T}X)\odot X\) for real analytic Hadamard functions \(\phi\). In particular, if \(\phi\) is either a polynomial with sufficiently high degree or not a polynomial, then both objects are full rank for all \((W,X)\) except on the zero set of a non-identically zero analytic function, and so the set of exceptions is measure zero and closed. In the context of machine learning, this rank result implies that a two layer neural network model is able to interpolate sets of \(n\) data points almost everywhere if the number of trainable parameters is \(\geq 2n(1+1/d)\), which is tight up to the factor of \(2(1+1/d)\). We hope that viewing the rank of the neural network Jacobian from the perspective of analytic functions of several variables
leads to a better understanding of the convergence and generalization properties of two layer neural networks.
Acknowledgments.We would like to thank Jason Altschuler for pointing out the references [1] and [3]. We would also like to thank the authors of [21] for helpful discussions concerning their findings. This work was partially funded by a UBC DSI Postdoctoral Fellowship and NSERC Discovery Grant No. 2021-03677.
## Appendix A Non-polynomial real analytic activations
After corresponding with the authors of [21], we came to understand that the following was the idea behind the proof of their Lemma E.1 (typos on top of convoluted presentation had previously prevented us from gleaning this):
Suppose \(d\mid n\). Let \(A=[a_{1}|\cdots|a_{d}]\in\mathbb{R}^{m\times d}\) and
\[B=\begin{bmatrix}b_{1}&&\\ &\ddots&\\ &&b_{d}\end{bmatrix}\] (A1)
where each \(b_{i}\in\mathbb{R}^{n/d}\). Then
\[B^{T}\odot\phi(AB^{T}) =B^{T}\odot\phi\left([a_{1}b_{1}^{T}|\cdots|a_{d}b_{d}^{T}]\right)\] \[=\begin{bmatrix}b_{1}^{T}&&\\ &\ddots&\\ &&b_{d}^{T}\end{bmatrix}\odot\left[\phi\left(a_{1}b_{1}^{T}\right)|\cdots| \phi\left(a_{d}b_{d}^{T}\right)\right]\] \[=\begin{bmatrix}b_{1}^{T}\odot\phi\left(a_{1}b_{1}^{T}\right)& \\ &&\ddots&\\ &&b_{d}^{T}\odot\phi\left(a_{d}b_{d}^{T}\right)\end{bmatrix}.\]
Since generic \(b_{i}\) have no zeros, the problem comes down to the generic rank of the \(\phi(a_{i}b_{i}^{T})\). [21] use that the \(\phi(a_{i}b_{i}^{T})\) have generically full rank if \(\phi\) is not a polynomial. This is a corollary of Theorem 8, which has been known for some time.
While Zhang et al [21] do not explicitly consider polynomials, we can extend to polynomials by applying Theorem 4, which has also been known for some time. Consider \(\phi=\sum_{k=0}^{K}c_{k}x^{k}\). Note that \(d=1\) here and so, by Theorem 4, the generic rank of \(\phi(a_{i}b_{i}^{T})\) is precisely
\[\min\bigg{\{}m,\frac{n}{d},\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\} \bigg{\}}.\]
Thus, the generic rank of \(B^{T}\odot\phi(AB^{T})\) where \(B\) has the form of Eq. (A1) is exactly
\[\min\bigg{\{}md,n,d\sum_{k=0}^{K}\mathbb{I}\left\{c_{k}\neq 0\right\}\bigg{\}},\] (A2)
which is much smaller than the generic rank which we derived in Theorem 7. In particular, suppose \(\textit{md}\geq n\). If all the \(c_{k}\) are nonzero, then \(K\) has to be greater than or equal to \(n/d-1\) in order for Eq. (A2) to equal \(n\). Furthermore, if \(\phi\) is a monomial, such as \(x^{K}\), then Eq. (A2) will not equal \(n\) for any \(K\in\mathbb{N}\).
To compare this to our Theorem 7, consider the example \(d=1e2\), \(n=1e5\), and \(m\geq 1e3\): \(\phi=x^{2}\) is sufficient for the generic rank in Theorem 7 to be \(n\), while it is necessary that \(\phi\) has at least \(1000\) nonzero coefficients for Eq. (A2) to be \(n\).
## Appendix B Inner product decompositions
Using the result from Section 3.2, we have an immediate corollary. If the rows of \(\widetilde{A}\in\mathbb{R}^{m\times N}\) and \(\widetilde{B}\in\mathbb{R}^{n\times N}\) are arbitrary vectors in a \(d\)-dimensional subspace \(V\subset\mathbb{R}^{N}\), then the generic rank of \(\widetilde{AB}^{T}\) is the same as the generic rank of \(AB^{T}\). In particular, we can apply this to the following decomposition from Lemma 4.4 of [3],
\[\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}=\left[\bigoplus_{\begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}c_{k}a_{1}^{\otimes k}\right|\cdots\bigg{|}\bigoplus_{ \begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}c_{k}a_{m}^{\otimes k}\right]^{T}\left[\bigoplus_{ \begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}b_{1}^{\otimes k}\right|\cdots\bigg{|}\bigoplus _{\begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}b_{n}^{\otimes k}\right]\]
where \(A=[a_{1}|\cdots|a_{m}]^{T}\) and \(B=[b_{1}|\cdots|b_{n}]^{T}\). The vectors in this decomposition are arbitrary vectors in
\[\bigoplus_{\begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}\text{Sym}^{k}(\mathbb{R}^{d})\]
where \(\text{Sym}^{0}(\mathbb{R}^{d})=\mathbb{R}\) and, for \(k\in\mathbb{N}\), \(\text{Sym}^{k}(\mathbb{R}^{d})\) is the vector space of symmetric tensors of order \(k\) defined on \(\mathbb{R}^{d}\). The dimension of this space is
\[\sum_{\begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}\binom{d}{k},\]
proving our Theorem 4.
It turns out we can construct a similar decomposition for \(B^{T}\odot\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}\). Observe that the \(((i_{1},i_{2}),j)\) element is
\[\langle e_{i_{1}},b_{j}\rangle\sum_{k=0}^{K}c_{k}\langle a_{i_{2}},b_{j} \rangle^{k}=\langle e_{i_{1}},b_{j}\rangle\sum_{k=0}^{K}c_{k}\langle a_{i_{2}} ^{\otimes k},b_{j}^{\otimes k}\rangle\]
\[=\left\langle e_{i_{1}},b_{j}\right\rangle\Bigg{\langle}\bigoplus_{ \begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}c_{k}a_{i_{2}}^{\otimes k},\bigoplus_{ \begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}b_{j}^{\otimes k}\Bigg{\rangle}\] \[=\left\langle e_{i_{1}}\otimes\bigoplus_{\begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}c_{k}a_{i_{2}}^{\otimes k},\bigoplus_{ \begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}b_{j}^{\otimes(k+1)}\right\rangle\]
and so we can write
\[B^{T}\odot\sum_{k=0}^{K}c_{k}(AB^{T})^{(k)}=\begin{bmatrix} \widetilde{A}\\ \ddots\\ \widetilde{A}\end{bmatrix}^{T}\begin{bmatrix}\bigoplus_{\begin{subarray}{c}k=0 \\ c_{k}\neq 0\end{subarray}}^{K}b_{1}^{\otimes(k+1)}\Big{|}\cdots\Big{|}\bigoplus _{\begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}b_{n}^{\otimes(k+1)}\end{bmatrix}\] (B3)
where
\[\widetilde{A}=\begin{bmatrix}\bigoplus_{\begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}c_{k}a_{1}^{\otimes k}\Big{|}\cdots\Big{|}\bigoplus_{ \begin{subarray}{c}k=0\\ c_{k}\neq 0\end{subarray}}^{K}c_{k}a_{m}^{\otimes k}\end{bmatrix},\]
but this does not reduce to \(AB^{T}\).
|
2302.13143 | Ensemble learning for Physics Informed Neural Networks: a Gradient
Boosting approach | While the popularity of physics-informed neural networks (PINNs) is steadily
rising, to this date, PINNs have not been successful in simulating multi-scale
and singular perturbation problems. In this work, we present a new training
paradigm referred to as "gradient boosting" (GB), which significantly enhances
the performance of physics informed neural networks (PINNs). Rather than
learning the solution of a given PDE using a single neural network directly,
our algorithm employs a sequence of neural networks to achieve a superior
outcome. This approach allows us to solve problems presenting great challenges
for traditional PINNs. Our numerical experiments demonstrate the effectiveness
of our algorithm through various benchmarks, including comparisons with finite
element methods and PINNs. Furthermore, this work also unlocks the door to
employing ensemble learning techniques in PINNs, providing opportunities for
further improvement in solving PDEs. | Zhiwei Fang, Sifan Wang, Paris Perdikaris | 2023-02-25T19:11:44Z | http://arxiv.org/abs/2302.13143v2 | # Ensemble learning for Physics Informed Neural Networks: a Gradient Boosting approach
###### Abstract
While the popularity of physics-informed neural networks (PINNs) is steadily rising, to this date, PINNs have not been successful in simulating multi-scale and singular perturbation problems. In this work, we present a new training paradigm referred to as "gradient boosting" (GB), which significantly enhances the performance of physics informed neural networks (PINNs). Rather than learning the solution of a given PDE using a single neural network directly, our algorithm employs a sequence of neural networks to achieve a superior outcome. This approach allows us to solve problems presenting great challenges for traditional PINNs. Our numerical experiments demonstrate the effectiveness of our algorithm through various benchmarks, including comparisons with finite element methods and PINNs. Furthermore, this work also unclocks the door to employing ensemble learning techniques in PINNs, providing opportunities for further improvement in solving PDEs.
PDE Physics-informed neural networks Gradient boosting Ensemble learning
## 1 Introduction
Physics informed neural networks have recently emerged as an alternative to traditional numerical solvers for simulations in fluids mechanics [1, 2], bio-engineering [3, 4], meta-material design [5, 6], and other areas in science and engineering [7, 8]. However, PINNs using fully connected, or some variants architectures such as Fourier feature networks [9], fail to accomplish stable training and produce accurate predictions at whites, especially when the underlying PDE solutions contain high-frequencies or multi-scale features [10, 11]. To mitigate this pathology, Krishnapriyan _et. al._[12] proposed a sequence-to-sequence learning method for time-dependent problems, which divide the time domain into sub-intervals and solve the problem progressively on each them. This method avoids the pollution of the underlying solution due to the temporal error accumulation. Wang _et. al._[13] elaborated the reason that the PINNs fail to train from a neural tangent kernel perspective, and proposed an adaptive training strategy to improve the PINNs' performance. An empirical learning-rate annealing scheme has been proposed in Wang _et. al._[14], which utilizes the back-propagated gradient statistics during training to adaptively assign importance weights to different terms in a PINNs loss function, with the goal of balancing the magnitudes of the gradients in backward propagation. Although all of these works were demonstrated to produce significant and consistent improvements in the stability and accuracy of PINNs, the fundamental reasons behind the practical difficulties of training fully-connected PINNs still remain unclear [10].
Besides PINNs, many other machine learning tasks suffer from the same issues, and some of these issues have been resolved by gradient boosting method. The idea of gradient boosting is blending several weak learners into a fortified one that gives better predictive performance than could be obtained from any of the constituent learners alone [15]. For example, Zhang and Haghani [16] proposes a gradient-boosting tree-based travel time prediction method, driven by the successful application of random forest in traffic parameter prediction, to uncover hidden patterns in travel time data to enhance the accuracy and interpretability of the model. Callens _et. al._[17] used gradient boosting trees to improve wave forecast at a specific location whose RMSE values in average \(8\%\) to \(11\%\) lower for the correction of significant wave height and peak wave period. Recently, many researchers have contributed to gradient boosting
method and further improved its performance. Friedman _et. al._[18] shows that both the approximation accuracy and execution speed of gradient boosting can be substantially improved by incorporating randomization into the procedure, and this randomized approach also increases robustness against overcapacity of the base learner. Ke [19] found that the efficiency and scalability of Gradient Boosting Decision Tree (GBDT) are unsatisfactory when the feature dimension is high and data size is large and a greedy algorithm has been used to effectively reduce the number of features without hurting the accuracy of split point determination by much and thus solve the issue.
Inspired by the above-mentioned literature review, we arrive at our proposed method in this paper. In this work, we present a gradient boosting physics informed neural networks (GB PINNs), which adopts a gradient boosting idea to approximate the underlying solution by a sequence of neural networks and train the PINNs progressively. Specifically, our main contributions can be summarized into the following points:
1. A simple implementation of the gradient boosting method, which can easily be integrated into existing PINNs code with minimal modifications.
2. The assembly of several weak PDE predictors to form a strong predictor, resulting in increased flexibility for solving intractable problems.
3. Low sensitivity to the choice of neural networks and their arrangement, resulting in fewer efforts required for fine-tuning hyperparameters.
4. The flexibility to combine with other techniques, such as Fourier features, making it a versatile approach for PINNs.
We introduce some preliminaries for key ingredients of our algorithm in section 2. Then we present our algorithm with motives in section 3. Numerical experiments are shown in section 4 to verify our algorithm. We discuss our algorithm and conclude the paper in section 5.
## 2 Preliminaries
In this section, we will provide a brief overview of the related topics that are relevant to the proposed algorithm in this paper. For a more in-depth understanding of these topics, we encourage readers to refer to the original papers cited below.
### Physics informed neural networks
PINNs are a method for inferring a continuous latent function \(u(\mathbf{x})\) that serves as the solution to a nonlinear PDE of the form:
\[\mathcal{N}[u](\mathbf{x}) =0,\quad\text{ in }\Omega, \tag{1}\] \[\mathcal{B}[u](\mathbf{x}) =0,\quad\text{ on }\partial\Omega, \tag{2}\]
where \(\Omega\) is an open, bounded set in \(\mathbb{R}^{d}\) with a piecewise smooth boundary \(\partial\Omega\), \(\mathbf{x}\in\mathbb{R}^{d}\), and \(\mathcal{N}\) and \(\mathcal{B}\) are nonlinear differential and boundary condition operators, respectively.
The solution to the PDE is approximated by a deep neural network, \(u_{\theta}\), which is parameterized by \(\theta\). The loss function for the network is defined as:
\[L(u;\theta)=\frac{\omega_{e}}{N_{p}}\sum_{i=1}^{N_{p}}|\mathcal{N}[u_{\theta} ](\mathbf{x}_{i}^{p})|^{2}+\frac{\omega_{b}}{N_{b}}\sum_{i=1}^{N_{b}}|\mathcal{B} [u_{\theta}](\mathbf{x}_{i}^{b})|^{2}, \tag{3}\]
where \(\{\mathbf{x}_{i}^{p}\}_{i=1}^{N_{p}}\) and \(\{\mathbf{x}_{i}^{b}\}_{i=1}^{N_{b}}\) are the sets of points for the PDE residual and boundary residual, respectively, and \(\omega_{e}\) and \(\omega_{b}\) are the weights for the PDE residual loss and boundary loss, respectively. The neural network \(u_{\theta}\) takes the coordinate \(\mathbf{x}\) as input and outputs the corresponding solution value at that location. The partial derivatives of the \(u_{\theta}\) with respect to the coordinates at \(\mathcal{N}\) in (3) can be readily computed to machine precision using reverse mode differentiation [20].
The loss function \(L(u;\theta)\) is typically minimized using a stochastic gradient descent algorithm, such as Adam, with a batch of interior and boundary points generated to feed the loss function. The goal of this process is to find a set of neural network parameters \(\theta\) that minimize the loss function as much as possible.
It is worth noting that the abstract PDE problem in (1)-(2) can easily be extended to time-dependent cases by considering one component of \(\mathbf{x}\) as a temporal variable. In this case, one or more initial conditions should be included in the PDE system and additional initial condition constraints should be added to the loss function (3).
### Gradient boosting machines
Gradient Boosting (GB) is a powerful machine learning technique that is commonly used in regression and classification tasks. It is an additive ensemble of weak prediction models, similar to AdaBoost, but with a key difference - unlike other ensemble algorithms, GB does not have trainable weights, and the sub-models are trained sequentially instead of in parallel. For the sake of simplicity, in the rest of the paper, we will use \(f(x;\theta)\) to denote a general neural network \(f\) with input \(x\) and parameterized by \(\theta\).
Given a neural network \(f(x;\theta)\) and a training dataset, the loss function \(L(f;\theta)\) is defined as the sum of the individual losses for each sample, as follows:
\[L(f;\theta)=\sum_{i=1}^{N}L(y_{i},f(x_{i};\theta)),\]
where \(N\) is the total number of samples in the dataset, \(y_{i}\) is the true label for sample \(x_{i}\), and \(f(x_{i};\theta)\) is the predicted label for sample \(x_{i}\).
To minimize this loss function, a common approach is to use the stochastic gradient descent algorithm. This algorithm updates the network's parameters, \(\theta\), iteratively using the following update rule:
\[\theta\leftarrow\theta-\gamma\frac{\partial}{\partial\theta}L(f;\theta), \tag{4}\]
where \(\gamma\) is a user-specified learning rate that controls the step size of the updates.
The goal of the gradient boosting (GB) method is to minimize the loss function \(L(f;\theta)\) with respect to the neural network function \(f\). GB method assumes that the surrogate model can be represented in the following iterative form:
\[f_{m}(\mathbf{x};\Theta_{m})=f_{m-1}(\mathbf{x};\Theta_{m-1})+\rho_{m}h_{m}(\mathbf{x}; \theta_{m}),\quad\text{ for }m=1,2,3,\cdots, \tag{5}\]
where \(f_{0}(\mathbf{x};\theta_{0})\) is a pre-selected baseline neural network, \(\rho_{m}\) is the learning rate, \(f_{m}(\mathbf{x};\Theta_{m-1})\) is parameterized by \(\Theta_{m}=\bigcup_{i=0}^{m}\theta_{m}\), and \(h_{m}(\mathbf{x};\theta_{m})\) is a neural network designed to enhance the accuracy of the predictor \(f_{m-1}(\mathbf{x};\Theta_{m-1})\). The gradient descent algorithm is used to choose \(h_{m}(\mathbf{x};\theta_{m})\), which is defined as:
\[h_{m}(\mathbf{x};\theta_{m})=-\frac{\partial}{\partial f_{m-1}(\mathbf{x};\Theta_{m- 1})}L(f_{m-1};\Theta_{m-1}). \tag{6}\]
Therefore, the model update rule is defined as:
\[f_{m}(\mathbf{x};\Theta_{m})=f_{m-1}(\mathbf{x};\Theta_{m-1})-\rho_{m}\frac{\partial }{\partial f_{m-1}(\mathbf{x};\Theta_{m-1})}L(f_{m-1};\Theta_{m-1}). \tag{7}\]
In this fashion, the corresponding loss at the \(m\)-th step reads
\[L(f_{m};\Theta_{m})=L(f_{m-1}+\rho_{m}h_{m};\Theta_{m}). \tag{8}\]
The technique outlined in this construction is commonly referred to as a GB method. The update function, \(h_{m}(\mathbf{x};\theta_{m})\) in equation (6), is similar in nature to the gradient vector in equation (4), however, GB operates by taking the gradient with respect to the function, rather than the parameter vector as traditional gradient descent does. This distinction is the reason why we refer to GB as a method that descends the gradient in function space. For further information on gradient boosting methods, please refer to the reference [21]. Furthermore, it is worth noting that in the context of PINNs, this method has been adapted to a simpler form that is easily implementable.
## 3 Gradient boosting physics informed neural networks
Despite a series of promising results in the literature [22; 4; 11; 1; 2], the original formulation of PINNs proposed by Raissi _et. al._[23] has been found to struggle in constructing an accurate approximation of the exact latent solution. The reasons for this remain poorly understood. However, some observations in the literature can be used to infer potential solutions to this issue. One such observation is that the prediction error in PINNs is often of high frequency, with small and intricate structures, as seen in figures 4(b) and 6(a) and (b) of [13]. As demonstrated in [9], high-frequency functions can be learned relatively easily using Fourier features. Based on these findings, it is natural to consider using a multi-layer perceptrons (MLPs) as a baseline structure in PINNs, followed by a Fourier feature network, to further minimize the error. This idea led to the development of GB PINNs.
The proposed method, referred to as GB PINNs, utilizes a sequence of neural networks in an iterative update procedure to gradually minimize the loss function. As shown in equation (6), the update model \(h_{m}(\mathbf{x};\theta_{m})\) is defined by the
gradient of the loss with respect to the previous output \(f_{m-1}\). However, in the context of PINNs, the PDE residual loss in (3) typically includes gradients of the outputs with respect to the inputs. This necessitates the computation of twisted gradients, which is a unique characteristic of this approach. For example
\[\frac{\partial}{\partial f(\mathbf{x};\theta)}\left[\left(\frac{\partial f(\mathbf{x}; \theta)}{\partial\mathbf{x}}\right)^{2}\right],\]
which is definitely not elementary and should be avoided. Despite the mathematical validity of the gradient
\[\frac{\partial}{\partial f_{m-1}(\mathbf{x};\Theta_{m-1})}L(f_{m-1};\Theta_{m-1}),\]
it can be challenging to compute it using AD due to the fact that \(L(f_{m-1};\theta)\) is typically a leaf node in the computational graph.
Fortunately, we can still utilize the formulation in equation (8) to establish an appropriate GB algorithm for PINNs. After the training of the \((m-1)\)-th step is completed, we add an additional pre-selected neural network \(\rho_{m}h_{m}(\mathbf{x};\theta_{m})\) to the previous predictor \(f_{m-1}(\mathbf{x};\Theta_{m-1})\) and subsequently apply gradient descent with respect to the parameters \(\theta_{m}\). This iterative procedure allows us to gradually minimize the loss and improve the accuracy of the predicted solution.
It is important to note that the neural networks utilized in the proposed GB PINNs algorithm do not need to possess a consistent structure. In fact, they can be composed of a variety of surrogate models, as long as they have the same input and output dimensions. Examples of such models include MLPs, Fourier feature networks, radial basis neural networks, and even finite element representations. This flexibility allows for a more versatile approach to minimizing the loss and improving the accuracy of the approximation to the exact latent solution.
As highlighted in [13], the neural tangent kernel of wide and deep neural networks remains relatively stable during the training process, which can impede the ability to learn solutions with sharp gradients. However, it has been proposed that by decreasing the size of the network, such issues can be addressed. This gives rise to the idea of utilizing a small network for the initial approximation of the solution, and then progressively refining it using larger networks. 1
Footnote 1: It is worth noting that the proposed organization of neural networks is merely a rough idea and may not always yield the best performance. The choice and arrangement of neural networks may vary depending on the specific problem at hand. The numerical experiments will provide further insights into the optimal configuration of neural networks for a given problem.
In GB training, the term \(\rho_{m}\) in equation (5) serves as a learning rate in the function space gradient descent, and it also adjusts the magnitude of \(h_{m}(\mathbf{x};\theta_{m})\). In PINNs scenarios, once the training of \(f_{m-1}(\mathbf{x};\Theta_{m-1})\) is complete, we already have a decent predictor, which implies that the relative error between the current predictor and the ground truth (for example, relative \(l^{2}\) error defined below) is assumed to be small. The additive model \(h_{m}(\mathbf{x};\theta_{m})\) is then used to handle this error, thus it is reasonable to assume that the magnitude of \(h_{m}(\mathbf{x};\theta_{m})\) decreases over iteration step \(m\). As a result, it is also reasonable to assume that the \(\rho_{m}\) gradually decreases over \(m\). In the experiments below, we will assume that the \(\rho_{m}\) exponentially decays, which is similar to traditional gradient descent methods.
The proposed algorithm can be summarized as follows:
```
0: A baseline neural network \(f_{0}(\mathbf{x};\theta_{0})\) and an ordered neural network set \(\{h_{i}(\mathbf{x};\theta_{i})\}_{i=1}^{m}\) that contains models going to be trained in sequence; A set of learning rate \(\{\rho_{i}\}_{i=0}^{m}\) that correspond to \(\{f_{0}(\mathbf{x};\theta_{0})\}\cup\{h_{i}(\mathbf{x};\theta_{i})\}_{i=1}^{m}\). Usually, \(\rho_{0}=1\) and \(\rho_{i}\) is decreasing in \(i\); Set \(f_{i}(\mathbf{x};\Theta_{i})=f_{i-1}(\mathbf{x};\Theta_{i-1})+\rho_{i}h_{i}(\mathbf{x}; \theta_{i}),\quad\text{ for }i=1,2,3,\cdots,m\). Given PDEs problem (1)-(2), establish the corresponding loss (3).
0:
1: Train \(f_{0}(\mathbf{x};\theta_{0})=\rho_{0}f_{0}(\mathbf{x};\theta_{0})\) to minimize loss (3).
2:for\(i=1\) to m do
3: In \(f_{i}(\mathbf{x};\Theta_{i})=f_{i-1}(\mathbf{x};\Theta_{i-1})+\rho_{i}h_{i}(\mathbf{x}; \theta_{i})\), set trainable parameters as \(\theta_{i}\). Train \(f_{i}(\mathbf{x};\Theta_{i})\) to minimize loss (3).
4:endfor
5:return\(f_{m}(\mathbf{x};\Theta_{m})\) as a predictor of the solution of (1)-(2) for any point in \(\overline{\Omega}\).
```
**Algorithm 1** Gradient boosting physics informed neural network.
The proposed algorithm can be summarized as follows:
```
0: A baseline neural network \(f_{0}(\mathbf{x};\theta_{0})\) and an ordered neural network set \(\{h_{i}(\mathbf{x};\theta_{i})\}_{i=1}^{m}\) that contains models going to be trained in sequence; A set of learning rate \(\{\rho_{i}\}_{i=0}^{m}\) that correspond to \(\{f_{0}(\mathbf{x};\theta_{0})\}\cup\{h_{i}(\mathbf{x};\theta_{i})\}_{i=1}^{m}\). Usually, \(\rho_{0}=1\) and \(\rho_{i}\) is decreasing in \(i\); Set \(f_{i}(\mathbf{x};\Theta_{i})=f_{i-1}(\mathbf{x};\Theta_{i-1})+\rho_{i}h_{i}(\mathbf{x}; \theta_{i}),\quad\text{ for }i=1,2,3,\cdots,m\). Given PDEs problem (1)-(2), establish the corresponding loss (3).
0:
1:for\(i=1\) to m do
2: In \(f_{i}(\mathbf{x};\Theta_{i})=f_{i-1}(\mathbf{x};\Theta_{i-1})+\rho_{i}h_{i}(\mathbf{x}; \theta_{i})\), set trainable parameters as \(\theta_{i}\). Train \(f_{i}(\mathbf{x};\Theta_{i})\) to minimize loss (3).
3:endfor
5:return\(f_{m}(\mathbf{x};\Theta_{m})\) as a predictor of the solution of (1)-(2) for any point in \(\overline{\Omega}\).
```
**Algorithm 2** Gradient boosting physics informed neural network.
The proposed algorithm, described in Algorithm 1, utilizes a sequence of neural networks and an iterative update procedure to minimize the loss gradually. At each iteration step \(i\), the forward prediction relies on the union parameter
set \(\Theta_{i}\), while the backward gradient propagation is only performed on \(\theta_{i}\). This results in a mild increase in computational cost during the training of GB iteration. The simplicity of this algorithm allows practitioners to easily transfer their PINNs codes to GB PINNs'. In the following section, we will demonstrate that this simple technique can enable PINNs to solve many problems that were previously intractable using the original formulation of Raissi _et. al._[23].
Additionally, the proposed GB PINNs algorithm also introduces another dimension of flexibility in terms of network architecture design, namely the combination of different neural networks. This opens up new opportunities for fine-tuning the architecture to minimize PDE residual losses and improve overall predictive accuracy. As shown in the following section, the performance of GB PINNs is relatively insensitive to the specific choice and arrangement of networks, as long as their capacity is sufficient.
## 4 Numerical Experiments
In this section, we will demonstrate the effectiveness of the proposed GB PINNs algorithm through a comprehensive set of numerical experiments. To simplify the notation, we use a tuple of numbers to denote the neural network architecture, where the tuple represents the depth and width of the layers. For example, a neural network with a two-dimensional input and a one-dimensional output, as well as two hidden layers with width \(100\) is represented as \((2,100,100,1)\). Our default experimental setup is summarized in Table 4, and will be used in all experiments unless otherwise specified.
To quantify the model's accuracy, we use the relative \(l^{2}\) error over a set of points \(\{x_{i}\}_{i=1}^{N}\):
\[\text{Error}=\frac{\sum_{i=1}^{N}|u_{pred}(x_{i})-u_{true}(x_{i})|^{2}}{\sum _{i=1}^{N}|u_{true}(x_{i})|^{2}}.\]
### 1D singular perturbation
In this first example, we utilize GB PINNs to solve the following 1D singular perturbation problem.
\[-\varepsilon^{2}u^{\prime\prime}(x)+u(x) =1,\qquad\text{ for }x\in(0,1),\] \[u(0) =u(1) =0.\]
The perturbation parameter, \(0<\varepsilon\ll 1\), is set to \(10^{-4}\) in this case. The exact solution to this problem is given by
\[u(x)=1-\frac{e^{-x/\varepsilon}+e^{(x-1)/\varepsilon}}{1+e^{-1/\varepsilon}}.\]
Despite the boundedness of the solution, it develops boundary layers at \(x=0\) and \(x=1\) for small values of \(\varepsilon\), a scenario in which traditional PINNs have been known to perform poorly.
To evaluate the performance of GB PINNs, we used a series of fully connected network structures sequentially \((1,50,1)\), \((1,100,1)\), \((1,100,100,1)\), \((1,100,100,1)\) for the baseline and update neural networks, followed by a Fourier feature neural network \((1,50,50,1)\) with frequencies ranging from \(1\) to \(10\). The details of the Fourier feature method used in this study can be found in the appendix 6.1. The step size \(\rho_{m}\) in (5) was set to \(0.5^{i}\), where \(i=0,1,\cdots,5\) is the model index.
For each GB iteration, we train \(10,000\) steps using a dataset of \(10,000\) uniform random points in \((0,1)\). The weights in the loss function (3) are set to \(\omega_{e}=1\) and \(\omega_{b}=10\), respectively, and the batch size for PDE residual computation is \(10,000\).
The output of GB PINNs is shown in Figure 1, where the relative \(l^{2}\) error is found to be \(0.43\%\). The boundary layers at \(x=0\) and \(x=1\) are clearly visible in the solution, which is a result of the thinness of the layers and the almost right
\begin{table}
\begin{tabular}{l l} \hline \hline Name & Value \\ \hline Activation function & GeLU \\ Method to initialize the neural network & Xavier \\ Optimizer & Adam \\ learning rate & \(10^{-3}\) \\ learning rate decay period & \(10,000\) \\ learning rate decay rate & \(0.95\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Default Experiment Set up
angle curvature of the solution at these points. Despite the singularity present in the solution, GB PINNs were able to provide an accurate solution for this problem. To further highlight the contribution of GB PINNs in this example, an ablation study was conducted. A vanilla PINNs approach, using a network structure of \((1,100,100,100,1)\) and \(20,000\) training steps, was used to solve the same problem. The resulting relative \(l^{2}\) error was found to be \(11\%\), as shown in Figure 2. Additional experiments including ablation studies and comparisons can be found in appendix 6.2.
Furthermore, we demonstrate the robustness of our algorithm against the choice of network structure and arrangement through this example. We solve the problem using a variety of networks, including \((1,50,1)\), \((1,100,1)\), \((1,100,100,1)\), followed by a Fourier feature network \((1,100,100,100,1)\) with frequencies ranging from \(1\) to \(10\). The resulting relative \(l^{2}\) error is around \(1.1\%\), which is comparable to the previously mentioned result. It is possible that there exists a specific set of hyperparameters and configurations that would allow a single neural network to perfectly solve this problem. After all, by the universal approximation theorem [24], even a neural network with a simple structure possesses the ability to approximate a complicated function. However, the fine-tuning of hyperparameters is a common challenge in machine learning tasks and can consume significant computational resources. GB PINNs, on the other hand, do not require such fine-tuning as the multiple networks adjust the results automatically, ultimately saving effort and resources.
### 2D singular perturbation with boundary layers
In this example, we aim to solve the Eriksson-Johnson problem, which is a 2D convection-dominated diffusion equation. As previously noted in the literature, such as in [25], this problem necessitates the use of specialized finite element techniques in order to obtain accurate solutions, such as the Discontinuous Petrov Galerkin (DPG) finite element method.
Let \(\Omega=(0,1)^{2}\). The model problem is
\[-\varepsilon\Delta u+\frac{\partial u}{\partial x} =0 \text{in }\Omega,\] \[u =u_{0} \text{on }\partial\Omega.\]
The manufactured solution is
\[u(x,y)=\frac{e^{r_{1}(x-1)}-e^{r_{2}(x-1)}}{e^{-r_{1}}-e^{-r_{2}}}\sin(\pi y )\quad\text{ with }\quad r_{1,2}=\frac{-1\pm\sqrt{1+4\varepsilon^{2}\pi^{2}}}{-2\varepsilon}.\]
In this example, we set \(\varepsilon=10^{-3}\). To resolve this problem, we employ various neural network architectures, including \((2,50,1)\), \((2,100,1)\), \((2,100,100,1)\), \((2,100,100,1)\), \((2,100,100,1)\), and a Fourier feature network \((1,100,100,1)\) with frequencies ranging from \(1\) to \(50\). For each iteration of our GB algorithm, we train for \(20,000\) steps. We set the weights in (3) as \(\omega_{e}=1\) and \(\omega_{b}=10,000\), respectively. The batch sizes for PDE residuals and boundaries are set at \(10,000\) and \(50,00\), respectively. The predicted solution is visualized in Figure 3. We can see that
Figure 1: Prediction of singular perturbation problem by GB PINNs, \(\varepsilon=10^{-4}\). Left: predicted solution (black) v.s. ground truth (red). Right: pointwise error.
our model prediction is in good agreement with the ground truth, with a relative \(l^{2}\) error of \(1.03\%\). Notably, there is a boundary layer present on the right side of the boundary (\(x=1\)), which is not easily recognizable to the naked eye due to its thinness. However, GB PINNs are able to provide a reasonable degree of predictive accuracy even in this challenging scenario.
To further demonstrate the efficacy of our proposed method, we also attempted to solve this problem using a single fully connected neural network of architecture \((2,100,100,10)\), under the same hyperparameter settings as before. However, the resulting relative \(l^{2}\) error was \(57.7\%\). As can be seen in Figure 4, there is a significant discrepancy between the predicted solution and the reference solution. Additional experimental results, including an ablation study and comparisons, can be found in Appendix 6.2.
### 2D singular perturbation with an interior boundary layer
In this example, we address a 2D convection-dominated diffusion problem featuring curved streamlines and an interior boundary layer. The model problem is
\[-\varepsilon\Delta u+\beta\cdot\nabla u =f\qquad\text{ in }\Omega,\] \[u =u_{0}\qquad\text{ on }\partial\Omega,\]
Figure 3: Prediction of 2D singular perturbation with boundary problem by GB PINNs, \(\varepsilon=10^{-3}\). Left: predicted solution. Middle: ground truth. Right: pointwise error.
Figure 2: Prediction of singular perturbation problem by PINNs for ablation study, \(\varepsilon=10^{-4}\). Left: predicted solution (black) v.s. ground truth (red). Right: pointwise error.
with \(\beta=e^{x}(\sin(y),\cos(y))\) and \(f\), \(u_{0}\) are defined such that
\[u(x,y)=\arctan\left(\frac{1-\sqrt{x^{2}+y^{2}}}{\varepsilon}\right).\]
This example has been solved by DPG finite element method in [25]. A specific value of \(\epsilon=10^{-4}\) was chosen for the purpose of this study. The neural network architectures employed include \((2,200,200,200,1)\), \((2,100,100,1)\), \((2,100,100,1)\), and a Fourier feature network \((2,50,50,1)\) with frequency ranging from \(1\) to \(5\). The weights for the loss function in (3) were set as \(\omega_{e}=1\) and \(\omega_{b}=10,000\), respectively. The batch size for the PDE residual and boundary were set to \(10,000\) and \(5,000\), respectively. The results of this study are shown in Figure 5 and exhibit a relative \(l^{2}\) error of \(3.37\%\).
As a part of an ablation study, we resolve this problem using a fully connected neural network architecture of \((2,200,200,200,1)\), while maintaining the other configurations as same as the previous experiment. The relative \(l^{2}\) error obtained in this case is \(16\%\). The predictions and the corresponding errors are depicted in Figure 6. Additional experiments pertaining to the ablation study and comparisons can be found in the appendix, section 6.2.
### 2D nonlinear reaction-diffusion equation
In this example, we investigate the solution of a time-dependent nonlinear reaction-diffusion equation. As demonstrated in [12], conventional PINNs have been shown to be inadequate in accurately learning the solution of such equations.
Let \(\Omega=(0,2\pi)\). The model problem is
\[\frac{\partial u}{\partial t}-10\frac{\partial^{2}u}{\partial x^{2 }}-6u(1-u) =0,\quad x\in\Omega,t\in(0,1],\] \[u(x,0) =h(x)\quad x\in\Omega,\]
Figure 4: Prediction of 2D singular perturbation with boundary problem by PINNs, \(\varepsilon=10^{-3}\). Left: predicted solution. Middle: ground truth. Right: pointwise error.
Figure 5: Prediction of 2D singular perturbation with interior boundary problem by GB PINNs, \(\varepsilon=10^{-4}\). Left: predicted solution. Middle: ground truth. Right: pointwise error.
with periodic boundary conditions, where
\[h(x)=e^{-\frac{(\varepsilon-\pi)^{2}}{2(\nu/4)^{2}}}.\]
In order to impose an exact periodic boundary condition, we use \((\sin(x),\cos(x))\) as the spatial input instead of \(x\), while maintaining the temporal input unchanged. This eliminates the need for boundary loss. Additionally, we include an additional loss term for the initial condition in the loss function, equation (3). The neural network architecture utilized for this problem is \((2,200,200,200,1)\), \((2,100,100,100,1)\), \((2,100,100,1)\). The weights for the PDE residual and initial condition loss are set to \(1\) and \(1,000\), respectively. The batch sizes for the PDE residual and initial condition loss are \(20,000\) and \(1,000\), respectively. We present our results in Figure 7. The relative \(l^{2}\) error is \(0.58\%\). As shown in [12], the relative error for traditional PINNs with \(\rho=\nu=5\) is \(50\%\). A comparison between the exact solution and the PINNs' prediction can also be found in the figure.
In the aforementioned study, Krishnapriyan _et. al._[12] proposed a sequence-to-sequence learning approach to address this problem, achieving a relative \(l^{2}\) error of \(2.36\%\) for \(\rho=\nu=5\). The method required training the neural network for \(20\) steps. In contrast, our approach, which was implemented with \(\nu=10\) and \(\rho=6\), a more challenging scenario, required training only three networks. Despite this, our method achieved an error rate that was approximately four times lower than that of the previous study. This represents a significant improvement.
## 5 Conclusion
In this paper, we propose a GB PINNs algorithm, which utilizes multiple neural networks in sequence to predict solutions of PDEs. The algorithm is straightforward to implement and does not require extensive fine-tuning of hyperparameters. Additionally, the method is flexible and can be easily integrated with other PINNs techniques. Our experimental results demonstrate its effectiveness in solving a wide range of intractable PDE problems.
Figure 6: Prediction of 2D singular perturbation with interior boundary problem by PINNs, \(\varepsilon=10^{-4}\). Left: predicted solution. Middle: ground truth. Right: pointwise error.
Figure 7: Prediction of nonlinear reaction-diffusion equation by GB PINNs. Left: predicted solution. Middle: ground truth. Right: pointwise error.
However, it should be noted that the algorithm has some limitations. Firstly, it is not suitable for solving conservation laws with derivative blow-ups, such as the inviscid Burgers' equation and the Sod shock tube problem. This is due to the lack of sensitivity of these equations' solutions to PDE loss. The addition of more neural networks alone cannot overcome this issue. Secondly, the optimal combination of neural networks is not always clear, and the current experimental selection is mostly based on experience and prior estimation of the PDE problem. Further research into the theoretical and quantitative analysis of this method is an interesting direction for future work.
## Acknowledgments
This was supported in part by the US Department of Energy (grant DE-SC0019116) and the Air Force Office of Scientific Research (grant FA9550-20-1-0060), and DOE-ARPA grant DE-AR0001201.
|
2310.05256 | Precise neural network predictions of energies and radii from the
no-core shell model | For light nuclei, ab initio many-body methods such as the no-core shell model
are the tools of choice for predictive, high-precision nuclear structure
calculations. The applicability and the level of precision of these methods,
however, is limited by the model-space truncation that has to be employed to
make such computations feasible. We present a universal framework based on
artificial neural networks to predict the value of observables for an infinite
model-space size based on finite-size no-core shell model data. Expanding upon
our previous ansatz of training the neural networks to recognize the
observable-specific convergence pattern with data from few-body nuclei, we
improve the results obtained for ground-state energies and show a way to handle
excitation energies within this framework. Furthermore, we extend the framework
to the prediction of converged root-mean-square radii, which are more difficult
due to the much less constrained convergence behavior. For all observables
robust and statistically significant uncertainties are extracted via the
sampling over a large number of network realizations and evaluation data
samples. | Tobias Wolfgruber, Marco Knöll, Robert Roth | 2023-10-08T18:10:40Z | http://arxiv.org/abs/2310.05256v2 | # Precise neural network predictions of energies and radii from the no-core shell model
###### Abstract
For light nuclei, _ab initio_ many-body methods such as the no-core shell model are the tools of choice for predictive, high-precision nuclear structure calculations. The applicability and the level of precision of these methods, however, is limited by the model-space truncation that has to be employed to make such computations feasible. We present a universal framework based on artificial neural networks to predict the value of observables for an infinite model-space size based on finite-size no-core shell model data. Expanding upon our previous ansatz of training the neural networks to recognize the observable-specific convergence pattern with data from few-body nuclei, we improve the results obtained for ground-state energies and show a way to handle excitation energies within this framework. Furthermore, we extend the framework to the prediction of converged root-mean-square radii, which are more difficult due to the much less constrained convergence behavior. For all observables robust and statistically significant uncertainties are extracted via the sampling over a large number of network realizations and evaluation data samples.
## I Introduction
The challenge of solving the nuclear many-body problem with realistic Hamiltonians is at the core of nuclear theory. Throughout the past decades, the access to growing high performance computing (HPC) resources has revolutionized nuclear structure physics and caused a paradigm shift from computationally trivial to more demanding numerical models, giving rise to a range of successful _ab initio_ methods such as the no-core shell model (NCSM) [1; 2; 3; 4], the coupled-cluster (CC) theory [5], self-consistent Green's function (SCGF) approaches [6], the in-medium similarity renormalization group (IM-SRG) [7], or quantum Monte Carlo (QMC) methods [8]. While they have proven to provide realistic results for a range of observables, their precision is limited by computational constraints.
In a concurrent development, modern machine learning algorithms have excelled in a variety of computational tasks such as pattern recognition, interpolation, or optimization and have naturally sparked the interest of researchers in many fields including nuclear structure physics. This has led to various applications [9; 10] either through exploiting machine learning features as done in neural-network quantum state techniques [11; 12; 13], purely data driven approaches [14; 15], or as supplemental tools for the aforementioned many-body methods [16; 17; 18]. Focusing on the latter, machine learning is of particular interest when it comes to extending the reach of _ab initio_ methods by circumventing their computational limitations. As most of them are based on a basis expansion of the many-body problem, a major restraint are the rapidly growing model spaces that quickly exceed the capabilities of even the largest HPC clusters available. Due to the nature of _ab initio_ methods, which employ systematically improvable truncations, the errors induced by these truncations can, in principle, be controlled. However, accurately quantifying them or extrapolating results from finite model spaces to the full many-body Hilbert space are extremely challenging tasks. While ground-state energies are accessible with conventional extrapolation schemes based on exponential fits [19; 20; 3], there are no widely established methods for other observables such as radii.
As shown in recent applications to NCSM or CC calculations of ground-state observables, artificial neural networks (ANNs) are a promising tool to tackle this challenge [16; 17; 18]. The convergence behavior of these methods w.r.t the model space size is controlled by a model-space truncation parameter and the harmonic-oscillator (HO) frequency of the underlying single-particle basis.
The ANN models for extrapolating such data separate into two conceptually different categories. The first category attempts to emulate the functional dependence of the observable on the model-space size or, more precisely, the truncation parameter and the HO frequency, thus, directly replacing exponential or polynomial extrapolation methods with an ANN [16; 17]. Approximations for the full Hilbert space are then given by the networks prediction for very large values of the model-space truncation parameter. While this provides robust extrapolations for well balanced sets of training data, the applicability of such an ANN is, by construction, limited to the nucleus, interaction, state, and observable it was trained for. Thus, the computation of a large and balanced sets of training data as well as the ANN training process itself has to be repeated for each nucleus, interaction, state, and observable under consideration. This is a major bottleneck as the generation of training data becomes very costly. Moreover, the ANNs are used for a true extrapolation, i.e., an evaluation in an input parameter regime they were never trained for.
We have introduced a different approach in Ref. [18], which is more akin to a pattern recognition task. In our ANN model, the observable in the full Hilbert space is directly predicted from a set of converging sequences in small model spaces, which share the same limit. Hence, the ANN attempts to capture the convergence pattern and predict the converged value, similar to how an experienced practitioner would estimate it. Since we need to specify the fully converged values for the
training process, we can only use NCSM data from very light systems with \(A\leq 4\) for the training set. Despite this limitation, we can construct an extensive library of training data for a specific observable by varying the underlying Hamiltonian in addition to the nucleus and model-space parameters. In this way the training data encompasses very diverse convergence patterns so that, with a proper normalization, the ANN has learned all possible convergence patterns during the training. This makes this ANN universally applicable to different nuclei, interactions and states. This universality in a great advantage. The generation of training data and the training only happens once and the resulting ANNs are then simply applied with small sets of NCSM evaluation data for the systems of interest.
While our previous work [18] has demonstrated the capabilities of this universal ANN model for predicting ground-state energies, this paper focuses on improvements of the precision of the ANN prediction and the generalization to other observables, particularly excitation energies and root-mean-square (rms) radii. The description of these observables is more challenging because they show a much larger variety of non-monotonous convergence patterns, since they are not protected by the variational principle. We will introduce a simple normalization scheme that improves the precision of predictions of converged ground-state and excitation energies and enables the robust prediction of converged radii. For all observables we will extract statistically meaningful uncertainties for the ANN predictions. We will demonstrate the application of the ANNs to a range of p-shell nuclei up to \({}^{9}\)Be.
## II No-core shell model
While these ANN approaches can be adapted to various many-body methods, we focus on the NCSM, which solves the many-body stationary Schrodinger equation as a matrix eigenvalue problem
\[\sum_{j}\left\langle\phi_{i}|H|\phi_{j}\right\rangle\left\langle\phi_{j}|\psi_ {n}\right\rangle=E_{n}\left\langle\phi_{i}|\psi_{n}\right\rangle\quad\forall i, \tag{1}\]
by expanding the Hamiltonian \(H\) as well as the eigenstates \(|\psi_{n}\rangle\) in a complete basis. The basis \(\{|\phi_{i}\rangle\}\) is a set of Slater determinants of single-particle basis states, in our case eigenstates of the HO. To numerically solve this matrix eigenvalue problem, a truncation to a finite model space is employed. The so-called \(N_{\text{max}}\) truncation limits the total number of HO excitation quanta. The convergence behavior as function of \(N_{\text{max}}\) depends on the chosen HO frequency \(\hbar\Omega\) of the single-particle basis, though in the limit \(N_{\text{max}}\rightarrow\infty\) this dependency vanishes and the exact solution is recovered.
Observables other than the energies \(E_{n}\) are easily accessible in the NCSM by constructing the matrix representation of the corresponding operator in the many-body basis and evaluating the expectation value with the calculated eigenvectors. Since the NCSM is a variational method, the energy eigenvalues converge monotonously from above to the exact value with increasing \(N_{\text{max}}\). This powerful constraint on the convergence pattern does, however, not hold for other observables, e.g. radii, leading to more complex and less constrained convergence patterns.
The Hamiltonian employed in the NCSM calculations consists of a kinetic energy contribution and inter-nucleon interactions, typically derived from chiral effective field theory (EFT). The are several families of chiral nucleon-nucleon (NN) plus three-nucleon (3N) interactions with different order in the chiral power-counting and different cutoffs available nowadays, which exhibit different NCSM convergence behaviors. Even for the softest, i.e., fastest converging, of the the interactions very large \(N_{\text{max}}\) are required to reach convergence. Therefore, an additional pre-processing of the Hamiltonian through a similarity renormalization group (SRG) transformation is used to accelerate the model space convergence [19; 21; 22; 23; 24]. The SRG transformation introduces the continuous flow parameter \(\alpha\) which provide direct control over the convergence rate.
For few-body systems, which include \({}^{2}\)H, \({}^{3}\)H, and \({}^{4}\)He, we can use the Jacobi-NCSM [25], which is a efficient formulation of the NCSM for very light nuclei. It uses a relative basis instead of the typical \(m\)-scheme, which allows us to obtain fully converged calculations at minimal computational expense, ideal for generating large sets of training data. For heavier nuclei in the p-shell, as they are used as test cases for the network evaluation, we use the standard \(m\)-scheme NCSM.
## III Artificial neural networks
For our purpose, artificial neural networks are an ideal tool, as they excel at capturing patterns, especially in cases where classical algorithms are hard to implement or where the exact correlations between data points are unknown. At their core, ANNs roughly emulate biological neural networks as present in the brain. The type of network we use is called a dense feed-forward neural network. It consists of neurons with inputs and outputs, which are organized in layers. In this context dense means that each neuron's input is connected to the output of every neuron in the preceding layer. Based on these inputs, each neuron then calculates an output, which is fed to every neuron in the subsequent layer. For example, the \(i\)-th neuron in the \(n\)-th layer computes its output \(x_{n}^{(i)}\) according to
\[x_{i}^{(n)}=\sigma\left(\sum_{j=0}^{N_{\text{max}-1}}x_{j}^{(n-1)}w_{ji}^{(n)}+ b_{j}^{(n)}\right)\,, \tag{2}\]
where \(N_{n-1}\) is the number of connected neurons from the previous layer, \(w_{ji}^{(n)}\) and \(b_{j}^{(n)}\) are the weights and biases which are optimized during training, and \(\sigma\) is the activation function which rescales the output and in general introduces non-linearities. The weights and biases are initialized randomly and are optimized during the training process via supervised learning. This means that every network input in the training data is labeled with the desired output.
The training process starts with a feed-forward pass, where a batch of training samples are evaluated and a combined deviation of the network's predictions from the desired results is
calculated with a so-called loss function. The following back propagation step optimizes the weights and biases based on the gradient of the loss function. Repeating this process leads to an iterative improvement of the parameters of the network. A validation data set that is distinct from the training data is used to probe the performance of the network and the training progress and is usually used to adjust the step size in the gradient descent, commonly called learning rate. In then end, one should obtain a network that captures the patterns in the training data, leading to accurate predictions on the training data as well as previously unseen evaluation data.
So far we did not specify the choice of the so-called hyperparameters like the activation function, loss function, or back propagation algorithm. These choices can have a significant impact on the performance on both the training efficiency as well as on the quality of the networks themselves. We achieved the best results with a rectified linear unit (ReLU) [26] activation function, a mean-square error (MSE) loss function, and the AdamW back-propagation algorithm [27] in combination with an adaptive learning rate scheduler and a batch size of 512.
## IV Concepts and Network Design
As already mentioned, artificial neural networks are ideally suited for situations where data is correlated, but where the patterns are either too varied or the problem is too hard to write down a functional dependence. This is exactly the case for NCSM calculations, where the convergence with \(N_{\text{max}}\) clearly follows a certain pattern, that is hard to quantify. The idea is to show the network multiple sequences of data points which all must converge to the same value and have the network output a prediction for the fully converged value of these sequences. An illustration of converging NCSM sequences for the rms-radius of \({}^{4}\)He is shown in Fig. 0(a).
To construct such ANNs, we first need to train them on realistic NCSM convergence data. Since we use supervised learning, the exact, fully converged observable is a requirement for every sequence in the training data, which limits us to using few-body systems for the training as only these can be converged to the required precision. However, since the convergence patterns in heavier p-shell nuclei are very similar to those in few-body systems, ANNs trained on the latter can provide precise predictions for a broad range of p-shell nuclei. The main benefit of this method is that the training only needs to be done once and the trained ANNs can subsequently be applied, as a universal tool, to convergence sequences from any NCSM calculation.
Note that each observable needs its own set of networks, as the convergence pattern can vary significantly between different observables, though strongly related observables such as the ground-state energy and excited state energies or rms radii and point-proton rms radii can use the same set of networks.
One important aspect we have not touched on yet is the exact design of the ANN including the structure of the data samples, which defines the input and output layers, and the topology, which determines the number of hidden layers. For our application, the input for the network consists of \(X\) sequences of NCSM calculations for different \(\hbar\Omega\) which contain \(L\) values of a specific observable for subsequent values of \(N_{\text{max}}\). This sets the input layer to be \(X\cdot L\) neurons wide, while the output layer consists of a single neuron, which is supposed to be the prediction for the fully converged value of the observable. We found that three hidden layers with sizes \(4X\cdot L\), \(4X\cdot L\), and \(8X\) provide the best results. Figure 1 visualizes both a training sample (a) and the network topology (b) for the input dimensions of \(X=3\) and \(L=4\), which is the structure used for all results presented in this work. Note that the input layer only accepts a subset of the available data in
Figure 1: (a) Exemplary Jacobi-NCSM results for the mass rms radius of \({}^{4}\)He. All training data sequences for this combination of nucleus and interaction are shown in gray. Highlighted in color is one possible training sample, consisting of four radius results for consecutive \(N_{\text{max}}\) values for 3 different HO frequencies, and the fully converged target value (green). (b) Schematic representation of the fully connected feed-forward network topology, where the colors of the input and output layer correspond to the colors of the sample in (a).
the NCSM sequences--there are typically more than \(X=3\) different oscillator frequencies and more than \(L=4\) different \(N_{\text{max}}\) values available. This opens up the opportunity for a random sampling of the input data, which will be important for the training and statistical evaluation discussed below.
In order to evaluate the performance of our networks, it is helpful to compare them with traditional extrapolation techniques. For energy extrapolations we compare to an exponential fit scheme as described in Ref. [24] for both the ground-state energy and excitation energies. Radii are, due to being less constrained, more difficult to extrapolate. As there is no widely used algorithm for the extrapolation of radii, we forgo a comparison with a classical extrapolation technique for this observable. An interesting point for a future comparison are the effective-theory-based infrared extrapolations for the NCSM [28; 29]. The applicability of these methods relies on specific and often untypical combinations of \(N_{\text{max}}\) and \(\hbar\Omega\), which require a large number of dedicated NCSM calculations and are not directly possible with the evaluation data used here.
## V Training data and statistical evaluation
Our training data consists of \({}^{2}\)H, \({}^{3}\)H, and \({}^{4}\)He Jacobi-NCSM calculations up to \(N_{\text{max}}=50,\ 40,\ \text{and}\ 24\), respectively, for seven HO frequencies \(\hbar\Omega=12,\ 14,\ 16,\ 20,\ 24,\ 28,\) and \(32\,\text{MeV}\). We use the non-local NN+3N interactions from chiral EFT at orders N\({}^{2}\)LO, N\({}^{3}\)LO, and N\({}^{4}\)LO\({}^{\prime}\) and for cutoffs \(\Lambda=450,\ 500,\ \text{and}\ 550\,\text{MeV}\) introduced in [30; 31]. We applied these interactions bare and SRG evolved with three different flow parameters of \(\alpha=0.02,\ 0.04,\ \text{and}\ 0.08\,\text{fm}^{4}\). All in all, we obtain 756 converging sequences. To reduce artifacts in the training set, we exclude \(N_{\text{max}}=0\) data and remove sequences that are not sufficiently converged, which means that the value of the observable at the largest available \(N_{\text{max}}\) shows a deviation of more than \(5\,\%\) from the fully converged value. The data that is left forms the basis from which we can construct samples for training. Each sample consists of a subset of the training data with a specific number of randomly selected HO frequencies and a specific window in \(N_{\text{max}}\), together with the fully converged value of the observable of choice.
We construct three disjoint subsets of samples: a large set of training samples, and two smaller sets of test and validation samples. The training consists of 20 epochs, iterating through all training samples with a batch size of 512 each time, monitoring the average loss via the test set at every cycle. This information is used to adaptively adjust the learning rate, which is initialized to 0.001. We evaluate the quality of the fully trained networks by measuring their performance on the validation set and discard poorly performing networks.
When applying the trained ANNs to unseen data we rely on a statistical evaluation for which we first construct evaluation samples analogously to the sample generation done for the training data, i.e., we construct all possible samples of \(X=3\) HO frequencies and their permutations with values for the observable at \(L=4\) consecutive \(N_{\text{max}}\). In addition to evaluating multiple samples, we also evaluate these samples with 1000 networks, that have been initialized differently and trained individually, in order to suppress any errors from a single ANN. This multitude of predictions is then incorporated into a histogram that describes the distribution of the individual predictions, which usually shows a strong, single-peak structure that is very similar to a normal distribution. Foe simplicity, fit a Gaussian to the distribution to obtain the mean and standard deviation of the dominant peak structure. While the extracted mean can be understood as the final ANN prediction for the given observable, the width of the distribution provides an uncertainty measure that incorporates not only all information from the evaluation data, but also accounts for the uncertainty of the individual ANNs. Hence, we can provide precise predictions, which are robust against outliers, along with reliable \(1\sigma\) uncertainties.
To be able to gauge the quality and consistency of the predictions, we group samples by the highest \(N_{\text{max}}\) value they contain, denoted by \(\mathcal{N}_{\text{max}}\). Higher \(\mathcal{N}_{\text{max}}\) correspond to larger model spaces and, therefore, better converged sequences, which should improve the ANN predictions of the fully converged value. To emulate the situation in heavier p-shell nuclei where we see the largest potential for this method, we artificially limit the information for the evaluation in this work to \(N_{\text{max}}=12\) or less. This corresponds to evaluation samples with \(\mathcal{N}_{\text{max}}\leq 12\). With increasing \(\mathcal{N}_{\text{max}}\) we expect the distribution of network predictions to decrease in width, corresponding to a smaller uncertainty, as well as improve in accuracy. Furthermore, the predictions should be compatible with each other within their uncertainty bands.
## VI Input modes
There is some freedom when it comes to formatting the data that is fed into the input layer of the networks. We can formalize this by looking at the networks like a mapping \(M:S\to O^{\infty}\), where \(O^{\infty}\) is the converged observable and \(S\) is the input sample. In our previous work [18], we compared two distinct input modes. In the ABS mode, the data for a given observable, e.g. the ground-state energy, is simply fed in as-is.
Figure 2: Histogram of the dimensionless target values of all samples in the MINMAX input mode for ground-state energies (left) and mass rms radii (right), separated by color: \({}^{2}\)H (green), \({}^{3}\)H (blue), and \({}^{4}\)He (red). Values left of zero (right of one) belong to samples exclusively converging from above (below), while target values between zero and one belong to samples with a mixed convergence pattern.
With our chosen network topology, a single ABS sample takes the shape
\[\begin{split} S^{N_{\text{max}}}_{\text{ABS}}=(O^{N_{\text{max}}-6}_{ \text{hd}1_{1}},O^{N_{\text{max}}-4}_{\text{hd}1_{1}},O^{N_{\text{max}}-2}_{ \text{hd}1_{1}},O^{N_{\text{max}}}_{\text{hd}1_{1}}\\ O^{N_{\text{max}}-6}_{\text{hd}2_{1}},O^{N_{\text{max}}-4}_{\text{hd }2_{1}},O^{N_{\text{max}}-2}_{\text{hd}2_{2}},O^{N_{\text{max}}}_{\text{hd}2_{ 1}}\\ O^{N_{\text{max}}-6}_{\text{hd}2_{1}},O^{N_{\text{max}}-4}_{\text{hd }2_{1}},O^{N_{\text{max}}-2}_{\text{hd}2_{1}},O^{N_{\text{max}}}_{\text{hd}2_{ 1}}\\ \end{split} \tag{3}\]
This is the naive choice and gives the network all available information, but also the maximum amount of flexibility to look for patterns in the input data. A clear disadvantage is, however, that this can lead to undesired training results, as the networks just have to reproduce the few results for the nuclei in the training data without learning the convergence pattern. Previous work has further shown, that this input mode induces a dependency on the respective energy range, which distorts the predictions in nuclei beyond the training set. To circumvent this, we have introduced an additional step of scaling and shifting the data before feeding it to the network to increase variety in the target values and convergence patterns. This slightly alleviates the effects of the large gap between the target value of the heaviest training nucleus and the heavier nuclei in the evaluation set.
The other mode we introduced in Ref. [18] is called DIFF and feeds the differences between consecutive \(N_{\text{max}}\) steps into the networks. This inherently alleviates the difference in scales between the nuclei in the training and the evaluation set, though shifting the data obviously had no more effect so that one source for inflating the initial training data pool was eliminated. Both of these modes were explored with the ground-state energy as the target observable (for details see Ref. [18]). Unfortunately, both exhibit significant shortcomings when applied to an observable with a different convergence structure like the radius.
This leads us to look into another input mode called min-max normalization, which we refer to as MINMAX. The min-max normalization is a common normalization technique for machine learning applications. In general, it normalizes the input data per sample to an interval \([a,b]\), though we exclusively choose an interval of \([0,1]\) for our network input. A single MINMAX sample can be defined via the ABS sample and takes the form
\[S^{N_{\text{max}}}_{\text{MINMAX}}=\frac{S^{N_{\text{max}}}_{\text{ABS}}-\min( S^{N_{\text{max}}}_{\text{ABS}})}{\max(S^{N_{\text{max}}}_{\text{ABS}})-\min(S^{N_{ \text{max}}}_{\text{ABS}})}\,. \tag{4}\]
To recover the value of the predicted observable \(O^{\infty}\) from the network output \(O^{\infty}_{\text{MINMAX}}\), the inverse transformation has to be applied:
\[O^{\infty}=O^{\infty}_{\text{MINMAX}}\left(\max(S^{N_{\text{max}}}_{\text{ABS }})-\min(S^{N_{\text{max}}}_{\text{ABS}})\right)+\min(S^{N_{\text{max}}}_{ \text{ABS}}). \tag{5}\]
The goal is to get rid of scale dependencies and reduce the information to the network in such a way that the recognition and extrapolation of the convergence pattern is the only viable strategy for the network due to a lack of other clues or reference points contained within the data.
Figure 2 shows the distribution of the MINMAX-normalized target values of all training samples for ground-state energies and radii. The colors correspond to the three training nuclei. Both normalized target values are dimensionless, and the position on the \(x\)-axis determines if the value
Figure 3: Input data and network predictions for the ground-state energy and mass radius of \({}^{4}\)He. The left column shows the input data, consisting of NCSM calculations for \(\hbar\Omega=12,\ 14,\ 16,\ 20,\ 24,\ 28,\) and \(32\,\text{MeV}\) (gray to red). The right column shows a histogram of the predictions of the networks using the ABS, DIFF, and MINMAX input modes as as well as the fitted Gaussian and its mean and standard deviation. The three segments labeled 8, 10, and 12 correspond to the \(N_{\text{max}}\) of the evaluation samples.
belongs to a sample that converges exclusively from above (below 0), exclusively from below (above 1), or one that has a mixed convergence (between 0 and 1). As ground-state energies are constrained by the variational principle, all samples must naturally converge from above. Furthermore, the ground-state energy usually converges rather fast, leading to most target values being grouped closely below zero. Radii on the other hand are, as previously mentioned, not very well constrained. The direction of convergence mainly depends on the specific HO frequency in conjunction with the nucleus and the \(N_{\text{max}}\) window. For both \({}^{2}\)H and \({}^{3}\)H, samples that converge from below dominate in our training set, while \({}^{4}\)He appears to be much more balanced in that regard. However, we expect this to be a good match for the situation of most nuclei we are interested in, as a typical energy-guided selection of HO frequencies leads to the majority of sequences for the rms-radius to converge from below. For the training, we generate 1 000 000 training samples for the ABS and DIFF input modes via random scaling and shifting, while we are limited to about 350 000 native samples for MINMAX.
The performance of the MINMAX input mode is compared to ABS and DIFF in Fig. 3 for the \({}^{4}\)He ground-state energy and mass rms-radius. The left-hand panels show the evaluation data for both observables, while the right-hand panels shows histograms of the networks' predictions together with the fitted Gaussian for all 3 input modes at increasing \(\mathcal{N}_{\text{max}}\). The fully converged value obtained from large \(N_{\text{max}}\) is depicted as a horizontal green line.
Starting with the ground-state energies, all three input modes perform well, though ABS gives slightly overbound predictions, while both DIFF and MINMAX are very accurate even at \(\mathcal{N}_{\text{max}}=8\). DIFF gives very small uncertainties compared to both other modes, though the MINMAX uncertainties decrease significantly with increasing \(\mathcal{N}_{\text{max}}\) down to approximately the level of DIFF, while the ABS uncertainties remain rather large. As the DIFF uncertainties can tend to be somewhat underestimated, MINMAX seems to be a very good alternative, retaining the accuracy of DIFF with the slightly more realistic uncertainties. The radius results in the lower panel show a much larger discrepancy between the different modes. Both ABS and DIFF give rather inaccurate results, especially for smaller \(\mathcal{N}_{\text{max}}\). The uncertainties of both modes also remain fairly large. The MINMAX input mode on the other hand is already extremely accurate at \(\mathcal{N}_{\text{max}}=8\), and subsequent \(\mathcal{N}_{\text{max}}\) increase the precision in a realistic and systematic way when compared to the raw data on the left.
Though not shown here, the different input modes show a very similar behavior for other nuclei as well. This means that MINMAX is clearly superior for radii, and at least comparable if not better than both other input modes for ground-state energies. Therefore, we will exclusively use the MINMAX input mode for all following investigations.
## VII Results for ground-state and excitation energies
In order to evaluate the performance of the networks, we will start with a look at ground-state energies of the few-body systems \({}^{2}\)H, \({}^{3}\)H, and \({}^{4}\)He, which are also used in the train process. It is important to note that all evaluations shown in this work use an entirely different family of interactions than the non-local chiral interaction used during training. The evaluation data is obtained with a semi-local NN+3N interaction derived from chiral EFT at N\({}^{2}\)LO with a cutoff of \(\Lambda=450\,\text{MeV}\)[24; 32], SRG evolved with a flow parameter of \(\alpha=0.08\,\text{fm}^{4}\). This ensures maximum independence of training and evaluation data, even if the evaluation is performed for isotopes contained in the training data. The specific selection of HO frequencies for the NCSM evaluation data is given in the caption of the respective figure.
Figure 4: Input data and network predictions of the ground-state energy for \({}^{2}\)H, \({}^{3}\)H, and \({}^{4}\)He. The left hand panels show the NCSM input data for \(\hbar\Omega=12,\,14,\,16,\,20,\,24,\,28,\,\text{and}\,\,32\,\text{MeV}\) (gray to red), while the right hand panels show a histogram of the network predictions together with a fitted Gaussian, which gives the mean and 1-\(\sigma\) uncertainty. The variational minimum at each \(\mathcal{N}_{\text{max}}\) is given by the black dashed lines, the classical extrapolation results in red with the associated uncertainty, and the fully converges value is given by the green line.
Figure 4 shows results for the few-body nuclei, the corresponding numerical values are summarized in Table 1. As before, the left-hand panels show the raw evaluation data, while the right-hand panels show the distribution of the predictions together with a fitted Gaussian that defines the mean and standard deviation. The dotted lines indicate the variational minimum for \(\mathcal{N}_{\text{max}}=8,\ 10,\text{ and }12\) truncating the data fed into the networks. The results of traditional extrapolations at \(N_{\text{max}}=8,\ 10,\text{ and }12\) are given in red for comparison. The green line is the fully converged result obtained at very large \(N_{\text{max}}\).
As expected, the networks show excellent agreement with the fully converged results and are well below the variational minimum except when the sequences are already well converged. The prediction using the smallest \(\mathcal{N}_{\text{max}}=8\) is in all 3 cases almost exactly on the fully converged value, indicating that the networks can recognize the convergence pattern very well and give accurate predictions. The uncertainties of the predictions get systematically smaller with increasing \(\mathcal{N}_{\text{max}}\), and all predictions are well within the preceding uncertainties indicating over-all consistency of the predictions and the uncertainty estimated.
Compared to the classical extrapolation, the networks are generally more accurate and precise in cases where the energy is not converged yet, which is the case for \({}^{2}\)H and \({}^{3}\)H, especially at smaller \(\mathcal{N}_{\text{max}}\). Only the exceptionally well bound \({}^{4}\)He nucleus converges so fast, that there is no advantage compared to a classical extrapolation.
Looking at slightly heavier nuclei, we are not only interested in the ground-state energy, but also in excited-state energies or excitation energies. The energy of excited states can be predicted in exactly the same way using the same pre-trained networks as for the ground-state energy extrapolation, feeding sequences of the converging excited state to the networks as inputs instead. The upper panel of Fig. 5 shows the NCSM data for the \(1^{+}\) ground and \(3^{+}\) excited state of \({}^{6}\)Li, with the corresponding network predictions on the right. There is no discernible difference in the performance of the networks for the two states, for both states the predictions are very stable and consistent with each other. This is possible since there is no qualitative difference in the convergence behavior of bound excited states compared to the ground state.
To give predictions for excitation energies with our networks, we evaluate both the ground and the excited-state energy separately, and subsequently subtract the predictions sample-wise, i.e., we compute the difference between the predicted ground-state energy and the predicted excited-state energy of for each sample consisting of \(X=3\) different HO fre
Figure 5: Input data and network predictions for the \(1^{+}\) ground and \(3^{+}\) excited state of \({}^{6}\)Li (upper panel) and for the excitation energy of the \(3^{+}\) excited state (lower panel) with \(\hbar\Omega=14,\ 16,\ 20,\ 24,\) and \(28\,\text{MeV}\) (gray to red).
Figure 6: Input data and network predictions for the ground state and excitation energy of \({}^{6}\)Li. The lower left hand panels shows the NCSM input data for the ground-state prediction, while the upper panel illustrated the convergence behavior of the exited states, with data for \(\hbar\Omega=14,\ 16,\ 20,\ 24,\text{ and }28\,\text{MeV}\) (gray to red). The right hand panels show the corresponding network predictions, together with the classical extrapolation results and the variational minimum for the ground-state energy (dashed line).
quencies and \(L=4\) subsequent model space truncations \(N_{\text{max}}\). The resulting distribution tends to be approximately normal-shaped, so that we can once again simply fit a Gaussian to obtain the prediction for the excitation energy and its uncertainty from the mean and standard deviation the Gaussian.
The lower panels of Fig. 5 show the result of the above mentioned procedure for the \(3^{+}\) excitation energy on the right-hand side. The excitation energy sequences in the left-hand panel are only shown to give an impression of the convergence of the actual observable, as they are not used as input data for the networks. We observe that the excitation energy predictions are remarkably stable for the different \(\mathcal{N}_{\text{max}}\), given that this observable is a lot more challenging to predict, as slight variations in the prediction of the absolute energies has larger effects on the excitation energy. For this reason, we use the aforementioned sample-wise subtraction method instead of just taking the difference of the whole distributions. This way, we can make exploit of correlations in the convergence pattern of different states for the same HO frequency. Typically, this improves the prediction and leads to smaller uncertainties.
Figures 6 to 9 as well as Table 1 give a comprehensive overview of the performance of the networks for ground-state energies and the lowest few excitation energies of \({}^{6}\)Li, \({}^{7}\)Li, \({}^{8}\)Li, and \({}^{9}\)Be. These NCSM calculations for p-shell nuclei have been discussed in detail in Ref. [33] and we reuse these NCSM outputs here to benchmark the performance of the networks [34]. In these figures, the ground-state energy is shown in the lower panel, while the excitation energy results are in the upper panel. Additionally, classical extrapolations for both observables are depicted as a red bar, with the corresponding uncertainty as a red band around it.
One major observation we want to highlight is that the ANN predictions for the ground-state energies are remarkably stable with increasing model-space sizes and generally significantly outperform the classical extrapolations at \(\mathcal{N}_{\text{max}}=8\) across all considered nuclei when compared with the values obtained for large \(\mathcal{N}_{\text{max}}\). The classical extrapolations are more susceptible to a systematic downwards trend with increasing model-space size, which has its roots in the fact that the convergence of ground-state energies is not quite exponential. The networks do not suffer from such a systematic, which facilitates a robust and accurate prediction of the converged energy in smaller model spaces.
Excitation energies are slightly more difficult, since the correlation between the convergence of the ground and the ex
Figure 7: Input data and network predictions for the ground state and excitation energy of \({}^{7}\)Li with \(\hbar\Omega=14,\;16,\;20,\;\text{and}\;24\,\text{MeV}\) (gray to red), analogous to Fig. 6
cited state are relevant. Furthermore, excited-state energies, especially for more loosely bound states, converge slower than the ground-state energy. Together, this makes the prediction of the converged value much more challenging, especially at \(\mathcal{N}_{\text{max}}=8\). Nevertheless, the ANN results for excitation energies are generally very robust, in particular for the lowest excited states. Higher-lying, more loosely bound excited states like the \(2^{+}\) state in \({}^{6}\)Li or the \(\frac{7}{2}^{-}\) state in \({}^{7}\)Li require \(\mathcal{N}_{\text{max}}=10\) to give accurate results. However, in these cases, the convergence behavior of the sequences changes significantly within the lower \(N_{\text{max}}\) data points, so a slight influence on the ANN predictions is expected. For this reason, we recommend checking for the robustness of the predictions by comparing with predictions for other \(\mathcal{N}_{\text{max}}\) if available.
## VIII Results for radii
As already mentioned, the extrapolation of NCSM sequences for rms radii is very challenging, as their convergence behavior is far less constrained than for the ground-state energy. As a result a larger variety of convergence patterns can be observed and the networks have to learn to cope with the different patterns. Obviously, we have to train a new set of networks to pick up the convergence patterns inherent to the radius. We use the same network topology and input mode (MINMAX) as for the ground-state energy training, but train on data for mass rms radii instead. The evaluation step is performed analogous to the ground-state energies.
The application of the radius networks to \({}^{2}\)H, \({}^{3}\)H, and \({}^{4}\)He is illustrated in Fig. 10 and the final ANN predictions are summarized in Table 1. The NCSM data for the mass rms radius, which is fed into the networks, is shown in the left-hand panels, while the ANN predictions are depicted on the right side, together with the fully converged values (green lines). As before, we use the semi-local NN+3N interaction at N\({}^{2}\)LO with \(\Lambda=450\,\text{MeV}\)[32, 24] and \(\alpha=0.08\,\text{fm}^{4}\) for this evaluation, which is not included in the training set.
We first observe that the convergence patterns for the radii are really very different from the ground-state energies. The radius is not constrained via the variational principle, which is evident from the fact that convergence is not monotonous. Depending on the selection of HO frequencies, whole sequences can converge from or from below. The convergence itself is also significantly slower compared to energies, and some sequences show a jagged pattern, particularly at \(N_{\text{max}}\) values.
Despite of these characteristics, the ANN predictions for the \({}^{2}\)H and \({}^{4}\)He mass rms radius are in very good agreement with the fully converged value, even at \(\mathcal{N}_{\text{max}}=8\). These two nuclei also demonstrate the two extremes of possible convergence patterns: With a selection of HO frequencies around
Figure 10: Mass rms radii input data and resulting network predictions for few-body systems. The left hand panels show the NCSM data for \(\hbar\Omega=12,\ 14,\ 16,\ 20,\ 24,\ 28,\ \text{and}\ 32\,\text{MeV}\) (gray to red), while the right hand panels show the ANN predictions for \(\mathcal{N}_{\text{max}}=8,\ 10,\ \text{and}\ 12\), with the green line indicating the fully converged value obtained at a large \(N_{\text{max}}\).
Figure 9: Input data and network predictions for the ground state and excitation energy of \({}^{9}\)Be with \(\hbar\Omega=14,\ 16,\ 20,\ 24,\ \text{and}\ 28\,\text{MeV}\) (gray to red), analogous to Fig. 6.
the variational minimum for the ground-state energy, \({}^{4}\)He exhibits a very symmetric convergence, with some sequences converging from above and some from below. \({}^{2}\)H on the other hand exhibits convergence exclusively from below, which is the typical case for most nuclei we looked at. This reflects the distribution of target values for all training samples mentioned earlier, and depicted in Fig. 2. The predictions for \({}^{3}\)H show a light drift, particularly the \(\mathcal{N}_{\text{max}}=8\) is slightly above the exact radius, which might be related to the strong zig-zag pattern for small \(N_{\text{max}}\) values in the input data.
To assess the performance of the networks beyond of the few-body systems used for training, we take a look at four p-shell nuclei. Figure 11 shows input data and ANN predictions for \({}^{6}\)Li, \({}^{7}\)Li, \({}^{8}\)Li, and \({}^{9}\)Be. The final predictions are summarized in Table 1. This data again is extracted from the NCSM calculations performed for Ref. [33], which focused entirely on energies. Therefore, the selection of HO frequencies available is optimized for the description of energies and not for rms radii. As a result, the sequences predominantly converge from below and, particularly for \({}^{6}\)Li and \({}^{7}\)Li, do not cover the range around the optimum frequency for the radius.
Despite these deficiencies in the evaluation data, the predictions are very stable across the board. For \({}^{6}\)Li and \({}^{7}\)Li a slight trend towards larger radii, which is compatible with the depicted uncertainties, can be observed with increasing \(\mathcal{N}_{\text{max}}\). This shift gets smaller for larger model spaces, and is less large around the optimum frequency for the radius.
Despite these deficiencies in the evaluation data, the predictions are very stable across the board. For \({}^{6}\)Li and \({}^{7}\)Li a slight trend towards larger radii, which is compatible with the depicted uncertainties, can be observed with increasing \(\mathcal{N}_{\text{max}}\). This shift gets smaller for larger model spaces, and is less large around the optimum frequency for the radius.
Despite these deficiencies in the evaluation data, the predictions are very stable across the board. For \({}^{6}\)Li and \({}^{7}\)Li a slight trend towards larger radii, which is compatible with the depicted uncertainties, can be observed with increasing \(\mathcal{N}_{\text{max}}\). This shift gets smaller for larger model spaces, and is less large around the optimum frequency for the radius.
\begin{table}
\begin{tabular}{l c c c c c} \hline \hline & \multicolumn{3}{c}{\(\mathcal{N}_{\text{max}}=8\)} & 10 & 12 & conv. \\ \hline \multicolumn{6}{c}{\({}^{2}\)H} \\ \(E_{\text{Ep}}\) & ANN & \(-2.195(47)\) & \(-2.223(27)\) & \(-2.195(14)\) & \(-2.200\) \\ \(E_{\text{Ep}}\) & extr. & \(-2.013(106)\) & \(-2.147(^{*})\) & \(-2.183(106)\) & \(-2.200\) \\ \(R_{\text{rms}}\) & ANN & \(1.995(46)\) & \(1.967(23)\) & \(1.979(26)\) & \(1.979\) \\ \hline \multicolumn{6}{c}{\({}^{3}\)H} \\ \(E_{\text{Ep}}\) & ANN & \(-8.482(65)\) & \(-8.509(33)\) & \(-8.487(12)\) & \(-8.481\) \\ \(E_{\text{Ep}}\) & extr. & \(-8.43(110)\) & \(-8.480(109)\) & \(-8.473(24)\) & \(-8.481\) \\ \(R_{\text{rms}}\) & ANN & \(1.726(20)\) & \(1.712(14)\) & \(1.703(8)\) & \(1.696\) \\ \hline \multicolumn{6}{c}{\({}^{4}\)He} \\ \(E_{\text{Ep}}\) & ANN & \(-28.513(71)\) & \(-28.526(25)\) & \(-28.526(8)\) & \(-28.524\) \\ \(E_{\text{Ep}}\) & extr. & \(-28.503(48)\) & \(-28.528(24)\) & \(-28.523(9)\) & \(-28.524\) \\ \(R_{\text{rms}}\) & ANN & \(1.461(10)\) & \(1.461(4)\) & \(1.460(2)\) & \(1.460\) \\ \hline \multicolumn{6}{c}{\({}^{6}\)Li} \\ \(E_{\text{Ep}}\) & ANN & \(-31.98(17)\) & \(-32.01(11)\) & \(-32.106(6)\) & \(-\) \\ \(E_{\text{Ep}}\) & extr. & \(-31.72(27)\) & \(-31.91(19)\) & \(-32.01(36)\) & \(-\) \\ \(E_{\text{ex}}(3^{+})\) & ANN & \(2.44(12)\) & \(2.42(5)\) & \(2.40(4)\) & \(-\) \\ \(E_{\text{ex}}(3^{+})\) & extr. & \(2.38(35)\) & \(2.41(19)\) & \(2.34(36)\) & \(-\) \\ \(E_{\text{ex}}(40^{+})\) & ANN & \(3.91(10)\) & \(3.86(6)\) & \(3.79(6)\) & \(-\) \\ \(E_{\text{ex}}(4^{0})\) & extr. & \(3.92(35)\) & \(3.76(19)\) & \(3.65(36)\) & \(-\) \\ \(E_{\text{ex}}(2^{+})\) & ANN & \(4.74(15)\) & \(4.56(10)\) & \(4.46(7)\) & \(-\) \\ \(E_{\text{ex}}(2^{+})\) & extr. & \(4.67(59)\) & \(4.38(19)\) & \(4.44(47)\) & \(-\) \\ \(R_{\text{rms}}\) & ANN & \(2.235(18)\) & \(2.284(22)\) & \(2.291(18)\) & \(-\) \\ \hline \multicolumn{6}{c}{\({}^{7}\)Li} \\ \(E_{\text{Ep}}\) & ANN & \(-39.46(19)\) & \(-39.39(11)\) & \(-39.40(6)\) & \(-\) \\ \(E_{\text{ex}}(5)\) & extr. & \(-39.12(34)\) & \(-39.24(13)\) & \(-39.39(7)\) & \(-\) \\ \(E_{\text{ex}}(1/2^{-})\) & ANN & \(0.37(5)\) & \(0.33(3)\) & \(0.32(1)\) & \(-\) \\ \(E_{\text{ex}}(1/2^{-})\) & extr. & \(0.34(34)\) & \(0.33(15)\) & \(0.32(7)\) & \(-\) \\ \(E_{\text{ex}}(5/2^{-})\) & ANN & \(5.01(13)\) & \(4.93(5)\) & \(4.88(3)\) & \(-\) \\ \(E_{\text{ex}}(5/2^{-})\) & extr. & \(4.86(46)\) & \(4.91(13)\) & \(4.96(11)\) & \(-\) \\ \(E_{\text{ex}}(5/2^{-})\) & ANN & \(6.95(13)\) & \(6.81(10)\) & \(6.71(7)\) & \(-\) \\ \(E_{\text{ex}}(5/2^{-})\) & extr. & \(6.93(55)\) & \(6.81(25)\) & \(6.65(12)\) & \(-\) \\ \(E_{\text{ex}}(7/2^{-})\) & ANN & \(8.14(3)\) & \(7.95(6)\) & \(7.88(3)\) & \(-\) \\ \(R_{\text{rms}}\) & ANN & \(8.05(53)\) & \(7.94(23)\) & \(7.84(11)\) & \(-\) \\ \(R_{\text{rms}}\) & ANN & \(2.288(15)\) & \(2.307(15)\) & \(2.325(14)\) & \(-\) \\ \hline \multicolumn{6}{c}{\({}^{8}\)Li} \\ \(E_{\text{Ep}}\) & ANN & \(-41.35(21)\) & \(-41.36(14)\) & \(-\) & \(-\) \\ \(E_{\text{Ep}}\) & extr. & \(-41.14(47)\) & \(-41.23(16)\) & \(-\) & \(-\) \\ \(E_{\text{ex}}(1^{+})\) & ANN & \(1.22(9)\) & \(1.10(7)\) & \(-\) & \(-\) \\ \(E_{\text{ex}}(1^{+})\) & extr. & \(1.18(50)\) & \(1.11(19)\) & \(-\) & \(-\) \\ \(E_{\text{ex}}(3^{+})\) & ANN &
pronounced for \({}^{8}\)Li and \({}^{9}\)Be, where the chosen HO frequencies include more optimal values producing a flat convergence curve. Therefore, we expect that an optimized selection of HO frequencies in the NCSM calculations, leading to a more symmetric convergence pattern, will improve the predictions and alleviate the observed slight upwards trend. Another way to tackle such a systematic might be to restrict the training data set to sequences that converge exclusively from below, thereby, obtaining networks that are specialized for this situation. However, even with a non-optimized frequency selection and the general set of training data, the ANNs provide robust predictions for the converged rms radii with realistic data-driven uncertainties based on a rather limited set of evaluation data.
## IX Conclusions
We have extended our ANN architecture to high-precision predictions of ground-state and excited-state energies and radii from non-converged NCSM calculations. The core idea of the framework is to learn convergence patterns from a large pool of training data obtained from few-body systems such as \({}^{2}\)H, \({}^{3}\)H, and \({}^{4}\)He with a range of different interactions, and apply the trained networks to NCSM data for a larger range of nuclei. This includes a statistical evaluation scheme, where many networks are trained and evaluated to obtain a distribution of predictions that allows for the extraction of statistically meaningful uncertainties. With the new MINMAX input mode we are able to extend this capability to radii as well, a much less constrained observable compared to energies. Additionally, we find improvements in accuracy coupled with more realistic uncertainties in the case of energies when compared with our previous generation of networks.
Based on these advances we are convinced that the ANN architecture is capable of handling other observable as well, especially electromagnetic moments and transition strengths. For electric quadrupole observables we expect a correlation to the rms radius, which can be exploited in the evaluation and construction of the networks. Of course, for the training of new ANN for such observables we need a sufficient amount of training data in very light nuclei. This can become an issue, since many electromagnetic observables, particularly transition strengths, naturally appear in bound few-nucleon system. To remedy this issue, we are currently looking into synthetic nuclei which emerge from modified Hamiltonians. We can, for example, we enhance the interaction to create additional bound states in these small systems, making more complex observables accessible in few-body systems and to create a large library of training data.
###### Acknowledgements.
We thank Pieter Maris for providing us with the raw NCSM output for the calculations presented in Ref. [33]. All other numerical calculations have been performed on the LICHTENBERG II cluster at the computing center of the TU Darmstadt. This work is supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) through the DFG Sonderforschungsbereich SFB 1245 (Project-ID 279384907) and the BMBF through Verbundprojekt 05P2021 (ErUM-FSP T07, Contract No. 05P21RDFNB).
|
2303.15196 | Probing optimisation in physics-informed neural networks | A novel comparison is presented of the effect of optimiser choice on the
accuracy of physics-informed neural networks (PINNs). To give insight into why
some optimisers are better, a new approach is proposed that tracks the training
trajectory curvature and can be evaluated on the fly at a low computational
cost. The linear advection equation is studied for several advective
velocities, and we show that the optimiser choice substantially impacts PINNs
model performance and accuracy. Furthermore, using the curvature measure, we
found a negative correlation between the convergence error and the curvature in
the optimiser local reference frame. It is concluded that, in this case, larger
local curvature values result in better solutions. Consequently, optimisation
of PINNs is made more difficult as minima are in highly curved regions. | Nayara Fonseca, Veronica Guidetti, Will Trojak | 2023-03-27T13:35:28Z | http://arxiv.org/abs/2303.15196v1 | # Probing optimisation in physics-informed neural networks
###### Abstract
A novel comparison is presented of the effect of optimiser choice on the accuracy of physics-informed neural networks (PINNs). To give insight into why some optimisers are better, a new approach is proposed that tracks the training trajectory curvature and can be evaluated on the fly at a low computational cost. The linear advection equation is studied for several advective velocities, and we show that the optimiser choice substantially impacts PINNs model performance and accuracy. Furthermore, using the curvature measure, we found a negative correlation between the convergence error and the curvature in the optimiser local reference frame. It is concluded that, in this case, larger local curvature values result in better solutions. Consequently, optimisation of PINNs is made more difficult as minima are in highly curved regions.
## 1 Introduction
The idea of solving PDE problems using neural networks (NNs) was put forward by Lagaris et al. (1997; 1998); Lagaris et al. (2000) in the second half of the '90s and then revised in 2017 by Raissi et al. (2017a;b) who named the methodology Physics-Informed Neural Networks (PINNs). Relying on the universal approximation theorem of Cybenko (1989); Hornik (1991); Pinkus (1999), PINNs aim to deliver a universal regressor that can represent any bounded continuous function and solve any PDE/ODE problems, having input and output shape as the only limitation. Although the goal of PINNs was to produce a unifying method of solving PDE/ODEs, satisfactory results could not be achieved in a multitude of cases. The recent works of Karniadakis et al. (2021); Hao et al. (2022) provide an overview of the state-of-the-art; furthermore, Cuomo et al. (2022) focus on algorithms and applications and Beck et al. (2020) on theoretical results.
Several studies have analysed the effects of choosing different architectures, loss function formulations, and treatment of domain and collocation points. However, the effect of the optimiser choice on PINN performance needs more attention. Recently, new PINN-specific optimisation methods were developed or applied to improve poor convergence performance. For example, De Luca & Silverstein (2022) propose a _relativistic_ optimisation algorithm that introduces chaotic jumps and Davi & Braga-Neto (2022) use a metaheuristic optimisation method, namely, particle swarm optimisation, to eliminate gradient-related problems.
This work aimed to improve the understanding of how PINNs performance is affected by optimiser choice. Specifically, we considered the following algorithms spanning different optimiser categories: gradient descent (GD) without momentum, LBFGS (Dennis & More, 1973; Goodfellow et al., 2016) (a second order quasi-Newton method), ADAM (Kingma & Ba, 2014) (an adaptive stochastic GD algorithm), and bouncing Born-Infeld (BBI) (De Luca & Silverstein, 2022). The first three optimisers are widely used in ML optimisation problems, whereas BBI is a recent realisation of a frictionless energy-conserving optimiser. See Appendix A for details.
Moreover, we introduce a new method to study optimisation in neural networks, which provides training trajectory curvature data at low computational cost. Using this approach, we studied the evolution of different optimisers through the network parameter space during training. Further discussion is given in Section 2.1.
Specifically, we apply PINNs to solve the linear advection equation as described in Section 2.2. Linear advection is a simple PDE with a single parameter, i.e., the wave speed \(\beta\), whose variation can tune the complexity of the PINN landscape (Krishnapriyan et al., 2021). Moreover, to understand how a network adjusts to different depths and widths, we considered two configurations of multi-layer perceptron architectures with different numbers of hidden layers and nodes per layer.
The main contributions of this work are:
* We found that the choice of optimisation algorithm significantly impacts the convergence of PINNs models. Specifically, second-order optimisers that do not directly follow gradient directions, such as LBFGS, performed better, as shown in Fig. 1a.
* We introduce a new low-cost method for studying the dynamics of optimisers. This relies on defining a local reference frame and evaluating the local curvature of the training trajectory in the NN parameter space.
* We found a negative correlation between PINNs convergence error and the newly introduced training trajectory curvature which is shown in Fig. 1b. This implies that good PINNs solutions lie in highly curved regions of the optimiser reference frame. Therefore, making PINNs converge is hard for those techniques designed to explore shallow landscapes that generalise well under perturbation.
## 2 Background
### Tracking local curvature
Solely observing the convergence performance of an optimiser will show which optimiser is the best for a given task but will give limited information as to why. To move a step towards explaining why one optimiser is better than another, we analyze the trajectory of every optimiser in their local reference frame.
To begin, let \(\mathbf{\omega}\) be the neural network parameters, the weight update rule for update \(k\) is defined as \(\Delta\mathbf{\omega}_{k}\equiv\mathbf{\omega}_{k+1}-\mathbf{\omega}_{k}=\mathbf{V}(\mathbf{ \omega}_{k},\mathbf{\eta})\), where \(\mathbf{\eta}\) are the model hyperparameters. Assuming the continuum time limit, the trajectory in the parameter space during training can be described by:
\[\hat{\mathbf{\omega}}=\mathbf{V}(\mathbf{\omega},\mathbf{\eta}), \tag{1}\]
where the overdot corresponds to a time derivative, i.e. \(\hat{\mathbf{\omega}}=\mathrm{d}\mathbf{\omega}/\mathrm{d}t\). When using gradient descent, Eq. (1) can be interpreted as the equation of motion of a classical particle in a friction-dominated setup and \(\mathbf{V}(\mathbf{\omega},\lambda)=-\lambda\frac{1}{n}\sum_{i}\nabla_{\mathbf{\omega} }\ \mathcal{L}(\mathbf{x}^{(i)},\mathbf{\omega})\). Here, \(\lambda\) is the learning rate, \(n\) is the number of samples in the training set \(\{\mathbf{x}^{(1)},\mathbf{x}^{(2)},\cdots,\mathbf{x}^{(n)}\}\), and \(\mathcal{L}\) is the loss function. For other optimisation algorithms, the definition of \(\mathbf{V}\) changes and the ODE in Eq. (1) is no longer obtained via the Euler-Lagrange equations. Therefore, it does not have a dynamic interpretation. However, Eq. (1) can be efficiently used to understand the kinematics of the optimiser trajectories. This aspect is discussed further in Section 3.
To examine the motion in parameter space described by Eq. (1), we introduce the unit vector tangential to the training trajectory, defined as
\[\hat{\mathbf{T}}=\frac{\hat{\mathbf{\omega}}}{\|\hat{\mathbf{\omega}}\|_{2}},\quad \text{with}\quad\|\hat{\mathbf{\omega}}\|_{2}=\sqrt{\langle\hat{\mathbf{\omega}},\hat {\mathbf{\omega}}\rangle}. \tag{2}\]
Here, \(\hat{\mathbf{T}}\) is a time-dependent vector in a \(N_{\mathbf{w}}\)-dimensional space, for a \(N_{\mathbf{w}}\) parameter NN. To track the local training trajectory curvature in this time-dependent reference frame, we can define the local (time-dependent) curvature, \(\kappa_{t}\). This is the rate at which the tangent unit-vector changes with respect to time, and is given by:
\[\kappa_{t}=\left\|\frac{\mathrm{d}\hat{\mathbf{T}}}{\mathrm{d}t}\right\|_{2}= \frac{1}{\|\hat{\mathbf{\omega}}\|_{2}}\left[\mathbf{\tilde{\omega}}\cdot\mathbf{\tilde{ \omega}}-\left(\frac{\mathrm{d}\|\hat{\mathbf{\omega}}\|_{2}}{\mathrm{d}t}\right)^{ 2}\right]^{1/2}. \tag{3}\]
Another parametrisation with a clearer geometric meaning is \(\kappa_{\omega}=\left\|\frac{\mathrm{d}\mathbf{\hat{\Sigma}}}{\mathrm{d}\omega} \right\|_{2}=\kappa_{t}/\|\boldsymbol{\dot{\omega}}\|_{2}\). This represents a local geometric quantity, i.e., the local curvature in the parameter space, removing the effects of time and trajectory speed1. To calculate the curvature at each training step a first-order approximation is used, details of which are given in Appendix C.
Footnote 1: This is the local curvature of the training trajectory, not the curvature of the space of weights, which is flat.
In comparison with a Hessian-based curvature calculation, the method presented here has a significantly lower computational cost as it does not require the Hessian of the loss function. Furthermore, in most cases, an optimiser does not solely follow the gradient loss and it is generally non-trivial to find the function relating the loss, its derivatives, and the trajectory followed by the optimiser. Therefore, although every optimiser is constructed with the aim of sharing its minima with the loss function, analyzing the loss Hessian may not characterise the optimiser trajectories and may not explain why a certain minimum is found. Moreover, different optimisers are based on different assumptions--such as energy conservation, friction-dominated motion, or others--further modifying the loss seen by the optimiser. Fig. 2 in Appendix C gives a pictorial representation of the loss function (or its distorted version seen by the optimiser) and its relationship to the trajectory in the parameter space.
### Linear Advection
The PDE used for the tests in this work was the one-dimensional linear advection equation on the periodic spatial domain \(\Omega=[0,2\pi)\), given by
\[\frac{\partial u}{\partial t}+\beta\frac{\partial u}{\partial x} =0,\quad\text{for}\quad\mathrm{u}:\mathrm{T}\times\Omega\mapsto \mathbb{R},\quad\Omega=[0,2\pi),\mathrm{T}\in[0,1], \tag{4a}\] \[u(x,0) =u_{0}(x),\] (4b) \[u(0,t) =u(2\pi,t), \tag{4c}\]
where \(\beta\) is the wave speed and \(u_{0}(x)\) is the initial condition. The exact solution of this system can be straightforwardly found using the superposition of Bloch waves. To find approximate solutions to this system we applied PINNs with loss functions similar to those used by Krishnapriyan et al. (2021), defined as
\[\mathcal{L}(\theta)=\frac{1}{N_{u}}\sum_{i=1}^{N_{u}}\left(\hat{u}-u_{0}^{i} \right)^{2}+\frac{1}{N_{f}}\sum_{i=1}^{N_{f}}\lambda_{i}\left(\frac{\partial \hat{u}}{\partial t}+\beta\frac{\partial\hat{u}}{\partial x}\right)^{2}+\frac {1}{N_{b}}\sum_{i=1}^{N_{b}}\left(\hat{u}(\theta,0,t)-\hat{u}(\theta,2\pi,t) \right)^{2}.\] (5a) Here \[\hat{u}=\hat{u}(\theta,x,t)\] is the neural network output, parameterised by \[\theta\]. The initial condition used through out this work was \[u(x,0)=\sin(x)\] and \[u(0,t)=u(2\pi,t)\]. For all the experiments we fix \[\lambda_{i}=1\].
## 3 Results and Discussion
Fig. 0(a) shows the median over 10 samples of the mean squared error (MSE) evaluated on the entire domain between the \(\hat{u}\) predicted by the PINN and the analytical solution. Here the samples were formed by using 10 different random network initialisation. The corresponding training and test losses are shown in Appendix D.1. During testing, it was observed that the learning rate significantly impacts the final performances; therefore, a grid search was performed over a range of learning rates to estimate the best configuration for each optimiser. See Appendix B for the details.
Two multi-layer perception architectures were considered, with layer structures \(S=[2,25,25,1]\) and \(L=[2,50,50,50,50,1]\) resulting in \(751\) and \(7851\) trainable parameters respectively2. The number of training points was around 2000, as described in Appendix B; therefore, the larger network is in the over-parameterised regime, i.e. it has more parameters than training data. Fig. 0(a) shows that the large network
generally has a lower error, in agreement with common knowledge in ML3. This effect is most noticeable for BBI 4. A significant observation is that for all configurations of NN and optimiser, PINNs failed to produce good approximations for systems with large values of \(\beta\).
Footnote 3: From classical statistical learning, one expects that over-parameterised models over-fit. However, there is overwhelming evidence that large models generalise well in several cases of interest, e.g. Szegedy et al. (2015); Huang et al. (2019).
Footnote 4: The total phase space volume for BBI can be analytically estimated and is parametrically large as the objective function is close to zero with an exponential dependence on the number of dimensions (see Appendix A.3 in De Luca and Silverstein (2022)).
In Fig. (b)b, we show the inverse relation between the final values of MSE and the curvature \(\kappa_{\omega}\). Here, only \(\beta=1,5\) were considered as they converged to reasonable errors for most of the optimisers, see Appendix D.2. Significantly, LBFGS achieves the highest values of \(\kappa_{\omega}\) and the lowest error. Moreover, LBFGS has significant memory overhead but it typically converges in fewer epochs compared to the other optimisers. Note that such a negative correlation in Fig. (b)b links generalisation (measured by the MSE on the entire domain) with the curvature \(\kappa_{\omega}\). Deriving their exact relation is non-trivial and we leave further investigations for future work. Nevertheless, we would like to stress that the high curvature values is not solely associated with orbiting the final local or global minima. In fact, this is due to \(\kappa_{\omega}\) and MSE being negatively correlated throughout the whole trajectory, including its initial stages. We show examples of this behavior in Appendix D.2.
Outlook. In contrast to traditional ML tasks such as image recognition and NLP, ML methods applied to science require more accurate models which, in general, are trained with high-quality data. This suggests that the training process on data from physical phenomena can be fundamentally different from common ML applications. A promising future research direction would be exploring the connection between model generalisation and the flatness of minima for problems requiring high accuracy. For example, the work of Dinh et al. (2017); Huang et al. (2020) discuss this in the context of traditional ML tasks. Finally, in the future, it would be insightful to compare Hessian-based methods such as that of Michaud et al. (2023), with our approach linking accuracy and local trajectory curvature.
Figure 1: (a) Median MSE over 10 samples for various optimisers and \(\beta\) values. _Solid/dashed_ lines refer to small/large (S/L) network architectures. (b) Relation between final values of convergence (MSE) and curvature (\(\kappa_{\omega}\)) for \(\beta=1\) (left) and \(5\) (right). Dots and crosses refer to small (S) and large (L) networks, respectively.
#### Acknowledgments
We thank Eloisa Bentivegna and Imran Nasim for discussions. NF and WT acknowledge the UKRI support through the grant MR/T041862/1. The authors acknowledge the IBM Research Cognitive Computing Cluster service for providing resources that have contributed to the research results reported within this work.
|
2304.04982 | Biological Factor Regulatory Neural Network | Genes are fundamental for analyzing biological systems and many recent works
proposed to utilize gene expression for various biological tasks by deep
learning models. Despite their promising performance, it is hard for deep
neural networks to provide biological insights for humans due to their
black-box nature. Recently, some works integrated biological knowledge with
neural networks to improve the transparency and performance of their models.
However, these methods can only incorporate partial biological knowledge,
leading to suboptimal performance. In this paper, we propose the Biological
Factor Regulatory Neural Network (BFReg-NN), a generic framework to model
relations among biological factors in cell systems. BFReg-NN starts from gene
expression data and is capable of merging most existing biological knowledge
into the model, including the regulatory relations among genes or proteins
(e.g., gene regulatory networks (GRN), protein-protein interaction networks
(PPI)) and the hierarchical relations among genes, proteins and pathways (e.g.,
several genes/proteins are contained in a pathway). Moreover, BFReg-NN also has
the ability to provide new biologically meaningful insights because of its
white-box characteristics. Experimental results on different gene
expression-based tasks verify the superiority of BFReg-NN compared with
baselines. Our case studies also show that the key insights found by BFReg-NN
are consistent with the biological literature. | Xinnan Dai, Caihua Shan, Jie Zheng, Xiaoxiao Li, Dongsheng Li | 2023-04-11T04:57:02Z | http://arxiv.org/abs/2304.04982v1 | # Biological Factor Regulatory Neural Network
###### Abstract.
Genes are fundamental for analyzing biological systems and many recent works proposed to utilize gene expression for various biological tasks by deep learning models. Despite their promising performance, it is hard for deep neural networks to provide biological insights for humans due to their black-box nature. Recently, some works integrated biological knowledge with neural networks to improve the transparency and performance of their models. However, these methods can only incorporate partial biological knowledge, leading to suboptimal performance. In this paper, we propose the Biological Factor Regulatory Neural Network (BFReg-NN), a generic framework to model relations among biological factors in cell systems. BFReg-NN starts from gene expression data and is capable of merging most existing biological knowledge into the model, including the regulatory relations among genes or proteins (e.g., gene regulatory networks (GRN), protein-protein interaction networks (PPI)) and the hierarchical relations among genes, proteins and pathways (e.g., several genes/proteins are contained in a pathway). Moreover, BFReg-NN also has the ability to provide new biologically meaningful insights because of its white-box characteristics. Experimental results on different gene expression-based tasks verify the superiority of BFReg-NN compared with baselines. Our case studies also show that the key insights found by BFReg-NN are consistent with the biological literature.
biological factor, gene regulatory network +
Footnote †: [leftmargin=*] *The work was done during the author’s internship with Microsoft.
+
Footnote †: [leftmargin=*] *The work was done during the author’s internship with Microsoft.
the functions of genes or proteins, and ultimately give insights into the mechanism of larger living systems. Particularly, BFReg-NN is a neural network with the following architecture. For one thing, each neuron is mapped into a biological factor (e.g., a specific gene or protein), and arranged level by level based on the hierarchy of biological concepts, such as genes, proteins, pathways, biological processes, and so on. For another, since biological factors regulate each other, edges between neurons (and hyperedges among neurons) are set to reflect the existence of these regulations. In such a manner, edges also model biological meanings.
Further, we apply two different operations to simulate all the types of interactions in BFReg-NN. Inside one layer, genes regulate each other and create feedback loops to form cyclic chains of dependencies in the regulatory network. Therefore, graph neural network styled operations are suitable to build the gene reactions in the k-hop neighborhood, and obtain the "steady state" of genes. It is the same for proteins in PPI. In the layer of pathways, it can be regarded as a hypergraph where each hyperedge is a pathway containing multiple proteins. Accordingly, the hypergraph neural network is used to aggregate and balance the information of each pathway. Across the layers, we need to imitate the material transformation (e.g., genes translate protein). Thus, we adopt deep neural network styled operations to map the relations.
Moreover, BFReg-NN is flexible to explore new biological knowledge by trying to add non-existing edges in the network. The reason is that some edges are still hard to be discovered due to technological limitations and rewiring phenomenons in individual cells. If the prediction performance is improved by added edges, it is more likely that these edges exist. We illustrate BFReg-NN simulates on genome-scale cell system as an example in Figure 1.
The advantages of our proposed model include: (1) Compared with previous works, BFReg-NN merges with the structural biological knowledge in cell systems, including hierarchical relations (e.g., genes-proteins, proteins-pathways mappings), and regulatory relations among certain factors, such as GRN and PPI. Therefore, it could imitate how different biological factors work inside a cell. (2) The model of BFReg-NN is transparent and interpretable, as each neuron and edge has its corresponding biological meaning. Thus, the learned model weights give evidence of which biological parts are activated and which biological products are generated, leading to the final prediction. (3) By adding new edges between neurons, BFReg-NN not only achieves better performance in downstream tasks, but also has the potential to complete undiscovered biological knowledge. Traditional knowledge completion methods for biological domains (e.g., link prediction by knowledge bases/graphs) suffer from imbalanced data problems (Brock et al., 2017). BFReg-NN utilizes the gene expression data, which reflects the real cell states, and thus obtains more reliable results.
In the experiment, we show the effectiveness of BFReg-NN on several kinds of biological tasks, including missing gene expression value prediction, cell classification, future gene expression value forecasting and cell trajectory simulation. We also test the knowledge completing ability of BFReg-NN by the recall of the existing biological knowledge. Finally, we do case studies for newly discovered knowledge. The results demonstrate that BFReg-NN provides biologically meaningful insights.
## 2. Related Work
**Gene expression and its applications:** By RNA sequencing, it is easy to obtain gene expression which is a value to represent the amount of gene transcripts from a DNA fragment (Kraus et al., 2017). It has been used in a variety of biological applications, including single-cell analysis (Shen et al., 2017; Wang et al., 2018), disease diagnosis (Shen et al., 2018) and drug discovery (Shen et al., 2018). But most of these models lack transparency and ignore the existing biological knowledge.
**Knowledge graph enhanced downstream tasks:** The emergence of knowledge bases/graphs has led to enhancing the performance in many fields of computer science, such as computer vision and natural language processing (Shen et al., 2018; Wang et al., 2018; Wang et al., 2018). Similarly, knowledge graphs also have been widely used for specific biological tasks such as cancer diagnosis in recent years (Kraus et al., 2017; Wang et al., 2018). Some methods (Shen et al., 2018; Wang et al., 2018; Wang et al., 2018) used the Gene Ontology (GO) knowledge, which defines GO terms (e.g., molecular function, cellular component, biological process) and builds the neural network architecture based on term relations. However, the network is too sketchy to simulate the complex gene/protein reactions in the cell, leading to suboptimal performance. OntoProtein (Wang et al., 2018) embedded the gene ontology knowledge in pre-training to improve the performance of several protein downstream tasks. But it limited the interpretation ability because of transforming knowledge into embeddings. P-Net (Kraus et al., 2017) modeled the relations of gene-pathway and pathway-biological process as a neural network to diagnose prostate cancer. GLRP (Gulman et al., 2017) assigned genes to the PPI network to predict breast cancer, and then explained the important genes by Layer-wise Relevance Propagation. Although they mitigate the black-box issues, they all use a small part of biological knowledge, and they cannot explore new knowledge from gene expression data.
**Knowledge complement:** Our work is related to knowledge complement (Kraus et al., 2017; Wang et al., 2018). In particular, lots of work on biological knowledge complement has been done recently (Wang et al., 2018; Wang et al., 2018). Much attention is paid to predicting the relation between specific biological factors, which can be regarded as a link prediction problem. For example, (Kraus et al., 2017) classified whether ligand and receptor proteins interact based on their molecular structures. (Wang et al., 2018) predicted drug-target interaction (DTI) by learning representations of drugs and targets from the KEGG database. (Kraus et al., 2017) discovered new drugs for diseases by embedding the drug-gene-disease database in multiple relations. However, existing biological knowledge is collected in imbalance, which causes little biological meaningful predictions (Brock et al., 2017). In our work, we expect discovered knowledge from gene expression data, which can interpret the cell state by biological factor interactions and avoid imbalanced situations.
## 3. Biological Background
The biological system is modeled by a complex network that connects many biologically relevant entities to work together to perform one or more particular functions. It could be at the organ/tissue scale, such as the nervous system, or the integumentary system. On the micro/nanoscopic scale, examples include cells, organelles, and so on. In this work, we focus on the simulation of the biological system in a cell at a genome-scale.
Thanks to the development of sequencing technologies, it is easy and cheap to obtain an amount of gene expression data to build genome-scale analysis. Starting from genes, we model the cell genome-scale system by single-omic level (intra-level) regulations and different onice level (inter-level) mappings (Becker et al., 2015). Among different ionic levels, defined as inter-level in BFReg-NN, genes are first transcribed from DNA and then translate to proteins. Then, pathways integrate individual genes or protein products to perform certain cell functions. To model single-omic level regulations, we define the intra-level interactions. Genes are regulated by each other, known as GRN, which means the gene expression values are governed to be inhabited or activated by association molecule products, such as RNA. The interactions among proteins are similar, where they inhabit, activate, or combine with others to influence the expression values (or protein abundances) in cells, called PPI. Notice that in general, the relations among factors are universal for all the cells, thus the biological knowledge could adapt to different types of cells. But sometimes the biological factor interaction would rewire in specific cells, and thus the extra knowledge discovered and verified is also important (Kang et al., 2017).
## 4. Methodology
Assume we have gene expression data \(\mathbf{x}\in\mathbb{R}^{n}\) show the state of a cell, where \(n\) is the number of genes. Besides, we also define the neural network architecture of BFReg-NN according to structural biological knowledge with the intra-level regulations \(\mathcal{A}\) and the inter-level mappings \(\mathcal{M}\). After training BFReg-NN, we obtain the hidden embedding \(\mathbf{H}_{i}=\text{BFReg-NN}(\mathbf{x},\mathcal{A},\mathcal{M})\) for each gene \(i\), and do predictions for downstream tasks.
The output format of predictions could be a single value \(y=f(\mathbf{H})\), or multiple values \(\mathbf{x}=f(\mathbf{H})\). Further, we also handle the time-series output. Given the gene expressions of cells at the \(t_{0}\) time, we aim to predict the gene expressions \(\hat{\mathbf{X}}\in\mathbb{R}^{n\times T}=f(\mathbf{H})\) in the following \(t_{1},\ldots,T\) time steps. Finally, BFReg-NN could explore new insights by adding more edges \(\mathcal{A}^{\prime}\).
In the following sections, we first extract \(\mathcal{A}\) and \(\mathcal{M}\) from the existing biological databases/graphs. Then, we propose two versions of BFReg-NN. Finally, we introduce how to apply BFReg-NN to different downstream tasks.
### Biological knowledge databases/graphs
Based on the existing biological knowledge, we first divide biological factors into different levels, \(\mathcal{L}=\{\text{Gene},\text{Protein},\text{Pathway},\ldots\}\). At each level, regulatory relations between factors in the intra-level are formulated as a matrix set \(\mathcal{M}=\{\mathbf{A}_{\text{Gene}},\mathbf{A}_{\text{Protein}},\mathbf{A}_{ \text{Pathway}},\ldots,\mathbf{A}_{L}\}\), where \(\mathbf{A}_{\text{Gene}}\) could be gene relations and defined by GRN, and \(\mathbf{A}_{\text{Protein}}\) is decided by PPI. \(\mathbf{A}_{\text{Pathway}}\) is a little special because it is a hypergraph, where each edge could connect more than two nodes, called the hyperedge. The proteins in a hyperedge propagate the information to influence each other directly.
The values in \(\mathbf{A}_{I}\) are binary to represent the existence of relations. We also identify the binary mapping matrixes \(\mathcal{M}=\{\mathbf{M}_{1},\mathbf{M}_{2},\ldots,\mathbf{M}_{L-1}\}\) from level \(l\) to its upper level \(l+1\) as the inter-level interaction. The dimension of \(\mathbf{M}_{I}\) is dependent on the factor numbers of the two levels. We set \(\mathbf{M}_{1}\) to map between genes and proteins, and \(\mathbf{M}_{2}\) as a
Figure 1. The pipeline of BFReg-NN. We build the hierarchical biological network inspired by the cell system, modeling several levels to separate mRNA, protein, pathway and phenotype, and simulating biological factor interactions both at the intra-level and inter-level. We obtain the gene expression value from RNA sequencing as input, to predict the property of the phenotype as output. Taking the cancer dataset NCI-60 as an example. We know that the regulatory activations start from gene HIF1A and TP53 to gene AURKA and CDKN1A at the gene level (Kang et al., 2017). And at the protein level, the translated proteins Q16665 and P04637 stimulate P17858 and O14965 respectively (Kang et al., 2017). We mark those relations as existing biological knowledge by the black solid lines. Multiple genes with their products consist of pathways to drive cells to different types. For example, PFKL and HIF1A are activated in the HEPG2 cell line pathway, which leads to a type of liver cancer (Kang et al., 2017). Besides, new regulatory relations would be identified at each level shown as dotted lines. After training, we learn the good representations of biological factors, and employ them for different downstream tasks with various output formats.
direct mapping between protein-level and pathway-level. \(\mathcal{A}\) and \(\mathcal{M}\) both decide the architecture of the neural network, including neurons and links between neurons.
### Basic BFReg-NN model
Given the gene expression of a cell \(\mathbf{x}\), we first utilize an embedding layer to encode each gene independently, where \(\mathbf{H}_{i}^{0,0}=\text{Emb}(\mathbf{x}_{i})\). The embedding layer lets genes share the same parameter MLP layer to obtain the gene expression representation. As the gene expression is in a floating form with a little measurement error, the embedding layer is utilized to reduce this error and thus enhance the performance of the model. Then we obtain \(\mathbf{H}^{0,0}\in\mathbb{R}^{n\times d}\) as the input to neurons at the first level, i.e., gene neurons.
We have \(\mathbf{A}_{l}\) as intra-level relations between neurons at level \(l\). Inspired by graph neural networks, we use the message passing mechanism to update \(\mathbf{H}^{l,k}\), which is the hidden representation of the neuron in the \(k\)-hop at level \(l\). The formulation is:
\[\mathbf{H}_{i}^{l,k+1}=\text{update}\left(\sum_{j\in\mathbf{A}_{l}(i)}\text{ message}\left(\mathbf{H}_{i}^{l,k},\mathbf{H}_{j}^{l,k}\right),\mathbf{H}_{i}^{l,k} \right). \tag{1}\]
The message function is to generate the message from neuron \(j\) to neuron \(i\), where \(\mathbf{A}_{l}(i)\) decides which neurons are neighbors for neuron \(i\). Then the update function is to update the embedding of neuron \(i\) using the obtained messages and the previously hidden embedding. \(k\in[0,K-1]\) is the number of hops to determine that neuron \(i\) is influenced by other neurons in the \(K\)-hop neighborhood. Batch normalization is conducted at the end of each level. In detail, we utilize GAT-styled (graph attention) (Sutskever et al., 2017) to compute the attention weight for each message, and weighted sum up all the messages to update. As for operations in hypergraphs, we apply HGNN-styled (hypergraph neural network) (Bahdan et al., 2017) message and update functions. Specifically, the hypergraph can be represented by an incidence matrix \(\mathbf{R}\in\mathbb{R}^{|\mathbf{V}_{\mathbf{R}}|\times|\mathbf{E}_{\mathbf{R }}|}\), where \(\mathbf{R}_{ij}=1\) means the node \(i\) belongs to the hyperedge \(j\) (i.e., the protein \(i\) is contained in the pathway \(j\)). The equation is
\[\mathbf{H}^{l,k+1}=\sigma(\mathbf{D}_{\mathbf{R}}^{-1}\mathbf{R}\mathbf{B}_{ \mathbf{R}}^{-1}\mathbf{R}^{T}\mathbf{H}^{l,k}\mathbf{W}^{l,k})\]
where \(\mathbf{D}_{\mathbf{R}}\) and \(\mathbf{B}_{\mathbf{R}}\) are two corresponding degree matrices for normalization, and \(\mathbf{W}^{l,k}\) is the learnable matrix.
Due to multiple-level interactions in biological systems, the embedding is also learned level level by. Since \(\mathbf{M}_{l}\) is inter-level relations between level \(l\) and \(l+1\), we utilize the masked deep neural network to update the initial representation \(\mathbf{H}^{l+1,0}\) at next level
\[\mathbf{H}^{l+1,0}=\text{activation}\left(\left(\mathbf{M}_{l}\odot\mathbf{W }^{l,K}\right)\mathbf{H}^{l,K}+\mathbf{b}^{l}\right).\]
\(\mathbf{H}^{l,K}\) is the output after batch normalization. The element-wise multiplication \(\mathbf{M}_{l}\odot\mathbf{W}^{l,K}\) ensures that non-existing relations are not used for updating. \(\mathbf{W}^{l,K}\) and \(\mathbf{b}^{l}\) are learnable parameters.
### Enhanced BFReg-NN model
Here the enhanced version is introduced by adding new edges in \(\mathcal{A}=\{\mathbf{A}_{\text{Gene}},\mathbf{A}_{\text{Protein}},\mathbf{A}_{ \text{Pathway}},\ldots\}\). It can explore new biological insights and improve performance simultaneously.
Existing biological knowledge is detected by biological technology to reflect the implicit relations among factors. However, some knowledge is still hard to be discovered due to technological limitations and rewiring phenomenons in individual cells. Therefore, we spilt the interaction into two types. One is the universal regulation, supported by existing knowledge \(\mathcal{A}\). The other is local interaction, inferring the new biological knowledge or rewiring in individual cells, but now hidden in the non-existent edges of \(\mathcal{A}\). Instead of a binary matrix \(\mathbf{A}_{l}\) used in the basic model, we use \(\mathbf{A}_{l}\) to constrain the learnable matrix \(\mathbf{A}^{\prime}_{l}\) to discover new knowledge. As universal regulations are verified by biological methods, we use them the same as the basic model. For non-existent edges, we reweigh it by a small value \(0\leq\alpha<1\) due to it being less convincing. Thus, the edge intensity based on two types of knowledge is modified as:
\[\mathbf{A}^{\prime}_{l}=\begin{cases}\alpha^{l}_{ij^{\prime}}&\text{universal regulation that already exists in }\mathbf{A}_{l}\\ \alpha^{0}_{ij^{\prime}}&\text{local interaction that is ignored in }\mathbf{A}_{l} \end{cases} \tag{3}\]
where \(\alpha^{l}_{ij}=\sigma(\text{MLP}(\text{concat}[\mathbf{H}_{l}^{l},\mathbf{H}_{ j}^{l}]))\). In the enhanced model, we not only learn the neuron embeddings, but also utilize these embeddings with an MLP transformation to infer the intensity of the hidden interaction between neuron \(i\) and \(j\). Then we update the representations by
\[\mathbf{H}^{l,k+1}=\sigma\left(\mathbf{A}^{\prime}_{l}\mathbf{H}^{l,k}\mathbf{ W}^{l,k}\right). \tag{4}\]
After the model is trained to converge, we obtain the learned weights for non-existence edges, which provides insights for new knowledge and the rewiring phenomenon. We sort the weights \(\mathbf{w}^{l}_{ij}\) to identify the candidates which deserve verification by biological experiments. Here we use a simple edge weight modification method instead of gated edges implemented by the gumble-softmax function or advanced graph structure learning algorithms (Sutskever et al., 2017; Wang et al., 2018). The reason is that the biological knowledge is not sparse, and even dense in some core genes. Thus, it does not satisfy the sparse and low-rank requirements. Besides, we also implement a neural network where the existence of new edges is gated by the gumble-softmax function, but it does not work in the experiments. Our simple method does not add much extra computation cost while achieving great effectiveness in biological tasks.
### Downstream Tasks
After we obtain the final embedding \(\mathbf{H}^{l,K}\), we could conduct different types of downstream tasks, whose output format could be one-dimensional, multiple-dimensional, or time-series. Here we illustrate them with three specific tasks, missing gene expression value prediction, future gene expression value forecasting, and cell classification.
**Missing gene expression value prediction:** Suppose we have a gene expression vector \(\mathbf{x}\in\mathbb{R}^{n}\) for \(n\) genes, measured by the single-cell sequencing technology. Some parts in the vector are zeros or in a low value because of dropout events (K
**Cell classification:** This task is to classify the cell types using gene expression values \(\mathbf{x}\), which is important to determine the situation of tissues or patients. Because cell type is the observable result of a biological system, we simulate each gene to pass the multiple levels of transformation to infer the property of the cell. The prediction is computed by \(\hat{y}=\mathrm{MLP}(\mathbf{H}^{L,K})=\mathrm{MLP}(\mathrm{BFReg-NN}(\mathbf{x}))\). It is a multi-class classification task and we employ a cross-entropy loss.
**Future gene expression value forecasting:** The single-cell data is efficient to analyze the cell response under different drugs. However, it is expensive to collect the data at different time steps and draw the development trend of cells. Thus, we model the cell response by future gene expression value prediction. In other words, given the gene expression data \(\mathbf{x}\in\mathbb{R}^{n}\) at \(t_{0}\), we aim to forecast the gene expression data \(\bar{\mathbf{X}}\in\mathbb{R}^{n\times T}\) in the following \(t_{1},\dots,T\) time steps. We use two backbones, MLP and LSTM. MLP predicts the gene expression in the future time steps simultaneously, and the equation is \(\hat{\mathbf{X}}=\mathrm{MLP}(\mathrm{BFReg-NN}(\mathbf{x}))\). LSTM models the dynamic values step by step, where it takes the last time output as the next step input, and the equation is \(\hat{\mathbf{x}}^{t}=\mathrm{LSTM}(\mathrm{BFReg-NN}(\hat{\mathbf{x}}^{t-1}))\). We employ MSE as the loss function.
## 5. Further Applications
BFReg-NN has the potential to be plugged into more sophisticated models, such as generative models and pre-learning.
### Cell trajectory simulation
In this task, we regard cells as a population to understand the population dynamics. In other words, our goal is to simulate the evolution of the distribution of gene expression over time. Since the single-cell sequencing technology makes the cells die after measurement, we can only know the distribution of gene expression of a part of cells at a certain time step, i.e., \(\{x_{1,t_{i}},x_{2,t_{i}},\cdots,x_{N_{i},t_{i}}\}\) where \(i=\{1,2,\cdots,T\}\). Based on previous papers (Srivastava et al., 2017; Wang et al., 2018), we also utilize continuous normalizing flows (Beng et al., 2018) as the generative model to learn an underlying differentiation landscape from scRNA-seq data. The main difference is that our proposed BFReg-NN is utilized as \(f_{0}\) instead of a traditional DNN. Because the architecture of BFReg-NN is built on biological factors and their interactions are also regarded as differential equations, BFReg-NN has a better inductive bias to model complex relationships and further improves the performance.
Specifically, assume that \(P_{t}(\mathbf{x})\) is the distribution of gene expression of cells at time step \(t\), and \(\mathbf{x}(t)\) is the gene expression of a cell drawn from \(P_{t}(\mathbf{x})\). Let \(\frac{\mathrm{d}\mathbf{x}(t)}{\mathrm{d}t}=f_{0}(\mathbf{x}(t),t)\) be a differential equation describing a continuous-in-time gene transformation of \(\mathbf{x}\). We seek to train \(f_{0}\) satisfying
\[\mathbf{x}(t_{i}) \sim P_{t_{i}}(\mathbf{x})\quad i=0,1,2,\cdots,T\] \[\frac{\mathrm{d}\mathbf{x}(t)}{\mathrm{d}t} =f_{0}(\mathbf{x}(t),t)\text{ for }t\in[t_{0},t_{T}].\]
According to the characteristic of continuous normalizing flows, we have
\[\log P_{t_{T}}(\mathbf{x}(t_{T}))=\log P_{t_{0}}(\mathbf{x}(t_{0}))-\int_{t_{0}}^{t_{T }}\mathrm{Tr}(\frac{\partial f_{0}(\mathbf{x}(t),t)}{\partial\mathbf{x}(t)})\mathrm{d}t.\]
Therefore, given a batch of empirical samples \(\{x_{0,t_{i}},x_{1,t_{i}},\cdots,x_{N_{i},t_{i}}\}\) where \(i=\{0,1,\cdots,T\}\), we can first map the distribution at the time \(t_{i}\) into the distribution at the time \(t_{i-1}\). Then we compare the distribution difference to make it as the same as possible. We use the wasserstein distance as the loss to evaluate the difference.
Then we utilize BFReg-NN to instantiate \(f_{0}\). Assume that we only have one layer, such as gene layer. We first embed \(\mathbf{x}\) by \(\mathbf{H}^{0}=\mathrm{Emb}(x)\), and change the message passing for genes
\[\mathbf{H}^{k+1}=\mathbf{H}^{k}+\int_{t_{i}}^{t_{k}+\alpha_{T}}f_{0}(\mathbf{ H}(t),t)\mathrm{d}t \tag{5}\]
where \(f_{0}(\mathbf{H}(t),t)=\sigma(A^{\prime}\mathbf{H}(t)\mathbf{W}(t))\mathbf{U}(t)\), and \(\mathbf{W}(t)\) and \(\mathbf{U}(t)\) are produced by the hypernetwork (Kang et al., 2018) to make them change over time. When we have different \(L\) layers in BRReg-NN, which mean \(f_{0}\) is a piecewise function based on the value of \(t\). One straightforward and effective approach is to define \(f_{0}\) as:
\[\begin{cases}f_{0_{1}}\leftarrow\sigma(A^{\prime}_{1}(t)\mathbf{W}^{1}(t)), \ t\in[t_{i},t_{i}+\frac{L}{L}\Delta_{t})\\ f_{0_{2}}\leftarrow\sigma((\mathbf{M}_{1}\odot\mathbf{W}^{2}(t))\mathbf{H}(t) +\mathbf{b}^{2}(t)),\ t\in[t_{i}+\frac{L}{L}\Delta_{t},t_{i}+\frac{L}{L} \Delta_{t})\\ \cdots\\ f_{0_{L}}\leftarrow\sigma(A^{\prime}_{L}\mathbf{H}(t)\mathbf{W}^{L}(t)) \mathbf{U}(t),\ t\in[t_{i}+\frac{L-1}{L}\Delta_{t},t_{i}+\Delta_{t}].\end{cases}\]
\(f_{0_{1}}\) imitates the interactions in gene layer, \(f_{0_{2}}\) simulates the mapping from genes to proteins, and then the following \(f_{0_{i}}\) imitate the reactions in higher layers.
### Pre-training
BFReg-NN is also suitable in pre-training and fine-tuning framework. For example, we utilize the missing gene expression prediction task to pre-train a BFReg-NN. Then we freeze the parameters of BFReg-NN except for the last MLP layers, and fine-tune the last MLP layers in downstream tasks, such as forecasting future gene expression and cell classification.
## 6. Experiments
In this section, we first describe the experimental setting for each task, including datasets, evaluation metrics, network architecture, baselines and training details (Section 6.1). Then we present the main results in Section 6.2. The cell trajectory simulation and pre-training are conducted in Section 6.3 and Section 6.4. Further, Section 6.5 shows the ability of BFReg-NN to discover the new biological knowledge. Finally, we did some ablation study to evaluate the each part of BFReg-NN in Section 6.6. All the experiments are run on a single A100 GPU. The code and toy datasets are in [https://github.com/DDigimon/BFReg](https://github.com/DDigimon/BFReg).
### Setup
#### 6.1.1. Datasets
Here we describe different datasets for all the tasks mentioned in Section 4 and 5.
**Missing gene expression value prediction:** In this task, we collect 10 cell lines (BT20, HS578T, LNCaP, A549, MCF7, MCF10A, MDAMB231, PC3, SKBR3 and A375) from the L1000 dataset. Because of the limitation of sequencing technology, the L1000 dataset
\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline Dataset & \#Sample & rGene & GBN knowledge & PPI knowledge & Pathways & fLabel \\ \hline GSE & 4688 & 418 & 172 & 136 & 89 & 8 \\ lung & 1642 & 382 & 148 & 332 & 121 & 11 \\ muscle & 1051 & 401 & 317 & 401 & 119 & 6 \\ trachea & 3587 & 326 & 109 & 207 & 110 & 5 \\ diaphragm & 853 & 355 & 239 & 299 & 115 & 5 \\ \hline \hline \end{tabular}
\end{table}
Table 1. Statistics for cell classification datasets
does not have the golden standard values for non-landmark genes. Thus, we employ the pre-processed data based on (Srivastava et al., 2017). Besides, we also ignore the time point information in cell lines. In each cell line, we have 1482 cell samples and 714 genes. We also collect 541 and 2305 existing knowledge edges for GRN and PPI respectively. We randomly mask the gene expression value with a 60% probability, and predict these missing values. The cell samples are randomly split by 60/20/20% as training/validation/test data. The evaluation metric is mean square error (MSE), which means the smaller the better.
**Cell classification:** We gather 5 datasets to predict cell types, and data statistics are summarized in Table 1. The first one is GSE756888 (breast cancer) collected from (Brock et al., 2017). The following four datasets are about organs, including muscle, diaphragm, lung and trachea, obtained from (Brock et al., 2017). We pre-process the data by deleting the cells and genes which have a larger ratio of zeros. The remaining data are summarized in Table 1. We also split the data same as the missing value task, and evaluate the results by macro AUC.
**Future gene expression value forecasting:** For future value prediction, we choose the breast cancer dataset from 2019 Dream Challenge (Deng et al., 2019). There are 44 cell lines and 5 treatments. Different treatments mean using various drugs on cells to test the drug effects. So we have 220 situations. In each situation, the detailed process to obtain time-series gene expression data is: all the cells are first treated and then divided into several groups. At (i)regular time step, a group of cells is killed and their gene expression is measured. There are seven timestamps, and about hundreds of cells are measured at each timestamp. To avoid noise caused by this measurement on each individual cell, we calculate the median for each gene. Thus, the format of data is \(\mathbf{X}\in\mathbb{R}^{N_{\text{treatment}}\times N_{\text{Netall,line}} \times N_{\text{mustemap}}\times N_{\text{gene}}}\).
Since the data are quantified at the proteomic level, we have 37 biomarkers as genes and 38 related PPIs as the existing knowledge, which is a small protein-protein interactions graph where nodes are phosphorylated genes. Different from the previous two tasks, we use 5 treatments as training data, and the remaining one as test data. The 5-fold cross-validation is done. We use MSE and Pearson correlation coefficient (PCC) to evaluate average performance.
**Cell trajectory simulation:** In this task, we use the same dataset as future gene expression forecasting. Instead of calculating the median value, we consider the evolution of the distribution of gene expression. Thus, we sample \(512\) cells at each timestamp. The current format of data is \(\mathbf{X}\in\mathbb{R}^{N_{\text{treatment}}\times N_{\text{Netall,line}} \times N_{\text{mustemap}}\times N_{\text{gene}}}\). In each situation (i.e., a certain combination of cell lines and treatments), we use the first two timestamps as known data, and predict the following trend for the remaining timestamps. The weessentrian distance is utilized to evaluate the similarity between two distributions. The performance is also averaged by the number of predicted timestamps.
**Pre-training:** The dataset and evaluation metric are also the same as future value forecasting.
#### 6.1.2. Neural network architecture
The architecture is totally defined by existing knowledge. From open-source databases, we select Dorothea (Deng et al., 2019) as GRN construction, and Omnipath (Marcus et al., 2019) as PPI. As the pathway is specific in different cells, we collect pathways for each dataset by Enrich (Enrich, 2017), which provides knowledge of the hyperedge connection among genes and proteins, including LINCS_L1000_Ligand_Perturbations for missing value task and WikiPathways_2019_MOUSE(HUMAN) for cell classification task. For future value forecasting and Cell trajectory simulation, we utilize its corresponding relations (38 related PPIs) in the dataset.
#### 6.1.3. Baselines
We divide baselines into three types:
(1) There is no prior knowledge integrated into the model, and the input is only gene expression data.
* **MLP** is the simplest model for static prediction.
* **LSTM** is the typical RNN-based model for dynamic value prediction.
* **Random Forest** and **XGBoost** are two classical tree-based models.
* **Transformer**(Srivastava et al., 2017) is an advanced model which achieves great performance in many NLP tasks.
* **GatedNN** is an improved version of deep neural networks, where edges between neurons are gated by the gumbel-softmax function so the network could be sparse.
(2) The second type of baselines is to first learn a gene co-expression matrix as knowledge and then do the prediction. The co-expression matrix identifies which genes have a tendency to show a coordinated expression pattern, so it can be built by the similarity between gene expressions. We follow the process described in MLA-GNN (Marcus et al., 2019) to learn the knowledge and then apply two classical graph neural networks, **GCN**(Marcus et al., 2019) and **GAT**(Srivastava et al., 2017), to aggregate the information and do the prediction.
(3) We also compare the models using the existing biological knowledge. This knowledge could be graphs, such as GRN or PPI.
* **MLP+N2V** used node2vec (Deng et al., 2019) to learn node embeddings of the prior graph, combine them with gene expression data and employ MLP to predict.
* **GCN** and **GAT** directly utilized the prior graph. As there are different prior graphs (GRN or PPI), we report the best results for GCN and GAT with the most suitable graph.
* **DCeII**(Srivastava et al., 2017) used the Gene Ontology (GO) knowledge to build the neural network architecture.
* **P-NET**(Marcus et al., 2019) utilized protein-pathway relations as prior knowledge and apply DNNs to predict.
* **BFReg-NN** is our proposed method. There are basic and enhanced versions.
#### 6.1.4. Training Details
For optimizers, we use Adam for all the models. The hyperparameters are summarized in Table 9 in Appendix. We set a small dimension of hidden embeddings to avoid overfitting. For the prediction module, we set the number of hidden units with the best value obtained from the validation data. In addition, the update function could be implemented by the sum or concatenation operation. We set \(K=1\) for all the experiments.
The performance of BFReg-NN is influenced by the value of hyperparameter \(\alpha\). While \(\alpha\) controls the acceptance of newly discovered knowledge, it is dependent on whether the existing biological knowledge is suitable for the current dataset, as shown in Table 10 in Appendix. For example, in the future value forecasting task, \(\alpha\) is larger than in other tasks to get the best result because existing knowledge is incomplete in the dataset. Besides, in the missing value task, our model performs better when \(\alpha=0\) in the protein
level, which means BFReg-NN ignores the irrelevant level when discovering knowledge. We vary it from [0, 0.00001, 0.00005, 0.0001, 0.0005, 0.001, 0.005] and select the best value when the loss is the smallest in the validation dataset.
### Main Results
Here we describe the results from two aspects, static and dynamic. Missing gene expression prediction and cell classification are static tasks, while future gene expression prediction is dynamic tasks.
**Static task results:** We report the main results for missing value prediction and cell classification, summarized in Table 2 and Table 3 respectively. Firstly, in general, compared to no prior knowledge methods, biological knowledge improves the performance of models effectively, which means that modeling specific meanings for neural networks could improve the performance in biological tasks. Although Gated NN includes the gumble-softmax function which also is able to predict edges in a probability, it is hard to generate the existing biological knowledge. Besides, co-expression knowledge does not show outstanding performance because it is extracted from a small size of data and thus brings the noise. Some complex model also achieves promising results, such as Transformer, which indicates that building dense biological relations may be needed for the cell samples.
\begin{table}
\begin{tabular}{l l c c} \hline \hline
**Knowledge** & **Models** & **MSE** & **PCC** \\ \hline \multirow{6}{*}{no prior knowledge} & MLP & 0.0761 \(\pm\) 0.0038 & 0.9704 \(\pm\) 0.0018 \\ & LSTM & 0.0822 \(\pm\) 0.0028 & 0.8888 \(\pm\) 0.0034 \\ & Transformer & 0.0743 \(\pm\) 0.0013 & 0.9717 \(\pm\) 0.0007 \\ & Gated NN & 0.0743 \(\pm\) 0.0026 & 0.9717 \(\pm\) 0.0007 \\ & Random Forest & 0.1115 \(\pm\) 0.0021 & 0.9685 \(\pm\) 0.0006 \\ & XGBoost & 0.0837 \(\pm\) 0.0033 & **0.9753**\(\pm\) 0.0008 \\ \hline \multirow{6}{*}{co-expression} & GCN & 0.3838 \(\pm\) 0.0090 & 0.8293 \(\pm\) 0.0036 \\ & GAT & 0.3447 \(\pm\) 0.0236 & 0.8455 \(\pm\) 0.0114 \\ \cline{1-1} \cline{2-4} & MLP+N2V & 0.0760 \(\pm\) 0.0043 & 0.9706 \(\pm\) 0.0018 \\ \cline{1-1} & GCN & 0.0920 \(\pm\) 0.0053 & 0.9646 \(\pm\) 0.0020 \\ \cline{1-1} & GAT & 0.0869 \(\pm\) 0.0044 & 0.9661 \(\pm\) 0.0017 \\ \cline{1-1} \cline{2-4} & BFReg-NN (MLP+B) & 0.0732 \(\pm\) 0.0026 & 0.9719 \(\pm\) 0.0009 \\ \cline{1-1} knowledge & BFReg-NN (MLP+F) & **0.0724**\(\pm\) 0.0023 & 0.9724 \(\pm\) 0.0007 \\ \cline{1-1} & BFReg-NN (LSTM+B) & 0.0825 \(\pm\) 0.0029 & 0.8906 \(\pm\) 0.0041 \\ \cline{1-1} & BFReg-NN (LSTM+E) & 0.0819 \(\pm\) 0.0027 & 0.8907 \(\pm\) 0.0049 \\ \hline \hline \end{tabular}
\end{table}
Table 4. Results on future gene expression value forecasting (evaluated by MSE\(\downarrow\) and PCC’).
\begin{table}
\begin{tabular}{c l c c c c c c c c c} \hline \hline
**Knowledge** & **Models** & **BT20** & **HS578T** & **LNCAP** & **A549** & **MCF7** & **MCF10A** & **MDAMB231** & **PC3** & **SKBR3** & **A375** \\ \hline \multirow{3}{*}{no knowledge} & MLP & **0.314** & 0.344 & 0.320 & 0.326 & 0.337 & 0.325 & 0.378 & 0.317 & 0.336 \\ & Transformer & 0.396 & 0.377 & 0.406 & 0.383 & 0.396 & 0.399 & 0.418 & 0.402 & 0.387 & 0.407 \\ & Gated NN & 0.709 & 0.681 & 0.644 & 0.533 & 0.647 & 0.700 & 0.667 & 0.722 & 0.594 & 0.729 \\ \hline \multirow{3}{*}{co-expression} & GCN & 0.715 & 0.714 & 0.722 & 0.653 & 0.688 & 0.675 & 0.707 & 0.731 & 0.677 & 0.702 \\ & GAT & 0.719 & 0.715 & 0.723 & 0.655 & 0.693 & 0.669 & 0.720 & 0.721 & 0.676 & 0.716 \\ \hline \multirow{6}{*}{existing knowledge} & MLP+N2V & 0.351 & 0.378 & 0.380 & 0.349 & 0.368 & 0.350 & 0.358 & 0.392 & 0.343 & 0.354 \\ & GCN & 0.331 & 0.329 & 0.330 & 0.304 & 0.340 & 0.313 & 0.319 & 0.338 & 0.331 & 0.317 \\ \cline{1-1} & GAT & 0.324 & 0.331 & 0.332 & 0.308 & 0.321 & 0.314 & **0.317** & 0.347 & 0.317 & 0.315 \\ \cline{1-1} & P-NET & 0.349 & 0.335 & 0.340 & 0.340 & 0.321 & 0.352 & 0.336 & 0.354 & 0.322 & 0.331 \\ \cline{1-1} & BFReg-NN(Basic) & 0.318 & 0.336 & 0.332 & 0.329 & **0.308** & 0.328 & 0.328 & 0.344 & 0.318 & 0.328 \\ \cline{1-1} & BFReg-NN(Enhanced) & 0.318 & **0.317** & **0.320** & **0.297** & **0.308** & **0.306** & 0.320 & **0.335** & **0.307** & **0.308** \\ \hline \hline \end{tabular}
\end{table}
Table 2. Results on missing gene expression value prediction (evaluated by MSE\(\downarrow\)).
\begin{table}
\begin{tabular}{c l c c c c} \hline \hline
**Knowledge** & **Models** & **GSE** & **muscle** & **diaphrag** & **lung** & **trachea** \\ \hline \multirow{3}{*}{no prior knowledge} & MLP & 0.9122 & 0.8586 & 0.7881 & 0.8545 & 0.9387 \\ & Random Forest & 0.9688 & 0.8771 & 0.7161 & 0.8834 & 0.9273 \\ & XGBoost & 0.8867 & 0.8534 & 0.7549 & 0.8625 & 0.9193 \\ & transformer & 0.9476 & 0.8785 & **0.8717** & 0.8900 & 0.9242 \\ & Gated NN & 0.7910 & 0.7784 & 0.7110 & 0.8240 & 0.9120 \\ \hline \multirow{3}{*}{co-expression} & GCN & 0.6916 & 0.6424 & 0.5945 & 0.5822 & 0.6612 \\ & GAT & 0.7790 & 0.6882 & 0.6305 & 0.6312 & 0.6294 \\ \hline \multirow{3}{*}{existing knowledge} & MLP+N2V & 0.9064 & 0.8772 & 0.7501 & 0.8180 & 0.9404 \\ & GCN & 0.9285 & 0.8449 & 0.7896 & 0.8581 & 0.9421 \\ \cline{1-1} & GAT & 0.9255 & 0.8470 & 0.8039 & 0.8246 & 0.9409 \\ \cline{1-1} & P-NET & 0.9052 & 0.8654 & 0.7973 & 0.8425 & 0.9332 \\ \cline{1-1} & DCell & 0.9482 & 0.7158 & 0.6731 & 0.7545 & 0.9322 \\ \cline{1-1} & BFReg-NN(Basic) & 0.9476 & 0.8808 & 0.8420 & 0.8808 & 0.9376 \\ \cline{1-1} & BFReg-NN(Enhanced) & **0.9693** & **0.8884** & 0.8509 & **0.8903** & **0.9446** \\ \hline \hline \end{tabular}
\end{table}
Table 3. Results on cell classification (evaluated by macro AUC\(\uparrow\)).
Secondly, BFReg-NN also outperforms the baselines using the existing knowledge. MLP+N2V fails in prediction because it uses the knowledge by embedding nodes implicitly, rather than in an explicit architecture. Compared with GCN and GAT, the basic BFReg-NN(B) could merge hierarchical knowledge from different levels of the biological system. Decll and P-NET built the sketchy networks and applied DNNs to predict, which cannot simulate the complex gene/protein reactions. Thus, their performance are also worse than BFReg-NN(B).
Thirdly, the enhanced BFReg-NN(E) learns important undiscovered knowledge from the gene expression data, and enhances the performance further. Overall, BFReg-NN(E) achieves the best results in most cases.
**Dynamic task results:** Results on future value prediction are presented in Table 4. Compared with directly employing MLP/LSTM to forecast the values, BFReg-NN followed with MLP/LSTM could improve the quality of embeddings and achieve better performance. GCN and GAT with co-expression matrix perform badly due to the small data size. When using existing knowledge, MLP+N2V, GCN and GAT still cannot obtain a good result because the knowledge is incomplete. For example, there are several isolated nodes in the dataset, and these methods fail in updating the embeddings of these nodes. Transformer and Gated NN merge the gene expression densely, so they obtain better results.
The best-performing models in this dataset are tree-based ensemble methods, so we apply Random Forest and XGBoost. Random Forest has a poor performance on both MSE and PCC. XGBoost has a little higher value on PCC but also a higher MSE, which means XGBoost could predict the trend but fail on the specific values.
Finally, the enhanced BFReg-NN(MLP+E) could add the extra discovered knowledge to mitigate the problem of incomplete prior knowledge, and learn the embeddings with a suitable architecture. Therefore, it has the lowest MSE value and a higher PCC value closing to the best one.
### Results for Cell Trajectory
To show the efficiency of the BFReg-NN model, we compare it with two baselines. MLP(S) indicates that genes do not interact with each other and the value is predicted by DNNs. MLP simply applied DNNs to aggregate all the genes and then simulate the trajectory one by one. Since the number of situations is large, we show the result for five treatments averaged by different cell lines in Table 5. In detail, the treatments include stimulating cells with EGF (epidermal growth factor), and four kinase inhibitors (iEFGR, iMEK, iFXC, iPI3K) combined with EGF.
BFReg-NN obtained the small westernitan distance compared with baselines on average. Specifically, BFReg-NN achieved significant results in EGF and iEGFR treatments. The reason is that gene value is constrained by their related genes during several time steps. BFReg-NN considered that suitable relationship among genes, which helps to predict the trajectory for each gene. MLP(S) regarded each gene as independent, so it cannot use the other gene information to make a better prediction. MLP supposed that all the genes have a strong influence on each other, which is against the truth that some genes have more significant influence than others. Thus, MLP has a suboptimal performance.
### Results for Pre-training
BFReg-NN could benefit from the pre-training and fine-tuning framework, and the results are shown in Table 6. The detailed experimental steps are: (1) Utilize the missing gene value prediction task to pre-train a BFReg-NN model on the breast cancer dataset; (2) Freeze the parameters of the BFReg-NN model except for the last MLP layers, and (3) Fine-tune the last MLP layers to do the future gene expression prediction. With the pre-training, the performance increases significantly on the MSE metric. Because biological knowledge is universal and similar in the cell across different tasks, it is reasonable that pre-trained BFReg-NN improves the other tasks' performance with fine-tuning. However, the standard deviation slightly rises, which means a more stable method to fine-tune the model should be discussed in the future.
### Knowledge completion by BFReg-NN
To demonstrate the ability of BFReg-NN to complete the knowledge, we evaluate it on the future value forecasting task. We conducted two type of experiments. One is to remove the existing edges and then see if these edges can be recalled by BFReg-NN. The other is to judge whether the newly discovered biological knowledge is also proved in the recent literature.
In the first experiment, for each gene, we remove its all the edges to make it an isolated node, and conduct the model to recover the knowledge. The discovered edges come out with weights, and we rank them to obtained the top-k list. We run BFReg-NN several times to avoid randomness. The frequency of an edge is computed by (the times that the edge is in the top-k list)/(the total runs). We select the top-20 interaction pairs with the highest frequency as discovered knowledge. The results are shown in Figure 2, where BFReg-NN achieves an average 0.4172 recall score for all the nodes.
We also take p.p53 gene as an example. The detailed recalled edges are shown in Figure 3 where the purple color marks the edges existed in the current network. All the existing edges for p.p53 are recalled in the top-20 list.
Secondly, some new knowledge is discovered by biological methods in recent breast cancer research, which is also found in our proposed BFReg-NN. We take the gene p53, a well-known tumor
\begin{table}
\begin{tabular}{l l l} \hline \hline Model & MSE & PCC \\ \hline BFReg-NN (MLP+E) & 0.0724 \(\pm\) 0.0023 & 0.9724\(\pm\) 0.0007 \\ Pre-trained BFReg-NN (MLP+E) & **0.0719\(\pm\)** 0.0042 & 0.9723\(\pm\) 0.0018 \\ \hline \hline \end{tabular}
\end{table}
Table 6. Performances of pre-trained BFReg-NN (evaluated by MSE\(\downarrow\) and PCC\(\uparrow\)).
\begin{table}
\begin{tabular}{l l l l l l l} \hline \hline Model & EGF & iEGFR & iMEK & iPKC & iPI3K & Avg. \\ \hline MLP(S) & 1.2829 & 1.2087 & 1.1471 & 1.1320 & 1.1362 & 1.2265 \\ MLP & 1.0325 & 1.0592 & 1.0893 & **1.0824** & **1.0827** & 1.0692 \\ BFReg-NN (E) & **0.8490** & **0.8753** & **0.9198** & 1.0830 & 1.1077 & **0.9670** \\ \hline \hline \end{tabular}
\end{table}
Table 5. Performances of cell trajectory simulation (evaluated by WD\(\downarrow\)).
suppressor, as an example to verify the biological meaning of discovered knowledge. We show the top-10 frequent interaction pairs including p53 in Figure 4. And then we find the cues in recent biological literature. Iododeoxyuridine (Idu) is the most frequent marker, which identifies cell phases, indicating whether the cell division is continued in breast cancer (Beng et al., 2017; Chen et al., 2018). S6 takes the second place, which is regulated in mTOR signaling by p53, and the level of S6 increases when p53 is insufficient (Krishnan et al., 2017). Besides, p53 also regulates the expression level of Her2, where the interaction frequency is about 0.15 in our prediction. As a kind of Her2-positive cancer, breast cancer could be treated by inhibiting p53 (Chen et al., 2018). After that, the regulatory relation between p53 and RB is in the existing biological knowledge dataset.
Overall, we notice that most of the existing edges can be recalled by our model, while BFReg-NN also adds knowledge that does not appear in the current database.
### Ablation Study
In this section, we provide a brief description of the effectiveness of each part in BFReg-NN. The ablation analysis for the cell classification task is shown in Table 8. The accuracy is gradually improved when adding a higher level of knowledge to the model in most cases. In trachea, GRN shows the best performance which indicates PPI may lead to an overfitting problem in this organ. In addition, we present the results of _no intra-level_ and _no inter-level_ situations. _No intra-level_ version removes PPI and GRN knowledge and maintains the hierarchical network; and _no inter-level_ merges the PPI and GRN into a large graph and deletes the hierarchical structure. The results show that hierarchical structure is more important than simply linking the factors together, which obeys the phenomenon that the biological factors in a cell are produced step by step.
In addition, we could choose different levels from the biological system as layers for BFReg-NN to adapt to different tasks. For example, the cell classification task aims to capture the cell state involving a variety of factors in a cell, and thus it needs multiple levels of biological knowledge to build the cell phenotype. In contrast, shown in Table 7, the missing value task focuses on gene expression value, which means single gene level knowledge is enough while protein or pathway level knowledge may bring the noise to predictions.
## 7. Conclusion
In this paper, we propose a generic framework BFReg-NN, which offers biological meanings to neurons and links between neurons, and imitates the whole cell system as a neural network at both intra-level and inter-level. We apply BFReg-NN to different downstream tasks and our experimental results demonstrate that BFReg-NN consistently outperforms baselines and discovers new biological meaningful insights. BFReg-NN provides a novel paradigm to merge cell sequencing data and biological knowledge, and it could be extended to more types of genomics data to simulate and understand complex biological systems in the future.
In the future, we plan to apply BFReg-NN in some real and important biological problems, such as predicting drug surgery effect for a special disease, and simulating stem cell development.
\begin{table}
\begin{tabular}{l c c c c c c c c c c} \hline \hline Knowledge & BT20 & HS578T & LNCaP & A549 & MCF7 & MCF10A & MDAMB231 & PC3 & SKBR3 & A375 \\ \hline GRN & **0.318** & **0.317** & **0.320** & **0.297** & **0.308** & **0.306** & **0.320** & 0.335 & **0.307** & **0.308** \\ GRN\&PPI & 0.343 & 0.342 & 0.338 & 0.326 & 0.339 & 0.333 & 0.343 & 0.357 & 0.338 & 0.344 \\ GRN\&Pathway & 0.335 & 0.335 & 0.326 & 0.314 & 0.324 & 0.319 & 0.331 & **0.332** & 0.327 & 0.325 \\ \hline \hline \end{tabular}
\end{table}
Table 7. Ablation study results on missing value prediction (evaluated by MSE \(\downarrow\)). |
2305.03308 | Tiny-PPG: A Lightweight Deep Neural Network for Real-Time Detection of
Motion Artifacts in Photoplethysmogram Signals on Edge Devices | Photoplethysmogram (PPG) signals are easily contaminated by motion artifacts
in real-world settings, despite their widespread use in Internet-of-Things
(IoT) based wearable and smart health devices for cardiovascular health
monitoring. This study proposed a lightweight deep neural network, called
Tiny-PPG, for accurate and real-time PPG artifact segmentation on IoT edge
devices. The model was trained and tested on a public dataset, PPG DaLiA, which
featured complex artifacts with diverse lengths and morphologies during various
daily activities of 15 subjects using a watch-type device (Empatica E4). The
model structure, training method and loss function were specifically designed
to balance detection accuracy and speed for real-time PPG artifact detection in
resource-constrained embedded devices. To optimize the model size and
capability in multi-scale feature representation, the model employed depth-wise
separable convolution and atrous spatial pyramid pooling modules, respectively.
Additionally, the contrastive loss was also utilized to further optimize the
feature embeddings. With additional model pruning, Tiny-PPG achieved
state-of-the-art detection accuracy of 87.4% while only having 19,726 model
parameters (0.15 megabytes), and was successfully deployed on an STM32 embedded
system for real-time PPG artifact detection. Therefore, this study provides an
effective solution for resource-constraint IoT smart health devices in PPG
artifact detection. | Yali Zheng, Chen Wu, Peizheng Cai, Zhiqiang Zhong, Hongda Huang, Yuqi Jiang | 2023-05-05T06:17:57Z | http://arxiv.org/abs/2305.03308v3 | Tiny-PPG: A Lightweight Deep Neural Network for Real-Time Detection of Motion Artifacts in Photoplethysmogram Signals on Edge Devices
###### Abstract
Photoplethysmogram (PPG) signals are easily contaminated by motion artifacts in real-world settings, despite their widespread use in Internet-of-Things (IoT) based wearable and smart health devices for cardiovascular health monitoring. This study proposed a lightweight deep neural network, called Tiny-PPG, for accurate and real-time PPG artifact segmentation on IoT edge devices. The model was trained and tested on a public dataset, PPG DaLiA, which featured complex artifacts with diverse lengths and morphologies during various daily activities of 15 subjects using a watch-type device (Empatica E4). The model structure, training method and loss function were specifically designed to balance detection accuracy and speed for real-time PPG artifact detection in resource-constrained embedded devices. To optimize the model size and capability in multi-scale feature representation, the model employed deep separable convolution and atrous spatial pyramid pooling modules, respectively. Additionally, the contrastive loss was also utilized to further optimize the feature embeddings. With additional model pruning, Tiny-PPG achieved state-of-the-art detection accuracy of 87.8% while only having 19,726 model parameters (0.15 megabytes), and was successfully deployed on an STM32 embedded system for real-time PPG artifact detection. Therefore, this study provides an effective solution for resource-constraint IoT smart health devices in PPG artifact detection.
**Keywords**: Edge AI, IoT wearables, Photoplethysmogram, Motion artifacts
## 1 Introduction
Cardiovascular diseases have emerged as the leading cause of mortality in the modern society. With the advancement of sensing, electronic, and information technologies, smart wearable medical devices such as watches, glasses, and clothing have been proposed for the unobtrusive measurement of vital signs like electrocardiogram (ECG) or photoplethysmogram (PPG) [1] to monitor cardiovascular health. These devices are expected to be valuable in the prevention and precise diagnosis and treatment of cardiovascular diseases.
PPG is a simple, non-invasive, and cost-effective optical technique that measures blood volume changes in microvasculature and has been widely employed to estimate physiological parameters such as heart rate, blood pressure [2][3], oxygen saturation [4], and respiratory rate [5], etc. However, PPG signals are often interfered with by various noises, especially motion artifacts (MA) caused by relative movements between the sensor and skin. MAs are difficult to remove because they overlap with the signal frequency [6]. In most research, PPG artifacts are detected by dividing PPG signals into segments and classifying them into either clean or artifact categories [7][8]. However, pulse segmentation can be challenging in complex motion scenarios. Researchers have attempted to assess signal quality by extracting hand-crafted features such as pulse width, amplitude, and slope in a sliding window [9][10].
In recent years, deep learning methods have been increasingly employed in the analysis of various |
2306.10624 | Meta-Learning for Airflow Simulations with Graph Neural Networks | The field of numerical simulation is of significant importance for the design
and management of real-world systems, with partial differential equations
(PDEs) being a commonly used mathematical modeling tool. However, solving PDEs
remains still a challenge, as commonly used traditional numerical solvers often
require high computational costs. As a result, data-driven methods leveraging
machine learning (more particularly Deep Learning) algorithms have been
increasingly proposed to learn models that can predict solutions to complex
PDEs, such as those arising in computational fluid dynamics (CFD). However,
these methods are known to suffer from poor generalization performance on
out-of-distribution (OoD) samples, highlighting the need for more efficient
approaches. To this end, we present a meta-learning approach to enhance the
performance of learned models on OoD samples. Specifically, we set the airflow
simulation in CFD over various airfoils as a meta-learning problem, where each
set of examples defined on a single airfoil shape is treated as a separate
task. Through the use of model-agnostic meta-learning (MAML), we learn a
meta-learner capable of adapting to new tasks, i.e., previously unseen airfoil
shapes, using only a small amount of task-specific data. We experimentally
demonstrate the efficiency of the proposed approach for improving the OoD
generalization performance of learned models while maintaining efficiency. | Wenzhuo Liu, Mouadh Yagoubi, Marc Schoenauer | 2023-06-18T19:25:13Z | http://arxiv.org/abs/2306.10624v1 | # Meta-Learning for Airflow Simulations with Graph Neural Networks
###### Abstract
The field of numerical simulation is of significant importance for the design and management of real-world systems, with partial differential equations (PDEs) being a commonly used mathematical modeling tool. However, solving PDEs remains still a challenge, as commonly used traditional numerical solvers often require high computational costs. As a result, data-driven methods leveraging machine learning (more particularly Deep Learning) algorithms have been increasingly proposed to learn models that can predict solutions to complex PDEs, such as those arising in computational fluid dynamics (CFD). However, these methods are known to suffer from poor generalization performance on out-of-distribution (OoD) samples, highlighting the need for more efficient approaches. To this end, we present a meta-learning approach to enhance the performance of learned models on OoD samples. Specifically, we set the airflow simulation in CFD over various airfoils as a meta-learning problem, where each set of examples defined on a single airfoil shape is treated as a separate task. Through the use of model-agnostic meta-learning (MAML), we learn a meta-learner capable of adapting to new tasks, i.e., previously unseen airfoil shapes, using only a small amount of task-specific data. We experimentally demonstrate the efficiency of the proposed approach for improving the OoD generalization performance of learned models while maintaining efficiency.
Keywords:PDEs CFD Meta Learning Graph Neural Networks
## 1 Introduction
Nowadays, numerical simulations of partial differential equations (PDEs) are a crucial tool in designing and managing real-world systems. For instance, the Navier-Stokes equations describing the motion of some fluid are commonly used in the analysis of fluid flow systems, such as aerodynamic airfoil design. However, solving numerically PDEs remains a challenge despite their widespread use. Numerical Analysis encompasses different numerical simulation methods that are widely used to approximate the solutions of PDEs. One of the common used methods to deal with this limitation is the Finite Volume Method (FVM): This approach discretizes the domain into a _mesh_ and computes approximated values of the quantities of interest in each cell of the mesh. While these approaches can
predict the behavior of systems with known error bounds, their computational cost can be extremely high for complex systems, especially in computational fluid dynamics (CFD).
Over the past few years, there has been a significant increase in using machine learning algorithms for numerically solving physical problems, particularly in fluid dynamics, where conventional numerical solvers are computationally expensive. In such context, data-driven methods have been proposed to learn Deep Network (DN) models that predict the solutions of complex PDEs to make full use of accumulated datasets, either generated by classical solvers, or from experimental sources. Through Deep Learning (DL) methods, these models can learn from data, allowing for more efficient solutions to PDEs. However, a major limitation of these approaches is their tendency to suffer from poor generalization performance on out-of-distribution (OoD) samples. As the deep learning methods learn patterns directly from the data instead of studying problem-related constraints beyond the PDEs, they cannot grasp the physics of the problem at hand. The lack of underlying physical laws leads to generalization issues: the predicted results can significantly lack any physical significance, and the learned models often underperform on OoD samples: the deep learning models can predict unseen examples that are close to the training set but perform poorly at solving new problems that significantly differ from the training examples, as the underlying physical laws are not explicitly incorporated into the learning process. In order to address this issue, a number of researchers have proposed the use of hybrid models that combine deep learning with computational fluid dynamics (CFD) solvers. [4] takes advantage of the approximated solutions from CFD solvers on coarse meshes, using them as input features for deep learning models to make super-resolution predictions in aerodynamics. [17] uses machine learning to correct errors in cheap and under-resolved simulations on coarse meshes from traditional solvers. These models obtain extra information from the coarse-grained simulations to reduce generalization errors. [21] uses the predictions obtained from deep learning models as initial values and then employs CFD solvers to further refine and improve the solutions from the deep learning models. While these hybrid models are able to improve the accuracy of predictions on OoD samples, they are often less efficient than pure machine learning methods [4].
In this paper, we introduce a meta-learning perspective for CFD tasks and apply an optimization-based meta-learning approach to enhance the performance of the learned models on OoD data points. Meta-learning provides a way to gain meta-knowledge over various tasks and to use this knowledge to learn new tasks using a few task-specific data points. Specifically, we formulate the CFD problem of airflow simulation over various airfoil shapes as a meta-learning problem: learning airflow simulations around one single airfoil is considered as one task. By leveraging the information from these tasks with meta-learning, a meta-learner can then adapt to new tasks, i.e., to unseen airfoil shapes, using only a small amount of task-specific sample data points.
## 2 CFD Background
Computational Fluid Dynamics (CFD) has extensive applications across various fields of study and industries, such as aerodynamics, weather simulation, and heat transfer, among others. The Navier-Stokes equations form the fundamental basis for the majority of CFD problems, governing the behavior of single-phase fluid flows. However, traditional numerical solvers often encounter high computational costs when addressing complex problems in the CFD domain.
In recent years, machine learning algorithms have emerged as a promising alternative for CFD problems, garnering significant interest due to their potential to alleviate computational burdens while maintaining accuracy in simulating fluid dynamics.
### Machine Learning for CFD
#### 2.1.1 Data-driven method
Several works have proposed data-driven methods, making full use of labeled data accumulated by numerical solvers. The objective is to create a model capable of solving a family of PDEs of the same type. The inputs of the model are the physical quantities that define a specific instance of the target PDE, and the geometrical definition of the domain of interest where this PDE is defined. The 'labels' are the corresponding numerical solutions of the PDE. These methods learn a mapping from the physical and geometrical inputs to the corresponding solutions. Early works in 2D [6, 32, 31] considered the problem as an image-to-image problem and applied Convolutional Neural Networks (CNNs) in a straightforward manner. However, such a CNN approach only applies to image-like data. These researches either use structured meshes to discretize the physical domain, directly producing image-like data, or apply interpolation to convert mesh data into structured grids. As a result, they could not handle well problems with complex geometry.
In recent years, many attempts have been made to construct models with Graph Neural Networks (GNNs) to cope with mesh data. [15] discusses fluid flow field problems on different irregular geometries, considering CFD data as a set of points (called point clouds) and applying the PointNet [23] architecture specially designed for such a data type; [22] proposes a framework for learning mesh-based simulation problems with graph neural networks. Both these data-driven approaches are extremely efficient compared with numerical solvers in terms of computational cost; however, they always suffer from out-of-distribution generalization issues.
#### 2.1.2 Unsupervised learning Approaches
On the other hand, some works [5, 26, 27] based on unsupervised learning aim to design mesh-free methods, e.g., in the case of high dimensions or complex geometry. The basic idea of such methods is to put the physics in the loss during training. The inputs of the NN are the coordinates of some points in the domain, and the output is the solution \(u\) of the PDE at hand. At inference time, the network directly predicts the value \(u(x)\)
when given \(x\) as input. However, these unsupervised learning methods solve one problem each time (e.g., re-training is necessary when the boundary conditions change) and require much more computational time for a new problem than data-based approaches.
### Airfoil Flow Simulation
In this study, we focus on airfoil flow simulation problems in the CFD domain and aim to develop a robust deep learning model using a data-driven approach.
Analyzing the flow fields around airfoils using the so-called Navier-Stokes PDE to represent the physical system is a classical use case in CFD. The traditional CFD solvers compute the velocity field and the pressure of the flow around the airfoil, enabling the understanding and improvement of airfoil properties and designs. The simplified Reynolds-averaged Navier-Stokes (RANS) equations [28] are time-averaged equations of motion for fluid flows that are commonly used for airfoil simulations. The system modeled by RANS equations can be expressed as:
\[\frac{\partial u_{i}}{\partial x_{i}}=0 \tag{1}\] \[u_{j}\frac{\partial u_{i}}{\partial x_{j}}=\frac{\partial}{ \partial x_{j}}[-p\delta_{ij}+(v+v_{t})(\frac{\partial u_{i}}{\partial x_{j}} +\frac{\partial u_{j}}{\partial x_{i}})] \tag{2}\]
where \(U=(u_{x},u_{y})\) is the velocity field and \(p\) the pressure, the unknown quantities to be determined. \(\nu\) is the fluid viscosity considered as a constant, and \(\nu_{t}\) is the so-called eddy viscosity. \(\nu_{t}\) can be determined using the widely-adopted Spalart-Allmaras equation [30]. RANS equations of four partial differential equations in a two-dimensional space are obtained by integrating the Spalart-Allmarasa equation. A no-slip boundary condition is imposed along the wall of the airfoil, meaning that U is set to zero along all the points at the wall. To solve this system, the Semi-Implicit Method for Pressure-Linked Equations (SIMPLE) algorithm is commonly employed [10], operating under the assumption of incompressible fluid behavior.
#### 2.2.1 Machine Learning Scenario
Real-world applications of airfoil flow simulation involve studying various airfoil shapes to optimize aircraft design for maximum energy capture and efficiency. In such context, our objective is to construct a model able to predict in short time fluid flow (velocity and pressure) around an airfoil based on its shape (and an associated mesh) and the two flow parameters, Angle of Attack (AoA) and Mach number (Mach), describing the specificities of the physical system. To achieve this, we will train a GNN model using a dataset generated by a numerical CFD solver, encompassing a variety of triplets (airfoil shapes, AoA, Mach).
It is critical that the trained model provides accurate predictions for airfoil shapes not seen during the training phase or those that significantly differ from
the training set (out-of-distribution - OoD) in real-world applications in aeronautics. However, traditional supervised learning algorithms discussed in Section 2.1 encounter difficulties in achieving this objective (see e.g., the results of the baseline in Table 1). Thus, we propose utilizing meta-learning techniques as a solution to address this issue, enabling the trained model to maintain the high performance for OoD problems.
## 3 Meta-Learning
Meta-learning [12], aka "learning to learn", has emerged as a promising approach for training models that efficiently adapt to new tasks outside the ones used during training. In the context of multi-task learning, whereas standard machine learning algorithms are concerned with solving one single task, meta-learning involves learning, over several different tasks, some incomplete model that is able to learn a specialized model for all the tasks in training set from only a few data points for each task. This incomplete model is then able to also learn new tasks with only a few data points.
### Problem Set-Up
A Meta-Learning dataset \(\mathcal{D}_{meta}\) is a set of different supervised learning tasks: \(\mathcal{D}_{meta}=\{\mathcal{T}_{i};i=1,\ldots,N\}\). Each task \(\mathcal{T}_{i}\) is defined by a dataset of labeled sample points \(\mathcal{D}_{i}=\{(x_{1}^{i},y_{1}^{i}),\ldots,(x_{k}^{i},y_{k}^{i})\}\) containing a limited number of examples for the problem at hand, and a loss function \(\mathcal{L}_{i}\) to be minimized: \(\mathcal{T}_{i}=(\mathcal{D}_{i},\mathcal{L}_{i})\). As usual in supervised learning, each dataset \(\mathcal{D}_{i}\) is split into a training and a test set: \(\mathcal{D}_{i}=(\mathcal{D}_{i}^{tr},\mathcal{D}_{i}^{test})\). Similarly, the meta-dataset is partitioned into a meta-training and a meta-test set: \(\mathcal{D}_{meta}=(\mathcal{D}_{meta}^{tr},\mathcal{D}_{meta}^{test})\).
The goal of meta-learning is to train a model (aka meta-learner) that can quickly adapt to all the tasks in \(\mathcal{D}_{meta}^{tr}\). This meta-learner is then tested on the tasks in \(\mathcal{D}_{meta}^{test}\). The underlying reasoning is that if it generalizes well on the tasks in \(\mathcal{D}_{meta}^{tr}\) using only a small number of specific examples, it should later similarly perform well on any new task, using, again, only a small number of examples.
### Model-Agnostic Meta-Learning
The model-agnostic meta-learning (MAML) [11] is a widely used method in meta-learning. The aim of MAML is to learn some initial parameters \(\theta_{0}\) of a parameterized NN model \(f_{\theta}\), such that \(f_{\theta_{0}}\) can quickly be fine-tuned to any task in the meta-training set \(\mathcal{D}_{meta}^{tr}\), using a small number of examples of that task. Given \(f\) parameterized by \(\theta\), we will denote \(\mathcal{L}(\mathcal{D},\theta)=\sum_{(x,y)\in\mathcal{D}}\mathcal{L}(f_{ \theta}(x),y)\)
#### 3.2.1 Meta-Training
All details can be found in [11], but a schematic view with on gradient step for meta-tuning is pseudo-coded in Algorithm 1, in which \(\mathcal{D}_{meta}^{tr}\) is identified to the set of airfoil shapes \(\{\mathcal{A}_{1},\ldots,\mathcal{A}_{n}\}\).
Two optimization processes are embedded, the upper one updating the parameter \(\theta_{0}\) of the meta-learner, and the inner one performing a few gradient descent steps on each task to evaluate the ability to quickly learn on the different tasks of \(\mathcal{D}^{tr}_{meta}\).
Inner loop:From the current meta-learner \(f_{\theta_{0}}\), \(M\) gradient descent steps are performed for each task \(\mathcal{T}_{i}\in\mathcal{D}^{tr}_{meta}\), leading to updated values \(\theta_{i}^{k}\) at the different steps \(k\in[1,M]\), using the examples in \(\mathcal{D}^{tr}_{i}\) (Line 9 of Algorithm 1, with \(M=1\) and \(k\) omitted).
Outer loop:The update of \(\theta_{0}\) is then done by one gradient step too, aiming at minimizing the test error on all tasks \(\mathcal{T}_{i}\in\mathcal{D}^{tr}_{meta}\), i.e., the error on the corresponding test set \(\mathcal{D}^{test}_{i}\) (Line 11 of Algorithm 1).
#### 3.0.1 Meta-Test
During Meta Test, given a new meta-test task \(\mathcal{T}=((\mathcal{D}^{tr},\mathcal{D}^{test}),\mathcal{L})\) sampled from the same meta-distribution as the training tasks \(\mathcal{T}_{1},\ldots,\mathcal{T}_{N}\), the task-specific parameters \(\theta\) for the new task \(\mathcal{T}\) is updated using the same fine-tuning method as in the inner loop of the training process. The performance of the whole meta-learning algorithm is then evaluated on the meta-test set \(\mathcal{D}^{test}_{meta}\) (and possibly for several different new meta-test tasks \(\mathcal{T}\)).
#### 3.0.2 MAML++
In fact, the update of the meta-parameters \(\theta_{0}\) requires second-order derivatives. As a result, the bi-level optimization problem introduces instabilities when training the meta-learner. In order to mitigate these instabilities, [2] proposed a multi-step loss optimization method (MSL). Instead of minimizing only the loss from the last step, the idea is to minimize the weighted sum of the losses at every updating step j, where the weights \(w_{j}\) are pre-defined by users (see [2] for all details and related experiments). Compared to the original MAML method, the modified version MAML++ stabilizes the training process, facilitating quicker and easier convergence. From now on, by abuse of notation, we will simply write MAML for MAML or MAML++ indistinctively. However, all experiments in Section 4 have been performed using MAML++.
#### 3.0.3 MAML for PDEs
Nowadays, there has been a growing trend in applying meta-learning algorithms to the approximation of PDEs [25, 14, 8]. These approaches often integrate MAML and its variant [20] with unsupervised learning methods for PDEs, such as physics-informed neural networks [27] (PINNs). Researchers consider related parametric PDEs as a set of related but distinct tasks and employ meta-learning principles to learn an initial model with strong generalization capabilities for these PDEs, thereby reducing the number of iterations required to adapt to a new PDE task. Such works partially reduce the computational cost for PINNs when a large number of PDEs with different parameters are to be solved but are nevertheless still much less efficient than data-based approaches.
### Meta-Learning for Airfoil Flow
Experiments on data-based approaches to airflow simulations have demonstrated that, whereas the generalization with respect to AoA and Mach is acceptable, that with respect to the airfoil shape is not, even more so when the shapes are chosen out of the distributions of the shapes in the training set: the results in Table 1 are the visible part of these results, not shown here due to space constraints. Hence we propose to consider different airfoil shapes as different tasks, and to use MAML to train a meta-learner capable of adapting to new shapes with only a few sample data points for each shape.
#### 3.3.1 Rationale
Transfer learning is useful for enhancing the predictive accuracy of the trained model, in particular regarding OoD shapes. Given an OoD airfoil, transfer learning can be simply employed by fine-tuning a pre-trained model on a small dataset of pairwise data from that OoD airfoil. This approach has a low computational cost on the training process and helps alleviate overfitting concerns. However, transfer learning may be less effective when limited data (less than 100 examples) is available for the new task [13]. As a result, collecting data for fine-tuning a model on OoD airfoils can be resource-intensive, requiring running numerical simulations hundreds of times to generate new problem instances for each airfoil. This can be burdensome, especially when the model needs to be fine-tuned for multiple OoD airfoils.
Instead of transfer learning from a pre-trained model for each new airfoil shape, it is natural to consider employing the MAML algorithm, which embeds the fine-tuning process within the training phase, to develop a meta-learner proficient in fine-tuning for novel airfoil shapes. This approach can reduce the requirement for additional data points.
To accomplish this, we formulate the airflow problem over various airfoils as a meta-learning problem (see Figure 1), where each set of examples defined on a single airfoil shape is treated as a separate task. The modified version MAML++ is used to learn an incomplete model \(f_{\theta_{0}}\), to be fine-tuned with a few steps of gradient descent, for any task, both from the meta-training set and the meta-test set.
## 4 Experiment
### Data Preparation
We generate a database of cases with various angles of attack (AoA), Mach numbers, and airfoil shapes as described below. The CFD solver OpenFOAM[34] is applied to generate ground truth on structured C-grid meshes in our work.
#### 4.1.1 Airfoil Generation
We create 80 distinct NACA 4-digit airfoil shapes characterized by their camber \(C\), the position of their maximum camber \(P\), and their
thickness \(T\). All three parameters are randomly sampled from uniform distributions: \(C\sim\mathcal{U}[0,0.09]\), \(P\sim\mathcal{U}[0.4,0.6]\) and \(T\sim\mathcal{U}[0.1,0.3]\).
#### 4.2.3 Example Generation
We construct C-grid meshes for each NACA airfoil using an automated algorithm [1] for further ground truth generation with the CFD solver OpenFOAM. For each NACA airfoil, 40 examples are generated by sampling uniformly the two physical parameters, Angle-Of-Attack(AoA) in [-22.5, 22.5] (in degrees), and Mach number in [0.03, 0.3].
#### 4.2.4 Data Pre-processing
We follow the recommended data pre-processing steps outlined in [31], concentrating on a small region near the airfoil and normalizing the output quantities. Airflow simulations by CFD solvers require a computational domain that is much larger than the airfoil so as to maintain an adequate distance between the airfoil object and the boundaries of the computational domain, to ensure that the boundary conditions assigned to the outer domain do not impact the quality of the flow simulation around the airfoil. However, when training the NN models, it is not necessary to compute predictions for areas far away from the airfoil, which is of less interest (and remains almost constant, equal to the boundary conditions). As a result, we focus the learning on a small domain in close proximity to the airfoil. Additionally, we normalize the output quantities, velocity \(U\) and pressure \(p\), see Section 2.2, relative to the magnitude of the freestream velocity \(U_{0}\) to make these quantities dimensionless:
\[\bar{U}=U/||U_{0}||,\quad\bar{p}=p/||U_{0}||^{2}\]
#### 4.2.5 Network Inputs and Outputs
Both input and output are represented in the form of graph data. Formally, graph data can be expressed as \(G=(N,E,\mathcal{V},\mathcal{E})\), where \(N\) is the graph nodes, \(E\) the set of edges, \(\mathcal{V}\in\mathbb{R}^{N\times F}\) are the \(F\)-dimensional node attributes attached to each node, and \(\mathcal{E}\in\mathbb{R}^{E\times D}\) the D-dimensional attributes attached to each edge.
In our case, the CFD solver OpenFOAM uses finite volume methods to discretize the PDE. The simulation results provide an approximate value of the output quantities at the center of each cell. Rather than preserving the mesh nodes, the centroids of each cell are converted to the nodes of the graph, and two centroids \(i\) and \(j\) are connected if their corresponding cells are adjacent (i.e., share an edge). Moreover, the edge attribute \(x_{ij}^{e}\in\mathcal{E}\) of edge \((i,j)\) is \(x_{ij}^{e}=c_{j}-c_{i}\), where \(c_{i}\) and \(c_{j}\) are the coordinates of nodes \(i\) and \(j\) respectively (D=2), representing the distance relations in the mesh. The initial freestream condition \(U_{0}=(v_{0,x},v_{0,y})\) depending on AoA and Mach is considered as the input node attributes (F=2). The output node attributes are the velocity and pressure at node i (F=3).
### Model Architecture
The model architecture employs the Graph U-Net architecture proposed in [18], which combines the advantages of Graph Neural Networks (GNNs) and the U-Net architecture [29]. This Section will briefly give its main characteristics for the sake of completeness.
#### 4.2.1 Graph Neural Networks
Graph Neural Networks (GNNs) [7, 9, 16, 3, 33] are designed to treat data from non-Euclidean spaces, such as graphs, meshes, or manifolds, and are now widely used for processing mesh data in the physical domain [15, 4, 22]. Key components of a GNN include a convolutional operator that is invariant to node permutations.
Figure 1: A schematic view of MAML algorithm to solve Airfoil Flow Problems
Among the different types of GNN, we use the MoNet GNN [19], defined as follows. Consider a weighted graph \(G=(N,E,\mathcal{V},\mathcal{E})\). Let \(x_{i}\in\mathbb{R}^{F}\) be the feature vector of node \(i\), and \(x_{ij}^{e}\in\mathbb{R}^{D}\) be the feature of the edge \(i,j\) defining the set of neighbors \(N(i)\) of node \(i\). The basic idea of MoNet is to define a trainable function \(\mathbf{w}\) that computes an edge weight \(w_{ij}\) from the edge feature \(x_{ij}^{e}\). MoNet then defines the convolutional operator at node \(i\) as:
\[\mathbf{x}_{i}^{\prime}=\frac{1}{|\mathcal{N}(i)|}\sum_{j\in\mathcal{N}(i)} \frac{1}{K}\sum_{k=1}^{K}\mathbf{w}_{k}(\mathbf{x}_{ij}^{e})\odot\mathbf{ \Theta}_{k}\mathbf{x}_{j}\]
where \(\mathbf{K}\) is the user-defined kernel size, \(\mathbf{\Theta_{k}}\in\mathbb{R}^{M\times N}\) stands for the trainable matrix applying a linear transformation on the input data, \(\odot\) is the element-wise product, and \(\mathbf{w}_{k},k=1,\ldots,K\) are trainable edge weights. Following [19], we use Gaussian kernels: \(\mathbf{w}_{k}(x_{ij}^{e})=exp(-\frac{1}{2}(x_{ij}^{e}-\mu_{k})^{T}\Sigma_{k} ^{-1}(x_{ij}^{e}-\mu_{k}))\). Both \(\mu_{k}\) and \(\Sigma_{k}\) are trainable variables.
#### 4.2.2 Graph U-Net
GNNs can directly handle mesh data, making them well-suited for processing complex geometries like airfoil shapes. Meanwhile, the U-Net architecture [29] is known in image processing for its ability to extract hierarchical spatial features, which helps in capturing essential information at various scales. Modern mesh generators enable the creation of hierarchical meshes for the same domain while preserving geometric information. The model leverages these algorithms to build a hierarchy of meshes and construct the Graph U-Net architecture. A series of graph layers are applied at the same mesh level, while pooling operators transfer data between different mesh levels.
#### 4.2.3 Pooling Operator
The k-nearest interpolation proposed in PointNet++ [24] was chosen to design the pooling operators. It is consistent with standard interpolation routinely used in piecewise continuous numerical approximations. Let \(y\) be a node from \(\mathcal{M}_{1}\), and assume its \(k\) nearest neighbors on \(\mathcal{M}_{2}\) are \((x_{1},\ldots,x_{k})\). The interpolated feature for \(y\) is defined from those of the \(x_{i}\)'s as:
\[\mathbf{f}(\mathbf{y})=\frac{\sum_{i=1}^{k}w(x_{i})\mathbf{f}(x_{i})}{\sum_{i =1}^{k}w(x_{i})}\text{, where }w(x_{i})=\frac{1}{||y-x_{i}||_{2}}\]
### Training the Meta-Learner
The Meta-Learner is trained based on our described methodology in Section 3.2. A 10-fold cross-validation is used to assess the robustness of the proposed approach. The loss function is defined as the Mean Squared Error (MSE) between the prediction and ground truth. Our approach is compared with two baselines: The first baseline uses a global (single-task) approach, and considers the multi-datasets as one single dataset, to which it applies standard supervised learning. MAML models require additional data every time a new task is presented. In
contrast, the baseline model is applied directly to unseen airfoils. However, such extra data (the few labeled examples available for the new tasks/airfoils) can help not only MAML but maybe also the baseline model: To be fair to the baseline, the second baseline consist in fine-tuning it at test time, for each new task, using the same additional data as MAML, called "Baseline+FT". 10-fold cross-validation is used in all experiments and means and standard deviations on the (meta-) test sets are reported.
#### 4.3.2 Hyper-parameters Setting
In order to validate the effectiveness of the proposed approach and ensure a fair comparison, the architecture and hyperparameters of the Meta-Learner are the same as those that were selected for the baseline model. The graph U-Net architecture detailed in Section 4.2 is used, with the same graph blocks and sampling operators. Each graph block \(C\) contains multiple graph layers followed by the activation function "ELU." The block \(C\) is specified by the number of layers \(l\), a channel factor \(c\), and a kernel size \(k\). A sampling operator is applied after each GNN block to transform data between two mesh levels. The sampling operator has one hyper-parameter, the number of nearest neighbors, set to 6. The model down-samples progressively three times in the encoding part and recovers the initial mesh resolution with three up-sampling operators during decoding, containing seven GNN blocks \(C=(2,48,5)\). Finally, a graph layer maps the high-dimensional features to the solution space. During meta-training, the Adam optimizer is used with an initial learning rate of 5E-4 and step decay by a factor of 0.5 every 500 epochs. The number of inner gradient update steps is set to 3, and the first 20 examples of each task \(\mathcal{T}_{i}\) are considered as the train set \(\mathcal{D}_{i}^{tr}\) used for inner gradient updates with a fixed learning rate of 0.01, while the remaining examples are used as \(\mathcal{D}_{i}^{test}\) to compute the meta-loss \(\mathcal{L}\) for meta-update.
### Experimental Results
#### 4.4.1 Meta-Test Sets
Three meta-test sets allow us to evaluate the generalization properties of the models with respect to airfoil shapes. For the flow parameters AoA and Mach number, we use the same distribution as in the training set in order to more accurately highlight the performance of the models on OoD tasks (see Section 4.1).
* **Flow Interpolation Set**: As a sanity check, we generate 10 additional examples (AoA, Mach) for each airfoil shape (meta-training task). For evaluation, we directly use the initial training data to update each task and make predictions for new examples.
* **Shape Interpolation Set**: This set includes 20 new airfoil shapes that are generated using the same distributions of NACA parameters as the training set (see Section 4.1). Each airfoil is treated as a separate meta-test task, with 50 (AoA, Mach) examples in total. We use the first 20 such examples to update the Meta Learner, and the remaining 30 examples to evaluate the model performance.
* **Out of Distribution Set**: Thinner and less regular airfoil shapes are created by altering the distribution range for NACA parameters \(T\) and \(P\) (\(P\in[20,80]\) and \(T\in[5,10]\)). Similarly to the Shape Interpolation Set, 50 (AoA, Mach) examples are created for this meta-test set, that are more challenging than those in the training set.
Unless otherwise stated, our meta-model is evaluated after fine-tuning on each meta-test task with 10 gradient updates and compared with the baseline model on the three meta-test sets described above.
#### 4.2.2 First Results
We use RMSE as the metric for model performance and compare it with the two baselines outlined in Section 4.3. Moreover, for all pair-wise comparisons between test errors on MAML and Baseline, we performed a Wilcoxon signed-rank statistical test with 95% confidence, and the differences between all pairs are statistically significant.
From the results in Table 1, it turns out the MAML model outperforms the baseline on the Shape Interpolation and OoD meta-test sets, while, as expected, the baseline performs best on the Flow Interpolation set - and fine-tuning of course does not improve its performance. By using just a few data points and gradient steps, MAML models can quickly adapt to new tasks without overfitting. Interestingly, adding some fine-tuning to the baseline does improve its performance on the Shape Interpolation and OoD meta-test sets, but the results remain far below those of the MAML approach.
#### 4.2.3 Number of gradient updates
Figure 3 displays plots of the RMSE error w.r.t. the number of gradient updates during the Meta-Test on the Shape Interpolation and OoD meta-test sets. It shows that, given very limited data, the model trained with MAML can rapidly adapt to novel tasks and continue to enhance performance without overfitting. Moreover, the figure highlights a comparison between the baseline with fine-tuning approach and the meta-trained model. While fine-tuning does improve the performance of the baseline model, the meta-trained model shows more significant improvements in performance. Finally, we observe on the OoD meta-test set that the decrease of the error is steeper and lasts longer for the meta-trained model, with a much lower variance than for the baseline.
\begin{table}
\begin{tabular}{l c c c} \hline \hline & \multicolumn{3}{c}{RMSE(1e-2)} \\ \cline{2-4} Test Sets & MAML & Baseline & Baseline + FT \\ \hline Flow Interpolation & 0.79 \(\pm\) 0.08 & **0.71 \(\pm\) 0.03** & 0.71 \(\pm\) 0.03 \\ Shape Interpolation & **1.18 \(\pm\) 0.14** & 1.58 \(\pm\) 0.15 & 1.48 \(\pm\) 0.14 \\ Out-of-Distribution & **3.69 \(\pm\) 0.28** & 6.43 \(\pm\) 1.79 & 5.35\(\pm\)1.62 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Evaluation Results on different test sets with 10 gradient updates
#### 4.2.2 Number of examples in meta-test sets
As previously mentioned, during the meta-training phase, 20 examples were employed for inner gradient updates. At the meta-test time, the same number of examples is used to update the meta-learner for meta-test tasks in the first experiment.
We now investigate the impact of the number of sample data points used for meta-test tasks on the performance of the MAML model: The MAML model is fine-tuned using from 1 to 20 examples, each with 10 gradient updates, in order to understand how the number of examples used for test tasks affects the model performance.
From Figure 4, increasing the number of examples used to update the meta-learner has a positive impact on the model performance. While the MAML model still performs well on new tasks and outperforms the baseline model when using more than 5 examples, it is unable to make reasonable predictions (i.e., at least
Figure 3: Sensitivity w.r.t. the number of gradients. The MAML model continuously improves, while the baseline does not show such significant improvements.
Figure 2: An example of prediction from MAML approach. By observing the intermediate plots and loss, the Meta-Learner demonstrates rapid convergence toward the ground truth
as good as the baseline) on new meta-tasks with using less than 4 examples: At least 4 examples are necessary for the Shape Interpolation set, while 3 are sufficient on the OoD set, where the baseline is far less efficient.
## 5 Conclusion
In this paper, we have presented a meta-learning approach to address airfoil flow problems. By utilizing the Model-Agnostic Meta-Learning (MAML) algorithm, we have trained a meta-learner that is able to adapt to new tasks with only a small number of examples.
Our experimental results show that the model obtained by meta-learning consistently outperforms the baseline model (a straightforward single-task approach which is trained classically, once and for all using the whole dataset) in terms of its ability to generalize to different airfoil shapes, even more so for out-of-distribution shapes - and this, even if this baseline model is fine-tuned with the same small amount of data for the new tasks than the MAML meta-model.
One drawback of the meta-learning approach is the need for a few examples for any new task. But the clear benefits in performance should justify it in most practical cases.
Overall, we claim that the meta-learning approach represents a promising solution for addressing the challenges of generalization in airfoil flow problems. Furthermore, this approach is not specific to airflow problems and could be used on top of any complex and computationally costly numerical simulation.
|
2308.05975 | A Self-supervised SAR Image Despeckling Strategy Based on
Parameter-sharing Convolutional Neural Networks | Speckle noise is generated due to the SAR imaging mechanism, which brings
difficulties in SAR image interpretation. Hence, despeckling is a helpful step
in SAR pre-processing. Nowadays, deep learning has been proved to be a
progressive method for SAR image despeckling. Most deep learning methods for
despeckling are based on supervised learning, which needs original SAR images
and speckle-free SAR images to train the network. However, the speckle-free SAR
images are generally not available. So, this issue was tackled by adding
multiplicative noise to optical images synthetically for simulating speckled
image. Therefore, there are following challenges in SAR image despeckling: (1)
lack of speckle-free SAR image; (2) difficulty in keeping details such as edges
and textures in heterogeneous areas. To address these issues, we propose a
self-supervised SAR despeckling strategy that can be trained without
speckle-free images. Firstly, the feasibility of SAR image despeckling without
speckle-free images is proved theoretically. Then, the sub-sampler based on the
adjacent-syntropy criteria is proposed. The training image pairs are generated
by the sub-sampler from real-word SAR image to estimate the noise distribution.
Furthermore, to make full use of training pairs, the parameter sharing
convolutional neural networks are adopted. Finally, according to the
characteristics of SAR images, a multi-feature loss function is proposed. The
proposed loss function is composed of despeckling term, regular term and
perception term, to constrain the gap between the generated paired images. The
ability of edge and texture feature preserving is improved simultaneously.
Finally, qualitative and quantitative experiments are validated on real-world
SAR images, showing better performances than several advanced SAR image
despeckling methods. | Liang Chen, Yifei Yin, Hao Shi, Qingqing Sheng, Wei Li | 2023-08-11T07:19:45Z | http://arxiv.org/abs/2308.05975v1 | A Self-supervised SAR Image Despeckling Strategy Based on Parameter-sharing Convolutional Neural Networks
###### Abstract
Speckle noise is generated due to the SAR imaging mechanism, which brings difficulties in SAR image interpretation. Hence, despeckling is a helpful step in SAR pre-processing. Nowadays, deep learning has been proved to be a progressive method for SAR image despeckling. Most deep learning methods for despeckling are based on supervised learning, which needs original SAR images and speckle-free SAR images to train the network. However, the speckle-free SAR images are generally not available. So, this issue was tackled by adding multiplicative noise to optical images synthetically for simulating speckled image. Therefore, there are following challenges in SAR image despeckling: (1) lack of speckle-free SAR image; (2) difficulty in keeping details such as edges and textures in heterogeneous areas. To address these issues, we propose a self-supervised SAR despeckling strategy that can be trained without speckle-free images. Firstly, the feasibility of SAR image despeckling without speckle-free images is proved theoretically. Then, the sub-sampler based on the adjacent-sentropy criteria is proposed. The training image pairs are generated by the sub-sampler from real-word SAR image to estimate the noise distribution. Furthermore, to make full use of training pairs, the parameter sharing convolutional neural networks are adopted. Finally, according to the characteristics of SAR images, a multi-feature loss function is proposed. The proposed loss function is composed of despeckling term, regular term and perception term, to constrain the gap between the generated paired images. The ability of edge and texture feature preserving is improved simultaneously. Finally, qualitative and quantitative experiments are validated on real-world SAR images, showing better performances than several advanced SAR image despeckling methods.
self-supervised; synthetic aperture radar (SAR); despeckling; deep learning
## I Introduction
As the main source of earth observation in remote sensing technology, synthetic aperture radar (SAR) provides the advantage of acquiring data in all-day and all-weather. Therefore, SAR image has been widely used for many applications, such as target detection, disaster management and geological exploration. However, speckle noise is an inherent factor causing SAR image degradation. Speckle noise is generated from the coherent sum of backscattered signals during imaging. The speckle noise degrades SAR image quality and interferes with interpretation. [1]. Hence, in SAR image pre-processing task, the reduction of speckle noise is an indispensable step.
In the past few years, there are many SAR image despeckling approaches have been proposed. In general, the existing SAR image despeckling methods can be classified as: filter-based methods, transform domain methods, variational methods, Markovian model-based methods, non-local mean (NLM) methods, dictionary learning and deep learning (DL) methods.
Lee filters[5], Frost filters[6] and Kuan filters[7] are the most common filter-based methods. These methods are typically assumed to operate on homogeneous regions. Thus, the edge and texture often fail to be preserved in real-world SAR images. Wavelet based[8] methods can distinguish signal and noise effectively according to the characteristic difference in wavelet domain. However, there are still some unignorable defects. The higher-dimensional features are hard to be expressed, resulting in blurred edge and texture features. Another important branch of speckle suppression is the Total Variation (TV)-based method [9]. By combining a regularization term with a data fidelity term, the TV method achieves a balance between smoothing noise and preserving edge. While effective at reducing noise and maintaining edge texture, this approach has its limitations of reducing SAR images' quality. Markov random field (MRF) methods build the model of contextual information to provide a quantitative depiction about the prior of image information. The MRF methods are widely used for SAR image despeckling [11]. Complex prior limits the application of the MRF-based SAR image despeckling methods.
By contrast, non-local mean (NLM) methods have improved performance significantly. These methods utilize the similarities between image patches to perform weighted filtering across the entire image, which benefits the preservation of details. The methods, such as probabilistic patch based (PPB) filtering method[12] and block-matching 3D (BM3D) algorithm[13], demonstrate the satisfying SAR image despeckling performance. However, the effectiveness of non-local mean methods in reducing noise largely depends
on the setteing of parameters. Moreover, it is inefficient when dealing with large-scale images. As an adaptive and straightforward approach, the sparse representation and dictionary learning have been able to reconstruct the image via pixel-by-pixel processing[14]. Whereas, this technique neglects the pixel correlation, and has a considerable computational burden. Therefore, the despeckling method still needs to be further improved.
In general, most of above methods face a few significant problems. First, the algorithm parameters depend on empirical setting. Second, the performance is scene-dependent and with poor adaptability. Third, there are sometimes artifacts in flat areas.
Recently, with the rapid development of deep learning, many denoising methods based on convolutional neural networks (CNNs) have been proposed. The CNN based methods have shown effective performance, such as DnCNN[15], FFDNet[16] and CBDNet[17]. Subsequently, SAR-CNN[18] is proposed for despeckling on SAR images. To convert speckle noise from multiplicative noise to additive noise, SAR-CNN performs homomorphic processing through log-transformation, and maps the despeckled image back to original domain through the exponential function to obtain the restored image. The CNN based method has demonstrated the effectiveness for SAR image despeckling, but acquisition of multitemporal data makes it challenging. Then, the ID-CNN [19] and SAR-DRN [20] methods are proposed which further improve the ability to remove despeckle noise. However, above supervised learning based despeckling methods focus on novel network architectures, ignoring the key problem: lack of speckle-free SAR images as ground truth in real-world condition. There are mainly two ways to solve this problem. The first strategy is synthetic speckle generation approach[21]. The multiplicative noise is overlayed onto clean grey optical images to simulate speckled images. The speckled images are treated as inputs and the clean grey optical images are treated as ground truth. The above two kinds of images serve as training data. However, the learned texture and edge pattern priors from optical images are inconsistent with the characteristics of real-world SAR images. The mismatch often leads to domain gap which is the source of the problem. The second strategy is multitemporal fusion approach[23]. A pile of real-world SAR images are acquired at varying temporal instants. The clean ground truth is generated through exploiting the temporal incoherence of the stack of real-world SAR images. However, accessing to a large multitemporal database remains an enormous challenge. And the change of the scene content may result in poor accuracy. To sum up, self-supervised methods without speckle-free images have become a hot topic for SAR image despeckling.
In this study, a self-supervised SAR image despeckling strategy is proposed that addresses the drawbacks of supervised learning-based methods. The proposed strategy allows for training directly on real-world SAR images using the improved generation training pairs module, the parameter-sharing convolutional neural network, and the self-supervised loss function. Experiments including quantitative and qualitative comparison are conducted on real-world SAR images. The results showed that, compared with the advanced despeckling methods, our proposed strategy can significantly suppress speckle noise, preserving SAR image features and detailed information simultaneously. The main innovations and contributions of our proposed strategy are summarized as shown below:
1. The proposed adjacent-syntropy sub-sampler allows for direct training on real-world SAR images without speckle-free images. Any existing despeckling networks can be trained without any speckle-free targets by this sub-sampler.
2. The proposed parameter-sharing convolutional neural networks can exploit the information of images more effectively. It takes the similarity between pairs of noisy images into consideration to boost despeckling performance.
3. The proposed multi-feature loss function considering the characteristics and properties of SAR images can accelerate the convergence speed, reduce spatial distortion and preserve edges.
The rest of this paper is organized as follows. Section II introduces related work, which includes self-supervised optical image denoising methods and self-supervised SAR image despeckling methods. Section III illustrates the deatils of our proposed method. Section IV introduces the implementation details of experiment, evaluation metrics, the compared methods, and experimental results on actual SAR images. Section V summarizes the paper.
## II Related Work
As discussed, there is no speckle-free SAR images to use for the supervised methods. On this account, the self-supervised despeckling methods have developed rapidly in recent years. The self-supervised methods are first introduced for optical image denoising. And then the self-supervised methods are extended to SAR image despeckling.
### _Self-supervised denoising methods in optical image_
The concept of self-supervised denoising is introduced by Noise2Noise [25] for the first time. The input and target for training have the same underlying ground truth and the mean of them is equal to underlying ground truth. Only their realizations of the noise process are different. Noise2Noise proved that when pairs of noisy images meet the above conditions, a neural network can be trained on paired noisy images rather than pairs of noisy and clean images. However, making multiple observations of the scene with the same content is a major obstacle. In single-image denoising techniques, this problem does not present itself. Noise2Self [26] and Noise2Void [27] introduced the concept of blind-spot network. They can be trained using only individual noisy images. They depend on meticulous data model, by assuming the noise is spatially independent and acquiring statistical priors about the distribution of the data. However, specifying the data model is hard, particularly in real-world scenarios. In addition, the absence of valuable information caused by blind spot dramatically degrades the despeckling performance. Consequently, the applications of blind-spot networks are limited because of the heavy computation and low accuracy.
To overcome the limitations above, Neighbor2Neighbor [28] was proposed. It aims to train denoising networks solely with noisy images available, instead of modifying the structure of the despeckling network, and does not rely on noise models. Inspired by these works, the study of self-supervised SAR image despeckling has also been promoted.
### _Self-supervised despeckling methods in SAR image_
Many studies have attempted to despeckle without speckle-free SAR images. They are derived from optical image denoising methods. A self-supervised densely dilated CNN (BDSS-CNN) [29] for blind despeckling was designed. This method extends Noise2Noise approach to despeckling by generating paired noisy images through overlaying speckle noise which is multiplicative noise onto optical images. Then, BDSS-CNN is trained with the generated paired noisy images. Finally, the trained despeckling network is applied to despeckle actual SAR images. However, the BDSS-CNN only applies Noise2Noise to SAR image despeckling instead of solving the essential problem of lack for ground truth. Besides, a no-reference based SAR deep learning (NR-SAR-DL) filter [30] was proposed, which employed SAR images obtained from the same scene with the same sensor to train the despeckling network. NR-SAR-DL has good ability of suppressing speckle noise on real-world SAR images. It has good ability of point targets preservation and the radio metrics preservation. The main limitation of NR-SAR-DL is that the change of the scene content may result in poor accuracy. Speckle2void [31] proposed a self-supervised Bayesian framework for SAR despeckling, which extends the single-image blind-spot appraoch. This method depends on accurate noise models and blind-spot pixel priors. To compensate for the autocorrelation of the speckle process, Speckle2void employs a whitening preprocessing and a network with a variable blind-spot size. However, Speckle2void depends on accurate statistical modeling of the data which limits further improvements. SSD-SAR-BS [32], a self-supervised method for SAR image despeckling was subsequently proposed. The method only requires original speckled SAR images and uses Bernoulli sampling to generate image pairs as input and target for training a multiscale despeckling network. This approach allows for training despeckling networks using only real speckled SAR images. Its despeckling performance can be further improved.
Existing self-supervised methods for SAR image despeckling still have shortcomings in terms of computational performance, acquiring training data, poor despeckling performance, etc. In response to these challenges, we designed a self-supervised SAR image despeckling strategy, including a generation training pairs module, a parameter-sharing convolutional neural network, and a self-supervised training loss function.
## III Method
In this section, a self-supervised strategy is proposed to train despeckling network with speckled images. The theoretical proof of the method is given at first. The proposed strategy contains three parts. In the first part, it introduces the generate module of speckled images pairs by using adjacent-syntropy sub-sampler. In the second part, the parameter-sharing network is adopted to train the generated speckled paired images. For the third part, a multi-feature loss function is introduced to maintain texture and improve the performance.
### _Theoretical background of proposed strategy_
Speckle noise is an inherent factor causing SAR image degr
adation. Speckle noise is often modeled as multiplicative noise. \(Y\) is used to represent the speckled SAR image. \(X\) is used to represent the underlying ground truth of speckled SAR image. \(Y\) and \(X\) satisfy the following relationship:
\[\tilde{Y}=X\times N \tag{1}\]
where \(\times\) represents the element-wise product. \(N\) represents speckle noise. Speckle noise is modeled to follow Gamma distribution [33]. Speckle noise has unit mean. The probability density function \(P_{r}(\cdot)\) of \(N\) can be defined as:
\[P_{r}(N)=\frac{L^{L}N^{L-1}e^{-LN}}{\Gamma(L)},N\geq 0,L\geq 1, \tag{2}\]
where \(\Gamma(\cdot)\) represents the Gamma function. \(L\) represents the number of looks.
Considering the difficulty with dealing with multiplicative noise and the abundance of literature on removing additive noise, the homomorphic method is adopted by converting the SAR images to logarithmic domain. So, the equation (1) can be modified to:
\[\tilde{Y}=\tilde{X}+\tilde{N} \tag{3}\]
In the above formula, \(\tilde{X}\) represents the underlying speckle-free SAR image in logarithmic domain. \(\tilde{Y}\)represents the speckled SAR image in logarithmic domain. \(\tilde{N}\) represents the speckle noise in logarithmic domain. Specially,
\[\tilde{X} = \log X \tag{4}\] \[\tilde{Y} = \log Y\] (5) \[\tilde{N} = \log N \tag{6}\]
The noise in the logarithmic domain follows the Fisher-Tippett distribution [34]:
\[P(\tilde{N})=\frac{L^{L}}{\Gamma(L)}e^{L\tilde{N}}\exp(-Le^{\tilde{N}}) \tag{7}\]
In addition, the mean of noise in the logarithmic domain only depends on the number of looks:
\[E[\tilde{N}]=\psi(L)-\log(L) \tag{8}\]
The noisy image pair \((\texttt{g}_{1}(\tilde{Y}),\texttt{g}_{2}(\tilde{Y}))\) is generated by the sub-sampler from a single speckle image \(\tilde{Y}\). The sub-samplers will be described in detail in Section III-C. The noise is considered independent of the underlying ground truth. According to the sampling method, the contents of the two generated images \(\texttt{g}_{1}(\tilde{Y})\) and \(\texttt{g}_{2}(\tilde{Y})\) are almost the same. It means that the gap caused by sampled images will be sufficiently small. Consequently, the speckled pairs satisfy that:
\[E(g_{1}(\tilde{Y}))=E(g_{2}(\tilde{Y}))=E(\tilde{X})+E(\tilde{N})=E(\tilde{X} )+\psi(L)-\log(L) \tag{9}\]
Therefore, when constant \(\log(\text{L})-\Psi(\text{L})\) is added to the training pair, the above equation becomes:
\[E(g|\tilde{Y})+\log(L)-\psi(L))=E(g2(\tilde{Y})+\log(L)-\psi(L))-E(\tilde{X}) \tag{10}\]
\(\text{g}_{1}(\tilde{Y})+\log(L)-\Psi(L)\)is denoted as \(y_{1},\ \text{g}_{2}(\tilde{Y})+\log(L)-\Psi(L)\)is denoted as \(y_{2}\). \(y_{1}\) and \(y_{2}\) are taken as the data pair for training. The equation (10) can be rewritten as:
\[E(y_{1})=E(y_{2})=E(\tilde{X}) \tag{11}\]
Generally, in the visual task of image denoising, pairs of noisy image and clean image (\(y\), \(x\)) are required to train the supervised network \(f_{0}\). The empirical risk minimization task of loss function \(L\) becomes:
\[\operatorname*{arg\,min}_{\theta}\mathbb{E}_{(x,y)}\{L(f_{\theta}(y),x)\} \tag{12}\]
Furthermore, equation (12) is also equivalent to:
\[\operatorname*{arg\,min}_{\theta}\mathbb{E}_{x}\{\mathbb{E}_{y_{1}x}\{L(f_{ \theta}(y),x)\}\} \tag{13}\]
For the SAR images in the logarithm domain, the equation (13) should be written as:
\[\operatorname*{arg\,min}_{\theta}\mathbb{E}_{\tilde{X}}\{\mathbb{E}_{\tilde{ Y}|\tilde{X}}\{L(f_{\theta}(\tilde{Y}),\tilde{X})\}\} \tag{14}\]
Noise2Noise denotes that the optimal network parameters \(\theta\) of Equation (14) also remain unchanged, when the targets are corrupted with noise which has zero mean. Therefore, the speckle-free images can be replaced with speckled images that have the same content and the equal mean. The generated training pair (\(y_{1}\), \(y_{2}\)) meets the training conditions of Noise2Noise. \(y_{1}\) and \(y_{2}\) have the same content and equal mean with \(\tilde{X}\). The despeckling networks can be trained with data pair (\(y_{1}\), \(y_{2}\)). Concretely, in \(L2\) norm minimization task, calculating the expected squared difference between speckled images and corresponding ground truth can explain the feasibility. \(\{y_{i}\}_{i=1}^{N}\) represents the noisy target for training in place of clean ground truth. \(\{\tilde{X}_{i}\}_{i=1}^{N}\) represents the clean ground truth. \(N\) is the number of training pairs. \(E\{y_{i}\}=\tilde{X}_{i}\). The calculation of the expected squared difference between \(\{y_{1}\}_{i=1}^{N}\) and \(\{\tilde{X}_{i}\}_{i=1}^{N}\) is as follows:
\[\mathbb{E}_{y}[\frac{1}{N}\sum_{i}\tilde{X}_{i}-\frac{1}{N}\sum_{ i}y_{i}]^{2} \tag{15}\] \[=\frac{1}{N^{2}}[\mathbb{E}_{y}(\sum_{i}\tilde{X}_{i})^{2}-2 \mathbb{E}_{y}[\sum_{i}\tilde{X}_{i})(\sum_{i}y_{i})]+\mathbb{E}_{y}(\sum_{i }y_{i})^{2}]\] \[=\frac{1}{N^{2}}Var(\sum_{i}y_{i})\] \[=\frac{1}{N}[\frac{1}{N}\sum_{i}\sum_{j}Cov(y_{i},y_{j})]\]
If the noisy targets are not correlated with each other, the result of the above equation can be:
\[\frac{1}{N}[\frac{1}{N}\sum_{i}Var(\tilde{X}_{i})] \tag{16}\]
As \(N\) increases, the error between noisy target for training and clean ground truth decreases. Therefore, if \(N\) is large enough, the error is close to zero.
Figure 1: Overview of our self-supervised despeckling strategy. (a) The illustration of the training phase. (b) The flowchart of the inference phase.
Therefore, the empirical risk minimization task in this paper becomes:
\[\underset{\theta}{\arg\min}\mathbb{E}_{y_{2}}\{\mathbb{E}_{y_{1}|y_{2}}\{L(f_{ \theta}(y_{1}),y_{2})\}\} \tag{17}\]
In this way, the model is trained to obtain despeckled results without speckle-free images.
### _Overview of proposed strategy_
The overview of our proposed self-supervised despeckling strategy is shown in Fig. 1. Training phase and inference phase are both illustrated. In the training phase, there are two parts. In the first part, pairs of speckled images for training are generated. The original SAR image \(Y\) is transformed into log domain as log\(Y\). Then, a pair of sub-sampled images (g\({}_{i}\)(log\(Y\)), g\({}_{i}\)(log\(Y\))), are generated from the log\(Y\) with an adjacent-syntropy sub-sampler \(G=\) (g\({}_{i}\), g\({}_{2}\)). Subsequently, \(C\) is added to the paired images to get training pairs (\(y_{1}\), \(y_{2}\)), which will be put into the despeckling network as input and target respectively. There, \(y_{i}\)=g\({}_{i}\)(log\(Y\))+\(C\), \(y_{2}\)=g\({}_{i}\)(log\(Y\))+\(C\). The \(C\) is the negative number of speckle noise in the logarithmic domain:
\[C\!=\!\log(L)-\psi(L) \tag{18}\]
In the second part, the image pairs (\(y_{i}\), \(y_{2}\)) generated by sub-sampler are used to train despeckling networks. The parameter-sharing network takes \(y_{i}\) as input and takes \(y_{2}\) as target respectively. Under the multi-feature loss function, the better despeckling performance can be achieved. The multi-feature loss function includes three items to suppress speckle noise, accelerate the convergence speed, reduce spatial distortion and preserve edges. \(x_{l}\) is the despeckling result of \(y_{l}\) and \(x_{2}\) is the despeckling result of \(y_{2}\). \(x_{1}=f_{\theta}(y_{1})\) and \(x_{2}=f_{\theta}(y_{2})\). \(\hat{Y}\) is the despeckling result of \(\hat{f}_{\theta}(\log Y+C)\), where \(\hat{f}_{\theta}(\ \boldsymbol{\tau}\ )\) means that the despeckling process do not contribute to updating the gradient. That is, \(\hat{f}_{\theta}(\log Y+C)\) can be considered as an ordinary constant. \(X_{l}\) and \(X_{2}\) are generated images by sub-sampler of \(\hat{Y}\):
\[X_{1}=g_{1}(\hat{f}_{\theta}(\log Y+C)) \tag{19}\]
\[X_{2}=g_{2}(\hat{f}_{\theta}(\log Y+C)) \tag{20}\]
In the inference phase, the SAR image to be despeckled is processed at first. The SAR image is transformed into logarithm domain and added \(C\) on it. Then it is used as the input of trained despeckling network. The networks' s output is the ground truth of sepckled SAR image in logarithm domain. The final despeckling result is obtained by performing exponential transformation of the output.
### _Adjacent-syntropy sub-sampler_
The logarithmic graph is denoted as log\(Y\). log\(Y\) is \(W\) wide and \(H\) high. According to the adjacent-syntropy rule, a sub-sampler is designed, in which a pair of noisy images (\(y_{i}\), \(y_{2}\)) are achieved from log\(Y\) to train despeckling networks. The illustration of the process to generate an image pair with an adjacent-syntropy sub-sampler is shown in Fig. 2. The
Fig. 2: Illustration of the process to generate image pairs with proposed adjacent-syntropy sub-sampler. The generated paired images, in different colors, are generated in the above way. (a) The horizontal mode. (b) The portrait mode.
generation process of the proposed adjacent-sentropy sub-sampler consists of three steps. Firstly, divide the original image into small patches. Take a square of side length k as the basic unit to divide the \(\log\)_Y_. \(\left[W/k\right]\times\left[H/k\right]\) patches can be achieved. Empirically, \(k\) is set as 2. Secondly, select the pixels for paired images. Two pixels of _i_-th row and _j_-th column patch are selected according to the adjacent-sentropy rule. Remarkably, selection has two modes: horizontal and portrait, which make sure that the two pixels satisfy the condition of being adjacent and in the same direction. Each mode is selected with a probability of 0.5. Once selected, the sub-images are sampled according to the mode. In this way, the underlying ground-truth of paired images are closer as far as possible and have similar texture structure. Then, the two pixels are taken to be the (_i,j_) column element of \(\text{g}_{1}(\log Y)\) and \(\text{g}_{2}(\log Y)\) respectively. Thirdly, repeat the second step to generate paired images. The image pair \(\left\{\text{g}_{1}(\log Y),\text{g}_{2}(\log Y)\right\}\) is finally obtained. The size of \(\left\{\text{g}_{1}(\log Y),\text{g}_{2}(\log Y)\right\}\) is \(\left[W/k\right]\times\left[H/k\right]\). By adding \(C\) to \(\left\{\text{g}_{1}(\log Y),\text{g}_{2}(\log Y)\right\}\), the final training image pair (\(y_{1}\), \(y_{2}\)) is obtained.
In conclusion, the adjacent-sentropy sub sampler can be used to acquire paired images from single speckled image for training. The adjacent characteristic can make sure that the underlying ground-truths of (\(y_{1}\), \(y_{2}\)) are close to each other, since corresponding selected pixels of (\(y_{i}\), \(y_{2}\)) are neighbors in the \(\log\)_Y_. The syntropy characteristic ensures that the texture structures of the sampled sub-images are not much different from each other, and the spatial distribution is similar. The adjacent-sentropy sub sampler meets that the gap between the \(y_{i}\) and \(y_{2}\) is small.
### _Parameter-sharing convolutional neural networks_
Theoretically, paired training images \(y_{i}\) and \(y_{2}\) are hoped to have the same underlying ground truth. However, there is still gap between \(y_{1}\) and \(y_{2}\). Single branch network is greatly affected by the gap. Considering the parameter sharing network can measure the similarity between images, the parameter-sharing network is adopted to narrow the gap of paired training images. Besides, an accurate despeckling model can be trained by exploiting the information of the paired training images twice. To realize parameter sharing, the despeckling network takes \(y_{t}\) to be the inference of \(y_{2}\) and then takes \(y_{2}\) to be the inference of \(y_{t}\) subsequently. The process can be seen as a two-branches network in Fig. 3. Each branch of the parameter-sharing network is a despeckling network such as SAR-CNN or SAR-DRN. The network's inputs are generated training pairs: (\(y_{1}\), \(y_{2}\)), and the outputs are \(x_{l}\) and \(x_{2}\) accordingly.
The SAR-CNN and SAR-DRN are employed as our baseline and call the parameter-sharing networks SAR-CNN\(+\)SDSS (Self-supervised Despeckling Strategy for SAR) and SAR-DRN\(+\)SDSS, respectively.
### _Multi-feature loss function_
In the proposed self-supervised strategy, the multi-feature loss function is designed to remove as much speckle noise as possible while achieving the goal of preserving image texture details. It takes into account the characteristics of SAR images and narrows the gap between the noise pairs generated by the sub-sampler. The proposed multi-feature loss function \(L\) is a linear sum of three terms: the despeckling term, the regularization term and the perception term.
MSE is used as the despeckling term. According to the derivation in Section III-A, MSE can be used as the loss function. To accelerate the convergence of MSE, it is formulated as:
\[L_{deep}=\frac{\left\|{x_{1}-y_{2}}\right\|_{2}^{2}}{\left\|{X_{1}-x_{1}} \right\|_{2}^{2}}+\frac{\left\|{x_{2}-y_{1}}\right\|_{2}^{2}}{\left\|{X_{2}-x_ {2}}\right\|_{2}^{2}} \tag{21}\]
There, \(y_{l}\) and \(y_{2}\) are the noisy image pairs for training respectively, \(x_{l}\) and \(x_{2}\) are the despeckled images of \(y_{l}\) and \(y_{2}\) obtained by the network. \(X_{l}\) and \(X_{2}\) are generated paired images from despeckled image. Considering that directly applying the despeckling term will lead to over-smoothing, a regularization term should be adopted to address the gap
Fig. 3: The presentation of adopted despeckling networks. Each branch of the parameter-sharing network is a despeckling network such as SAR-CNN or SAR-DRN. They are trained with generated paired images \(y_{l}\) and \(y_{2}\). (a) The structure of parameter-sharing SAR-CNN. (b) The structure of parameter-sharing SAR-DRN.
between the generated paired images. In the optimal situation, despeckling network and clean image satisfy that \(f_{\theta}^{*}(\log Y)=\log X\) and \(f_{\theta}^{*}(\texttt{g}_{1}(\texttt{g}_{1}(\log Y))=\texttt{g}_{1}(\log X)\).
The following regularized optimization term applies to the optimal network\(f_{\theta}^{*}\):
\[\begin{split} L_{reg}=&\parallel x_{1}-y_{2}+X_{1}- X_{2}\parallel+\\ &\parallel x_{2}-y_{1}+X_{1}-X_{2}\parallel\end{split} \tag{22}\]
To preserve edges and identify structures, a perceptual loss is used to generate high-quality despeckled images. First, VGG16 is used to extract the feature maps of the despeckled sub-image \(x_{i}\) and sub-image of despeckled image \(X_{i}\). Then MSE is used to compare the features of the two to make the high-level information (content and global structure) close to enhance the details. The perceptual term is expressed as:
\[\begin{split} L_{par}=&\frac{1}{CHW}\left\| \phi(X_{i})-\phi(x_{i})\right\|_{2}^{2},\\ i=& 1,2\end{split} \tag{23}\]
There, \(\phi\) is the VGG network and \(\phi(\cdot)\) represents a feature map of shape \(\mathcal{C}\times H\times W\).
The actual cost function is composed of three terms:
\[\begin{split} L=L_{deep}+\alpha L_{reg}+\beta L_{par}\end{split} \tag{24}\]
Specifically, the \(L_{deep}\) term is responsible for the reconstruction of the despeckled image space. It takes into account the characteristics of speckle noise as well as faster convergence. The \(\texttt{L}_{\text{reg}}\) term is to compensate for the gap between the generated paired images and prevent the despeckling effect from being too smooth. The \(L_{per}\) term is to preserve image texture details and edge information.
## IV Experiment
In this section, the performance about despeckling of our proposed self-supervised strategy is evaluated experimentally. First, the network SAR-CNN and the network SAR-DRN are trained with our strategy. They are full-supervised networks and are employed as our baseline. Second, quantitative and visual comparison experiments are performed to illustrate the superiority of our proposed strategy. Third, the comprehensive ablation studies are conducted to explain the effectiveness of our strategy further.
### _Implementation Details_
The patch size of adjacent-surrropy sub-samplers is fixed as 2. As for the parameters of loss functions, \(\alpha\) is set as 2 and \(\beta\) is set as 1 empirically. Adam optimizer is adopted and its initial learning rate is set as 0.0003. Per 20 epochs, the learning rate is decayed by half. The batch size of training data is set as 4 and the number of epochs is set as 200. The experimental framework is PyTorch 1.4.0. Our dataset is acquired from TerraSAR, Sentinel-1 and RADARSAT2 systems.
### _Evaluation Metrics_
#### Iv-B1 Enl
ENL[35] is a non-referenced metric, which is used to evaluate the performance of suppressing speckle noise by measuring smoothness in homogeneous region. ENL is defined as:
\[\textit{ENL}=\frac{\mu_{d}^{2}}{\sigma_{d}^{2}} \tag{25}\]
where the \(\mu_{d}\) is the mean of despeckled image and \(\sigma_{d}\) is the standard variance of despeckled image. If the value is higher, the performance of despeckling is better.
#### Iv-B2 Tcr
The TCR [36] value is used to evaluate the performance of retaining the scattering information. Specially, it is important to keep the high returns of strong scattering point in target detection tasks. By measuring the difference between scattering information in the speckled image and despeckled image. TCR is defined as:
\[TCR=\left|20\cdot\log 10\frac{\max(\hat{X})}{E(\hat{X})}-20\cdot\log 10\frac{ \max(X)}{E(X)}\right| \tag{26}\]
where \(X\) represents the patches of speckled image and \(\hat{X}\) represents the patches of despeckled images, respectively. The smaller the TCR value, the better the performance of retaining the scattering information.
#### Iv-B3 MoR
The MoR[37] value is used to measure the performance of preserving radiometric information in the despeckled images. MoR is defined as:
\[\textit{MoR}=\frac{1}{\textit{WH}}\sum_{w=1}^{W}\sum_{h=1}^{H}\frac{X_{w,h}^{ HR}}{\hat{X}_{w,h}^{HR}} \tag{27}\]
where \(X\) represents the patches of speckled image and \(\hat{X}\) represents the patches of despeckled images, respectively.
The highest value of MoR is 1. The closer to 1 the MoR value, the better the performance of preserving radiometric information.
#### Iv-B4 Epd-Roa
The EPD-ROA [38] can evaluate the performance of retaining edges for a filter, which is given by:
\[\begin{split} EPD-ROA=\frac{\sum_{i=1}^{M}\left\|\hat{X}_{A}(i) \right./\left.\hat{X}_{B}(i)\right\|}{\sum_{i=1}^{M}\left|X_{A}(i)\right./\left. X_{B}(i)\right|}\end{split} \tag{28}\]
Where \(\hat{X}_{A}(i)\) and \(\hat{X}_{B}(i)\) represent the adjacent pixel values of filtered images along the certain direction, respectively. \(\text{X}_{A}(i)\) and \(\text{X}_{B}(i)\) represent the adjacent pixel values of initial images along the certain direction, respectively. If the EPD-ROA value is higher, the performance of retaining edges is better.
### _Comparison with Baseline_
The SAR-CNN and SAR-DRN are employed as our baseline. Our self-supervised networks are referred to as SAR-CNN\(+\)SDSS and SAR-DRN\(+\)SDSS, respectively. In Fig. 4 and Fig. 5, the comparison results are presented.
It can be seen from Fig. 4 and Fig. 5, either compared with SAR-CNN or compared with SAR-DRN, our SDSS achieves better despeckling performance. Especially when it comes to preserving textures, our strategy has more obvious advantages. The supervised networks are trained with synthetic SAR images and tested on the real-world SAR images. However, the characteristics of SAR images are inconsistent with optical images, especially scattering property. Their performance is not good enough due to the domain gap. As shown in the red box of Fig. 4 and Fig. 5, the texture information is blurred or lost. In addition, scattering information from some strong point targets are weaken. On the opposite, our SDSS strategy solves the domain gap problems and retains edges well. Besides, in the respect of retaining the high returns from strong point targets, our SDSS strategy can preserve the scattering intensity, while the supervised networks reduce the scattering intensity because of their washing despeckled effect.
Figure 6: Comparison results of our proposed SAR-DRN+SDSS on Sentinel-1 image against other methods: Lee, SAR-BM3D, HDRANet and MONet. (a) Despeckling results of different methods. (b) Details of the despeckling images.
Figure 7: Comparison results of our proposed SAR-DRN+SDSS on TerraSAR image against other methods: Lee, SAR-BM3D, HDRANet and MONet. (a) Despeckling results of different methods. (b) Details of the despeckling images.
### _Comparison with State-of-the-art_
To reveal the despeckling performance of the proposed SDSS strategy, the despeckling results of SAR-DRN+SDSS with those of the SAR despeckling methods are compared: the PPP filter, the SAR-BM3D filter, the HDRANet and the MONet. The despeckling results on different SAR images are shown in Fig. 6 to Fig. 8. The quantitative evaluation results of ENL, TCR, MoR and EPD-ROA of the different methods are also listed in Table I.
#### Iv-D1 Qualitative Results
As revealed in Fig. 6 to Fig. 8, the Lee filter can remove speckle noise well, but the homogeneous region has obvious block effect, leading to the blurring of structures. SAR-BM3D performs better than the Lee filter as the image contrast is higher and the structure is clearer. However, slight artifacts can still be observed in the SAR-BM3D despeckling results. The two methods based on supervised deep learning show better despeckling performance compared with the previous traditional methods. They are good at smoothing images to remove speckle noise. But it is accompanied by distorting many of the image features. HDRANet, trained on synthetic SAR images, exists the problem of over-smoothing the heterogeneous area. MONet has better feature retention properties, but the problem of domain gap still exists. Our SDSS strategy, while looking slightly less smooth than the two supervised methods, excels at preserving features in the heterogeneous area and suppressing speckle noise in homogeneous area.
In summary, our SDSS strategy is able to despeckle without any noise-free reference labels. At the same time, the purpose of suppressing speckle noise in homogeneous area while preserving the texture and edge information in heterogeneous area is achieve. Our method achieves comparable or even superior performance to fully supervised methods.
#### Iv-D2 Quantitative Results
The ENL values listed in Table I illustrate that, the HDRANet and MONet have good performance of suppressing the speckle noise. However, due to domain gaps, over-smoothing occurs, which means that the ENL value alone cannot fully evaluate the despeckling performance. The TCR and MoR value are used to evaluate the performance of retaining the scattering information from strong point targets and radiometric preservation respectively. Our proposed strategy, SDSS, achieves the highest TCR and MoR scores. Furthermore, SDSS shows stronger capacity of retaining edges according to the EPD- ROA value. Instead of using optical images to simulate SAR images, our proposed SDSS realize despeckling by learning from real SAR images directly. Thus, the problem of domain gap is solved fundamentally. Specifically, our proposed SDSS showed good ability of suppressing speckle noise, preserving texture information, and preserving radiometric information, according to these evaluation metrics.
Fig. 8: Comparison results of our proposed SAR-DRN+SDSS on TerraSAR image against other methods: Lee, SAR-BM3D, HDRANet and MONet. (a) Despeckling results of different methods. (b) Details of the despeckling images.
From the perspective of visual results and assessment indices, the SDSS strategy has a positive effect on all images.
### _Ablation Study_
Here, ablation studies of our SDSS strategy are conducted for further study. Specially, we assess 1) the influence of the sampling strategy; 2) the performance of the parameter-sharing convolution network; 3) the importance of each term in the multi-feature loss function; 4) the influence of the weight in the multi-feature loss function.
_1) the influence of the sampling strategy_
The validity of our proposed adjacent-syntropy sub-sampler is illustrated by comparing in Section III-C to the random neighbor sub-sampler. The comparison results are illustrated in the Fig. 9.
\begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{Figure} & \multirow{2}{*}{Index} & Random & Adjacent-syntropy \\ & & sub-samplers & sub-samplers \\ \hline \multirow{2}{*}{1} & ENL & 100.3635 & **313.3470** \\ & MoR & 0.8728 & **0.8847** \\ \hline \multirow{2}{*}{2} & ENL & 103.0519 & **134.7330** \\ & MoR & 0.9365 & **0.9701** \\ \hline \hline \end{tabular}
\end{table} TABLE II: Quantitative results of sampling strategy.
\begin{table}
\begin{tabular}{c|l|c|c|c|c} \hline \hline No. & Method & ENL & TCR & MoR & EPD-ROA \\ \hline \multirow{4}{*}{Image} & Lee & 43.8345 & 3.9190 & 0.8021 & 0.6972 \\ \cline{2-6} & SAR-BM3D & 31.2785 & 4.0905 & 0.7952 & 0.7002 \\ \cline{2-6} & HDRANet & **46.5970** & 5.0730 & 0.8120 & 0.6856 \\ \cline{2-6} & MONet & 44.2231 & 4.3958 & 0.8260 & 0.6976 \\ \cline{2-6} & SAR-DRN+SDSS(Proposed) & 40.6545 & **3.9136** & **0.9481** & **0.7053** \\ \hline \multirow{4}{*}{Image} & Lee & **5.6600** & 1.3706 & 0.7943 & 0.8441 \\ \cline{2-6} & SAR-BM3D & 3.5305 & 1.1768 & 0.6864 & 0.8497 \\ \cline{2-6} & HDRANet & 4.9029 & 1.5194 & 0.8477 & 0.8394 \\ \cline{2-6} & MONet & 4.8265 & 1.7199 & 0.9253 & 0.8414 \\ \cline{2-6} & SAR-DRN+SDSS(Proposed) & 4.2472 & **1.1378** & **0.9515** & **0.8572** \\ \hline \multirow{4}{*}{Image} & Lee & 47.9865 & 3.7501 & 0.8743 & 0.6937 \\ \cline{2-6} & SAR-BM3D & 41.9027 & 6.7534 & 0.9894 & **0.6989** \\ \cline{1-1} \cline{2-6} & HDRANet & **61.6822** & 2.5735 & 0.8524 & 0.6954 \\ \cline{1-1} \cline{2-6} & MONet & 59.9685 & 1.9055 & 0.9692 & 0.6955 \\ \cline{1-1} \cline{2-6} & SAR-DRN+SDSS(Proposed) & 51.1076 & **1.5773** & **0.9981** & 0.6974 \\ \hline \hline \end{tabular}
\end{table} TABLE I: Quantitative Results for different images
Fig. 9: Visual comparison results of sub-sampler: random neighbor sub-sampler and proposed adjacent-syntropy sub-sampler. (a) The top row is the despeckling results when using random neighbor sub-sampler. The second row is the details of the corresponding images. (b) The top row is the despeckling results when using proposed adjacent-syntropy sub-sampler. The second row is the details of the corresponding images.
The filtered result using the random neighbor sub-sampler tends to show the grid effect in homogeneous regions. It is can be inferred that the randomness sampling disturbs the structure of the image which leads to the inconsistency of noisy pairs. Our sampling strategy takes the texture into consideration to alleviate this phenomenon. Furthermore, the quantitative comparison is shown in Table II.
The comparison displays the vital role of syntropy in the proposed sampling strategy and the proposed adjacent-syntropy sub-sampler achieves better performance.
#### V-A2 the performance of the parameter-sharing convolution network
To validate that the parameter-sharing convolution network can better exploit the information of the images, it is compared with the original network. From Table III, it can be observed that the parameter-sharing network achieved higher scores of ENL, TCR, MoR and EPD-ROA. Though the original network has achieved good performance, the employment of parameter-sharing can take full advantage of the training information of generated paired images, thereby improving despeckling performance. It also can narrow the gap between paired images to improve the accuracy of training.
#### V-A3 the importance of each term in the multi-feature loss function
The three terms in the multi-feature loss function are used to remove noise, narrow gap between the noise pairs generated by the sub-sampler and preserve texture details respectively. Table IV lists the performance of SSDS strategy under different combination of above terms. From Table IV, the following observations can be achieved. First, when the despeckling term is removed, the ENL scores are low. It indicates that the despeckling results remain a mass of speckle noise. So, the despeckling term is vital for removing noise. When the coefficient of regularization term is set as 0, the corresponding despeckled image is over-smoothing and loses texture information. This term plays a role of narrowing gap between the training paired images Third, the removal of perceptual term makes the EPD-ROA value decreases. It strengthens the concentration on the edge and the structures to improve the quality of despeckled images.
#### V-A4 the influence of the weight in the multi-feature loss function
The hyper-parameter \(\alpha\) and \(\beta\)are introduced in Equation (13) to control the proportion of the regularization term and perceptual term in the multi-feature loss function. Table V lists the performance under different combination of \(\alpha\) and \(\beta\) values. As shown in the Table V, the weights act as a controller between smoothness and details. First, a larger \(\alpha\) leads to a better the details retention while the ENL of the despeckled image is reduced, which means poor despeckling effect. Second, the larger the \(\beta\), the better the details retention. However, increasing the ENL will lead to a decrease in the despeckling effect (Probably some of the noise was retained during edge retention) and will no longer have the effect of increasing the EPD-ROA up to a certain point.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multicolumn{2}{c}{ENL} & \(\alpha=1\) & \(\alpha=2\) & \(\alpha=3\) & \(\alpha=4\) \\ /EPD-ROA & \(\alpha=1\) & \(\alpha=2\) & \(\alpha=3\) & \(\alpha=4\) \\ \hline \multirow{2}{*}{\(\beta=1\)} & 62.9232 & **63.4325** & 62.7235 & 62.4519 \\ & /0.8442 & **/0.8453** & /0.8471 & /0.8453 \\ \multirow{2}{*}{\(\beta=2\)} & 63.4296 & 62.9187 & 62.7030 & 62.4482 \\ & /0.8517 & /0.8471 & /0.8497 & /0.8453 \\ \hline \multirow{2}{*}{\(\beta=3\)} & 63.4226 & 62.9109 & 62.6928 & 62.4115 \\ & /0.8497 & /0.8492 & /0.8464 & /0.8475 \\ \multirow{2}{*}{\(\beta=4\)} & 63.4182 & 62.7830 & 62.3925 & 62.4193 \\ & /0.8464 & /0.8442 & /0.8441 & /0.8453 \\ \hline \hline \end{tabular}
\end{table} TABLE V: Ablation on different weights (\(\alpha,\beta\)) of the regularization term. ENL and EPD-ROA results are evaluated.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Data & Method & ENL & TCR & MoR & EPD-ROA \\ Source & & 74.2482 & 0.8975 & 0.9634 & 0.6756 \\ \multirow{2}{*}{TerraSAR} & Parameter-sharing SAR-CNN & 75.3324 & 1.1373 & 0.9659 & 0.6923 \\ & SAR-DRN & 75.9832 & 0.9588 & 0.9832 & 0.6852 \\ & Parameter-sharing SAR-DRN & 76.3283 & 1.2423 & 0.9870 & 0.7071 \\ \multirow{2}{*}{Sentinel-1} & SAR-CNN & 86.2748 & 1.7394 & 0.9265 & 0.7235 \\ & Parameter-sharing SAR-CNN & 86.0372 & 1.9424 & 0.9304 & 0.7764 \\ \multirow{2}{*}{Sentinel-1} & SAR-DRN & 88.2374 & 2.1413 & 0.9558 & 0.7848 \\ & Parameter-sharing SAR-DRN & 88.4928 & 2.3820 & 0.9587 & 0.8149 \\ \hline \hline \end{tabular}
\end{table} TABLE III: Quantitative results of parameter-sharing convolution network.
## V Conclusion
In this work, a self-supervised SAR despeckling strategy (SDSS) is proposed. It is possible to train the existing despeckling network with the speckled SAR images only. In our SDSS, the parameter-sharing networks are trained using the generated noisy pairs by the adjacent-syntropy sub-sampler and the multi-features loss function. This strategy is able to be migrated to the existing supervised despeckling networks.
The first part of our SDSS strategy is the adjacent-syntropy sub-sampler, which overcomes the domain gap problem caused by training with optical images by generating noise pairs that satisfy the same underlying clean target. Second, the use of a parameter-sharing network fully exploits the information within the generated noisy pairs, resulting in improved despeckling performance. Finally, the multi-feature loss function is designed to remove noise as much as possible while preserving texture details, taking into account the spatial and statistical characteristics of the SAR image, and compensating for the gap between the noise pairs generated by the sub sampler.
Experiments performed on actual SAR images have demonstrated that our proposed self-supervised despeckling strategy removes noise significantly, with performance that equals or even surpasses that of several advanced despeckling algorithms.
In the future, we are going to propose a despeckling network with strong interpretability and good despeckling performance based on the self-supervised despeckling strategy combined with the characteristics of SAR.
|
2310.15938 | ABKD: Graph Neural Network Compression with Attention-Based Knowledge
Distillation | Graph Neural Networks (GNNs) have proven to be quite versatile for a variety
of applications, including recommendation systems, fake news detection, drug
discovery, and even computer vision. Due to the expanding size of
graph-structured data, GNN models have also increased in complexity, leading to
substantial latency issues. This is primarily attributed to the irregular
structure of graph data and its access pattern into memory. The natural
solution to reduce latency is to compress large GNNs into small GNNs. One way
to do this is via knowledge distillation (KD). However, most KD approaches for
GNNs only consider the outputs of the last layers and do not consider the
outputs of the intermediate layers of the GNNs; these layers may contain
important inductive biases indicated by the graph structure. To address this
shortcoming, we propose a novel KD approach to GNN compression that we call
Attention-Based Knowledge Distillation (ABKD). ABKD is a KD approach that uses
attention to identify important intermediate teacher-student layer pairs and
focuses on aligning their outputs. ABKD enables higher compression of GNNs with
a smaller accuracy dropoff compared to existing KD approaches. On average, we
achieve a 1.79% increase in accuracy with a 32.3x compression ratio on
OGBN-Mag, a large graph dataset, compared to state-of-the-art approaches. | Anshul Ahluwalia, Rohit Das, Payman Behnam, Alind Khare, Pan Li, Alexey Tumanov | 2023-10-24T15:34:30Z | http://arxiv.org/abs/2310.15938v1 | # ABKD: Graph Neural Network Compression with Attention-Based Knowledge Distillation
###### Abstract
Graph Neural Networks (GNNs) have proven to be quite versatile for a variety of applications, including recommendation systems, fake news detection, drug discovery, and even computer vision. Due to the expanding size of graph-structured data, GNN models have also increased in complexity, leading to substantial latency issues. This is primarily attributed to the irregular structure of graph data and its access pattern into memory. The natural solution to reduce latency is to compress large GNNs into small GNNs. One way to do this is via knowledge distillation (KD). However, most KD approaches for GNNs only consider the outputs of the last layers and do not consider the outputs of the intermediate layers of the GNNs; these layers may contain important inductive biases indicated by the graph structure. To address this shortcoming, we propose a novel KD approach to GNN compression that we call Attention-Based Knowledge Distillation (ABKD). ABKD is a KD approach that uses attention to identify important intermediate teacher-student layer pairs and focuses on aligning their outputs. ABKD enables higher compression of GNNs with a smaller accuracy dropoff compared to existing KD approaches. On average, we achieve a \(1.79\%\) increase in accuracy with a \(32.3\times\) compression ratio on OGBN-Mag, a large graph dataset, compared to state-of-the-art approaches.
## 1 Introduction
Graph Neural Networks (GNNs) generalize Convolutional Neural Networks (CNNs) to non-Euclidean data. GNNs are widely used in a variety of fields, such as web-search recommendation systems (Ying et al., 2018), fake news detection for social networks (Han et al., 2020), modeling proteins for drug discovery (Zitnik and Leskovec, 2017), and computer vision tasks (Chen et al., 2022). Due to the expanding size of social networks and other graph-structured data, graph datasets have been steadily increasing in size (Wang et al., 2020). As datasets have expanded in size, GNN models have also increased in complexity, leading to substantial latency issues (Zhou et al., 2021; Que et al., 2023; Tan et al., 2023), as shown in figure 1. This is primarily attributed to the irregular structure of graph data and their access pattern in memory (Liu et al., 2022).
Due to this limitation, large GNNs need to be compressed into smaller GNNs for latency-sensitive applications such as real-time recommendation (Liu et al., 2022), visual question answering (Senior et al., 2023), image search (Formal et al., 2020), and real-time spam detection (Li et al., 2019).
### Knowledge Distillation
Knowledge Distillation (KD) is a common compression technique that uses a teacher model to supervise the training of a smaller student model (Hinton et al., 2015). While the original KD method can be applied to GNNs, it does not take into account any information about node connectivity. GraphAKD (He et al., 2022), LSP (Yang et al., 2021), and G-CRD (Joshi et al., 2022) are GNN-specific knowledge distillation methods that focus on aligning final layer node embeddings by considering node connectivity. However, these methods all consider only the node embeddings at the final layer and do not consider intermediate representations. By just aligning the final node embeddings, the model cannot learn the logic behind leveraging the connectivity of the graph or the
inductive biases (Baxter, 2000) contained in the adjacency matrix. Therefore, the student model is effectively just learning a mapping from node attributes to more refined node embeddings. This can lead to suboptimal test generalization when the model encounters previously unseen data.
**Objective**: Our goal is to achieve better generalization on out-of-distribution data, measured by accuracy @ various compression rates, by considering intermediate node embeddings and taking into account more of the inductive biases that GNNs contain.
### Attention-Based Knowledge Distillation
To improve accuracy over SOTA, we must consider some of the inductive biases that other methods overlook - the connectivity of the input graph. We observe that for the vast majority of GNN architectures, the \(k^{th}\) layer of a GNN computes node embeddings by aggregating information from each node's \(k\)-hop neighborhood. Therefore, each layer contains its own inductive bias. As other KD methods consider only the node embeddings at the last layer of the teacher and student networks, they do not leverage all the inductive biases present in the network. However, one obvious challenge that is present in aligning intermediate node embeddings is that teacher and student networks will likely have a different number of hidden layers. As a result, there is no 1-1 correspondence between teacher and student layers and no way to easily figure out which teacher node embeddings should be aligned with which student node embeddings.
To tackle these challenges, we propose Attention-Based Knowledge Distillation (ABKD). We use a trainable attention mechanism to learn which teacher-student pairs are the most important to align. We also utilize trainable projections into a common ABKD embedding space for teacher and student hidden layers. By aligning across intermediate layers, the student learns how to use the adjacency matrix to construct node embeddings instead of just learning a mapping from the node attributes to the final layer node embeddings (Figure 2).
### Our Contributions
Our contributions are summarized as the following:
1. We design Attention-Based Knowledge Distillation (ABKD), a novel knowledge distillation approach for GNNs that incorporates the intermediate feature maps from every layer in both the teacher and student networks. This approach can be utilized to train teacher and student networks of any architectural configuration.
Figure 1: Inference latency of GNNs with varying model sizes on the Flickr Zeng et al. (2020) dataset on a standard GCN model architecture with increasing embedding dimension. All tests were run on a Tesla V100 GPU.
2. We create an automatic feature linking mechanism using attention to identify which teacher-student layer pairs are the most important, which we then use to closely align their feature maps.
3. Our approach broadly improves the test accuracy of student networks over a large range of compression ratios.
4. We comprehensively test our approach on several datasets using different model architectures including GCNs (Kipf and Welling, 2016), RGCNs (Schlichtkrull et al., 2017) and GraphSAGE (Hamilton et al., 2017). We also test on several large datasets that are carefully curated to evaluate out-of-distribution generalization such as OGBN-Mag (Wang et al., 2020) and OGBN-Arxiv (Wang et al., 2020).
## 2 Related Work
**Knowledge Distillation** KD for GNNs is a relatively niche field that has expanded over the last three years with the work of LSP (Yang et al., 2021). In this work, the authors attempt to align node embeddings between the student and teacher networks by maximizing the similarity between embeddings that share edges. As only node embeddings between edges are aligned, this KD method only preserves local topology. Joshi et al. (2022) extend LSP and propose two different KD algorithms: Global Structure Preserving Distillation (GSP) and Global Contrastive Representation Distillation (G-CRD). GSP extends LSP by considering all pairwise similarities among node features, not just pairwise similarities between nodes connected by edges. The authors also propose G-CRD which aims to implicitly preserve global topology by aligning the student and teacher node feature vectors via contrastive learning (van den Oord et al., 2018). Another work introduces graph adversarial knowledge distillation (GraphAKD), which trains the student model as a generator network and a discriminator network to distinguish between the predictions of the student and teacher models (He et al., 2022). Another work, GeometricKD forces the number of teacher and student hidden layers to be the same to study the impact of a student network operating on a smaller graph than the teacher (Yang et al., 2023).
With the exception of GeometricKD, these works all consider the node embeddings at the final layer of the teacher and student network and aim to align those embeddings with one another in various ways. GeometricKD constrains the student and teacher networks to have the same number of layers, and it aligns the node embedding of teacher layer \(i\) with student layer \(i\), thus forming a 1-1 correspondence between the layers, which makes it inflexible to all student and teacher configurations. There have been several KD approaches that have been applied to CNNs that the GNN community has tried to adapt to GNNs with poor results, namely Fitnets (Romero et al., 2015) and attention transfer (Zagoruyko and Komodakis, 2016). These methods both compute a distance metric such as mean-squared error between the last layer node embeddings of the student and teacher network and do not take into account the adjacency matrix.
Using attention to find similarities across student and teacher layers is a concept explored in CNNs Ji et al. (2021). However, this work's ideas cannot be applied to GNNs because the operations it uses to compare student and teacher features do not apply to GNNs. GNNs need special consideration in this regard over CNNs due to the non-spatial and unstructured form of graph data.
**Compression:** Other common techniques for GNN compression include quantization and pruning. Quantization techniques differ for GNNs when compared to other deep neural networks because of unique sources of error, such as inaccurate gradient estimates, that arise due to the unstructured nature of GNNs (Tailor et al., 2021). To account for inaccurate gradient estimates, DegreeQuant, protects some number of nodes in every training iteration from lower precision training and utilizes full precision training for those nodes (Tailor et al., 2021). Other approaches consider the structure of the graph in their calculations to implicitly avoid GNN-specific sources of error (Feng et al., 2020; Bahri et al., 2021).
Pruning techniques, which involve compressing networks by selectively deleting learned parameters, have also been applied to GNNs. These techniques involve applying strategies that have worked for other deep networks and using them to identify the most important channels for output activation (Chen et al., 2021)(Zhou et al., 2021). One approach also works to dynamically prune during execution (Chen et al., 2021).
## 3 Proposed Approach
### Intuition and Mathematical Foundations
In this section, we first discuss the intuition behind ABKD and introduce some of the mathematical definitions needed to explain it thoroughly.
#### 3.1.1 SoftKD Intuition
In SoftKD (Hinton et al., 2015), we compute two different losses. The first, \(H(s_{p},y)\), is a cross-entropy loss between the output student probability distribution and the ground truth labels. The other, \(H(s_{p},t_{p})\), is a cross-entropy loss between the output student probability distribution and the output teacher probability distribution. The total loss is defined as:
\[L_{KD}=H(s_{p},y)+\alpha H(s_{p},t_{p}) \tag{1}\]
Here, \(\alpha\) is a hyper-parameter controlling how much the KD loss affects the total loss. The goal is to align the output student probability distribution with the output teacher probability distribution. The higher \(H(s_{p},t_{p})\) is, the less aligned the student and teacher output probability distributions are.
#### 3.1.2 ABKD Intuition
Similarly, with ABKD, we want to incorporate this intuition of alignment. However, we want to go further than just aligning the final output - we want to align the outputs at the intermediate layers, as the intermediate layers contain inductive biases that are not present in just the final layers. As one of our goals with ABKD is to work with any combination of teacher and student architectural configurations, this presents one significant challenge: Teacher and student networks will likely have a different number of hidden layers, which means there is no 1-1 correspondence between teacher and student layers.
ABKD solves this problem by identifying which teacher-student layer pairs are the most important to align via an attention mechanism. This mechanism works with any arbitrary number of teacher layers and student layers, which makes this approach amenable to any arbitrary teacher-student configuration. ABKD also uses a reprojection technique to account for the student and teacher networks having different hidden dimensions. The output of each hidden layer for both the teacher and student networks is projected into a standardized embedding dimension, which ensures that we can work with student and teacher networks of any embedding dimension. As each layer represents its own semantic information, an important challenge that we faced was to ensure that each layer's feature map was not smoothed out by a single projection matrix. To this end, we use separate trainable linear layers for each hidden layer in both the teacher and student networks, in order to ensure that we don't lose out on any valuable semantic information in the hidden layers.
These trainable linear layers help us construct the two key components of ABKD, which are the attention map and the dissimilarity map. At a high level, the attention map tells us how important each teacher-student layer pair is, while the dissimilarity map tells us how distant the feature maps of each teacher-student layer pair are. The teacher-student layer pairs with higher attention scores are deemed as more important, and ABKD focuses on reducing their dissimilarity scores during training.
\begin{table}
\begin{tabular}{|c|c|} \hline Method & Number of Layers Considered \\ \hline GraphAKD & \(1\) \\ G-CRD & \(1\) \\ Fitnets & \(1\) \\ LSP & \(1\) \\ ABKD & **All** \\ \hline \end{tabular}
\end{table}
Table 1: Comparison of Attention-Based Knowledge Distillation with other Knowledge Distillation approaches.
#### 3.1.3 Mathematical Foundation
Without loss of generality, we will consider distilling a general Graph Convolution Network (GCN) (Kipf & Welling, 2016), in which the output of the \(l^{th}\) layer is
\[H^{l}=\sigma(\hat{A}H_{l-1}W_{l}) \tag{2}\]
Here, \(\sigma\) is an activation function and \(\hat{A}\) is the normalized adjacency matrix, \(\hat{A}=D^{-\frac{1}{2}}AD^{-\frac{1}{2}}\), where \(D\) is the diagonal degree matrix. \(H^{l-1}\in R^{n\times d}\) represents the output of the last hidden layer and \(W^{l}\in R^{d\times d}\) represents the trainable weights of the current layer.
Consider two different tensors \(T\in R^{T_{l}\times n\times d_{e}}\) and \(S\in R^{S_{l}\times n\times d_{e}}\). \(T_{l}\) and \(S_{l}\) represent the number of layers in the teacher and student networks respectively. \(n\) represents the number of nodes in the graph that is being trained on and \(d_{t}\) and \(d_{s}\) represents the dimensionality of the teacher and student networks, respectively. \(T\) and \(S\) represent the calculated layer maps before activation is applied at every layer for the teacher and student networks, respectively.
### ABKD
#### 3.2.1 Attention Scores
The first step of ABKD is to generate \(A\in R^{T_{l}\times S_{l}}\). \(A_{ij}\) will represent an "importance" score for the layer pair consisting of teacher layer \(i\) and student layer \(j\). We take the average of the feature maps along the node dimension to compute a mean node feature for every layer in both the teacher and student networks. Call these tensors \(T_{a}\in R^{T_{l}\times d_{e}}\) and \(S_{a}\in R^{S_{l}\times d_{e}}\). Then, we pass each layer in \(T_{a}\) through its own linear layer to create \(T_{p}\in R^{T_{l}\times d_{a}}\), where \(d_{a}\) is the embedding dimension of ABKD. Similarly, we create \(S_{p}\in R^{S_{l}\times d_{a}}\). We can finally generate \(A\) in the following manner:
\[A=softmax(\frac{T_{p}S_{p}^{T}}{\sqrt{d_{a}}}) \tag{3}\]
#### 3.2.2 Dissimilarity Scores
The next step is to compute a pairwise dissimilarity score for each teacher-student layer pair. Again, we project the features into \(d_{a}\). For calculating the attention scores, we averaged over the node dimension before projecting, as our goal was to identify important layers. When calculating the
Figure 2: ABKD generates an attention map using a trainable attention mechanism and a dissimilarity map using a trainable subspace projection. The loss matrix is an element-wise multiplication of the attention matrix and the dissimilarity matrix.
pairwise dissimilarity, we want to incorporate the per-node embeddings. So, we use a separate set of projection matrices. We use \(P_{t}\in R^{d_{t}\times d_{a}}\) and \(P_{s}\in R^{d_{s}\times d_{a}}\) to represent the projections.
However, distance metrics are less semantically valuable if \(d_{a}\) is high. To alleviate this problem, we define a trainable matrix \(P\in R^{d_{a}\times d_{a}}\) to project all vectors into the subspace defined by the column space of \(P\). Since the cardinality of the subspace defined by the column space of \(P\) will be smaller than or equal to the cardinality of \(R^{d_{a}}\), distance metrics within the subspace will be more valuable on average compared to distance metrics in \(R^{d_{a}}\).
The final step is to average over the embedding dimension and then produce \(D\in R^{T_{1}\times S_{l}}\), which gives dissimilarity scores for each teacher-student layer pair. For calculating the dissimilarity, we experiment with Euclidean and cosine distance, but Euclidean distance generally tends to perform better. The dissimilarity score for a layer pair \((i,j)\) can be represented as:
\[D_{ij}=||(T_{i}P_{t}-S_{j}P_{s})P\frac{\mathds{1}_{d_{a}}}{d_{a}}||_{2}^{2} \tag{4}\]
where \(\mathds{1}_{d_{a}}\) is a vector of \(1\)s in \(R^{d_{a}}\).
#### 3.2.3 Final Loss Calculation
To produce the final loss matrix, we element-wise multiply \(A\) and \(D\) and then take the row-wise mean to produce a single number that represents the ABKD loss.
\[L_{abkd}=(\mathds{1}_{T_{l}})^{T}(A\odot D)(\frac{\mathds{1}_{S_{l}}}{S_{l}}) \tag{5}\]
The final loss is calculated as
\[L=H(s_{p},y)+\beta L_{abkd} \tag{6}\]
There is one important theorem to consider that proves \(L_{abkd}\) distills valuable knowledge from the teacher network to the student network.
**Theorem 1:** Consider a teacher layer \(i\) and a student layer \(j\) such that \(j<i\). Consider the weight \(W_{j}^{s}\) which is the associated weight for the \(j^{th}\) layer of the student network. The weight update for \(W_{j}^{s}\) will be affected by \(W_{i}^{t}\), which are the weights for the \(i^{th}\) layer of the teacher network.
**Proof:** To calculate the weight update, we have to first formulate a loss for the layer pair \((i,j)\). By adapting equation 5 to a specific element in the loss matrix, we get:
\[L_{ij} \sim(\frac{\mathds{1}_{n}}{n})^{T}(T_{i}^{p}(W_{j}^{ps})^{T})(W_{ j}^{s})^{T}((H_{j-1}^{s})^{T}\hat{A}^{T}))\frac{\mathds{1}_{n}}{n}*D_{ij}\] \[T_{i}^{p} =\hat{A}H_{i-1}^{t}W_{i}^{t}W_{i}^{pt}\]
where \(W_{i}^{pt}\) and \(W_{j}^{ps}\) represent the projection matrices used to calculate the attention score.
Assuming that our weight updates are performed by gradient descent, to calculate the weight update for \(W_{j}^{s}\) due to \(L_{ij}\), we have to first calculate \(\frac{\partial L_{ij}}{\partial W_{j}^{s}}\in R^{d_{a}\times d_{s}}\):
\[\frac{\partial L_{ij}}{\partial W_{j}^{s}}=\frac{\partial A_{ij}}{W_{j}^{s}}D_{ ij}+\frac{\partial D_{ij}}{W_{j}^{s}}A_{ij} \tag{7}\]
We focus on the first term and obtain the result:
\[\frac{\partial A_{ij}}{\partial W_{j}^{s}}\sim((H_{j-1}^{s})^{T}\hat{A}^{T}( \frac{\mathds{1}_{n}}{n}))((\frac{\mathds{1}_{n}}{n})^{T}T_{i}^{p}(W_{j}^{ps})^ {T}) \tag{8}\]
It is apparent that as \(\frac{\partial A_{ij}}{\partial W_{j}^{s}}\) contains the term \(T_{i}^{p}=\hat{A}H_{i-1}^{t}W_{i}^{t}W_{i}^{pt}\), the weight update will reflect terms from the \(i^{th}\) teacher layer. This theorem goes to show that even though student layer \(j\) is responsible for aggregating information for every node from its \(j\)-hop neighborhood, its weights
collect knowledge from teacher layer \(i\) - knowledge that would be unavailable to student layer \(j\) using any of the other GNN KD approaches.
An important follow-up observation is that the loss for a teacher-student layer pair will be higher if the pair is deemed as more important and if their projected feature maps have a high dissimilarity score (\(D_{ij}>0.5\)), which indicates that they aren't closely aligned.
To verify this observation, consider an arbitrary teacher layer \(i\) and an arbitrary student layer \(j\). Consider \(A_{ij}\). If the pair \((i,j)\) is deemed important, \(A_{ij}\) will be high. Now consider \(D_{ij}\). If the pair \((i,j)\) is not closely aligned, then \(D_{ij}\) will be high. As \(L_{ij}=A_{ij}*D_{ij}\), if both \(A_{ij}\) and \(D_{ij}\) are high, then \(L_{ij}\) will also be high, hence proving that the loss is high for important but misaligned layer pairs.
tion, our results empirically prove that ABKD can train student models that generalize better than other KD approaches.
**ABKD aligns intermediate embeddings**: To empirically prove that ABKD actually aligns intermediate embeddings based on the attention matrix, we visualize the before and after training attention and dissimilarity maps in figure 4. We train on OGBN-Mag and use a deeper teacher network of 5 layers and a hidden dimension of 512. The student network has 3 layers and a hidden dimension of 32. Our results show that dissimilarity scores are low where the attention scores are high and vice versa. This is in line with the intuition that we constructed in 3.2.3.
**Deep GNNs**: We also test ABKD on deep GNN architectures. While most GNN architectures are shallow due to the problem of over-smoothing, there are some approaches that alleviate this issue, allowing for deep GNN architectures. One of these approaches is GCNII (Chen et al., 2020). We test on Cora (Mccallum et al., 2000), Citeseer (Sen et al., 2008), Pubmed (Namata et al., 2012) and
Figure 4: Attention and Dissimilarity maps before and after training with ABKD. Cooler colors refer to lower scores and warmer colors correspond to higher scores.
\begin{table}
\begin{tabular}{c|c c c c} \hline \hline
**Dataset** & **Cora** & **Citeseer** & **Pubmed** & **NELL** \\
**Teacher** & GCNII (64L-64H) & GCNII (64L-64H) & GCNII (64L-64H) & GCNII (64L-64H) \\
**Student** & GCNII (4L-4H) & GCNII (4L-4H) & GCNII (4L-4H) & GCNII (4L-4H) \\ \hline Teacher & \(88.40\) & \(77.33\) & \(89.78\) & \(95.55\) \\ Student & \(74.22\pm 1.32\) & \(68.14\pm 1.45\) & \(88.66\pm 0.87\) & \(85.20\pm 0.75\) \\ LSP & \(75.18\pm 1.45\) & \(70.43\pm 1.32\) & \(89.01\pm 1.73\) & \(85.20\pm 1.32\) \\ GSP & \(78.32\pm 1.21\) & \(69.43\pm 0.87\) & \(89.13\pm 1.05\) & \(86.13\pm 1.47\) \\ G-CRD & \(83.35\pm 1.32\) & \(71.42\pm 1.21\) & \(89.73\pm 1.05\) & \(88.61\pm 1.01\) \\ ABKD & \(\mathbf{84.27\pm 1.48}\) & \(\mathbf{71.96\pm 0.87}\) & \(\mathbf{89.87\pm 0.45}\) & \(\mathbf{91.83\pm 0.74}\) \\ \# Parameters & \(5835\) & \(14910\) & \(2083\) & \(22686\) \\ Ratio & \(60.7\times\) & \(33.5\times\) & \(141.3\times\) & \(27.7\times\) \\ \hline \hline \end{tabular}
\end{table}
Table 3: Average accuracies over several trials for a variety of datasets, using GCNII. The results are based on the average of five trials, with each distillation method applied to the same set of student weights.
NELL (Carlson et al., 2010). Table 3 shows that ABKD is able to distill these deep GCNIIs into shallower GCNIIs with higher accuracy compared to other distillation methods in high compression settings. While currently, most GNN use cases require shallow GNNs, this could be useful for future applications that require deeper GNNs.
**Improved Weight Initialization for Highly Compressed Networks**: We find that for smaller datasets, information from the teacher network is mainly distilled into one layer of the student network, as shown in Figure 5. Our hypothesis for this occurrence is that smaller datasets are not very complex and one layer is sufficient for learning most of the patterns. Through experimentation, we prove that when we initialize a one-layer network from the weights of this particular layer, we get improved accuracy compared to random initialization, as shown in Table 4.
### Ablation Studies
**Aligning Intermediate Layers is Important**: To prove that the aligning of intermediate layers is necessary for superior performance, we experiment with a variant of ABKD, which we call modified ABKD, where we set \(A\in R^{T_{1}\times S_{1}}\) to all zeros, but we set the bottom right value to 1. This indicates that we are only interested in the dissimilarity between the last layer node embeddings of the teacher and student models. The results in table 5, prove that we gain accuracy by considering the outputs of intermediate layers for both teacher and student models. In this experiment, we start from the same set of initialized weights for both the ABKD and modified ABKD approaches.
**Improvements due to Subspace Projection**: In our approach, we introduced the concept of subspace projection as an alleviation to high dimensional embedding spaces. While it is not needed for ABKD to work, it does improve our results as the learned subspace projection matrix tends to be of lower rank than the embedding dimension. This indicates that we can project our feature maps into subspaces smaller than \(R^{d_{a}}\), which increases the semantic value of the dissimilarity scores.
**One Linear Layer Per Hidden Layer Is Necessary**: In our approach, we mention that each hidden teacher and student layer is assigned its own linear layer for projection into \(d_{a}\). This is because each
\begin{table}
\begin{tabular}{c c c c} \hline \hline Dataset & Initialized & Random Init & No Training \\ \hline Cora & \(80.29\) & \(73.58\) & \(65.36\) \\ Citeseer & \(70.12\) & \(68.12\) & \(54.20\) \\ Pubmed & \(88.76\) & \(86.03\) & \(72.90\) \\ \hline \hline \end{tabular}
\end{table}
Table 4: Results for weight initialization experiment. Experimental details can be found in the appendix.
Figure 5: Attention maps for Cora, Citeseer, and Pubmed. Each color in the heatmap represents the importance score associated with that teacher-student layer pair. Warmer colors mean higher important scores. It seems apparent that most of the knowledge from the teacher layers is distilled into one student layer.
\begin{table}
\begin{tabular}{c c c c} \hline \hline Dataset & Original-Mag & OGBN-Arxiv \\ \hline Student & \(44.46\pm 0.54\) & \(71.27\pm 0.48\) \\ ABKD & \(\mathbf{47.46\pm 0.45}\) & \(\mathbf{73.18\pm 0.56}\) \\ Modified ABKD & \(46.56\pm 0.60\) & \(71.89\pm 0.87\) \\ \hline \hline \end{tabular}
\end{table}
Table 5: Ablation study comparing modified ABKD that only considers aligning the last layer node embeddings with ABKD that considers intermediate layer node embeddings. The teacher and student models are the same as the ones in Table 2.
layer represents its own \(k\)-hop neighborhood, and using just one linear layer would prove inadequate in capturing the full spectrum of essential semantic information contained within each layer. We run an experiment in which we use only one linear layer for the teacher and student projections and demonstrate that there is a significant accuracy dropoff compared to using individual linear layers for the projection.
## 5 Conclusion
Graph Neural Networks (GNNs) have increased in complexity in recent years, owing to the rapidly increasing size of graph datasets. This increase in complexity poses a problem for latency-sensitive applications such as real-time recommendation and real-time spam detection, as GNN model sizes do not scale well with latency. To address this predicament, we propose an innovative solution known as Attention-Based Knowledge Distillation (ABKD). ABKD employs an attention-based feature linking mechanism to identify important intermediate teacher-student layer pairs and focuses on aligning the node embeddings of those pairs. This knowledge distillation approach broadly outperforms SOTA GNN-specific KD approaches over a wide variety of compression settings. It also works with both deep and shallow networks as proven by our experiments and performs well with several different types of GNN architectures. On average, we achieve a \(1.79\%\) increase in accuracy with a \(32.3\times\) compression ratio on OGBN-Mag, a large graph dataset, compared to state-of-the-art approaches.
\begin{table}
\begin{tabular}{r c c} \hline \hline Dataset & Subspace Projection & No Projection \\ \hline Cora & \(84.27\pm 1.32\) & \(83.78\pm 1.25\) \\ Citeseer & \(71.96\pm 0.83\) & \(71.46\pm 1.21\) \\ Pubmed & \(89.87\pm 0.87\) & \(89.03\pm 1.04\) \\ NELL & \(91.83\pm 0.85\) & \(90.98\pm 0.75\) \\ OGBN-Mag & \(47.21\pm 0.32\) & \(46.83\pm 0.45\) \\ OGBN-Arxiv & \(73.25\pm 0.56\) & \(72.87\pm 0.34\) \\ \hline \hline \end{tabular}
\begin{tabular}{r c} \hline Dataset & Multiple Linear Layers & One Linear Layer \\ \hline Cora & \(84.27\pm 1.48\) & \(75.52\pm 1.32\) \\ Citeseer & \(71.96\pm 0.87\) & \(68.86\pm 1.27\) \\ Pubmed & \(89.87\pm 0.45\) & \(88.75\pm 0.64\) \\ NELL & \(91.83\pm 0.74\) & \(85.38\pm 0.68\) \\ OGBN-Mag & \(47.21\pm 0.32\) & \(44.67\pm 0.54\) \\ OGBN-Arxiv & \(73.25\pm 0.56\) & \(71.23\pm 0.47\) \\ \hline \hline \end{tabular}
\end{table}
Table 6: Subspace Projection Ablation Results. The teacher and student networks are the same as the ones described in tables 2 and 3.
\begin{table}
\begin{tabular}{r c c} \hline \hline Dataset & Multiple Linear Layers & One Linear Layer \\ \hline Cora & \(84.27\pm 1.48\) & \(75.52\pm 1.32\) \\ Citeseer & \(71.96\pm 0.87\) & \(68.86\pm 1.27\) \\ Pubmed & \(89.87\pm 0.45\) & \(88.75\pm 0.64\) \\ NELL & \(91.83\pm 0.74\) & \(85.38\pm 0.68\) \\ OGBN-Mag & \(47.21\pm 0.32\) & \(44.67\pm 0.54\) \\ OGBN-Arxiv & \(73.25\pm 0.56\) & \(71.23\pm 0.47\) \\ \hline \hline \end{tabular}
\end{table}
Table 7: Linear Layer Ablation Results. The teacher and student networks are the same as the ones described in tables 2 and 3. |
2302.01584 | TT-TFHE: a Torus Fully Homomorphic Encryption-Friendly Neural Network
Architecture | This paper presents TT-TFHE, a deep neural network Fully Homomorphic
Encryption (FHE) framework that effectively scales Torus FHE (TFHE) usage to
tabular and image datasets using a recent family of convolutional neural
networks called Truth-Table Neural Networks (TTnet). The proposed framework
provides an easy-to-implement, automated TTnet-based design toolbox with an
underlying (python-based) open-source Concrete implementation (CPU-based and
implementing lookup tables) for inference over encrypted data. Experimental
evaluation shows that TT-TFHE greatly outperforms in terms of time and accuracy
all Homomorphic Encryption (HE) set-ups on three tabular datasets, all other
features being equal. On image datasets such as MNIST and CIFAR-10, we show
that TT-TFHE consistently and largely outperforms other TFHE set-ups and is
competitive against other HE variants such as BFV or CKKS (while maintaining
the same level of 128-bit encryption security guarantees). In addition, our
solutions present a very low memory footprint (down to dozens of MBs for
MNIST), which is in sharp contrast with other HE set-ups that typically require
tens to hundreds of GBs of memory per user (in addition to their communication
overheads). This is the first work presenting a fully practical solution of
private inference (i.e. a few seconds for inference time and a few dozens MBs
of memory) on both tabular datasets and MNIST, that can easily scale to
multiple threads and users on server side. | Adrien Benamira, Tristan Guérand, Thomas Peyrin, Sayandeep Saha | 2023-02-03T07:32:23Z | http://arxiv.org/abs/2302.01584v1 | # TT-TFE: a Torus Fully Homomorphic Encryption-Friendly Neural Network Architecture
###### Abstract
This paper presents TT-TFHE, a deep neural network Fully Homomorphic Encryption (FHE) framework that effectively scales Torus FHE (TFHE) usage to tabular and image datasets using a recent family of convolutional neural networks called Truth-Table Neural Networks (TTnet). The proposed framework provides an easy-to-implement, automated TTnet-based design toolbox with an underlying (python-based) open-source Concrete implementation (CPU-based and implementing lookup tables) for inference over encrypted data. Experimental evaluation shows that TT-TFHE greatly outperforms in terms of time and accuracy all Homomorphic Encryption (HE) set-ups on three tabular datasets, all other features being equal. On image datasets such as MNIST and CIFAR-10, we show that TT-TFHE consistently and largely outperforms other TFHE set-ups and is competitive against other HE variants such as BFV or CKKS (while maintaining the same level of 128-bit encryption security guarantees). In addition, our solutions present a very low memory footprint (down to dozens of MBs for MNIST), which is in sharp contrast with other HE set-ups that typically require tens to hundreds of GBs of memory per user (in addition to their communication overheads). This is the first work presenting a fully practical solution of private inference (i.e. a few seconds for inference time and a few dozens MBs of memory) on both tabular datasets and MNIST, that can easily scale to multiple threads and users on server side.
Machine Learning, ICML
## 1 Introduction
Deep Neural Networks (DNNs) have achieved remarkable results in various fields, including image recognition, natural language processing or medical diagnostics. "Machine Learning as a Service" (MLaaS) is a recent and popular DNN-based business use-case (Philipp et al., 2020; Li et al., 2017; Ribeiro et al., 2015), where clients pay for predictions from a service provider. However, this approach requires trust between the client and the service provider. In cases where the data is sensitive, such as military, financial, or health information, clients may be hesitant (or are simply not allowed) to share their data with the service provider for privacy reasons. On the service provider's side, training DNNs requires large amounts of data, technical expertise, and computer resources, which can be expensive and time-consuming. As a result, service providers may hesitate to give the model directly to the client, as it may be easily reverse-engineered (or at least make the attacker's task much easier), hindering the growth of MLaaS activity. Allowing the clients to perform the inference locally is also not very practical as any model update would have to be pushed to all clients, not to mention the complex support of the various client hardware/software configurations, etc.
HE/FHE (Gentry, 2009) is an ideal technology to address Privacy-Preserving in Machine Learning (PPML) as it allows the computations to be performed directly on encrypted data. By encrypting its data before sharing it with the service provider, the client ensures that it remains private while the service provider can still provide accurate predictions. This solves the trust issue and also gives a competitive advantage in regions where data regulations are stricter, such as Europe's General Data Protection Regulation (GDPR) (Regulation, 2016). The most popular HE schemes are BGV/BFV (Brakerski et al., 2014; Brakerski, 2012; Fan and Vercauteren, 2012), CKKS (Cheon et al., 2017) and Torus-FHE (TFHE) (Chillotti et al., 2016, 2020) and this paper presents our proposed solution that utilizes TFHE to provide a privacy-preserving MLaaS framework for DNNs. TFHE enables very fast gate
bootstrapping as well as circuit bootstrapping and operations over Boolean gates. Moreover, extended versions of TFHE, such as Concrete (Chillotti et al., 2020) allows programmable bootstrapping enabling evaluation of certain functions during the bootstrapping step itself.
The security and flexibility provided by HE come at a cost, as the computation, communication, and memory overheads are significant, especially for complex functions such as DNNs:
* Time overhead: on server side, an FHE logic gate computation within a TFHE scheme takes milliseconds (Chillotti et al., 2016), compared to nanoseconds for a standard logic gate. On client side the overhead for encryption/decryption of the data is usually not an issue, as milliseconds are enough for those operations.
* Communication overhead: an MNIST image sent in clear represents a few kBs, while encrypted within any HE scheme it is of the order of a few MBs (excluding the public key which typically requires hundred(s) of MBs) (Clet et al., 2021). Moreover, PPML schemes not based on TFHE, such as those based on CKKS, require a significant communication overhead due to the need for multiple exchanges between the client and the cloud (Clet et al., 2021).
* Memory overhead: TFHE-based schemes typically require a few of MBs of RAM on server side, while those based on CKKS need several GBs per image (Gilad-Bachrach et al., 2016; Brutzkus et al., 2019), even up to hundreds of GBs for the most time-efficient solutions (Lee et al., 2022) (384GB of RAM usage to infer a single CIFAR-10 image using ResNet).
* Technical difficulties and associated portability issues: mastering an HE/FHE framework requires highly technical and rare expertise.
These challenges can be approached from different directions, but only a few works have considered designing DNNs models that are compatible/efficient with state-of-the-art HE frameworks in a flexible and portable manner. This paper focuses on the integration of the recent FHE scheme, Torus-FHE (TFHE), with DNNs.
Our contributions.To address the above issue, we propose a DNN design framework called TT-TFHE that effectively scales TFHE usage to tabular and large datasets using a new family of Convolutional Neural Networks (CNNs) called Truth-Table Neural Networks (TTnet). Our proposed framework provides an easy-to-implement, automated TTnet-based design toolbox that utilizes the Pytorch and Concrete (python-based) open-source libraries for state-of-the-art deployment of DNN models on CPU, leading to fast and accurate inference over encrypted data. The TTnet architecture, being lightweight and differentiable, allows for the implementation of CNNs with direct expressions as truth tables, making it easy to use in conjunction with the TFHE open-source library (specifically the Concrete implementation) for automated operation on lookup tables. Therefore, in this paper, we try to tackle the TFHE efficiency overhead as well as the technical/portability issue.
Our experimental results.Evaluation on three tabular datasets (Cancer, Diabetes, Adult) shows that our proposed TT-TFHE framework outperforms in terms of accuracy (by up to +3%) and time (by a factor 7x to 1200x) any state-of-the-art DNN & HE set-up. For all these datasets, our inference time runs in a few seconds, with very small memory and communication requirements, enabling for the first time a fully practical deployment in industrial/real-world scenarios, where tabular datasets are prevalent (Cartella et al., 2021; Buczak & Guven, 2015; Clements et al., 2020; Ulmer et al., 2020; Evans, 2009).
For MNIST and CIFAR-10 image benchmarks, we further explore an approach for private inference proposed by LoLa (Brutzkus et al., 2019), in which the user/client side is able to compute a first layer and send the encrypted results to the cloud. In this real-world scenario, the user/client performs the computation of a standard public layer (such as the first block of the open-source VGG16 model) and sends the encrypted results to the cloud for further computation using HE. Through experimental evaluation, we demonstrate that our proposed framework greatly outperforms all previous TFHE set-ups (Sanyal et al., 2018; Fu et al., 2021; Chillotti et al., 2021) in terms of inference time. Specifically, we show that TT-TFHE can infer one MNIST image in 7 seconds with an accuracy of 98.1% or one CIFAR-10 image in 570 seconds with an accuracy of 74%, which is from one to several orders of magnitude faster than previous TFHE schemes, and even comparable to the fastest state-of-the-art HE set-ups (that do not benefit from the TFHE advantages) while maintaining the same 128-bit security level.
Our solutions represent a significant step towards practical privacy-preserving inference, as they offer fast inference with limited requirements in terms of memory on server side (only a few MBs, in contrary to other non-TFHE-based schemes), and thus can easily be scaled to multiple users. In addition, they benefit from lower communication overhead. In other words, this is the first work presenting a fully practical solution
of private inference (_i.e._ a few seconds for inference time and a few MBs of memory/communication) on both tabular datasets and MNIST.
Outline.In Section 2, we present related works in the field of HE and HE-friendly neural networks. In Section 3, we introduce our proposed TT-TFHE framework, while in Section 4 we provide an evaluation of the performance of our framework on various datasets and various privacy settings. Finally, in Section 5, we discuss the limitations of the proposed framework and present our conclusions.
## 2 Related Works
A lot of interest has been observed in PPML in the recent past, especially for implementing DNNs. Most of these efforts assume that the (unencrypted) model is deployed in the cloud, and the encrypted inputs are sent from the client side for processing. Inference timing of HE-enabled DNN models is the key parameter, but other factors, such as ease of automation and simplicity of such transformation have also attracted some attention (Boemer et al., 2019; Dathathri et al., 2019; Carpov et al., 2015).
Broadly, the problem can be approached from four complementary directions: 1) Optimizing the implementation of some DNN building blocks, such as the activation layers, using HE operations (Jovanovic et al., 2022; Lee et al., 2022); 2) Parallelizing the computation and batching of images (Gilad-Bachrach et al., 2016; Chou et al., 2018; Brutzkus et al., 2019) (this is aided by the ring encoding of HE in certain cases). Such efforts also include implementing a hybrid client-server protocol for computation (Juvekar et al., 2018; Mishra et al., 2020); 3) Optimizing the underlying HE operations (Chillotti et al., 2016, 2021; Ducas and Micciancio, 2015); 4) Designing a HE-friendly DNN (Sanyal et al., 2018; Lou and Jiang, 2019; Fu et al., 2021). This fourth category has been relatively less explored and is the main focus of this work.
To the best of our knowledge, the FHE-DiNN paper (Bourse et al., 2018) was the first to propose a quantified DNN to facilitate FHE operations. Then, the TAPAS framework (Sanyal et al., 2018) pushed this strategy further by identifying Binary Neural Networks (BNNs) as effective DNN modeling techniques for HE-enabled inference. This direction has been enhanced later by GateNet (Fu et al., 2021), which optimizes the BNN models by grouping the channels to reduce the number of gates.
Yet, none of these works actually explored the automation perspectives for optimizing a model itself for HE inference, as they still heavily leverage some manual optimizations concerning the underlying FHE library. TT-TFHE, however, is fully automated. Moreover, compared to previously proposed automated approaches, the translation from non-HE model to HE-enabled model is much simpler as all optimizations are handled during the design phase of the model, making TT-TFHE much more amenable for typical machine learning experts with little knowledge of FHE.
## 3 Tt-TFHE Framework
### Threat model
PPML methods are designed to protect against a variety of adversaries, including malicious insiders and external attackers who may have access to the neural network's inputs, outputs, or internal parameters. The level of secrecy required depends on the specific application and the potential impact of a successful attack. Common secrecy goals include protecting the input to the inference, ensuring that only authorized parties know the result of the inference, and keeping the weights and biases of the neural network secret from unauthorized parties. Some PPML approaches also aim to keep the architecture of the neural network confidential from unauthorized parties. However, most PPML methods do not address this last point, and some interactive approaches assume that the architecture of the neural network is known to all parties. Moreover, attacks on MLaaS settings exist and are very tricky to defend against (Tramer et al., 2016; Juuti et al., 2019). Thus, in this paper, we assume that an attacker can access the neural network and only the client's data privacy matters.
### Fhe general set-up
In this paper, the client \(\mathcal{C}\) will encrypt its data locally and send it along with its public key to the server \(\mathcal{S}\) (there is no need to send it again once it is pre-shared). The server will compute its algorithm on the encrypted data and send the encrypted result to \(\mathcal{C}\), who will decrypt its result locally. The server will have no access to the data in clear.
The classical configuration is that the entire model is computed privately on server side and we call this configuration Fully Private (Full-Pr). However, as it is anyway quite hard to defend against model weight-stealing attacks (our threat model does not include model privacy) and as already proposed by the LoLa team (Brutzkus et al., 2019), we also consider situations where the client can perform some local pre-processing (_i.e._ a first layer or block of the neural
network) to speed up the server computation without compromising its data security. This setting helps the user to perform its inference faster than in a Full-Pr situation with little memory cost on their side. Such pre-computation would usually be from a public architecture such as VGG, AlexNet or a ResNet(Simonyan and Zisserman, 2014; Krizhevsky et al., 2017; He et al., 2016) which are fully available online. In our case, this layer will then typically be followed by a Tnet model and a linear regression that will be computed through FHE on server side. This is a common approach in deep learning, where most models are fine-tuned from one of these three, or with fixed first layers followed by a shallow network.
We will denote \(N_{1}/N_{2}\) a configuration where the client performs the computation of the neural network \(N_{1}\) locally and the remaining part \(N_{2}\) is performed privately on server side. The final linear regression after \(N_{2}\) is always performed privately on server side, but some of the last few computations can be done by the client (for example a part of the sum and the final \(ArgMax\)(Podschwadt et al., 2022)). The general setup \(N_{1}/\texttt{TT}\) (where the part performed on server is a Tnet) is depicted in Figure 1. \(\emptyset\)/TT will represent one extreme case where the entire Tnet neural network is performed privately (Full-Pr) and \(N/\emptyset\) will represent the other extreme case where the entire neural network \(N\) is performed on client side, except the final linear regression. We will denote VGG\({}_{1L}\) the first layer of VGG16 (the first convolution), and VGG\({}_{1B}\) its first block (the first two convolutions and the pooling layer afterwards).
### Truth-table DCNN (TInet)
Truth Table Deep Convolutional Neural Networks (TInet) were proposed in (Benamira et al., 2022) as DCNNs convertible into truth tables by design, with security applications (a companion video is provided by the authors [https://youtu.be/loGlpVcy0AI](https://youtu.be/loGlpVcy0AI)). While recent developments in DNN architecture have focused on improving performance, the resulting models have become increasingly complex and difficult to verify, interpret and implement. Thus, the authors focused on CNNs, which are widely used in the field, and tried to transform them into tractable Boolean functions. A depiction of the general architecture of TInet can be found in Figure 3 of Appendix A.
**CNN filter as a tractable Boolean function.** Their proposed method converts CNN filters into binary truth tables by 1) decreasing the input size (noted as \(n\) in the rest of the paper) which reduces the complexity of the CNN filter function, 2) using the Heaviside step function denoted as \(bin_{act}=(1+sgn(x))/2\) to transform the inputs and outputs into binary values. This results in a tractable Boolean function (for \(n\) not too large) that can be stored as a truth table, as seen in Figure 2a. To achieve high accuracy, the CNN filter must also be non-linear before the step function. Then, the CNN filter becomes a tractable non-linear truth table, which is referred to as a Learning Truth Table (LTT) block.
**Description of an LTT block.** Among all the families of LTT blocks possible - we represent in Figure 2b an Expanding Auto-Encoder LTT block (E-AE LTT). An E-AE LTT block is composed of two layers of grouped CNN with an expanding factor. Figure 2a
Figure 1: The \(N_{1}/\texttt{TT}\) setting. The client computes locally a layer \(N_{1}\), encrypts the obtained output, and sends it to the server/cloud with the public key (which can be pre-shared). The server will compute through FHE the TInet layer with the linear regression and send the result to the client. The client can decrypt this output and make a few last computations to obtain the result of the inference. When \(N_{1}\) is identity (\(\emptyset\)/TT or more generally \(\emptyset/N_{2}\) for some neural network \(N_{2}\)), we denote the setting as Fully Private (Full-Pr).
shows a computation of E-AE 1D LTT block. We can observe that the input size is small (\(n=6\)), the input/output values are binary and SeLU is an activation function. Note that the inputs are binary but the weights and the intermediate values are real. We integrated LTT blocks into \(\mathcal{T}\mathcal{T}\)net as CNN filters are integrated into DCNNs: each LTT layer is composed of multiple LTT blocks and there are multiple LTT layers in total.
### Challenges and optimizations for integrating TTnet with TFHE-Concrete
The Concrete library (Chillotti et al., 2020) is a software implementation of TFHE. It is designed to provide a highly efficient and secure platform for performing mathematical operations on Boolean encrypted data. The library utilizes automated operations on lookup tables (concrete-numpy) to achieve high performance while maintaining a high level of security. The library is also designed to be very user-friendly, with simple and intuitive interfaces for performing encryption and decryption operations. The Concrete library has been shown to provide significant improvements in terms of memory and communication overheads compared to other HE schemes. Furthermore, it is open source, which allows researchers and practitioners to easily integrate it into their projects and benefit from its advanced features.
The use of TTnet architecture in combination with TFHE (and more specifically with Concrete) naturally provides a number of advantages. Firstly, the lightweight and differentiable nature of TTnet allows for the implementation of CNNs with direct expressions as truth tables, which is well-suited for Concrete. Additionally, the reduced complexity of the TTnet architecture leads to reduced computations and good scalability. Yet, the integration of TTnet into the TFHE framework presents several challenges that need to be addressed in order to achieve high performance. We detail below the constraints imposed by FHE libraries and the optimizations implemented to overcome these limitations and achieve state-of-the-art performance on various datasets.
Constraints imposed by Concrete.The Concrete implementation of the TFHE library, which utilizes automated operations on lookup tables, imposes a maximum limit of 16 on the input bit size \(n\) of the truth table. However, \(n\) has a strong impact on efficiency (cf Appendix B) and our tests show that \(n=4\) or \(n=6\) seem to offer the best trade-offs. Indeed, since we learn kernels of convolutional layers of size \((3,2)\) or \((2,3)\), it is convenient to use \(n\) a multiple of 2 and/or 3. Moreover, input sizes larger than \(n=8\) lead to a prohibitive average time per call.
Concrete proposes a built-in linear regression feature, but we tested that it performs not as well as an ad-hoc linear regression with multiplications and additions.
Finally, a very important limitation is that Concrete does not support multi-precision table lookups: the call time of each table lookup (even the small ones)
Figure 2: A Learning Truth Table (LTT) block. The intermediate values and weights are floating points, input/output values are binary.
will be equal to the call time of the largest bitwidth operations in the whole circuit. For example, if one of the computations operates on 16 bits, all lookup tables, even small, will require the call time of a 16-bit table lookup. This can be problematic when handling the final linear regression as we will have to sum many Boolean values and the sum result bitwidth might be larger than our planned table lookup size, therefore slowing down our entire implementation. If the sum result of our linear regression requires 16 bits, all our 4-bit lookup tables call time will be on par with 16-bit table lookups, going from 75ms to almost 5s per call. For now, the computation time is too slow for results that require a sum on more than 4 bits. To overcome this limitation, we implemented several optimizations to improve the accuracy of the model, particularly for image datasets (see below).
Limitations imposed by TInet.The original TInet paper proposed a training method that is not suitable for high accuracy performance as it was trained to resist PGD attacks (Madry et al., 2017), which reduces accuracy. Additionally, the pre-processing and final sparse layers in TInet being binary, this also leads to a significant decrease in accuracy. To address these limitations, we replace the final sparse binary linear regression with a linear layer with floating point weights (later quantified on 4 bits not to deteriorate too much the performances on Concrete) and propose a new training method that emphasizes accuracy (see below). We also propose to use a setting \(N_{1}/\texttt{TT}\), where a first layer \(N_{1}\) (a layer or block of a general open-source model) is applied to overcome the loss of information due to the first binarization. This is for example a standard method used in BNNs.
Training optimizations.To improve the accuracy of our model, we took several steps to optimize the training process. First, we removed the use of PGD attacks during training, as they have been shown to reduce accuracy. Next, we employed the DoReFa-Net method (Zhou et al., 2016) for CIFAR-10, a technique for training convolutional neural networks with low-bitwidth activations and gradients. Finally, to overcome the limitations of the TInet grouping method, we extended the training to 500 epochs, resulting in a more accurate model.
Architectural optimizations.For tabular datasets, the straightforward enhancements proposed in the previous sections are sufficient to achieve high accuracy. However, this is not the case for image datasets such as MNIST, CIFAR-10, and ImageNet. Therefore, we modify the general architecture of our model. Specifically, we use an architecture similar to the one presented for ImageNet in the original TInet paper. The limitation of our model is that it can see far in the spatial dimension but has limited representation in the channel dimension. To balance this property, we use three techniques: multi-headers, residual connections (He et al., 2016), and channel shuffling (Zhang et al., 2018). We have a single layer composed of four different functions in parallel: one LTT block with a kernel size of (3,2) and group 1 (to see far in space and low in channel), one LTT block with a kernel size of (2,3) and group 1, one LTT block with a kernel size of 1 and 6 groups (to see low in space but high in channel representation), and an identity function (as a residual connection for stability). We tried with a second layer to increase accuracy, but with the current version of Concrete (without the support of multi-precision table lookups), this led to sub-optimal performance/accuracy trade-offs with a drastic increase in FHE inference time.
Client server usage as optimizations.We describe here a solution to the issue of Concrete not supporting the results of linear regression that would be on more than 4 bits: we utilize the client's computing resources not only to prepare the input to the server, but also to post-process the server's output. Namely, the client will compute a small part of the final linear regression. Indeed, we quantify the weights of the final linear regression of TInet to 4 bits, which we divide into 4 binary matrices. Then, the server performs partial sums on each of these 4 matrices. Since the outputs of TInet are binary, the weights are binary, and the maximum number input bitwidth for our lookup tables is 4 bits. For optimal performance, we perform sub-sums of size 16 to ensure that the result of each sub-sum is always lesser than \(2^{4}\) as proposed by Zama's team1. It is important to note that by doing this, we maintain the privacy of the weights of the linear regression as they remain unknown to the client. Additionally, the function computation by the client is very light, for example in the case of the MNIST dataset in the VGG\({}_{1B}/\texttt{TT}\) setting, it will represent at most \(\frac{N_{\texttt{features}}}{N_{\texttt{bits}}}=\frac{576}{16}=12\) sums of 4-bit integers to be performed for each 4 weight matrices. The client will eventually add these four outputs to obtain its final result, _i.e._ computing \(\sum_{i=0}^{3}2^{i}*w_{i}*\text{output}_{i}\). Also, note that this client computation is fixed and will remain the same even if the model needs to be updated. Finally, this limitation is due to Concrete and likely temporary as Concrete identified lookup tables multi-precision as an "important feature to come"2.
Footnote 1: [https://community.zama.ai/t/load-model-complex-circuit/369/4](https://community.zama.ai/t/load-model-complex-circuit/369/4)
Footnote 2: [https://community.zama.ai/t/load-model-complex-circuit/369/4](https://community.zama.ai/t/load-model-complex-circuit/369/4)
Patching optimizations.Due to its highly decoupled nature, our model performance is dependent on the number of patches. The classification of an image can be viewed as \(N\) independent computations, where \(N\) is the number of patches of the original image. This is a unique property and is highly useful for addressing the issue of Concrete requiring a lot of RAM when compiling complex circuits, especially when one will have to scale to larger datasets. For example on MNIST, we have a patch of size (8x8x1) instead of an entire image of size (28x28x1).
## 4 Results
The project implementation was done in Python, with the PyTorch library (Paszke et al., 2019) for training, in numpy for testing in clear, and the Concrete-numpy library for FHE inference. Our workstation consists of 4 Nvidia GeForce 3090 GPUs (only for training) with 24576 MiB memory and eight cores Intel(R) Core(TM) i7-8650U CPU clocked at 1.90 GHz, 16 GB RAM. For all experiments, the CPU Turbo Boost is deactivated and the processes were limited to using four cores.
The details of all our models' architecture can be found in Appendix C.
### Tabular datasets
Our experimental results shown in Table 1 (in Table 6 of Appendix F for results normalized to a single CPU) demonstrate the superior performance of the proposed TT-TFHE framework on three tabular datasets (Cancer, Diabetes, Adult) in terms of both accuracy and computational efficiency. The framework achieved an increase in accuracy of up to \(+3\%\) compared to state-of-the-art DNN & HE set-ups based on TFHE such as TAPAS (Sanyal et al., 2018) or on CKKS such as the recent work from the ETHZ team (Jovanovic et al., 2022). More impressively, the inference time per CPU was significantly reduced by a factor 1205x, 7x, and 825x on Adult, Cancer, and Diabetes datasets respectively.
This enables the practical deployment of our framework in industrial and real-world scenarios where tabular datasets are prevalent (Cartella et al., 2021; Buczak and Guven, 2015; Clements et al., 2020; Ulmer et al., 2020; Evans, 2009), with low memory and communication overhead (see Table 5 in Appendix D). Note that these results are in the Full-Pr setting, as the binarization process in TT-TFHE does not lead to any particular issue for tabular datasets.
### Image datasets
Our experimental results and comparisons for image datasets are given in Table 2 (in Table 7 of Appendix F for all results normalized to a single CPU).
#### 4.2.1 Fully private (Full-Pr) setting
In the Full-Pr configuration, we focused on the performance of our method on the MNIST dataset, as the binarization process in TT-TFHE resulted in a significant loss of accuracy for CIFAR-10 or an increase in inference time. TT-TFHE offers a competitive trade-off compared to other TFHE-based methods, such as TAPAS (Sanyal et al., 2018), GateNet (Fu et al., 2021) or Zama (Chillotti et al., 2021). It is three orders of magnitude faster than TAPAS or GateNet, while showing only a slightly lower accuracy of \(1.4\%\). In comparison to Zama, our method is 2x faster per CPU for the same level of accuracy. Additionally, we highlight that for our single layer LTT block of size \(n=6\), we require 1600 calls to 6-bit lookup tables, which leads to an inference time of only 83 seconds on four CPU cores.
TT-TFHE is even competitive in terms of inference time with some non-TFHE-based schemes such as (Fast) CryptoNets (Gilad-Bachrach et al., 2016), but can be one order of magnitude slower with slightly lower accuracy. Therefore, one can observe that the Full-Pr setting of TFHE implemented in our framework generally underperforms compared to the very latest Full-Pr CKKS or BFV setups. This is explained by the first binarization process in TT-TFHE, which compresses too much information embedded in the input image. Yet,
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c|c|} \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**FHE**} & \multicolumn{2}{c|}{**Adult**} & \multicolumn{2}{c|}{**Cancer**} & \multicolumn{2}{c|}{**Diabetes**} \\ \cline{2-9} \multicolumn{1}{c|}{} & **family** & & & Acc. & Time & Acc. & Time & Acc. & Time \\ \hline ETHZ/CCS2 & CKKS & 64 & 81.6\% & 420s & - & - & - & - \\ \hline TAPAS & \multirow{2}{*}{THHE} & 16 & - & - & 97.1\% & 3.8\% & 54.9\% & 250s \\ \cline{2-9}
**Ours** & & 4 & 85.3\% & 5.6\% & 97.1\% & 1.8\% & 57.0\% & 1.2\% \\ \hline \end{tabular}
\end{table}
Table 1: Tabular dataset results for TT-TFHE and competitors. All results are in Full-Pr setting. All our models use a table lookup bitwidth of \(n=5\), except for Diabetes where we use \(n=6\).
\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c|c|} \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**P1-TFHE**} & \multicolumn{2}{c|}{**IFHE**} & \multicolumn{2}{c|}{**IFHE**} & \multicolumn{2}{c|}{**IFHE**} \\ \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**TFHE**} & \multicolumn{2}{c|}{**Cartella**} & \multicolumn{2}{c|}{**Ours**} & \multicolumn{2}{c|}{**Ours**} & \multicolumn{2}{c|}{**Zama**} & \multicolumn{2}{c|}{**Ours**} \\ \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**Ours**} & \multicolumn{2}{c|}{**Ours**} & \multicolumn{2}{c|}{**Zama**} & \multicolumn{2}{c|}{**Ours**} \\ \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} \\ \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} \\ \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} \\ \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} \\ \cline{2-9} \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**GFUCE**} & \multicolumn{2}{c|}{**
we again emphasize the many advantages of TFHE-based solutions compared to non-TFHE-based ones: little memory required allowing easy/efficient multiclient inference, low communication overhead, no security warning on TFHE while CKKS secret key can be recovered in polynomial time (Li & Micciancio, 2021) (a fix was proposed afterward (Li et al., 2022) but not yet implemented in SEAL for example), etc. We will see in the next sub-section that the performance situation is very different in the setting where the client can perform some pre-computation layer.
#### 4.2.2 Other settings
We first observe that when allowing the client to apply a simple pre-processing layer, the performance increases drastically for TT-TFHE. We have implemented and benchmarked both VGG\({}_{1L}\)/TT and VGG\({}_{1B}\)/TT settings, both with TTnet models with \(n=6\) and \(n=4\) and we obtained a 10x performance improvement, with an increase in accuracy. For reference, we have also tested the VGG\({}_{1B}\)/\(\emptyset\) setting where only a linear regression is computed privately on server: we remark that adding a TTnet in the server computation indeed improves accuracy by about 4%.
One could argue that more VGG blocks could be computed on client side to further increase the accuracy, but this would reduce the generality of the first layers and lead to PPML solutions that would not adapt very well to multiple use cases. We have tried blocks of other more recent CNNs than VGG, such as DenseNet(Huang et al., 2017), but the results remain very similar.
We can compare the TT-TFHE results to some TFHE-based competitors, as Zama proposed a similar setting 3 with VGG\({}_{1L}\) pre-computed by the client for CIFAR-10, and against which we infer 100x faster per CPU and with a 10% increase in accuracy.
Footnote 3: [https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/use_case_examples/cifar_10_with_model_splitting](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/use_case_examples/cifar_10_with_model_splitting)
Our TT-TFHE results are now even competitive against non-TFHE-based solutions (even though they miss many of TFHE advantages), being faster than (Fast) CryptoNets (Gilad-Bachrach et al., 2016) and SHE (Lou & Jiang, 2019), and on par with Lola (Brutzkus et al., 2019) and Lee _et. al._(Lee et al., 2022) per CPU. We note that SHE and Lee _et. al._ have better accuracy than our model.
### Memory/communication cost of TT-TFHE
In Table 5 from Appendix D, we compare the memory and communication needs for all our settings. We can observe that the deeper the representation, the smaller the communication needs: the inputs to the server become smaller as we go deeper into the neural network (there are also fewer computations to do in the server). Some settings do not need public keys as only a linear regression is done, and thus no programmable bootstrapping is involved (Chillotti et al., 2021). Then, the largest the lookup tables (in terms of the number of features and size), the larger will be the public keys as there will be more bootstrapping. Also, the optimization proposed in Section 3.4 to ease the linear regression comes with a cost: it increases the size of the outputs. Indeed, only the VGG\({}_{1B}\)/\(\emptyset\) setting does not use this optimization as there is no lookup-table involved and thus no bootstrapping. Finally, the encrypted inputs size increases with the number of features.
Comparison with other methods.As stated in (Clet et al., 2021), CKKS is more memory greedy than TFHE for communication. In Table 4 of Appendix D, we compare between each method the amount of RAM needed on server side for CIFAR-10 dataset. The best accuracy is the ResNet proposed by (Lee et al., 2022), but it also leads to the highest consumption in RAM. With LoLa setting, the accuracy is indeed lower but it requires 32x lesser RAM. Then, our method reduces again the memory on server by almost a factor of 15x for the same accuracy. RAM size on server matters for cloud computing as pricing increases along with memory needs4, thus low-memory solutions help the scalability of the MLaaS.
Footnote 4: [https://azure.microsoft.com/en-us/pricing/](https://azure.microsoft.com/en-us/pricing/)
## 5 Limitations and Conclusion
Limitations.Our proposed framework is still not as performant as the latest non-TFHE-based solutions with regard to running time and accuracy. Moreover, CIFAR-10 and larger datasets remain out of reach for industrial use. Finally, TT-TFHE is for the moment limited by the constraints of the Concrete library.
Conclusion.In this paper, we presented a new framework, TT-TFHE, which greatly outperforms all TFHE-based PPML solutions in terms of inference time, while maintaining acceptable accuracy. Our proposed framework is a practical solution for real-world applications, particularly for tabular data and small image datasets like MNIST, as it requires minimal memory/communication cost, provides strong security for the client's data, and is easy to deploy. We believe that this research will spark further investigations into the utilization of truth tables for privacy-preserving data usage, emphasized by the recently NIST Artificial Intelligence Risk Management Framework (AI, 2023). |
2307.05882 | Knowledge-Driven Resource Allocation for D2D Networks: A WMMSE Unrolled
Graph Neural Network Approach | This paper proposes an novel knowledge-driven approach for resource
allocation in device-to-device (D2D) networks using a graph neural network
(GNN) architecture. To meet the millisecond-level timeliness and scalability
required for the dynamic network environment, our proposed approach
incorporates the deep unrolling of the weighted minimum mean square error
(WMMSE) algorithm, referred to as domain knowledge, into GNN, thereby reducing
computational delay and sample complexity while adapting to various data
distributions. Specifically, the aggregation and update functions in the GNN
architecture are designed by utilizing the summation and power calculation
components of the WMMSE algorithm, which leads to improved model generalization
and interpretabiliy. Theoretical analysis of the proposed approach reveals its
capability to simplify intricate end-to-end mappings and diminish the model
exploration space, resulting in increased network expressiveness and enhanced
optimization performance. Simulation results demonstrate the robustness,
scalability, and strong performance of the proposed knowledge-driven resource
allocation approach across diverse communication topologies without retraining.
Our findings contribute to the development of efficient and scalable wireless
resource management solutions for distributed and dynamic networks with strict
latency requirements. | Hao Yang, Nan Cheng, Ruijin Sun, Wei Quan, Rong Chai, Khalid Aldubaikhy, Abdullah Alqasir, Xuemin Shen | 2023-07-12T03:06:15Z | http://arxiv.org/abs/2307.05882v1 | Knowledge-Driven Resource Allocation for D2D Networks: A WMMSE Unrolled Graph Neural Network Approach
###### Abstract
This paper proposes an novel knowledge-driven approach for resource allocation in device-to-device (D2D) networks using a graph neural network (GNN) architecture. To meet the millisecond-level timeliness and scalability required for the dynamic network environment, our proposed approach incorporates the deep unrolling of the weighted minimum mean square error (WMMSE) algorithm, referred to as domain knowledge, into GNN, thereby reducing computational delay and sample complexity while adapting to various data distributions. Specifically, the aggregation and update functions in the GNN architecture are designed by utilizing the summation and power calculation components of the WMMSE algorithm, which leads to improved model generalization and interpretability. Theoretical analysis of the proposed approach reveals its capability to simplify intricate end-to-end mappings and diminish the model exploration space, resulting in increased network expressiveness and enhanced optimization performance. Simulation results demonstrate the robustness, scalability, and strong performance of the proposed knowledge-driven resource allocation approach across diverse communication topologies without retraining. Our findings contribute to the development of efficient and scalable wireless resource management solutions for distributed and dynamic networks with strict latency requirements.
Deep unrolling, GNN, knowledge-driven resource allocation, WMMSE algorithm, wireless communication
## I Introduction
In the era of 6G, mobile communication networks are envisioned to provide a wide variety of services and applications, from data-intensive services such as extended reality (XR), reliable and low-latency services such as autonomous driving and remote surgery, to the soaring intelligent services such as metaverse and ChatGPT [1]. Furthermore, 6G networks are becoming increasingly complex and dynamic as the emergence and fast development of space-air-ground integrated networks (SAGINs) significantly enlarge the network scale and require efficient management of multi-dimensional resources [2]. The complexity poses a significant challenge to wireless network management, such as resource allocation schemes and task scheduling, to fulfill the service requirements, especially delay-sensitive and reliability services, where a fault or delayed decision may lead to fatal outcomes. Therefore, it is critical to design efficient, responsive, and scalable wireless network management schemes in 6G networks.
Wireless resource allocation plays a pivotal role in network management to allocate spatial and temporal wireless resources for certain goals, such as maximizing the transmission rate or minimizing the transmission delay or energy consumption. A plethora of model-based iterative algorithms, such as iterative water-filling type algorithms [3], WMMSE algorithms [4], and successive convex approximation algorithms [5, 6], have been proposed based on the convex optimization theory to address the wireless resource allocation problem. These algorithms have successfully solved classical resource allocation problems, commonly with small network scale and low-level network dynamics. However, as the network scale increases, the high computational complexity associated with multiple iterations of these algorithms can hardly meet the stringent milliseconds-level service requirements.
Due to the efficient real-time computational capabilities, deep learning techniques have found application in diverse areas of wireless communication systems [7], such as UAV-assisted IoT applications [8],spectrum Sharing [9], resource management [10], and mobile computing offloading [11]. Ye _et al._ employed deep neural networks (DNNs) for channel estimation and signal detection, achieving efficient handling of channel distortion [12]. He _et al._ investigated the utilization of convolutional neural network (CNN)-based architectures for channel estimation in beamspace millimeter-wave massive multiple-input-multiple-output (MIMO) systems, surpassing the most advanced compressed sensing-based algorithms. Tang and Wong utilized bidirectional long short-term memory (LSTM) in mobile edge computing systems to handle user scheduling problems in ad hoc networks, effectively minimizing the average age of information [13]. To solve the resource allocation problem for weighted sum rate maximization, multi
layer perceptrons (MLP) [14] and CNN [15] are employed to approximate the WMMSE algorithm, using outputs of algorithms as labels and reducing computational complexity. In [16], the objective function, i.e., the weighted sum rate, is regarded as the loss function, achieving better performance. These studies presented exhibit impressive performance and low inference complexity. However, applying them effectively to radio resource management for an arbitrary number of users faces a significant challenge. Commonly utilized neural networks, including DNN, CNNs, recurrent neural networks, and attention-based Transformer models, are not readily scalable for an arbitrary number of users, as their input and output dimensions must remain constant. Therefore, designing scalable neural network architectures is crucial for effectively managing wireless resources, given the dynamic fluctuations in user numbers within mobile applications.
In this context, a graph structure with expandable connecting nodes is more suitable for capturing the dynamic characteristics of wireless networks. By incorporating such graph structure into neural networks, GNNs are envisioned as a potential solution to realize scalable resource allocation [17, 18]. A random edge graph neural network (REGNN) is proposed to enhance scalability and generalization for optimal power control in interference channels [19]. Addressing the limitations of REGNN in heterogeneous agents and multi-antenna systems, the interference graph convolutional network (IGCNet) is proposed in [20]. Furthermore, a message-passing graph neural network (MPGNN) is presented for tackling large-scale wireless resource management problems, such as beamforming, user association, and channel estimation [21]. The authors established the equivalence between MPGNN and distributed optimization algorithms, showcasing its performance and generalization capabilities. While GNNs demonstrate scalability, their intrinsic learning approach primarily relies on statistical distributions with poor interpretability, leading to struggles to accommodate varying distributions and necessitating a large amount of training data for a particular distribution. In the context of radio resource management, collecting identical distribution training data is time-consuming and costly, and the dynamic nature of wireless networks causes a dataset shift that degrades model performance.
Unlike deep learning, model-based iterative algorithms can consistently achieve solutions with theoretical performance guarantees. Integrating domain knowledge in model-based algorithms and neural networks, known as knowledge-driven methods, can simplify the architecture of machine learning systems, decrease training overhead, enhance the interpretability of decisions, and increase their practical utility [22]. Deep unrolling [23] provides an effective solution for integrating domain knowledge with iterative algorithms. The main idea is to design neural networks by leveraging the structure of classical iterative algorithms, incorporating the iterative structure of the algorithm into each layer of the network. This approach treats network layer as an iteration in the original iterative optimization algorithm and learns the network parameters from the data. Deep unrolling combines the benefits of data-driven learning with the domain knowledge embedded in the iterative algorithm, resulting in improved performance and generalization capabilities. In the field of image processing, deep unrolling has successfully addressed several challenging problems, including image restoration [24], deep image deblurring [25], and image super-resolution [26]. In the field of wireless communications, deep unrolling projected gradient descent (PGD) algorithm into a neural network has shown better accuracy with lower and more flexible computational complexity in MIMO detection problems [27]. A low-complexity deep neural network-based MIMO detector was proposed using the multipliers algorithm's deep unrolling alternating direction approach [28]. In [29], the original iterative shrinkage thresholding algorithm is transformed into an unrolled RNN, maintaining the robustness of the algorithm and improving estimation accuracy. The iterative WMMSE algorithm is unrolled into a layer-by-layer CNN structure, introducing trainable parameters to replace the high-complexity operations in forward propagation, reducing computational complexity for efficient performance and enhancing neural network generalization [30]. In addition to unrolling model-based iterative algorithms such as DNN and RNN, unrolled GNN has the advantages of scalability and interpretability. A deep unrolling architecture based on GNN is proposed in [31], which only learns key parameters of the WMMSE algorithm with GNN without unrolling iterations in WMMSE algorithm as layers in GNN. As demonstrated in [32], the alignment of the GNN architecture with the algorithm may potentially enhance the representation of GNN and thus increase the sample complexity. Therefore, the investigation of GNN unrolling with accurate alignment between GNN layers and algorithm iterations is required to improve the performance further.
In this paper, we propose a novel knowledge-driven GNN architecture-based resource allocation approach for D2D networks, guided by the WMMSE algorithm's unrolling, aiming to manage radio resources in D2D networks. Specifically, to align one iteration of the WMMSE algorithm with a one layer GNN, message passing and aggregation functions are designed based on the unrolling WMMSE algorithm, which utilize two cascaded GNN modules respectively for hierarchical feature extraction and node update. By adopting the structure and domain knowledge of the WMMSE algorithm, our proposed approach retains the algorithm's robustness while effectively reducing its computational delay, decreasing the sample complexity of the neural network, and adapting to various data distributions. The main contributions of the paper can be summarized as follows.
1. We propose a novel GNN architecture guided by a deep unrolling WMMSE algorithm, named UWGNN. This approach leverages the summation part of the WMMSE algorithm to design the aggregation function in GNN while adopts the power calculation formula of a single node to design the update function of GNN.
2. We conduct a theoretical analysis to demonstrate the validity of deep unrolling in the UWGNN, where layers in GNN are alignment with iterations in WMMSE algorithm. The deep unrolling model is scrutinized from two aspects: network mapping and the size of network exploration space. Through this analysis, it is concluded
that deep unrolling make the mapping relationship of the model more accurate and reduce the exploration space of the model.
3. Our proposed UWGNN shows strong performance, robustness, and scalability through extensive simulations. Moreover, the architecture exhibits excellent generalization performance when dealing with diverse data distributions and communication topologies without necessitating retraining. Experiments show that the approach enables on-demand reduction of delay in communication network resource allocation.
The remainder of this paper is organized as follows. Section II introduces the communication model and the formulae for resource allocation problems. In Section III, we present the WMMSE algorithm along with our proposed unrolling network architecture. In Section IV, we propose a theoretical hypothesis for the validity of the unrolling technique. In Section V, we demonstrate the effectiveness of our proposed approach through numerical experiments. Finally, Section VI summarizes and concludes the paper.
## II System Model and Problem Formulation
### _System Model_
We consider a D2D scenario consisting of \(N\) single-antenna transceiver pairs. Let \(p_{i}\) denote the transmission power that transmitter \(i\) uses to send a baseband signal \(s_{i}\) to receiver \(i\). That is, the transmission signal \(x_{i}=\sqrt{p_{i}}s_{i}\). Then, the received signal at receiver \(i\) is
\[y_{i}=h_{ii}x_{i}+\sum_{j=1,j\neq i}^{N}h_{ij}x_{j}+n_{i},\;\forall i, \tag{1}\]
where \(h_{ii}\in\mathbb{R}\) represents direct channel between transmitter \(i\) and receivers \(i\), \(h_{ij}\in\mathbb{R}\) with \(i\neq j\) interference channel from transmitter \(j\) to receiver \(i\), and \(n_{i}\in\mathbb{R}\) denotes the additive noise following the complex Gaussian distribution \(\mathcal{CN}(0,\sigma^{2})\). Based on the receive threshold equalization \(u_{i}\), the signal recovered by receiver \(i\) can be obtained as \(\hat{s}_{i}=u_{i}y_{i}\). Assuming that the signals of different users are independent of each other and receiver noises, the signal-to-interference-plus-noise ratio (SINR) of receiver \(i\) is expressed as
\[SINR_{i}=\frac{|h_{ii}|^{2}p_{i}}{\sum_{j\neq i}^{N}|h_{ij}|^{2}p_{j}+\sigma^{ 2}},\;\forall i, \tag{2}\]
where \(p_{i}\) represents the power of transmitter \(i\), and \(0\leq p_{i}\leq p_{\max}\) with \(p_{\max}\) denoting as the max transmission power of the transmitter.
Our objective is to maximize the weighted sum rate by optimizing the transmission power, formulated as
\[\max_{\mathbf{p}}\sum_{i=1}^{N}\lambda_{i}\mathrm{log}_{2}\left( 1+\frac{|h_{ii}|^{2}p_{i}}{\sum_{j\neq i}^{N}|h_{ij}|^{2}p_{j}+\sigma^{2}} \right), \tag{3}\] \[\mathrm{s.t.}\;0\leq p_{i}\leq p_{\max},\;\forall i,\]
where the weight \(\lambda_{i}\) represents the priority of transmitter \(i\) in the sum rate problem, and the power vector is expressed as \(\mathbf{p}=[p_{1},\ldots,p_{N}]\).
### _WMMSE Algorithm_
The non-convex nature of Problem (3) arises from the objective function. Many iterative algorithms have been proposed to solve it effectively, of which the WMMSE algorithm [4] is the most classical one. The main idea of the algorithm is to equivalently transform the weighted sum-rate maximization problem into a problem of minimizing a weighted sum of mean squared errors (MSE), as follows:
\[\min_{\mathbf{u},\mathbf{v},\mathbf{w}} \sum_{i=1}^{N}\lambda_{i}(w_{i}e_{i}-\log w_{i})\] \[\mathrm{s.t.}\;0\leq{v_{i}}^{2}\leq p_{\max},\;\forall i, \tag{4}\]
where \(w_{i}\geq 0\) is an introduced auxiliary variables indicating the weight for transmitter \(i\). \(v_{i}=\sqrt{p_{i}}\), and \(\mathbf{u}=[u_{1},\ldots,u_{N}],\mathbf{v}=[v_{1},\ldots,v_{N}],\mathbf{w}= [w_{1},\ldots,w_{N}]\), respectively. \(e_{i}\triangleq\mathbb{E}_{s,n}\left[\left(\hat{s}_{i}-s_{i}\right)^{2}\right]\) is the MSE covariance of the transmission signal \(s_{i}\) and the recovery signal \(\hat{s}_{i}\), represented as
\[e_{i}=\left(1-u_{i}h_{ii}v_{i}\right)^{2}+\sum_{j\neq i}\left(u_{i}h_{ij}v_{j} \right)^{2}+\sigma^{2}u_{i}^{2},\;\forall i. \tag{5}\]
It has been demonstrated in [4] that the WMMSE problem presented in (4) is equivalent to the problem of maximizing the sum-rate as depicted in (3), with both problems sharing an identical optimal solution denoted as \(v_{i}\). Subsequently, the weighted sum-MSE minimization problem is decomposed into three separate optimization subproblems, each of which can be solved iteratively. Since the subproblems associated with the optimization variable vectors \(\{\mathbf{u},\mathbf{v},\mathbf{w}\}\) are convex in nature, the algorithm utilizes a block coordinate descent approach to solve the WMMSE problem in (4). More specifically, by sequentially fixing two of the three variables \(\{u_{i},w_{i},v_{i}\}\) and simultaneously updating the third variable, the WMMSE formula is as follows:
\[{u_{i}}^{(k)} =\frac{h_{ii}{v_{i}}^{(k-1)}}{\sigma^{2}+\sum_{j}h_{ij}^{2}{v_{j }}^{(k-1)}{v_{j}}^{(k-1)}},\;\forall i \tag{6}\] \[{w_{i}}^{(k)} =\frac{1}{1-u_{i}{{}^{(k)}}h_{ii}{v_{i}}^{(k-1)}},\;\forall i\] (7) \[{v_{i}}^{(k)} =\frac{\lambda_{i}{u_{i}}^{(k)}h_{ii}{v_{i}}^{(k)}}{\sum_{j}h_{ ji}^{2}{u_{j}}^{(k)}{u_{j}}^{(k)}{w_{j}}^{(k)}},\;\forall i \tag{8}\]
where \(k=1,...,K\) represents the number of iterations. The detailed WMMSE algorithm is outlined in Algorithm 1.
```
1:Initialization:\(\{v_{i}\}\) to satisfy \(0\leq{v_{i}}^{2}\leq p_{\max}\). The current iteration index \(k=1\).
2:repeat
3: Update \(u_{i}^{(k)}\) based on Equation (6);
4: Update \(w_{i}^{(k)}\) based on Equation (7);
5: Update \(v_{i}^{(k)}\) based on Equation (8);
6:\(k=k+1\);
7:until the convergence condition is met,
8:transmission power \(p_{i}=v_{i}^{2}\).
```
**Algorithm 1** WMMSE Algorithm
## III System Model and Problem Formulation
### _System Model_
The proposed approach is to maximize the weighted sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by minimizing the sum rate by the sum rate by minimizing the sum rate by the sum rate by minimizing the sum rate by the sum rate by minimizing the sum rate by the sum rate by minimizing the sum rate by the sum rate by minimizing the sum rate by the sum rate by minimizing the sum rate by the sum rate by the sum rate by the sum rate by minimizing the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum sum sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum sum by the rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum sum rate by the sum sum rate by the sum rate by the sum sum rate by the sum rate by the sum rate by the sum rate by the sum sum rate by the sum rate by the sum rate by the sum rate by the sum rate by the sum sum rate by the sum sum rate by the sum rate by the sum sum rate
Although the WMMSE algorithm has demonstrated high performance in various wireless communication systems, some of its shortcomings limit its practical application. Firstly, the algorithm is prone to get trapped in local optima. Additionally, the computational time required for the WMMSE algorithm to converge is significant, particularly in large-scale networks.
## III Neural Network Architecture Design Using WMMSE Algorithm
To enhance online computational efficiency while preserving the interpretability of the WMMSE algorithm, we propose a knowledge-driven GNN approach for transmission power allocation in D2D networks. Our proposed method incorporates the unrolled WMMSE algorithm as the message aggregation and combination functions within the GNN. In what follows, we first briefly introduce GNN and unrolling technique, then present the knowledge-driven GNN.
### _Preliminaries_
#### Iii-A1 Graph Neural Networks
GNNs were initially designed to process non-Euclidean structured graphs data [33]. Unlike traditional neural networks that operate on a fixed grid of inputs, GNNs can handle data with arbitrary connectivity, making them well-suited for tasks such as node classification, graph classification, and clustering detection. Particularly, GNNs operate by iteratively passing messages between nodes in the graph, updating the node representations based on the received information from neighboring nodes. This process can be thought of as a form of message passing, where each node can aggregate information from its local neighborhood and integrate it into its representation.
The aggregation function is primarily utilized to consolidate the neighborhood features of nodes from their neighboring nodes and connected edges. In contrast, the combined function is responsible for updating the current node features based on the previous iteration node features and the neighborhood features. Formally, the aggregate and combine rules of the \(k\)-th layer at node \(i\) in GNNs are respectively expressed as
\[\mathbf{\alpha}_{i}^{(k)} =\mathrm{AGGREGATE}^{(k)}\left(\left\{\mathbf{\beta}_{j}^{(k-1)}:j \in\mathcal{N}(i)\right\}\right), \tag{9}\] \[\mathbf{\beta}_{i}^{(k)} =\mathrm{COMBINE}^{(k)}\left(\mathbf{\beta}_{i}^{(k-1)},\mathbf{\alpha}_ {i}^{(k)}\right) \tag{10}\]
where \(\beta_{i}^{(k)}\) represents the feature vector of node \(i\) at either the \(k\)-th layer or after the \(k\)-th iteration. \(\mathcal{N}(i)\) is the set of neighbor nodes of \(i\), and \(\alpha_{i}^{(k)}\) is an intermediate variable.
#### Iii-A2 Algorithm Unrolling
Algorithm unrolling, also referred to as deep unrolling or unfolding, represents a technique that bridges the gap between deep learning and traditional iterative models, enabling the amalgamation of domain knowledge and data-driven learning. The fundamental concept of deep unrolling is transforming an iterative inference algorithm into a hierarchical structure that mimics a neural network. Each layer of the neural network corresponds to each iteration of the algorithm. Gregor and LeCun proposed deep unrolling seminal work [34], which has been used to connect various iterative algorithms, such as those used in sparse coding, to diverse neural network architectures. It is possible to unfold an N-step iterative inference algorithm into an N-layer neural network with trainable parameters. This aims to enhance the model performance by leveraging a computationally-lighter neural network.
Unrolled networks boost high parameter efficiency and require less training data than popular neural networks. Therefore, this approach efficiently counters the lack of interpretability normally found in traditional neural networks. This approach provides a systematic link between traditional iterative algorithms and deep neural networks, leading to efficient, interpretable, and high-performance network architectures.
### _Graph Representation of the Weighted Sum Rate Maximization Problem_
Before presenting the knowledge-driven neural network architecture, we considered the D2D network as a directed graph with node and edge features. As shown in Fig. 1, we consider a pair of D2D communication users as a node in the graph and the interference link between transmitter \(j\) and receiver \(i\) as an edge between node \(j\) and node \(i\). Typically, node features include attributes such as node labels, node degrees, and node positions, while edge features may include attributes such as edge weights, edge types, and edge directions. For problem (4), node features contain the weighted factor \(\lambda_{i}\), channel gain \(h_{ii}\) between D2D pair, transmission power \(v_{i}\) of transmitter\(i\), and resource allocation intermediate variables \(u_{i},w_{i}\), etc, whereas edge feature includes the channel gain of the interfering channel \(h_{ij}\).
Fig. 1: Graph modeling of the D2D communication network. We consider a pair of D2D users as a node in the graph and the interference link between transmitter \(j\) and receiver \(i\) as an edge between node \(j\) and node \(i\).
The modeled wireless channel directed graph is mathematically represented as \(G=(V,E)\), where \(V\) is the set of nodes, \(E\) is the set of edges. We denote the feature of node \(i\) by notation vector \(\mathbf{z}_{i}\), represented as
\[\mathbf{z}_{i}=[\lambda_{i},h_{ii},v_{i},\mathbf{u}_{i},\mathbf{w}_{i}]^{\top},\,\mathbf{z}_{i}\in\mathbb{C}^{(3+d_{u}+d_{w})\times 1} \tag{11}\]
where \(\lambda_{i},\;h_{ii},\;v_{i}\) are one-dimensional variables, \(u_{i}\) and \(w_{i}\) are a \(d_{u}\)-dimension vector and a \(d_{w}\)-dimension vector, respectively, expanded by the one-dimensional variables, to enhance the feature extraction capability of GNNs.
To improve the feature extraction capability of GNN, we propose expanding the one-dimensional variable \(u_{i}\) and \(w_{i}\) into a \(d_{u}\)-dimension vector and a \(d_{w}\)-dimension vector, respectively. The node feature matrix \(\mathbf{Z}\) can be expressed as \(\mathbf{Z}=[\mathbf{z}_{1},\ldots,\mathbf{z}_{N}]\). The edges adjacency feature matrix \(\mathbf{A}\in\mathbb{C}^{N\times N}\) is given by
\[\mathbf{A}_{(i,j)}=\begin{cases}0,&\quad\text{if}\;\{i,j\}\notin E\\ h_{ij},&\quad\text{otherwise}\end{cases} \tag{12}\]
By defining nodes feature matrix \(\mathbf{Z}\) and edges feature matrix \(\mathbf{A}\), the considered D2D scenario is converted as a directed graph. Based on this, we will develop an effective algorithmic knowledge inspired graph neural network architecture.
### _Proposed Knowledge-Driven GNN Architecture_
Although the non-Euclidean data structure of GNN has the advantage of handling communication topological information compared to other deep learning models, its internal structure design is also essential. The aggregate and combined functions of most GNNs are typically designed with consideration of graph data structures and features, such as permutation invariance and self-attentiveness mechanisms, etc. Although these data-driven design approaches have excellent end-to-end nonlinear mapping performance, they are usually interpretable to a limited extent as black box models.
Inspired by the deep unrolling technique, we propose a novel GNN architecture based on the unrolling WMMSE algorithm, named UWGNN. Specifically, in the message passing process of the GNN, we design the message passing and aggregation functions by utilizing the sum operation of neighborhood information in the denominators of (6) and (8) in the WMMSE algorithm. Instead of aggregating all node and edge features into the aggregation function at once, we selectively input the features of the aggregation function based on the sum operation. Typically, a single-layer GNN involves only one round of message passing and aggregation. In contrast, as shown in (6) and (8), the WMMSE algorithm requires two rounds of aggregation for neighbor messages within one cycle, and the information dimensions of the two processes are different. Therefore, we design two different aggregation functions corresponding to two GNN modules in cascade. For the node feature update, we design three update steps based on the WMMSE algorithm, corresponding to the updates of \(u_{i}\), \(w_{i}\), and \(v_{i}\). Similar to the idea of the algorithm to fix one variable and update the remaining variables, our GNN architecture first updates \(u_{i}\), then updates \(w_{i}\), and finally passes the new \(u_{i}\) and \(w_{i}\) to updates \(v_{i}\). This hierarchical feature extraction and node update strategy, inspired by the algorithm, is more conducive to the GNN deep cognition of data features. The network architecture is depicted in Figure 2.
The first GNN module is used to unroll the equation of the algorithm that calculates \(u_{i}\) and \(w_{i}\). In (13), the feature of neighbor power \(v_{j}\) and path loss \(h_{ij}\) is extracted by \(\mathrm{MLP}_{1}\). To cope with the lack of channel information, we adopt the MAX pooling operation to aggregate the neighborhood information \(\alpha_{u_{i}}\). Feeding \(\alpha_{u_{i}}\) and node feature \(v_{i},h_{ii}\) into the combination function \(\mathrm{MLP}_{2}\) in (14), we can obtain the \(u_{i}\) information of the nodes. Similarly, \(w_{i}\) is calculated by \(\mathrm{MLP}_{3}\) in (15).
Fig. 2: Knowledge-driven graph neural network architecture. The proposed GNN model utilizes a two-module architecture inspired by the unrolling WMMSE algorithm. The first GNN module focuses on calculating \(u_{i}\) and \(w_{i}\), while the second module computes node power \(v_{i}\). This hierarchical feature extraction and node update strategy allows for deep learning of data features and more effective cognition within the GNN architecture.
\[\alpha_{u_{i}}{}^{(k)} =\mathrm{MAX}\left\{\mathrm{MLP}_{1}\left(h_{ij},v_{j}{}^{(k-1)} \right)\right\},j\in\mathcal{N}(i), \tag{13}\] \[u_{i}{}^{(k)} =\mathrm{MLP}_{2}\left(h_{ii},v_{i}{}^{(k-1)},\alpha_{u_{j}}{}^{( k)}\right)\] (14) \[w_{i}{}^{(k)} =\mathrm{MLP}_{3}\left(h_{ii},v_{i}{}^{(k-1)},u_{i}{}^{(k)} \right), \tag{15}\]
We utilize the second GNN to unroll equation (8), which serves as a basis for computing the node power \(v_{i}\). In order to compute the denominator part of (15), we employ \(\mathrm{MLP}_{4}\) as the aggregation function for the second GNN, which enables us to gather information on neighboring nodes \(u_{j}\), \(w_{j}\), and the edges \(h_{ji}\) feature. The neighborhood information \(\alpha_{v_{i}}\) is aggregated by MAX pooling operation. Finally, we use \(\mathrm{MLP}_{5}\) in (16) as the combining function to update the node power information \(v_{i}\).
\[\alpha_{v_{i}}{}^{(k)} =\mathrm{MAX}\left\{\mathrm{MLP}_{4}\left(h_{ji},u_{j}{}^{(k)}, w_{j}{}^{(k)}\right)\right\},j\in\mathcal{N}(i), \tag{16}\] \[v_{i}{}^{(k)} =\gamma\left(\mathrm{MLP}_{5}\left(\lambda_{i},h_{ii},u_{i}{}^{ (k)},w_{i}{}^{(k)},\alpha_{v_{i}}{}^{(k)}\right)\right), \tag{17}\]
where \(\gamma(x)\) is a sigmoid function to constrain output power, i.e., \(\gamma(x)=\frac{1}{1+e^{-x}}\).
### _The Training Approach_
The selection of the loss function for neural networks has a significant impact on the overall performance of the network. In supervised learning, the loss function is computed using the labels \(\hat{v}_{i}\) derived from the WMMSE algorithm. However, in realistic scenarios, communication channel and network topology change quickly, and ground truth labels required for training are difficult to collect within a limited period of time. And it is demonstrated in [16] that the algorithm's output constrains the upper limit of convergence performance.
The unsupervised loss function in (18) uses problem formation to optimize the neural network. Recent research on [16][19] has shown that unsupervised training approaches outperform the WMMSE algorithm. Therefore, for unsupervised training of our model, we adopt the optimization objective as the loss function in (18).
\[\mathcal{L}_{U}(\theta)=-\mathbb{E}\left(\sum_{i=1}^{N}\lambda_{i}\mathrm{log }_{2}\left(1+\frac{|h_{ii}v_{i}(\theta)|^{2}}{\sum_{i\neq j}|h_{ji}v_{j}( \theta)|^{2}+\sigma^{2}}\right)\right), \tag{18}\]
where \(\theta\) is the learnable parameter of the neural network.
## IV Theoretical Assumptions about Validity of Graph Neural Network Unrolling Approach
In this section, we discuss the validity of deep unrolling techniques for GNNs with respect to network mapping and the size of the model exploration space. Traditional neural networks employ the back-propagation algorithm to determine the steepest gradient descent direction for updating network parameters. The acquired network mapping is optimal for solving optimization problems under a specific data distribution, which can be conceptualized as end-to-end matrix multiplication. However, the learned mapping is highly dependent on the data distribution.
### _Constrained Neural Network Mapping_
As stated in [32], a good algorithm alignment means that all algorithm steps of an iterative algorithm are easy to learn. To facilitate learning complex end-to-end mappings, the unrolling approach decomposes the one-iteration process of the algorithm into smaller, simpler subtasks in a hierarchical fashion. Each module learns a portion of the mapping relationship in the optimization algorithm, thereby reducing the overall complexity of model training. For instance, the Newton iterative approach in (19) necessitates that an end-to-end neural network learn the entire mapping of \(G\left(x\right)\), containing multiple steps. When \(f\left(x\right)\) is complex, learning the end-to-end mapping is challenging. By dividing the mapping into distinct \(g_{i}\left(x\right)\) modules in (21), the unrolling approach can learn these mappings, including crucial parameters such as iteration steps during the iterative process. This technique effectively learns the algorithmic mapping and, through multi-level mapping, enhances the expressive network capability compared to one-step mapping.
\[x_{n+1}=x_{n}-\frac{f\left(x_{n}\right)}{f^{\prime}\left(x_{n} \right)} \tag{19}\] \[\Leftrightarrow G\left(x\right):x_{n+1}\to x_{n}\] (20) \[\Leftrightarrow\begin{cases}g_{1}\left(x\right):x_{n}\to f \left(x_{n}\right)\\ g_{2}\left(x\right):x_{n}\to f^{\prime}\left(x_{n}\right)\\ g_{3}\left(x\right):\left(f^{\prime}\left(x_{n}\right),f\left(x_{n}\right),x_{n }\right)\to x_{n+1}\end{cases} \tag{21}\]
### _Reduce the Model Exploration Space_
Furthermore, the input-output relationship between algorithm-designed modules constrains the mapping direction, and algorithm-based feature extraction aids in reducing the network exploration space. Building on the conclusions in [35] that deeper GNNs increase feature correlations, we examine the impact of input inter-feature correlations on network exploration. Employing the widely used Pearson correlation coefficient measure, [35] introduces the metric \(Corr(X)\) to quantify the correlation between all feature dimension pairs.
\[Corr(\mathbf{X})=\frac{1}{d(d-1)}\sum_{i\neq j}\left|\varphi\left(\mathbf{X}_{ (\cdot,i)},\mathbf{X}_{(\cdot,j)}\right)\right|,\ i,j\in[1,2,\ldots,d], \tag{22}\]
where \(\mathbf{X}\in\mathbb{C}^{N\times d}\) represents the node feature matrix with \(d\) being the number of features, \(\mathbf{X}_{(\cdot,i)}\) indicates the \(i\)-th column feature vector of \(\mathbf{X}\), and \(\varphi(x,y)\) is a popular Pearson correlation coefficient for assessing the correlation between learned dimensions in deep GNNs.
We propose that the exploration space of a neural network can be viewed as a high-dimensional space, expanded orthogonally by independent input variables. Considering two one-dimensional features on a graph node, it is observed that when the two input features are independent, the exploration space can be characterized as a high-dimensional space \(\mathbb{R}^{2}\), expanded orthogonally by two one-dimensional variables. In contrast, if the two features are identical, the exploration space is reduced from a high-dimensional, orthogonally expanded \(\mathbb{R}^{2}\) space to a one-dimensional linear expanded \(\mathbb{R}^{1}\) space.
This reduction in the exploration space size is manifested by an increase in the correlation coefficient \(Corr(X)\) between input features, with \(Corr(X)\) varying from 0 to 1. Therefore, the relationship between exploration space and input feature correlation can be expressed as \(\mathbb{R}^{d^{1-Corr(X)}}\).
Based on an iterative algorithm, the unrolling approach decomposes end-to-end optimization in a single iteration into multiple sub-problems that are iteratively processed. Through repeated feature extraction, this approach increases the correlation between node features in GNNs. For example, in the WMMSE algorithm, the \(k\)-th power \(v_{i}^{(k)}\) is generated by channel features \(h\) plus the power \(v_{i}^{(k-1)}\) from the previous iteration, which creates a certain correlation between the input features of the GNN. Moreover, in the deep unrolling architecture, two message passing operations and multiple channel information pass to increase the correlation between power \(v_{i}\) and channel characteristic \(h\). This approach is more effective in feature extraction with higher correlation of features after multi-layer networks and more accurate exploration of optimization objectives, especially when faced with changing data distributions.
## V Numerical Experiments
This section is dedicated to the conduction of comprehensive numerical tests to affirm the effectiveness and generalization of the presented knowledge-driven network architecture. Our experimental setup consists of a user count set to \(N=10\), a noise variance of \(\sigma^{2}=10\)dB, and an interference channel following a Rayleigh distribution. We derive the channel coefficients \(h_{ij}\) from the complex normal distribution \(\mathcal{CN}(0,1)\). In terms of the neural network training parameters, we utilize the Adam optimizer with a set learning rate of \(0.001\) and designate the batch size to be \(64\) samples. We compare UWGNN with established benchmarks and cutting-edge approaches.
1. **WMMSE**[4]: This is a classical iterative optimization algorithm for weighted sum rate maximization in interference channels. We run WMMSE for 100 iterations with \(p_{\max}\) as the initial power setting. The results obtained from this process served as our benchmark measurements.
2. **WCGCN**[21]: This is an unsupervised message passing GNN that uses two MLP networks to aggregate neighbor information and update its power information, and obtain a performance much better than the WMMSE algorithm.
3. **UWMMSE**[31]: UWMMSE proposed a deep unrolling architecture based on GNN to learn the iterative step-size \(a^{(k)}\) and the weight translation parameter \(b^{(k)}\), reduced the times of WMMSE iterations, and attained the performance comparable with well-established benchmarks.
4. **MLP**[14]: MLP uses the WMMSE output as a training label to supervise and learn a function mapping between the channel state information and the corresponding resource allocation.
We set UWGNN, WCGCN, and UWMMSE as three-layer networks, corresponding to three iterations, and use the same random seed to generate \(10^{4}\) sets of channel training samples to train three networks, respectively. Learning the iterative process with an MLP can be challenging and may require more training samples. Therefore, to effectively train the model, we utilized a ten-fold increase in training data in this study.
### _Selection of UWGNN Hyperparameters_
In this section, our investigation centers on how model performance is influenced by factors such as the intermediate message-passing dimension, which is the output dimension of \(\mathrm{MLP}_{1,4}\), the variable dimension, which corresponds to the output dimension of \(\mathrm{MLP}_{2,3}\). We used 20 random seed variables in our experiments and chose the WMMSE algorithm output as a benchmark. As illustrated in Fig. 3(a), the effect of the message passing size on model performance was demonstrated. We observed that when the dimension of the aggregation message was too small, UWGNN performance declined. When the dimension increased to 16, UWGNN performance exceeded the WMMSE baseline. Further increases did not impact the model performance significantly. We hypothesized that the message passing dimension influences the ability of the node to extract information from neighboring nodes, as evidenced by (17), and concluded that the dimension of
Fig. 3: Impact of variation in width of GNN on performance
message variables must be at least equal to the sum of the dimensions of \(u_{j}\), \(w_{j}\), and \(h_{ij}\). Reducing message passing dimension will lead to feature information compression of neighboring nodes that decrease network performance. On the other hand, excessively wide message passing dimension only marginally enhanced model performance but generated computational complexity redundancy.
For the intermediate variable dimensions, as presented in Fig. 3(b), the impact on the performance of the network model is minimal, with a slight decrease in performance observed only for intermediate variable dimensions equal to two. The intermediate variables designed in our study, based on one-dimensional messages \(u_{i}\) and \(w_{i}\) in (6)-(8). Increasing the dimension of these variables has little impact on one-dimensional feature extraction. Thus, the size of the message passing dimension in Fig. 3 does not significantly affect network performance. However, in distributed GNNs, communication resources are utilized during the message passing process. An excessively wide intermediate variable dimension requires a larger message passing dimension, which can increase transmission latency and path loss, thereby affecting the accuracy and delay of GNN inference. As a result, we aim to strike a balance between network feature extraction and optimal network performance by ensuring that the feature dimension of \(u_{i},w_{i}\) is comparable to the input dimension of \(h_{i},v_{i}\).
As stated above, we establish the network unit size of \(\mathrm{MLP_{1}-MLP_{5}}\) in (13)-(17) to {5, 8, 16}, {19, 8, 4}, {7, 8, 4}, {10, 8, 16}, and {27, 8, 1}. UWGNN is constructed with three unrolled WMMSE layers, each of which shares parameters. In every layer, two GNNs are incorporated as learning components, utilized for the emulation of (6)-(8).
### _Sum Rate Performance_
We compare the sum rate performance obtained by UWGNN with other approaches, as shown in Table I. To determine the upper bound, we ran the WMMSE algorithm 100 times for random power initialization and selected the best performance. As shown by the results, both UWGNN and WCGCN are in close proximity to the benchmark performance when dealing with relatively smaller problem scales. As the user size increases, MLP is not an optimal choice because it requires a large number of training samples. This observation indicates that MLP is not well-suited for learning an iterative process. In contrast, UWGNN and WCGCN demonstrate attractive properties as their performance remains stable and close to the performance ceiling of WMMSE, even as the user size increases. It is worth noting that UWMMSE requires the WMMSE algorithm to obtain the output power, which significantly impacts its performance as the computational complexity increases. Our findings suggest that message passing GNNs are preferable and more effective than other approaches for the iterative optimization problems.
### _Convergence Speed Comparison_
We compare the network convergence rate in Fig. 4, and our network, which converges in only \(\frac{1}{3}\) of the epochs to achieve convergence performance compared to that of WCGCN. UWMMSE learns the step size parameter and uses the WMMSE algorithm to iteratively obtain the output. Therefore, the initial performance of UWMMSE is better, but it presents a slower linear convergence speed. Although the deep unrolling operation increases the computational complexity of the network from \(O(L(|E|+|N|))\) to \(O(L(|E|+|N|^{2})(|E|+|N|))\), our network architecture is narrower in width and deeper in depth; thus the network parameters of UWGNN has a smaller parameter count than WCGCN. We employ the hop library in Python for comparing the computational load and the network's parameter count, as specified in Table II. The proposed network converges faster because we have more iterations of channel state information and node power information, resulting in a smaller exploration space, and the same feature extraction approach as the WMMSE algorithm.
### _Scalability Comparison_
In order to assess network scalability, both UWGNN and WCGCN were independently trained over 30 epochs until convergence was achieved in a scenario with 20 users. Subsequently, these trained networks were transferred to new scenarios featuring varying numbers of users, without the need for additional training. As shown in Fig. 6, both GNN networks have good convergence performance for a smaller
Fig. 4: Network convergence speed comparison
number of 10 user scenario. However, when the number of users increases to 50, the WCGCN network can no longer exceed the performance of the WMMSE baseline, while our network can still exceed the baseline performance. As the number of users reaches 100 and the user connection density intensifies, the WCGCN can no longer achieve the baseline performance, while our network architecture still achieves the baseline performance.
After our experiments, we found that the scalability of GNN comes from the smoothing operation of the max pooling layer on the features of neighboring nodes. When the user dimension changes, the pooling layer uses \(\mathrm{SUM}(.)\), \(\mathrm{MAX}(.)\), or \(\mathrm{MEAN}(.)\) functions to extract the feature information of neighbor nodes and edges. Experimentally, it is found that the MAX function works best for the problem in this paper. Moreover, our network architecture undergoes two rounds of MAX pooling because of two information aggregation operations; thus, it is better suited for scaling to diverse scenarios with varying user number densities.
### _Channel Distribution Generalization_
The generalization performance of the network is tested using datasets with varying channel distributions. As the user moves, the scattered channel may convert into a direct channel, leading to a potential shift in data distribution from Rayleigh to Rician distributions in the communication scenario. To ascertain the model's generalization ability, we adjusted the sample distribution of the channel in the test set. The initial training set consisted of Rayleigh channels with a mean of 0 and a variance of 1. As shown in Fig. 5(a), we modified the variance of the Rayleigh channel within the test set. During minor variance changes, UWGNN and WCGCN both exhibited generalization capabilities. Nonetheless, as the variance gap widened, WCGCN's performance deteriorated noticeably, signifying its limitations in adapting to data distribution shifts. With the integration of a knowledge-driven network grounded on the WMMSE algorithm, our network architecture demonstrated superior generalization compared to WCGCN, maintaining robust adaptability amidst diverse data distributions. Remarkably, our model sustained roughly 90% of its performance even amidst substantial variance alterations. In Fig. 5(b), we introduced the line of sight (LOS) component to the Rayleigh channel by increasing the channel mean to 1, thus transforming its distribution into a Rician distribution. Following this, we altered the variance of the Rician distribution. The experimental results underscored the continued robust generalization performance of our network. Fig. 5(c) illustrates the impact of modifying the strength of the LOS component within the Rician channel. Our model maintained satisfactory performance under varied direct path strengths, facilitating a seamless transition between scattered and direct channels - a critical feature ensuring the model's generalization ability in a mobile environment.
The conducted experiments affirm that the integration of a knowledge-driven model significantly bolsters generalization across disparate sample distributions. Facing diverse data distributions, our model demonstrates minimal performance degradation, obviating the need for additional retraining.
Fig. 5: Channel distribution generalization comparison
Fig. 6: Scalability comparison
### _Communication Topology Generalization_
As shown in Fig. 8, the topology of a communication network changes with the movement of users and the addition or removal of nodes, which affects the size of the node degree in the graph and thus impacts the performance of GNNs. To evaluate network generalization in adapting to communication topology changes, we generated a connection weight matrix as depicted in 23. The edges with weights lower than the probability of losing connection \(\eta_{lc}\) were removed to simulate sparse connections, allowing us to convert between fully and sparsely connected interference graph datasets.
\[C_{(j,i,:)}=\left\{\begin{array}{ll}\mathbf{0},&\mathrm{c_{ji}}<\eta_{lc} \\ \mathbf{1},&\mathrm{otherwise}\end{array}\right. \tag{23}\]
\[\hat{A}_{(j,i,:)}=A_{(j,i,:)}\odot C_{(j,i,:)} \tag{24}\]
where \(c_{ji}\) followed standard Gaussian distribution. \(\hat{A}_{(j,i,:)}\) is a new adjacency matrix of communication graph.
We experimented with two training and testing directions: from dense to sparse, and from sparse to dense. First, we trained the network on a fully connected graph data set with 10 pairs of users, migrating the test to sparsely connected graph data. As shown in Fig. 7(a), our network degrades in performance as the communication topology becomes more sparse, but still maintains a generalization performance of over 85%. In contrast, the performance of WCGCN degrades more significantly as the topology of the communication network changes. Compared with the unweighted scenario, the performance of the neural network trained in the weighted summation rate scenario is more generalized in Fig. 7(b). This is because the weighted and rate scenarios are more complex and the network learns more data about distribution during training. So when the network topology is changed, it is more adaptable. Second, we train the neural network on a training sample with \(\eta_{lc}\) of 0.6 and gradually decrease the \(\eta_{lc}\) value on the test data, making the sparse connected graph into a fully connected graph. The results are shown in Figs. 7(c) and 7(d). With increasing communication topology density, our network performance still closely follows the WMMSE algorithm performance, but the traditional end-to-end GNN performance decreases as increasing interference density.
### _Mobile Generalizability Performance_
The previous experiment only changed the link structure of the communication topology, however, as wireless devices usually move, the communication channel gain changes as well. In this experiment, we distribute N-transmitters uniformly in the space of \([1000\mathrm{m}\times 1000\mathrm{m}]\), and the corresponding receivers are distributed around the transmitters with distances obeying uniform distribution \(\mathbf{U}(30,90)\). Then we let each receiver device move randomly with speed \(S\). The change of position of the receiver obeys a two-dimensional Gaussian distribution \(N(0,0,S,S,0)\). The distance matrix \(\mathbf{D}\) can be obtained by calculating the inter-device distance. we multiply
Fig. 8: Change the communication network topology. With the movement of communication nodes, the interference between certain nodes in the fully connected communication topology will decrease, and the communication network topology will change. The addition of new nodes will also change the communication topology.
Fig. 7: Performance comparison of changing communication network topology
the distance matrix \(\mathbf{D}(t)\). The channel gain matrix \(\mathbf{H}(t)\) is adjusted proportionally based on distance to reflect the changes in device movement, resulting in the updated channel gain matrix \(\mathbf{H}(t+1)\). If the inter-device distance is greater than \(1000\) m, we consider that the channel gain is small and set \(h_{ij}\) to 0 to simulate the process of moving the user out of the device coverage. In this way, the test sample distribution will gradually move away from the training sample distribution with the increase of move time.
In Fig. 9, we test how the different user movement speeds affect the network generalization. When the device moves at low speed, the communication topology and channel gain change slowly, and the distribution of training and test data do not differ much. So, both GNNs can maintain more than 95% performance. However, when the speed of device movement gradually increases, and the test data changes more drastically, the end-to-end GNN has difficulty in adapting to the new distribution and the performance degrades. Due to the incorporation of algorithmic knowledge, our proposed GNN excels in its generalization capabilities, especially in dynamic environments involving user mobility. This advantage equips the GNN to seamlessly adapt to evolving communication scenarios and maintain the communication rates under varying conditions.
### _Sample Complexity_
In [32], the concept of network sample complexity and algorithm alignment is introduced, which shows that the higher algorithm alignment, the lower network sample complexity. To compare their network sample complexities, UWGNN and WCGCN are trained using different training samples until they attain convergence, and their performance is tested on 2000 test samples. Analysis of Fig. 10 shows that our network performs well on small training datasets with different numbers of users, indicating that it does not depend on a large sample size to learn the statistical distribution of the data, but to learn the structure and iterative calculation of the WMMSE algorithm. Additionally, the performance improves faster with an increase in sample size, indicating that our network aligns more effectively with the algorithm than the conventional GNN network.
## VI Conclusion
In this paper, we have proposed a novel knowledge-driven approach based on WMMSE algorithm inspired GNN to solve the resource allocation problem in D2D networks. Compared with current approaches, our approach has exhibited unique advantages in scalability and data generalization. Moreover, we have introduced a theoretical hypothesis for the validity of the graph neural network unrolling approach. Going forward, we plan to extend this work to other wireless resource allocation problems, such as bandwidth allocation, beam assignment, etc., and further develop our theoretical results to better guide the design of unrolling approaches. We expect that neural networks with knowledge-driven architecture will be significant in the future of wireless communication networks.
|
2306.10397 | Enhancing the Prediction of Emotional Experience in Movies using Deep
Neural Networks: The Significance of Audio and Language | Our paper focuses on making use of deep neural network models to accurately
predict the range of human emotions experienced during watching movies. In this
certain setup, there exist three clear-cut input modalities that considerably
influence the experienced emotions: visual cues derived from RGB video frames,
auditory components encompassing sounds, speech, and music, and linguistic
elements encompassing actors' dialogues. Emotions are commonly described using
a two-factor model including valence (ranging from happy to sad) and arousal
(indicating the intensity of the emotion). In this regard, a Plethora of works
have presented a multitude of models aiming to predict valence and arousal from
video content. However, non of these models contain all three modalities, with
language being consistently eliminated across all of them. In this study, we
comprehensively combine all modalities and conduct an analysis to ascertain the
importance of each in predicting valence and arousal. Making use of pre-trained
neural networks, we represent each input modality in our study. In order to
process visual input, we employ pre-trained convolutional neural networks to
recognize scenes[1], objects[2], and actions[3,4]. For audio processing, we
utilize a specialized neural network designed for handling sound-related tasks,
namely SoundNet[5]. Finally, Bidirectional Encoder Representations from
Transformers (BERT) models are used to extract linguistic features[6] in our
analysis. We report results on the COGNIMUSE dataset[7], where our proposed
model outperforms the current state-of-the-art approaches. Surprisingly, our
findings reveal that language significantly influences the experienced arousal,
while sound emerges as the primary determinant for predicting valence. In
contrast, the visual modality exhibits the least impact among all modalities in
predicting emotions. | Sogand Mehrpour Mohammadi, Meysam Gouran Orimi, Hamidreza Rabiee | 2023-06-17T17:40:27Z | http://arxiv.org/abs/2306.10397v1 | Enhancing the prediction of emotional experience in movies using deep neural networks: the significance of audio and language
###### Abstract
Our paper focuses on making use of deep neural network models to accurately predict the range of human emotions experienced during watching movies. In this certain setup, there exist three clear-cut input modalities that considerably influence the experienced emotions: visual cues derived from RGB video frames, auditory components encompassing sounds, speech, and music, and linguistic elements encompassing actors' dialogues. Emotions are commonly described using a two-factor model including valence (ranging from happy to sad) and arousal (indicating the intensity of the emotion). In this regard, a Plethora of works have presented a multitude of models aiming to predict valence and arousal from video content. However, non of these models contain all three modalities, with language being consistently eliminated across all of them. In this study, we comprehensively combine all modalities and conduct an analysis to ascertain the importance of each in predicting valence and arousal. Making use of pre-trained neural networks, we represent each input modality in our study. In order to process visual input, we employ pre-trained convolutional neural networks to recognize scenes [1], objects [2], and actions [3, 4]. For audio processing, we utilize a specialized neural network designed for handling sound-related tasks, namely SoundNet [5]. Finally, Bidirectional Encoder Representations from Transformers (BERT) models are used to extract linguistic features [6] in our analysis. We report results on the COG-NIMUSE dataset [7], where our proposed model outperforms the current state-of-the-art approaches. Surprisingly, our findings reveal that language significantly influences the experienced arousal, while sound emerges as the primary determinant for predicting valence. In contrast, the visual modality exhibits the least impact among all modalities in predicting emotions.
Sogand Mehrpour Mohammadi\({}^{1}\), Meysam Gouran Orim\({}^{2}\), Hamidreza Rabiee\({}^{3}\)\({}^{1}\)Department of Computer Science, University of Mazandaran, Babolsar, Iran
\({}^{2}\)Department of Computer Engineering, Shahrood University of Technology, Shahrood, Iran
\({}^{3}\)Department of Electrical Engineering, Islamic Azad University, Karaj Branch, Karaj, Iran
Email: [email protected]
Emotion Recognition, Multimodal, Sound, Text, Spatio-temporal, Affective Computing
## 1 Introduction
In recent years, notable advancements have been made in the field of emotion recognition specifically pertaine to video and sound analysis [1]. However, there remain challenges as predictive models need to improve their accuracy and information processing capabilities to efficiently disentangle the influence of diverse modalities. These advancements will empower multimedia creators in the advertising or film industries to employ these improved predictive models as valuable tools. Researchers in the fields of neuroscience and psychology have extensively investigated the impacts of various input stimulus modalities on evoked emotions [8, 9, 10] and [11, 12]. Multimodal approaches to emotion identification are considered among the most important techniques for obtaining computer intelligence, as humans can perceive and comprehend emotions via the combined information conveyed in sound, video, and text [13, 14]. In the past, research on emotion recognition has predominantly directed on discriminative emotion features and recognition models that rely on single modalities such as audio signals [15] or facial expressions in video. In this work, we place significant emphasis on considering context information, knowing its importance in developing a robust emotion prediction model [16]. There is a scarcity of research focused on anticipating the feeling responses that videos and other multimedia content can elicit in viewers. With the progression of neural networks, numerous studies have endeavored to extract suitable global and local features from raw speech signals and RGB images, leading to improved performance in emotion recognition tasks [17]. These collective efforts have enhanced the performance of emotion recognition systems. Recent advancements in emotion recognition systems are hindered by a lack of comprehensive multimodal analysis, as they fail to consider all the relevant modalities that influence the recognition of emotions.
In this study, we harness the capabilities of deep convolutional neural networks (CNNs) to present a novel three-dimensional model of effective content. This model enables us to precisely predict the evoked emotion from movies, music, and text, with the ability to independently forecast arousal and valence as distinct dimensions of emotion. To extract features from static RGB frames, we employ state-of-the-art deep convolutional neural networks (CNNs). These advanced CNN models empower us to capture both picture-related features and motion-related features from the RGB frames. The I3D [3] architecture, which combines spatial and temporal networks, is employed to determine activity in a manner similar to CNNs. In order to extract information from scenes [1] and objects [2] in video frames, the spatial network is used. On the other hand, the temporal network captures and learns information according to the motion of the camera and objects across successive frames. Furthermore, sound representation is computed using soundNet [5], which is employed to extract the audio features. SoundNet has illustrated notable performance in the classification of acoustic scenes and objects by utilizing the inherent synchronization between vision and sound during model training. This natural synchronization allows for more efficient utilization of the advantages presented by both visual and audio information. To obtain text features from movie subtitles, we employed the pre-trained Bidirectional Encoder Representations from Transformers (BERT) model [6]. By feeding the movie subtitles into the BERT model, we achieved meaningful text representations that are vital for emotion recognition. In other words, the BERT model is utilized for extracting deep bidirectional representations from unlabeled text. In our study, we employed fully connected layers to integrate proposed multimodal networks. This integration was performed using the expanded COGNIMUSE dataset, [7].
### Related work
Currently, the majority of computer vision research on emotion identification mainly focuses on analyzing human facial expressions in both video and still images [18]. When inspecting research related to predicting emotions from videos, it is evident that the majority of works utilize multimodal techniques that consider and combine data from diverse modalities. Moreover, the field of computer vision has shown a growing interest in exploring the relationships and interactions between diverse modalities, including the synergies between sound and vision modalities [19]. In this paper, we aim to explore the relationship between sound and visual semantic information in the domain of emotion detection. While the combination of diverse modalities, such as sound and language, has been increasingly studied in the field of speech recognition [20], we extend this exploration to the realm of emotion detection, searching for uncover how these modalities synergistically contribute to the exact determination and understanding of emotions in multimedia content. Additionally, the relationship between text and visual modalities has been thoroughly investigated for the question-answering task [21].In this paper, our main goal is to develop a comprehensive representation that empowers us to conceive emotions through the integration of multiple modalities, including text, sound, and visual information extracted from both static images and motion. Unlike previous works that concentrates on only two modalities, our aim is to capture the rich and complex nature of emotions by harnessing the synergistic interaction of all available modalities. To extract text features from the movie subtitles in our dataset, we utilized a pre-trained BERT model [6].By feeding the movie subtitles into this pre-trained BERT model, we can extract meaningful text features that capture the linguistic content and context for further analysis and emotion anticipation. The main contribution of our paper is to demonstrate the effectiveness of a deep model that leverages three important natural modalities for emotion recognition. We provide an in-depth description of our methodology and thorough explanations of the conducted experiments in the following sections. Through these detailed analyses, we aim to showcase the robustness and accuracy of our approach in recognizing and predicting emotions across several modalities. In Section 2, we present our approach for developing a comprehensive understanding of emotion representations by incorporating concepts from sound, text, and visuals. In section 3, we present a detailed account of the experiments conducted to determine the effectiveness of our proposed representations. We present various experimental setups and analyze the performance of our model in anticipating and classifying emotions based on the extracted features.
Figure 1: Sample frames from the COGNIMUSE dataset to show our different modalities, i.e., video frame, sound and subtitles,(a) low valence, (b) high valence.
The experimental results serve to validate the robustness and efficacy of our approach across diverse datasets and scenarios.
## 2 Multimodal Learning of Concepts
In this section, our main goal is to achieve a comprehensive understanding of a given notion by exploring and comprehending its various modalities, including text, sound, and still images. By considering and integrating information from several modalities, we aim to capture a more complete and nuanced understanding of the targeted notion. We introduce a novel multimodal approach that utilizes all available modalities, including visual, sound, and text characteristics, to train our emotion prediction model. To achieve this, we employ the visual modality, which encompasses scene comprehension, object detection, and motion data. Additionally, the acoustic content of the second modality is processed. Last but not least, we employ text processing techniques to train multimodal networks within the context of textual information. To begin with, our network is organized to automatically detect visual concepts in both spatial and temporal dimensions, addressing the numerous challenges according to this task. Secondly, in order to tackle the sound processing challenge, it is vital for us to comprehend the audio segment that corresponds to a video concept. Finally, we extract the wording directly from the movie's subtitles, which may correspond to specific scenes, several instances, or different visual ideas. We utilize a pre-trained network to learn representations range from sound, vision, and text modalities in order to recognize emotions. Prior to combining them to produce audio-visual-text features, each of these input categories is passed through fully connected layers to decrease dimensionality and adapt the representations for emotion prediction. During the training phase of our presented network architecture, the weights of these fully connected layers are learned. Figure 1 shows a few frame samples showing strong and low-valence emotions.
### Visual concept
_Still Image:_ Following a similar approach to previous work [22], we divided the videos into five-second segments and extracted frames from each segment. Then, to extract features from static RGB frames, we employ the pre-trained Resnet152 [2] algorithm. The Imagenet
Figure 2: Video, Sound, and text modalities pass through our proposed network for emotion classification using fully connected layers.
dataset, which offers spatial information on the category of objects, is used to train the Resnet network.
_Scene information:_ To ascertain the semantic importance of visual attributes in scenes, we utilize pre-trained VGG networks [24] that were trained on Places datasets [1] for the scene classification task.To feed the fully connected layer of our network, we calculated the visual features from successive frames for each movie. After getting the visual features, we utilized max-pooling to downsample the feature representation and decrease its dimensionality.
_Motion information:_ To retrieve motion characteristics from the input image frame sequence, we utilized a two-stream inflated 3D ConvNet (I3D) [3]. The I3D model includes 2D ConvNet inflation and was trained on the Kinetics dataset for the action detection task.To extract spatio-temporal features, we applied a two-stream method with a combination of still frames and optical flow. Specifically, we fed the still RGB images into the pre-trained I3D models, which were originally trained for action recognition tasks. This allowed us to derive relevant spatio-temporal features from the video data.
### Sound
In the COGNIMUSE dataset, the accompanying sound for the movies can be classified as either speech or music. As part of our preprocessing method, each training and test sample is separated into non-overlapping fixed-length sound waveform files of approximately five seconds. This approach is similar to the one used in the work of [22]. Next, we extract features from the raw audio waveforms using SoundNet [5].
\begin{table}
\begin{tabular}{|c||c|c||c|c|} \hline & \multicolumn{2}{c||}{**Arousal**} & \multicolumn{2}{c|}{**valence**} \\ \hline \hline
**model** & **Accuracy(\%)** & **Accuracy \(\pm\) 1 (\%)** & **Accuracy (\%)** & **Accuracy \(\pm\) 1 (\%)** \\ \hline
**FC (RGB frame + OF + Audio)**[22] & 53.32 & 94.75 & 43.10 & 90.51 \\ \hline
**LSTM (RGB frame + OF + Audio)**[22] & 48.64 & 95.28 & 37.20 & 89.22 \\ \hline \hline
**Visual (Resnet + Places + I3D)** & 42.23 & 90.55 & 41.71 & 91.23 \\ \hline
**Sound (SoundNet)** & 58.59 & 95.11 & **56.28** & **97.20** \\ \hline
**Text (BERT)** & **58.86** & **95.13** & 32.55 & 82.62 \\ \hline
**Visual+ Sound** & 54.30 & 94.20 & 32.30 & 82.90 \\ \hline
**Resnet+ Sound** & 58.59 & 95.11 & 36.43 & 86.20 \\ \hline
**Text+ Sound** & 58.59 & 95.11 & 30.82 & 83.17 \\ \hline
**Text + visual** & 54.22 & 94.36 & 30.40 & 83.22 \\ \hline
**Text + Resnet** & 58.22 & 95.11 & 36.32 & 86.18 \\ \hline
**Visual+ Sound + Text** & 56.86 & 94.65 & 42.19 & 91.46 \\ \hline \end{tabular}
\end{table}
Table 1: Accuracy results on COGNIMUSE dataset along with the arousal and valence experienced emotion labels.
\begin{table}
\begin{tabular}{|c||c|c||c|c|} \hline & \multicolumn{2}{c||}{**Arousal**} & \multicolumn{2}{c|}{**valence**} \\ \hline \hline
**Model** & **Accuracy (\%)** & **Accuracy \(\pm\) 1 (\%)** & **Accuracy (\%)** & **Accuracy \(\pm\) 1 (\%)** \\ \hline
**FC (RGB frame + OF + Audio)**[22] & 31.20 & 72.94 & 30.33 & 66.95 \\ \hline
**LSTM (RGB frame + OF + Audio)**[22] & 30.80 & 71.69 & 22.54 & 57.63 \\ \hline
**Malandrakis et al.**[23] & 24.00 & 57.00 & 24.00 & 64.00 \\ \hline \hline
**Visual (Resnet + Places + I3D)** & 42.67 & 86.99 & 49.20 & 93.81 \\ \hline
**Sound (SoundNet)** & 58.51 & 95.10 & **55.85** & 96.21 \\ \hline
**Text (BERT)** & **58.56** & 95.10 & 32.45 & 83.99 \\ \hline
**Visual+ Sound** & 58.51 & 95.10 & 54.85 & **97.45** \\ \hline
**Text+ Sound** & 58.51 & 95.10 & 41.79 & 83.65 \\ \hline
**Text + visual** & 58.51 & 94.94 & 31.53 & 84.21 \\ \hline
**Text + Resnet** & 56.89 & 94.79 & 30.41 & 83.70 \\ \hline
**Sound + Text + Resnet** & 54.42 & 94.07 & 37.48 & 87.23 \\ \hline
**Visual+ Sound + Text** & 54.45 & **96.35** & 32.48 & 83.99 \\ \hline \end{tabular}
\end{table}
Table 2: Accuracy results on COGNIMUSE dataset along with the arousal and valence dimension on intended emotion label.
### Text
In this paper, we leverage the multimodal properties of sound, video, and text as sources of supervision to predict emotion labels. By incorporating information from several modalities, we intend to increase the accuracy and robustness of emotion prediction. We use three modalities that are able to mutually supervise each other during the training process. Large-scale language models, such as BERT (Bidirectional Encoder Representations from Transformers) [6], have shown significant performance in several natural language processing (NLP) tasks, showcasing their efficiency at both the word and sentence levels. These models have significantly advanced the field by capturing rich contextual information and semantic representations, allowing them to earn state-of-the-art results in diverse NLP applications. To extract bidirectional linguistic semantic data from the subtitles of each movie, we employ the power of the BERT (Bidirectional Encoder Representations from Transformers) model.Before using word2vec to embed each word from the subtitles, we apply a pre-processing step to remove English stop words [25].In our paper, the BERT model is employed, which enables us to understand the relationships between words, the meaning of sentences, and the overall structure of the subtitle text, which in turn contributes to our multimodal emotion anticipation model.
### Modality integration
To capture the correlations between diverse modalities and their influence on elicited emotion, we use the synchronous nature of sound, text, and visual input. We utilize pairs of video and text (from the subtitles), as well as pairs of images and sound (from videos). Our proposed multimodal network, depicted in Figure 2, leverages fully connected layers to incorporate and process diverse modalities for emotion classification. During training, the weights of the fully connected layers in our network are learned and optimized to precisely predict emotions. Subsequently, the outputs of these fully connected layers are concatenated and passed through another two fully connected layers. Using our multimodal network, we can predict emotion arousal and valence labels while individuals watch movies.
## 3 Experiment
To determine the performance of our model, we conduct tests using the COGNIMUSE dataset [7], which is composed of seven half-hour continuous movie clips. This dataset provides emotion annotations in terms of continuous arousal and valence ratings, ranging from -1 to 1. The primary focus of this work is to predict intended, expected and experienced emotions.In other words, we aim to understand and predict the emotions that individuals intend to convey, expect to feel, and actually experience while interacting with various multimedia content.
### Experimental setup
To ensure a comprehensive comparison, we also consider the results of intended emotions, which reflect the intentions of the filmmakers. These intentions are assessed by the same specialist who evaluates the other emotion categories. Additionally, to address potential challenges in emotion categorization, we employ seven different bins for each set of emotions. This method allows for a more nuanced analysis and interpretation of the emotions expressed in the multimedia content. To evaluate the performance of our proposed models, we utilized a leave-one-out cross-validation method. This means that for each iteration, we train the model on all samples except one, and then test its performance on the left-out sample. This process is repeated for each sample in the dataset. To evaluate the accuracy of our emotion classification, we use two metrics, namely accuracy and accuracy\(\pm\)1. Accuracy measures the percentage of correctly classified emotions, while accuracy\(\pm\)1 considers emotions that are classified within one bin of the ground truth emotion. In order to pre-process the data and remove noise, we apply Malandrakis' method [23]. After noise removal, we further apply the Savitzky-Golay filter [26] to smooth the data and decrease any remaining fluctuations. To guarantee consistency and comparability, we also rescale the preprocessed data within the range of -1 to 1. The valence and arousal are independently classified into seven distinct classes by the models. To train these models, we utilize stochastic gradient descent (SGD) optimization algorithm. The models are trained with a learning rate of 0.005, weight decay of 0.005, and the softmax function with a temperature of T = 2. During training, we run the models for 50 epochs with a batch size of 128. To avoid overfitting and enhance efficiency, we utilize early stopping with a patience of 25 epochs.
### Results
The results presented in table 1 and 2 showcase the accuracy of our proposed models for the 7-class classification of intended emotion prediction and experienced emotion prediction, respectively. We followed the test-training split and evaluation design presented in [22] to ensure consistency in our evaluation methodology. Each video clip in our dataset is divided into five-second segments, with synchronized sound and subtitles for each segment. The raw RGB video frames are then fed into the ResNet-152, a pre-trained model on the ImageNet dataset, to
extract features from each frame. These features are successively used as input to the final classification layer for emotion prediction.A completely connected layer is added on top of the retrieved features after applying max-pool to minimize dimensions, as seen in Fig 2. We employ the same methodology to extract scene features from locations. I3D models are used to extract motion features from snippet frames, and motion features are then layered with average pooling dimensional reduction before a fully connected layer is applied. The BERT model and SoundNet are utilized in a similar manner as the I3D model for extracting features from text and sound modalities, respectively. In our study, we investigate how diverse modalities, such as visual, sound, and text, contribute to the classification of viewers' emotional states. We use the network with fully connected layers for this analysis. In our study, we maintain a consistent architecture throughout the experiments, while changing the input features based on the specific modality being considered. We inspect diverse combinations of modalities, including audio, text, RGB frame features, Places features, and I3D features. Each modality is treated as a separate input to the architecture, allowing us to examine their individual contributions to the overall emotion recognition task. By systematically evaluating the performance of the model with different input features, we gain insights into the relative importance and effectiveness of each modality in capturing and predicting emotions. As shown in Table 1, text features provide a classification accuracy for arousal emotion labels that is higher than that of other modalities (image and motion). Sound modality gains high accuracy in valence emotion labels on experienced emotion annotation. According to the results presented in Table 2,text modality obtains higher accuracy when predicting intended arousal emotion label, and the sound modality provides better accuracy in predicting intended valence emotion label. The observed results, where text features perform well in anticipating intended arousal emotion labels and audio features perform better in predicting intended valence emotion labels, suggest that the influence of different modalities on emotions may vary. It is possible that text features, such as the semantic content derived from subtitles, play a more important role in conveying information related to arousal emotions. On the other hand, the audio features used, which capture the acoustic characteristics of the sound, may be more effective in capturing signals related to valence emotions. We compare our approach with the state-of-the-art of [23, 22] in emotion prediction in Table 1, 2.
## 4 Conclusion
In this paper, we propose a novel deep convolutional network that leverages multimodal inputs, including sound, vision, and text, to learn representations for emotion identification. Emotion classification is evaluated using both experienced and intended emotion annotations from the extended COGNIMUSE dataset. We train multiple model components and evaluate their performance when using diverse input modalities and their combinations. The results of our experiments demonstrate significant improvements in both experienced and intended emotion annotations from the extended COGNIMUSE dataset, highlighting the efficacy of our approach in enhancing emotion recognition using multimodal information.
|
2304.11196 | Fast GraspNeXt: A Fast Self-Attention Neural Network Architecture for
Multi-task Learning in Computer Vision Tasks for Robotic Grasping on the Edge | Multi-task learning has shown considerable promise for improving the
performance of deep learning-driven vision systems for the purpose of robotic
grasping. However, high architectural and computational complexity can result
in poor suitability for deployment on embedded devices that are typically
leveraged in robotic arms for real-world manufacturing and warehouse
environments. As such, the design of highly efficient multi-task deep neural
network architectures tailored for computer vision tasks for robotic grasping
on the edge is highly desired for widespread adoption in manufacturing
environments. Motivated by this, we propose Fast GraspNeXt, a fast
self-attention neural network architecture tailored for embedded multi-task
learning in computer vision tasks for robotic grasping. To build Fast
GraspNeXt, we leverage a generative network architecture search strategy with a
set of architectural constraints customized to achieve a strong balance between
multi-task learning performance and embedded inference efficiency. Experimental
results on the MetaGraspNet benchmark dataset show that the Fast GraspNeXt
network design achieves the highest performance (average precision (AP),
accuracy, and mean squared error (MSE)) across multiple computer vision tasks
when compared to other efficient multi-task network architecture designs, while
having only 17.8M parameters (about >5x smaller), 259 GFLOPs (as much as >5x
lower) and as much as >3.15x faster on a NVIDIA Jetson TX2 embedded processor. | Alexander Wong, Yifan Wu, Saad Abbasi, Saeejith Nair, Yuhao Chen, Mohammad Javad Shafiee | 2023-04-21T18:07:14Z | http://arxiv.org/abs/2304.11196v1 | Fast GraspNeXt: A Fast Self-Attention Neural Network Architecture for Multi-task Learning in Computer Vision Tasks for Robotic Grasping on the Edge
###### Abstract
Multi-task learning has shown considerable promise for improving the performance of deep learning-driven vision systems for the purpose of robotic grasping. However, high architectural and computational complexity can result in poor suitability for deployment on embedded devices that are typically leveraged in robotic arms for real-world manufacturing and warehouse environments. As such, the design of highly efficient multi-task deep neural network architectures tailored for computer vision tasks for robotic grasping on the edge is highly desired for widespread adoption in manufacturing environments. Motivated by this, we propose Fast GraspNeXt, a fast self-attention neural network architecture tailored for embedded multi-task learning in computer vision tasks for robotic grasping. To build Fast GraspNeXt, we leverage a generative network architecture search strategy with a set of architectural constraints customized to achieve a strong balance between multi-task learning performance and embedded inference efficiency. Experimental results on the MetaGraspNet benchmark dataset show that the Fast GraspNeXt network design achieves the highest performance (average precision (AP), accuracy, and mean squared error (MSE)) across multiple computer vision tasks when compared to other efficient multi-task network architecture designs, while having only 17.8M parameters (about \(>\)5\(\times\) smaller), 259 GFLOPs (as much as \(>\)5\(\times\) lower) and as much as \(>\)3.15\(\times\) faster on a NVIDIA Jetson TX2 embedded processor.
## 1 Introduction
Significant advances have been made in recent years to take advantage of deep neural networks for robotic grasping. In particular, multi-task learning has shown considerable promise for improving the performance of deep learning-driven vision systems for robotic grasping [3, 7, 8], where the underlying goal is to learn to perform additional tasks during the model training process. Multi-task learning has enabled not only greater precision and versatility in deep learning-driven vision systems for robotic grasping, but also enabled such systems to perform a wide range of computer vision tasks that are important for robotic grasping (see Fig. 1 for example tasks that need to be performed
Figure 1: Example multi-task outputs from Fast GraspNeXt. (a) and (b) Detected occluded objects are shown in blue and non-occluded objects are shown in red. (c) The detected center of mass of each object is shown in blue. (d) Applicability of suction grasp is labelled from high to low in red, green, and blue as a heatmap.
by such deep learning-driven vision systems for robotic grasping such as visible object mask detection, amodal object detection [1], center of mass prediction, and suction grasp heatmap generation [2]). However, while multi-task learning can greatly improve the performance of computer vision tasks for robotic grasping, high architectural and computational complexity can limit operational use in real-world manufacturing and warehouse environments on embedded devices.
Motivated to address these challenges with embedded deployment for robotic grasping in real-world manufacturing and supply chain environments, we leverage a generative network architecture search strategy with a set of architectural design constraints defined to achieve a strong balance between multi-task learning performance and embedded operational efficiency. The result of this generative network architecture search approach is Fast GraspNeXt, a fast self-attention neural network architecture tailored specifically for multi-task learning in robotic grasping under embedded scenarios.
The paper is organized as follows. Section 2 describes the methodology behind the creation of the proposed Fast GraspNeXt via generative network architecture search, as well as a description of the resulting deep neural network architecture. Section 3 describes the dataset used in this study, the training and testing setup, as well as the experimental results and complexity comparisons.
## 2 Methods
### Generative Network Architecture Search
In this paper, we take a generative network architecture search approach to creating the optimal multi-task deep neural network architecture for Fast GraspNeXt. More specifically, we leveraged the concept of generative synthesis [13], an iterative method that generates highly tailored architectural designs that satisfy given requirements and constraints (e.g., model performance targets). Generative synthesis can be formulated as a constrained optimization problem:
\[\mathcal{G}=\max_{\mathcal{G}}\mathcal{U}(\mathcal{G}(s))\quad\text{ subject to}\quad 1_{r}(G(s))=1,\ \ \forall\in\mathcal{S}. \tag{1}\]
where the underlying objective is to learn an expression \(\mathcal{G}(\cdot)\) that, given seeds \(\{s|s\in S\}\), can generate network architectures \(\{N_{s}|s\in S\}\) that maximizes a universal performance metric \(U\) (e.g., [11]) while adhering to operational constraints set by the indicator function \(1_{r}(\cdot)\). This constrained optimization is solved iteratively through a collaboration between a generator \(G\) and an inquisitor \(I\) which inspects the generated network architectures and guides the
Figure 2: Overall network architecture design for Fast GraspNeXt, which possess a self-attention neural network architecture with highly optimized macroarchitecture and microarchitecture designs for all components. Fast GraspNeXt consists of a generated self-attention backbone architecture feeding into a generated feature pyramid network architecture followed by generated head network architecture designs for multi-task learning. The numbers in brackets are channel sizes of the feature maps in the heads.
generator to improve its generation performance towards operational requirements (see [13] for details).
To build Fast GraspNeXt, we enforce essential design constraints through \(1_{r}(\cdot)\) in Eq. 1 to achieve the desired balance between i) accuracy, ii) architectural complexity, and iii) computational complexity to yield high-performance, compact, and low-footprint neural network architectures such as:
1. Encouraging the implementation of anti-aliased downsampling (AADS) [14] to enhance network stability and robustness.
2. Encouraging the use of attention condensers [12], which are highly efficient self-attention mechanisms designed to learn condensed embeddings characterizing joint local and cross-channel activation relationships for selective attention. They have been shown to improve representational performance while improving efficiency at the same time.
3. Enforce a FLOPs requirement of less than 300B FLOPs and an accuracy requirement of no lower AP across all assessable tasks than a ResNet-50 variant of the multi-task network for robotic grasping (which we call ResNet-GraspNeXt) by 0.5%.
### Network Architecture
The resulting Fast GraspNeXt network architecture design is shown in Fig. 2. It possesses a self-attention neural network architecture with highly optimized macroarchitecture and microarchitecture designs for all its components. The network architecture adheres to the constraints we imposed, with the generated backbone architecture feeding into a generated feature pyramid network architecture design followed by generated head network architecture designs for predicting the multi-task outputs: i) amodal object bounding boxes, ii) visible object masks, iii) amodal object masks, iv) occlusion predictions, v) object center of mass, vi) and suction grasp heatmap.
More specifically, the multi-scale features from the generated backbone architecture are provided as input directly to each level of the generated feature pyramid network architecture, followed by the generated bounding box head, visible mask head, amodal mask head and occlusion prediction head. Each level of the feature pyramid network are also upsampled to reach the same scale and summed as input for the center of mass head and suction grasp heatmap head.
The multi-task training loss, denoted as \(L_{mt}\), used to train Fast GraspNeXt is a weighted combination of task-specific losses and can be expressed by
\[\begin{split} L_{mt}&=l_{rpn}+\lambda_{1}l_{abox}+ \lambda_{2}l_{segm,v}+\lambda_{3}l_{segm\_a}\\ &+\lambda_{4}l_{occ}+\lambda_{5}l_{com}+\lambda_{6}l_{suc}\end{split} \tag{2}\]
where \(\lambda_{1},\lambda_{2},\ldots,\lambda_{6}\) denote task-specific weight coefficients used to balance the contribution of individual task-specific losses. The individual task-specific losses are defined as follows:
* \(l_{rpn}\): Region Proposal Network loss [9]
* \(l_{abox}\): Amodal bounding box prediction loss [1]
* \(l_{segm\_v}\): Visible mask segmentation loss [1]
* \(l_{segm\_a}\): Amodal mask segmentation loss [1]
* \(l_{occ}\): Occlusion classification loss [1]
* \(l_{com}\): Center of mass heatmap prediction loss implemented with the modified focal loss proposed by CenterNet [15]
* \(l_{suc}\): Suction grasp heatmap prediction loss implemented with pixel-wise averaged mean squared error (MSE) loss
It can be observed that the architecture design is highly heterogeneous and columnar for high architectural and computational efficiency. It can also be observed that the architecture design possesses attention condensers at different stages of the architecture for improved attentional efficacy and efficiency. Furthermore, the architecture design possesses AADS at strategic locations for greater robustness. Finally, it can be observed that the macroarchitecture for each task-specific head is unique, thus tailored around the specific balance between accuracy and efficiency for each individual task. As such, these characteristics make the Fast GraspNeXt architecture design well-suited for high-performance yet highly efficient multi-task robotic grasp applications on the edge.
## 3 Experiments
### Dataset
We evaluate the performance of the proposed Fast GraspNeXt on the MetaGraspNet [4] benchmark dataset to explore the efficacy. This large-scale robotic grasping benchmark dataset contains 217k images across 5884 scenes featuring 82 different objects. We use 60%, 20%, and 20% of the scenes for training, validation, and testing respectively. Average precision (AP) evaluation was conducted for amodal object bounding box, visible object mask, amodal object mask, and object center of mass. Occlusion accuracy evaluation was conducted to evaluate occlusion predictions, while mean squared error (MSE) evaluation was conducted to evaluate suction grasp heatmap predictions. Our experiments use the class agnostic labels which put all objects into one class category, so that it can be readily deployed in industrial scenarios with novel, unseen items.
### Training and Testing Setup
In addition to the proposed Fast GraspNeXt, we evaluated the performance of efficient multi-task network designs leveraging ResNet-50 [5], EfficientNet-B0 [10], and MobileNetV3-Large [6] as backbones paired with our multi-task network architecture design but without utilizing the generative network architecture search strategy. Both EfficientNet and MobileNetV3 are widely-used, state-of-the-art efficient backbones, making them well-suited for this comparison. Those network architectures are designated as ResNet-GraspNeXt, EfficientNet-GraspNeXt, and MobileNet-GraspNeXt, respectively.
For training, we use a base learning rate of 0.03, SGD optimizer with momentum of 0.9, and weight decay of 0.0001 for all experiments. Learning rate step decay are performed at 67% and 92% of the total epochs with gamma of 0.1. All network architectures are trained with the full image size of 1200\(\times\)1200 pixels with batch size of 2. Empirical results found that the above training strategy yielded the best performance for all tested architectures.
Inference time evaluations are executed with batch size of 1 to reflect the robotic grasping environment which prioriti lowest possible inference latency instead of potential speed benefit of batched inference. We evaluate the inference time on the NVIDIA Jetson TX2 embedded processor with 8 GB of memory, which is widely used for embedded robotics applications in manufacturing and warehouse scenarios.
### Results and Analysis
Tab. 1 shows the quantitative performance results and model complexity of the proposed Fast GraspNeXt compared to ResNet-GraspNeXt, EfficientNet-GraspNeXt, and MobileNet-GraspNeXt. We can observe that leveraging state-of-the-art efficient backbone architectures EfficientNet-B0 and MobileNetV3-Large enables noticeably faster inference time and lower architectural complexity when compared to leveraging ResNet-50 but results in
\begin{table}
\begin{tabular}{l c c c c c c c c c} \hline \hline Model & \begin{tabular}{c} Inf. Time \\ (ms) \\ \end{tabular} & \begin{tabular}{c} Amodal \\ Bbox AP \\ \end{tabular} & \begin{tabular}{c} Visible \\ Mask AP \\ \end{tabular} & \begin{tabular}{c} Amodal \\ Mask AP \\ \end{tabular} & \begin{tabular}{c} Occlusion \\ Accuracy \\ \end{tabular} & \begin{tabular}{c} Center of \\ Mass AP \\ \end{tabular} & \begin{tabular}{c} Heatmap \\ MSE \\ \end{tabular} & \begin{tabular}{c} Parameters \\ (M) \\ \end{tabular} &
\begin{tabular}{c} FLOPs \\ (B) \\ \end{tabular} \\ \hline ResNet-GraspNeXt & 3501 & 85.0\% & 84.9\% & 84.1\% & 77.2\% & 75.3\% & 0.0113 & 92.1 & 1314 \\ EfficientNet-GraspNeXt & 2972 & 84.6\% & 85.0\% & 83.8\% & 81.7\% & 82.6\% & 0.0189 & 72.0 & 1183 \\ MobileNet-GraspNeXt & 2712 & 84.3\% & 84.6\% & 83.7\% & 80.7\% & 81.2\% & 0.0104 & 70.9 & 1189 \\ Fast GraspNeXt & **1106** & **87.9\%** & **85.4\%** & **85.0\%** & **85.1\%** & **84.6\%** & **0.0095** & **17.8** & **259** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Summary of quantitative performance results on MetaGraspNet dataset and network complexity.
Figure 3: (top) Predicted suction grasp heatmaps produced by the proposed Fast GraspNeXt. (bottom) Example ground truth suction grasp heatmaps.
a noticeable drop in amodal bbox AP and amodal mask AP performance. In contrast, the proposed Fast GraspNeXt is \(>\)3.15\(\times\), \(>\)2.68\(\times\), and \(>\)2.45\(\times\) faster on the Jetson TX2 embedded processor compared to ResNet-GraspNeXt, EfficientNet-GraspNeXt, and MobileNet-GraspNeXt, respectively, while improves the performance across all test tasks. Specifically, Fast GraspNeXt improves the amodal bbox AP, visible mask AP, amodal mask AP, occlusion accuracy, center of mass AP, and averaged heatmap MSE by 2.9%, 0.4%, 0.6%, 3.4%, 2.0%, and 8.7% respectively compared to the second best results.
In terms of architectural complexity, Fast GraspNeXt is 5.2\(\times\) smaller then ResNet-GraspNeXt which has the second best amodal bbox AP and amodal mask AP, 4\(\times\) smaller then EfficientNet-GraspNeXt which has the second best visible mask AP and center of mass AP, and 4\(\times\) smaller then MobileNet-GraspNeXt. In terms of computational complexity, Fast GraspNeXt is 5.1\(\times\), 4.6\(\times\), and 4.6\(\times\) lower FLOPs than ResNet-GraspNeXt, EfficientNet-GraspNeXt, and MobileNet-GraspNeXt respectively. Example ground truth suction grasp heatmaps along with the predicted suction grasp heatmaps produced by proposed Fast GraspNeXt are shown in Fig. 3.
As such, the above experimental results demonstrated that the proposed Fast GraspNeXt achieves significantly lower architectural complexity and computational complexity while possessing improved AP across test tasks compared to designs based on state-of-the-art efficient architectures. Furthermore, these experiments demonstrated that Fast GraspNeXt achieves significantly faster inference time on the NVIDIA Jetson TX2 embedded processor, making it well-suited for robotic grasping on embedded devices in real-world manufacturing environments. Future work involves exploring this generative approach to network architecture search for other embedded robotics applications in manufacturing and warehouse scenarios.
## Acknowledgements
This work was supported by the National Research Council Canada (NRC) and German Federal Ministry for Economic Affairs and Climate Action (BMWK) under grant 01MJ21007B.
|
2307.08197 | Towards Self-Assembling Artificial Neural Networks through Neural
Developmental Programs | Biological nervous systems are created in a fundamentally different way than
current artificial neural networks. Despite its impressive results in a variety
of different domains, deep learning often requires considerable engineering
effort to design high-performing neural architectures. By contrast, biological
nervous systems are grown through a dynamic self-organizing process. In this
paper, we take initial steps toward neural networks that grow through a
developmental process that mirrors key properties of embryonic development in
biological organisms. The growth process is guided by another neural network,
which we call a Neural Developmental Program (NDP) and which operates through
local communication alone. We investigate the role of neural growth on
different machine learning benchmarks and different optimization methods
(evolutionary training, online RL, offline RL, and supervised learning).
Additionally, we highlight future research directions and opportunities enabled
by having self-organization driving the growth of neural networks. | Elias Najarro, Shyam Sudhakaran, Sebastian Risi | 2023-07-17T01:58:52Z | http://arxiv.org/abs/2307.08197v1 | # Towards Self-Assembling Artificial Neural Networks through
###### Abstract
Biological nervous systems are created in a fundamentally different way than current artificial neural networks. Despite its impressive results in a variety of different domains, deep learning often requires considerable engineering effort to design high-performing neural architectures. By contrast, biological nervous systems are grown through a dynamic self-organizing process. In this paper, we take initial steps toward neural networks that grow through a developmental process that mirrors key properties of embryonic development in biological organisms. The growth process is guided by another neural network, which we call a _Neural Developmental Program_ (\(\mathcal{NDP}\)) and which operates through local communication alone. We investigate the role of neural growth on different machine learning benchmarks and different optimization methods (evolutionary training, online RL, offline RL, and supervised learning). Additionally, we highlight future research directions and opportunities enabled by having self-organization driving the growth of neural networks.
## Introduction
The study of neural networks has been a topic of great interest in the field of artificial intelligence due to their ability to perform complex computations with remarkable efficiency. However, despite significant advancements in the development of neural networks, the majority of them lack the ability to self-organize, grow, and adapt to new situations in the same way that biological neurons do. Instead, their structure is often hand-designed, and learning in these systems is restricted to the optimization of connection weights.
Biological networks on the other hand, self-assemble and grow from an initial single cell. Additionally, the amount of information it takes to specify the wiring of a sophisticated biological brain directly is far greater than the information stored in the genome [1]. Instead of storing a specific configuration of synapses, the genome encodes a much smaller number of rules that govern how to grow a brain through a local and self-organizing process [2]. For example, the 100 trillion neural connections in the human brain are encoded by only around 30 thousand active genes. This outstanding compression has also been called the "genomic bottleneck" [2], and neuroscience suggests that this limited capacity has a regularizing effect that results in wiring and plasticity rules that generalize well.
In this paper, we take first steps in investigating the role of developmental and self-organizing algorithms in growing neural networks instead of manually designing them, which is an underrepresented research area [1, 1, 13, 14]. Even simple models of development such as cellular automata demonstrate that growth (i.e. unfolding of information over time) can be crucial to determining the final state of a system, which can not directly be calculated [15]. The grand vision is to create a system in which neurons self-assemble, grow, and adapt, based on the task at hand.
Towards this goal, we present a graph neural network type of encoding, in which the growth of a policy network (i.e. the neural network controlling the actions of an agent) is controlled by another network running in each neuron, which we call a _Neural Developmental Program_ (\(\mathcal{NDP}\)). The \(\mathcal{NDP}\) takes as input information from the connected neurons in the policy network and decides if a neuron should replicate and how each connection in the network should set its weight. Starting from a single neuron, the approach grows a functional policy network, solely based on the local communication of neurons. Our approach is different from methods like NEAT [15] that grow neural networks during evolution, by growing networks during the lifetime of the agent. While not implemented in the current \(\mathcal{NDP}\) version, this will ultimately allow the neural network of the agents to be shaped based on their experience and environment.
While indirect genome-to-phenotype encodings such as CPPN-based approaches [2] or Hypernetworks [1] have had great success, they often purposely abstracted away development and the process of self-organizational growth. However, in nature, these abilities seem essential in enabling the remarkable robustness to perturbations and unexpected changes [1, 13]. Allowing each neuron in an artificial neural network to act as an autonomous agent in a decentral
ized way similar to their biological counterpart Hiesinger (2018), could enable our AI methods to overcome some of their current limitations in terms of robustness.
Since the space of possible \(\mathcal{NDP}\) representations is large, we explore two different representations and different training methods such as evolutionary and gradient-descent based. While lacking state-of-the-art performance, our method can learn to grow networks and policies that can perform competitively, opening up interesting future work in growing and developmental deep neural networks. Our goal is to inspire researchers to explore the potential of \(\mathcal{NDP}\)-like methods as a new paradigm for self-assembling artificial neural networks. Overall, this work represents a step towards the development of more biologically inspired developmental encodings, which have the potential to overcome some of the limitations of current deep learning approaches.
## Background and Related Work
### Indirect encodings
Indirect encodings are inspired by the biological process of mapping a compact genotype to a larger phenotype and have been primarily studied in the context of neuroevolution Floreano et al. (2008) (i.e. evolving neural networks) but more recently were also optimized through gradient-descent based approaches Ha et al. (2016). In indirect encodings, the description of the solution is compressed, allowing information to be reused and the final solution to contain more components than the description itself. Even before the success of deep RL, these methods enabled solving challenging car navigation tasks from pixels alone Koutnik et al. (2013).
A highly influential indirect encoding is HyperNEAT Stanley et al. (2009). HyperNEAT employs an indirect encoding called compositional pattern producing networks (CPPNs) that _abstracts away the process of growth_ and instead describes the connectivity of a neural network through a function of its geometry; an extension called Evolvable-substrate HyperNEAT Risi and Stanley (2012) allowed neural architectures to be discovered automatically but did not involve any self-organizing process. More recently, Hypernetworks Ha et al. (2016) demonstrated that networks generating the weights of another network can also be trained end-to-end through gradient descent. Hypernetworks have been shown to be able to generate competitive convolutional neural networks (CNNs) Zhmoginov et al. (2022) and recurrent neural networks (RNNs) in a variety of tasks while using a smaller set of trainable parameters. However, neither HyperNEAT nor Hypernetworks make use of the process of development over time, which can increase the evolvability of artificial agents Kriegman et al. (2017); Bongard (2011) and is an important ingredient of biological systems Hiesinger (2021).
Developmental EncodingsDevelopmental encodings are a particular family of indirect encodings. They are abstractions of the developmental process that allowed nature to produce complex artifacts through a process of growth and local interactions between cells, ranging from the low level of cell chemistry simulations to high-level grammatical rewrite systems Stanley and Miikkulainen (2003), and neurogenesis approaches Miller (2022); Maile et al. (2022); Tran et al. (2022); Huang et al. (2023). Approaches with
Figure 1: **Neural Developmental Program approach for growing neural network. Each node state \(s\) is represented as an embedding vector. During the information aggregation phase, the graph propagates each node state \(s\) to its neighbors for \(n\) steps. Based on the updated nodes embedding \(\hat{s}_{t+n}\), the replication model —implemented as a MLP— determines which nodes will grow new nodes. Finally, if the target network is not unweighted, another MLP estimates the edge weights of each pair of nodes based on their concatenated embeddings; otherwise, edges are assigned a unitary weight. The resulting network is evaluated through an objective function, i.e. solving a task or having certain topological properties. The \(\mathcal{NDP}\) is a distributed model that operates purely on local information.**
neural networks that can grow are a largely under-explored area [1, 13, 14, 15] because these algorithms are either not expressive enough or not efficiently searchable.
Recently, cellular automata (CA) had a resurgence of interest as a model of biological development. CA are a class of computational models whose outcomes emerge from the local interactions of simple rules. Introduced by Neumann et al. (1966) as a part of his quest to build a self-replicating machine or universal constructor, a CA consist of a lattice of computing cells that iteratively update their states based exclusively on their own state and the states of their local neighbors. On a classical CA, each cell's state is represented by an integer and adjacent cells are considered neighbors. Critically, the update rule of a cellular automaton is identical for all the cells.
Neural cellular automata (NCA) differ from classical cellular automata (CA) models by replacing the CA update function with an optimized neural network [14, 15]. Recently, this approach has been extended to grow complex 3D entities such as castles, apartment blocks, and trees in a video game environment [13].
A recent method called HyperNCA, extends NCA to grow a 3D pattern, which is then mapped to the weight matrix of a policy network [16]. While working well in different reinforcement learning tasks, the mapping from the grown 3D pattern to policy weight matrix did not take the topology of the network into account. Instead of a grid-like HyperNCA approach, the method presented in this paper extends NCA to directly operate on the policy graph itself and should thus also allow more flexibility in the types of architectures that can be grown.
### Distribution-fitting approaches to evolving graphs
Previous work has explored the emerging topologies of the different growth processes [1] and shown that they can reproduce real networks by fitting the parameters of the distribution from which new nodes are sampled. In contrast to our method, the growth processes in previous network-theory approaches do not depend on the internal state of the graph, and therefore do not make use of the developmental aspect of the network to achieve the target topological properties.
### Approach: Growing Neural Networks through Neural Developmental Programs
This section presents the two different Neural Developmental Program instantiations we are exploring in this paper: (1) an evolution-based \(\mathcal{NDP}\) and (2) a differentiable version trained with gradient descent-based. While an evolutionary version allows us to more easily explore different architectures without having to worry about their differentiability, gradient descent-based architectures can often be more sample efficient, allow scaling to higher dimensions, and enable approaches such as offline reinforcement learning. Code implementations will be available soon at: [https://github.com/enajx/NDP](https://github.com/enajx/NDP).
### Evolutionary-based \(\mathcal{NDP}\)
The \(\mathcal{NDP}\) consists of a series of developmental cycles applied to an initial seeding graph; our experiments always use a seeding graph consisting of a single node or a minimal network connecting the neural network's inputs directly to its outputs. Each of the nodes of the graph has an internal state represented as \(n-\)dimensional latent vector whose values are updated during the developmental process through local communication. The node state-vectors --or embeddings-- encode the cells' states and are used by the \(\mathcal{NDP}\) to determine which nodes will duplicate to make new nodes.
Similarly to how most cells in biological organisms contain the same program in the form of DNA, each node's growth and the synaptic weights are controlled by a copy of the same \(\mathcal{NDP}\), resulting in a distributed self-organized process that incentives the reuse of information. An overview of the approach is shown in Fig. 1.
The \(\mathcal{NDP}\) architecture consists of a Multilayer Perceptron (MLP) --acting as a Graph Cellular Automata (GNCA) [12]-- which updates the node embeddings after each message-passing step during the developmental phase. Subsequently, a replication model in the form of a second MLP queries each node state and predicts whether a new node should be added; if so, a new node is connected to the parent node and its immediate neighbors. Finally, if the target network is weighted, a third MLP determines the edge weights based on the concatenation of each pair of node embeddings. The grown network can now be evaluated on the task at hand by assigning a subset of nodes as the input nodes and another subset as the output nodes. In our case, we select the first --and last-- rows of the adjacency matrix representing the network to act as input -- and output-- nodes, respectively. During evaluation the activations of the nodes are scalars (that is, \(\mathbb{R}^{1}\) instead of the \(\mathbb{R}^{n}\) vectors used during development), and all node activations are initialized to zero.
We refer to the \(\mathcal{NDP}\) as the set of these MLPs which are identical for each cell in the policy network; in order to keep the number of parameters of the \(\mathcal{NDP}\) low, the reported experiments make use of small MLPs with a single hidden layer. However, it's worth noticing that because the \(\mathcal{NDP}\) is a distributed model (i.e. the same models are being applied to every node), the number of parameters is constant with respect to the size of the graph in which it operates. Therefore, any neural network of arbitrary size or architecture could be used, provided that it was deemed necessary to grow a more complex graph. The \(\mathcal{NDP}\)'s neural networks can be trained with any black-box optimization algorithm to satisfy any objective function. In this paper, we demonstrate how the ap
proach allows to grow neural networks capable of solving reinforcement learning and classification tasks, or exhibiting some topological properties such as small-worldness. The pseudocode of the approach is detailed in Algorithm 1.
```
Input: Replication model \(\mathcal{R}\), Graph Cellular Automata \(\mathcal{GNC}\mathcal{A}\), Weight update model \(\mathcal{W}\), number of developmental cycles \(\mathcal{C}\), pruning threshold \(\mathcal{P}\), number of training generations \(\mathcal{T}\), training hyper-parameters \(\Omega\) Output: Developmental program producing graph \(\mathcal{G}\) that minimise/maximise \(\mathcal{F}\)
1 Co-evolve or sample random embedding \(E_{N=0}\) for the initial node \(N_{0}\) of \(\mathcal{G}\);
2forgenerationin\(\mathcal{T}\)do
3fordevelopmental cyclein\(\mathcal{C}\)do
4 Compute network diameter \(\mathtt{D}\);
5 Propagate nodes states \(E_{N}\) via graph convolution \(\mathtt{D}\) steps;
6 Replication model \(\mathcal{R}\) determines nodes in growing state;
7 New nodes are added to each of the growing nodes and their immediate neighbors;
8 New nodes' embeddings are defined as the mean embedding of their parent nodes.
9ifweightednetworkthen
10 Weight update model \(\mathcal{W}\) updates
11 connectivity for each pair of nodes based on their concatenated embeddings;
12ifpruningthen
13 Edges with weights below pruning threshold \(\mathcal{P}\) are removed;
14 Evaluate objective \(\mathcal{F}\) of grown graph \(\mathcal{G}\);
15 Use \(\mathcal{F}(G)\) to guide optimisation;
```
**Algorithm 1**Neural Developmental Program \(\mathcal{NDP}\): non-differentiable version
### Gradient-based \(\mathcal{NDP}\)
The gradient-based growth process is similar to the evolutionary approach, albeit with some additional constraints due to its requirement of complete differentiability in the process. In contrast to the evolutionary approach, the grown networks are exclusively feedforward networks, where information is iteratively transmitted through message passing via the topologically sorted nodes. Each node has a bias value, and an activation that is applied to when the incoming nodes' information is aggregated, similar to the node behavior in e.g. NEAT [20].
Like in the evolutionary approach, cells' states are represented as vectors. However, instead of all values of each cell's state vector being treated as intractable black-boxes for the network to store information, here each first and second elements of the vectors have pre-defined roles: the first element represents the bias value and the second encodes the activation. The remaining encode hidden states for each cell, capturing temporal information used to guide the developmental process. These cells are passed into a message-passing network, implemented as a graph Convolution [17], where a neighborhood of cell embeddings, characterized as being 1 edge away are linearly projected and added to create new embeddings. In addition to using a message passing network to update nodes, we use a trainable small 2-layer MLP, with tanh activation, to predict edge weights using pairs of (source, destination) nodes. The message-passing network is composed of a GraphConv layer that outputs vectors of size 32, followed by a Tanh activation, followed by a linear layer that maps the size vectors to the original cell embeddings.
In order to add more nodes, we treat a channel in each cell as a _replication probability_, which is used to sample cells and connect to a random node further into the network. This process happens every other growth step.
Detailed replication process: (1) A replication network, implemented as a separate graph convolution, is applied on cells to output replication probabilities. (2) A cell is sampled from these probabilities and is passed into a perturbation network to get a new cell, and an incoming edge is connected from the parent to the new cell. An outgoing edge is connected to a random child (found further in the network). After the new node is added to the network, we update the edges using an MLP that takes in incoming node and outgoing node pairs and outputs a new edge weight.
We initialize the starting network by fully connecting trainable input cell embeddings and output cell embeddings, which we found to work better for our gradient-based \(\mathcal{NDP}\) than starting with a single node. For example, if input = 4 and output = 2, then each input node will be connected to an output node, resulting in 4\(\times\)2 initial edges. The pseudocode of this approach is detailed in Algorithm 2.
## Experiments
We test the \(\mathcal{NDP}\) approach on generating networks for classification tasks such as _MNIST_, boolean gates such as _XOR_ gate and reinforcement learning tasks with both continuous and discrete action spaces. The RL tasks include _CartPole_, a classical control task with non-linear dynamics, and _LunarLander_, a discrete task where the goal is to smoothly land on a procedurally generated terrain. We also tackle an offline RL task using Behavioral Cloning (BC) [17], which is _HalfCheetah_, a canine-like robot task.
The different environments are shown in Fig. 2. The _CartPole_ environment provides observations with 4 dimensions, _LunarLander_ has 8, MNIST has 64, and HalfCheetah has 17. _CartPole_ has 2 actions, _LunarLander_ has 4 actions, _MNIST_ has 10 classes to predict, and _HalfCheetah_ has a continuous action of dimension 7.
### Evolutionary Optimization Details
We use CMA-ES -- Covariance Matrix Adaptation Evolution Strategy -- [1], a black-box population-based optimisation algorithm to train the \(\mathcal{NDP}\). Evolutionary strategies (ES) algorithms have been shown to be capable of finding high-performing solutions for reinforcement learning tasks, both directly optimising the policy weights [10], and with developmental encodings [10]. Black-box methods such as CMA-ES have the advantage of not requiring to compute gradients and being easily parallelizable.
Experiments have been run on a single machine with a _AMD Ryzen Threadripper 3990X_ CPU with \(64\) cores. We choose a population size of \(512\), and an initial variance of \(0.1\). Finally, we employ an early stopping method which stops and resets training runs that show poor performance after a few hundred generations.
### Differentiable Optimization Details
We use the Pytorch Geometric library to implement our \(\mathcal{NDP}\) as well as our grown networks, enabling us to backpropagate a loss using predictions from the grown networks all the way back to the parameters of the \(\mathcal{NDP}\). We are also able to leverage GPUs for the forward and backward passes.
Experiments have been run on a single machine with a _NVIDIA 2080ti_ GPU. We use the Adam Optimizer [11] to optimize the \(\mathcal{NDP}\)'s trainable parameters.
Online RL with PPOBecause we can take advantage of backpropagation with the differentiable \(\mathcal{NDP}\) approach, we can utilize reinforcement learning algorithms, specifically Proximal Policy Optimization (PPO) [12], to grow optimal policies. Implementations of PPO typically use separate networks / shared networks for critic and actor heads. In our implementations, we simply treat the critic output as a separate node that is initially fully connected to all the input nodes. In our implementation, we use a learning rate of 0.0005, an entropy coefficient of 0.001, and optimize for 30 steps after each rollout is collected. We train for 10,000 rollouts and record the average reward from 10 episodes in Tables (a)a and (b)b.
Offline RL with Behavioral CloningIn Offline RL, instead of gathering data from an environment, we only have access to a dataset of trajectories. This setting is challenging but also easier because we can avoid the noisy training process of Online RL. In our approach, we utilize Behavioral Cloning (BC) to optimize our \(\mathcal{NDP}\) to grow high-performing policies. We use a learning rate of 0.0001 and a batch size of 32 observations. We train for 10000 rollouts and record the average reward from 10 episodes in Table (b)b.
Supervised LearningWe evaluate the supervised learning capabilities of our differentiable \(\mathcal{NDP}\) with the classic _MNIST_ task, where a small (8\(\times\)8) image is classified as a digit between 0-9. We use a learning rate of 0.001 and a batch size of 32 observations. We train for 10000 iterations and record the test accuracy in Table (a)a.
Fruchterman-Reingold force-directed algorithm. Training curves are shown in Fig. 3.
**Growing policy network for RL tasks.** We trained a \(\mathcal{NDP}\) with 162 parameters for the CartPole tasks, in which it has to grow a policy network controlling the force applied to a pole to keep it balanced. It grew an undirected network with 10 nodes and 33 weighted edges that reached a reward of \(500\pm 0\) over 100 rollouts (Fig. 3). This score is considered as solving the task. The growth process of the network from a single node to the final policy can be seen in Fig. 5.
Similarly, we trained a \(\mathcal{NDP}\) to grow a network policy to solve the Lunar Lander control task (Fig. 4, right). In this case, a \(\mathcal{NDP}\) with 868 trainable parameters grew an undirected network policy with 16 nodes and 78 weighted edges. Over 100 rollouts, the mean reward obtained is \(116\pm 124\). Although the resulting policy controller could solve the task in many of the rollouts, the stochasticity of the environment (e.g. changing the landing surface at each instantiation) resulted in a high reward variance. This means that the grown network did not quite reach the 200 reward over 100 rollouts score that is considered as the task's solving criterion.
**Growing small-world topologies.** Real networks found in nature such as biological neural networks, ecological networks or social networks are not simple random networks but rather their graphs have very specific topological properties. In order to analyze the ability of the neural developmental program to grow complex graph motifs, we train the \(\mathcal{NDP}\) to grow a small-world network (Watts and Strogatz, 1998). A small-world network is characterised by a small average shortest path length but a relatively large clustering coefficient. We can quantify this with two metrics \(\sigma=\frac{C/C_{r}}{L/L_{r}}\) and \(\omega=\frac{L_{r}}{L}-\frac{C}{C_{l}}\), where \(C\) and \(L\) are respectively the average clustering coefficient and average shortest path length of the network. \(C_{r}\) and \(L_{r}\) are respectively the average clustering coefficient and average shortest path length of an equivalent random graph. A graph is commonly classified as small-world if \(\sigma>1\) or, equivalently, \(\omega\approx 0\).
We show that \(\mathcal{NDP}\) technique can grow a graph with small-world coefficients are \(\sigma\approx 1.27\) and \(\omega\approx-1.11^{-16}\), hence satisfying the small-worldness criteria. An example network is shown in Fig. 6. While these results are promising, further experiments are required --notably on bigger graphs-- to investigate with solid statistical significance the potential of the method to grow graphs with arbitrary topological properties.
## Gradient-Based Results
We evaluate the differentiable \(\mathcal{NDP}\) by comparing models that are trained and tested on different numbers of growth steps ("Growth Steps" column in Table 1). It seems that for most tasks, after a certain number of growth steps, the grown network's performance can deteriorate, as policies do not really benefit from more complexity. This could also be due to the simplicity constraint of grown architectures, making it unable to take advantage of new nodes as the networks get larger. Automatically learning when to stop growing will be
Figure 4: Grown networks solving XOR gate task (left), and Lunar Lander task (right). Red nodes behave as sensory neurons, white nodes are interneurons, and blue ones are the _output_ neurons that determine the actions of the cartpole.
Figure 3: Fitness during evolution on the XOR, LunarLander and CartPole tasks. Gray areas show standard deviation at each generation of the CMA-ES sampled solutions.
Figure 2: Test domains in this paper include both reinforcement and supervised tasks.
an important addition to the \(\mathcal{NDP}\) approach.
The differentiable \(\mathcal{NDP}\) reaches comparable performance to the evolutionary-based version on CartPole (Table 0(a)) and LunarLander (Table 0(b)). An example of the growth steps for the LunarLander tasks is shown in Figure 7. In the offline RL setting, the NDP is able to get a mean reward of 29 on the HalfCheetah task (Table 0(b)), which is satisfactory but lower compared to the performance of 43.1 achieved by behavioral cloning in (Chen et al., 2021).
We are also able to scale up to larger networks for tasks like MNIST, which uses an 8\(\times\)8 image and reaches a test accuracy of 91% (Table 0(a)). The sequence of an MNIST network growing is shown in Figure 8.
## Discussion and Future Work
We introduced the idea of a neural developmental program and two instantiations of it, one evolutionary-based and one gradient descent. We showed the feasibility of the approach in continuous control problems and in growing topologies with particular properties such as small-worldness. While the approach is able to solve these simple domains, many future work directions remain to be explored.
For example, the current \(\mathcal{NDP}\) version does not include any activity-dependent growth, i.e. it will grow the same network independently of the incoming activations that the agent receives during its lifetime. However, biological nervous systems often rely on both activity and activity-independent growth; activity-dependent neural development enables biological systems to shape their nervous system depending on the environment. Similar mechanisms also form the basis for the formation of new memories and learning. In the future, we will extend the \(\mathcal{NDP}\) with the ability to also incorporate activity-dependent and reward-modulated growth and adaptation.
While a developmental encoding offers the possibility to encode large networks with a much smaller genotype, the
\begin{table}
\end{table}
Table 1: **Differentiable NDP: Online RL Results. Mean reward is calculated over 10 test episodes after 10,000 rollouts were collected. Networks are trained with a specific number of growth steps, as shown in the “growth steps” column.**
Figure 5: Developmental growth of the network capable of solving the Cart Pole balancing task. The network starts as a single node and grows to a network of size 2, 4, 5, and finally 10 neurons and 33 weighted edges after 4 growth cycles. Red nodes behave as sensory neurons, white nodes as interneurons, and blue ones act as the _output_ neurons that determine the actions of the cartpole. The vector displayed above the neurons are the node embeddings which represent the state of each node during the growth process.
Figure 6: Grown Small-World network. In this experiment, the \(\mathcal{NDP}\) seeks to maximise the coefficients used to capture the small-worldness criteria of a graph. Unlike the networks grown to act as policies, this network is unweighted.
\(\mathcal{NDP}\) in this paper are in fact often larger than the resulting policy networks. However, by running the developmental process longer, it is certainly possible to ultimately grow policy networks with a larger number of parameters than the underlying \(\mathcal{NDP}\). However, as the results in this paper suggest, growing larger policy networks than necessary for the tasks can have detrimental effects (Table 0(b)), so it will be important to also learn when to stop growing. The exact interplay between genome size, developmental steps, and task performance constitutes important future work.
We will additionally extend the approach to more complex domains and study in more detail the effects of growth and self-organization on the type of neural networks that evolution is able to discover. \(\mathcal{NDP}s\) offer a unifying principle that has the potential to capture many of the properties that are important for biological intelligence to strive (Versace et al., 2018; Kudithipudi et al., 2022). While innate structures in biological nervous systems have greatly inspired AI approaches (e.g. convolutional architectures being the most prominent), how evolution discovered such wiring diagrams and how they are grown through a genomic bottleneck are questions rarely addressed. In the future, \(\mathcal{NDP}s\) could consolidate a different pathway for training neural networks and lead to new methodologies for developing AI systems, beyond training and fine-tuning.
## Acknowledgments
This project was supported by a GoodAI Research Award and a European Research Council (ERC) grant (GA no. 101045094, project "GROW-AI")
\begin{table}
\end{table}
Table 2: **Differentiable \(\mathcal{NDP}\)**: Supervised Learning and Offline RL tasks. Test accuracy for MNIST calculated after 10,000 epochs. Mean reward for HalfCheetah calculated over 10 test episodes after 10000 epochs.
Figure 8: **Differentiable \(\mathcal{NDP}\)**: MNIST network growth over 64 steps.
Figure 7: **Differentiable \(\mathcal{NDP}\)**: Lunar Lander Network policy growth over 64 steps. Red nodes are input nodes, blue nodes are output nodes, white nodes are hidden nodes. |
2302.12711 | FG-SSA: Features Gradient-based Signals Selection Algorithm of Linear
Complexity for Convolutional Neural Networks | Recently, many convolutional neural networks (CNNs) for classification by
time domain data of multisignals have been developed. Although some signals are
important for correct classification, others are not. When data that do not
include important signals for classification are taken as the CNN input layer,
the calculation, memory, and data collection costs increase. Therefore,
identifying and eliminating nonimportant signals from the input layer are
important. In this study, we proposed features gradient-based signals selection
algorithm (FG-SSA), which can be used for finding and removing nonimportant
signals for classification by utilizing features gradient obtained by the
calculation process of grad-CAM. When we define N as the number of signals, the
computational complexity of the proposed algorithm is linear time O(N), that
is, it has a low calculation cost. We verified the effectiveness of the
algorithm using the OPPORTUNITY Activity Recognition dataset, which is an open
dataset comprising acceleration signals of human activities. In addition, we
checked the average 6.55 signals from a total of 15 acceleration signals (five
triaxial sensors) that were removed by FG-SSA while maintaining high
generalization scores of classification. Therefore, the proposed algorithm
FG-SSA has an effect on finding and removing signals that are not important for
CNN-based classification. | Yuto Omae, Yusuke Sakai, Hirotaka Takahashi | 2023-02-23T05:19:03Z | http://arxiv.org/abs/2302.12711v1 | FG-SSA: Features Gradient-based Signals Selection Algorithm of Linear Complexity for Convolutional Neural Networks
###### Abstract
Recently, many convolutional neural networks (CNNs) for classification by time domain data of multisignals have been developed. Although some signals are important for correct classification, others are not. When data that do not include important signals for classification are taken as the CNN input layer, the calculation, memory, and data collection costs increase. Therefore, identifying and eliminating nonimportant signals from the input layer are important. In this study, we proposed features gradient-based signals selection algorithm (FG-SSA), which can be used for finding and removing nonimportant signals for classification by utilizing features gradient obtained by the calculation process of grad-CAM. When we define \(n_{\text{s}}\) as the number of signals, the computational complexity of the proposed algorithm is linear time \(\mathcal{O}(n_{\text{s}})\), that is, it has a low calculation cost. We verified the effectiveness of the algorithm using the OPPORTUNITY Activity Recognition dataset, which is an open dataset comprising acceleration signals of human activities. In addition, we checked the average 6.55 signals from a total of 15 acceleration signals (five triaxial sensors) that were removed by FG-SSA while maintaining high generalization scores of classification. Therefore, the proposed algorithm FG-SSA has an effect on finding and removing signals that are not important for CNN-based classification.
_Impact Statement_--Recently, it has become possible to measure various signals, e.g., electroencephalogram, electrocardiogram, acceleration/gyro, ambient signals, and others. This has led to the development of many artificial intelligences for classification using multiple signals as input data. However, some of the multiple signals are not necessary for class estimation. The such signals increase memory resources, computation time, data measurement cost, and using artificial intelligence cost. Therefore, it is better to remove signals that are not necessary for class estimation from the input layer of the artificial intelligence. Therefore, in this study, we devised an algorithm to remove them. By applying this algorithm to a artificial intelligence that performs class estimation from multiple signals, useless signals are removed and a lightweight model can be constructed.
Convolutional neural network, signal importance, signal selection algorithm
## I Introduction
Recently, many convolutional neural networks (CNNs) have been developed for classification in the time domain of signals [1, 2, 3, 4]. Although these studies used all signals, signals that are not important for correct classification may be included in the CNN input layer. These signals worsen classification accuracy, and increase calculation costs, required memory, and data collection costs. Therefore, finding and removing nonimportant signals from the CNN input layer and creating a classification model for the minimum signals possible are crucial. However, many CNNs use all signals [5, 4, 6] or manually select signals [7, 8].
We can visually find nonimportant signals using grad-CAM embedded in CNNs. Grad-CAM [9] is a method for determining the activated region on input data, and it was proposed by improving the CAM [10]. The method is primarily used to input image data [11, 12, 13, 14, 15]. Cases of applying grad-CAM to CNNs that input time domain data of signals are continuously increasing. For example, classification of the sleep stages [16], prognostication of comatose patients after cardiac arrest [17], classification of schizophrenia and healthy subjects [18], and classification of motor imagery [19] are performed using electroencephalography (EEG) signal(s). Electrocardiogram (ECG) signals are used to detect nocturnal hypoglycemia [20] and predict 1-year mortality [21] have been reported. Acceleration signals have been used to detect hemiplegic gait [22] and human activity recognition [23].
From these studies, we visually find nonimportant signals for correct classification by applying grad-CAM to CNN, inputting the time domain of the signals. However, because one grad-CAM for one input data is generated, observing all of them and finding nonimportant signals is extremely difficult. Therefore, we propose features gradient-based signals selection algorithm (FG-SSA), which can be used to find and remove nonimportant signals from a CNN input layer by utilizing features gradient obtained by the calculation process of grad-CAM. The algorithm provides a signal subset consisting of only important signals. When we define \(n_{\text{s}}\) as the number of all signals, the computational complexity of the proposed algorithm is linear order \(\mathcal{O}(n_{\text{s}})\), that is, FG-SSA has a low calculation cost.
Kim [24] has proposed a group lasso-based algorithm for signal selection. Although this is an effective method, visual insights into the results are difficult because grad-CAM is not used in the calculation process. By contrast, by using the proposed algorithm FG-SSA, we can visually determine the reason the removed signals are not important.
## II Proposed method
### _Specific problem for classification_
We consider a situation in which the task is to estimate a class \(c\) belonging to class set \(\mathbf{C}\) by CNNs from the measurement data of the signal set \(\mathbf{S}\) of size \(n_{\text{s}}\). Some \(n_{\text{s}}\) signals are important for classification, whereas others are not. Therefore, finding a signal subset \(\mathbf{S}_{\text{use}}\) that are removed the nonimportant signals from all signal sets \(\mathbf{S}\) is crucial. In this study, we provide an algorithm for finding such a subset of signals \(\mathbf{S}_{\text{use}}\subseteq\mathbf{S}\). The applicable targets of the proposed method are all tasks of solving classification problems using CNNs inputting the time domain of multisignals. For an easy understanding of the principle of the proposed method, we set a specific classification problem and explain the proposed algorithm.
"OPPORTUNITY Activity Recognition" is the dataset for activity recognition and it is used in "Activity Recognition Challenge" held by IEEE in 2011 [25, 26]. We regard the dataset as reliable because it is used for the performance evaluation of machine learning in some studies [27, 28]. The dataset contains data on multiple inertial measurement units, 3D acceleration sensors, ambient sensors, 3D localization information, etc. Four subjects performed a natural execution of daily activities. The activity annotations include locomotions (e.g., sitting, standing, walking) and left- and right-hand actions (e.g., reach, grasp, release, etc.). Details of the dataset are described in [25, 26].
In this study, we used five triaxial acceleration sensors from all the measurement devices (sampling frequency: 32 [Hz]). Attachment points of sensors on the humans body are "back," "right arm," "left arm," "right shoe," and "left shoe." The total number of signals was 15, because we adopted five triaxial sensors (\(5\times 3=15\)). We adopted data splitting using the sliding window method with window length \(w=60\) and sliding length \(60\). One signal length was approximately 2 s, because the sampling frequency was 32 [Hz]. Searching for the optimal window length size is important because it is a hyperparameter that affects the estimation accuracy [29, 30]. However, because the main objective of this study was to provide a signal-selection algorithm, we did not tune the window length size.
Next, we labeled the motion class label for each dataset based on human activity. The class labels are combinations of locomotions ("Stand," "Walk," "Sit," and "Lie") and three hands activity ("R": moving right hand, "L": moving left hand, and "N": not moving hands). For example, the class label "Sit R" refers to the sitting and right-hand motions.
Table I lists the results of applying the described procedures to all the data. This indicates that the data size of the left-hand motion is small. We consider that nearly all subjects were right-handed (notably, we could not find a description of the subjects' dominant arm in the explanation of the OPPORTUNITY dataset). Moreover, data belonging to Lie R and L are absent. Therefore, these classes were removed from the estimation task; that is, the total number of classes was 10.
Subsequently, we randomly split all the data into a training dataset (80%) and a test dataset (20%). Moreover, we assigned 20% of the training dataset to the validation dataset. The training, validation, and test datasets were independent because we adopted the sliding window method for the same window and slide length (60 steps).
We define the signal set \(\mathbf{S}\), which has 15 elements, and the class set \(\mathbf{C}\), which has 10 elements, as follows:
\[\mathbf{S}=\{\text{Back X},\text{Back Y},\text{Back Z},\] \[\text{Right arm X},\text{Right arm Y},\text{Right arm Z},\] \[\text{Left arm X},\text{Left arm Y},\text{Left arm Z},\] \[\text{Right shoe X},\text{Right shoe Y},\text{Right shoe Z},\] \[\text{Left shoe X},\text{Left shoe Y},\text{Left shoe Z}\}, \tag{1}\] \[\mathbf{C}=\{\text{Stand N},\text{Stand L},\text{Stand R},\] \[\text{Walk N},\text{Walk L},\text{Walk R},\] \[\text{Sit N},\text{Sit L},\text{Sit R},\text{Lie N}\}. \tag{2}\]
In other words, CNNs solve 10 classification problems from 15 multisignals. Moreover, we provide an algorithm for removing nonimportant signals while maintaining the estimation accuracy. Although the sets \(\mathbf{S}\) and \(\mathbf{C}\) represent acceleration signals and human activities, respectively, the proposed algorithm can be used for other diverse signals, such as EEG, ECG, and others.
### _Class estimation_
The CNN structure for class estimation is shown in Figure 1. The data for the input layer are in the form of a matrix \(w\times n_{\text{s}}\). \(w\) is the window length and \(n_{\text{s}}=|\mathbf{S}|\) is the number of signals. In the case of Subsection II-A, the input layer size is a matrix of \(60\times 15\).
Subsequently, the input data are convoluted using kernel filters of the time-directional convolution size \(s_{\text{c}}\). The number of generated feature maps is \(n_{\text{f}}\) because the number of filters is \(n_{\text{f}}\). The reason for adopting only time-directional convolution is to avoid mixing a signal and others in the convolution process. The input data are convoluted by these \(n_{\text{c}}\) convolution layers, and the CNN generates the feature maps shown in the extracted feature maps in Figure 1. Subsequently, the CNN generates the output vector using some fully connected layers
and the SoftMax function. We define the output vector \(\mathbf{y}\) as follows:
\[\mathbf{y}=[y_{c}]\in\mathbb{R}^{|\mathbf{C}|},\ c\in\mathbf{C},\ \sum_{c\in\mathbf{C}}y_{c}=1. \tag{3}\]
The estimation class \(c^{\prime}\) is
\[c^{\prime}=\operatorname*{argmax}_{c\in\mathbf{C}}\ \{y_{c}|c\in\mathbf{C}\}. \tag{4}\]
Herein, we only define the output vector \(\mathbf{y}\) because it appears in the grad-CAM definition. We explain grad-CAM for time domain signals in the next subsection.
### _Time-directional grad-CAM_
We define the vertical size of the feature map before the fully connected layer as \(s_{\mathrm{f}}\), as shown in Figure 1 "Extracted feature maps." Let us denote the \(k\)th feature map of signal \(s\) as
\[\mathbf{f}^{s,k}=[f_{1}^{s,k}\ \ f_{2}^{s,k}\ \ \cdots\ \ f_{s_{\mathrm{f}} }^{s,k}]^{\top}\in\mathbb{R}^{s_{\mathrm{f}}},\] \[s\in\mathbf{S},\ k\in\{1,\cdots,n_{\mathrm{f}}\}. \tag{5}\]
In the case of CNNs for image-data-based classification, the form of feature maps is a matrix. However, in the case of CNNs consisting of time-directional convolution layers, the form of the feature maps is a vector. We define the effect of the feature map \(\mathbf{f}^{s,k}\) on the estimation class \(c^{\prime}\) as
\[\alpha_{c^{\prime}}^{s,k}=\frac{1}{s_{\mathrm{f}}}\sum_{j=1}^{s_{\mathrm{f}} }\frac{\partial y_{c^{\prime}}}{\partial f_{j}^{s,k}}, \tag{6}\]
Then, we can apply the grad-CAM of signal \(s\) to estimation class \(c^{\prime}\) in the vector form of
\[\mathbf{Z}_{c^{\prime}}^{s}=\mathrm{ReLU}\Big{(}\frac{1}{n_{\mathrm{f}}}\sum_{k=1 }^{n_{\mathrm{f}}}\alpha_{c^{\prime}}^{s,k}\mathbf{f}^{s,k}\Big{)},\ \ \mathbf{Z}_{c^{\prime}}^{s}\in\mathbb{R}_{\geq 0}^{s_{ \mathrm{f}}}. \tag{7}\]
The activated region of each signal can be understood by calculating \(\mathbf{Z}_{c^{\prime}}^{s}\) for all signals \(\forall s\in\mathbf{S}\).
In this paper, we refer to \(\mathbf{Z}_{c^{\prime}}^{s}\) as "time-directional grad-CAM" because it is calculated by the summing partial differentiations of time direction. This was defined by a minor change in the basic grad-CAM for image data [9]. In the case of the basic grad-CAM [9], the CNN generates one grad-CAM for one input data. By contrast, in the case of time-directional grad-CAM, CNN generates grad-CAMs as many as the number of signals \(n_{\mathrm{s}}\) for one input data.
Figure 2 shows the examples of \(\mathbf{Z}_{c^{\prime}}^{s}\) calculated using the CNN described in Section IV. From top to bottom, these results correspond to \(c^{\prime}=\operatorname{Stand}\operatorname{N}\operatorname{Stand} \operatorname{L}\operatorname{,Stand}\operatorname{R}\), and Walk N. We can determine the signals that are important by viewing the time-directional grad-CAM shown in Figure 2. For example, signals from the left arm and left shoe are not used for estimating the Stand N class. Moreover, left arm signals are not used for the estimation of the Stand R class. Therefore, the time-directional grad-CAM is effective for finding nonimportant signals.
### _Signals importance index_
Although we can find nonimportant signals by viewing time-directional grad-CAM, the result varies for each input data. Therefore, when the data size is large, viewing all the
Fig. 1: CNN structure for 10 human activities recognition from 15 acceleration signals. We applied the proposed algorithm to this structure.
grad-CAMs is difficult. Herein, we quantify the importance of signal \(s\) for classification based on \(\alpha_{c^{\prime}}^{s,k}\) defined in Equation 6.
Here, we denote the input dataset of size \(n_{\text{dat}}\) as
\[\mathbf{X}=\{\mathbf{X}_{i}|i=1,\cdots,n_{\text{dat}}\},\ \ \mathbf{X}_{i}\in\mathbb{R}^{w \times n_{s}}. \tag{8}\]
The size of \(i\)th input data \(\mathbf{X}_{i}\) is \(w\times n_{\text{s}}\), which is the window length \(w\) and number of signals \(n_{\text{s}}\). When we define the input dataset of estimation class \(c^{\prime}\in\mathbf{C}\) as \(\mathbf{X}_{c^{\prime}}\), we can represent the input dataset \(\mathbf{X}\) as
\[\mathbf{X}=\bigcup_{c^{\prime}\in\mathbf{C}}\mathbf{X}_{c^{\prime}}. \tag{9}\]
Using the set \(\mathbf{X}_{c^{\prime}}\), we define the importance of the signal \(s\in\mathbf{S}\) to the estimation class \(c^{\prime}\in\mathbf{C}\) as
\[L^{s}(\mathbf{X}_{c^{\prime}})=\frac{1}{|\mathbf{X}_{c^{\prime}}|}\sum_{\mathbf{X}_{i}\in \mathbf{X}_{c^{\prime}}}g_{c^{\prime}}^{s}(\mathbf{X}_{i}), \tag{10}\]
where
\[g_{c^{\prime}}^{s}(\mathbf{X}_{i})=\frac{1}{n_{\text{f}}}\sum_{k=1} ^{n_{\text{f}}}\beta_{c^{\prime}}^{s,k}(\mathbf{X}_{i}),\] \[\beta_{c^{\prime}}^{s,k}(\mathbf{X}_{i})=\begin{cases}\alpha_{c^{ \prime}}^{s,k}(\mathbf{X}_{i}),\ \ \text{if}\ \alpha_{c^{\prime}}^{s,k}(\mathbf{X}_{i})\geq 0\\ 0,\ \ \text{otherwise}\end{cases},\] \[\mathbf{X}_{i}\in\mathbf{X}_{c^{\prime}}. \tag{11}\]
In addition, \(\alpha_{c^{\prime}}^{s,k}(\mathbf{X}_{i})\) is \(\alpha_{c^{\prime}}^{s,k}\) of the input data \(\mathbf{X}_{i}\) to grad-CAM, and \(c^{\prime}\) is the estimated class. Therefore, \(L^{s}(\mathbf{X}_{c^{\prime}})\) represents the importance of signal \(s\) to class \(c^{\prime}\) based on the grad-CAM. Notably, to extract the positive effect on classification, we ignore terms with negative partial derivatives, as shown in Equation 11. Moreover, using \(L^{s}(\mathbf{X}_{c^{\prime}})\), we can obtain the matrix
\[\mathbf{I}_{\text{mat}}(\mathbf{X})=[L^{s}(\mathbf{X}_{c^{\prime}})]\in \mathbb{R}_{\geq 0}^{|\mathbf{S}|\times|\mathbf{C}|}\] \[s\in\mathbf{S},c^{\prime}\in\mathbf{C}. \tag{12}\]
We refer to \(\mathbf{I}_{\text{mat}}(\mathbf{X})\) as the "signals importance matrix (SIM)" because the matrix comprises the importance of all signals and classes using the input dataset \(\mathbf{X}\). We can understand the effect of each signal to all classes by calculating and viewing SIM \(\mathbf{I}_{\text{mat}}(\mathbf{X})\).
Although \(\mathbf{I}_{\text{mat}}(\mathbf{X})\) includes important information, summarizing the SIM is necessary to find signals that are not important to all classes. Therefore, by calculating the summation of the row values of SIM, we denote the importance of signal \(s\) as
\[I^{s}(\mathbf{X})=\frac{1}{|\mathbf{C}|}\sum_{c^{\prime}\in\mathbf{C}}I_{ \text{mat}}^{s,c^{\prime}}(\mathbf{X}), \tag{13}\]
where \(I_{\text{mat}}^{s,c^{\prime}}(\mathbf{X})\) is the value of row \(s\) and column \(c^{\prime}\). By calculating \(I^{s}(\mathbf{X})\) for all signals \(s\), we obtain the vector as
\[\mathbf{I}_{\text{vec}}(\mathbf{X})=[I^{s}(\mathbf{X})]\in\mathbb{R}_{\geq 0}^{|\mathbf{S}|}. \tag{14}\]
We refer to \(\mathbf{I}_{\text{vec}}(\mathbf{X})\) as the "signals importance vector (SIV)" because it is the vector that consists of the signal importance.
SIM and SIV are shown in Figure 3. Examples were calculated using the CNN of condition A described in Section IV (see condition A in Section IV). The result of SIM (columns 1 to 10 in Figure 3) includes various important information, for example, the signals Back Z and Right arm X are important for estimating the class Walk R. Moreover, by viewing SIV (the column 11 in Figure 3), we can identify the signals that are important for all classes.
Fig. 2: Examples of time-directional grad-CAMs of 15 acceleration signals for four estimation classes (Stand N, Stand L, Stand R, and Walk N) calculated by the CNN of condition A described in Section IV. The red color represents high activation and the dark blue represents low activation.
From SIV, we denote the minimum important signal \(s_{\min}\) and maximum signal \(s_{\max}\) as
\[(s_{\min},\ s_{\max})=\Big{(}\underset{s\in\mathbf{S}}{\operatorname{ argmin}}\,I^{s}(\mathbf{X}),\ \underset{s\in\mathbf{S}}{\operatorname{argmax}}\,I^{s}(\mathbf{X})\Big{)}. \tag{15}\]
We expect to maintain the estimation accuracy even when removing \(s_{\min}\) because it is a minimum important signal. By contrast, when we remove \(s_{\max}\) and re-learn the CNN, we expect the accuracy to decrease, because it is the most important signal.
### _Signals Selection Algorithm_
In this study, we proposed an algorithm to find a desirable signal subset \(\mathbf{S}_{\rm use}\subseteq\mathbf{S}\) by removing nonimportant signals. The proposed method is presented in Algorithm 1. The main inputs to the algorithm are the training dataset \(\mathbf{X}_{\rm train}\), validation dataset \(\mathbf{X}_{\rm valid}\), and the input signal set \(\mathbf{S}\). To avoid data leakage, the test dataset was not used in the algorithm. The elements of set \(\mathbf{S}\) are the signal identification names defined in Equation 1. The first procedure is to create the initial signal set \(\mathbf{S}_{0}\), which consists of all signals (line 1). The next step is to develop a CNN using the training dataset \(\mathbf{X}_{\rm train}^{\mathbf{S}_{0}}\), which consists of \(\mathbf{S}_{0}\) (line 3). Subsequently, we measure the validation accuracy \(A(\mathbf{X}_{\rm valid}^{\mathbf{S}_{0}})\) using the validation dataset \(\mathbf{X}_{\rm valid}^{\mathbf{S}_{0}}\) (line 4). Next, we determine the most important signal \(s_{\min}\in\mathbf{S}_{0}\) based on Equation 15 (line 5). Finally, we obtain the next signal set \(\mathbf{S}_{1}\) by removing \(s_{\min}\) from \(\mathbf{S}_{0}\) (line 6).
This procedure is repeated until the number of signals reaches one (i.e., \(t=|\mathbf{S}|-1\)), and record validation accuracies. The algorithm returns the signal subset \(\mathbf{S}_{\rm use}\) leading to maximum validation accuracy (lines 8 and 9). Notably, the case wherein the signal subset leading to the maximum accuracy is the initial signal set can occur, that is, \(\mathbf{S}_{\rm use}=\mathbf{S}\). In cases wherein the main purpose is to achieve maximum accuracy, adopting the initial signal set as an optimal subset is a better option, if \(\mathbf{S}_{\rm use}=\mathbf{S}\) occurs. However, some cases exist that require a decrease in the number of signals. Therefore, we prepare constraints wherein the number of adopted signal sizes is \(\gamma\) or less, that is, \(|\mathbf{S}_{\rm use}|\leq\gamma\). This is a hyperparameter of the proposed algorithm.
When the size of the initial signal set \(\mathbf{S}\) is \(n_{\rm s}\), the number
Fig. 3: Example of signals importance to all class expressed by SIM \(\mathbf{I}_{\rm max}(\mathbf{X})\) and SIV \(\mathbf{I}_{\rm vec}(\mathbf{X})\) calculated to CNNs of Condition A described in Section IV. The columns 1 to 10 are SIM and the column 11 is SIV (“All classes”). The values are standardized from zero to one in each column. The greater the cell’s value, the greater is the relevance of signal \(s\) on estimation class \(c^{\prime}\).
of developing CNN in Algorithm 1 is as follows:
\[T(n_{\mathrm{s}}) =n_{\mathrm{s}}-1\] \[\sim n_{\mathrm{s}}. \tag{16}\]
That is, the computational complexity of Algorithm 1 is \(\mathcal{O}(n_{\mathrm{s}})\). This means that even if the signal size \(n_{\mathrm{s}}\) increases, the signal subset is returned in realistic time.
Generally, the total pattern for choosing \(m\) from \(n\) signals is \({}_{n}\mathrm{C}_{m}\). Because \(m\), the number of signals leading to the maximum validation accuracy, is not known, the total number of combinations of input layers \(T_{\mathrm{bs}}(n_{\mathrm{s}})\) is similar to
\[T_{\mathrm{bs}}(n_{\mathrm{s}}) =\sum_{m=1}^{n_{\mathrm{s}}}{}_{n_{\mathrm{s}}}\mathrm{C}_{m}\] \[\sim\max_{m}{}_{n_{\mathrm{s}}}\mathrm{C}_{m}\] \[={}_{n_{\mathrm{s}}}\mathrm{C}_{\lfloor n_{\mathrm{s}}/2\rfloor}. \tag{17}\]
Therefore, finding the optimal signal subset using a brute-force search is difficult. The computation time tends to be large because the CNN includes many other hyperparameters. From this viewpoint, a fast algorithm such as the proposed method is important.
## III Experiment 1: Relationship between validation accuracy and the number of deleted signals
### _Objective and outline_
Herein, we examine the reliability of \(s_{\mathrm{min},\;\mathrm{max}}\) defined in Equation 15. We expect to maintain estimation accuracy even if the signal \(s_{\mathrm{min}}\) is removed because it is the most nonimportant signal. By contrast, because signal \(s_{\mathrm{max}}\) is the most important signal, the estimation accuracy may decrease by removing it. To verify the aforementioned hypothesis, we gradually removed signal \(s_{\mathrm{min},\;\mathrm{max}}\) using the processes of lines 2 to 7 of Algorithm 1. In addition, we repeatedly developed CNNs and recorded their validation accuracies. We performed verification using a total of 100 seeds because CNN depends on randomness. The adopted layer structure of the CNN is explained in the Appendix section; the number of epochs was 300.
### _Result and discussion_
First, we indicate the validation accuracies when the most nonimportant signal, \(s_{\mathrm{min}}\), is gradually removed, as shown in Figure 4 (A). From left to right in Figure 4 (A), the number of deleted signals increases, that is, the number of signals in the CNN input layer decreases. The leftmost result is obtained using all signals, and the rightmost result is obtained by using only one signal as the CNN input layer. The results show that even if six signals were deleted, the validation accuracy did not decrease. Moreover, by removing seven or more signals, the accuracy decreases significantly. In this case, although CNNs estimate class labels from 15 signals in the set \(\mathbf{S}\), six signals appear unnecessary.
We calculated the average removed timings of the 15 signals to determine the unnecessary signals. The result is shown in Figure 4 (b). This means that the lower the value, the earlier the signal is removed in the procedure of Algorithm 1. The results indicate that the signals of the right and left shoes are removed earlier than those of the other sensors. By contrast, some signals from the back, right arm, and left arm did not disappear early. Therefore, we can regard shoe signals as unimportant for classification. In addition, shoe sensors seem important for walk motion classification. However, even if shoe sensors disappear, we consider that the back sensor attached to centroids of the human body contributes to the classification of walk motions because these motions are periodic.
Next, we indicate the validation accuracies when the most important signal, \(s_{\mathrm{max}}\), is gradually removed in Figure 5 (a). We can verify that the validation accuracy statistically decreases by removing one of the most important signals. Therefore, we consider that removing the most important signal, \(s_{\mathrm{max}}\) leads to a worse accuracy. The average timing of the signal removal is shown in Figure 5 (b). From this figure, we confirm that the signals of back X, right arm X, and left arm Y are removed early. Moreover, we confirm that shoe sensor signals are not removed early. These tendencies are in contrast compared with the case of removing the most nonimportant signal \(s_{\mathrm{min}}\).
Clearly, (1) even if we remove the most nonimportant signal \(s_{\mathrm{min}}\), the estimation performance tends to remain, and (2) when we remove the most important signal \(s_{\mathrm{max}}\), the performance tends to decrease. Therefore, we regard the signal importance \(I^{s}(\mathbf{X})\) defined in Equation 13 as reliable.
## IV Experiment 2: Effectiveness of FG-SSA on generalization scores
### _Objective and outline_
Herein, we confirm the effect of FG-SSA indicated in Algorithm 1 on the generalization performance of the classification. Therefore, we develop the following three conditions for CNNs.
* Condition A: CNN using all signals, i.e., FG-SSA is not used.
* Condition B: CNN for applied FG-SSA of \(\gamma=n_{\mathrm{s}}\).
* Condition C: CNN for applied FG-SSA of \(\gamma=9\).
Condition A means that the CNN does not remove signals but uses all signal sets \(\mathbf{S}\). Condition B refers to the CNN use the signal subset \(\mathbf{S}_{\mathrm{use}}\) obtained by the FG-SSA, given \(n_{\mathrm{s}}\) as the constraint parameter \(\gamma\). Under this condition, when maximum validation accuracy is achieved using all signal sets \(\mathbf{S}\), we allow the algorithm to return \(\mathbf{S}\) as \(\mathbf{S}_{\mathrm{use}}\). In other words, a case wherein no signals are removed can occur. Condition C implies that the number of adopted signals is nine or less for a CNN input layer, that is, \(|\mathbf{S}_{\mathrm{use}}|\leq 9\). In other words, six or more signals were deleted, because the initial number of signals was 15. The value of hyper-parameter \(\gamma=9\) was determined by referring to the result shown in Figure 4 (A).
We developed CNNs using the signal set, which was determined by FG-SSA. Moreover, the optimal epochs leading to a maximum validation accuracy were adopted. The search range of epochs was from 1 to 300. Subsequently, the generalization
performance is measured using the test dataset. The test dataset was used only at this time, that is, it was not used for the parameter search. To remove the randomness effect, we developed CNNs for Conditions A, B, and C with a total of 100 seeds.
### _Result and discussion_
By developing CNNs under conditions A, B, and C on a total of 100 seeds, the average number of signals used was 15.00, 11.94, and 8.35, respectively. In other words, an average of 3.06 and 6.65 signals were removed by FG-SSA in the cases of Condition B and C, respectively. The generalization performance (F score, precision, and recall) measured by the test dataset for each condition is shown in Figure 6. These are histograms of 100 CNNs developed using 100 random seeds.
The results indicated that the generalization scores were nearly the same for conditions A, B, and C. Moreover, \(p\) values of the two-sided \(t\)-test were not statistically significant. Next, we show the confusion matrices obtained by CNNs for each condition in Figure 7. The values were averaged by 100 seed results and standardized, where the summation in each row was 1. Consequently, the confusion matrices were nearly the same. Although the proposed algorithm removed some signals, generalization errors did not increase. Therefore, we consider FG-SSA has the effect of finding and removing signals that are not important for CNN-based classification.
From another viewpoint, the number of correct classifications of left hand motions (Stand L, Walk L, and Sit L) was small in all conditions. We adopted weighted cross-entropy-based learning for CNNs because the original data size of the left hand motions is small, as indicated in Table I. However, we consider that an appropriate classification cannot be performed because the data diversity of these motions is low. Although we believe that nearly all subjects are right-handed, the explanation of subjects' dominant arm in the OPPORTUNITY dataset is insufficient to the best of our
Fig. 4: (A) Maximum validation accuracy in 300 epochs when the most nonimportant signal \(s_{\mathrm{min}}\) is gradually removed and CNNs are re-learned. (B) Average removed timings of each signal. It means the smaller the timing, the earlier the signal is removed. The results of both (A) and (B) are average values of 100 seeds, and the error bars are standard deviations. The \(p\) values in (A) represent the results of two-sided \(t\) test, and the dashed line represents the timing of statistically decreasing validation accuracy.
Fig. 5: (A) Maximum validation accuracy in 300 epochs when the most important signal \(s_{\mathrm{max}}\) is gradually removed and CNNs are re-learned. (B) Average removed timings of each signal. In contrast to that shown in Figure 4, the most important signals are removed.
knowledge.
## V Conclusion, limitations, and future works
In this paper, we describe the following two topics to find and remove nonimportant signals for CNN-based classification.
* (1) The signals importance indices SIM \(\mathbf{I}_{\rm mat}(\mathbf{X})\) and SIV \(\mathbf{I}_{\rm vec}(\mathbf{X})\) are explained in Subsection II-D.
* (2) The algorithm of the linear complexity \(\mathcal{O}(n_{\rm s})\) for obtaining the signals subset \(\mathbf{S}_{\rm use}\) from the initial signals set \(\mathbf{S}\) by finding and removing nonimportant signals (see Algorithm 1).
Although the proposed algorithm performed well in the case of the OPPORTUNITY dataset, it had some limitations. This is explained in the following sections. Future work will confirm these findings.
* (A) The results described in this paper is obtained from limited cases. Although we assume that the algorithm can be applied to other than acceleration signals, e.g., EEG, ECG, and others, it is not validated.
* (B) In this experiment, the initial signals set size was 15.
Fig. 6: Histograms of estimation score using the test dataset (total 100 seeds). The macro averages of 10 classes of F score, precision, and recall from left to right, and Conditions A, B, and C from top to bottom.
Fig. 7: Confusion matrices of the conditions A, B, and C using the test dataset. Values are averaged by results of 100 seeds. The values are standardized wherein the summation in each row is one.
The number of signals may be much higher depending on some situations. It is important to determine the relationship between the number of nonimportant signals and effectiveness of FG-SSA.
* (C) We assume that the algorithm may extract the signals subset weighted specific target class by providing class weights to the signal importance \(I^{s}(\mathbf{X})\) defined in Equation 13. In other words, we denote the importance of signal \(s\) weighted classes as \[I^{s}(\mathbf{X};\mathbf{w})=\frac{1}{|\mathbf{C}|}\sum_{c^{\prime}\in\mathbf{C}}w^{c^{\prime}}I ^{s,c^{\prime}}_{\rm mat}(\mathbf{X}),\] (18) where \(w^{c^{\prime}}\) denotes the weight of class \(c^{\prime}\) and \(\mathbf{w}\) denotes the class weight vector, defined as follows: \[\mathbf{w}=[w^{c^{\prime}}]\in\mathbb{R}^{|\mathbf{C}|},\ \text{s.t.,}\ \sum_{c^{\prime}\in\mathbf{C}}w^{c^{\prime}}=1.\] (19) We note that the algorithm based on \(I^{s}(\mathbf{X};\mathbf{w})\) can return the signals subset weighted specific classes. However, this effect is not confirmed in this paper. This will be studied in the future.
## Appendix: Layers structure of CNNs
The CNNs layer structure is illustrated in Figure 1. First, an input layer exists for inputting \(w\times n_{\rm s}\) size data (\(w\): window length, \(n_{\rm s}\): the number of signals). Then, \(n_{\rm c}=3\) convolution layers exist to generate \(n_{\rm f}\) feature maps using kernel filters of convolution size \(s_{\rm c}\). The convolutions are only in the direction of time. Next, the generated feature maps are transformed into a vector form by the flattened layer. Vector dimensions are gradually reduced to 200, 100, and 50. Finally, an output vector \(\mathbf{y}\) of 10 dimensions is generated, and classification is performed. The total number of CNN layers is nine (one input layer, three convolution layers, four dense layers, and one output layer). The activation function of each layer is ReLu.
We performed a hyperparameter search for convolution size \(s_{\rm c}\) and the number of kernel filters \(n_{\rm f}\) and learning rate \(r\). In particular, CNNs were trained using the training and validation datasets described in Subsection II-A and 300 epochs. We adopted a weighted cross-entropy-based loss function based on the inverse values of class sample sizes because the sample sizes of each class are imbalanced, as listed in Table I.
The parameter candidates are as follows:
\[s_{\rm c} \in\{5,10,15\},\] \[n_{\rm f} \in\{5,10\},\] \[r \in\{10^{-3},10^{-4}\}. \tag{20}\]
The combination of hyperparameters leading to the maximum validation accuracy was \((s_{\rm c},n_{\rm f},r)=(10,10,10^{-4})\) (accuracy: 0.726). Therefore, we adopted these parameters because all CNNs appeared in this study. Although CNNs have many other hyperparameters, we refrained from excessive tuning because the main purpose of this study is to provide and confirm the signal-selection algorithm.
|
2310.18987 | Path Analysis for Effective Fault Localization in Deep Neural Networks | Despite deep learning's transformative impact on various domains, the
reliability of Deep Neural Networks (DNNs) is still a pressing concern due to
their complexity and data dependency. Traditional software fault localization
techniques, such as Spectrum-based Fault Localization (SBFL), have been adapted
to DNNs with limited success. Existing methods like DeepFault utilize SBFL
measures but fail to account for fault propagation across neural pathways,
leading to suboptimal fault detection. Addressing this gap, we propose the
NP-SBFL method, leveraging Layer-wise Relevance Propagation (LRP) to identify
and verify critical neural pathways. Our innovative multi-stage gradient ascent
(MGA) technique, an extension of gradient ascent (GA), activates neurons
sequentially, enhancing fault detection efficacy. We evaluated the
effectiveness of our method, i.e. NP-SBFL-MGA, on two commonly used datasets,
MNIST and CIFAR-10, two baselines DeepFault and NP- SBFL-GA, and three
suspicious neuron measures, Tarantula, Ochiai, and Barinel. The empirical
results showed that NP-SBFL-MGA is statistically more effective than the
baselines at identifying suspicious paths and synthesizing adversarial inputs.
Particularly, Tarantula on NP-SBFL-MGA had the highest fault detection rate at
96.75%, surpassing DeepFault on Ochiai (89.90%) and NP-SBFL-GA on Ochiai
(60.61%). Our approach also yielded results comparable to those of the
baselines in synthesizing naturalness inputs, and we found a positive
correlation between the coverage of critical paths and the number of failed
tests in DNN fault localization. | Soroush Hashemifar, Saeed Parsa, Akram Kalaee | 2023-10-29T12:01:15Z | http://arxiv.org/abs/2310.18987v3 | **Path Analysis for Effective Fault Localization in Deep Neural Networks**
###### Abstract
Deep learning has revolutionized various real-world applications, but the quality of Deep Neural Networks (DNNs) remains a concern. DNNs are complex and have millions of parameters, making it difficult to determine their contributions to fulfilling a task. Moreover, the behavior of a DNN is highly influenced by the data used during training, making it challenging to collect enough data to exercise all potential DNN behavior under all possible scenarios. This paper proposes NP-SBFL method to locate faulty neural pathways (NP) using spectrum-based fault localization (SBFL). Our method identifies critical neurons using the layer-wise relevance propagation (LRP) technique and determines which critical neurons are faulty. Moreover, we propose a multi-stage gradient ascent (MGA), an extension of gradient ascent (GA), to effectively activate a sequence of neurons one at a time while maintaining the activation of previous neurons, so we are able to test the reported faulty pathways. We evaluated the effectiveness of our method, i.e. NP-SBFL-MGA, on two commonly used datasets, MNIST and CIFAR-10, two baselines DeepFault and NP-SBFL-GA, and three suspicious neuron measures, Tarantula, Ochiai, and Barinel. The empirical results showed that NP-SBFL-MGA is statistically more effective than the baselines at identifying suspicious paths and synthesizing adversarial inputs. Particularly, Tarantula on NP-SBFL-MGA had the highest fault detection rate at 96.75%, surpassing DeepFault on Ochiai (89.90%) and NP-SBFL-GA on Ochiai (60.61%). Our approach also yielded comparable results to the baselines in synthesizing naturalness inputs, and we found a positive correlation between the coverage of critical paths and the number of failed tests in DNN fault localization.
**Keywords**: Fault Localization; Neural Pathway; Deep Neural Networks; Neuron Relevancy; Statistical Analysis
## 1 Introduction
Deep Learning (DL) has been successful in addressing many real-world problems, such as classifying images [1], recognizing human speech [2], natural language processing [3], and software engineering tasks [4]. However, Deep Neural Networks (DNNs) have demonstrated quality issues, such as their inability to classify samples correctly in real-world applications despite achieving high accuracy. Real-world cases, such as Tesla/Uber accidents and incorrect diagnoses in healthcare, signify the need for assessment approaches in DNNs to assure their quality, particularly in safety- and security-critical systems [5]. Obviously, only DNN-based systems with high levels of trustworthiness should be approved to work in the public domain [6]. However, the complexity of DNN architectures makes it difficult to determine the contribution of each parameter to fulfilling a task. This complexity, combined with the fact that a DNN's behavior is produced according to the quality of data used to train it, makes it challenging to collect enough data to exercise all potential DNN behavior under various scenarios [7]. Therefore, effective testing approaches are needed to evaluate the quality of decisions made by DNN-based systems [8].
Although extensive research has shown that directly applying software testing methods to DNNs is not feasible, it is possible to map advanced principles behind to test DNNs [9, 10]. However, black-box DNN testing is limited in
providing insights into activation pattern of intermediate neurons and identifying inputs that result in exposing unexpected network behavior. To address this, researchers have turned to white-box testing techniques from software engineering. For example, DeepXplore [11] and DeepGauge [12] use differential algorithms and multi-granularity coverage criteria for conducting effective tests. Other research has proposed testing criteria and techniques inspired by metamorphic testing [13], combinatorial testing [14], mutation testing [15], MC/DC [16], symbolic execution [17], and Concolic testing [18].
Software fault localization aims to identify a system's parts responsible for incorrect behavior [19]. Spectrum-based fault localization (SBFL) is a promising technique for locating faults in traditional software programs, as explained in Section 2. Only one technique, DeepFault [20], currently employs traditional software fault localization to find suspicious neurons [20]. It utilizes measures such as Tarantula and Ochiai from the SBFL domain. Along with DeepFault, several approaches have been recently proposed to locate the most suspicious neurons within the network in Deep Neural Networks (DNNs) using statistical techniques [21-24].
However, none of the existing fault localization techniques considers the propagation of faults through the neural connections in different layers of the DNN. Identifying the faulty path can be achieved through pathways of sequential neurons most responsible for incorrect behavior. However, there are challenges in considering pathways in DNNs. Firstly, it is not easy to define a pathway. Additionally, the tremendous number of pathways in a DNN makes it impossible to calculate pathways for large DNNs, which can quickly become infeasible.
This paper proposes a novel approach for DNN fault localization that adapts Spectrum-based Fault Localization (SBFL) to locate faulty neural pathways. The NP-SBFL-MGA approach identifies critical neurons using the Layer-wise Relevance Propagation (LRP) technique and determines which critical neurons are faulty. A Multi-stage Gradient Ascent (MGA) technique, an extension of gradient ascent, is used to effectively activate a sequence of neurons one at a time while maintaining the activation of previous neurons. The method's effectiveness is evaluated on two commonly used datasets, MNIST and CIFAR-10, and compared with two baselines, DeepFault and NP-SBFL-GA, using three suspicious neuron measures, Tarantula, Ochiai, and Barinel. The approach outperforms the baselines in identifying faulty neural pathways and synthesizing adversarial inputs.
Specifically, Tarantula on NP-SBFL-MGA had the highest fault detection rate at 96.75%, surpassing DeepFault on Ochiai (89.90%) and NP-SBFL-GA on Ochiai (60.61%). It is concluded that this approach provides a systematic and effective framework for DNN fault localization and can help improve the quality and reliability of DNN-based software.
The effectiveness of the proposed method is evaluated on two commonly used datasets, MNIST [27] and CIFAR-10 [28]. The method is compared to two baselines, DeepFault and NP-SBFL-GA (a version of NP-SBFL that uses gradient ascent to activate neurons during input synthesis). Results show that NP-SBFL is statistically more effective than the baselines at identifying suspicious paths and synthesizing adversarial inputs. Specifically, the instance NP-SBFL-MGA using Tarantula had a 96.75% average fault detection rate compared to 89.90% for DeepFault using Ochiai and 60.61% for NP-SBFL-GA using Ochiai across all datasets and models. The proposed method also identifies unique suspicious neurons, especially in complex models, whereas the other methods rely heavily on a common neuron, making them less reliable. In addition to the fault detection rate, the naturalness of the synthesized inputs is evaluated using popular distance metrics such as Manhattan, Euclidean, Chebyshev, inception score, and Fre'chet Inception Distance. The approach yields comparable results to DeepFault. Furthermore, a positive correlation is found between the coverage of critical paths and the number of failed tests in DNN fault localization.
Overall, the contributions of this paper to the field of DNN fault localization are as follows: First, spectrum-based suspiciousness measures from software engineering are used to locate faulty pathways of neurons in DNNs. Second, verifying identified faulty pathways through multi-stage gradient ascent instead of just gradient ascent. Third, the proposal of an algorithm that guides the synthesis of inputs to activate potentially suspicious neural pathways. Fourth, the thorough evaluation of NP-SBFL on two publicly available datasets (MNIST and CIFAR-10) with different models demonstrates its feasibility and effectiveness.
The evaluation results show that the NP-SBFL method effectively identifies faulty neural pathways and synthesizes adversarial inputs. Compared to existing baselines, the method has demonstrated superiority in identifying unique suspicious neurons, especially in complex models. Furthermore, evaluating the synthesized inputs' naturalness shows
comparable results to existing methods. The correlation analysis also suggests a positive relationship between the coverage of critical paths and the number of failed tests in DNN fault localization.
The proposed NP-SBFL method offers a systematic and practical framework for DNN fault localization that can potentially improve the quality and reliability of DNN-based software. The contributions of this paper provide a foundation for future research on DNN fault localization, which could guide the development of safer and more trustworthy DNN-based systems.
The subsequent sections of this paper are structured as follows. Section 2 provides a comprehensive overview, covering the background of traditional software fault localization, the fault taxonomy in DNNs, and the relevance propagation concept. Section 3 summarizes the existing literature on fault localization in DNNs. In Section 4, we introduce our proposed approach, NP-SBFL. Section 5 contains a meticulous account of the experimental setup, the evaluation performed, and the potential threats to validity. Finally, Section 6 concludes the paper.
## 2 Background
The following section provides an overview of fault localization in traditional software, followed by an introduction to fault taxonomy in DNN models. Additionally, a detailed explanation of the relevancy concept is also included.
### 2.1 Fault Localization in Traditional Software
Fault localization (FL) can be categorized as white box testing that aims to identify source code elements more prone to produce faults [19]. An FL technique is applied to test a program P against a test oracle T, which reports tests with passed and failed status. Subsequently, an FL measurement technique is employed to determine how likely each program element is to cause fault during the execution time, i.e. suspiciousness of the program element.
Spectrum-based FL (SBFL) [29] belongs to a family of debugging techniques aiming to identify potentially faulty code by analyzing both passing and failing executions of a faulty program. It infers statistical properties from these executions and provides developers with a ranked list of potentially faulty statements to investigate. When given a faulty program and a set of test cases, an automated debugging tool based on SBFL generates a ranked list of potentially faulty statements. Developers can then inspect these statements one by one until they find the bug.
### 2.2 Faults Taxonomy in Deep Neural Networks
There are fundamental differences in definition of fault and detecting faults between regular software programs and DNN models [30]. Regular programs express their logic through control flow, while weights among neurons and various activation functions play crucial role in the logic of DNN programs. In software programs, bugs are often identified by comparing ground-truth outputs with expected outputs. As long as there is a difference between the ground-truth output and the expected one, a bug is considered to be present. In contrast, DNN-based program learns from a training dataset and once the DNN misclassifies during inference, the input samples are termed as failure cases. However, it is essential to note that since a DNN model cannot guarantee complete accurate classifications, such failures do not necessarily imply the presence of a bug. To address this, DeepDiagnosis [30] has discussed eight types of failure symptoms and their underlying causes. Additionally, Neural Trojans represent another type of symptom that can lead to misbehavior in DNNs [31]. These failure roots and symptoms are summarized in Table 1.
\begin{table}
\begin{tabular}{p{113.8pt} p{113.8pt} p{113.8pt}} \hline \hline \# & **Symptom** & **Description** & **Root causes** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Typical failure symptoms and their root causes in a DNN.
### Layer-Wise Relevance Propagation
Layer-wise relevance propagation (LRP) [32][33] is an explanation technique applicable to neural network models that handle inputs like images, videos, or text [34][35]. LRP operates by propagating the prediction f(x) backward in the neural network using specifically designed local propagation rules.
The propagation process employed by LRP adheres to a conservation property, where the relevance received by a neuron must be equally redistributed to the neurons in the lower layer. This behavior is akin to Kirchoff's conservation laws observed in electrical circuits. Let j and k represent neurons at two consecutive layers in the neural network. The relevance scores are propagated from a given layer onto the neurons of the lower layer using the rule depicted in Eq. 1.
\[R_{j}=\sum_{k}\frac{z_{jk}}{\sum_{j}z_{jk}}R_{k} \tag{1}\]
The variable z\({}_{jk}\) represents the contribution of neuron j to the relevance of neuron k. The denominator ensures the conservation property is maintained. The propagation process concludes once the input features are reached. By applying this rule to all neurons in the network, the layer-wise conservation property \(\sum_{j}R_{j}=\sum_{k}R_{k}\) can be easily verified and extended to a global conservation property \(\sum_{i}R_{i}=f(x)\). The overall LRP procedure is illustrated in Figure 1.
## 3 Related work
The literature discusses two distinct approaches for fault localization in DNN models. Analytical methods employ analytical techniques to identify the most suspicious neurons within the network. On the other hand, statistical methods use statistics, such as spectrum-based techniques, to identify faulty paths in the network. In the following review, we will briefly explore previous works in these two categories and investigate how FL techniques have been applied to DNNs.
### 3.1 Localizing faults in parameters
DeepFault [20] is an SBFL-based method designed for DNNs, which requires can be categorized as white-box approaches. DeepFault starts by identifying neurons which are more likely to cause misclassifications. To achieve this, DeepFault analyzes the behavior of intermediate neurons at inference, establishing a hit spectrum for each neuron under a specific test set. By analyzing these hit spectrums, DeepFault identifies highly defective neurons and synthesize new input samples that activate error prone neurons. The identification of suspicious neurons is based on calculating a suspiciousness score for each neuron using various measurements of suspiciousness: Tarantula [36], Ochiai [37], and DStar [38]. These measures have been used for fault localization in the field of software engineering for the first time [19]. Neurons with higher suspiciousness scores contribute more to incorrect DNN decisions, due to their lack of adequately training budget. Consequently, the weights of these neurons need to be further adjusted [39]. In the synthesis phase, correctly classified inputs are used to generate input samples that aim to maximize the activation values of neurons identified as suspicious. By doing so, the information produced by these neurons propagates through the network, causing shifts in the decision boundaries learned by the network.
NNrepair [22] proposes separate repair techniques for both the intermediate and last layers, aiming to find potentially faulty network weights. Repairing all the output classes at once can be challenging. So, NNrepair prepare a set of expert networks, each specializing in one specific label class, which is computationally more feasible. These experts are combined to create a final repaired classifier. In the fault localization step, network activation patterns are utilized as an oracle for correct behavior. An activation pattern \(\sigma\) specifies an activation state ("on" or "off") for a subset of neurons at a layer in the network. These patterns guide the identification of potentially faulty neurons. Highly
Figure 1: Illustration of the LRP procedure. Each neuron redistributes to the lower layer as much as it has received from a higher layer.
supported correct-label patterns corresponding to each output class at an intermediate layer are extracted. A highly supported correct-label pattern suggests that the network would likely classify any input satisfying the pattern to the appropriate label, while misclassified inputs would not meet the correct label pattern. For each incorrect input, the activations of the neurons corresponding to the correct-label pattern are compared, and neurons with different activations are considered potentially faulty. The repair process aims to modify the outputs of these neurons for each failing input to match the correct label pattern for their respective labels.
### 3.2 Localizing faults in architecture
DeepLocalize [21] presents a fault localization approach for DNNs, which requires access to the source code of the DNN model. DeepLocalize aims at fixing bugs in the architecture of the DL program. They propose two mechanisms to collect dynamic traces: (1) the first technique works by mapping the code into an intermediate representation of the DNN. This representation allows the internal states of the DNN to be monitored, enabling the insertion of probes for dynamic analysis during the training process. (2) The second technique investigates the internal state of the DNN source code by injecting a callback function. Through this dynamic analysis, DeepLocalize identifies the faulty hyper-parameters, including layers, responsible for the error. DeepLocalize aims to achieve three main objectives: (1) determine if there exist a bug inside the DL program, (2) localize the fault, and (3) provide failure information. They test DeepLocalize on buggy models collected from commits of GitHub and posts on Stack Overflow platforms, demonstrating its ability to identify bugs in 23 out of 29 buggy programs using the first technique and 34 out of 40 using the callback function.
DeepDiagnosis [30], as an analytical approach, offers bug fixes in the DL program. During training, the approach monitors essential indicators like weights and gradients, analyzing the recorded values to detect symptoms and potential training issues. When a symptom is identified, a Decision Tree is utilized to diagnose it based on pre-defined rules. The process begins by taking the initial model architecture and a training dataset as input and passing a callback method to the _fit(.)_ method. This callback method captures and records key values (e.g., weights and gradients) during feed-forward and backward propagation. A dynamic detector reports various symptoms at different stages during training, based on error conditions. If a symptom is detected, the recorded key values are analyzed to determine potential locations in the input model that need correction. DeepDiagnosis then reports the type of symptom, the layers and stages where it was detected, and suggests a location for fixing the issue.
Finally, Cao et al. [23] propose DeepFD, a learning-based fault diagnosis and localization framework that treats the fault localization task as a learning problem, in a statistical manner. It infers suspicious fault types by monitoring runtime features extracted during DNN model training and then locates the diagnosed faults in the architecture of the DL programs. DeepFD overcomes limitations by identifying the root causes of faults in DL programs instead of neurons and diagnoses them using a learning approach instead of a set of hard-coded rules.
Table 2 summarizes the benefits of existing and our proposed NP-SBFL fault localization methods.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Method** & **Approach** & **Repair model** & **Phase** & **Detection region** & **Focus** \\ \hline DeepFault [20] & Statistical & & Post-train & whole network & Neuron \\ \hline DeepLocalize [21] & Statistical & & During train & - & Hyper-parameters \\ \hline NNrepair [22] & Statistical & & Post-train & fully connected layers & Weights \\ \hline DeepDiagnosis [30] & Analytical & & During train & - & Hyper-parameters \\ \hline \hline \end{tabular}
\end{table}
Table 2: An overview of the explained Fault-Localization methods.
## 4 Proposed Approach
This section introduces our NP-SBFL white-box approach, which presents a systematic testing method for DNNs. The approach aims to identify and locate highly erroneous neural pathways within a DNN. By employing a sequence of analysis, identification, and synthesis steps on a pre-trained DNN, NP-SBFL can effectively pinpoint these problematic pathways and create new inputs that activate them. A comprehensive overview of NP-SBFL is given in Section 4.1, while Sections 4.2 to 4.4 delve into the specific details of the NP-SBFL steps.
### Overview
In this section, we provide an overview of NP-SBFL. Initially, we extract neurons that are critical from each layer of the neural network. This extraction process involves using LRP, as explained in Section 2.3, to unhide the internal decision process for input data. LRP measures how relevant each neuron is, starting from the output layer and tracing back to the first layer, in terms of their impact on prediction results. This relevance signifies the influence of each neuron on the way the network make decisions. Once we have the relevant neurons and their activation values for each layer, we employ fault localization methods based on spectrum, to identify suspicious neurons. Finally, we generate a synthesized dataset to activate these suspicious paths and verify whether they lead to incorrect classification results. To achieve this, we propose the use of a multi-stage gradient ascent technique to activate these faulty paths effectively.
### Neural Pathways Analysis
In this section, we present the method for identifying the essential decision path for a given input. As mentioned earlier, the relevance of each neuron \(R_{i}^{l}\) signifies its contribution to the final decision. A higher relevance value indicates that neuron i at layer l has a more significant impact on the decision-making process. Since a DNN's prediction relies on the extracting high quality features at each layer, the critical neurons with high relevance reveal the logic behind the decision process of the DNN [40].
Inspired by [40], for an input x, we formulate the condition of critical neurons as shown in Eq. 2 at each layer \(l_{i}\):
\[\sum_{i\in l_{i}}R_{i}^{l}\ >\ \alpha\ \cdot\ g_{f}(x) \tag{2}\]
where \(\alpha\) is a hyper-parameter controlling the volume of neurons that are considered as critical at each layer. By definition, a critical neuron positively contributes to the decision, meaning it has a positive relevance value. To determine the set of critical neurons, we define this set as the minimum subset of neurons with a cumulative relevance exceeding a predefined threshold. This threshold is a fraction of \(g_{f}(x)\) denoting the cumulative relevance of the input values. By adjusting \(\alpha\), we can control the number of critical neurons located at each layer, where smaller \(\alpha\) values result in fewer critical neurons being chosen.
### Suspicious Neural Pathways Identification
The next stage of NP-SBFL involves examining neural activity to pinpoint faulty neurons in each layer individually. To achieve this, NP-SBFL detects suspicious neurons by defining characteristics of a neuron's execution procedure, drawing inspiration from DeepFault [20]. However, unlike DeepFault, which considers all neurons collectively, our focus is on critical neurons in each layer, as they hold greater relevance to the DNN's decision-making process. The quantities \(A^{c}_{p}\) and \(A^{c}_{f}\) represent the number of times a neuron was covered by the input sample and resulted in a passed or failed decision, respectively. Similarly, quantities \(A^{n}_{p}\) and \(A^{n}_{f}\) indicate cases where the neuron remained uncovered by the input sample. The abstract procedure for determining the suspicious scores are presented in Algorithm 1.
```
1:Input a neural network with L layers; test set T; activation threshold \(\beta\)
2:Output suspiciousness scores of all neurons in the network
3:\(A^{c}_{p}=\) matrix of active-passed tests with initial value of \(0\)
4:\(A^{n}_{p}=\) matrix of inactive-passed tests with initial value of \(0\)
5:\(A^{n}_{f}=\) matrix of active-failed tests with initial value of \(0\)
6:\(A^{n}_{f}=\) matrix of inactive-failed tests with initial value of \(0\)
7:\(supiciousness Scores=\) matrix of suspiciousness scores associated with each neuron
8:for\(input_{sample}\in test\ set\ T\)do
9: predict \(input_{sample}\) by the network
10: get relevancy and activation values of all layers of network
11:\(neurons_{critical}=[]\)
12:for\(layer\ l=1,2,\ldots,L\)do
13: find critical neurons according to equation (2) and append them to \(neuron_{critical}\)
14:endfor
15:for\(layer\ l=1,2,\ldots,L\)do
16:for\(neuron\ n\in layer\ l\)do
17:if\(input_{sample}\) is correctly classified then
18:if\(n_{activation}\geq\beta\) and \(n\in neurons_{critical}[l]\)then
19:\(increment\ A^{n}_{p}[l][n]\)
20:endif
21:if\(n_{activation}<\beta\) and \(n\in neurons_{critical}[l]\)then
22:\(increment\ A^{n}_{p}[l][n]\)
23:endif
24:else
25:if\(n_{activation}\geq\beta\) and \(n\in neurons_{critical}[l]\)then
26:\(increment\ A^{n}_{f}[l][n]\)
27:endif
28:if\(n_{activation}<\beta\) and \(n\in neurons_{critical}[l]\)then
29:\(increment\ A^{n}_{f}[l][n]\)
30:endif
31:endif
32:endfor
33:endfor
34:for\(layer\ l=1,2,\ldots,L\)do
35:for\(neuron\ n\in l\)do
36:\( suspiciousness Scores[l][n]=SBFL(A^{c}_{p}[l][n],A^{n}_{p}[l][n],A^{c}_{f}[l][n],A^{n}_{f}[l][n])\)
37:endfor
38:return\(suspiciousness Scores\)
```
**Algorithm 1** Determine Suspiciousness Scores
Under a test set T, NP-SBFL analyzes the behavior of relevant neurons in the DNN to create a hit spectrum for each neuron (lines 6-32), which describes its dynamic behavior. This involves utilizing the activation patterns of relevant neurons in each layer for analysis (lines 16-29). After obtaining the set of hit spectrums through DNN
analysis, NP-SBFL proceeds to individually identify suspicious relevant neurons in each layer. These suspicious neurons are grouped from the first to the last layer, forming a sequence of neurons. Finally, NP-SBFL employs a suspiciousness measure based on spectrum, which calculates a suspiciousness score for each neuron based on spectrum-related information (lines 33-37). The higher the suspiciousness score, the more likely the neuron was inadequately trained, contributing to incorrect DNN decisions. In this paper, we implement NP-SBFL using three distinct suspiciousness measures: Tarantula [36], Ochiai [41], and Barinel [29]. Their algebraic formulas are presented in Table 3.
These suspiciousness measures operate on the principle that a neuron is deemed more suspicious if it is frequently covered by test inputs resulting in incorrect DNN decisions, and less frequently covered by test inputs leading to correct decisions. Upon analyzing the suspiciousness of neurons in each layer of a DNN, the neurons are arranged in descending order of suspiciousness. The k most likely defective neurons are then selected in each layer to form a pattern of interconnected neurons.
### Suspiciousness-Guided Input Synthesis
To assess the faulty paths identified in the previous steps, it is necessary to activate these suspicious paths and check whether they lead to misclassifications by the DNN. To achieve this, we aim to maximize the activation of the set of suspicious neurons determined by NP-SBFL, using a technique called Activation Maximization. Activation Maximization is a visualization method for neural networks that seeks to maximize the activation of specific neurons. During standard training, the weights and biases of the neural network are iteratively adjusted to minimize the error (or loss) across training examples in the dataset. Activation Maximization, on the other hand, works inversely. After the classifier has been trained, we want to iteratively find the parts of the data that the model associates with a specific class.
One approach used in Activation Maximization is Gradient Ascent (GA). Gradient Ascent involves using the derivative of a differentiable function, f(x): \(R^{d}\rightarrow\mathbb{R}\), to determine how much f(x) will change if we increase x slightly. This information is valuable for optimization problems, such as finding a minimum. In Gradient Descent algorithm, we start from any point and move in the direction that decreases f(x) the most, repeatedly calculating the gradient and taking steps until we reach the minimum. In the context of our model, the gradient of the function (neural network) provides information about each input dimension's effect on increasing the function's value [43].
For activating target neurons, we apply the GA to each neuron, adding the gradient of that neuron with respect to the input data to the input image pixels. However, since NP-SBFL operates based on a sequence of neurons, the
\begin{table}
\begin{tabular}{l c} \hline \hline
**Suspiciousness Measure** & **Algebraic Formula** \\ \hline Tarantula & \(\dfrac{A_{f}^{c}}{A_{f}^{c}\ +\ A_{f}^{n}}\) \\ \(\dfrac{A_{f}^{c}}{A_{f}^{c}\ +\ A_{f}^{n}}\ +\dfrac{A_{p}^{c}}{A_{p}^{c}\ +\ A_{p}^{n}}\) \\ \hline Ochiai & \(\dfrac{A_{f}^{c}}{\sqrt{\left(A_{f}^{c}\ +\ A_{f}^{n}\right)\ *\ (A_{f}^{c}\ +\ A_{p}^{c})}}\) \\ \hline Barinel & \(1-\dfrac{A_{p}^{c}}{A_{f}^{c}\ +\ A_{p}^{c}}\) \\ \hline \hline \end{tabular}
\end{table}
Table 3: Suspiciousness measures used in NP-SBFL.
naive GA may not be effective in activating these paths. Activating a neuron in later layers could inadvertently deactivate previous neurons in earlier layers along the path, or vice-versa.
To address this issue, we developed a method called multi-stage Gradient Ascent (MGA), an extension of GA. MGA activates a sequence of neurons one at a time while maintaining the activation of previous neurons. To achieve this, we minimize a loss function for all layers sequentially. The intended loss function is represented by Eq. 3.
\[\mathit{loss}_{L}=\mathit{-activation}_{target}^{L}+\sum_{l=1}^{L-1}(- \mathit{activation}_{target}^{l}+\mathit{\left\lfloor activation_{target}^ {L}\right\rfloor}\mathit{-activation}_{target}^{l}) \tag{3}\]
The loss function is minimized layer-by-layer. For each layer L, the target activations in the current layer (first term) and all previous target activations are kept activated (second term). As described in Algorithm 2, the gradient of this loss function is then added to the input image to synthesize it and activate the suspicious paths (line 11). Finally, the domain constraints are applied to the synthesized image (line 12), which consists of normalizing the image's new pixel values in range of [0, 1]. The effectiveness of MGA is explored in later sections.
```
1:Input a neural network with L layers; test set T; list of suspicious neurons in each layer \(\mathit{suspicious_{neurons}}\); learning rate \(lr\)
2:Output a set of synthesized images to activate faulty paths
3:\(synthesizedImages\) = []
4:for\(input_{sample}\in tests\,set\,\,T\)do
5:for\(iteration=1,2,\,\ldots,\,I\)do
6: predict \(input_{sample}\) by the network
7:if\(input_{sample}\) is correctly classified then
8:for\(layer\,l=1,2,\ldots,L\)do
9:for\(neuron\,n\in\mathit{suspicious_{neurons}}[l]\)do
10: calculate loss objective according to equation (3)
11:endfor
12:\(gradients=\frac{\partial loss}{\partial input_{sample}}\)
13:\(input_{sample}=input_{sample}-lr*gradients\)
14: apply domain constraints on \(input_{sample}\)
15:endfor
16: append synthesized \(input_{sample}\) to \(synthesizedImages\)
17:endif
18:endfor
19:endfor
20:return\(synthesizedImages\)
```
**Algorithm 2** Suspiciousness-Guided Input Synthesis
## 5 Implementation
The prototype tool we have implemented on top of PyTorch v2.0 has been designed to streamline the evaluation and adoption of the NP-SBFL approach. By providing intuitive functionality, we aim to make it easier for researchers and practitioners to incorporate NP-SBFL into their work. Additionally, we have made the full experimental results available on the NP-SBFL project page at [https://github.com/soroushhashemifar/NP-SBFL](https://github.com/soroushhashemifar/NP-SBFL), allowing for easy access and reference.
## 6 Evaluation
In this section, we describe our experiments to evaluate the effectiveness of our fault localization technique, NP-SBFL, in localizing faulty sequences of neurons within a neural network. Firstly, we describe our experimental setup, including the dataset used, the neural network architecture, and the evaluation metrics employed. Next, we outline the research questions we aim to answer through our experimental evaluation. These questions include comparing the performance of different fault localization approaches, evaluating our technique's effectiveness using different
suspiciousness measures, and examining the correlation between critical path coverage and the number of failed tests. Subsequently, we present the results of our experiments and discuss their implications. We provide a detailed analysis of the performance of different fault localization approaches and evaluate our technique's effectiveness using different suspiciousness measures. Finally, we discuss potential threats to the validity of our experimental evaluation and outline steps taken to mitigate these threats.
### Experimental Setup
We evaluate NP-SBFL using two widely-used datasets. The first dataset, MNIST [27], contains handwritten digit samples comprising 60,000 training and 10,000 testing samples. Each sample comprises a 28x28 pixel image with a class label ranging from 0 to 9. The second dataset, CIFAR-10 [28], is an image dataset containing 50,000 training samples and 10,000 testing samples. This dataset includes 32x32 images of ten distinct classes, such as dogs, birds, and cars.
In our analysis of both datasets, we examine six DNNs implemented through the PyTorch framework, with the specific configurations outlined in Table 4. Each DNN has distinct architectural features and varying numbers of trainable parameters. To obtain a minimum accuracy of 95% on the MNIST dataset, we employ three deep Fully-connected NNs. Conversely, for the CIFAR-10 dataset, we experiment with three convolutional NNs enhanced by max-pooling and ReLU activation functions to achieve a minimum accuracy of 70%.
We have implemented NP-SBFL using the suspiciousness measures Tarantula, Ochiai, and Barinel, as shown in Table 5. To assess the effectiveness of NP-SBFL, we conducted experiments using different numbers of suspicious neurons, specifically k@{1,5,10} for MNIST models and k@{10,30,50} for CIFAR models. In addition, we conducted extensive experiments for models of Table 4 to optimize the hyper-parameters of Algorithm 2 and facilitate the reproducibility of our results. Through empirical analysis, we determined that the values listed in Table 5 are suitable for perturbing inputs in MNIST and CIFAR-10 models. The NP-SBFL method employs two gradient ascent synthesizers - NP-SBFL-GA, a simple one, and NP-SBFL-MGA, a multi-stage synthesizer. For DeepFault, we utilized the step size values recommended by the original paper.
Furthermore, we determine an upper-bound for allowed distance (d) to ensure it does not exceed the distances specified in Table 5, considering the range of values provided in each dimension of input sample and also its highest pixel value. For DeepFault, we again employed the distance values suggested by the original paper. Exploring alternative step and parameter d is an area of future investigation for our research.
The evaluations were conducted on an Ubuntu desktop with a memory capacity of 16 GB and an Intel(r) Core(tm) i7-4790K CPU running at 4.00GHz with eight cores. Throughout the experiments, a criticality coefficient \(\alpha\) value of 0.7 was employed. Given that all activation functions were ReLU, neurons with an activation value greater than 0.0 were considered to be activated.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Dataset** & **Model** & \begin{tabular}{c} **\# Trainable** \\ **Params** \\ \end{tabular} & **Architecture** & **Accuracy** & \begin{tabular}{c} **\#Correctly** \\ **Classified** \\ **Samples** \\ \end{tabular} \\ \hline \multirow{4}{*}{MNIST} & MNIST\_1 & 27,420 & 5 * \textless{}30\textgreater{}, \textless{}10\textgreater{} & 96.6 \% & 9631 \\ \cline{2-5} & MNIST\_2 & 22,975 & 6 * \textless{}25\textgreater{}, \textless{}10\textgreater{} & 95.8 \% & 9581 \\ \cline{2-5} & MNIST\_3 & 18,680 & 8 * \textless{}20\textgreater{}, \textless{}10\textgreater{} & 95 \% & 9512 \\ \hline \multirow{4}{*}{
\begin{tabular}{c} CIFAR-10 \\ \end{tabular} } & CIFAR\_1 & 411,434 & 2 * \textless{}32@3x3\textgreater{}, 2 * \textless{}64@3x3\textgreater{}, 4 * \textless{}128\textgreater{}, \textless{}10\textgreater{} & 70.1 \% & 7066 \\ \cline{1-1} \cline{2-5} & CIFAR\_2 & 724,010 & 2 * \textless{}32@3x3\textgreater{}, 2 * \textless{}64@3x3\textgreater{}, 2 * \textless{}64@3x3\textgreater{}, 2 * \textless{}256\textgreater{}, \textless{}10\textgreater{} & 72.6 \% & 7413 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Configuration of all DNN models used in NP-SBFL
### Research Questions
Our experimental evaluation aims to address the following research questions.
* RQ1 (Validation): Does empirical evaluation validate the effectiveness of NP-SBFL in identifying suspicious paths and its ability to outperform DeepFault, a neuron-based suspiciousness selection strategy, in synthesizing adversarial inputs that lead to misclassification of previously correctly classified inputs by DNNs?
* RQ2 (Comparison): How do NP-SBFL-GA, NP-SBFL-MGA, and DeepFault instances with different measurements of suspiciousness compare against each other? The evaluation is conducted by analyzing the results produced by different instances using Tarantula [36], Ochiai [41], and Barinel [29].
* RQ3 (Fault Detection Rate): Which of the selected approaches exhibits a greater fault detection rate?
* RQ4 (Correlation) Is there a correlation between the coverage of critical paths and the number of failed tests in DNN fault localization?
* RQ5 (Locating Unique Suspicious Neurons): Which approach is more effective in locating unique suspicious neurons among the different instances?
* RQ6 (Quality of Synthesized Inputs): How well can NP-SBFL synthesize inputs of acceptable quality?
### Results and Discussion
In this section, we design and conduct specific experiments to address each research question and provide insights into the impact of activating suspicious paths on the model's performance and potential vulnerabilities. Our experiment process involves several steps. Firstly, we choose a group of accurately classified samples from the test set based on the pre-trained model's predictions. Next, we utilize an input synthesis technique to activate suspicious paths in the model. This technique involves modifying the input samples to highlight certain patterns that could trigger misclassifications. Then, we measure the misclassification rate by inputting the synthesized samples into the model and comparing the predicted and actual labels. After that, we calculate the fraction of samples that activate the suspicious paths and lead to misclassification by dividing the number of misclassified samples by the total number of synthesized samples. Lastly, we analyze the ratios obtained to conclude the effectiveness of activating suspicious paths in producing faulty results.
#### RQ1 (Validation)
We use the NP-SBFL workflow to analyze DNNs in Table 4. This analysis involves identifying the K neurons with the highest scores using a suspiciousness measure and synthesizing new input samples from those input samples classified correctly, which exercise the identified neurons. The last column in Table 4 shows the number of correctly
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{Model} & \multicolumn{2}{c}{DeepFault} & \multicolumn{2}{c}{NP-SBFL-GA} & \multicolumn{2}{c}{NP-SBFL-MGA} \\ \cline{2-7} & step size & distance & step size & distance & step size & distance \\ \hline \hline MNIST-1 & 1 & 0.1 & 1 & 0.5 & 5 & 0.006 \\ \hline MNIST-2 & 1 & 0.1 & 1 & 0.5 & 5 & 0.006 \\ \hline MNIST-3 & 1 & 0.1 & 1 & 0.5 & 5 & 0.006 \\ \hline CIFAR-1 & 10 & 0.1 & 10 & 0.1 & 5 & 0.01 \\ \hline CIFAR-2 & 10 & 0.1 & 10 & 0.1 & 5 & 0.02 \\ \hline CIFAR-3 & 10 & 0.1 & 10 & 0.1 & 5 & 0.04 \\ \hline \hline \end{tabular}
\end{table}
Table 5: The hyper-parameters of different approaches and models.
classified inputs. We evaluate the DNN's prediction performance using standard metrics like cross-entropy loss and accuracy. The analysis is done per class since inputs from the same class have similar activation patterns.
Tables 6 to 8 show the average loss and accuracy of inputs synthesized by different methods, including DeepFault, NP-SBFL-GA, and NP-SBFL-MGA. They use Tarantula, Ochiai, and Barinel to identify suspicious neurons on MNIST (top) and CIFAR-10 (bottom) models from Table 4. In Tables 6 to 8, each cell value represents an average over the synthesized inputs. The number of synthesized inputs for each model is reported in the last column of Table 4. The loss and accuracy of the synthesized samples demonstrate the effectiveness of the gradient ascent method in generating improved samples to deceive the network.
Table 6 reveals that DeepFault using Tarantula and Barinel achieved significantly lower prediction performance than Ochiai on all models. The performance between Tarantula and Barinel is similar. These results suggest that the identified neurons are suspicious, so their weights are insufficiently trained. In NP-SBFL-GA and NP-SBFL-MGA, Ochiai and Barinel have similar effectiveness on the models and obtain lower performance than Tarantula. These results demonstrate that the identified paths are suspicious, so their weights are insufficiently trained. Therefore, slightly perturbing the inputs correctly classified by the DNN could transform them into adversarial by increasing the activation value of suspicious paths.
\begin{table}
\begin{tabular}{l l l l l l l l l l l} \hline \hline & & K=1 & K=5 & K=10 & K=1 & K=5 & K=10 & K=1 & K=5 & K=10 \\ \hline \multirow{2}{*}{MNIST-1} & Loss & **0.1553** & 0.0280 & 0.0113 & 0.1340 & **0.0383** & **0.0201** & 0.1340 & **0.0383** & **0.0201** \\ & Accuracy & **25.07** & 66.80 & 81.58 & 34.39 & **64.45** & **75.28** & 34.39 & **64.45** & **75.28** \\ \hline \multirow{2}{*}{MNIST-2} & Loss & 0.0274 & 0.0271 & 0.0208 & **0.0548** & **0.0392** & **0.0273** & **0.0548** & **0.0392** & **0.0273** \\ & Accuracy & 65.41 & 61.51 & 68.40 & **46.65** & **59.38** & **64.46** & **46.65** & **59.38** & **64.46** \\ \hline \multirow{2}{*}{MNIST-3} & Loss & **0.1297** & 0.0275 & 0.0271 & 0.0819 & **0.0574** & **0.0290** & 0.0819 & **0.0574** & 0.0275 \\ & Accuracy & **40.65** & 72.93 & 74.20 & 41.61 & **59.85** & **73.08** & 41.61 & **59.85** & 74.40 \\ \hline \hline \multirow{2}{*}{CIFAR-1} & \multirow{2}{*}{K=10} & K=30 & K=50 & K=10 & K=30 & K=50 & K=10 & K=30 & K=50 \\ & & & & & & & & & \\ \hline \multirow{2}{*}{CIFAR-1} & Loss & 0.0106 & 0.0065 & **0.0052** & **0.0107** & **0.0093** & 0.0049 & **0.0107** & **0.0093** & 0.0051 \\ & Accuracy & **59.97** & 72.95 & **77.73** & 61.47 & **65.49** & 79.63 & 61.47 & **65.49** & 79.06 \\ \hline \multirow{2}{*}{CIFAR-2} & Loss & **0.0146** & 0.0122 & 0.0119 & 0.0132 & **0.0158** & **0.0151** & 0.0132 & **0.0158** & **0.0151** \\ & Accuracy & **47.38** & 51.73 & 52.39 & 48.18 & **45.01** & **45.74** & 48.18 & **45.01** & **45.74** \\ \hline \multirow{2}{*}{CIFAR-3} & Loss & **0.0102** & **0.0074** & **0.0076** & 0.0083 & 0.0062 & 0.0070 & 0.0083 & 0.0062 & 0.0070 \\ & Accuracy & **56.06** & **65.65** & **65.20** & 63.03 & 71.69 & 67.89 & 63.03 & 71.9 & 67.89 \\ \hline \hline \end{tabular}
\end{table}
Table 8: Loss and accuracy of all models on the synthesized data for NP-SBFL-MGA on all the selected models. The best results per suspiciousness measure are shown in bold. K represents the number of suspicious neurons.
\begin{table}
\begin{tabular}{l l l l l l l l l l l} \hline \hline \multirow{2}{*}{**Model**} & \multirow{2}{*}{**Measure**} & \multicolumn{4}{c}{**Tarantula**} & \multicolumn{4}{c}{**Ochiai**} & \multicolumn{4}{c}{**Barinel**} \\ \cline{3-10} & & K=1 & K=5 & K=10 & K=1 & K=5 & K=10 & K=1 & K=5 & K=10 \\ \hline \multirow{2}{*}{MNIST-1} & Loss & **0.0442** & 0.0317 & **0.0679** & 0.0293 & **0.0713** & 0.0392 & 0.0293 & **0.0713** & 0.0392 \\ & Accuracy & 47.52 & 51.68 & **34.18** & **46.53** & **28.43** & 41.0 & **46.53** & **28.43** & 41.0 \\ \hline \multirow{2}{*}{MNIST-2} & Loss & **0.0437** & **0.0450** & **0.0452** & 0.0393 & 0.0394 & 0.0429 & 0.0393 & 0.0394 & 0.0429 \\ & Accuracy & 33.99 & **30.04** & 35.06 & **33.04** & 35.01 & **34.51** & **33.04** & 35.01 & **34.51** \\ \hline \multirow{2}{*}{MNIST-3} & Loss & **0.0423** & 0.0896 & **0.0665** & 0.0201 & **0.0911** & 0.0652 & 0.0201 & **0.0911** & 0.0652 \\ & Accuracy & **26.04** & 25.47 & 30.52 & 38.19 & 19.50 & **24.17** & 38.19 & 19.50 & **24.17** \\ \hline \hline \multirow{2}{*}{CIFAR-1} & \multirow{2}{*}{K=10} & K=30 & K=50 & K=10 & K=30 & K=50 & K=10 & K=30 & K=50 \\ & Accuracy & **0.0160** & **0.0234** & **0.0209** & 0.0158 & 0.0182 & 0.0205 & 0.0158 & 0.0182 & 0.0205 \\ & Accuracy & **30.76** & **23.06** & 21.27 & 31.61 & 26.80 & 21.22 & 31.61 & 26.80 & **19.17** \\ \hline \multirow{2}{*}{CIFAR-2} & Loss & 0.0196 & 0.0233 & 0.0236 & **0.0320** & **0.0469** & **0.0547** & **0.0320** & **0.0469** & **0.0547** \\ & Accuracy & 38.01 & 32.22 & 33.91 & **20.41** & **17.65** & **15.28** & **20.41** & **17.65** & **15.28** \\ \hline \multirow{2}{*}{CIFAR-3} & Loss & 0.0183 & 0.0222 & 0.0255 & **0.0231** & **0.0242** & **0.0363** & **0.0231** & 0.0234 & **0.0363** \\ & Accuracy & 41.19 & 36.57 & 30.59 & **25.50** & **19.57** & **15.03** & **25.50** & 19.83 & **15.03** \\ \hline \hline \end{tabular}
\end{table}
Table 9: Loss and accuracy of all models on the synthesized data for NP-SBFL-MGA on all the selected models. The best results per suspiciousness measure are shown in bold. K represents the number of suspicious neurons.
Figures 2 and 3 show the loss and accuracy of MNIST and CIFAR on the synthesized data for different approaches and suspicious measures. The figures reveal that among the different approaches, the suspicious paths reported by NP-SBFL-MGA are more responsible for insufficient DNN performance because it obtains the lowest accuracy and higher loss, except for MNIST_1, in all variant K. This observation suggests two points: 1) neural pathway fault localization is more successful than neuron-based fault localization in identifying a DNN low performance, and 2) a gradient ascent synthesizer technique is not suitable for activating sequences of neurons. The last point will be further discussed in RQ2.
We used the Wilcoxon rank-sum test [44] for statistical significance at a 95% confidence level and the Vargha and Delaney's A 12 statistics [45] for the effect size measure to compare the performance of NP-SBFL-MGA instances with other methods. Table 9 reports the results. According to the table, NP-SBFL-MGA had a statistically significant difference (p-value \(<\) 0.05) compared to other approaches for all CIFAR-10 models. However, for all MNIST models, NP-SBFL-MGA achieved significantly lower accuracy than other methods. We will further investigate this observation in our future work.
Tables 6 to 8 show that there is a performance difference for all instances when using different K values. Further analysis of the trend of accuracy and loss for each instance, respectively depicted in Figures 4 and 5, revealed that increasing K values during fault localization results in the synthesized inputs increasing accuracy and decreasing loss for all instances except for NP-SBFL-MGA. This trend is reversed for all instances of NP-SBFL-MGA except for MNIST with K = 10 when using Ochiai and Barinel. This achievement is because NP-SBFL-MGA uses a multi-stage gradient ascent technique, a layer-wise paradigm, to maximize the activation values produced by suspicious neural pathways, unlike DeepFault and NP-SBFL-GA.
Figure 2: Loss and accuracy of MNIST on the synthesized data for different approaches and suspicious measures.
Figure 3: Loss and accuracy of CIFAR on the synthesized data for different approaches and suspicious measures.
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{Approach} & \multirow{2}{*}{Model} & \multirow{2}{*}{Measure} & \multicolumn{2}{c}{Tarantula} & \multicolumn{2}{c}{Ochiai} & \multicolumn{2}{c}{Barinel} \\ \cline{3-8} & & & A12 & P-value & A12 & P-value & A12 & P-value \\ \hline \hline \multirow{4}{*}{DeepFault} & \multirow{2}{*}{MNIST} & Accuracy & **0.87** & \(<\)**0.001** & **1** & \(<\)**0.001** & **0.92** & \(<\)**0.001** \\ \cline{3-8} & & Loss & 0.62 & 0.01 & 0.48 & 0.04 & 0.35 & 0.10 \\ \cline{2-8} & \multirow{2}{*}{CIFAR} & Accuracy & **1** & \(<\)**0.001** & **1** & \(<\)**0.001** & **1** & \(<\)**0.001** \\ \cline{3-8} & & Loss & **0.97** & \(<\)**0.001** & **0.97** & \(<\)**0.001** & **0.97** & \(<\)**0.001** \\ \hline \hline \end{tabular}
\end{table}
Table 9: The statistical test compares the performance of NP-SBFL-MGA instances with other methods.
Figure 4: Accuracy of MNIST and CIFAR on the synthesized data using different approaches and suspicious measures for a variant number of suspicious neurons, K: MNIST(CIFAR).
_RQ1 (Validation)._ There is empirical evidence of suspicious neural pathways that could be causing inadequate DNN performance. NP-SBFL-MGA instances with different suspiciousness measures significantly improve localizing low performance compared to other approaches for most DNN models (except for the loss case on MNIST models).
Figure 5: Loss of MNIST and CIFAR on the synthesized data using different approaches and suspicious measures for a variant number of suspicious neurons, K: MNIST(CIFAR).
#### RQ2 (Comparison)
We compared suspiciousness measures in all instances and performed pair-wise comparisons using the Wilcoxon rank-sum test [44] for statistical significance at a 95% confidence level and the Vargha and Delaney's A'12 statistics [45] for the effect size measure to explore whether there are significant differences between Tarantula, Ochiai, and Barinel. Tables 11 and 12 present the results of these comparisons for MNIST and CIFAR10, respectively. Our study has concluded that NP-SBFG-MGA delivers superior results on all models when using any suspicious measure. This achievement suggests that the neural pathways identified as suspicious by NP-SBFG-MGA have a greater impact on DNN performance than other methods. Therefore, there is no single best spectrum-based suspiciousness measure. This finding is consistent with traditional fault localization techniques used in software development.
\begin{table}
\begin{tabular}{c
_RQ2 (Comparison)._ NP-SBFG-MGA with any suspiciousness measure is statistically superior to other instances in uncovering the low performance of models. These findings have significant implications for the field of neural network development and suggest that focusing on specific pathways rather than single neurons can lead to more accurate fault localization.
#### RQ3 (Fault Detection Rate)
Table 13 displays the proportions of synthesized samples that activate the critical pathways (C) and the proportions of failed synthesized samples that activate the faulty pathways (F) for each instance of all models. In the table, DF stands for DeepFault, NG for NP-SBFL-GA, and NM represents NP-SBFL-MGA. It can be observed that NP-SBFL-MGA using Tarantula achieves higher values in terms of both criteria C and F for all the models compared to the other instances. The second-best result is obtained by DeepFault using Ochiai. The effectiveness of the generated synthesized samples in activating faulty pathways for all approaches is represented by Figures 6 to 8, using Tarantula, Ochiai, and Barinel, respectively. These figures confirm that higher values of the number of covered critical pathways are associated with higher values of the number of failed tests. This point will be statistically proven in RQ4. Figure 7 further demonstrates that Ochiai effectively detects faulty neurons for all models. The results of Figure 6 indicate that Tarantula performs effectively in detecting faulty pathways across all models. The results of DeepFault using Tarantula and Barinel are not as satisfactory for CIFAR10, while NP-SBFL-GA and NP-SBFL-MGA show similar levels of effectiveness for all models.
Figure 6: A comparison between the averaged ratios of failed synthesized tests and the synthesized samples activating faulty pathways for Tarantula in different models and approaches.
_RQ3 (Fault Detection Rate)._ NP-SBFL-MGA using Tarantula is the most effective approach regarding the ratio of failed synthesized test samples activating faulty pathways for all models. Moreover, Ochiai is an acceptable option for detecting faulty neurons, while Tarantula is a good alternative for detecting faulty pathways.
#### RQ4 (Correlation)
Figure 9 displays the scatter plots illustrating the correlation between the rate of covered critical pathways and failed tests across all instances and models. Except for DeeFault using Ochiai and NP-SBFL-GA using Tarantula, it is observed that an increase in the rate of covered critical pathways leads to a corresponding increase in the rate of failed tests.
We utilized the Spearman correlation coefficient to investigate the statistical correlation between these variables [46]. The reason for selecting the Spearman correlation is its ability to quantify the strength of a monotonic relationship between two variables while remaining agnostic about the relationship's form or the distribution of the data [46]. Our findings indicate a significant positive correlation between the variables. The obtained correlation results are presented in Table 14, encompassing various instances of all DNN models. Bold values within the table denote statistically significant correlations (p-value \(<=\) 0.05). Consequently, our results showcase statistically significant correlations between the rate of covered critical pathways and the percentage of failed tests in all instances.
Figure 8: A comparison between the averaged ratios of failed synthesized tests and the synthesized samples activating faulty pathways for Barinel in different models and approaches.
Figure 7: A comparison between the averaged ratios of failed synthesized tests and the synthesized samples activating faulty pathways for Ochiai in different models and approaches.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{Approach} & \multirow{2}{*}{Measure} & \multicolumn{2}{c}{MNIST} & \multicolumn{2}{c}{CIFAR} \\ \cline{3-5} & & Spearman & P-value & Spearman & P-value \\ \hline \multirow{3}{*}{DeepFault} & Tarantula & **0.99** & **< 0.001** & **1** & **0** \\ \cline{2-5} & Ochiai & **0.93** & **< 0.001** & **0.91** & **< 0.001** \\ \cline{2-5} & Barinel & **0.99** & **< 0.001** & **1** & **0** \\ \hline \hline \end{tabular}
\end{table}
Table 13: Correlation results between the number of covered critical pathways and the detected faults by different approaches. The bolds refer to statistically significant correlations (p-value \(<\)= 0:05).
Figure 9: The correlation between the rate of covered critical pathways and failed tests across all instances and models.
#### RQ5 (Locating Unique Suspicious Neurons)
Figure 10 displays the ratios of common neurons in inputs synthesized by NP-SBFL-MGA using Tarantula, Ochiai, and Barinel for various K and different models. Notably, from the left part of Figure 10, Ochiai and Barinel detected the same suspicious neurons, albeit with varying levels of suspicion. Conversely, the right part of Figure 10 reveals that Tarantula identified entirely distinct neurons, particularly in convolutional networks. It shows that the suspicious neurons detected by Tarantula yielded higher reliability levels than those detected by Ochiai and Barinel.
Figure 11 illustrates the ratios of common neurons between the best results of DeepFault using Ochiai for K = 10 (50) and the best results of NP-SBFL-MGA using Tarantula for K = 10 (5). As observed in Figure 5, fully-connected networks exhibit more common neurons between NP-SBFL-MGA and DeepFault. However, it is worth noting that suspicious neurons detected by NP-SBFL-MGA differ significantly for larger models such as convolutional networks.
Figure 10: A comparison between the Ratios of common neurons in each layer of a DNN model for NP-SBFL-MGA using Ochiai against Barinel (left) and Tarantula against Ochiai/Barinel (right).
_RQ5 (Locating Unique Suspicious Neurons)._ Ochiai and Barinel detect common suspicious neurons but with varying suspicion levels among the different suspicious measures. However, Tarantula identifies distinct neurons, particularly in convolutional networks, and detects the neurons with higher reliability than those detected by Ochiai and Barinel. Besides, more common neurons between DeepFault and NP-SBFL-MGA are observed in fully-connected networks. The significant differences are in suspicious neurons detected by NP-SBFL-MGA for complex models like convolutional networks.
#### RQ6 (Quality of Synthesized Inputs)
This section examines the quality of the generated inputs for NP-SBFL-MGA and the baseline approach DeepFault. We analyze the distance between the original and synthesized images using various distance metrics, such as \(L_{1}\) Manhattan, \(L_{2}\) Euclidean, and \(L_{\infty}\) Chebyshev. Additionally, we consider the naturalness scores, including inception score (IS) [47] and Frechet Inception Distance (FID) [48], for different values of K (# suspicious neurons) in both approaches.
Table 15 presents the results for the quality of synthesized inputs over different K values. According to the table, for MNIST models, DeepFault exhibits a consistent degree of perturbation regardless of the value of K. On the other hand, NP-SBFL illustrates an increase in distances as K increases. Both approaches yield comparable IS scores. However, DeepFault outperforms NP-SBFL-MGA regarding FID values for CIFAR models, indicating a higher level of naturalness.
Table 16 compares the distances between the original and synthesized images based on different suspiciousness measures employed by various approaches. The scores for these measures are relatively close for all models in a specific approach, except for DeepFault using Ochiai over the CIFAR model, where a notable difference is observed. Specifically, the inputs synthesized by DeepFault instances using Ochiai achieve the best FID value, while those synthesized by NP-SBFL instances using Tarantula demonstrate the best FID value. In the case of MNIST, Tarantula, and Barinel exhibit the same distance for DeepFault and are lower than Ochiai.
These findings provide insights into the quality of the generated inputs and the performance of different approaches in terms of perturbation and naturalness scores. The results highlight the strengths and weaknesses of NP-SBFL-MGA and DeepFault, shedding light on their suitability for specific models and metrics.
_Table 14. A comparison between the quality of synthesized input over different K values. K: MNIST(CIFAR)._
\begin{tabular}{|c|c|c|c|c|c|c|} \hline \multirow{2}{*}{K} & \multirow{2}{*}{Approach} & \multicolumn{3}{c|}{MNIST} & \multicolumn{3}{c|}{CIFAR} \\ \cline{3-8} & & \(L_{1}\) & \(L_{2}\) & \(L_{\infty}\) & IS (mean) & IS (std) & FID \\ \hline \end{tabular}
Figure 11: A comparison between the ratio of common neurons in each layer of a DNN model for the best results of NP-SBFL-MGA and DeepFault.
### Threats to Validity
**Construct Validity**: When conducting experiments, there is a possibility of challenges to the accuracy of the results. Poor accuracy can occur due to various factors, including the selection of datasets and DNN models. To ensure the reliability of our research, we have taken steps to address these potential concerns. Firstly, we have used well-known and widely studied public datasets, such as MNIST and CIFAR-10. Furthermore, we have applied our NP-SBFL method to multiple DNN models with distinct architectures, which have all shown competitive prediction accuracies, as shown in Table 4. Additionally, we have incorporated established suspiciousness measures from the field of fault localization in software engineering, outlined in Algorithm 1, to mitigate any potential threats related to identifying suspicious neural pathways. These efforts contribute to the overall robustness and validity of our research findings.
**Internal Validity**: To ensure the accuracy of NP-SBFL-MGA's ability to produce new inputs that trigger suspicious neural pathways, we addressed potential threats to internal validity. We utilized various distance metrics to verify that the generated inputs closely resemble the original inputs and are comparable to those generated by DeepFault. We also took measures to prevent NP-SBFL-MGA's suspiciousness measures from accidentally outperforming the baselines. We performed a non-parametric statistical test, specifically the Wilcoxon rank-sum test [44] for statistical significance at a 95% confidence level and Vargha and Delaney's A'12 statistics [45] for the effect size measure to compare the performance of NP-SBFL-MGA and the baselines, and assess any significant differences.
**External Validity:** To address potential issues with external validity, NP-SBFL needs to be able to examine the internal structure of DNN and gather data on the activation patterns of neurons to assess their level of suspicion accurately. To achieve this, we utilized PyTorch in developing NP-SBFL, enabling comprehensive white-box analysis of DNNs. While we have examined various measures of suspicion, we acknowledge the potential existence of other measures. Furthermore, we have validated NP-SBFL against multiple instances of DNNs trained on widely-used datasets to ensure its practicality. However, further experiments are needed to assess the efficacy of NP-SBFL in different domains and networks [48].
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline \multirow{2}{*}{Measure} & \multirow{2}{*}{Approach} & \multicolumn{4}{c|}{MNIST} & \multicolumn{3}{c|}{CIFAR} \\ \cline{3-8} & & \(L_{1}\) & \(L_{2}\) & \(L_{\infty}\) & IS (mean) & IS (std) & FID \\ \hline \multirow{2}{*}{Tarantula} & DeepFault & **6022.74** & **334.31** & **25.37** & 1.00 & 0.00 & **46.90** \\ \cline{2-8} & NP-SBFL-MGA & 12314.54 & 619.14 & 46.27 & 1.00 & 0.00 & 48.22 \\ \hline \multirow{2}{*}{Ochiai} & DeepFault & **7500.54** & **395.60** & **25.49** & 1.01 & 0.00 & **32.47** \\ \cline{2-8} & NP-SBFL-MGA & 12276.75 & 618.33 & 45.80 & 1.00 & 0.00 & 49.95 \\ \hline \multirow{2}{*}{Barinel} & DeepFault & **6022.74** & **334.31** & **25.37** & 1.00 & 0.00 & **46.90** \\ \cline{2-8} & NP-SBFL-MGA & 12261.40 & 617.59 & 45.78 & 1.00 & 0.00 & 49.96 \\ \hline \end{tabular}
\end{table}
Table 15: A comparison between the quality of synthesized input over different suspicious measures.
Conclusion
Deep Neural Networks have successfully solved complex tasks in many real-world applications, such as image classification, recognizing human speech, natural language processing, and software engineering. However, despite their high accuracy, DNNs have quality issues and cannot classify samples correctly in real-world applications. Therefore, there is a need for an effective assessment of the quality of DNNs, especially in safety- and security-critical systems. In this paper, we propose a new fault localization method called NP-SBFL that identifies critical neurons using the Layer-wise Relevance Propagation technique and then determines which critical neurons are faulty. The method's effectiveness is demonstrated on two benchmark datasets, MNIST and CIFAR-10, showing its high accuracy and efficiency in fault localization. We also propose a novel methodology to verify the detected faulty paths based on gradient ascent. Our results show that NP-SBFL is highly effective and can achieve an average 96.75% fault detection rate for all models under test. It substantially outperforms the DeepFault technique that analyzes neurons as the root cause of faults in the neural network. Moreover, the multi-stage gradient ascent used in NP-SBFL is more effective than the simple gradient ascent.
In the future, we plan to evaluate NP-SBFL on various other DNNs and datasets. Some examples of these include the steering wheel control of a self-driving car and the Udacity dataset. Additionally, we aim to enhance the suspiciousness-guided synthesis algorithm, expand the creation of synthesized inputs, and explore methods for fixing faulty neural pathways. Furthermore, we intend to design explicit criteria to confine critical pathways, improving syntenies inputs' naturalness. These endeavors are crucial in assessing the resilience of DNNs and facilitating the development of safety cases.
#### Declaration of generative AI and AI-assisted technologies in the writing process
During the preparation of this work the authors used ChatGPT-3.5 in order to improve language and readability of the work. After using this tool/service, the authors reviewed and edited the content as needed and takes full responsibility for the content of the publication.
|
2302.09443 | VITAL: Vision Transformer Neural Networks for Accurate Smartphone
Heterogeneity Resilient Indoor Localization | Wi-Fi fingerprinting-based indoor localization is an emerging embedded
application domain that leverages existing Wi-Fi access points (APs) in
buildings to localize users with smartphones. Unfortunately, the heterogeneity
of wireless transceivers across diverse smartphones carried by users has been
shown to reduce the accuracy and reliability of localization algorithms. In
this paper, we propose a novel framework based on vision transformer neural
networks called VITAL that addresses this important challenge. Experiments
indicate that VITAL can reduce the uncertainty created by smartphone
heterogeneity while improving localization accuracy from 41% to 68% over the
best-known prior works. We also demonstrate the generalizability of our
approach and propose a data augmentation technique that can be integrated into
most deep learning-based localization frameworks to improve accuracy. | Danish Gufran, Saideep Tiku, Sudeep Pasricha | 2023-02-18T23:43:45Z | http://arxiv.org/abs/2302.09443v1 | VITAL: Vision Transformer Neural Networks for Accurate Smartphone Heterogeneity Resilient Indoor Localization
###### Abstract
Wi-Fi fingerprinting-based indoor localization is an emerging embedded application domain that leverages existing Wi-Fi access points (APs) in buildings to localize users with smartphones. Unfortunately, the heterogeneity of wireless transceivers across diverse smartphones carried by users has been shown to reduce the accuracy and reliability of localization algorithms. In this paper, we propose a novel framework based on vision transformer neural networks called VITAL that addresses this important challenge. Experiments indicate that VITAL can reduce the uncertainty created by smartphone heterogeneity while improving localization accuracy from 41% to 68% over the best-known prior works. We also demonstrate the generalizability of our approach and propose a data augmentation technique that can be integrated into most deep learning-based localization frameworks to improve accuracy.
Vision Transformer, Neural Networks, Indoor localization, Device Heterogeneity, Fingerprinting
## I Introduction
Indoor localization systems (ILS) allow the localization of items or persons within buildings and subterranean facilities (e.g., underground tunnels, mines). As the Global Positioning System (GPS) is unreliable in indoor settings due to the lack of visible contact with GPS satellites, an ILS must rely on alternative means of localization. These include techniques such as triangulation and fingerprinting with wireless technologies, e.g., Wi-Fi, Bluetooth Low Energy (BLE), Ultra-Wideband (UWB), and Radio Frequency Identification (RFID) [1]. Such ILS techniques are now powering several geo-location-based embedded systems and business platforms including Amazon warehouses robots, parking features in self-driving cars, IoT indoor navigation solutions, and so on [2].
Out of the available approaches, fingerprinting has shown to be one of the most scalable, low-cost, and accurate indoor localization solutions [3, 4]. The operation of fingerprint-based ILS is divided into two phases. The supplier of the ILS gathers received signal strength indication (RSSI) data for wireless Access Points (APs), such as Wi-Fi APs, at various indoor locations of interest during the first (offline) phase. The unique RSSI values at each location form a "fingerprint" vector at that location, which is different from the fingerprint vector at other locations. Subsequently, a database of RSSI fingerprint vectors and their corresponding locations is created. This database can be used together with pattern matching algorithms to estimate location in the second (online) phase, where a person uninformed of their location captures an RSSI fingerprint using their smartphone and sends it to the algorithm (on the smartphone or a cloud server) to predict their location. This predicted location can be displayed on the smartphone for real-time location visualization.
In recent years, Wi-Fi-based fingerprinting when combined with machine learning has been shown to provide promising accuracy for indoor location predictions [5]. Neural networks can capture prominent features in RSSI values from Wi-Fi signals captured by a smartphone and map these features to the location of the smartphone, which is often referred to as the Reference Point (RP) prediction problem. Despite the claimed benefits of Wi-Fi fingerprinting-based indoor localization, there remain several unresolved issues. Wi-Fi signals are affected by poor wall penetration, multipath fading, and shadowing. Due to these difficulties, establishing a deterministic mathematical relationship between the RSSI and distance from APs is challenging, especially in dynamic environments and across different device configurations. The latter problem is particularly challenging as different smartphones use different wireless transceivers, which significantly changes RSSI values captured by the different smartphones at the same location.
The performance of indoor localization solutions today is very susceptible to heterogeneity within smartphones, as well as other embedded and IoT devices that may participate in ILS. We quantify the impact of this device heterogeneity on several smartphone devices in Section III. This device heterogeneity leads to unpredictable variation in performance (location estimates) across users that may be present at the same physical location. The variations reduce precision, and ultimately the accuracy of ILS.
In this paper, we present VITAL, a novel embedded software framework that enables robust and calibration-free Wi-Fi-based fingerprinting for smartphones, with broad applicability to embedded and IoT devices used in ILS. VITAL aims to achieve device invariance with the end goal of achieving negligible precision error across heterogeneous smartphones and high-accuracy localization. Our framework employs vision transformer neural networks for the first time to the problem of Wi-Fi fingerprinting-based indoor localization. RSSI data is converted to images and processed using novel algorithms that integrate the transformer neural network to assist with device heterogeneity-resilient indoor localization.
The main contributions of our work are:
* We present a novel vision transformer neural network-based indoor localization solution that is resilient to device heterogeneity and achieves high-accuracy localization.
* We propose a novel RSSI image-based model to capture prominent features from Wi-Fi RSSI fingerprints,
* We design a data augmentation technique that can be seamlessly integrated into any deep learning model, including vision transformers, to improve heterogeneity resilience,
* We evaluate the localization performance of VITAL against the best-known indoor localization solutions from prior work, across several real indoor paths in multiple buildings, and for various smartphones carried by users.
## II Related Works
Indoor localization competitions in recent years held by Microsoft [6] and NIST [7] have advocated for Wi-Fi fingerprinting-based indoor localization as the foundation for future ILS. The improvements in the computational abilities of smartphones and embedded platforms have empowered them to execute deeper and more powerful machine learning (ML) models to improve indoor localization performance. Thus, many efforts in recent years have started to explore the use of ML with Wi-Fi fingerprinting.
A survey of ML-based Wi-Fi RSSI fingerprinting schemes, including data preprocessing and ML prediction models for indoor localization, was presented in [8]. In [9], an analysis was performed to determine how to select the best RSSI fingerprints for ML-based indoor localization. In [10] and [11], Deep feedforward Neural Networks (DNNs) and Convolutional Neural Networks (CNNs) were shown to improve indoor localization accuracies over classical localization algorithms. A recent work in [12] explored the traditional transformer neural network on Channel State Information (CSI) data
for indoor localization. The work in [13] proposes an early-exit deep neural network strategy for fast indoor localization on mobile devices. These prior works motivate the use of ML-based techniques for indoor localization. However, none of these efforts address real-world challenges related to device heterogeneity.
The work in [14] performed a comparative study on the behavior of classification and regression-based ML models and their ability to deal with device heterogeneity. In [15], an unsupervised learning mechanism with Generative Adversarial Networks (GAN) was used for data augmentation with deep neural networks. However, this work does not address localization with noisy fingerprint data (e.g., fluctuating RSSI data from different smartphones). The work in [16] employed a deep autoencoder for dealing with noisy fingerprint data and device heterogeneity. The deep autoencoder was used along with traditional K-Nearest-Neighbor (KNN) classification models, but results for the approach across smartphones are not promising. Calibration-free approaches were proposed that used Signal Strength Difference (SSD) and Hyperbolic Location Fingerprints (HLF) with pairwise ratios to address heterogeneity [18]. However, both these approaches also suffer from slow convergence and high errors across larger sets of diverse smartphones.
The recent works ANVIL [19], SHERPA [20], CNNLoc [21], and WiDeep [22] improve upon the efforts mentioned above, to more effectively cope with device heterogeneity while maintaining lower localization errors. In, [19] a multi-headed attention neural network-based framework was proposed for indoor localization. The work in [20] combined KNN and deep neural networks for fingerprint classification. In [21], CNNs were used for regression-based localization prediction. The work in [22] employed a stacked autoencoder for data augmentation and a Gaussian process classifier for localization classification. The ML models and augmentation techniques in all of these works aim to improve resilience to device heterogeneity while minimizing localization error.
As [19]-[23] represent the state-of-the-art heterogeneity-resilient indoor localization efforts, we modeled these frameworks and used them to contrast against our framework. Deep learning models used for indoor localization are typically very large in size, consisting of millions or even billions of parameters, which can make them challenging to deploy on resource-constrained devices [24]. Model compression techniques can be used to reduce the size of these models, making them more efficient to deploy in real-world applications [25]. This is particularly important for indoor localization, where accurate and efficient models are necessary to locate users within indoor environments. The works in [24, 25] demonstrate strategic approaches in reducing the model dimensionality without compromising the model's performance. Mobile devices are also vulnerable to security threats such as data breaches and unauthorized access [26]. Overcoming security vulnerabilities in deep learning-based indoor localization frameworks on mobile devices is crucial to ensure the privacy and security of user data [26].
Our proposed VITAL framework integrates a novel data augmentation approach with an enhanced vision transformer neural network to achieve promising results for resilience towards device heterogeneity, while maintaining extremely low localization errors, as shown in Section VI.
## III Analysis Of RSSI Fingerprints
To illustrate the challenge due to device heterogeneity during Wi-Fi fingerprinting-based indoor localization, we present RSSI values captured by four different smartphones at a single location. These devices are a subset of those used to evaluate our proposed framework against the state-of-the-art, with results in Section VI. Figure 1 shows a plot of the RSSI from the four smartphones. The RSSI values captured are in the range of -100dB to 0dB, where -100dB indicates no visibility and 0dB is the strongest signal. The figure shows 10 RSSI values from 10 different Wi-Fi APs captured at a single location. The solid lines represent mean RSSI values across 10 samples taken for each smartphone at that location. Note that the RSSI values are combined into a "fingerprint" vector for that location. From the figure, we can make the following observations:
* The RSSI values captured by the different smartphones show deviations from each other, which is referred to as the AP visibility variation problem in indoor localization. Our proposed framework is curated to address this problem.
* There are similarities in RSSI patterns between some device pairs, such as between HTC-U11 and Galaxy-S7, and between iPhone-12 and Pixel-4. Even though there is variation across the patterns, it is possible to develop a calibration-free deep learning model, to learn to predict locations for these patterns.
* The skews of RSSI variations, even among the pairs of devices with similar patterns, are not fixed. This complicates the learning problem. To overcome this, we propose a powerful image-based fingerprinting technique that converts the RSSI fingerprints to an image that emphasizes high-visibility APs.
* Some APs that are visible to a smartphone may not be visible with a different smartphone at the same location. For example, the WiFi AP with a MAC ID (80:8d:b7:55:39\(\times\)c1) is only visible to the HTC-U11 device (-81dB value) but is not visible for the other smartphones (-100 dB value). This is referred to as the missing APs problem in indoor localization. We develop a novel data augmentation module to address this challenge.
We analyzed RSSI patterns across multiple locations in different buildings and with additional smartphones (results for which are presented in Section VI), and our observations were consistent with the discussion above. The observed discrepancies in RSSI readings motivated our design of the novel VITAL framework that improves upon the state-of-the-art in fingerprinting-based indoor localization.
## IV Vision Transformers: Overview
A transformer is a powerful deep neural network model that relies on the self-attention mechanism [17]. The self-attention mechanism mimics human cognitive attention, enhancing some parts of the input data while diminishing other parts, via a differential weighting approach. The motivation for doing so is to force the neural network to devote more focus to the small, but important, parts of the data. Learning which part of the data is more important than another depends on the context, which is trained by gradient descent. Transformers are today being widely used in Natural Language Processing (NLP) tasks.
Since the original transformer was proposed, many efforts have attempted to go beyond NLP and apply it to computer vision tasks. Unfortunately, the naive application of self-attention to images requires that each pixel attends to every other pixel. With quadratic cost in the number of pixels, this does not scale to realistic input sizes. The vision transformer (ViT) model [27] was recently
Figure 1: RSSI values of ten Wi-Fi APs observed by four different smartphones at the same location. The values differ significantly across devices.
proposed as a scalable approach to applying transformers to image processing. ViT improves upon the traditional transformer model which lacks some of the image-specific inductive biases (such as translation equivariance and locality) that make convolutional neural networks (CNNs) very effective for computer vision tasks.
An overview of the ViT model is depicted in Figure 2. ViT consists of three main components: 1) position embedding of patches, 2) transformer encoder block, and 3) a Multi-Layer Perceptron (MLP) head. The first component of ViT creates patches from an image, essentially dividing the input image into small chunks and then positionally encoding each chunk to retain the order of the patches created. These positionally encoded patches are referred to as embedded patches and allow the ViT to be permutationally invariant. The embedded patches are subsequently sent as inputs to the transformer encoder, which is the second component. The layers of the transformer encoder are shown in Figure 2 and consist of \(L\) alternating layers of a multi-headed self-attention (MSA) and an MLP block, in addition to layer normalizations, and residual connections. In the MSA block \(h\) denotes the number of heads. The output of the transformer is sent to the third component, which is an MLP head that contains two layers with a GELU non-linearity for classification.
## V Vital Framework
Figure 3 shows an overview of our proposed VITAL framework that adapts (and enhances) vision transformers for the indoor localization problem. The proposed framework consists of 2 phases, namely the offline phase, depicted with red arrows, and the online phase, depicted with blue arrows. In the offline phase, the RSSI fingerprints are captured at each RP, with different smartphones, across various buildings. We use three fingerprint values at each RP and create a 1D image with three channels using a custom RSSI image creator. This module maps the three RSSI readings for each AP to a pixel. Thus, a pixel represents the three RSSI values for an AP, and the fingerprint vector at an RP consists of RSSI readings for all APs, in the form of a 1D image. The 1D image is pre-processed with a data augmentation module (DAM) and represented as 2D images. These images are then sent as inputs to a vision transformer model, to learn the mapping between the fingerprints and RP locations. In the online phase, the user requesting their location captures RSSI fingerprints from the smartphone at an unknown location. The RSSI fingerprints are pre-processed with DAM and represented as an image, as done in the offline phase. The image is then sent to the trained vision transformer to predict the location.
In the following subsections, we describe the two main components of our framework: DAM and the vision transformer.
### _Data augmentation module_
Our data augmentation module (DAM) is responsible for preparing the input data to help improve the sensitivity of location prediction and make it calibration-free. DAM consists of four stages as shown in Figure 3: data normalization, fingerprint replication, random dropout, and gaussian noise.
The first stage normalizes the input data. This is an important step as it ensures that each pixel has a similar distribution, making the convergence faster during training. The layer standardizes the features in the fingerprint to achieve smoother gradients and better generalization during training. The second stage replicates the fingerprint data to concatenate the augmented features with the original features as a single image. The replication is done such that the input 1D image size of 1\(\times\)\(R\) (where \(R\) is the number of RPs) is augmented and represented as a 2D image of size \(R\)\(\times\)\(R\). We explored various image augmentation sizes to determine the optimal value, and this study is presented in Section VI.B. The third and fourth steps involve the addition of random dropout and Gaussian noise. The random dropout is used to randomly drop some APs or features in the input data to represent missing APs and allow the model to be robust to missing APs when making location predictions. The Gaussian noise is used to infill the dropped features with some random noise to represent different AP visibilities. This allows capturing the effect of fluctuating RSSI values due to dynamic environmental factors in indoor locations and makes the trained model more robust to RSSI variations.
In our framework, DAM is applied after the fingerprint capture step. This module can be integrated into any ML framework to improve robustness of indoor localization. In fact, we demonstrate in Section VI.D that DAM can have a notable positive impact for many indoor localization frameworks from prior work.
### _Vision transformer_
The output from DAM is sent to a vision transformer model that we modify and adapt for the indoor localization problem domain. We modified some of the layers from the vision transformer model proposed in [27], and make changes to the image creation process, input parameters for the MSA, and the MLP layers in the transformer encoder and the classification head, as discussed below.
Post augmentation from DAM, we now have a 2D image of size \(R\)\(\times\)\(R\). This image is sliced into small patches of size \(\bar{P}\)\(\times\)\(P\). We
Figure 3: An overview of the proposed device heterogeneity-resilient VITAL indoor localization framework.
Figure 2: Overview of Vision Transformer Neural Network
explored the impact of different patch sizes, with results presented in Section VI.2. The number of patches per image is represented as \(N\), where \(N\) is calculated by dividing the area of the input image (\(H^{*}\#I\)) by the area of the patch sizes, i.e., \(N=(H^{*}\#I)(P^{*}P)\). The \(N\) patches serve as an input sequence to the vision transformer. As the model expects a constant vector of size \(N\) for all its layers, to satisfy this requirement, we flatten the patches and map them as a linear trainable projection. These projections are then sent to the transformer encoder block.
The self-attention sub-block in the transformer encoder calculates a weighted average for each feature in the projections from the input image. The weights are proportional to the similarity score between each feature. The attention mechanism in the sub-block is modeled such that it extracts values (\(I\)) with associated keys (\(K\)) for a given query (\(Q\)). Through this, we calculate attention as:
\[Attention(Q,K,V) =\sqrt[]{\textit{softmax}(\textit{Dot Score})V} \tag{1}\] \[\textit{Dot Score} =\left(\begin{array}{c}Q\ \textit{K}^{T}\sqrt[]{d_{k}}\end{array}\right)\] (2) \[Q =XW^{Q}\,K =XW^{K},V=XW^{V} \tag{3}\]
where \(d_{k}\) is the dimensionality of the key, \(X\) is the input, and \(W^{Q}\), \(W^{K}\), and \(W^{v}\) are the trainable weight matrices for \(Q\), \(K\), and \(V\), respectively. In our framework, \(Q\) is the patched images, \(K\) is the one-hot encoded positions of each patch, and \(V\) is the one-hot encoded RP locations of the input image. The higher the dot product score, the higher the attention weights will be, which is why it is considered a similarity measure. Using this information, we implement a multi-headed self-attention (MSA) mechanism to extract information from different input representations. Multi-head attention allows the model to jointly attend to information from different representation subspaces at different positions. With a single attention head, averaging inhibits this. The multi-headed attention function is expressed as:
\[\textit{MultiHead}(Q,K,V)=Concat(h_{k},h_{2},-h_{n})W^{n}\] \[\textit{where }h_{i}=Attention(QW^{Q},KW^{k},WW^{v}) \tag{4}\]
We use sensitivity analysis to determine the optimal number of MSA heads in Section VI.2. The encoder comprises an MSA sub-block and an MLP sub-block with two dense neural network layers and a GELU non-linearity. We used layer normalization before each MSA and MLP sub-block to independently normalize inputs across all features, and concatenated the MSA sub-block output with the MLP sub-block outputs to restore any lost features. The encoder outputs a vector of values that corresponds to the location class of the input RSSI image. To make the indoor localization framework calibration-free, we fine-tuned the output from the transformer encoder using a fine-tuning MLP block with a series of MLP layers. We explored the optimal number of dense layers via sensitivity analysis (Section VI.2), and set the last dense layer to contain as many neurons as the number of RPs.
After training, we deployed the model on smartphones for online inference. To predict the unknown location from RSSI values collected at an unknown location, we pre-processed and represented the RSSI fingerprints as images, as done in the offline phase, and sent the requesting image to our vision transformer neural network.
The VITAL framework is set to be calibration-free by group training the neural network model. The group training combines RSSI fingerprint data from different smartphones for RPs. This approach allows the model to learn the vagaries of RSSI visibility across different smartphones. In the next section, we present our experimental results, including the performance of the trained model on new smartphones not used in the RSSI training data pool.
## VI Experimental Results
### _Indoor paths and smartphones_
The VITAL framework was evaluated in four different buildings. The RSSI fingerprints are captured along paths in each of the buildings, as shown in figure 4. The samples were collected using a granularity of 1 meter between each RP. The blue dots in figure 4 represent the RPs for fingerprint collection. The path lengths varied from 62 meters to 88 meters. Each building also had a different number of Wi-Fi access points (WAPs). Note that only a subset of the WAPs present in a building were visible at each of the RPs in that building. Each of the buildings also had a very different material composition (wood, metal, concrete) and was populated with diverse equipment, furniture, and layouts, creating different environments in which to evaluate our framework as well as other heterogeneity-resilient localization frameworks from prior work.
For our experiments, we made use of six distinct smartphones from different manufacturers, to capture RSSI data across the RPs in the four buildings and train the indoor localization frameworks. Table I summarizes the details of these smartphones. The devices operated under the latest OS available at the time of this experiment. We refer to this set of devices as 'Base' devices. The RSSI data captured across the building consisted of five RSSI data samples captured at an RP for each of the six smartphones, across the four buildings. These five values were reduced down to three by capturing their min, max, and mean values, and used to create the three channels for each element (pixel) in the fingerprint vector that is input to our VITAL framework. The RSSI data captured was split into two datasets: training (approximately 80%) and testing (approximately 20%), with results reported for the testing dataset.
### _Hyperparameter exploration_
The VITAL framework involves multiple hyperparameters. While an exhaustive search across all possible values for all hyperparameters was not practically possible, we focused on analyzing four critical hyperparameters across the pre-processing and transformer architecture design, as part of a sensitivity analysis. In the first analysis, we focused on the input pre-processing phase in VITAL, within DAM. Figure 5 depicts the impact of different RSSI fingerprint image sizes and patch sizes on the mean indoor localization error with the VITAL framework. From the results, we conclude that an RSSI fingerprint image size of R\(\times\)R = 206\(\times\)206 and patch size of P\(\times\)P = 20\(\times\)20 results in the least mean localization error. Smaller patch sizes under-perform as they
\begin{table}
\begin{tabular}{|l|l|l|l|} \hline
**Manufacturer** & **Model** & **Acronym** & **Release Date** \\ \hline BLU & Vivo 8 & BLU & 2017 \\ HTC & U1 & HTC & 2017 \\ \hline Samsung & Galaxy S7 & 2016 \\ \hline LG & V20 & LG & 2016 \\ \hline Motorola & Z2 & MOTO & 2017 \\ \hline Oneplus & OnePlus 3 & OP3 & 2016 \\ \hline \end{tabular}
\end{table} TABLE I: Smartphones used for evaluation (Base devices).
Fig. 4: Benchmark indoor paths that were used for fingerprint collection. We collected RSSI data across four buildings, with varying path lengths. The blue dots indicate reference points (RP) at which the RSSI reading were taken. Six different smartphones were used to capture RSSI data at each RP.
lead to a greater number of patches being created, which tends to over-fit the data, whereas larger patch sizes tend to under-fit the data. The RSSI fingerprint image sizes had relatively less impact on the localization error. However, we did note that image sizes that led to the creation of partial patches at the boundaries, led to the discarding of some features, which tended to reduce accuracy.
We further explored two hyperparameters of the vision transformer encoder block used within the VITAL framework. We analyzed the impact of the number of multi-headed self-attention (MSA) heads and dense layers in the fine-tuning MLP block on the mean indoor localization error. Figure 6 shows a heatmap of this exploration. We observe that an MSA head count of five and two fine-tuning MLP layers show the least mean indoor localization error (shown in meters in Figure 6). A lower number of MLP layers tends to under-fit the data whereas a higher number of MLP layers tends to over-fit the data. We also observe that the number of MSA heads has a significant impact on the model's performance. A higher head count tends to over-fit the data.
Based on the results from our hyperparameter analysis, we finalized the configuration of the VITAL framework that was used to compare with frameworks from prior work (next Section). We used an RSSI fingerprint image size of \(R\)\(\times\)\(R\) = 206\(\times\)206, patch size of \(P\)\(\times\)\(P\) = 20\(\times\)20, number of transformer encoder blocks \(L\)=1, number of MSA heads \(-\) 5, number of dense layers in the MLP sub-block within the encoder = 2 (with 128 and 64 units, respectively), and the number of dense layers in the fine-tuning MLP block = 2 (with 128 and _num_classes_ units, respectively). The total number of trainable parameters in the transformer model was 234,706. This compact model was able to perform inference within \(\sim\)50ms, making it amenable to deployment on memory-constrained and computationally limited embedded and IoT platforms.
### _Comparison with state-of-the-art_
We compared our VITAL framework with four state-of-the-art frameworks for heterogeneity-resilient indoor localization: ANVIL [19], SHERPA [20], CNNLoc [21], and WiDeep [22]. These frameworks have shown the most promising results for device heterogeneity tolerance during indoor localization. ANVIL [19] employs a multi-headed attention mechanism and a Euclidean distance-based matching approach to achieve device heterogeneity tolerance. In our proposed VITAL framework, we enhance the attention mechanism used in ANVIL using multi-headed self-attention as part of the vision transformer encoder, as explained earlier. CNNLoc [21] employs a combination of stacked autoencoder (SAE) and 1D CNN to tackle device heterogeneity. The SAE is used as an augmentation to better deal with noisy fingerprint data. In VITAL, we make use of the more powerful DAM, described earlier, to deal with noisy data. Lastly, SHERPA [20] employs a KNN algorithm enhanced with DNNs and WiDeep [22] utilizes a Gaussian Process Classifier enhanced with an SAE, respectively.
Figure 8 shows a color-coded comparison of VITAL with these state-of-the-art frameworks. We can observe that WiDeep consistently shows high mean errors across most buildings, making
Figure 5: Surface plot showing the impact of patch size and RSSI image sizes on the mean indoor localization error.
Figure 8: Min (lower whisker), Mean (red bar), and Max (upper whisker) error across all buildings for comparison frameworks w/ base devices
Figure 6: Impact of number of fine tuning MLP layers and number of MSA heads in our vision transformer model on mean indoor localization error.
Figure 7: Mean indoor localization error across all six smartphones, four building, and localization frameworks.
it the worst performing framework. One possible explanation for this is the effect of the de-noising SAE, which very aggressively creates noisy reconstructions of the inputs in a manner that makes it difficult for the classifier to arrive at accurate predictions. CNNLoc also employs SAE but shows better results compared to WiDeep. as its algorithms can deal with noisy data more effectively. Interestingly, CNNLoc fails to localize accurately in less noisy environments, such as that found in Building 4. ANVIL and SHERPA show better results than WiDeep and CNNLoc, with a few outliers. Our proposed VITAL framework shows overall much better results than these four state-of-the-art frameworks as it uses a more powerful learning engine (transformer) and is better able to exploit heterogeneous fingerprints captured across smartphones than the other frameworks. To better visualize the performance of these frameworks, Figure 8 shows a box plot with minimum, maximum, and mean errors across all buildings. Our VITAL framework has the least minimum, maximum, and mean errors compared to all other frameworks. VITAL has the least mean error (1.18 meters), followed by ANVIL (1.9 meters), SHERPA (2.0 meters), CNNLoc (2.98 meters), and WiDeep (3.73 meters). Thus, VITAL achieves improvements ranging from 41% to 68%. VITAL also has the lowest maximum error (3.0 meters), followed by ANVIL (3.56 meters), SHERPA (6.22 meters), CNNLoc (4.58 meters), and WiDeep (8.2 meters).
### _Effectiveness of DAM_
The Data Augmentation Module (DAM) is a significant component of the proposed VITAL framework, with broad applicability to various indoor localization frameworks. To analyze the impact of DAM, we integrated it into the four comparison frameworks. Figure 9 shows a slope graph showing the mean error for all frameworks with and without DAM. The integration of DAM allows VITAL to achieve lower mean localization errors than without it. Moreover, DAM shows notable improvements when integrated with ANVIL, SHERPA, and CNNLoc, three of the four state-of-the-art frameworks that we compare against. WiDeep shows higher mean errors with the inclusion of DAM, as it tends to overfit easily. Thus, DAM can significantly improve localization accuracy predictions for some frameworks, such as ANVIL, SHERPA, and CNNLoc, as well as our VITAL framework proposed in this paper.
### _Results on extended (new) smartphones_
To further evaluate the generalizability of our VITAL framework, we conducted another experiment by deploying the frameworks on three new smartphone devices on which the frameworks were not trained. The new devices, referred to as 'extended devices', are shown in Table II.
Figure 10 shows a box plot with minimum, maximum, and mean errors across all buildings for the comparison frameworks, across the three extended devices. From the figure, we can conclude that VITAL outperforms all frameworks significantly. VITAL has the least mean error (1.38 meters), followed by SHERPA (1.7 meters), ANVIL (2.51 meters), CNNLoc (2.94 meters), and WiDeep (5.90 meters). Thus, VITAL achieves improvements ranging from 19% to 77%. VITAL also has the least maximum error (3.03 meters), followed by SHERPA (3.18 meters), ANVIL (4.0 meters), CNNLoc (3.92 meters), and WiDeep (8.20 meters). Thus, VITAL enables superior device heterogeneity tolerance and localization accuracy, even on new and unseen devices that it has not been trained on.
## VII Conclusion
In this paper, we presented a novel framework called VITAL that is resilient to device heterogeneity during indoor localization. VITAL was compared with four state-of-the-art frameworks for device heterogeneity-resilient indoor localization, across four different buildings, and with nine different smartphone devices. VITAL shows 41% to 68% mean localization error improvement compared to the best-performing frameworks from prior work. VITAL also shows great generalizability across new smartphone devices, with 19% to 77% mean localization error improvement compared to the best-performing frameworks from prior work. The calibration-free approach enabled by VITAL makes it a preferred framework for indoor localization in real-world settings.
|
2304.02840 | NTK-SAP: Improving neural network pruning by aligning training dynamics | Pruning neural networks before training has received increasing interest due
to its potential to reduce training time and memory. One popular method is to
prune the connections based on a certain metric, but it is not entirely clear
what metric is the best choice. Recent advances in neural tangent kernel (NTK)
theory suggest that the training dynamics of large enough neural networks is
closely related to the spectrum of the NTK. Motivated by this finding, we
propose to prune the connections that have the least influence on the spectrum
of the NTK. This method can help maintain the NTK spectrum, which may help
align the training dynamics to that of its dense counterpart. However, one
possible issue is that the fixed-weight-NTK corresponding to a given initial
point can be very different from the NTK corresponding to later iterates during
the training phase. We further propose to sample multiple realizations of
random weights to estimate the NTK spectrum. Note that our approach is
weight-agnostic, which is different from most existing methods that are
weight-dependent. In addition, we use random inputs to compute the
fixed-weight-NTK, making our method data-agnostic as well. We name our
foresight pruning algorithm Neural Tangent Kernel Spectrum-Aware Pruning
(NTK-SAP). Empirically, our method achieves better performance than all
baselines on multiple datasets. | Yite Wang, Dawei Li, Ruoyu Sun | 2023-04-06T03:10:03Z | http://arxiv.org/abs/2304.02840v1 | # NTK-SAP: Improving neural network pruning by aligning training dynamics
###### Abstract
Pruning neural networks before training has received increasing interest due to its potential to reduce training time and memory. One popular method is to prune the connections based on a certain metric, but it is not entirely clear what metric is the best choice. Recent advances in neural tangent kernel (NTK) theory suggest that the training dynamics of large enough neural networks is closely related to the spectrum of the NTK. Motivated by this finding, we propose to prune the connections that have the least influence on the spectrum of the NTK. This method can help maintain the NTK spectrum, which may help align the training dynamics to that of its dense counterpart. However, one possible issue is that the fixed-weight-NTK corresponding to a given initial point can be very different from the NTK corresponding to later iterates during the training phase. We further propose to sample multiple realizations of random weights to estimate the NTK spectrum. Note that our approach is weight-agnostic, which is different from most existing methods that are weight-dependent. In addition, we use random inputs to compute the fixed-weight-NTK, making our method data-agnostic as well. We name our foresight pruning algorithm Neural Tangent Kernel Spectrum-Aware Pruning (NTK-SAP). Empirically, our method achieves better performance than all baselines on multiple datasets. Our code is available at [https://github.com/YiteWang/NTK-SAP](https://github.com/YiteWang/NTK-SAP).
## 1 Introduction
The past decade has witnessed the success of deep neural networks (DNNs) in various applications. Modern DNNs are usually highly over-parameterized, making training and deployment computationally expensive. Network pruning has emerged as a powerful tool for reducing time and memory costs. There are mainly two types of pruning methods: post-hoc pruning (Han et al., 2015; Renda et al., 2020; Molchanov et al., 2019; LeCun et al., 1989; Hassibi and Stork, 1992) and foresight pruning (Lee et al., 2018; Wang et al., 2020; Alizadeh et al., 2022; Tanaka et al., 2020; de Jorge et al., 2020; Liu and Zenke, 2020). The former methods prune the network after training the large network, while the latter methods prune the network before training. In this paper, we focus on foresight pruning.
SNIP (Lee et al., 2018) is probably the first foresight pruning method for modern neural networks. It prunes those initial weights that have the least impact on the initial loss function. SNIP can be viewed as a special case of saliency score based pruning: prune the connections that have the least "saliency scores", where the saliency score is a certain metric that measures the importance of the connections. For SNIP, the saliency score of a connection is the difference of loss function before and after pruning this connection. GraSP (Wang et al., 2020) and Synflow (Tanaka et al., 2020) used two different saliency scores. One possible issue of these saliency scores is that they are related to the initial few steps of training, and thus may not be good choices for later stages of training. Is there a saliency score that is more directly related to the whole training dynamics?
### Our Methodology
Recently, there are many works on the global optimization of neural networks; see, e.g., Liang et al. (2018, 2019, 2021); Venturi et al. (2018); Safran and Shamir (2017); Li et al. (2022); Ding et al. (2022); Soltanolkotabi et al. (2019); Sun et al. (2020a); Lin et al. (2021, 2021); Zhang et al. (2021) and the surveys Sun et al. (2020b); Sun (2020). Among them, one line of research uses neural tangent kernel (NTK) (Jacot et al., 2018) to describe the gradient descent dynamics of DNNs when the network size is large enough. More specifically, for large enough DNNs, the NTK is asymptotically constant during training, and the convergence behavior can be characterized by the spectrum of the NTK. This theory indicates that the spectrum of the NTK might be a reasonable metric for the whole training dynamics instead of just a few initial iterations. It is then natural to consider the following conceptual pruning method: prune the connections that have the least impact on the NTK spectrum.
There are a few questions on implementing this conceptual pruning method.
First, what metric to compute? Computing the whole eigenspectrum of the NTK is too time-consuming. Following the practice in numerical linear algebra and deep learning (Lee et al., 2019; Xiao et al., 2020), we use the nuclear norm (sum of eigenvalues) as a scalar indicator of the spectrum.
Second, what "NTK" matrix to pick? We call the NTK matrix defined for the given architecture with a random initialization as a "fixed-weight-NTK", and use "analytic NTK" (Jacot et al., 2018) to refer to the asymptotic limit of the fixed-weight-NTK as the network width goes to infinity. The analytic NTK is the one studied in NTK theory (Jacot et al., 2018), and we think its spectrum may serve as a performance indicator of a certain architecture throughout the whole training process.1 However, computing its nuclear norm is still too time-consuming (either using the analytic form given in Jacot et al. (2018) or handling an ultra-wide network). The nuclear norm of a fixed-weight-NTK is easy to compute, but the fixed-weight-NTK may be quite different from the analytic NTK. To resolve this issue, we notice a less-mentioned fact: the analytic NTK is also the limit of the expectation (over random weights) of fixed-weight-NTK2, and thus it can be approximated by the expectation of fixed-weight-NTK for a given width. The expectation of fixed-weight-NTK shall be a better approximation of analytic NTK than a single fixed-weight-NTK. Of course, to estimate the expectation, we can use a few "samples" of weight configurations and compute the average of a few fixed-weight-NTKs.
Footnote 1: Please see Appendix B.2 for more discussions from an empirical perspective.
One more possible issue arises: would computing, say, \(100\) fixed-weight-NTKs take \(100\) times more computation cost? We use one more computation trick to keep the computation cost low: for each mini-batch of input, we use a fresh sample of weight configuration to compute one fixed-weight-NTK (or, more precisely, its nuclear norm). This will not increase the computation cost compared to computing the fixed-weight-NTK for one weight configuration with \(100\) mini-batches. We call this "_new-input-new-weight_" (INNW) trick.
We name the proposed foresight pruning algorithm **N**eural **T**angent **K**ernel **S**pectrum-**A**ware **P**runing **(**NTK-SAP**). We show that NTK-SAP is competitive on multiple datasets, including CIFAR-10, CIFAR-100, Tiny-ImageNet, and ImageNet. In summary, our contributions are:
* We propose a theory-motivated foresight pruning method named NTK-SAP, which prunes networks based on the spectrum of NTK.
* We introduce a multi-sampling formulation which uses different weight configurations to better capture the expected behavior of pruned neural networks. A "_new-input-new-weight_" (INNW) trick is leveraged to reduce the computational cost, and may be of independent interest.
* Empirically, we show that NTK-SAP, as a data-agnostic foresight pruning method, achieves state-of-the-art performance in multiple settings.
## 2 Related work and background
**Pruning after training (Post-hoc pruning).** Post-hoc pruning can be dated back to the 1980s (Janowsky, 1989; Mozer and Smolensky, 1989) and they usually require multiple rounds of train-prune-retrain procedure (Han et al., 2015; LeCun et al., 1989). Most of these pruning methods use
magnitude (Han et al., 2015), Hessian (LeCun et al., 1989; Hassibi and Stork, 1992; Molchanov et al., 2019) and other information (Dai et al., 2018; Guo et al., 2016; Dong et al., 2017; Yu et al., 2018) to define the scoring metrics which determine which weights to prune. Some other recent works (Verma and Pesquet, 2021) identify sparse networks through iterative optimization. Most post-hoc pruning methods intend to reduce the inference time, with the exception of lottery ticket pruning (Frankle and Carbin, 2018; Renda et al., 2020) which prunes the networks for the purpose of finding a trainable sub-network.
**Pruning during training.** Another class of pruning algorithms gradually sparsifies a dense neural network during training. Some works use explicit \(\ell_{0}\)(Louizos et al., 2017) or \(\ell_{1}\)(Wen et al., 2016) regularization to learn a sparse solution. Other works introduce trainable masks (Liu et al., 2020; Savarese et al., 2020; Kang and Han, 2020; Kusupati et al., 2020; Srinivas et al., 2017; Xiao et al., 2019) or use projected gradient descent (Zhou et al., 2021) to specifically learn the connections to be remained. DST methods (Mocanu et al., 2018; Bellec et al., 2017; Mostafa and Wang, 2019; Dettmers and Zettlemoyer, 2019; Liu et al., 2021b; Evici et al., 2020; Liu et al., 2021c;a) train the neural network with a fixed parameter count budget while gradually adjust the parameters throughout training. Moreover, another line of work (You et al., 2019) tries to identify the winning ticket at early epochs. These methods can reduce some training time, but often do not reduce the memory cost of training.
**Pruning before training (foresight pruning).** SNIP (Lee et al., 2018) is arguably the first foresight pruning method. Later, GraSP (Wang et al., 2020) uses Hessian-gradient product to design the pruning metric. To address the layer collapse issue of SNIP and GraSP at high sparsity ratios, Synflow (Tanaka et al., 2020) prunes the network iteratively in a data-independent manner. FORCE and Iterative SNIP (de Jorge et al., 2020) also intend to improve the performance of SNIP at high sparsity ratios. Lee et al. (2019) uses orthogonal constraint to improve signal propagation of networks pruned by SNIP. Neural tangent transfer (Liu and Zenke, 2020) explicitly lets subnetworks learn the full empirical neural tangent kernel of dense networks. PropsPr (Alizadeh et al., 2022) also mentions the "shortsightedness" of existing foresight pruning methods and proposes to use meta-gradients to utilize the information of the first few iterations.
## 3 General pipeline for foresight pruning methods
In this section, we review the formulation of pruning-at-initialization problem and revisit several existing foresight pruning methods. Here we consider Synflow (Tanaka et al., 2020), GraSP (Wang et al., 2020), SNIP (Lee et al., 2018) and Iterative SNIP (de Jorge et al., 2020). When given a dataset \(\mathcal{D}=(\mathbf{x}_{i},\mathbf{y}_{i})_{i=1}^{n}\) and an untrained neural network \(f(\cdot;\mathbf{\theta})\) parameterized by \(\mathbf{\theta}=\{\theta^{1},\theta^{2},\cdots,\theta^{p}\}\in\mathbb{R}^{p}\), we are interested in finding a binary mask \(\mathbf{m}=\{m^{1},m^{2},\cdots,m^{p}\}\in\{0,1\}^{p}\) which minimizes the following equation:
\[\min_{\mathbf{m}}\mathcal{L}(\mathcal{A}(\mathbf{\theta}_{0},\mathbf{ m})\odot\mathbf{m};\mathcal{D}) =\min_{\mathbf{m}}\frac{1}{n}\sum_{i=1}^{n}\mathcal{L}(f(\mathbf{x}_{i}; \mathcal{A}(\mathbf{\theta}_{0},\mathbf{m})\odot\mathbf{m}),\mathbf{y}_{i})\] (1) s.t. \[\mathbf{m}\in\{0,1\}^{p},\quad\|\mathbf{m}\|_{0}/p\leq d=1-k\]
where \(k\) and \(d=1-k\) are the target sparsity and density, \(\mathbf{\theta}_{0}\) is an initialization point which follows a specific weight initialization method \(\mathcal{P}\) (e.g. Xavier initialization), \(\odot\) denotes the Hadamard product, and \(\mathcal{A}\) denotes a training algorithm (e.g. Adam) which takes in mask \(\mathbf{m}\) as well as initialization \(\mathbf{\theta}_{0}\), and outputs trained weights at convergence \(\mathbf{\theta}_{\text{final}}\odot\mathbf{m}\).
Since directly minimizing Equation (1) is intractable, existing foresight pruning methods assign each mask and corresponding weight at initialization \(\theta_{0}^{j}\) with a saliency score \(S(\theta_{0}^{j})\) in the following generalized form:
\[S(m^{j})=S(\theta_{0}^{j})=\frac{\partial\mathcal{I}}{\partial m^{j}}=\frac{ \partial\mathcal{I}}{\partial\theta_{0}^{j}}\cdot\theta_{0}^{j} \tag{2}\]
where \(\mathcal{I}\) is a function of parameters \(\mathbf{\theta}_{0}\) and corresponding mask \(\mathbf{m}\). Intuitively, Equation (2) measures the influence of removing connection \(m^{j}\) on \(\mathcal{I}\). Once the saliency score for each mask is computed, we will only keep the top-\(d\) masks. Specifically, the masks with the highest saliency scores will be retained (\(m^{j}=1\)), while other masks will be pruned (\(m^{j}=0\)).
**SNIP.** SNIP (Lee et al., 2018) defines \(S_{\text{SNIP}}(m^{j})=\left|\frac{\partial\mathcal{L}(\mathbf{\theta}_{0}\odot\mathbf{m};D )}{\partial\theta_{0}^{j}}\cdot\theta_{0}^{j}\right|\), where \(D\subset\mathcal{D}\) is a subset of the whole training set. SNIP prunes the whole network in one round.
**Iterative SNIP.** The saliency score of Iterative SNIP3 (de Jorge et al., 2020) remains the same as the original SNIP. However, multiple rounds of pruning are performed.
Footnote 3: We do not consider FORCE in this work since we find empirically that FORCE is less stable than Iterative SNIP. See Appendix F for a detailed comparison.
**GraSP.** GraSP (Wang et al., 2020) defines \(S_{\text{GraSP}}(m^{j})=-\left[H(\mathbf{\theta}_{0}\odot\mathbf{m};D)\frac{\partial \mathcal{L}(\mathbf{\theta}_{0}\odot\mathbf{m};D)}{\partial\theta_{0}}\right]^{j} \cdot\theta_{0}^{j}\), where \(H\) is the Hessian matrix. Additionally, GraSP is also a single round foresight pruning method.
**Synflow.** Synflow (Tanaka et al., 2020) uses \(S_{\text{Syaffow}}(m^{j})=\left|\frac{\partial\sum_{k}f(1;|\mathbf{\theta}_{0}| \odot\mathbf{m})_{k}}{\partial|\theta_{0}^{j}|}\cdot|\theta_{0}^{j}|\right|\) as saliency score, where \(f_{k}\) denotes the \(k\)-th output logit, \(\mathbb{1}\) denotes an input full of \(1\)s, and \(f(\cdot;|\theta_{0}^{j}|)\) means replacing all the parameters of the neural network by their absolute values. Similar to Iterative SNIP, Synflow is also an iterative pruning method but in a data-agnostic manner.
## 4 Review of neural tangent kernel
Recent works (Jacot et al., 2018; Lee et al., 2019; Arora et al., 2019; Xiao et al., 2020) study the training dynamics of large DNNs under gradient descent. Formally, let \(\mathcal{D}=\{(\mathbf{x}_{i},\mathbf{y}_{i})\}_{i=1}^{n}\subset\mathbb{R}^{n _{0}}\times\mathbb{R}^{k}\) denote the training set and let \(\mathcal{X}=\{\mathbf{x}:(\mathbf{x},\mathbf{y})\in\mathcal{D}\}\), \(\mathcal{Y}=\{\mathbf{y}:(\mathbf{x},\mathbf{y})\in\mathcal{D}\}\) denote inputs and labels, respectively. Consider a neural network \(f(\cdot;\mathbf{\theta})\) parameterized by weights \(\mathbf{\theta}\). Let \(\mathcal{L}(\mathbf{\theta})=\sum_{(\mathbf{x},\mathbf{y})\in(\mathcal{X},\mathcal{ Y})}\ell(f(\mathbf{x};\mathbf{\theta}),\mathbf{y})\) denote the empirical loss where \(\ell\) is the loss function. Thus, \(f(\mathcal{X};\mathbf{\theta})\in\mathbb{R}^{kn\times 1}\) is the concatenated vector of predictions for all training inputs. Under continuous time gradient descent with learning rate \(\eta\), the evolution of the parameters \(\mathbf{\theta}_{t}\), where we emphasize the dependence of \(\mathbf{\theta}\) on time \(t\), and the training loss of the neural network \(\mathcal{L}\) can be expressed (Lee et al., 2019) as
\[\dot{\mathbf{\theta}}_{t}=-\eta\nabla_{\mathbf{\theta}_{t}}f(\mathcal{X}; \mathbf{\theta}_{t})^{T}\nabla_{f(\mathcal{X};\mathbf{\theta}_{t})}\mathcal{L} \tag{3}\] \[\dot{\mathcal{L}}=\nabla_{f(\mathcal{X};\mathbf{\theta}_{t})}\mathcal{ L}^{T}\nabla_{\mathbf{\theta}_{t}}f(\mathcal{X};\mathbf{\theta}_{t})\dot{\mathbf{\theta}}_{t} =-\eta\nabla_{f(\mathcal{X};\mathbf{\theta}_{t})}\mathcal{L}^{T}\hat{\mathbf{\Theta}}_ {t}(\mathcal{X},\mathcal{X})\nabla_{f(\mathcal{X};\mathbf{\theta}_{t})}\mathcal{L} \tag{4}\]
where we obtain the NTK at time \(t\):
\[\hat{\mathbf{\Theta}}_{t}(\mathcal{X},\mathcal{X};\mathbf{\theta}_{t})\triangleq\nabla _{\mathbf{\theta}_{t}}f(\mathcal{X};\mathbf{\theta}_{t})\nabla_{\mathbf{\theta}_{t}}f( \mathcal{X};\mathbf{\theta}_{t})^{T}\in\mathbb{R}^{kn\times kn}. \tag{5}\]
It is proven that when the width of the neural network becomes sufficiently large (Jacot et al., 2018; Arora et al., 2019), the fixed-weight-NTK converges to a deterministic matrix \(\mathbf{\Theta}(\mathcal{X},\mathcal{X})\), which we term analytic NTK. The analytic NTK remains asymptotically constant throughout training, i.e. \(\mathbf{\Theta}_{t}(\mathcal{X},\mathcal{X})\approx\mathbf{\Theta}_{0}(\mathcal{X}, \mathcal{X}),\ \forall t\geq 0\).
**The condition number of the NTK is related to neural network optimization.** The condition number of the NTK is known to be important in neural network optimization. Specifically, let the eigenvalue decomposition of the NTK at initialization be \(\mathbf{\Theta}_{0}(\mathcal{X},\mathcal{X})=U^{T}\Lambda U\) where \(\Lambda=\text{diag}(\lambda_{1},\cdots,\lambda_{kn})\) is the diagonal matrix containing all the eigenvalues of the NTK.
For large-width networks, the mean prediction of the neural network in the eigenbasis of NTK can be approximately described as \((U\mathbb{E}\left[f(\mathcal{X})\right])_{i}=(\mathbf{I}-e^{-\eta\lambda_{i}t} (U\mathcal{Y}))_{i}\)(Xiao et al., 2020). Therefore, when using the largest possible learning rate \(\eta\sim 2/\lambda_{1}\)(Lee et al., 2019), the convergence rate of the smallest eigenvalue is related to \(\lambda_{1}/\lambda_{kn}\), which is the condition number of the NTK. Empirically, the condition number of the NTK has been successfully used to identify promising architectures in the neural architecture search (NAS) field (Chen et al., 2021; Wang et al., 2022).
**The entire spectrum of the NTK is a better measure.** However, the smallest and the largest eigenvalues only provide very limited information on the optimization property of the DNNs. In the classical optimization theory, the convergence speed depends on all eigenvalues of the Hessians, as different eigenvalues control the convergence of different eigen-modes. Similarly, for neural networks, a few works (Kopitkov & Indelman, 2020; Su & Yang, 2019) have shown that the convergence speed depends on eigenvalues other than the smallest eigenvalue. In this sense, compared to only considering the condition number of the NTK, controlling the entire eigenspectrum may be a better way to ensure the satisfactory optimization performance of DNNs.
## 5 Our method
### Account for the effects of the entire eigenspectrum with trace norm
As discussed in Section 4, the eigenspectrum of the NTK captures the training dynamics of large DNNs, and thus we intend to use the NTK spectrum to guide foresight pruning. More specifically, we would like to keep the spectrum of the pruned network close to that of the large network, so that the pruned network may perform similarly to the large network.
As discussed in Section 3, the saliency-score-based method requires using a single metric to capture the optimization performance. This single metric is often a scalar, and thus we want to generate a scalar to capture the information of the whole spectrum. A very natural choice is to use the average value of all eigenvalues. In fact, Pennington et al. (2017, 2018); Shu et al. (2021) indeed analyze the optimization property of DNNs through the average eigenvalues of the NTK (or a related matrix called input-output Jacobian) explicitly or implicitly. Additionally, using the average eigenvalues have also a few good properties which make it more suitable than other metrics for pruning:
**Computational efficiency.** To begin with, the computational cost of computing all the eigenvalues would be too expensive. On the contrary, trace norm can be efficiently computed, which we will show in Section 5.2.
**Potentially preserve the entire spectrum.** As indicated in Section 3, the saliency score for each weight measures the change of the metric (here it is the trace norm of the NTK) when removing the weight. More precisely, removing weights with a smaller saliency score is less likely to induce significant change to the eigenvalue distribution. Hence, using the NTK trace norm as the indicator is beneficial in maintaining the entire spectrum.
### Approximating the trace norm of the NTK
**Nuclear norm as a proxy of the whole spectrum.** The NTK is a symmetric matrix. Hence, the trace of the NTK is equivalent to the squared Frobenius norm of parameter-output Jacobian, i.e.
\[\|\mathbf{\Theta}_{0}\|_{*}=\|\mathbf{\Theta}_{0}\|_{\text{tr}}=\|\nabla_{\mathbf{ \theta}_{0}}f(\mathcal{X};\mathbf{\theta}_{0})\|_{F}^{2}. \tag{6}\]
**Finite difference approximation.** Computing the Frobenius norm of the Jacobian matrix \(\nabla_{\mathbf{\theta}_{0}}f(\mathcal{X};\mathbf{\theta}_{0})\in\mathbb{R}^{kn\times p}\) is memory and computation heavy. More specifically, a naive solution that constructs the Jacobian matrix explicitly for a batch of training data may require at least \(k\) rounds of backward propagation, where \(k\) is as large as 1000 for ImageNet classification task. So approximation is needed.
One possible way is to lower-bound it using loss gradient with respect to weights \(\|\nabla_{\mathbf{\theta}_{0}}\mathcal{L}\|_{2}^{2}\). Such a method has been studied in FORCE (de Jorge et al., 2020) but found to be inferior to Iterative SNIP.
Alternatively, we use the finite difference expression \(\frac{1}{\epsilon}\mathbb{E}_{\Delta\mathbf{\theta}\sim\mathcal{N}(\mathbf{0},\mathbf{c })}\left(\|f(\mathcal{X};\mathbf{\theta}_{0})-f(\mathcal{X};\mathbf{\theta}_{0}+ \Delta\mathbf{\theta})\|_{2}^{2}\right]\) to approximate the Jacobian norm. Please see Appendix O for the justification.
**Approximating the training set with pruning set.** We use the following finite approximation expression to define a saliency score:
\[S_{\text{NTK-SAP}}(m^{j})=\left|\frac{\partial\mathbb{E}_{\Delta\mathbf{\theta} \sim\mathcal{N}(\mathbf{0},\mathbf{c})}\left[\|f(\mathbf{X}_{D};\mathbf{\theta}_{0}\odot \mathbf{m})-f(\mathbf{X}_{D};(\mathbf{\theta}_{0}+\Delta\mathbf{\theta})\odot\mathbf{ m})\|_{2}^{2}\right]}{\partial m^{j}}\right| \tag{7}\]
where we use the inputs of the pruning dataset \(\mathbf{X}_{D}\) to approximate the whole training inputs \(\mathcal{X}\). Our foresight pruning method will use the same framework shown in Section 3, which prunes the weights with the least saliency scores defined in Equation (7). Nevertheless, a few more tricks are needed to make this method practical, as discussed next.
### NTK-SAP: multi-sampling formulation
The last subsection computes the saliency score using the fixed-weight-NTK. We think the spectrum of analytic NTK may serve as a performance indicator of a certain architecture. While a single fixed-weight-NTK can be viewed as an approximation of the analytic NTK, the expectation
of fixed-weight-NTKs (expecation over random draw of weight configurations) shall be a better approximation. Further, to approximate the expectation, we sample a few independent realization of weight configurations and compute the average of their fixed-weight-NTKs. This helps explore the parameter space and better capture the expected behavior of the pruned neural networks.
Specifically, with \(R\) random weight configurations \(\mathbf{\theta}_{0,r}\stackrel{{\mathrm{iid}}}{{\sim}}\mathcal{P}\), we use the following stabilized version of the saliency score:
\[S_{\text{NTK-SAP}}(m^{j})=\left|\frac{\partial\frac{1}{R}\sum_{r=1}^{R}\mathbb{ E}_{\Delta\mathbf{\theta}\sim\mathcal{N}(\mathbf{\theta},\mathbf{\mathrm{I}})}\left[\|f( \mathbf{X}_{D};\mathbf{\theta}_{0,r}\odot\mathbf{m})-f(\mathbf{X}_{D};(\mathbf{\theta }_{0,r}+\Delta\mathbf{\theta})\odot\mathbf{m})\|_{2}^{2}\right]}{\partial m^{j}} \right|. \tag{8}\]
There is a major difference between the proposed saliency score and most existing foresight pruning scores: our score is weight-agnostic, i.e., it is not defined by a specific random draw of weight configuration. In other words, the score is mainly determined by the mask structure rather than specific weights.4
Footnote 4: Please refer to Appendix M for a discussion on whether a good pruning solution should be weight-agnostic.
**New-input-new-weight (NINW) trick.** It seems that using multiple weight configurations will cause a large increase in the computational cost. Nevertheless, by utilizing the fact that the training subset for pruning \(D=(\mathbf{x}_{i},\mathbf{y}_{i})|_{i=1}^{|D|}\subset\mathcal{D}\) is usually fed into neural networks in multiple batches, we further approximate Equation (8) with NINW trick as
\[S_{\text{NTK-SAP}}(m^{j})=\left|\frac{\partial\frac{1}{[D]}\sum_{i=1}^{|D|} \mathbb{E}_{\Delta\mathbf{\theta}\sim\mathcal{N}(\mathbf{\theta},\mathbf{\mathrm{I}})} \left[\|f(\mathbf{x}_{i};\mathbf{\theta}_{0,i}\odot\mathbf{m})-f(\mathbf{x}_{i};( \mathbf{\theta}_{0,i}+\Delta\mathbf{\theta})\odot\mathbf{m})\|_{2}^{2}\right]}{ \partial m^{j}}\right|. \tag{9}\]
**Replacing pruning set with random input.** Furthermore, we find that replacing the training subset \(D\) with standard Gaussian noise \(\mathcal{Z}\sim\mathcal{N}(\mathbf{0},\mathbf{\mathrm{I}})\) can generate comparable performance, which makes NTK-SAP purely data-agnostic. As for Gassuan perturbation, ideally, using multiple draws will indeed give a more accurate approximation. However, we empirically find that a single draw of Gaussian perturbation is good enough to generate satisfactory performance. Hence, by using one random draw of \(\Delta\mathbf{\theta}\) we have the final data-agnostic NTK-SAP with its saliency score
\[S_{\text{NTK-SAP}}(m^{j})=\left|\frac{\partial\frac{1}{[D]}\sum_{i=1}^{|D|} \left[\|f(\mathbf{z}_{i};\mathbf{\theta}_{0,i}\odot\mathbf{m})-f(\mathbf{z}_{i};( \mathbf{\theta}_{0,i}+\Delta\mathbf{\theta}_{i})\odot\mathbf{m})\|_{2}^{2}\right]}{ \partial m^{j}}\right| \tag{10}\]
where \(\mathbf{\theta}_{0,i}\stackrel{{\mathrm{iid}}}{{\sim}}\mathcal{P}\), \(\Delta\mathbf{\theta}_{i}\stackrel{{\mathrm{iid}}}{{\sim}}\mathcal{N}( \mathbf{0},\mathbf{\mathrm{\epsilon}}\mathbf{\mathrm{I}})\) and \(\mathbf{z}_{i}\stackrel{{\mathrm{iid}}}{{\sim}}\mathcal{N}(\mathbf{0},\mathbf{\mathrm{I}})\).
In addition, to potentially avoid layer collapse, we also iteratively prune neural networks like Synflow in \(T\) rounds.5 The major steps of the NTK-SAP algorithm are given in Algorithm 1.
Footnote 5: Please refer to Appendix N for a discussion on why NTK-SAP could potentially avoid layer collapse.
**Computational cost.** We compare the computational cost of NTK-SAP with Iterative SNIP as they are both iterative methods and use multi-batch inputs. Since the overhead of the reinitialization process is negligible, NTK-SAP needs roughly double the computational cost of Iterative SNIP due to two forward passes with the computational graph in the formula. However, one should note that NTK-SAP is a data-agnostic method that can be computed beforehand, and the computation time can be reduced with a smaller \(T\); thus, the computational overhead is reasonable. Effects of \(T\), a detailed comparison of pruning time, and FLOPs comparison can be found in Section 6.4, Appendix D.1, and Appendix D.2, respectively.
## 6 Experiments
In this section, we empirically evaluate the effectiveness of our proposed method, NTK-SAP (red). We compare with two baseline methods random pruning (gray) and magnitude pruning (magenta), as
well as foresight pruning algorithms SNIP (blue) (Lee et al., 2018), Iterative SNIP (yellow) (de Jorge et al., 2020b), GraSP (green) (Wang et al., 2020) and Synflow (cyan) (Tanaka et al., 2020) across multiple architectures and datasets.
**Target datasets, models, and sparsity ratios.** We develop our code based on the original code of Synflow (Tanaka et al., 2020). On smaller datasets, we consider ResNet-20 (He et al., 2016) on CIFAR-10, VGG-16 (Simonyan and Zisserman, 2014) on CIFAR-100 (Krizhevsky et al., 2009) and ResNet-18 on Tiny-ImageNet. For ImageNet (Deng et al., 2009) experiments, we consider ResNet-18 and ResNet-50. For the training protocols, we roughly follow the settings in Frankle et al. (2020b). Details of training hyperparameters can be found in Appendix A. We divide the sparsity ratios into three ranges: trivial sparsity ratios (36.00%, 59.04% and 73.80%), mild sparsity ratios (83.22%, 89.30% and 93.12%) and extreme sparsity ratios (95.60%, 97.17% and 98.20%).
Figure 1: Performance of NTK-SAP against other foresight pruning methods. Results are averaged over 3 random seeds, and the shaded areas denote the standard deviation. We highlight SNIP and GraSP as they perform best among baselines on mild and extreme density ratios, respectively.
**Implementation details.** Following the original implementation, SNIP, GraSP, and Iterative SNIP are run by setting BatchNorm layers as train mode while Synflow metric is evaluated under evaluation mode. The number of training samples for pruning we use is ten times of the number of classes as suggested by the original implementations of SNIP and GraSP. For iterative methods, including Iterative SNIP and Synflow, we prune all the weights in 100 rounds in an exponential schedule following Tanaka et al. (2020); Frankle et al. (2020b). Further, following Frankle et al. (2020b), Kaiming normal initialization is used for all models. We prune networks using a batch size of 256 for CIFAR-10/100 and Tiny-ImageNet datasets and a batch size of 128 for ImageNet experiments.
For NTK-SAP, we use the same number of Gaussian noise batches as in Iterative SNIP and prunes neural network progressively in \(T=100\) rounds for CIFAR-100 and Tiny-ImageNet. Since the pruning dataset for CIFAR-10 only contains 1 batch of the training sample, we alternatively sample \(R=5\) independent initialization points and prune progressively in \(T=20\) rounds, keeping the overall computational cost roughly the same. More details can be found in Appendix A.
### Results on CIFAR and Tiny-ImageNet
In Figure 1 we evaluate NTK-SAP using ResNet-20 on CIFAR-10, VGG-16 on CIFAR-100 and ResNet-18 on Tiny-ImageNet. It can be observed that NTK-SAP is competitive for all sparsity ratios.
**Trivial and mild sparsity ratios.** For trivial sparsity ratios, all methods show good performance except GraSP, magnitude, and random pruning. On ResNet-20, all methods are similar, while random pruning and GraSP show slightly worse performance. On VGG-16 (ResNet-18), similar trend can be observed while the performance gap is larger. NTK-SAP shows consistent good performance, especially on ResNet-18 (TinyImageNet).
For mild sparsity ratios, NTK-SAP is the only method that performs well across all datasets and models. On ResNet-20, SNIP and Iterative SNIP take the lead with NTK-SAP while suffering from a performance drop starting at 93.12% sparsity. Magnitude pruning and GraSP have similar performance to NTK-SAP after 89.30%. On VGG-16 and ResNet-18, NTK-SAP and SNIP remain dominant, while NTK-SAP outperforms SNIP.
**Extreme sparsity ratios.** NTK-SAP's superior performance can be seen at extreme sparsity ratios, especially 98.20%. On the CIFAR-10 dataset, GraSP and magnitude pruning are competitive as in matching sparsity ratios. On VGG-16, SNIP first dominates with NTK-SAP and then becomes much inferior. At the sparsest level 98.20%, magnitude, Iterative SNIP, and GraSP show similar results, about 1 percentage point lower than NTK-SAP.
### Results on larger dataset
We further evaluate the performance of NTK-SAP on more difficult tasks: we run experiments on the ImageNet dataset using ResNet-18 and ResNet-50 with pruning ratios {89.26%, 95.60%}.6 We compare NTK-SAP against Synflow, SNIP, Iterative SNIP, GraSP, Magnitude, and Random pruning.
Footnote 6: We choose these sparsity ratios as they include matching and extreme sparsity ratios and close to {90%, 95%} as used by Iterative SNIP (de Jorge et al., 2020b) and ProsPr (Alizadeh et al., 2022).
The results are shown in Table 1. We find that SNIP, which performs reasonably well for smaller datasets, is no longer competitive. For ResNet-50, NTK-SAP beats other pruning methods with margins at least 0.5% and 1% for sparsity ratio 89.26% and 95.60%, respectively. For ResNet-18, NTK-SAP slightly outperforms magnitude pruning under 89.26% sparsity, and GraSP follows. For sparsity ratio 95.60 %, GraSP is better than magnitude pruning while NTK-SAP still takes the lead.
One should note the surprisingly good performance of magnitude pruning. We hypothesize that magnitude pruning chooses an appropriate layer-wise sparsity ratio since Kaiming normal initialization already gives weights different variances depending on the number of parameters of different layers. Thus, layers with more parameters will be more likely pruned.
### An overall comparison with SNIP and GraSP
In this section, we explicitly compare NTK-SAP with two competitive baseline methods in detail, i.e., SNIP and GraSP, since there is no state-of-the-art foresight pruning algorithms (Frankle et al., 2020b).
We highlight both baseline algorithms in Figure 1. Specifically, SNIP is considered competitive as it generally performs well, especially for trivial and mild sparsity ratios. However, SNIP shows poor performance for ImageNet. On the contrary, GraSP indeed shows promising performance on the ImageNet dataset and extreme sparsity ratios on smaller datasets, while it suffers from poor performance on trivial and mild sparsity ratios of smaller datasets. In this sense, NTK-SAP is the first foresight pruning algorithm that works consistently well on all datasets.
### More ablation studies
We finally evaluate the performance of NTK-SAP when varying the number of iterative steps (\(T\)), which can give a better understanding of how iterative pruning helps NTK-SAP achieve better performance at higher sparsity ratios. We repeat experiments of Section 6.1 with varying \(T\). Results show that increasing \(T\) consistently boosts the performance of NTK-SAP. Moreover, such an increase saturates when \(T\) is roughly \(1/5\) of the adopted value in Section 6.1. Hence, the computational cost of NTK-SAP can be further decreased if we use a smaller value of \(T\). Please refer to Appendix C for more details. We also conduct an ablation study on the effects of perturbation hyperparameter \(\epsilon\). Results show that NTK-SAP is robust to the choices of \(\epsilon\). See Appendix I for more details.
### The eigenspectrum of the fixed-weight-NTK after pruning
To visualize the effectiveness of our proposed NTK-SAP method, we show eigenspectrum of pruned subnetwork on CIFAR-10 dataset with ResNet-20 at sparsity ratios \(73.80\%\). Figure 2 shows that NTK-SAP successfully maintain the eigenspectrum of the fixed-weight-NTK compared to other methods. See Appendix G.1 for the eigenspectrum of the fixed-weight-NTK for other sparsity ratios.
## 7 Conclusion
Pruning at initialization is appealing compared to pruning-after-training algorithms since it circumvents the need for training to identify the masks. However, most of the existing foresight pruning methods do not capture the training dynamics after pruning. We argue that such an issue can be mitigated by using NTK theory. Hence, we propose NTK-SAP, which iteratively prunes neural networks without any data. Additionally, NTK-SAP pays attention to multiple random draws of initialization points. Empirically, our method is competitive in all datasets and models studied in this work. We consider that our algorithm can encourage more works to apply theoretical findings to empirical applications. Additionally, our novel way of combining multiple initialization configurations may further encourage future work to investigate the similarity of pruning and NAS just like Liu et al. (2018); Abdelfattah et al. (2021).
The limitations of the work include the relatively heavy computation nature of iterative pruning methods compared to single-shot pruning methods. We also want to emphasize the great significance of pruning methods in reducing the energy cost of training and applying deep learning models.
\begin{table}
\begin{tabular}{l c c c c} \hline \hline Network & \multicolumn{2}{c}{**ResNet-18**} & \multicolumn{2}{c}{**ResNet-50**} \\ \hline Sparsity percentage & 89.26\% & 95.60\% & 89.26\% & 95.60\% \\ \hline (Dense Baseline) & 69.98 & & 76.20 & \\ \hline Synflow & 57.30 & 45.65 & 66.81 & 58.88 \\ SNIP & 57.41 & 45.04 & 60.98 & 40.69 \\ Iterative SNIP & 52.97 & 37.44 & 52.53 & 36.82 \\ GraSP & 58.16 & 49.17 & 67.74 & 59.73 \\ Magnitude & 58.75 & 48.50 & 66.80 & 43.79 \\ Random & 54.48 & 42.80 & 65.30 & 56.53 \\ \hline \hline
**Our method** & **58.87** & **49.43** & **68.28** & **60.79** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Test performance of foresight pruning methods on the ImageNet dataset. Best results are in **bold**; second-best results are underlined.
Figure 2: Eigenvalue distribution of the fixed-weight-NTK on ResNet-20 (CIFAR-10) at sparsity ratio \(73.80\%\).
## 8 Acknowledgement
This work utilizes resources supported by the National Science Foundation's Major Research Instrumentation program, grant No.1725729 (Kindratenko et al., 2020), as well as the University of Illinois at Urbana-Champaign. This paper is supported in part by Hetao Shenzhen-Hong Kong Science and Technology Innovation Cooperation Zone Project (No.HZQSWS-KCCYB-2022046); University Development Fund UDF01001491 from the Chinese University of Hong Kong, Shenzhen; Guangdong Key Lab on the Mathematical Foundation of Artificial Intelligence, Department of Science and Technology of Guangdong Province.
We would like to thank the program chairs and the area chairs for handling our paper. We would also like to thank the reviewers for their time and efforts in providing constructive suggestions on our paper. |
2308.04672 | Resource Constrained Model Compression via Minimax Optimization for
Spiking Neural Networks | Brain-inspired Spiking Neural Networks (SNNs) have the characteristics of
event-driven and high energy-efficient, which are different from traditional
Artificial Neural Networks (ANNs) when deployed on edge devices such as
neuromorphic chips. Most previous work focuses on SNNs training strategies to
improve model performance and brings larger and deeper network architectures.
It is difficult to deploy these complex networks on resource-limited edge
devices directly. To meet such demand, people compress SNNs very cautiously to
balance the performance and the computation efficiency. Existing compression
methods either iteratively pruned SNNs using weights norm magnitude or
formulated the problem as a sparse learning optimization. We propose an
improved end-to-end Minimax optimization method for this sparse learning
problem to better balance the model performance and the computation efficiency.
We also demonstrate that jointly applying compression and finetuning on SNNs is
better than sequentially, especially for extreme compression ratios. The
compressed SNN models achieved state-of-the-art (SOTA) performance on various
benchmark datasets and architectures. Our code is available at
https://github.com/chenjallen/Resource-Constrained-Compression-on-SNN. | Jue Chen, Huan Yuan, Jianchao Tan, Bin Chen, Chengru Song, Di Zhang | 2023-08-09T02:50:15Z | http://arxiv.org/abs/2308.04672v1 | # Resource Constrained Model Compression via Minimax Optimization for Spiking Neural Networks
###### Abstract.
Brain-inspired Spiking Neural Networks (SNNs) have the characteristics of event-driven and high energy-efficient, which are different from traditional Artificial Neural Networks (ANNs) when deployed on edge devices such as neuromorphic chips. Most previous work focuses on SNNs training strategies to improve model performance and brings larger and deeper network architectures. It's difficult to deploy these complex networks on resource-limited edge devices directly. To meet such demand, people compress SNNs very cautiously to balance the performance and the computation efficiency. Existing compression methods either iteratively pruned SNNs using weights norm magnitude or formulated the problem as a sparse learning optimization. We propose an improved end-to-end Minimax optimization method for this sparse learning problem to better balance the model performance and the computation efficiency. We also demonstrate that jointly applying compression and finetuning on SNNs is better than sequentially, especially for extreme compression ratios. The compressed SNN models achieved state-of-the-art (SOTA) performance on various benchmark datasets and architectures. Our code is available at _[https://github.com/chenjallen/Resource-Constrained-Compression-on-SNN_](https://github.com/chenjallen/Resource-Constrained-Compression-on-SNN_).
Spiking Neural Networks, Model Compression, Sparse Pruning, Minimax Optimization 1
Footnote 1: The corresponding author.
2023
Spiking Neural Networks, Model Compression, Sparse Pruning, Minimax Optimization 2023
## 1. Introduction
As the third generation of neural networks (Wang et al., 2017), Spiking Neural Networks (SNNs) has been widely concerned in recent years. SNNs are the core of brain heuristic intelligence research, which have high biological interpretability and strong Spatio-temporal information processing ability (Shen et al., 2018). In addition, due to the inherent asynchrony and sparsity of spiking training, these types of networks can maintain relatively good performance as well as low power consumption, especially when combined with neuromorphic chips (Shen et al., 2018; Chen et al., 2019). With the development of efficient deep SNN training strategies, some useful network architectures are built, such as Spiking ResNet (Shen et al., 2018; Chen et al., 2019; Chen et al., 2019) and SEW ResNet (He et al., 2019) to improve the performance of SNNs. The parameters and computational energy of SNN models rapidly increase, while the computational resources of edge devices are usually limited. For example, SpiNNaker demonstrated to run networks with up to 250,000 neurons and 80 million synapses on a 48-chip board (Shen et al., 2018), which is still unable to run those more advanced SNNs. Thus, it is of great significance to compress SNNs before deploying them in real scenarios, which reduces computing costs, saves storage resources, and helps researchers exploit more benefits from high energy savings. Model compression was proposed to reduce the model size and improve the inference efficiency of the DNNs (Chen et al., 2019). Weights pruning (Chen et al., 2019) is one of the widely used techniques for compressing the model size by zeroing out the individual weight of the convolutional kernel or fully connected weights matrix. Filter pruning (Wang et al., 2017; Chen et al., 2019; Chen et al., 2019) is another kind of pruning technique that prunes entire filters (or nodes for fully connected layers) and their corresponding weights. In this way, the entire filters can be removed and the original DNN can be transformed to be a thinner network, thus achieving speedup on general hardware.
Recently, researchers have carried out several works on SNNs pruning methods and made considerable progress. In GPSNN (Chen et al., 2019), a two-stage growing-pruning algorithm was used to compress fully
connected SNN so that the network could achieve better performance. In (Kumar et al., 2017), the non-critical synapses of SNNs were regularly pruned during Spike Timing Dependent Plasticity (STDP) training process based on a preset threshold. A soft pruning method has been considered to reduce the number of SNN weight updating during network training (Kumar et al., 2017). Recently, ADMM optimization combined with Spatio-temporal backpropagation (STBP) training was used to compress SNNs (Kumar et al., 2018). An attention-guided compression technique presented in (Song et al., 2019), used two steps to generate compressed deep SNN that could reduce spiking activity. Recent work (Chen et al., 2020) performs pruning on the temporal dimension of SNNs to reduce time steps for inference. Grad Rewiring (Gord et al., 2019) is a joint learning algorithm of SNN connection and weight, which can strengthen the exploration of network structures. Most existing SNNs pruning work has either focused on shallow structures or has only attempted to prune networks at low sparsity. Besides, A very recent work proposed a dynamic pruning framework to prune SNNs based on temporal lottery ticket hyperthesis (Song et al., 2020), which handles the weights pruning of the deep SNN structures.
In this paper, we present an end-to-end framework of weights pruning to compress the SNNs with a given resource budget. Unlike most resource-constrained compression methods which treat the resource consumption function as a black box (Kumar et al., 2019), we directly use the resource consumption to formulate a constrained optimization. The key idea is to use learnable parameters to control the lower bound of the sparsities. This introduces a sparsity constraint so that the resource constraint will only depend on the sparsity parameters. The constrained problem can be transformed into a Minimax optimization. Since the sparsity and resource constraints are not differentiable, the Minimax problem cannot be directly solved by gradient-based methods. In this work, we use the difference of convex function (DC) (Song et al., 2019) sparsity reformulation and straight-through estimator (STE) (Beng et al., 2019) to build a gradient-based algorithm to effectively optimize the compression problem.
We summarize the contributions as below:
* We propose an end-to-end Minimax optimization method to successfully compress the SNNs, as shown in Figure 1. DC sparsity reformulation (Song et al., 2019) and STE (Beng et al., 2019) are key components in this Minimax reformulation. Our compression procedure is end-to-end joint training of compression and fine-tuning on SNNs.
* We formulate the resource-constrained SNNs compression problem into a constrained optimization problem where the SNNs weights and resource consumption are linked with learnable sparsity parameters.
* The algorithm is gradient-based and easy to train. Evaluations of SNNs pruning on the public benchmark tasks show that our method is effective to compress SNNs and achieves state-of-the-art (SOTA) performance.
## 2. Related Work
We review the related work from three aspects: the set of work in SNNs; the set of work in model compression and the specific model compression for SNNs.
### Spiking Neural Networks
Different from ANNs, SNNs have a temporal dimension inherently, which uses sparse binary spike event sequences to represent information. Therefore, they contribute to more energy savings in specialized neuromorphic hardware (Kumar et al., 2018). The information is transmitted among neurons via synapses. When the membrane potential exceeds a certain threshold caused by accumulating received spikes, the neuron fires a spike to the next layer. In this study, we employed the Leaky Integrate-and-Fire (LIF) neuron (Leaky Integrate and-Fire, 1990), which is one of the most widely used neurons due to its effectiveness. The most common form of the LIF neuron is described as:
\[\tau_{m}\frac{\mathrm{d}V_{m}(t)}{\mathrm{d}t}=-\left(V_{m}(t)-V_{\mathrm{ rest}}\right)+X_{t} \tag{1}\]
where \(V_{m}(t)\) represents the membrane potential of the neuron at time \(t\), \(X_{t}\) represents the input from the presynaptic neuron. \(\tau_{m}\) is the membrane time as a constant value, that controls the decay and \(V_{\mathrm{rest}}\) is the resting potential after firing. A spike will fire if \(V_{t}\) exceeds the threshold \(V_{\mathrm{th}}\). As claimed in previous works (Kumar et al., 2018) and (Gord et al., 2019), We convert the above continuous differential equation into a discrete version:
\[H_{t+1} =V_{t}+\frac{1}{\tau_{m}}\left(-\left(V_{t}-V_{\mathrm{rest}}\right) +X_{t}\right) \tag{3}\] \[S_{t+1} =\Theta\left(m_{t+1}-V_{\mathrm{th}}\right)\] (4) \[V_{t+1} =S_{t+1}V_{\mathrm{rest}}+\left(1-S_{t+1}\right)H_{t+1} \tag{2}\]
where \(H_{t}\) and \(V_{t}\) denote the value of membrane potential after neural dynamics and after generating a spike at time step \(t\), respectively. \(S_{t}\) denotes the spike output at time step \(t\). \(\Theta(\cdot)\) is the Heaviside step function which is defined as \(\Theta(x)=1\) for \(x>=0\) and \(\Theta(x)=0\) for \(x<0\).
As we can see, the integration and firing behavior of neurons will result in the non-differentiability of the transfer function. So it is difficult to apply standard backpropagation in the training phase (Beng et al., 2019). To obtain a high-performance SNN, researchers have proposed various training methods (Beng et al., 2019; Chen et al., 2020; Chen et al., 2020; Chen et al., 2020; Chen et al., 2020). Recently, some works focus on supervised learning based on backpropagation algorithms, where they use a surrogate gradient function to approximate the gradient of non-differentiable spike activity (Kumar et al., 2018; Chen et al., 2020; Chen et al., 2020; Chen et al., 2020; Chen et al., 2020). These surrogate gradient methods provide an effective solution for training SNNs with deeper architecture (Xu et al., 2019), such as VGGNet (Wang et al., 2019) and ResNet (Krizhevsky et al., 2015) families. Therefore, we adopt a backpropagation algorithm based on surrogate gradient (Song et al., 2019) as the basic method for our SNNs training.
Figure 1. Our whole pipeline. The resource-constrained Minimax Optimization method can compress SNNs into a light-weight model with different sparsity levels.
### Model Compression
There are different techniques for model compression, such as pruning (Zhou et al., 2017; Chen et al., 2017; Chen et al., 2018; Chen et al., 2019; Chen et al., 2019; Chen et al., 2019), quantization (Chen et al., 2017; Chen et al., 2019; Chen et al., 2019; Chen et al., 2019), low-rank factorization (Chen et al., 2017; Chen et al., 2019), etc. Pruning utilizes the sparsity of weights tensors to achieve model compression. Weights pruning (Zhou et al., 2017; Chen et al., 2019) is effective to remove the single elements by zeroing out the individual weight. Moreover, structured pruning (Chen et al., 2017; Chen et al., 2019; Chen et al., 2019; Chen et al., 2019) prunes the weights according to specific structures to achieve more speedup on general hardware. Filter pruning (Chen et al., 2017; Chen et al., 2019; Chen et al., 2019; Chen et al., 2019) is the most broadly used structured pruning, which prunes all the weights associated with certain filters. Most filter pruning works prune the channels with low magnitude weights (Chen et al., 2017; Chen et al., 2019), or estimate the importance of channels for pruning (Chen et al., 2017; Chen et al., 2019; Chen et al., 2019). Yang _et al._(Yang et al., 2019) pre-compute a lookup table to estimate the latency of a convolution layer with different input/output channels, and use a greedy search strategy to gradually reduce the number of filters until the given resource budget is achieved. He _et al._(He et al., 2020) adopt reinforcement learning to search the number of pruned filters for each layer. The classification accuracy is used as the reward, and the number of pruned filters is taken as the action. Recently, more approaches (He et al., 2020; Chen et al., 2019; Chen et al., 2019) consider the model compression as a constrained problem (Chen et al., 2017; Chen et al., 2019; Chen et al., 2019; Chen et al., 2019). Furthermore, resource consumption is used to restrict the action space. These methods are successfully applied to fully supervised tasks such as image classification and object detection. In this paper, we proposed an end-to-end optimization method to solve a resource-constrained compression problem on SNNs, we demonstrate the problem formulation from the unstructured weights pruning perspective.
### Model Compression for SNN
To reduce the energy consumption of SNNs, some approaches focus on the compression of SNN models recently, such as connection pruning (Chen et al., 2017; Chen et al., 2019; Chen et al., 2019) and model quantization (Chen et al., 2017; Chen et al., 2019; Chen et al., 2019; Chen et al., 2019). Deng _et al._(Deng et al., 2019) defined the connection pruning and weight quantization as a constrained optimization problem and used Spatio-temporal backpropagation (STBP) and alternating direction method of multipliers (ADMM) to solve it. Chen _et al._(Chen et al., 2017) formulated the gradient rewiring (Grad R) algorithm which redefines the gradient of SNNs to a new synaptic parameter and joint learning SNNs connection and weight. In addition, Kim _et al._(Kim et al., 2019) performed the connection pruning toward deeper SNNs (\(\geq 16\) layers) and combined the Iterative Magnitude Pruning (Chen et al., 2019) and Early-Bird (Evely and Ferrara, 2019) tickets to obtain smaller SNNs. Chen _et al._(Chen et al., 2019) proposed a dynamic pruning algorithm based on nonlinear reparameterization mapping from spine size to SNN weights. To compare with these unstructured weights pruning works for SNNs, we adopt the Minimax optimization method to jointly optimize the global sparsity of SNNs and weights parameters. We handle all layers' weights parameters globally with one sparsity parameter to solve the unstructured pruning problem.
## 3. Formulation
### Resource-Constrained Optimization
The ideal scenario of SNN compression is that given a resource budget \(R_{\text{budget}}\) (based on a certain metric, e.g., Parameters, Flops, latency, or energy), the compression method can return a compressed model which satisfies the given budget and maintains the accuracy as well as possible. The whole process should be automatic, i.e., there is no need to manually set the sparsity of each layer. In this paper, we directly formulate such a compression scheme for a constrained optimization problem:
(5a) \[\min_{\mathcal{W},\mathbf{s}} \mathcal{L}(\mathcal{W})\] (5c) \[\text{s. t.} R(s)\leq R_{\text{budget}},\] (5d) \[\sum_{i}\mathbf{I}(\mathcal{W}_{i}=0)\geq s\] (5e)
where \(R(s)\) evaluates a general resource consumption (e.g., Flops or latency) based on the number of (nonzero) weights for each layer. It does not need to be differentiable. For example, when representing latency, it can be computed by a latency table as in Yang et al. (Yang et al., 2019). \(\mathcal{L}\) is the standard training loss.
\(\mathbf{I}(\cdot)\) is the indicator function that returns \(1\) if the argument is satisfied and \(0\) otherwise. \(\mathbf{s}\) is a learnable scalar variable to control the lower bound of the sparsity of weight parameters vector \(\mathcal{W}\) of the whole network. This formulation holds because the resource function \(R\) monotonically decreases with respect to the increasing sparsities, i.e., the more weights are pruned, the smaller the resource consumption we have. Note that we mainly focus on the unstructured pruning (or called weights sparsification) for SNN in the main text, thus \(\mathcal{W}_{i}\) in the above equation stands for **each element of weight parameters vector \(\mathcal{W}\)** of the whole network.
## 4. Optimization
In the previous section, we have already formulated the resource-constrained pruning as a constrained optimization (5). In this section, we first do some reformulation to make it more convenient to solve. Then we propose a gradient-based algorithm to solve the resource-constrained pruning in an end-to-end way.
### Minimax Reformulation
The sparsity constraint (\(\mathbf{c}_{\text{C}}\)) is non-convex and the non-continuous indicator function makes it more difficult. Common approaches to deal with this constraint include \(\ell_{1}\)-norm relaxation (Zhou et al., 2017) and \(\ell_{0}\)-norm projection (Chen et al., 2019). The ideas of \(\ell_{1}\)-norm relaxation have been applied in DNN compression (Wang et al., 2019; Chen et al., 2019; Chen et al., 2019). However, the \(\ell_{1}\)-norm can only approximate the sparsity constraint, so it is not equivalent to the sparsity constraint and there is no guarantee to bound the real sparsity by restricting the \(\ell_{1}\)-norm.
Figure 2. The dynamics of LIF neurons, as similarly described in (Chen et al., 2019). When the membrane potential exceeds a threshold value, the neuron will fire a spike to the next layer and resets.
Let \(\|\mathbf{u}\|_{\mathrm{s,2}}\) be the bottom-(s, 2) "norm", which denotes the \(\ell_{2}\)-norm of the sub vector composed of bottom-\(s\) elements in magnitude. Then we have an _equivalent_ reformulation for the sparsity constraint (5c):
\[\|\mathcal{W}\|_{\mathrm{s,2}}=0\Leftrightarrow\sum_{i}\mathbf{I}(\mathcal{W}_ {i}=0)\geq s, \tag{6}\]
Equation (6) is proved by Tono _et al._Tono et al. (2017), where the left-hand side is called DC (difference of convex functions) representation of the \(\ell_{0}\)-constraint. By this transformation, the sparsity constraint becomes an equality constraint of a continuous function. Compared to the original \(\ell_{0}\)-norm constraint, it can be written as a "soft" constraint and avoid being stuck in the bad local optimum of the constraint set.
By introducing dual variables \(y\) and \(z\), we derive the minimax reformulation of problem (5):
\[\min_{\mathcal{W},s}\max_{y,z\geq 0}\mathcal{L}(\mathcal{W})+\underbrace{y\| \mathcal{W}\|_{\mathrm{f}=1}^{2}}_{\mathrm{sparsity\ loss}\cdot\mathcal{S}(y,s \mathcal{W})}+\underbrace{z(R(s)-R_{\mathrm{budget}})}_{\mathrm{resource\ loss}}. \tag{7}\]
Where we introduce the sparsity loss \(\mathcal{S}(y,s,\mathcal{W}):=y\|\mathcal{W}\|_{\mathrm{f}=1}^{2}\), and resource loss \(z(R(s)-R_{\mathrm{budget}})\) to substitute the original constraints. Figure 3 shows an illustration of the reformulated minimax problem. It is easy to verify that (7)\(\rightarrow\)\(\ \
### Implementation details
In our works, we validate the compression method on six SNN models, including the shallow SNNs (e.g. 2 FC, 6 Conv and 2 FC) and the deep SNNs (e.g. VGG16 (Wang et al., 2017), ResNet19 (He et al., 2017), SEW ResNet18 (He et al., 2017), VGGSNN (He et al., 2017)). We compare the performance of our method with previous SNN compression methods on static MNIST, CIFAR10, CIFAR100, ImageNet11K datasets and neuromorphic CIFAR10-DVS dataset which is converted from the static image dataset by using a DVS camera. Experiments are conducted on NVIDIA V100 GPUs and we use Spikingfelly (Srivastava et al., 2015) framework to implement SNNs.
Similar to the previous SNN work (Chen et al., 2017), we use a shallow SNN with 2 FC layers on the MINST dataset, and a model with 6 convolution layers and 2 FC layers for the CIFAR10 dataset. These two shallow SNNs are trained with Adam optimizer with a learning rate 1e-4. The timestep is set to 8. Other hyperparameters of baseline are the same as [6](e.g. batch size, learning rate). What's more, we use deep SNNs, VGG16, ResNet19, and VGGSNN. The training method follows the previous SNN work (He et al., 2017). We train deep SNNs by SGD optimizer with momentum 0.9 and weight decay 5e-4. The learning rate is set to 0.05 for baseline training and cosine decay to 0. The timestep is set to 5 and the batch size is set to 32. The default number of epochs is set to 300. As for training SEW ResNet18 on ImageNet, we follow all the training setting of SEW ResNet (He et al., 2017). The base learning is 0.1 with cosine annealing scheduler. The number of epochs is 320, the batch size is set to 32, and the timestep is set to 4. In all datasets, the learning rate of \(y\) is set to 0.1, while the default learning rate of \(z\) is set to \(10^{5}\). We count the number of zero and nonzero values of the whole weights in SNN and compute the percentage of zero values to be the sparsity.
Training methodologyAccording to previous SNNs work settings respectively, we first train SNNs models to get pre-trained baseline models. Then our compression training stage starts with pre-trained models. Before pruning the SNN models, we set a budget list which values are some compression ratios from 0.5 to 0.005 (e.g. [0.25, 0.1, 0.05, 0.01, 0.005]). Furthermore, the value of the budget list can be connectivity, parameter size, latency times, FLOPs, and so on. For connection pruning, the values in the budget list are connectivity ratios. For structure pruning, the values in the budget list are FLOPs ratios in our work. During our compression training, if the model connectivity meets the current target compression ratio, we pause the pruning and then fine-tune the snapshot at this ratio until achieving the maximum fine-tuning epochs. After the
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Pruning Method** & **Dataset** & **Arch.** & **Top-1 Acc. (\%)** & **Acc. Loss (\%)** & **Sparsity (\%)** \\ \hline \multirow{3}{*}{ADMM-based (Srivastava et al., 2015)} & \multirow{3}{*}{MNIST} & \multirow{3}{*}{LeNet-5 like} & \multirow{3}{*}{99.07} & +0.03 & 50.00 \\ & & & & -0.43 & 60.00 \\ & & & & -2.23 & 75.00 \\ \hline \multirow{3}{*}{Deep R (Chen et al., 2017)} & \multirow{3}{*}{MNIST} & \multirow{3}{*}{2 FC} & \multirow{3}{*}{98.92} & -0.36 & 62.86 \\ & & & & -0.56 & 86.70 \\ & & & & -2.47 & 95.82 \\ & & & & -9.67 & 98.90 \\ \hline \multirow{3}{*}{Grad R (Chen et al., 2017)} & \multirow{3}{*}{MNIST} & \multirow{3}{*}{2 FC} & \multirow{3}{*}{98.92} & -0.33 & 74.29 \\ & & & & -0.43 & 82.06 \\ & & & & -2.02 & 94.37 \\ & & & & -3.55 & 96.94 \\ & & & & -8.08 & 98.62 \\ \hline \multirow{3}{*}{**Ours**} & \multirow{3}{*}{MNIST} & \multirow{3}{*}{2 FC} & \multirow{3}{*}{**98.91**} & **-0.06** & **75.00** \\ & & & & **-0.16** & **85.00** \\ & & & & **-1.23** & **95.00** \\ & & & & **-2.70** & **97.00** \\ & & & & & **-7.34** & **98.70** \\ \hline \hline \multirow{3}{*}{ADMM-based (Srivastava et al., 2015)} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{7 Conv, 2 FC} & \multirow{3}{*}{89.53} & -0.38 & 50.00 \\ & & & & -2.16 & 75.00 \\ & & & & -3.85 & 90.00 \\ \hline \multirow{3}{*}{Deep R (Chen et al., 2017)} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{6 Conv, 2 FC} & \multirow{3}{*}{92.84} & -1.98 & 94.76 \\ & & & & -2.56 & 98.05 \\ & & & & -3.53 & 98.96 \\ \hline \multirow{3}{*}{Grad R (Chen et al., 2017)} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{6 Conv, 2 FC} & \multirow{3}{*}{92.84} & -0.30 & 71.59 \\ & & & & -0.34 & 87.96 \\ & & & & -0.81 & 94.92 \\ & & & & -1.47 & 97.65 \\ & & & & -3.52 & 99.27 \\ \hline \multirow{3}{*}{STDS (Chen et al., 2017)} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{6 Conv, 2 FC} & \multirow{3}{*}{92.84} & -0.35 & 97.77 \\ & & & & -2.63 & 99.25 \\ \hline \multirow{3}{*}{**Ours**} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{6 Conv, 2 FC} & \multirow{3}{*}{**92.88**} & **+0.84** & **75.00** \\ & & & & **+0.52** & **88.04** \\ & & & & **+0.41** & **95.07** \\ & & & & **-0.13** & **97.71** \\ & & & & **-1.38** & **98.84** \\ & & & & **-2.56** & **99.31** \\ \hline \hline \end{tabular}
\end{table}
Table 1. Performance comparison between our method and previous works on MNIST and CIFAR10 datasets.
fine-tuning process at the current compression rate finishes, our method removes the current ratio from the budget list and then continues the compression training automatically to achieve the next compression ratio. Compression and fine-tuning are jointly performed in the one-stage training process of SNNs. The number of epochs in fine-tuning phase for \(i_{th}\) compression ratio in the budget list is set to the same value or scheduled as \(\frac{1}{S^{t}}\frac{T_{\text{epoch}}-C_{\text{epoch}}}{\sum\limits_{j=1}^{N} \frac{1}{S^{t}}}\).
where, \(S^{t}\) is the \(i_{th}\) compression ratio. \(T_{\text{epoch}}\) is the total number of epochs, \(C_{\text{epoch}}\) is the number of already used epochs.
### Quantitative Experiments
_Connection pruning and fine-tuning jointly._ We use the connection of the SNNs model as the budget compression ratios for our Minimax optimization method. During compression training, the connection pruning and fine-tuning are trained jointly. Our joint compression method not only reduces the training time and simplifies the tedious fine-tuning process for different compression ratio, but also help the model under smaller ratios get better performance. Therefore, for one SNN model, we can achieve state-of-the-art (SOTA) performance of different ratios in one compression training process, which is different from previous work, since they only can get one compression ratio per training process [38]. As shown in Table 1 and 2, we summed up the results of our compression
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Pruning Method** & **Dataset** & **Arch.** & **Top-1 Acc. (\%)** & **Acc. (\%)** & **Sparsity (\%)** \\ \hline \multirow{3}{*}{IMP [38]} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{VGG16} & \multirow{3}{*}{-} & 92.66 & 68.30 \\ & & & & 92.54 & 89.91 \\ & & & & 92.38 & 95.69 \\ & & & & 91.81 & 98.13 \\ \hline \multirow{3}{*}{**Ours**} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{VGG16} & \multirow{3}{*}{**93.25**} & **93.27** & **69.02** \\ & & & & **93.26** & **90.09** \\ & & & & **92.76** & **95.70** \\ & & & & **92.00** & **98.13** \\ \hline \hline \multirow{3}{*}{Grad R [6]} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{ResNet19} & \multirow{3}{*}{93.22} & 92.68 & 76.90 \\ & & & & 91.91 & 94.25 \\ & & & & 91.12 & 97.56 \\ \hline \multirow{3}{*}{IMP [38]} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{ResNet19} & \multirow{3}{*}{93.22} & 93.50 & 76.20 \\ & & & & 93.46 & 94.29 \\ & & & & 93.18 & 97.54 \\ \hline \multirow{3}{*}{**Ours**} & \multirow{3}{*}{CIFAR10} & \multirow{3}{*}{ResNet19} & \multirow{3}{*}{**94.85**} & **94.84** & **80.05** \\ & & & & **94.36** & **95.07** \\ & & & & **93.81** & **97.07** \\ \hline \hline \multirow{3}{*}{Grad R [6]} & \multirow{3}{*}{CIFAR100} & \multirow{3}{*}{ResNet19} & \multirow{3}{*}{71.34} & 69.36 & 77.03 \\ & & & & 67.47 & 94.92 \\ & & & & 67.31 & 97.65 \\ \hline \multirow{3}{*}{IMP [38]} & \multirow{3}{*}{CIFAR100} & \multirow{3}{*}{ResNet19} & \multirow{3}{*}{71.34} & 71.45 & 76.20 \\ & & & & 69.05 & 97.54 \\ \hline \multirow{3}{*}{**Ours**} & \multirow{3}{*}{CIFAR100} & \multirow{3}{*}{ResNet19} & \multirow{3}{*}{**74.71**} & **73.05** & **79.99** \\ & & & & **72.67** & **95.19** \\ & & & & **70.80** & **97.31** \\ \hline \hline \multirow{3}{*}{Grad R [6]} & \multirow{3}{*}{ImageNet} & \multirow{3}{*}{SEW ResNet18} & \multirow{3}{*}{63.22} & 60.65 & 50.94 \\ & & & & 24.62 & 53.65 \\ \hline \multirow{3}{*}{ADMM [10]} & \multirow{3}{*}{ImageNet} & \multirow{3}{*}{SEW ResNet18} & \multirow{3}{*}{63.22} & 59.48 & 82.58 \\ & & & & 55.85 & 88.84 \\ \hline \multirow{3}{*}{STDS [8]} & \multirow{3}{*}{ImageNet} & \multirow{3}{*}{SEW ResNet18} & \multirow{3}{*}{63.22} & 61.30 & 82.58 \\ & & & & 59.93 & 88.84 \\ & & & & 58.06 & 93.24 \\ & & & & 56.28 & 95.30 \\ \hline \multirow{3}{*}{**Ours**} & \multirow{3}{*}{ImageNet} & \multirow{3}{*}{SEW ResNet18} & \multirow{3}{*}{**63.25**} & **61.42** & **82.50** \\ & & & & **60.51** & **88.84** \\ & & & & **58.12** & **93.20** \\ & & & & **56.46** & **94.39** \\ \hline \hline \end{tabular}
\end{table}
Table 2. Performance comparison between our method and previous works on larger models.
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Method** & **Arch.** & **Top-1 Acc. (\%)** & **Acc. (\%)** & **Sparsity (\%)** \\ \hline \multirow{3}{*}{IMP [38]} & \multirow{3}{*}{VGGNN} & \multirow{3}{*}{82.80} & 81.10 & 76.20 \\ & & & 81.50 & 86.57 \\ & & & 80.10 & 89.91 \\ & & & 78.60 & 94.28 \\ \hline \multirow{3}{*}{**Ours**} & \multirow{3}{*}{VGGNN} & \multirow{3}{*}{82.80} & **82.40** & **85.18** \\ & & & **81.90** & **90.14** \\ & & & **81.20** & **93.14** \\ & & & **80.10** & **95.16** \\ \hline \hline \end{tabular}
\end{table}
Table 3. Performance of our method and previous work IMP on CIFAR10-DVS dataset.
experiments which were obtained by jointly pruning connection and fine-tuning the model.
Comparisons to previous work.We compare our method with previous works in Table 1, 2 and 3. The results of two shallow SNN models on MNIST and CIFAR10 are shown in Table 1. We compare our connection pruning and fine-tuning jointly training method with previous research, including ADMM-based (Deng et al., 2017), Deep R (Chen et al., 2018), Grad R (Chen et al., 2018), and STDS (Chen et al., 2018). It is observed that our approach outperforms previous pruning methods in terms of connection sparsity and accuracy on the two benchmark datasets. Furthermore, we have smaller \(\Delta\)Acc degradations under all comparable compression ratios.
We present the comparisons of deep SNN models, VGG16 (Vgg et al., 2016), ResNet19 (He et al., 2016) and SEW ResNet18 (He et al., 2016) in Table 2. We reproduce the baseline based on the previous work (Wang et al., 2018), and the performance is much higher than the reported result in (Wang et al., 2018): 1.63% higher on CIFAR10 and 3.37% higher on CIFAR100 for ResNet19 (He et al., 2016) SNN model, therefore, we compare absolute values of accuracy on deep SNNs. As shown in Table 2, our method is comparable to other approaches. For the VGG16 model, our methods have the highest accuracy at all connection sparsity ratios compared with Grad R (Chen et al., 2018) and IMP (Wang et al., 2018). For ResNet19 (He et al., 2016), when the connection sparsity ratio is less than 97%, our method significantly outperforms other methods. When the connection sparsity is higher than 97%, we still achieve better accuracy compared with other works, but the connection sparsity is slightly smaller than Grad R (Chen et al., 2018) and IMP (Wang et al., 2018). It is worth mentioning that the accuracy of our method can even be further improved compared to the baseline on all datasets when the sparsity is nearly 80%. Even on the large-scale dataset like ImageNet, our pruning method has also achieved competitive performance compared with the state-of-the-art.
We also validated on neuromorphic datasets that have been less involved in previous work. To the best of our knowledge, our work is the first work to compress SNNs on the temporal CIFAR10-DVS dataset. Under the same structure and settings, we implemented the IMP method (Wang et al., 2018) and conducted our experiments on the CIFAR10-DVS dataset. As shown in Table 3, our method significantly improves the accuracy of VGGSNN (Chen et al., 2018) model with different sparsity ratios. In summary, experiments have shown that our compression optimization method can theoretically handle any type of SNN model.
## 6. Ablation Studies
Comparison with sequential method.We compare our end-to-end Minimax optimization method on both sequentially and jointly training, for pruning and fine-tuning on the CIFAR10 dataset. For the sequential compression method, we first prune the SNNs models and save the pruned model snapshots during pruning training. We then fine-tune each of these snapshots for another 256 epochs for 6 Conv, 2 FC SNN models, which means need to fine-tune extra \(n\times 256\) epochs, the \(n\) is the length of the budget list. As shown in Table 4, the compression ratios (column b) in which pruning and fine-tuning are trained jointly have better accuracy when compression ratios are smaller than 5%. Sequentially trained compression ratios (column a) which connect 11.95% have a slight advantage because trained more epochs than joint ratios with a similar connection. However, as the connection turn smaller, the joint method achieves better results and even obtains an 8.72% accuracy advantage at a 0.64 connection ratio. What's more, the joint method in Table 4 was trained 700 epochs in total, which is far less than the train epochs numbers of the sequential method.
Comparison of fine-tuning options.We compare the final accuracy between applying with a cosine annealing scheduler and without any learning rate scheduler when fine-tuning on the CIFAR10 dataset. For using a cosine annealing scheduler, in each stage of achieving the new compression ratio in the resource budget list, the number of the fine-tuning epoch is reset to 300 and the initial learning rate is changed to 0.001. As shown in Table 4, the accuracy significantly increased when we use the cosine annealing scheduler in the fine-tuning phase.
Training trend plots.We plot the changing trend of sparsity value \(s\) in Figure 4, which demonstrates that our Minimax optimization algorithm can converge well gradually.
Per-layer Sparsity vs. Global Sparsity.We compare the difference between pruning using per-layer sparsity and our pruning using global sparsity. Our optimization is based on global sparsity \(s\), which sorts the weight values of tensors of all layers together during pruning and coordinates the total sparsity of the whole model during optimization. On the contrary, the method using per-layer sparsity sorts the weights on each layer separately, each with a sparsity variable to control. For both the per-layer sparsity method and global sparsity method, our compression target is the layers whose connectivity is more than 1e4. Figure 5 shows the difference in connectivity sparsity between the per-layer sparsity method and our global sparsity method on 6 Conv, 2 FC SNN model, the 6 source convolution layers have the same connectivity in the baseline model. In Figure 5, we can see the connectivity after pruning using the global sparsity method show more obvious diversities between these 6 convolution layers. However, the per-layer sparsity method results in almost the same pruned connectivity for these 6 convolution layers. In Table 6, we can see that our global sparsity method has better pruning performance at each connectivity level. |
2304.09097 | Sheaf4Rec: Sheaf Neural Networks for Graph-based Recommender Systems | Recent advancements in Graph Neural Networks (GNN) have facilitated their
widespread adoption in various applications, including recommendation systems.
GNNs have proven to be effective in addressing the challenges posed by
recommendation systems by efficiently modeling graphs in which nodes represent
users or items and edges denote preference relationships. However, current GNN
techniques represent nodes by means of a single static vector, which may
inadequately capture the intricate complexities of users and items. To overcome
these limitations, we propose a solution integrating a cutting-edge model
inspired by category theory: Sheaf4Rec. Unlike single vector representations,
Sheaf Neural Networks and their corresponding Laplacians represent each node
(and edge) using a vector space. Our approach takes advantage from this theory
and results in a more comprehensive representation that can be effectively
exploited during inference, providing a versatile method applicable to a wide
range of graph-related tasks and demonstrating unparalleled performance. Our
proposed model exhibits a noteworthy relative improvement of up to 8.53% on
F1-Score@10 and an impressive increase of up to 11.29% on NDCG@10,
outperforming existing state-of-the-art models such as Neural Graph
Collaborative Filtering (NGCF), KGTORe and other recently developed GNN-based
models. In addition to its superior predictive capabilities, Sheaf4Rec shows
remarkable improvements in terms of efficiency: we observe substantial runtime
improvements ranging from 2.5% up to 37% when compared to other GNN-based
competitor models, indicating a more efficient way of handling information
while achieving better performance. Code is available at
https://github.com/antoniopurificato/Sheaf4Rec. | Antonio Purificato, Giulia Cassarà, Federico Siciliano, Pietro Liò, Fabrizio Silvestri | 2023-04-07T07:03:54Z | http://arxiv.org/abs/2304.09097v3 | # Sheaf Neural Networks for Graph-based Recommender Systems
###### Abstract.
Recent progress in Graph Neural Networks has resulted in wide adoption by many applications, including recommendation systems. The reason for Graph Neural Networks' superiority over other approaches is that many problems in recommendation systems can be naturally modeled as graphs, where nodes can be either users or items and edges represent preference relationships. In current Graph Neural Network approaches, nodes are represented with a static vector learned at training time. This static vector might only be suitable to capture some of the nuances of users or items they define. To overcome this limitation, we propose using a recently proposed model inspired by category theory: Sheaf Neural Networks. Sheaf Neural Networks, and its connected Laplacian, can address the previous problem by associating every node (and edge) with a vector space instead than a single vector. The vector space representation is richer and allows picking the proper representation at inference time. This approach can be generalized for different related tasks on graphs and achieves state-of-the-art performance in terms of F1-Score@N in collaborative filtering and Hits@20 in link prediction. For collaborative filtering, the approach is evaluated on the MovieLens 100K with a 5.1% improvement, on MovieLens 1M with a 5.4% improvement and on Book-Crossing with a 2.8% improvement, while for link prediction on the ogbl-ddi dataset with a 1.6% refinement with respect to the respective baselines.
Recommender systems, graph neural networks, link prediction, collaborative filtering +
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: conference: Proceedings in the 2015 ACM SIGKDD international conference on Knowledge and data mining, pp. 1-10. ACM, 2015.
+
Footnote †: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference:: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference:: conference:: conference: conference: conference:: conference: conference: conference: conference:: conference: conference: conference: conference: conference: conference:: conference: conference: conference: conference: conference:: conference: conference: conference: conference:: conference: conference: conference:: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference: conference:: conference: conference: conference: conference:: conference: conference: conference: conference: conference:: conference:: conference: conference: conference: conference: conference:: conference: conference: conference:: conference:: conference: conference: conference: conference: conference:: conference: conference: conference:: conference: conference:: conference: conference: conference: conference:: conference: conference:: conference: conference: conference:: conference: conference: conference:: conference:: conference: conference: conference:: conference: conference: conference:: conference: conference:: conference:: conference:: conference:: conference: conference:: conference: conference: conference:: conference: conference:: conference: conference:: conference: conference: conference:: conference:: conference: conference:: conference: conference:: conference: conference:: conference: conference:: conference: conference:: conference: conference:: conference: conference: conference:: conference: conference:: conference:: conference: conference:: conference: conference: conference: conference:: conference: conference:: conference: conference:: conference: conference: conference: conference:: conference: conference:: conference: conference:: conference: conference:: conference: conference:: conference: conference: conference:: conference:: conference: conference: conference:: conference: conference:: conference: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference::: conference: conference:: conference:: conference::: conference:: conference:: conference:: conference::: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference::: conference:: conference:: conference:: conference:: conference::: conference: conference:: conference::: conference:: conference:: conference:: conference::: conference:: conference:: conference:: conference:: conference:: conference::: conference:: conference:: conference::: conference:: conference:: conference:: conference:: conference:: conference:: conference::: conference::: conference:: conference:: conference::: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference::: conference:: conference:: conference::: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference::: conference:: conference:: conference: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference: conference:: conference:: conference:: conference: conference:: conference:: conference: conference:: conference::: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference: conference: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference:: conference::: conference:: conference:: conference:: conference:: conference:: conference: conference:: conference:: conference: conference: conference:: conference
we are proposing, in this research, to use a novel class of GNN architectures: "_Sheaf Neural Networks_".
Sheaf Neural Networks (SNNs) are a recently proposed and novel class of Graph Neural Network models inspired by Category Theory. It has been used in many different tasks and has been proven superior to GNNs (Beng et al., 2015). In this class of models, the basic building blocks are _Cellular Sheaves_. Cellular sheaves associate a vector space with each node and edge of a graph and linear maps between these spaces. Simply put, Sheaf Neural Networks are Graph Neural Networks that operate over Cellular Sheaves (Beng et al., 2015). SNNs work by computing a generalization of the well-known Graph Laplacian, the so-called _Sheaf Laplacian_(Chen et al., 2016). Sheaf Laplacian is indeed a generalization of Graph Laplacian because when the vector spaces of the cellular sheaves are 1-dimensional, and we apply identity maps between them, then the two Laplacians are perfectly equivalent. The Sheaf Laplacian is computed via the restriction map in a non-parametric manner at pre-processing time (Beng et al., 2015).
Our research extends the results in the literature on the theory of SNNs, to two real-world problems: item recommender systems and link prediction. In particular, we show that applying SNNs to the task of graph-based recommender systems greatly improves the performance of both item recommender and link prediction systems. Experiments show that our proposed SNN-based models outperform all state-of-the-art models in the respective tasks. We show that in the case of recommendation, we outperform the state-of-the-art method by 5.1% on MovieLens 100k, 5.4% on MovieLens 1M and 2.8% on Book-Crossing. In the case of link prediction, we have a 1.6% improvement on the ogbl-ddi dataset.
The innovative contributions of this research work are the following:
* We propose a novel architecture for products and link recommender systems based on Sheaf Neural Networks that achieve state-of-the-art results in their respective tasks.
* We demonstrate the relation between our model and the use of the Bayesian Personalised Ranking loss function using different experiments.
* We perform extensive experiments on multiple datasets for top-N recommendation and link prediction tasks, which verify our solution's rationality and potential. Experimental results show that SNNs outperforms all the other baselines on the two tasks we focus on in this paper. In recommendation tasks, we beat the state-of-the-art method by 5.1% on MovieLens 100k, 5.4% on MovieLens 1M, and 2.8% on Book-Crossing. In the case of link prediction, we have a 1.6% improvement on the ogbl-ddi dataset.
The rest of the paper is organized as follows. Section 2 shows recent works in the current literature. Section 3 gives a background to Graph Neural Networks and sheaf theory. Section 4 explains our approach. Section 5 shows some implementation details as the dataset choice and the setting for the experiments. In section 6, we demonstrate the effectiveness of the proposed solution, and we conclude in 7 with pointers to future ideas.
## 2. Related Work
This section introduces some examples of state-of-the-art recommender systems.
### Deep learning-based recommender systems
We can distinguish between two categories in the existing DL-based recommendation models. For every category, it is shown an example.
* Recommendation based on neural building blocks (Han et al., 2015): the DL technique determines the recommendation model's applicability. For example, MLPs can simply model the non-linear interactions between users and items; CNNs can extract local and global representations from heterogeneous data sources like text and image; recommender systems can model the temporal dynamics and sequential evolution of content information using RNNs.
* Recommendation based on deep hybrid models (Zheng et al., 2016): this technique is based on a mix of deep learning techniques that change depending on the task. One common idea is to mix long-term and short-term networks to model long-term preferences and short-term preferences. Usually, this approach achieves better results with respect to the previous one.
Zheng et al. (Zheng et al., 2016) first convert a user's implicit feedback into a "like" vector and a confidence vector, and then they model the probability of the "like" vector, weighted by the confidence vector.
Dong et al. (Dong et al., 2015) propose a hybrid model which jointly performs deep users and items' latent factors learning from side information and collaborative filtering from the rating matrix. The output of this model approximates the predicted rating, and then a list of ranked items is generated for each user based on these prediction ratings.
### Autoencoder-based recommender systems
Autoencoder is an unsupervised model attempting to reconstruct its input data in the output layer. In general, the bottleneck layer (the middle-most layer) is used as a salient feature representation of the input data (Sachdeva et al., 2017). The main variants of Autoencoders can be considered as denoising Autoencoder (Wang et al., 2017) or variational Autoencoder (VAE) (Sachdeva et al., 2017). There are two ways to apply Autoencoder to a recommender system:
* Using Autoencoder to learn lower-dimensional feature representations at the bottleneck layer.
* Filling the blanks of the interaction matrix directly in the reconstruction layer.
Sachdeva et al. (Sachdeva et al., 2017) introduce a recurrent version of the VAE, where instead of passing a subset of the whole history regardless of temporal dependencies, they pass the consumption sequence subset through a recurrent neural network. At each time-step of the RNN, the sequence is fed through a series of fully-connected layers, the output of which models the probability distribution of the most likely future preferences.
Han et al. (Han et al., 2015) improve the previous idea. They first pre-train an autoencoder with the local kernelised weight matrix, which transforms the data from one space into the feature space by using a 2d-RBF kernel. Then, the pre-trained autoencoder is fine-tuned with the rating matrix, produced by a convolution-based global kernel, which captures the characteristics of each item.
Background
We briefly review the necessary background to understand the solution we propose. We start by summarizing the main characteristics of GNNs, and we then introduce cellular sheaf theory to finally present the learning algorithm we use: _Neural Sheaf Diffusion_.
### Graph Neural Networks
The rise of GNN mainly originates from the advancement of convolutional neural network (CNN) and Graph Representation Learning (GRL) (Goh et al., 2017). When applied to regular Euclidean data such as images or texts, CNN is extremely effective in extracting localized features. However, for non-Euclidean data like graphs, CNN requires generalization to handle the situations where operation objects (e.g., pixels in images or nodes on graphs) are non-fixed in size. In terms of GRL, it aims to generate low-dimensional vectors for graph nodes, edges, or subgraphs, which represent complex connection structures of graphs.
A graph is represented as \(G=(V,E)\), where \(V\) is the set of nodes and \(E\) is the set of edges. The set of edges can also be described by an adjacency matrix \(A\). Let \(v_{i}\in V\) be a node and \(e_{ij}=(v_{i},v_{j})\in E\) be an edge pointing from \(v_{j}\) to \(v_{i}\). \(A\) is defined as:
\[A_{ij}=\begin{cases}1\text{ if }\ e_{ij}\in E\\ 0\text{ otherwise}\end{cases} \tag{1}\]
The neighbourhood of a node \(v\) is denoted as:
\[N(\mathbf{o})=\{\mathbf{u}\in V\mid(\mathbf{o},\mathbf{u})\in E\} \tag{2}\]
The degree matrix of \(G\) is a matrix \(D\) which contains information about the number of edges attached to each vertex.
\[D_{ij}=\begin{cases}degree(i)\text{ if }i=j\\ 0\text{ otherwise}\end{cases} \tag{3}\]
Using the definition of degree matrix \(D\) and adjacency matrix \(A\) the Laplacian can be easily defined as:
\[L=D-A \tag{4}\]
Given the graph data, the main idea of GNN is to iteratively aggregate feature information from neighbours and integrate the aggregated information with the current central node representation during the propagation process. From the perspective of network architecture, GNN stacks multiple propagation layers consisting of aggregation and update operations. The formulation of propagation is:
\[Update:H^{(I)}=f(H^{(I-1)},A) \tag{5}\]
\[Aggregate:H^{(I)}=\sigma(D_{\mathbf{o}}^{-\frac{1}{2}}AW^{0}D_{\mathbf{e}}^{-1 }D_{\mathbf{o}}^{-\frac{1}{2}}W^{(I)}) \tag{6}\]
Where the aggregation function is for a hypergraph neural network. \(\sigma\) is the activation function, \(D_{\mathbf{o}}\) and \(D_{\mathbf{e}}\) denote the diagonal matrices of the edge degrees and the vertex degrees, respectively.
### Sheaf theory
A cellular sheaf \((G,\mathcal{F})\) on an undirected graph \(G=(V,E)\) consists of:
* A vector space \(\mathcal{F}(\mathbf{o})\) for each \(v\in V\);
* A vector space \(\mathcal{F}(\mathbf{e})\) for each \(v\in E\);
* A linear map \(\mathcal{F}_{v\ni\mathbf{e}}:\mathcal{F}(v)\rightarrow\mathcal{F}(e)\) for each incident node-edge pair \(v\trianglelefteq e\);
The vector spaces of the node and edges are called stalks, while the linear maps are called restriction maps. Given a sheaf \((G,\mathcal{F})\) we define the space of 0-cochains \(C^{0}(G,\mathcal{F})\) as the direct sum over the vertex stalks:
\[C^{0}(G,\mathcal{F})=\bigoplus_{v\in V}\mathcal{F}(v) \tag{7}\]
The space of 1-cochains \(C^{1}(G,\mathcal{F})\) is the direct sum over the edge stalks.
Given some arbitrary orientation for each edge \(e\) we define the co-boundary map:
\[\delta:C^{0}(G,\mathcal{F})\to C^{1}(G,\mathcal{F})=\delta(x)_{e}= \mathcal{F}_{v\trianglelefteq e}x_{\mathbf{o}}-\mathcal{F}_{u\trianglelefteq e}x_{u} \tag{8}\]
The sheaf Laplacian of a sheaf is defined as:
\[L_{\mathcal{F}}=\delta^{T}\delta=\sum_{v,u\trianglelefteq e}\mathcal{F}_{v \trianglelefteq e}^{T}(F_{v\trianglelefteq e}x_{\mathbf{o}}-F_{u\trianglelefteq e}x_{u}) \tag{9}\]
It can be seen how the sheaf Laplacian is strictly related to the Laplacian defined in 4 but considers restriction maps instead of edges. In fact, the sheaf Laplacian is a generalization of the graph Laplacian that encodes additional relational structure parameterized by the underlying graph. The normalised sheaf Laplacian \(\Delta_{\mathcal{F}}\) is defined as:
\[\Delta_{\mathcal{F}}=D^{-\frac{1}{2}}L_{\mathcal{F}}D^{-\frac{1}{2}} \tag{10}\]
With \(D\) block-diagonal of \(L_{\mathcal{F}}\).
### Neural sheaf diffusion
Given a graph \(G=(V,E)\) where each node of the graph \(v\in V\) has a \(d\)-dimensional feature vector \(x_{\mathbf{o}}\in\mathcal{F}(v)\) we construct an \(nd\)-dimensional vector \(x\in C^{0}(G,\mathcal{F})\) by column-stacking the individual vectors \(x_{\mathbf{o}}\). We produce the feature matrix \(\mathbf{X}\in\mathbb{R}^{(nd)\times f}\) where the columns of \(\mathbf{X}\) are vectors in \(C^{0}(G,\mathcal{F})\).
Sheaf diffusion is a process on \((G,\mathcal{F})\) governed by the following differential equation:
\[\mathbf{X}(0)=\mathbf{X},\ \ \ \mathbf{X}(t)=-\Delta_{\mathcal{F}}\mathbf{X}(t) \tag{11}\]
which is discretised via the explicit Euler scheme with unit step size:
\[\mathbf{X}(t+1)=\mathbf{X}(t)-\Delta_{\mathcal{F}}\mathbf{X}(t)=(\mathbf{I}_{ nd}-\Delta_{\mathcal{F}})\mathbf{X}(t) \tag{12}\]
In the model used by (Bang et al., 2017) the previous equation is discretised in the following way:
\[\mathbf{X}(t+1)=\mathbf{X}(t)-\sigma(\Delta_{\mathcal{F}(t)}(\mathbf{I}_{ \mathbf{o}}\otimes\mathbf{W}_{1}^{t})\mathbf{X}_{t}\mathbf{W}_{2}^{t}) \tag{13}\]
With the sheaf \(\mathcal{F}(t)\) and the weights \(\mathbf{W}_{1}^{t}\in\mathcal{R}^{d\times d}\) and \(\mathbf{W}_{2}^{t}\in\mathcal{R}^{f\times f}\) time-dependent, meaning that the underlying geometry evolves.
## 4. Method
### Collaborative filtering
We consider the information that a generic user embedding would have at each layer of the GNN. The user nodes are the input embeddings provided to the model in the input Layer, as shown in Figure 2. After the input Layer, a new item embedding is generated and is passed to Layer 1. The user node embedding will then get updated with a new item embedding containing semantic information related to its connected users. Note that, during this layer, the nodes
learn not only from the embedding they obtained in the input Layer but also from this new embedding. In Layer 2 the previous item embedding is updated with a new one. In this way, we try to cluster users with the same item interests. As a result, the user node in the final layer will gain knowledge about the embeddings of users 2-hops away in the GNN.
Semantically, in terms of recommendations, we have made this user's node embedding more similar to other users who share the same item interests. The reason behind the choice of node embedding is straightforward: at the node level, an embedding vector is generated with each node in the graph. This embedding vector can hold the graph representation and structure. At each step, the user's node embedding is more similar to other users who share the same item interests. Essentially, nodes in close proximity should also have vectors in close proximity to each other.
One advantage of our approach is that the connection between the proposed embedding and the architecture is extremely easy. SNN takes as input an embedding vector with the modified representation of users and items and the size of the graph (sum of the number of users and items). Then all the information from the embedding is stored in the corresponding vector spaces. The complete process can be found in Figure 1.
#### 4.1.1. Loss function
A surrogate loss function is used to enable efficient gradient-based optimization and also to work in the best way with sheaves. Specifically, we use the Bayesian Personalized Ranking (BPR) loss as the surrogate. To understand BPR, we need to define the notion of positive and negative edges: positive edges are those that exist in the graph and negative edges are those that don't.
In our bipartite graph, we can define the score of the user \(u\) for the item \(v\) is:
\[f_{\theta}(u,v)=e_{u}^{T}e_{v} \tag{14}\]
Where \(e_{u}\) is the embedding related to the user \(u\) and \(e_{v}\) is the embedding related to the item \(v\). Consequently, we can define for the user \(u\) the set of all positive edges containing \(u\) as \(s(p)=f_{\theta}(u,v_{pos})\) and the set of all negative edges containing u as \(s(n)=f_{\theta}(u,v_{neg})\). The BPR is:
\[BPR(u)=\sum_{p,n}-ln(\sigma(s(p)-s(n)) \tag{15}\]
To efficiently estimate the BPR loss and optimize \(f_{\theta}\), we train the model by sampling mini-batches. For each mini-batch, we sample the set of users and for each user sample one positive item (the item from a positive edge containing the user in question) and one negative item.
### SheafNN and recommendation
The improvements in this work are due to the use of topology. Since SNN works using sheaves we need to use an update function based on simplicial complexes (Bordes and T
\[m_{B}^{t+1}(\sigma)=AGG_{\tau\in B(\sigma)}(M_{B}(h_{\sigma}^{t},h_{ \tau}^{t})) \tag{16}\] \[m_{\uparrow}^{t+1}(\sigma)=AGG_{\tau\in N_{\uparrow},\beta eC( \sigma,t)}(M_{\uparrow}(h_{\sigma}^{t},h_{\tau}^{t},h_{\beta}^{t})) \tag{17}\]
The update function is:
\[h_{\sigma}^{t+1}=\bigcup\left(h_{\sigma}^{t},m_{B}^{t}(\sigma),m_{\uparrow}^{t +1}(\sigma)\right) \tag{18}\]
\(\sigma,\tau\) and \(\delta\) are cells while \(B\) represents a boundary. The update function \(h\) receives as input two different types of messages \(m_{B}\) and \(m_{\uparrow}\).
Our network transforms a standard graph into a sheaf. An example of a sheaf can be found in Figure 3.
We consider the node \(V\) as the user \(V\) and the node \(U\) as the user \(U\). We work in the following way:
\(\mathcal{F}(U_{e})\) is the vector space containing all the opinions of \(V\) that we split into positive and negative opinions and the same is for \(\mathcal{F}(U_{u})\) and user U. Up to this moment the main difference is that the information about a certain user is stored in the corresponding vector space.
\(U_{e}\) is the edge containing all the items in common between the two users. The features of the item are modelled into the vector space \(\mathcal{F}(U_{e})\). Every iteration of the training updates these features for all the users. From the previous chapter, we also know that \(f_{\theta}(u,v)=e_{u}^{T}e_{e}\) is the score for the user \(u\). But with this representation, we have the user embedding into \(\mathcal{F}(U_{u})\) and the item embedding into \(\mathcal{F}(U_{e})\). As a result, the score can be simply found in the restriction maps \(\mathcal{F}_{u\in\mathcal{E}}\) and \(\mathcal{F}_{\sigma\in\mathcal{E}}\) and the more we train our network the higher the score. For this reason, we have chosen to use the BPR loss, in fact with this representation it is extremely simple to be computed.
### Link prediction
The goal of SNN is to learn the embeddings of each node and to use them to predict edges in the graph. But SNN computes node embeddings for all nodes in the graph, but what we want to do is make predictions on pairs of nodes. For this reason, it is created a module in pairs of node embeddings (i.e., an edge) that classifies if the edge connecting two drugs exists or not. This module is a simple neural network called Link Predictor.
The Link predictor (shown in Figure 4) takes the element-wise product of the real-valued embedding vector of \(2\) nodes (\(h_{i}\) and \(h_{j}\)) and computes the probability score of whether there exists a link between the \(2\) nodes through a multi-layer perceptron.
Also in this case it is created a node embedding. The creation of the embedding is of primary importance for the training. Since the task is different, SNN is used differently. Given two generic nodes \(U\) and \(V\), the vector space \(\mathcal{F}(U_{u})\) associated to node \(U\) contains information about the molecule \(U\) and the same for \(V\). The restriction maps \(\mathcal{F}_{u\mathcal{E}\mathcal{E}}\) and \(\mathcal{F}_{v\mathcal{E}\mathcal{E}}\) contain information about the interaction between \(U\) and \(V\). During the training at every iteration the vector space \(\mathcal{F}(U_{e})\) related to the edge \(e\) and the restriction maps are updated with new features about the corresponding molecules. Also in this case SNN takes as input simply the embedding vector computed in the previous step.
#### 4.3.1. Loss function
The objective is to maximize the probability of correct edges (positive predictions \(p\)) while minimizing the probability of incorrect edges (negative predictions \(n\)). The loss function is the following:
\[\mathcal{L}=-\mu(ln(p))+\mu(ln(1-n)) \tag{19}\]
Where \(\mu\) represents the mean.
## 5. Experiments
In this section, we test the performance of Sheaf Neural Networks on two different tasks: collaborative filtering and link prediction. For collaborative filtering, three different datasets are used: MovieLens 100k, MovieLens 1M and the Book-Crossing dataset. For link prediction, it is used the ogbl-ddi dataset.
### Datasets description
#### 5.1.1. Book-Crossing dataset
The Book-Crossing dataset (Song et al., 2016) is a collection of user ratings of books. It comes with both explicit ratings (1-10 stars) and implicit ratings (user interacted with the book). It is composed by 278858 members of Book-Crossing and 1157112 ratings, referring to 271379 distinct ISBNs.
#### 5.1.2. MovieLens
MovieLens 1M dataset contains around 1 million anonymous ratings of approximately 3900 movies by 6040 users, where each user rated at least 20 items.
MovieLens 100k dataset contains around 100k anonymous ratings of approximately 1700 movies by 1000 users, where each user rated at least 20 items. The ratings in MovieLens 1M and MovieLens 100K datasets are made on a 5-star scale, with 1-star increments. In both datasets, each user is described by demographic info (age, gender, occupation).
A good way to visualize the interactions in a recommender system is by using a bipartite graph with the users and items (movies in this case) as nodes and edges between them indicating user-item interactions. The graph will be bipartite because users can be interested in items, but items and users can't be interested in other items or users, respectively.
#### 5.1.3. ogbl-ddi
This dataset contains 4,267 nodes and 1,334,889 edges representing the drug-drug interaction network. In the ogbl-ddi dataset, each node represents an FDA-approved or experimental drug. Edges represent interactions between drugs and can be interpreted as a phenomenon where the joint effect of taking two drugs together is considerably different from the expected effect in which drugs act independently of each other. It is implemented a protein-target split, meaning that drug edges are split according to
Figure 3. Sheaf structure. It is possible to see the stalks associated with each node and the restriction maps.
what proteins those drugs target in the body. As a result, the test set consists of drugs that predominantly bind to different proteins from drugs in the train and validation sets. This means that drugs in the test set work differently in the body, and have a rather different biological mechanism of action than drugs in the train and validation sets.
### Competitors
We compare our model with various baselines and current state-of-the-art models including recently published neural architectures and we now present a brief summary of our competitors to provide a better understanding of these models.
#### 5.2.1. Collaborative filtering
* CoFM (Krishnan et al., 2017) jointly trains FM and TransE by sharing parameters or regularization of aligned items and entities.
* MVAE (Krishnan et al., 2017) is an extension of variational autoencoders (VAEs) to collaborative filtering for implicit feedback.
* SVAE (Savaghi et al., 2018) is an improvement of MVAE using sequential VAEs based on a recurrent neural network.
* LinUCB (Liu et al., 2019) is a multi-armed bandit approach which recommends items to the user based on the contextual information about the user and items.
* SVD (Krishnan et al., 2017) is a popular algorithm utilizing Singular Value Decomposition for the process of recommendation.
* DeepMF (Wang et al., 2018) is a state-of-the-art neural network architecture based Matrix Factorization Method for recommendation.
* MDP (Krishnan et al., 2017) works as a reinforcement learning agent modeling collaborative filtering as a Markov Decision Process (MDP).
* LibFM (Liu et al., 2019) is a widely used feature-based factorization model for CTR prediction.
* RippleNet (Wang et al., 2018) is a memory-network-like approach that propagates users' preferences on the KG for recommendation.
* KGNN-LS (Wang et al., 2018) transforms the graph into a weighted graph and uses a GNN to compute item embeddings.
#### 5.2.2. Link prediction
* Node2Vec (Chen et al., 2017) learns a mapping of nodes to a low-dimensional space of features that maximizes the likelihood of preserving network neighbourhoods of nodes.
* SEAL (Wang et al., 2018) learns a function mapping the subgraph patterns to link existence.
* GCN (Glorot et al., 2017) is based on an efficient variant of convolutional neural networks which operate directly on graphs.
* GraphSAGE (Chen et al., 2017) leverages node feature information to efficiently generate node embeddings for unseen data.
### Metrics
#### 5.3.1. Collaborative filtering
We use three evaluation metrics that have been widely used in previous work:
* Precision@N: It is the fraction of the items recommended that are relevant to the user. We compute the mean of all the users as final precision;
* Recall@N: It is the proportion of items relevant to the user that have been successfully recommended. We compute the mean of all users as final recall.
* F1-score@N: It is the harmonic mean of precision at rank N and recall at rank N.
#### 5.3.2. Link prediction
The performance is evaluated by Hits@20: each true drug interaction is ranked among a set of approximately
\begin{table}
\begin{tabular}{c c c} \hline \hline & MovieLens 100k & MovieLens 1M \\ \hline Number of users & 943 & 6040 \\ Number of items & 1682 & 3952 \\ Number of ratings & 100000 & 1000029 \\ Number of all genres & 19 & 18 \\ Average number of genres & 1.7 & 1.6 \\ \hline \hline \end{tabular}
\end{table}
Table 1. Main stats about MovieLens 100k and MovieLens 1M.
Figure 4. Link predictor architecture. It takes as input \(h_{i}\odot h_{j}\) and outputs the probability of a link between node \(i\) and node \(j\).
100,000 randomly-sampled negative drug interactions, and count the ratio of positive edges that are ranked at 20-place or above.
## 6. Results
All the experiments were performed on a single NVIDIA RTX A6000 with 10752 CUDA cores and 48 GB RAM. In all the experiments different values of seed are used to see how the results of the models change with the split.
### ogbl-ddi
In this section, we test the performance of SNN on the ogbl-ddi dataset. During the comparison, the learning rate and the weight decay are fixed and equal to 0.003 and 0.0005, respectively. The model is trained with Adam optimizer, and 300 epochs are performed, completing the training phase in about 18 hours. Training our model takes quite a long time due to the inherent complex structure of SNNs, and the operations performed make computing the backpropagation algorithm less time efficient than other architectures.
It is important to notice that the variance of our results, compared to our competitors, decreases consistently. Our network is less affected by variations in the parameters than the other architectures making our method stable and, therefore, fitter to be used in different problems.
We run statistical tests on the results obtained by our models on this task to assess the significance of the differences. We used the student's unpaired t-test between our predictions and the predictions of our competitors with independent and identically distributed samples. By selecting \(p=0.05\) we demonstrated that our results are statistically significant if we compare them against GraphSage, GCN, and Node2Vec.
### MovieLens 1M
In this section, we test the performance of SNN on MovieLens 1M. We used a 90-10 train-test split. 90% of the samples are used for training and 10% for testing. This is the most common example of a split for this dataset. During the comparison, the learning rate and the weight decay are fixed and equal to 0.005 and 0.0001. The model is trained with a computational time of 210 minutes. The selected size for the embedding vector is 64; consequently, the input size of SNN is 64.
We use as a loss function the BPR loss, as explained in chapter 4. For the sake of completeness, we also experimented with different loss functions. In recommender systems, the most common example of a loss function is the Root Mean Squared Error (RMSE) loss. We also tested our approach using this loss function, but our experimental results show that the F1-Score was lower. The main advantage of BPR over RMSE is on the computational time. Table 3 shows that BPR is up to 50% faster than RMSE. We also tested Binary Cross-Entropy (BCE) loss. In this case, the efficiency of the method was comparable, but the performance in terms of F1-Score was much worse. Thus, we also did not consider this loss when training our models.
The choice of F1-Score@10 and F1-Score@100 as evaluation metrics is not random. In fact, by choosing \(N=10\) and \(N=100\) we are working with tho different sizes for the sets of relevant items for the users. The most common recommender systems based on graphs have a high F1-Score@N for small values of N. In our case also with high values of N the F1-Score is really high. In Figure 5 it is possible to compare our result with other state-of-the-art systems and we demonstrate that our solution is able to achieve good performance also with high values of \(N\). In this Image was not possible to represent the values of F1-Score@N for values of \(N>50\) because the other approaches obtained very bad results. Finally, in Table 4 we can see that SNN outperforms all the baselines in terms of F1-Score and Recall.
In Figure 6 we have tested the value of F1 when increasing the number of returned recommendations, \(K\). We can observe that F1-Score starts decreasing for \(K>60\). This is different from our competitors, where this value ranges between 20 and 40. This experiment shows that this architecture can achieve good results also when we produce a high number of recommended, and potentially relevant for the users, items. For example, consider MovieLens. The MovieLens dataset contains movie ratings, therefore, the higher the number of movies that we are able to recommend the more satisfied the user.
### MovieLens 100K
In this section, we test the performance of SNN on MovieLens 100k. We used an 80-20 train-test split. 80% of the samples are used for training and 20% for testing. The value of the hyperparameters is different from the previous experiment: the learning rate is fixed at 0.001 while the weight decay is 0.0002. The model is trained with
\begin{table}
\begin{tabular}{c c c} \hline \hline Model & Validation Hits@20 & Test Hits@20 \\ \hline Node2Vec & 0.329\(\pm\)0.012 & 0.233\(\pm\)0.021 \\ SEAL & 0.285\(\pm\)0.027 & 0.306\(\pm\)0.039 \\ GCN\({}^{\dagger}\) & 0.555\(\pm\)0.021 & 0.370\(\pm\)0.051 \\ GraphSAGE \({}^{\dagger}\) & 0.626\(\pm\)0.037 & 0.539\(\pm\)0.047 \\
**SNN (our)**\({}^{\dagger}\) & **0.632\(\pm\)0.036** & **0.555\(\pm\)0.044** \\ \hline \hline \end{tabular}
\end{table}
Table 2. Results of the evaluation using the ogbl-ddi dataset. SNN has a 32% improvement on the test hits with respect to the baseline and a 1.6% improvement with respect to the best model. \(\dagger\) means statistically significantly (Student’s unpaired t-test, p \(<\) 0.05)
\begin{table}
\begin{tabular}{c c c c} \hline \hline Loss & \#Layers & F1-Score@10 & Time \\ \hline RMSE & 2 & 0.112 & 283 \\ RMSE & 5 & 0.148 & 371 \\ BCE & 2 & 0.087 & 198 \\ BCE & 5 & 0.101 & 262 \\ BPR & 2 & 0.163 & 163 \\ BPR & 5 & 0.192 & 210 \\ \hline \hline \end{tabular}
\end{table}
Table 3. Performance of the same model using different loss functions and numbers of layers. The computational time is in minutes, \(\downarrow\) is better.
Adam optimizer and 50 epochs are performed with a computational time of 30 minutes. It is possible to see how our solution outperforms all the baselines in terms of F1-Score. The results can be seen in Table 5.
One of the advantages of SNN is the possibility of preventing over-smoothing. Deeply stacking the number of layers does not decrease the performance. In a lot of GNNs the features become progressively smoother with increased depth (Krizhevsky et al., 2017). In our case, the best results are obtained using 5 layers, as shown in Figure 7.
### Book-Crossing
In this section, we test the performance of SNN on Book-Crossing. During the comparison, the learning rate and the weight decay are fixed and equal to 0.001 and 0.0005. The model is trained for 70 epochs with a computational time of 251 minutes using as loss function the BPR loss. The computational time is a bit higher with respect to the previous experiments because the dataset is bigger and also contains a lot of side information, so the processing time is higher. In this experiment, we obtained better results by setting the selected size for the embedding vector to 32. As we can see in Table 6 we outperform the state-of-the-art results both on Recall@10 and Recall@100.
## 7. Conclusions and Future Work
Associating each node and each edge with a vector space is an effective strategy to sequence recommendation. To prove this, we used our architecture SNN, and the experimental evaluation highlights the capability of SNN to outperform state-of-the-art models on two different tasks consistently.
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline Model & Precision@10 & Recall@10 & F1-Score@10 & Precision@100 & Recall@100 & F1-Score@100 \\ \hline \hline MVAE\({}^{\dagger}\) & 0.090 & 0.091 & 0.091 & 0.054 & 0.414 & 0.096 \\ SVAE\({}^{\dagger}\) & 0.144 & 0.125 & 0.134 & 0.069 & 0.494 & 0.121 \\ CoFM\({}^{\dagger}\) & **0.321** & 0.130 & 0.178 & 0.354 & 0.135 & 0.189 \\
**SNN (our)** & 0.284 & **0.145** & **0.192** & 0.122 & **0.520** & **0.198** \\ \hline \hline \end{tabular}
\end{table}
Table 4. Results of the evaluation using the MovieLens 1M dataset. SNN has a 5.4% improvement on F1@10 with respect to the baseline and a 0.7% improvement with respect to the best model.
Figure 5. F1-Score values on MovieLens 1M compared with state-of-the-art solutions. The value of F1-Score for CAKR (Krizhevsky et al., 2017), RippleNet (Zhu et al., 2017) and Ripp-MKR (Ripp et al., 2018) goes down extremely fast. The value of the F1-Score of our model goes down less fast.
Figure 6. The value of F1-Score of our solution starts decreasing with a value of K between 60 and 70.
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline Model & Precision@10 & Recall@10 & F1-Score@10 & Precision@20 & Recall@20 & F1-Score@20 \\ \hline LinUCB\({}^{\dagger}\) & 0.321 & 0.135 & 0.192 & 0.286 & 0.203 & 0.238 \\ SVD\({}^{\dagger}\) & 0.343 & 0.163 & 0.222 & 0.282 & 0.245 & 0.272 \\ DeepMF\({}^{\dagger}\) & 0.344 & 0.160 & 0.219 & 0.314 & 0.244 & 0.262 \\ MDP\({}^{\dagger}\) & **0.357** & 0.168 & 0.228 & **0.313** & 0.251 & 0.278 \\
**SNN (our)** & 0.210 & **0.287** & **0.243** & 0.265 & **0.309** & **0.285** \\ \hline \hline \end{tabular}
\end{table}
Table 5. Results of the evaluation using the MovieLens 100k dataset. SNN has a 5.1% improvement on F1@10 with respect to the baseline and a 1.5% improvement with respect to the best model.
\(\dagger\) is used when the results are taken from the original paper.
These results finally prove the applicability of algebraic topology to machine learning tasks. In the future, we are interested in using this architecture in new studies. Thanks to its topological structure, we think this network could obtain good results on different applications storing the side information of the nodes in the corresponding stalks. A possible future direction could be the Next Point-Of-Interest recommendation to provide users with where to go and how to plan the day based on previous visits as well as current status or feature selection.
|
2302.11556 | Equivariant Polynomials for Graph Neural Networks | Graph Neural Networks (GNN) are inherently limited in their expressive power.
Recent seminal works (Xu et al., 2019; Morris et al., 2019b) introduced the
Weisfeiler-Lehman (WL) hierarchy as a measure of expressive power. Although
this hierarchy has propelled significant advances in GNN analysis and
architecture developments, it suffers from several significant limitations.
These include a complex definition that lacks direct guidance for model
improvement and a WL hierarchy that is too coarse to study current GNNs. This
paper introduces an alternative expressive power hierarchy based on the ability
of GNNs to calculate equivariant polynomials of a certain degree. As a first
step, we provide a full characterization of all equivariant graph polynomials
by introducing a concrete basis, significantly generalizing previous results.
Each basis element corresponds to a specific multi-graph, and its computation
over some graph data input corresponds to a tensor contraction problem. Second,
we propose algorithmic tools for evaluating the expressiveness of GNNs using
tensor contraction sequences, and calculate the expressive power of popular
GNNs. Finally, we enhance the expressivity of common GNN architectures by
adding polynomial features or additional operations / aggregations inspired by
our theory. These enhanced GNNs demonstrate state-of-the-art results in
experiments across multiple graph learning benchmarks. | Omri Puny, Derek Lim, Bobak T. Kiani, Haggai Maron, Yaron Lipman | 2023-02-22T18:53:38Z | http://arxiv.org/abs/2302.11556v2 | # Equivariant Polynomials for Graph Neural Networks
###### Abstract
Graph Neural Networks (GNN) are inherently limited in their expressive power. Recent seminal works (Xu et al., 2019; Morris et al., 2019) introduced the Weisfeiler-Lehman (WL) hierarchy as a measure of expressive power. Although this hierarchy has propelled significant advances in GNN analysis and architecture developments, it suffers from several significant limitations. These include a complex definition that lacks direct guidance for model improvement and a WL hierarchy that is too coarse to study current GNNs. This paper introduces an alternative expressive power hierarchy based on the ability of GNNs to calculate equivariant polynomials of a certain degree. As a first step, we provide a full characterization of all equivariant graph polynomials by introducing a concrete basis, significantly generalizing previous results. Each basis element corresponds to a specific multi-graph, and its computation over some graph data input corresponds to a tensor contraction problem. Second, we propose algorithmic tools for evaluating the expressiveness of GNNs using tensor contraction sequences, and calculate the expressive power of popular GNNs. Finally, we enhance the expressivity of common GNN architectures by adding polynomial features or additional operations / aggregations inspired by our theory. These enhanced GNNs demonstrate state-of-the-art results in experiments across multiple graph learning benchmarks.
Machine Learning, Graph Neural Networks, Graph Neural Networks
## 1 Introduction
In recent years, graph neural networks (GNNs) have become one of the most popular and extensively studied classes of machine learning models for processing graph-structured data. However, one of the most significant limitations of these architectures is their limited expressive power. In recent years, the Weisfeiler-Lehman (WL) hierarchy has been used to measure the expressive power of GNNs (Morris et al., 2019; Xu et al., 2019; Morris et al., 2021). The introduction of the WL hierarchy marked an extremely significant step in the graph learning field, as researchers were able to evaluate and compare the expressive power of their architectures, and used higher-order WL tests to motivate the development of new, more powerful architectures.
The WL hierarchy, however, is not an optimal choice for either purpose. First, its definition is rather complex and not intuitive, particularly for \(k\geq 3\). One implication is that it is often difficult to analyze WL expressiveness of a particular architecture class. As a result, many models lack a theoretical understanding of their expressive power. A second implication is that WL does not provide practical guidance in the search for more expressive architecture. Lastly, as was noted in recent works (Morris et al., 2022; 2019), the WL test appears to be too coarse to be used to evaluate the expressive power of current graph models. As an example, many architectures (e.g., (Frasca et al., 2022)) are strictly more powerful than 2-WL and bounded by 3-WL, and there is no clear way to compare them.
The goal of this paper is to offer an alternative expressive power hierarchy, which we call _polynomial expressiveness_ that mitigates the limitations of the WL hierarchy. Our proposed hierarchy relies on the concept of graph polynomials, which are, for graphs with \(n\) nodes, polynomial functions \(P:\mathbb{R}^{n^{2}}\rightarrow\mathbb{R}^{n^{2}}\) that are also permutation equivariant -- that is, well defined on graph data. The polynomial expressiveness hierarchy is based on a natural and simple idea -- the ability of GNNs to compute or approximate equivariant graph polynomials up to a certain degree.
Figure 1: Example of two basis elements of equivariant graph polynomials: node-valued (top), and edge-valued (bottom). Basis elements \(P_{H}\) can be described by tensor contraction networks \(H\) (left), corresponding to a matching einsum expression.
This paper provides a number of theoretical and algorithmic contributions aimed at defining the polynomial hierarchy, providing tools to analyze the polynomial expressive power of GNNs, and demonstrating how this analysis can suggest practical improvements in existing models that give state-of-the-art performance in GNN benchmarks.
First, while some polynomial functions were used in GNNs in the past (Maron et al., 2019; Chen et al., 2019; Azizian and Lelarge, 2021), a complete characterization of the space of polynomials is lacking. In this paper, we provide the first characterization of graph polynomials with arbitrary degrees. In particular, we propose a basis for this vector space of polynomials, where each basis polynomial \(P_{H}\) of degree \(d\) corresponds to a specific multi-graph \(H\) with \(d\) edges. This characterization provides a significant generalization of known results, such as the basis of constant and linear equivariant functions on graphs (Maron et al., 2018). Furthermore, this graphical representation \(H\) can be viewed as a type of a tensor network, which provides a concrete way to compute those polynomials by performing a series of tensor (node) contractions. This is illustrated in Figure 1.
As a second contribution, we propose tools for measuring polynomial expressiveness of graph models and placing them in the hierarchy. This is accomplished by analyzing tensor networks using standard contraction operators, similar to those found in Einstein summation (einsum) algorithms. Using these, we analyze two popular graph models: Message Passing Neural Networks (MPNNs) and Provably Powerful Graph Networks (PPGNs). This is done by first studying the polynomial expressive power of prototypical versions of these algorithms, which we define.
Our third contribution demonstrates how to improve MPNN and PPGN by using the polynomial hierarchy. Specifically, we identify polynomial basis elements that are not computable by existing graph architectures and add those polynomial basis elements to the model as feature layers. Also, we add two simple operations to the PPGN architecture (matrix transpose and diagonal / off-diagonal MLPs) to achieve the power of a Prototypical edge-based graph model. After precomputing the polynomial features, we achieve strictly better than \(3\)-WL expressive power while only requiring \(O(n^{2})\) memory -- to the best of our knowledge this is the first equivariant model to achieve this. We demonstrate that these additions result in state-of-the-art performance across a wide variety of datasets.
## 2 Equivariant graph polynomials
We represent a graph with \(n\) nodes as a matrix \(\textbf{X}\in\mathbb{R}^{n^{2}}\), where edge values are stored at off-diagonal entries, \(\textbf{X}_{ij}\), \(i\neq j\), \(i,j\in[n]=\{1,2,\ldots,n\}\), and node values are stored at diagonal entries \(\textbf{X}_{ii}\), \(i\in[n]\).
An _equivariant graph polynomial_ is a matrix polynomial map \(P:\mathbb{R}^{n^{2}}\rightarrow\mathbb{R}^{n^{2}}\) that is also equivariant to node permutations. More precisely, \(P\) is a polynomial map if each of its entries, \(P(\textbf{X})_{ij}\), \(i,j\in[n]\), is a polynomial in the inputs \(\textbf{X}_{rs}\), \(r,s\in[n]\). \(P\) is equivariant if it satisfies
\[P(g\cdot\textbf{X})=g\cdot P(\textbf{X}), \tag{1}\]
for all permutations \(g\in S_{n}\), where \(S_{n}\) denotes the permutation group on \([n]\), and \(g\) acts on a matrix **Y** as usual by
\[(g\cdot\textbf{Y})_{ij}=\textbf{Y}_{g^{-1}(i),g^{-1}(j)}. \tag{2}\]
### \(P_{h}\): Basis for equivariant graph polynomials
We next provide a full characterization of equivariant graph polynomials by enumerating a particular basis, denoted \(P_{H}\). In later sections we use this basis to analyze expressive properties of graph models and improve expressiveness of existing GNNs.
The basis elements \(P_{H}\) of degree \(d\) equivariant graph polynomials are enumerated from non-isomorphic _directed multigraphs_, \(H=(V,E,(a,b))\), where \(V=[m]\) is the node set; \(E=\{(r_{1},s_{1}),\ldots,(r_{d},s_{d})\}\), \(r_{i},s_{i}\in[m]\), the edge set, where parallel edges and self-loops are allowed; and \(a,b\in V\) is a pair of not necessarily distinct nodes representing the output dimension. The pair \((a,b)\) will be marked in our graphical notation as a red edge.
Defining the basis \(P_{H}\) will be facilitated by the use of Einstein summation operator defined next. Note that the multi-graph \(H\) can be represented as the following string that encodes both its list of edges and the single red edge: \(H\cong\ {}^{\prime}r_{1}s_{1},\ldots,r_{d}s_{d}\to ab^{\prime}\). The einsum operator is:
\[\texttt{einsum}(H,\textbf{X}^{1},\ldots,\textbf{X}^{d})_{i_{a}, i_{b}}=\] \[\texttt{einsum}(r_{1}s_{1},\ldots,r_{d}s_{d}\to ab,\textbf{X}^{1}, \ldots,\textbf{X}^{d})_{i_{a},i_{b}}=\] \[\sum_{\begin{subarray}{c}j_{1},\ldots,j_{m}\in[n]\\ j_{a}=i_{a},j_{b}=i_{b}\end{subarray}}\textbf{X}^{1}_{j_{r_{1}},j_{s_{1}}} \cdots\textbf{X}^{d}_{j_{r_{d}},j_{s_{d}}}\]
Figure 2 shows how matrix multiplication can be defined using a corresponding multigraph \(H\) and Einstein summation. Such multigraphs span the basis of equivariant polynomials:
Figure 2: Example of matrix multiplication, \(\mathbf{X}\mathbf{Y}\). Computation defined by a multigraph \(H\) and Einstein summation.
**Theorem 2.1** (Graph equivariant basis).: _A basis for all equivariant graph polynomials \(P:\mathbb{R}^{n^{2}}\rightarrow\mathbb{R}^{n^{2}}\) of degree \(\leq d\) is enumerated by directed multigraphs \(H=(V,E,(a,b))\), where \(|V|\leq\min\left\{n,2+2d\right\}\), \(|E|\leq d\), and \(V\backslash\left\{a,b\right\}\) does not contain isolated nodes. The polynomial basis elements corresponding to \(H\) are_
\[P_{H}(\textbf{X})=\texttt{einsum}(H,\overbrace{\textbf{X},\ldots,\textbf{X} }^{d\texttt{times}}). \tag{3}\]
An explicit formula for \(P_{H}\) can be achieved by plugging in the definition of einsum and equation 3:
\[P_{H}(\textbf{X})_{i_{a},i_{b}}=\sum_{\begin{subarray}{c}j_{1},\ldots,j_{m} \in[n]\\ j_{a}=i_{a},j_{b}=i_{b}\end{subarray}}\prod_{(r,s)\in E}\textbf{X}_{j_{r},j_{s }}. \tag{4}\]
Figure 1 depicts an example of graph equivariant basis elements \(P_{H}\) corresponding to two particular multigraphs \(H\). Note that a repeated pair \((a,a)\) in \(H\) leads to a _node-valued_ equivariant polynomial, while a distinct pair \((a,b)\), \(a\neq b\) leads to an _edge-valued_ equivariant polynomial. Furthermore, we make the convention that if \(E\) is empty then \(\prod_{(r,s)\in E}\textbf{X}_{i_{r},i_{s}}=1\). The number of such polynomials increases exponentially with the degree of the polynomial; the first few counts of degree \(d\) equivariant graph polynomials are 2 (\(d=0\)), 15 (\(d=1\)), 117 (\(d=2\)), 877 (\(d=3\)), 6719 (\(d=4\)),...Further details and proofs of these sequences are provided in Appendix I. The full proof of Theorem 2.1 is provided in Appendix B.
Proof idea for Theorem 2.1.: Since the set of monomials form a basis of all (not necessarily invariant) polynomials \(P:\mathbb{R}^{n^{2}}\rightarrow\mathbb{R}^{n^{2}}\), we can project them onto the space of equivariant polynomials via the symmetrization (Reynolds) operator to form a basis for the equivariant polynomials. This projection operation will group the monomials into orbits that form the equivariant basis.
To find these orbits, the basic idea is to consider the monomials in the input variables \(\{\textbf{X}_{i,j}:i,j\in[n]\}\) and an additional variable \(\{\delta_{i,j}:i,j\in[n]\}\) to denote the possible output entries of the equivariant map. Any given monomial \(M(\textbf{X},\delta^{a,b})\) takes the form
\[M(\textbf{X},\delta^{a,b})_{i,j}=\delta^{a,b}_{i,j}\prod_{r,s=1}^{n}\textbf{ X}_{r,s}^{\textbf{A}_{r,s}}, \tag{5}\]
where \(\textbf{A}\in\mathbb{N}_{0}^{n^{2}}\), \(\mathbb{N}_{0}=\{0,1,\ldots\}\) is the matrix of powers, and \(\delta^{a,b}_{i,j}=1\) if \(a=i\), \(b=j\), and \(\delta^{a,b}_{i,j}=0\) otherwise. A natural way to encode these monomials is with _labeled_ multi-graphs \(H=(V,E,(a,b))\), where \(V=[n]\), \(E\) is defined by the adjacency matrix **A**, and \((a,b)\) is a special (red) edge. We therefore denote \(M=M_{H}\).
These monomials can be projected onto equivariant polynomials via the Reynolds operator that takes the form,
\[\begin{split} Q_{H}(\textbf{X})&=\sum_{g\in S_{n}}g \cdot M_{H}(g^{-1}\cdot\textbf{X},\delta^{g(a),g(b)})\\ &=\sum_{g\in S_{n}}M_{g\cdot H}(\textbf{X},\delta^{a,b}),\end{split} \tag{6}\]
where the action of \(g\in S_{n}\) on the multi-graph \(H\) is defined (rather naturally) as node relabeling of \(H\) using the permutation \(g\).
From the above, we note: (i) \(Q_{H}\) sums all monomials with multi-graphs in the orbit of \(H\), namely \([H]=\{g\cdot H|g\in S_{n}\}\). This shows that, in contrast to \(M_{H}\), \(Q_{H}\) is represented by an _unlabeled_ multi-graph \(H\) and enumerated by _non-isomorphic_ multi-graphs \(H\). (ii) Since the symmetrization is a projection operator, any equivariant polynomial is spanned by \(Q_{H}\). (iii) Since each \(Q_{H}\) is a sum of \(M_{H}\) belonging to a different orbit, and since orbits are disjoint, the set \(\{Q_{H}\}\) for non-isomorphic \(H\) is linearly independent. These three points establish that \(\{Q_{H}\}\) for non-isomorphic multi-graphs \(H\) is a basis of equivariant graph polynomials.
Noting that \(Q_{H}(\textbf{X})_{ij}\) includes only terms for which \(\delta^{g(a),g(b)}=\delta^{i,j}\), the explicit form below can be derived:
\[Q_{H}(\textbf{X})_{i_{a},i_{b}}=\sum_{\begin{subarray}{c}j_{1}\neq\ldots, \neq j_{m}\in[n]\\ j_{a}=i_{a},j_{b}=i_{b}\end{subarray}}\prod_{(r,s)\in E}\textbf{X}_{j_{r},j_{s }}. \tag{7}\]
\(Q_{H}\) is similar to \(P_{H}\) in equation 4, except we only sum over non-repeated indices. The proof in Appendix B shows that \(P_{H}\) is also a basis for such equivariant polynomials.
**Example: linear basis.** Employing Theorem 2.1 for the \(d=0,1\) case reproduces the graph equivariant constant and linear functions from Maron et al. (2018). Figure 3 depicts the graphical enumeration of the 2 constant and 15 linear basis elements.
**Simple graphs.** It is often the case that the input data **X** is restricted to some subdomain of \(\mathbb{R}^{n^{2}}\), e.g., symmetric \(0/1\) matrices with diagonal entries set to zero correspond to simple graph data. In such cases, polynomials \(P_{H}\) that correspond to different multi-graphs \(H\) can coincide, resulting in a smaller basis. For simple graph data **X**, existence of self loops in \(H\) would result in \(P_{H}(\textbf{X})=0\), parallel edges in
Figure 4: Simple \(H\) corresponding to simple graph data.
Figure 3: Basis of equivariant constant (left of bold line) and linear (right of bold line) graph polynomials.
\(H\) can be replaced with single edges without changing the value of \(P_{H}(\textbf{X})\), and since the direction of black edges in \(H\) do not change the value of \(P_{H}(\textbf{X})\) we can consider only _undirected_ multi-graphs \(H\). That is, for simple graph data it is enough to consider simple graphs \(H\) (ignoring the red edge). Figure 4 shows two examples of \(H\) for simple graph data.
**Computing \(P_{H}(\textbf{X})\) with tensor contractions.** A useful observation for the graph model analysis performed later is that computing \(P_{H}(\textbf{X})\) is equivalent to a tensor contraction guided by \(H\). Similarly to \(\mathtt{einsum}\), computing \(P_{H}(\textbf{X})\) can be done iteratively in multiple ways by finding a sequence of contraction paths for \(H\) where we start with each edge of \(H\) endowed with **X** and our end goal is to have a single black edge aligned with the red edge. Figure 5 provides an example of computing a 4th degree polynomial through a sequence of 3 tensor contractions. In gray we indicate nodes that are contracted, namely, their index is summed in the \(\mathtt{einsum}\).
### Generalizations and discussion
**Invariant graph polynomials.** This approach also gives a basis for the invariant polynomials \(P:\mathbb{R}^{n^{2}}\rightarrow\mathbb{R}\). In this case, we let \(H\) be a directed multigraph without a red edge, and define \(P_{H}(\textbf{X})=\sum_{j_{1},\ldots,j_{m}\in[n]}\prod_{r,s\in E(H)}\textbf{ X}_{j_{r},j_{s}}\). Computing \(P_{H}\) then corresponds to contracting \(H\) to the trivial graph (with no nodes or edges). Our equivariant basis is a generalization of previous work, which used invariant polynomials analogous to \(P_{H}\) or the alternative basis \(Q_{H}\) to study properties of graphs (Thiery, 2000; Lovasz, 2012).
**Subgraph counting.** The previous work on invariant polynomials mentioned above as well as our proof of Theorem 2.1 suggest \(Q_{H}\) (see equation 7) as another basis of equivariant graph polynomials. In Appendix F, we show that when applied to binary input \(\textbf{X}\in\{0,1\}^{n\times n}\), \(Q_{H}\) performs subgraph counting; essentially, \(Q_{H}(\textbf{X})_{i_{a},i_{b}}\) is proportional to the number of subgraphs of **X** isomorphic to \(H\) such that \(i_{a}\) is mapped to \(a\) and \(i_{b}\) is mapped to \(b\). This \(Q_{H}\) basis is interpretable, but does not lend itself to efficient vectorized computation or the tensor contraction perspective that the \(P_{H}\) basis has.
**Equivariant polynomials for attributed graphs.** One can extend the polynomials discussed here to cover equivariant polynomials defined over _attributed graphs_ (i.e., graphs with \(\mathbb{R}^{f}\) features attached to nodes and/or edges), \(P:\mathbb{R}^{n^{2}\times f}\rightarrow\mathbb{R}^{n^{2}}\). A similar basis to \(P_{H}\) can be used in this case as described in Appendix E.
## 3 Expressive power of graph models
In this section we evaluate the expressive power of equivariant graph models from the new, yet natural hierarchy arising from equivariant graph polynomials. By graph model, \(\mathcal{F}=\{F\}\), we mean any collection of equivariant functions \(F:\mathbb{R}^{n^{2}}\rightarrow\mathbb{R}^{n^{k}}\), where \(k=1\) corresponds to a family of node-valued functions, \(F(\textbf{X})\in\mathbb{R}^{n}\), and \(k=2\) to node and edge-valued functions, \(F(\textbf{X})\in\mathbb{R}^{n^{2}}\). For expositional simplicity we focus on graph data **X** representing simple graphs, but note that the general graph data case can be analysed using similar methods. We will use two notions of polynomial expressiveness: exact and approximate. The exact case is used for analyzing Prototypical graph models, whereas the approximate case is used for analyzing practical graph models.
**Definition 3.1**.: A graph model \(\mathcal{F}\) is \(d\) node/edge polynomial _exact_ if it can compute all the degree \(d\) polynomial basis elements \(P_{H}(\textbf{X})\) for every simple graph **X**.
**Definition 3.2**.: A graph model \(\mathcal{F}\) is \(d\) node/edge polynomial _expressive_ if for arbitrary \(\epsilon>0\) and degree \(d\) polynomial basis element \(P_{H}(\textbf{X})\) there exists an \(F\in\mathcal{F}\) such that \(\max_{\textbf{X}\text{ simple}}|F(\textbf{X})-P(\textbf{X})|<\epsilon\).
As a primary application of the equivariant graph basis \(P_{H}\), we develop tools here for analyzing the polynomial expressive power of graph models \(\mathcal{F}\). We define _Prototypical_ graph models which provide a structure to analyze or improve existing popular GNNs such as MPNN (Gilmer et al., 2017) and PPGN (Maron et al., 2019).
### Prototypical graph models
We consider graph computation models, \(\mathcal{F}_{\mathcal{B}}\), that are finite sequences of tensor contractions taken from a bank of primitive contractions \(\mathcal{B}\).
\[\mathcal{F}_{\mathcal{B}}=\left\{C_{i_{1}}C_{i_{2}}\cdots C_{i_{ \ell}}\ |C_{i_{j}}\in\mathcal{B}\right\}, \tag{8}\]
where the bank \(\mathcal{B}=\{C_{1},\ldots,C_{k}\}\) consists of multi-graphs \(C_{i}=(V_{i},E_{i},(a_{i},b_{i}))\), each representing a different primitive tensor contraction. A model \(\mathcal{F}_{\mathcal{B}}\) can compute a polynomial \(P_{H}(\textbf{X})=\mathtt{einsum}(H,\textbf{X},\ldots,\textbf{X})\) if it can contract \(H\) to the red edge by applying a finite sequence of contractions from its bank. If there exists such a sequence then \(P_{H}\) is deemed computable by \(\mathcal{F}_{\mathcal{B}}\), otherwise it is not computable by \(\mathcal{F}_{\mathcal{B}}\). For example, the model with the bank presented in Figure 7 can compute \(P_{H}\) in Figure 5; removing any element from this model, will make \(P_{H}(\textbf{X})\) non-computable. We recap:
**Definition 3.3**.: The polynomial \(P_{H}\) is _computable by \(\mathcal{F}\)_ iff there exists a sequence of tensor contractions from \(\mathcal{F}\) that computes \(P_{H}(\textbf{X})=\mathtt{einsum}(H,\textbf{X},\ldots,\textbf{X})\).
Figure 7: A bank \(\mathcal{B}\) of a model \(\mathcal{F}_{\mathcal{B}}\) that can compute the example in Figure 5.
We henceforth focus on two Prototypical models: the node-based model \(\mathcal{F}_{n}\) and edge-based model \(\mathcal{F}_{e}\). Their respective contraction banks are depicted in Figure 6, each motivated by the desire to achieve polynomial exactness (see Definition 3.1) and contract multi-graphs \(H\) where a member of the bank can always be used to contract nodes with up to \(N\) neighbors. Taking \(N=1\) results in the node-based bank in Figure 6 (left), and \(N=2\) in the edge-based bank in Figure 6 (right). These choices are not unique -- other contraction banks can satisfy these requirements.
**Lemma 3.4**.: \(\mathcal{F}_{n}\) _(for simple graphs) and \(\mathcal{F}_{e}\) (for general graphs) can always contract a node in \(H\) iff its number of neighbors is at-most \(1\) and \(2\), respectively._
A few comments are in order. Node-based contractions can only add self-edges during the contraction process (i.e., new node-valued data) thus requiring only \(O(n)\) additional memory to perform computation. Further note that since we assume simple graph data, \(H\) is also a simple graph, and no directed edges (i.e., non-symmetric intermediate tensors) are created during contraction. Contraction banks with undirected graphs suffice in this setting. We later show that the node-based model acts analogously to message-passing. The edge-based model targets exactness over both node and edge valued polynomial. It generates new edges that can be directed even if **X** is simple, and thus includes directed contractions in its bank. The edge-based model will later be connected to the graph models PPGN (Maron et al., 2019) and Ring-GNN (Chen et al., 2019). We later show that the node-based is 1-WL expressive and the edge-based model is 3-WL expressive.
**Deciding computability of \(P_{H}(\textbf{X})\) with \(\mathcal{F}_{\textbf{{B}}}\).** A key component in analyzing the expressive power of a Prototypical model is determining which polynomials \(P_{H}(\textbf{X})\) can be computed with \(\mathcal{F}\), given \(H\) and **X** encoding simple graph data. A naive algorithm traversing all possible enumerations of nodes in \(H\) and their contractions would lead to a combinatorial explosion that is too costly -- especially since this procedure needs to be repeated for a large number of polynomials. Here, we show that at least for contraction banks \(\mathcal{F}_{n}\) and \(\mathcal{F}_{e}\), Algorithm 1 is a linear time (in \(|V|,|E|\)), _greedy_ algorithm for deciding computability of a given polynomial. Algorithm 1 finds a sequence of contractions using the greedy step until no more nodes are left to contract. That is, it terminates when all nodes, aside from \(a,b\), have more than 1 or 2 neighbors for \(\mathcal{F}_{n}\) or \(\mathcal{F}_{e}\), respectively. If it terminates with just \(\{a,b\}\) as vertices it deems \(P_{H}\) computable and otherwise it deems \(P_{H}\) non-computable. To show correctness of this algorithm we prove:
**Theorem 3.5**.: _Let \(H\) be some multi-graph and \(\mathcal{F}_{\mathcal{B}}\in\{\mathcal{F}_{n},\mathcal{F}_{e}\}\). Further, let \(H^{\prime}\) be the multi-graph resulting after contracting a single node in \(H\) using one or more operations from \(\mathcal{B}\) to \(H\). Then, \(H\) is \(\mathcal{F}_{\mathcal{B}}\)-computable iff \(H^{\prime}\) is \(\mathcal{F}_{\mathcal{B}}\)-computable._
To verify the correctness of this procedure, note that the algorithm has to terminate after at most \(|V|-|\{a,b\}\mid\) node contractions. Now consider two cases: if the algorithm terminates successfully, it must have found a sequence of tensor contractions to compute \(P_{H}(\textbf{X})\). If it terminates unsuccessfully, the theorem implies its last network \(H^{\prime}\) is computable iff the input network \(H\) is computable. Now
Figure 5: Computation of \(P_{H}(\textbf{X})\) with a sequence of tensor contractions: The polynomial \(P_{H}(\textbf{X})\) (left-most) is computed when a single black edge parallel to the red edge is left (right-most); above each arrow is the tensor contraction applied (contracted nodes are in gray).
Figure 6: Prototypical node-based (left) and edge-based (right) graph models’ contraction banks. Gray nodes indicate nodes that are contracted. Explicit formula of each element can be found in Appendix D.
since there is _no_ further node contraction possible to do in \(H^{\prime}\) using operations from \(\mathcal{B}\) it is not computable by definition, making \(H\) not computable.
**Polynomial exactness.** To compute the \(d\) polynomial exactness (see Definition 3.1) for the node-based and edge-based Prototypical graph models we enumerate all non-isomorphic simple graphs \(H\) with up to \(d\) edges and one red edge and run Algorithm 1 on each \(H\). This reveals that the node-based model \(\mathcal{F}_{n}\) is 2-node-polynomial-exact, while the edge-based model \(\mathcal{F}_{e}\) is 5-node-polynomial-exact and 4-edge-polynomial-exact. See Figure 8 for the lowest degree polynomials, represented by \(H\) with the smallest number of edges, that are non-computable for \(\mathcal{F}_{n}\) and \(\mathcal{F}_{e}\).
\(k\)**-WL expressive power.** For simple graphs, there is a natural connection between our Prototypical graph models and the \(k\)-WL graph isomorphism tests. This stems from a result of Dvorak (2010); Dell et al. (2018), which states that two graphs \(\textbf{X}^{(1)}\) and \(\textbf{X}^{(2)}\) are \(k\)-FWL equivalent if and only if \(\hom(H,\textbf{X}^{(1)})=\hom(H,\textbf{X}^{(2)})\) for all \(H\) of tree-width at most \(k\). Recall that \(\hom(H,\textbf{X})\) is the number of homomorphisms from \(H\) to **X** (where \(H\) has no red edges), which we show is equivalent to the output of \(P_{H}(\textbf{X})\) for the invariant polynomial \(P_{H}\) in Appendix F. By showing that the Prototypical node-based graph model can contract any \(H\) of tree-width 1 (and no others), and that the Prototypical edge-based graph model can contract any \(H\) of tree-width at most 2 (and no others), we thus have the following result.
**Proposition 3.6**.: _The Prototypical node-based model can distinguish a pair of simple graphs if and only if 1-WL can. The Prototypical edge-based model can distinguish a pair of simple graphs if and only if 3-WL / 2-FWL can._
### GNNs and their expressive power
In this section we turn our attention to commonly used graph neural networks (GNNs), and provide lower bounds on their polynomial expressive power as in Definition 3.2. The Message Passing Neural Network (MPNN) we consider consists of layers of the form
\[\textbf{Y}^{(k+1)}=\mbb\left[\textbf{X}\textbf{Y}^{(k)},\mathbf{1}\mathbf{1}^ {T}\textbf{Y}^{(k)},\textbf{Y}^{(k)}\right], \tag{9}\]
where the intermediate tensor variables are \(\textbf{Y}\in\mathbb{R}^{n\times d}\), \(\mathbf{1}\in\mathbb{R}^{n}\) is the vector of all ones, \(\textbf{Y}^{(0)}=\mathbf{1}\), brackets indicate concatenation in the feature dimension, and \(\mbb\) means a multilayer perceptron (MLP) applied to the feature dimension.
As an application of the Prototypical edge-based model, we propose and implement a new model architecture (PPGN++) that is at least as expressive as the full versions of PPGN/Ring-GNN (Maron et al., 2019; Chen et al., 2019) (which incorporate all \(15\) linear basis elements), but is more efficient -- PPGN++ uses a smaller number of "primitive" operations than the full PPGN/Ring-GNN, and does not need parameters for each linear basis element:
\[\textbf{Z}^{(k+1)}=\mbb_{3}\left[\mbb_{1}\left[\textbf{Z}^{(k)},\textbf{Z}^{( k)T}\right]\otimes\mbb_{2}(\textbf{Z}^{(k)}),\textbf{Z}^{(k)}\right], \tag{10}\]
where \(\textbf{Z}\in\mathbb{R}^{n^{2}\times d}\) are intermediate tensor variables, \(\textbf{Z}^{(0)}=\mathbf{X}\), \(\mbb_{\frac{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{ \cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot}{\cdot }{\cdot}{\
relevant polynomials \(P_{H}\) (right). For the node based model we count only node-valued polynomials, while for the edge based model we count both node and edge-valued polynomials. Note that the number of non-computable polynomials is substantially smaller than the total number, especially in \(\mathcal{F}_{e}\). Since polynomials are calculated at the data preprocessing step, there is an upfront computational cost for this procedure that must be accounted for. Finding the optimal contraction path that minimizes runtime complexity for a general matrix polynomial is an NP-hard problem (Biamonte et al., 2015) with a naive upper bound in runtime complexity of \(O(n^{d})\). An empirical evaluation of the preprocessing time is in Appendix A; in our experiments, preprocessing time is small compared to training time.
## 4 Related Work
**Relation to Homomorphisms and Subgraph Counts.** Past work has studied invariant polynomials on graphs (Thiery, 2000; Lovasz, 2012). Viewed as functions on binary inputs, the basis consists of functions that count homomorphisms or injective homomorphisms of \(H\) into an input graph \(\mathbf{X}\). Homomorphisms are related to the \(P_{H}\) basis, and injective homomorphisms are related to \(Q_{H}\) (see Appendix F). Also, equivariant homomorphism counts that relate to our \(P_{H}\) or \(Q_{H}\) has been studied (Mancinska and Roberson, 2020; Grohe et al., 2021; Maehara and NT, 2019; Bouritsas et al., 2022). However, these works do not exhibit a basis of equivariant polynomials. Also, our tensor contraction interpretation and analysis does not appear in past work.
**Expressivity Measures for Graph Models.** The \(k\)-WL hierarchy has been widely used for studying graph machine learning (Morris et al., 2021), starting with the works of Morris et al. (2019) and Xu et al. (2019), which show an equivalence between message passing neural networks and 1-WL. Tensor methods resembling \(k\)-WL such as \(k\)-IGN (Maron et al., 2018) and PPGN-like methods (Maron et al., 2019; Azizian and Lelarge, 2021) achieve \(k\)-WL power (Azizian and Lelarge, 2021; Geerts and Reutter, 2022), but scale in memory as \(n^{k}\) or \(n^{k-1}\) for \(n\)-node graphs. Morris et al. (2019, 2022) define new \(k\)-WL variants with locality and sparsity biases, which gives a finer hierarchy and offers a trade-off between efficiency and expressiveness.
A matrix query language (MATLANG) (Brijder et al., 2019; Geerts, 2021) and a more general tensor language (TL) (Geerts and Reutter, 2022) have been used to study expressive power of GNNs (Balcilar et al., 2021; Geerts and Reutter, 2022). These languages define operations and ways to compose them for processing graphs in a permutation equivariant or invariant way. Our edge-based Prototypical model result gives a new perspective on a result of Geerts (2021), which shows that MATLAB can distinguish any two graphs that 2-FWL / 3-WL can. Indeed, our edge-based graph model includes the five linear algebra operations that form the 3-WL expressive MATLAB. While the operations of MATLAB were included in a somewhat ad-hoc manner ("motivated by operations supported in linear algebra package" (Geerts, 2021)), our framework shows that these are the at-most quadratic equivariant polynomials that are required to contract all tree-width 2 graphs.
## 5 Experiments
In this section we demonstrate the impact of increasing the polynomial expressive power of GNNs. We test two families of models. PPGN++ (\(d\)) uses the architecture in equation 10, derived using our edge based Prototypical model, and achieves \(d\) polynomial expressive power by pre-computing polynomial features found in Subsection 3.3; missing (\(d\)) notation means using just PPGN++ without pre-computed features. GatedGCN (\(d\)) uses the base MPNN architecture of (Bresson and Laurent, 2017) with the \(d\)-expressive polynomials pre-computed. We experiment with \(4\) datasets: a graph isomorphism dataset SR (Bodnar et al., 2021), which measures the ability of GNNs to distinguish strongly regular graphs; and \(3\) real-world molecular property prediction datasets including ZINC, ZINC-full (Dwivedi et al., 2020) and Alchemy (Chen et al., 2019).
### Graph Isomorphism Expressiveness
Distinguishing non-isomorphic graphs from families of strongly regular graphs is a challenging task (Bodnar et al., 2021, 2020). The SR dataset (Bouritsas et al., 2022) is composed of 9 strongly regular families. This dataset is challenging since any pair of graphs in the SR dataset cannot be distinguished by the \(3\)-WL algorithm. This experiment is done without any training (same procedure as in (Bodnar et al., 2021)) and the evaluation is done by randomly initialized models. For every family in the dataset, we iterate over all pairs of graphs and report the fraction that the model determines are isomorphic. Two graphs are considered isomorphic if the \(L_{2}\) distance between their embeddings is smaller than a certain threshold (\(\epsilon=0.01\)). This procedure was repeated for \(5\) different random seeds and the averaged fraction rate was reported in Figure 9. This figure portrays the expressiveness boost gained by using high degree polynomial features. While the base models, GatedGCN and PPGN (and PPGN++), cannot distinguish any pair of graphs (as theoretically expected), adding higher degree polynomial features significantly improves the ability of the model to
\begin{table}
\begin{tabular}{l|c|c|c|c|c} \hline & \(d=3\) & \(d=4\) & \(d=5\) & \(d=6\) & \(d=7\) \\ \hline \(\mathcal{F}_{n}\) & 2/8 & 6/18 & 23/49 & 85/144 & 308/446 \\ \hline \(\mathcal{F}_{e}\) & 0/18 & 0/53 & 1/174 & 11/604 & 72/2193 \\ \hline \end{tabular}
\end{table}
Table 1: Numbers of non-computable polynomials (left) out of all relevant polynomials (right) for the Prototypical models.
distinguish non-isomorphic graphs in this dataset. Optimal results of \(0\%\) failure rate are obtained for PPGN++ (\(d\)) with \(d\geq 6\) (i.e., adding at-least degree \(6\) polynomial features). For the GatedGCN model, although we do not reach the \(0\%\) failure rate, adding the right polynomial features makes GatedGCN outperform \(3\)-WL based models in distinguishing non-isomorphic graphs in this dataset.
### Real-World Datasets
The efficacy of increasing polynomial expressive power on real-world data (molecular graphs datasets) was evaluated on \(3\) graph regression tasks: ZINC, ZINC-full and Alchemy.
**Training.** We followed the training protocol mentioned in (Dwivedi et al., 2020) for ZINC and ZINC-full and the protocol from (Lim et al., 2022) for Alchemy. All of our trained models obey a \(500K\) parameter budget. Further details regarding the training procedure and model parameters can be found in Appendix A.
**Baselines.** The baseline results for the ZINC \(12K\) experiment were obtained from (Zhao et al., 2022), except for PPGN and GatedGCN, which we calculated. For ZINC-full and Alchemy we used the results from (Lim et al., 2022) (again, excluding PPGN).
**Results.** The mean absolute error (MAE) over the test set is reported in Table 3 for ZINC \(12K\) and Table 2 for ZINC-full and alchemy. In both tables, PPGN++ (\(6\)) achieves SOTA results across all \(3\) datasets. In addition, for both test model families there is a clear correlation between higher \(d\) (polynomial expressiveness) and test error. Furthermore, PPGN++ (\(5\)) and PPGN++ (\(6\)), which produce the top results in all \(3\) experiments, are the only \(2\) models (including all baselines) which are provably strictly more powerful than 3-WL. Our results add evidence to the guiding hypothesis that increases in expressivity facilitate improved downstream performance.
## 6 Conclusions
We propose a novel framework for evaluating the expressive power of graph neural networks (GNNs) by evaluating their ability to approximate equivariant graph polynomials. Our first step was introducing a basis for equivariant graph polynomials of any degree. We then utilized Prototypical graph models to determine the computability of these polynomials with practical GNNs. This led to a method for increasing the expressivity of GNNs through the use of precomputed polynomial features, resulting in a significant improvement in empirical performance.
Future research could focus on several promising directions. One direction can reduce the number of features passed into GNNs by working with a generating set of polynomials rather than the complete basis. Additionally, incorporating features on nodes and edges, as outlined in Appendix E, could further improve performance. Another exciting avenue for exploration can incorporate otherwise uncomputable polynomials as computational primitives into GNN layers, rather than as features, to increase expressiveness. Finally, it would be beneficial to study Prototypical graph models to identify families with optimal properties related to expressiveness, memory/computation complexity,
\begin{table}
\begin{tabular}{l|c|c} \hline \multirow{2}{*}{Model} & ZINC-Full & Alchemy \\ \cline{2-3} & Test MAE & Test MAE \\ \hline GIN (Xu et al., 2019) &.088 \(\pm\).002 &.180 \(\pm\).006 \\ \(\delta\)-2-GNN (Morris et al., 2019) &.042 \(\pm\).003 &.118 \(\pm\).001 \\ SpeedNet (Morris et al., 2022) & - &.115 \(\pm\).001 \\ PF-GNN (Dupty et al., 2022) & - &.111 \(\pm\).010 \\ HIMP (Fey et al., 2020) &.036 \(\pm\).002 & - \\ SignNet (Lim et al., 2022) &.024 \(\pm\).003 &.113 \(\pm\).002 \\ CIN (Bodnar et al., 2021a) &.022 \(\pm\).002 & - \\ \hline PPGN (Maron et al., 2019) &.022 \(\pm\).003 &.113 \(\pm\).001 \\ PPGN++ &.022 \(\pm\).001 &.111 \(\pm\).002 \\
**PPGN++ (5)** & **.020 \(\pm\).001** &.110 \(\pm\).001 \\
**PPGN++ (6)** & **.020 \(\pm\).001** & **.109 \(\pm\).001** \\ \hline \end{tabular}
\end{table}
Table 2: Results on Alchemy (Chen et al., 2019) and ZINC-full (Dwivedi et al., 2020) datasets. Lower is better, best models are marked in **bold**.
\begin{table}
\begin{tabular}{l|c} \hline \multirow{2}{*}{Model} & ZINC-Full & Alchemy \\ \cline{2-3} & Test MAE & Test MAE \\ \hline GIN (Xu et al., 2019) &.088 \(\pm\).002 &.180 \(\pm\).006 \\ PNA (Corso et al., 2020) &.140 \(\pm\).006 \\ GSN (Bouritsas et al., 2022) &.115 \(\pm\).012 \\ PF-GNN (Dupty et al., 2022) &.122 \(\pm\).010 \\ GIN-AK (Zhao et al., 2021) &.080 \(\pm\).001 \\ CIN (Bodnar et al., 2021a) &.079 \(\pm\).006 \\ SetGNN (Zhao et al., 2022) &.075 \(\pm\).003 \\ \hline GatedGCN (Bresson and Laurent, 2017) &.265 \(\pm\).015 \\ GatedGCN (\(4\)) &.150 \(\pm\).005 \\ GatedGCN (\(5\)) &.138 \(\pm\).003 \\ GatedGCN (\(6\)) &.106 \(\pm\).003 \\ \hline PPGN (Maron et al., 2019) &.079 \(\pm\).005 \\ PPGN++ &.076 \(\pm\).003 \\ PPGN++ (5) &.072 \(\pm\).005 \\
**PPGN++ (6)** & **.071 \(\pm\).001** \\ \hline \end{tabular}
\end{table}
Table 3: Results on ZINC \(12K\)(Dwivedi et al., 2020) dataset. Lower is better, best model is marked in **bold**.
Figure 9: Failure rate (log scale) for distinguishing SR graphs, the lower the better.
and the size of the contraction bank.
## 7 Acknowledgments
OP is supported by a grant from Israel CHE Program for Data Science Research Centers. We thank Nicolas Usunier For his insightful remarks.
|
2306.02750 | The Learning Prescription, A Neural Network Hearing Aid Core | The definition of a hearing aid core which is based on a prescription neural
network (such as NAL-NL2) is defined here. This hearing aid core replaces a
traditional compressor hearing aid core which mimics the said hearing aid
prescription. Whilst the replacement of the compressors for a neural network
may seem simple, the implications are vast in terms of the "learning
prescription" where the topology of the neural network may be increased to make
available more free parameters and allow great personalisation of the hearing
aid prescription. | Matt R. Flax | 2023-06-05T10:12:41Z | http://arxiv.org/abs/2306.02750v1 | # The Learning Prescription, A Neural Network Hearing Aid Core
###### Abstract
The definition of a hearing aid core which is based on a prescription neural network (such as NAL-NL2) is defined here. This hearing aid core replaces a traditional compressor hearing aid core which mimics the said hearing aid prescription. Whilst the replacement of the compressors for a neural network may seem simple, the implications are vast in terms of the "learning prescription" where the topology of the neural network may be increased to make available more free parameters and allow great personalisation of the hearing aid prescription.
## 1 Introduction
The NAL-NL2 hearing aid prescription introduced a neural network for the prescription of hearing aid gain for the first time [2] based on a desensitised speech intelligibility index (SII) designed for NAL-NL2 [1]. Concise descriptions of the NAL-NL2 hearing aid prescription are given [4, 5] which focus on the effects of the desensitised SII on gain optimisation, however the said articles gloss over the importance of the introduction of the neural network to hearing aid prescription, which overcame significant hurdles of reliable prescriptions being dispensed by NAL-NL1. The reason why arbitrary prescription is now far more accurate was the ability for the NAL-NL2 neural network to successfully interpolate between optimised prescriptions for people with unique and unseen hearing loss profiles. Prior to the introduction of the neural network in hearing aid prescription, hand crafted nonlinear equations were used to try to match the infinite possible prescriptions which can't all be optimised and thus certain patients would not receive optimal hearing aid prescriptions.
This article takes the next logical step in hearing aid development by defining for the first time the replacement of hearing aid compressors by a personal prescription neural network. This article lays the foundation for the future layering of neural network and other statistically optimised systems to greatly improve hearing aid performance. With the introduction of personal prescription neural networks this article also introduces a robust method for further personalisation away from speech intelligibility prescriptions and towards learning prescriptions.
A digital hearing aid core is shown in Figure 1a where a filter bank bands the signal and pre-fit compressors implement the hearing aid prescription. The signal path is nonlinear as the sound pressure level is constantly changing and the level estimation in the compressors are constantly changing. This constantly changing level estimation generates nonlinear gain application as the compressor's operating point is slowly but constantly varying.
The hearing aid implemented with a prescription neural network core, shown in Figure 1b operates on a block of N samples of audio signal. The sound level meter (SLM) presents signal levels for the neural network to prescribe the block gain for each band of the filter bank. The gains are applied to the banded signals and summed then output to the receiver. As the gains are not varying within a signal block, the signal chain is linear. Half window overlap add techniques can be used to allow the audio blocks to vary smoothly and allow the gains to vary without output discontinuity.
This article prescribes the implementation of a hearing aid with a neural network core. Free software is also available which implements the theory in this document. The first Section 2 implements a log banded filter bank centred around the prescription frequencies (\(f_{c}\)). The duration of the audio in each filter is roughly eight milliseconds and after overlap add the effective hearing aid gains change at a rate of approximately four milliseconds. Rates of
gain change slower then three milliseconds are optimal for a prescription algorithm such as NAL-NL2 [2] as the compression ratio of the optimised prescription is not altered and thus the speech intelligibility index is maximised. The overall latencies of the filters are half the filter length as there is an overlap add framework. In operation, the first half block can be output after half the filter length is input/output and every subsequent half block is processed and output, resulting in an overall latency of half the filter length which is around 3 ms to 4 ms.
Subsequent sections 3 and 4 briefly address level metering and signal amplification. While the last section leaves the prescription neural network as an open design solution. The best neural network will start the user in a space which is optimised for SII maximisation, but allow the user to train their prescription to their own personal target. The gradual expansion of the free parameters available to the neural network will allow for the expansion in the complexity of gain prescription to the user's taste.
## 2 Log banded filter bank
The prescription algorithm outputs gains for the log centred frequencies (\(f_{c}\) in Hz) over the M=6 bands from m=0 to m=M-1
\[f_{c}\left(m\right)= 250\left(2^{m}\right)\]
Zero phase brick wall band limited filters are generated1 where the zero phase filters (\(h_{0,\,m}\)) are specified in the Discrete Fourier Domain (\(H_{0,\,m}\)) and transformed to the time domain using the inverse Discrete Fourier Transform
Figure 1: Digital and neural network hearing aid cores.
(DFT or \(\mathcal{F}\))
\[H_{0,\,m}\left(f_{i}\left(m\right),\,f_{a}\left(m\right)\right) =\left.1\right|_{f_{1}\leq\left|f\right|\leq f_{a}}\] \[h_{0,\,m} =\mathcal{F}^{-1}\left\{H_{0,\,m}\right\}\]
where the minimum frequency \(\left(f_{i}\left(m\right)\right)\) and maximum frequency \(\left(f_{a}\left(m\right)\right)\) are specified per band m (see Equation 1).
These zero phase filters are circularly shifted by a constant group delay of \(\frac{N}{2}\) samples to give the linear phase band limited filters \(\left(h_{m}\right)\)
\[h_{m}=h_{m,\,n}=h_{m}[n]=h_{0,\,m}\left[\left(n+\frac{N}{2}\right)\,mod\,N-1\right]\]
The specifaction of the band limits (in Hz) are
\[f_{a}\left(m\right)= \begin{cases}f_{c}\left(m\right)+f_{t}&m=0\\ \frac{3}{2}f_{c}\left(m\right)&m>0\end{cases} \tag{1}\] \[f_{i}\left(m\right)= \begin{cases}20&m=0\\ f_{a}\left(m-1\right)&m>0\end{cases}\]
where \(f_{t}\) is the frequency stepping between Fourier bins or the DFT resolution, which is kept to a maximum value
\[f_{t}=\frac{f_{c}\left(0\right)}{2}\]
and this defines the number of samples (N) in the filter given a sample rate of \(f_{s}\) Hz
\[N=\frac{f_{s}}{f_{t}}\]
An example filter bank with a sample rate of \(f_{s}=24\,kHz\) is implemented in the script LogFilterBankTest.m and is shown in Figure 2.
## 3 The sound level meter
The SLM estimates the dB SPL level of the signal \(\left(s\right)\) for each band \(\left(l_{m}\right)\)
\[l_{m}=20\,log10\left(\sum_{n=0}^{N-1}h_{m}*s+l_{t,m}\right)+l_{d,m}\]
where \(*\) represents the convolution operator and the three scaling variables are defined as; \(l_{t}\) is a time domain DC offset which may be necessary in some systems. \(l_{d}\) is a gain variable which converts digital full scale levels into dB sound pressure level.
## 4 Audio amplification and output
The gained bands of audio are summed and output
\[y=\sum_{m=0}^{M-1}g_{m}h_{m}*s\]
At this point overlap add sums the last block of audio to the current block of audio to generate the receiver's output audio signal \(\left(r_{n}\right)\)
\[r_{n}=y_{n-N/2}*w_{n}+y_{n}*w_{n}\]
## 5 The prescription neural network
The neural network will input signal levels per band for each block of audio and output the required signal gain per band (\(g_{m}\)). All neural network pre and post conditioning are applied in this block of processing.
The neural network can be multi-layer and have arbitrary non-linear layer output functions. The implementation of the prescription neural network [3] is proprietary software.
## 6 Conclusion
This article replaces traditional hearing aid cores which are based on compressors (see Figure 1a) with the a suitable SII maximising neural network (see Figure 1b). A traditional prescription system such as NAL-NL2 can be placed directly onto the users hearing aid in the form of a personal prescription neural network. This personal prescription neural network can then be trained to learn the user's preference in amplification. With time as the free parameters in the neural network are increased in number, more complex features and learning may be accomplished.
A suitable FIR filter for this hearing aid is defined in Section 2 which targets a half block input/output delay to allow a roughly 3 ms system latency which matches the optimal operating latency for the NAL-NL2 prescription algorithm. A simple sound level meter and amplification strategy is also defined in Sections 3 and 4.
|
2301.05926 | Physics-Informed Neural Networks for Mesh Deformation with Exact
Boundary Enforcement | In this work, we have applied physics-informed neural networks (PINN) for
solving mesh deformation problems. We used the collocation PINN method to
capture the new positions of the vertex nodes while preserving the connectivity
information. We use linear elasticity equations for mesh deformation. To
prevent vertex collisions or edge overlap, the mesh movement in this work is
conducted in steps with relatively small movements. For moving boundary
problems, the exact position of the boundary is essential for having an
accurate solution. However, PINNs are frequently unable to satisfy Dirichlet
boundary conditions exactly. To overcome this issue, we have used hard boundary
condition enforcement to automatically satisfy Dirichlet boundary conditions.
Specifically, we first trained a PINN with soft boundary conditions to obtain a
particular solution. Then, this solution was tuned with exact boundary
positions and a proper distance function by using a new PINN considering only
the equation residual. To assess the accuracy of our approach, we used the
classical translation and rotation tests and compared them with a proper mesh
quality metric considering the change in the element area and shape. The
results show the accuracy of this approach is comparable with that of finite
element solutions. We also solved different moving boundary problems,
resembling commonly used fluid-structure interaction problems. This work
provides insight into using PINN for mesh-deformation problems without needing
a discretization scheme with reasonable accuracy. | Atakan Aygun, Romit Maulik, Ali Karakus | 2023-01-14T14:17:22Z | http://arxiv.org/abs/2301.05926v1 | # Physics-Informed Neural Networks for Mesh Deformation
###### Abstract
In this work, we have applied physics-informed neural networks (PINN) for solving mesh deformation problems. We used the collocation PINN method to capture the new positions of the vertex nodes while preserving the connectivity information. We use linear elasticity equations for mesh deformation. To prevent vertex collisions or edge overlap, the mesh movement in this work is conducted in steps with relatively small movements. For moving boundary problems, the exact position of the boundary is essential for having an accurate solution. However, PINNs are frequently unable to satisfy Dirichlet boundary conditions exactly. To overcome this issue, we have used hard boundary condition enforcement to automatically satisfy Dirichlet boundary conditions. Specifically, we first trained a PINN with soft boundary conditions to obtain a particular solution. Then, this solution was tuned with exact boundary positions and a proper distance function by using a new PINN considering only the equation residual. To assess the accuracy of our approach, we used the classical translation and rotation tests and compared them with a proper mesh quality metric considering the change in the element area and shape. The results show the accuracy of this approach is comparable with that of finite element solutions. We also solved different moving boundary problems, resembling commonly used fluid-structure interaction problems. This work provides insight into using PINN for mesh-deformation problems without needing a discretization scheme with reasonable accuracy.
**Keywords:** physics-informed neural networks, mesh deformation, exact boundary enforcement, linear elasticity
## 1 Introduction
Dynamic grids in numerical fluid flow simulations generally arise in many applications, such as airfoil movement [1, 2], blood flow [3], parachute mechanics [4, 5], and free surface flow problems [6]. These and other fluid-structure interaction (FSI) problems need to move the computational grid with moving boundaries. The naive choice is to regenerate the mesh every time the boundary moves. Regenerating the mesh for a complex geometry results in a need for an automatic mesh generator [7]. This approach alters the grid connectivity and, therefore, brings up a need to project the solution to the new mesh. This introduces new projection errors each time the mesh is updated. Moreover, the cost of calling a new mesh generation algorithm can be overwhelming, especially for 3D problems [8].
Specific mesh moving techniques can overcome the drawbacks of remeshing for moving boundary problems. These methods try to update the position of the nodes of the original mesh under some prescribed laws without changing the grid connectivity. Farhat et al. introduced a spring analogy, where they fictitiously attach a torsional spring to the nodes of the mesh [9]. The system has fictitious mass, damping, and stiffness matrices, and the forcing is the displacement of the moving boundaries. This approach prevents vertex collisions as well as penetrating grid edges. In [8], the authors used a
linear elastic equation to represent the fluid domain as an elastically deformable body and introduced a parallel finite element strategy. Using the same elasticity formulation, Stein et al. [10] solved the equation using a Jacobian-based stiffening. They introduced an additional stiffening power as a function of transformation Jacobian in the finite element formulation. This addition allowed them to stiffen the smaller elements more than the larger ones, resulting in improved mesh quality near the moving surfaces. Takizawa et al. [11], introduced a method based on the fiber-reinforced hyperelasticity model. They introduced fibers in different directions according to the motion, which allows the model to reduce the distortion of a mesh element. The moving mesh problem can be solved using the Laplacian or biharmonic equations [12, 13, 14]. Although using the biharmonic operator introduces extra computational complexity compared to the Laplacian equation systems, it can give the extra ability to control the normal mesh spacing [14].
Apart from conventional numerical methods, machine learning methods are also used to solve partial differential equations. Deep neural networks were first used by Lee and Kang [15], and Lagaris et al [16] to predict the solution of a partial differential equation (PDE). Raissi et al. [17] introduced the concept of physics-informed neural networks (PINN) to solve PDEs without any given data. This approach gives information about the physical laws to the neural network. Using the information on the boundary and initial conditions, neural networks can predict the solution of a PDE. The PINN formulation has received great attention and has been studied in wide content. There are numerous extensions of PINN to improve the methodology. Several domain decomposition models are designed to improve the accuracy and allow parallelization [18, 19, 20]. Bayesian PINNs are proposed to tackle the problems involving solving PDEs where noisy data is available [21] and where uncertainty quantification is important. Applications of PINN cover the solutions of conservation laws [22], fractional and stochastic differential equations [23, 24], solution of Navier-Stokes equations [25, 26], Euler equations [27], heat transfer problems [28, 29], Boltzmann equation with Bhatnagar-Gross-Krook collision model [30], Allen-Cahn and Cahn-Hilliard equations [31, 32], free boundary and Stefan problems [33] and many more.
Despite the success of PINN across a range of different problems, it can face difficulties when solving multiscale and multiphysics problems [34], especially for dynamical systems with chaotic or turbulent behavior [35]. The fully connected networks face difficulties in learning high-frequency functions. This phenomenon is named spectral bias [36, 37]. The high-frequency behavior in the objective function results in sharp gradients. Therefore, PINN models can have difficulties while penalizing the residual loss. Although there are several approaches to tackle these problems and improve the training capabilities of PINN, the classical PINN method shows better performance to accurately solve the PDEs that govern the mesh deformation. Therefore our research focuses on using PINNs in the application of these problems.
The main objective of this paper is to show the applicability of physics-informed neural networks for moving mesh problems. The PINN approach can produce satisfactory solutions for the movement of boundaries without needing a discretization scheme. However, using the original PINN formulation for mesh moving problems can have difficulties with the static and moving boundaries. PINN minimizes the loss at the boundaries, without imposing boundary conditions exactly. To overcome this problem, we used exact boundary enforcement. After obtaining a particular solution that weakly satisfies the boundary conditions, the prediction is corrected by training another PINN. To the best of our knowledge, using PINNs on mesh movement problems with exact boundary enforcement is not studied in detail in the literature.
The remainder of this paper is organized as follows. First, basic information is given about physics-informed neural networks. This chapter is enhanced with the methodology of automatically satisfying boundary conditions using exact boundary enforcement. Most common mesh movement techniques are presented in the next chapter alongside the mesh quality metric used for comparing different methods. The results are presented with classical translation and rotation tests followed by examples resembling
commonly used moving boundary problems.
## 2 Physics-Informed Neural Networks
A basic, fully connected deep neural network architecture can be used to solve differential equations [38]. Given an input vector \(\mathbf{x}\in\mathbb{R}^{d}\), a single layer neural network gives an output \(\hat{\mathbf{u}}\) by the following form:
\[\hat{\mathbf{u}}=\sigma(\mathbf{W}_{1}\mathbf{x}+\mathbf{b}_{1})\mathbf{W}_{2} +\mathbf{b}_{2}, \tag{1}\]
where \(\mathbf{W}\) are the weight matrices and \(\mathbf{b}\) are the bias vectors. \(\sigma(\cdot)\) is a nonlinear function known as the activation function. In general, Sigmoid, hyperbolic tangent, and rectified linear unit (ReLU) are popular choices for the activation function. The hyperparameters \(\theta=[\mathbf{W},\mathbf{b}]\) are estimated by the following optimization problem
\[\theta^{*}=\operatorname*{arg\,min}_{\theta}J(\theta;\mathbf{x}). \tag{2}\]
Here, \(J\) is the objective function to be minimized. In this work, this function is defined as the mean squared error of the prediction. This minimization problem in Equation 2 can be solved by using first-order stochastic gradient descent (SGD) algorithms [39]. In each iteration, the hyperparameters are updated in such a way,
\[\theta^{i+1}=\theta^{i}-\eta^{i}\nabla_{\theta}J(\theta;\mathbf{x}), \tag{3}\]
where \(i\) being the current iteration and \(\eta\) is the learning rate. The gradient of the loss function, \(\nabla_{\theta}J(\theta;\mathbf{x})\), is calculated by backpropagation [40].
For the physics-informed a neural network, we consider the general form of partial differential equations:
\[\mathbf{u}_{t}+\mathcal{N}[u]=0, \mathbf{x}\in\Omega,\ t\in[0,T] \tag{4a}\] \[\mathbf{u}(\mathbf{x},0)=f(\mathbf{x}), \mathbf{x}\in\Omega\] (4b) \[\mathbf{u}(\mathbf{x},t)=g(\mathbf{x},t), \mathbf{x}\in\partial\Omega,\ t\in[0,T] \tag{4c}\]
where \(\mathcal{N}\) is a generalized differential operator that can be linear or nonlinear, \(\mathbf{x}\in\mathbb{R}^{d}\) and \(t\in[0,T]\) are the spatial and temporal coordinates. \(\Omega\) and \(\partial\Omega\) represent the computational domain and the boundary respectively. \(\mathbf{u}(\mathbf{x},t)\) is the general solution of the PDE with \(f(\mathbf{x})\) is the initial condition and \(g(\mathbf{x},t)\) is the boundary condition. The hidden solution, \(\mathbf{u}(\mathbf{x},t)\), can be approximated under the PINN framework proposed by Raissi et al. [17], by a feedforward neural network \(\hat{\mathbf{u}}(\mathbf{x},t;\theta)\) with parameters \(\theta\). For the supervised training the only labeled data comes from the boundary/initial points. Inside the domain, the loss is determined by the PDE residual. By utilizing automatic differentiation (AD) [41], PINNs can differentiate the network output w.r.t the input layer. AD applies the chain rule repeatedly to the elementary functions and arithmetic operations to achieve the derivative of the overall composition. AD is well implemented in popular deep learning frameworks such as TensorFlow [42] and PyTorch [43].
In classical PINN implementations, the loss term is a composite term including supervised data loss on the boundaries and initial points and the PDE loss. The total loss term can be written such that,
\[\mathcal{L}=w_{R}\mathcal{L}_{R}+w_{BC}\mathcal{L}_{BC}+w_{IC}\mathcal{L}_{IC}. \tag{5}\]
Here the terms represent the boundary loss \(\mathcal{L}_{BC}\), the initial condition loss \(\mathcal{L}_{IC}\), and the PDE residual loss \(\mathcal{L}_{R}\). The \(w\) terms are specific weights of each loss term that can be user-specified or tuned manually
or automatically [37, 44]. Each loss term can be written as,
\[\mathcal{L}_{R} =\frac{1}{N_{R}}\sum_{i=1}^{N_{R}}|\mathbf{u}_{t}+\mathcal{N}[ \mathbf{u}(\mathbf{x}^{i},t^{i})]|^{2} \tag{6a}\] \[\mathcal{L}_{BC} =\frac{1}{N_{BC}}\sum_{i=1}^{N_{BC}}|\mathbf{u}(\mathbf{x}^{i},t^ {i})-g(\mathbf{x}^{i},t^{i})|^{2}\] (6b) \[\mathcal{L}_{IC} =\frac{1}{N_{IC}}\sum_{i=1}^{I_{BC}}|\mathbf{u}(\mathbf{x}^{i},0 )-f(\mathbf{x}^{i})|^{2}. \tag{6c}\]
Here \(N_{R},\ N_{BC}\), and \(N_{IC}\) are the total number of points used for calculating the mean squared error used here as the loss function. The schematic of a classical PINN can be seen in the left part of Figure 1.
The hyperparameters \(\theta=[\mathbf{W},\mathbf{b}]\) can be optimized by a chosen optimization algorithm to find the minimum total loss defined in Equation 5. As mentioned above, stochastic gradient descent algorithms are commonly used in neural network implementations [39]. This method aims to find new parameters \(\theta\) in the opposite direction of the gradient of the objective function. The gradient of the loss function w.r.t. hyperparameters is calculated by backpropagation. In this work, we used the ADAM algorithm [45] as the SGD optimizer.
### Exact Boundary Enforcement
The optimization algorithm used in PINN tries to minimize the physics-based loss, \(\mathcal{L}_{R}\). Using proper boundary and initial conditions can regularize the physics loss in deep neural networks. This classical PINN boundary condition implementation in Equation 6 is named soft boundary enforcement [46]. In this approach, the boundary prediction is minimized in the composite loss function. Although the SGD
Figure 1: Schematic of PINN approach with exact boundary enforcement. The first PINN on the left shows the original formulation with weakly enforced Dirichlet boundary conditions. The second network uses the particular solution with exact boundary enforcement to satisfy Dirichlet boundaries exactly
algorithms can minimize these loss functions, they do not satisfy the boundary values exactly. However, some PDE applications, such as mesh movement, need exact boundary values. For this purpose, we apply exact boundary enforcement. Sun et al. [46] used this boundary condition enforcement to exactly satisfy the velocity and pressure values on the boundaries of internal flow cases with Navier-Stokes equations. Sukumar and Srivastava [47] introduced geometry-aware trial functions. They multiply the neural network output with these functions and use its generalization to exactly satisfy boundary conditions on complex geometries. In this work, we use this idea with multiple physics-informed neural networks to exactly satisfy Dirichlet boundary conditions. First, we trained a PINN with soft boundaries. For the mesh movement problem, the displacement vector \(\mathbf{u}=[X,Y]^{T}\) will give the new coordinates of the nodes from the first neural network prediction. This solution is then changed on the boundaries with the exact values. This new solution is the particular solution of our approach. Then, a new PINN is trained with an output \(\hat{\mathbf{u}}(\mathbf{x};\theta)\). This output is modified with the following equation.
\[\tilde{\mathbf{u}}(\mathbf{x};\theta)=\mathbf{u}_{par}(\mathbf{x})+D(\mathbf{ x})\hat{\mathbf{u}}(\mathbf{x};\theta). \tag{7}\]
Here, \(\mathbf{u}_{par}\) is a particular solution that is a globally defined smooth function that only satisfies the boundary conditions. Any smooth function can be used for the particular solution such as radial basis functions (RBF) or linear functions [46]. In this work, we use the classical PINN predictions with the soft boundary condition implementation as the particular solution. \(D\) is a specified distance function from the boundary. Equation 7 states that on the boundaries \(D(\mathbf{x})=0\), the particular solution satisfies the exact boundary values, \(\mathbf{u}=g\) on \(\partial\Omega\). For a general approach, we used the shortest distance between the residual points and the boundaries. Since the geometric domains used in this paper are not too complex, this approach is not very time consuming. For complex geometries, approximate distance functions using R-functions [47] or pre-trained deep neural networks [48] can be used. This modified output contributes to the physics loss of the new PINN. In this network, the objective function is only consisting of the PDE residual \(\mathcal{L}_{R}\) and trained with the same PDE. This approach allows us to exactly satisfy the Dirichlet boundary conditions using PINN.
## 3 Mesh Movement
Mesh movement strategies to deform the mesh with a moving boundary generally can be performed by solving a PDE or using an interpolation scheme [49]. All of these techniques have the goal to provide a displacement of the moving boundary and propagate this movement into the domain. Methods with a PDE solution, generally model the mesh movement as a physical process which can be solved using numerical methods. One of the popular versions includes modeling the domain with torsional springs that prevent the vertices to collide [9]. In a similar manner, this movement can be modeled with an elastic [8, 10] and hyperelastic [11] analogy, where the computational domain is simulated as an elastic body. Nonlinear elasticity equations with neo-Hookean models can be used in the same way as the elastic equations [50]. Other techniques include mesh deformation as a diffusive system modeled with the Laplacian or biharmonic equations [14]. All these PDEs can be solved using traditional numerical methods such as FEM.
Interpolation schemes consider the mesh movement as a problem of interpolation from the boundaries to the domain. These schemes use interpolation on scattered data and generally do not need connectivity information. Using radial basis functions (RBF) is one of the common methods. In [51], de Boer et al. use RBF interpolation on unstructured grids to estimate the movement. The equation system only involves the boundary nodes and displacement of the whole mesh is modeled. Extending this method, in [52], the authors use data reduction algorithms using a coarse subset of the surface mesh. With greedy algorithms, this approach is effective, especially for mesh motion problems with smooth surface deformations.
In this work, we used one of the common PDEs for mesh movement. The mesh motion is calculated by using the linear elasticity equation from structural mechanics. The coordinates of the nodes will be defined as \(\mathbf{u}\), the computational domain is referred to as \(\Omega\), and the boundaries are \(\partial\Omega\). Boundaries also include the moving objects inside the meshes. The new coordinates of the moving and stationary boundaries are given as the Dirichlet boundary condition. The movement of an object inside the mesh deforms the computational domain which is modeled as an elastic body. The new coordinates can be found by the following linear elasticity equation:
\[\nabla\cdot\boldsymbol{\sigma}(\mathbf{u})=0 \text{in }\Omega \tag{8a}\] \[\mathbf{u}=\mathbf{u}_{b} \text{on }\partial\Omega. \tag{8b}\]
Here \(\boldsymbol{\sigma}\) is the Cauchy stress tensor. It is related to the strain tensor \(\boldsymbol{\epsilon}=(\nabla\mathbf{u}+\nabla\mathbf{u}^{T})/2\). The stress tensor can be written in a way by Hooke's law:
\[\boldsymbol{\sigma}=\lambda\text{tr}(\boldsymbol{\epsilon})\mathbf{I}+2\mu \boldsymbol{\epsilon}. \tag{9}\]
The Lame parameters \(\lambda\) and \(\mu\) are structural parameters coming from the elastic modulus \(E\) and Poisson's ratio \(\nu\). Since the mesh domain is not a real elastic body, the exact values for these parameters are not known. A value between \(0.3\) and \(0.45\) is recommended for Poisson's ratio since a high value can lead to distorted elements, and a lower value can reduce the resistance [50].
To be able to compare the effectiveness of different mesh movement techniques after a deformation, we use a mesh quality metric based on [10]. In these metrics, the area and shape changes are considered by checking the element area and the aspect ratio. Both metric uses the initial mesh elements as reference elements and measures the change according to them. The element area change \(f^{e}_{A}\) and shape change \(f^{e}_{AR}\) is defined as :
\[f^{e}_{A} =\left|\log\left(\frac{A^{e}}{A^{e}_{o}}\right)/\log(2.0)\right|, \tag{10a}\] \[f^{e}_{AR} =\left|\log\left(\frac{AR^{e}}{AR^{e}_{o}}\right)/\log(2.0)\right|. \tag{10b}\]
Here, the superscript \(e\) represents the specific element, and the subscript \(o\) is the initial mesh element before the deformation occurs. \(AR^{e}\) is the element aspect ratio defined in [10] as:
\[AR^{e}=\frac{(l^{e}_{max})^{2}}{A^{e}}. \tag{11}\]
Here, \(l^{e}_{max}\) is the maximum edge length for the specific element. For comparison of different techniques, we use the global area and shape changes by considering the maximum values of element area and shape changes, respectively.
## 4 Results
The movement of dynamic meshes with PINN is presented with several different test cases. First, a deformed square is presented where we squeeze the domain from the top and bottom. Then, the basic translation and rotation tests are performed and the solutions of the PINN approach are compared with the finite element solutions. Lastly, the movement of a flexible beam is presented where one end of the beam is fixed. For all the problems, initial meshes are generated using the Gmsh mesh generator [53]. We used TensorFlow to construct our PINN framework with Adam optimizer as the gradient descent algorithm. We initialized all the neural networks using the Glorot scheme and used 7 hidden layers with 50 units. The classical neural networks are trained for 40000 iterations, and the networks with exact boundary enforcement are trained for 5000 iterations. The learning rate is \(10^{-3}\) with a decay rate of 0.9. The Lame parameters are selected as \(\mu=0.35\) and \(\lambda=1\) as recommended [50].
### Deformed Square
In this test case, a square domain is deformed from its boundaries. The square domain is \(x\), \(y\in[0,1]\times[0,1]\) and the unstructured mesh consists of 2744 triangular elements. The initial mesh can be seen in Figure 2. We want to find a deformed mesh where the position of the top boundary becomes \(\hat{y}=y-0.25\sin(\pi x)\). On the top surface, we implement this condition as a Dirichlet boundary condition as well as \(\hat{x}=x\). All the other boundaries have the same Dirichlet boundary condition as \(\hat{y}=y\), and \(\hat{x}=x\). The deformed mesh can be seen in Figure 2. The figure in the middle shows the results obtained by only using classical PINN. This shows the boundaries, especially the corners, are not in the exact position and are deformed in an undesired way. The figure on the right shows the solution after exact boundary enforcement. The boundary values are corrected with the exact positions with the proposed approach. The \(L_{2}\) error on the boundary nodes is calculated as 0.031. For this test case, we increased the specific weight of the boundary loss of the composite loss function in Equation 5. Since the deformation of the boundary is higher than the deformation of the computational domain, the boundary weight is increased. The weight ratio of the boundary loss and the residual loss is set to 25 to capture the boundary values more precisely.
The mesh quality measure of the deformed mesh based on the element area and shape changes can be seen in 3. The top surface is deformed according to a sinusoidal function. The elements near the deformed boundary have the most change in size and shape as expected. Especially in the middle where the deformation is the largest, the elements are squeezed and get smaller. In the corners where the element vertices have two boundary conditions in each direction, the element area change is not significantly large. However, the shape of the corner elements changes more than the other elements on the boundary. These elements are bounded by the two boundaries and therefore the aspect ratios get larger. The deformation of the inner elements is relatively low, especially near the bottom boundary. The mesh deformation metrics get lower as the elements' position moves away from the deformed boundary. The global area and shape change metrics are calculated as \(|f_{A}^{\infty}|=0.744\), \(|f_{AR}^{\infty}|=1.264\), respectively.
To see the capabilities of our approach we further deform the bottom boundary with its coordinates \(\hat{y}=y+0.25\sin(\pi x)\). The Dirichlet boundary conditions on the stationary boundaries are the same as the other, \(\hat{x}=x\), \(\hat{y}=y\). The same specific weight ratio for the loss function of the PINN formulation is used. The deformed configuration can be seen in Figure 4. The figure in the middle is the solution with the classical PINN approach. The vertices on the boundaries are not in exact positions. Especially
Figure 2: Initial and deformed meshes of the deformed square case with its deformed top boundary. The unstructured mesh consists of 2744 triangular elements The first deformed figure shows the solution with classical PINN. The last figure represents the solution with exact boundary enforcement.
on the corners, the classical PINN solution has difficulty satisfying the positions. The \(L_{2}\) error of the boundary positions is calculated as \(0.076\) for this case.
The elementwise quality measures of this case can be seen in Figure 5. the elements on the top and the bottom boundaries are deformed the most, the same as in the previous case. The elements in the middle collapsed more than the case before. The global area and shape change values are \(|f_{A}^{\infty}|=1.701\), \(|f_{AR}^{\infty}|=1.845\), respectively. The element shape and size change significantly as the deformation is increased.
### Translation and Rotation tests
To test the accuracy of our approach, translation and rotation tests in [10] are performed. The original mesh can be seen in Figures 6 and 7. There is a line object located in \((-L,0)\times(L,0)\) in a \((-2L,-2L)\times(2L,2L)\) domain. A total of 2182 triangles are generated for the mesh.
For the translation tests, the object is moved \(0.5L\) upwards. The movement is performed in 10 steps with \(0.05L\) and in 5 steps with \(0.1L\) movement upwards in two different training settings. The last step of the movement can be seen in Figure 6. In Figure 8, the PINN method is compared with the approach in [10]. The area and shape change metrics of two PINN solutions are presented alongside the classical finite element solutions and solutions with Jacobian-based stiffening. The authors applied a stiffening power to prevent the deformation of the smaller elements. The stiffened approach represents the best value obtained in [10] with different applied stiffening power. The two PINN solutions are representing the overall motion in 5 and 10 steps. The total number of steps is represented in parentheses in the figure. As seen in the first row of Figure 8, the PINN solutions are comparable with the FEM solutions with Jacobian-stiffening. As mentioned before, the PINN approach does not have any criteria to prevent mesh overlapping and sudden movements move the vertex nodes in an undesired way. Therefore, the quality of the deformed mesh improves as the number of steps increases.
For the rotation tests, the object is rotated \(0.25\pi\) counterclockwise. Again, to prevent overlapping
Figure 3: Element quality metrics of the square with deformed top boundary. The figure on the left shows the element area change and the figure on the right shows the element shape change with respect to the initial mesh elements.
Figure 4: Initial and deformed meshes of the deformed square case. The square is squeezed from its top and bottom boundary. The first deformed figure shows the solution with classical PINN. The last figure represents the solution with exact boundary enforcement.
Figure 5: Element quality metrics of the square deformed from the top and bottom boundaries. The figure on the left shows the element area change and the figure on the right shows the element shape change with respect to the initial mesh elements.
of edges and collision of vertices, the movement is performed in steps with \(0.025\pi\) and \(0.05\pi\) counter-clockwise movement in each step in two different training. The last step of the rotation can be seen in Figure 7. The deformed mesh differs especially on the boundaries between different PINN solutions. The small elements near the moving boundary start to collapse in the PINN solution with 5 steps. As the number of steps increases, the mesh quality increases. The comparison of the rotation tests with the same finite element solution of the translation tests is presented in Figure 8. The PINN approach again lies between the classical solution and the solution with Jacobian-based stiffening.
In both tests, the global mesh quality metric presented in section 3 is used. The \(|f_{A}|_{\infty}\) and \(|f_{AR}|_{\infty}\) are calculated as the maximum area and shape change of the values in Equation 10 in every step. The
\begin{table}
\begin{tabular}{c|c c c c c c c c c} \hline \hline \(\Delta y\) & 0.05 & 0.1 & 0.15 & 0.2 & 0.25 & 0.3 & 0.35 & 0.4 & 0.45 & 0.5 \\ \hline \(|f_{A}|_{\infty}\) & 0.667 & 1.196 & 1.189 & 1.291 & 1.518 & 1.627 & 1.697 & 1.715 & 1.791 & 1.998 \\ \(|f_{AR}|_{\infty}\) & 0.596 & 1.125 & 1.118 & 1.220 & 1.447 & 1.556 & 1.626 & 1.663 & 1.921 & 2.258 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Global area and shape changes of translation tests. The solution is performed in 10 steps. The values are given in every step.
Figure 6: Initial mesh and deformed mesh after a total translation of 5 units. The solution in the middle is performed in 10 steps while the solution on the right is performed in 5 steps.
Figure 7: Initial mesh and deformed mesh after a total rotation of \(0.25\pi\). The solution in the middle is performed in 10 steps while the solution on the right is performed in 5 steps.
## 4 Conclusion
In this paper, we have proposed a method for the estimation of the \(\Delta\theta(\pi)\) and \(\Delta\theta(\pi)\) using the proposed method. The proposed method is based on the proposed method. The proposed method is based on the proposed method.
area change and shape change values are presented in Tables 1 and 2, for the translation and rotation tests, respectively.
### Flexible Beam
This test case consists of a mesh movement due to a motion of a flexible beam adapted from the problem in [50]. The beam is fixed on its left end and sits in the center of the domain. Domain dimensions are \((-10,10)\times(-10,10)\) and the structure's position is \((-5,5)\times(-0.5,0.5)\) The deformation is based on a sinusoidal function \(\sin(\frac{\pi}{2}\frac{\pi}{L})\) with varying amplitude. The initial mesh can be seen in Figure 9. This unstructured mesh consists of 2098 triangular elements. The right end of the structure first moves to 4 units upwards, then 8 units downwards, following a 4-unit upward motion to return to its initial state. The movements are performed in steps with 2-unit motions, upwards or downwards.
In Figure 10, the deformed mesh after two steps of movement is presented with the mesh quality presented with the global area and shape change metric. Using exact boundary enforcement gives the true boundary position and therefore fixes the vertices on the boundaries. Therefore, on the outer boundaries, elements are stretched and squeezed more than the inner elements. Especially elements near the tip of the moving boundary have the most area and shape changes.
In figure 11, the mesh after one cycle of motion is presented. The structure returns to its original place after eight iterations. By looking at the area change, the sinusoidal motion of the structure can be observed. The most deformed elements are located at the top and bottom boundaries and near the moving tip of the structure. These elements are squeezed first and cannot recover themselves after the relative stretching.
## 5 Conclusion and Future Work
In this work, we solved mesh deformation problems with physics-informed neural networks. The selected method uses the linear elastic model since PINN can give accurate results for solving this type of PDE. We note that vertex nodes are moved according to boundary movement. Moreover,
Figure 9: Initial mesh of the flexible beam test case with 2098 triangular elements. The elements are concentrated on the moving boundary to track the deformation in a precise way.
Figure 11: Element quality metrics when the structure returns its original position.
Figure 10: Element quality metrics when the structure tip moves to \(y=4\).
exact boundary values are enforced to satisfy the Dirichlet boundary conditions exactly. We test this approach with translation and rotation tests and compared it with finite element solutions. We showed that the PINN solution is comparable with the FEM solutions. The deformation is performed in numerous steps instead of a sudden movement. This prevents vertex collision and edge overlapping. We showed that as the number of steps is increased, the deformed mesh quality gets higher. For a greater mesh quality, the number of steps can be increased.
The mesh movement method in this paper only includes linear elastic equations, although it can be extended to other techniques. Other commonly used methods such as the Laplacian or biharmonic equations are also applicable to PINN formulation. Our future work aims to use other methods that prevent mesh overlapping in the training of the PINN. The network parameters and formulation can be extended in a way that vertex collisions and edge overlapping is prevented.
|
2305.16513 | Sliding Window Sum Algorithms for Deep Neural Networks | Sliding window sums are widely used for string indexing, hashing and time
series analysis. We have developed a family of the generic vectorized sliding
sum algorithms that provide speedup of O(P/w) for window size $w$ and number of
processors P. For a sum with a commutative operator the speedup is improved to
O(P/log(w)). Even more important, our algorithms exhibit efficient memory
access patterns. In this paper we study the application of the sliding sum
algorithms to the training and inference of the Deep Neural Networks. We
demonstrate how both pooling and convolution primitives could be expressed as
sliding sums and evaluated by the compute kernels with the shared structure. We
show that the sliding sum convolution kernels are more efficient than the
commonly used GEMM kernels on the CPU, and could even outperform their GPU
counterparts. | Roman Snytsar | 2023-05-25T22:37:40Z | http://arxiv.org/abs/2305.16513v1 | # Sliding Window Sum Algorithms for Deep Neural Networks
###### Abstract
Sliding window sums are widely used for string indexing, hashing and time series analysis. We have developed a family of the generic vectorized sliding sum algorithms that provide speedup of \(O(P/w)\) for window size \(w\) and number of processors \(P\). For a sum with a commutative operator the speedup is improved to \(O(P/log(w))\). Even more important, our algorithms exhibit efficient memory access patterns.
In this paper we study the application of the sliding sum algorithms to the training and inference of the Deep Neural Networks. We demonstrate how both pooling and convolution primitives could be expressed as sliding sums and evaluated by the compute kernels with the shared structure.
We show that the sliding sum convolution kernels are more efficient than the commonly used GEMM kernels on the CPU, and could even outperform their GPU counterparts.
## 1 Introduction
A Deep Neural Network (DNN) is one of the most significant tools in the arsenal of the machine learning (ML) researcher [9]. DNNs are constructed from multiple layers that transform the data sequentially via operations such as pooling, convolution, and activation. In most successful DNNs the great portion of computational resources is consumed performing convolution.
A common approach to implementing convolutional layers is to expand the input into a column matrix (_im2col_) and then call a highly tuned General Matrix Multiplication (GEMM) procedure from the existing linear algebra library such as BLIS [13] or MKL [15]. Since the hardware optimized GEMM implementations exist for every standard CPU, graphics processing unit (GPU), or digital signal processor (DSP), the _im2col_ approach has been highly successful in DNN frameworks such as Caffe [8], ONNX [2] and Torch [5]. The popularity of the _im2col_ tactics also influences the design of the custom hardware marketed as ML accelerators that are in fact the GEMM accelerators.
The major disadvantages of the _im2col_ conversion are the greatly increased memory footprint of the input matrix and the reduced data locality. For a convolution with a filter size k, the column matrix is k times larger than the original input. A lot of effort has been put into remediating this problem. A mainstream approach is converting input to the low precision floating point or even integer representation [6]. The quantization techniques reduce the memory footprint and latency by an order of magnitude and even influence the design of the GEMM accelerators. It is important to note though that the quantization is not entangled with GEMM and could be equally successfully applied to the original convolution problem. Yet another research trend is applying the GEMM routines to the smaller intermediate data structures [1][14]or even to the original input data [16].
We propose an approach that replaces GEMM with a new kind of the computation kernel that operates on the unmodified input.
## 2 Methods
### Prefix Sum
At the foundation of our method is the concept of a _prefix sum_, and the accompanying _reduce_ and _scan_ algorithms. A prefix sum is a transformation that takes an operator \(\oplus\), and a sequence of elements
\[x_{0},x_{1},\ldots,x_{k},\ldots\]
and returns the sequence
\[y_{i}=\sum_{j=0}^{i}x_{j}=x_{0}\oplus x_{1}\oplus\ldots\oplus x_{i} \tag{1}\]
or in recurrent form
\[y_{i+1}=y_{i}\oplus x_{i+1} \tag{2}\]
Despite the data carry dependency, the \(Nth\) element of the prefix sum with an associative operator could be computed in \(O(log(N))\) parallel steps using _reduce_ algorithm. Even stronger statement is that all \(N\) elements of the prefix sum could be computed in the same \(O(log(N))\) parallel steps using _scan_ algorithm, as shown by [3].
### Sliding Window Sum
Sliding window sum (sliding sum) takes a window size \(w\) in addition to an operator \(\oplus\), and a sequence of elements, and returns the sequence
\[y_{i}=\sum_{j=i}^{i+w-1}x_{j}=x_{i}\oplus x_{i+1}\oplus\ldots\oplus x_{i+w-1} \tag{3}\]
where each sum is defined in terms of the operator \(\oplus\) and contains exactly \(w\) addends. The asymptotic complexity of a naive sliding sum algorithm is \(O(wN)\) where \(N\) is the length of the source sequence.
Every sum defined by Equation 3 is a prefix sum with operator \(\oplus\) and input sequence \(x_{i}\ldots\oplus x_{i+w-1}\). Many useful operators are associative, so the prefix scan algorithm is applicable here, reducing complexity of every sum in Equation 3 to \(O(log(w))\) and, trivially, the overall sliding sum complexity to \(O(Nlog(w))\) parallel steps.
While working on the bioinformatics applications, we have used sliding window sums to represent the minimizer seeds and have developed a family of algorithms to achieve better parallel speedups [11]. Now we will apply the same approach to the DNN operators.
### Pooling
The average pooling operator is trivially the sliding window sum with the associative operator \(+\). By analogy, the max pooling operator is a sliding window sum with the associative operator \(max\). Implementing the sliding pooling operator could be a warm-up before concentrating on the convolution.
### Dot Product
As a corollary we will show that a dot product is a prefix sum. Dot product of the two vectors of length \(M\) is defined as:
\[c=\sum_{i=0}^{M-1}a_{i}b_{i} \tag{4}\]
First, we replace vectors \(a\) and \(b\) with vectors \(\alpha\) and \(\beta\) so that:
\[\alpha_{i}=\begin{cases}1,&a_{i}=0\\ a_{i},&otherwise\end{cases},\beta_{i}=\begin{cases}0,&a_{i}=0\\ b_{i},&otherwise\end{cases} \tag{5}\]
It holds that
\[\sum_{i=0}^{M-1}\alpha_{i}\beta_{i}=\sum_{i=0}^{M-1}a_{i}b_{i} \tag{6}\]
Next, we define a sequence of \((M+1)\) pairs,
\[\gamma_{i}=\begin{pmatrix}u_{i}\\ v_{i}\end{pmatrix},\quad where\quad u_{i}=\begin{cases}1,&i=0\\ \frac{\alpha_{i-1}}{\alpha_{i}},&0<i<M\;,\quad and\quad v_{i}=\begin{cases}\beta _{i},&i<M\\ 0,&i=M\end{cases} \tag{7}\]
and the operator \(\oplus\) such that
\[\gamma_{i}\oplus\gamma_{j}=\begin{pmatrix}u_{i}\\ v_{i}\end{pmatrix}\oplus\begin{pmatrix}u_{j}\\ v_{j}\end{pmatrix}=\begin{pmatrix}u_{i}\bullet u_{j}\\ u_{j}\bullet v_{i}+v_{j}\end{pmatrix} \tag{8}\]
Operator \(\oplus\) is associative [3], and the sequence
\[\delta_{i}=\begin{cases}\gamma_{0},&i=0\\ \delta_{i-1}\oplus\gamma_{i},&0<i\leq M\end{cases} \tag{9}\]
is a prefix sum. The bottom element of the last sum \(\delta_{M}\) is the original dot product, and \(\delta_{M}\) could be evaluated using reduce algorithm in \(log(M)\) parallel steps of fused multiply-add (FMA) operations. The total work is still \(M\). The important result here is representing dot product as a prefix sum in preparations for the sliding window implementation of the convolution.
### Convolution
Convolution is a sliding window sum (dot product) with the associative operator defined by equation 8. Consequently our family of the sliding window algorithms is applicable to the convolution operator.
## 3 Algorithms
### Vector Algorithms
Our first algorithm is a vector-friendly way of calculating sliding sum assuming the input sequence elements become available one by one and are processed using the vector instructions of width \(P>w\):
```
procedureScalarInput(\(x_{0}\dots x_{n-1}\)) \(Y\leftarrow\Big{(}\underbrace{w^{-2}}_{j=0}x_{j},\sum_{j=1}^{ w-2}x_{j},\dots,x_{w-3}\oplus x_{w-2},x_{w-2},\dots,0\Big{)}\) for\(i=w-1\) to N do \(X\leftarrow\Big{(}\underbrace{x_{i},x_{i},\dots,x_{j}}_{w},0,\dots,0\Big{)}\) \(Y\gets Y\oplus X\) \(y_{i-w+1}\gets Y[0]\) \(Y\gets Y\lll 1\) endprocedure
```
**Algorithm 1** Scalar Input
Vector Y is initialized to the suffix sums with the number of elements decreasing from \(w-1\) to \(0\). Then in a loop every incoming element \(x_{k}\) is broadcast to the first \(w\) elements of vector X. After vector addition the zeroth element of Y contains the next sliding sum. Next, the vector Y is shifted left by one element, as denoted by operator \(\lll\), and the state is ready for the next iteration.
Asymptotic complexity of the scalar input algorithm is \(O(N)\) with no additional requirements on the operator \(\oplus\).
This result could be improved if we assume that the input sequence arrives packed in vectors of width \(P>w\).
At every iteration \(P\) input elements are placed into vector \(X\). X1 is filled with the prefix sums of up to \(w\) addends, and Y1 is filled with the suffix sums constructed from the elements of \(X\). Then the vector sum of \(Y\) and \(X1\) yields the
next P output elements. Finally, the suffix sums from \(Y1\) are shifted into proper positions in vector \(Y\), and it is ready for the next iteration.
The asymptotic complexity thus is \(O(N\cdot w/P)\) with the parallel speedup \(O(P/w)\) for any operator \(\oplus\). If \(\oplus\) is associative, the prefix/suffix sums could be computed in parallel using the algorithm in [3], and the complexity is reduced to \(O(N\cdot log(w)/P)\) with the speedup improving to \(O(P/log(w))\).
For example, since \(min\) is an associative operator, the sliding window minimum can be computed using the faster version of the vector input algorithm.
One might notice that the suffix sum computation utilises only \(w-1\) out of \(p\) elements of vector \(Y1\). Eliminating this inefficiency leads to the Ping Pong algorithm where both suffix and prefix sums yield some elements of the output sequence.
The Ping Pong algorithm does not offer any asymptotic improvements but is 30-50% faster in practice. It however accesses memory in strides unaligned to \(P\), and the two memory loads per iteration present a challenge while implementing boundary conditions like padding, mirroring, or periodicity.
A simpler algorithm could be formulated in terms of the Slide operation that extracts a vector from the concatenation of the two inputs. It directly maps to the **EXT** instruction from the ARM SVE instruction set [12], and is easily implemented via appropriately named **vsilideup/down** instructions of the RISC-V vector extension [10], or the **vperm*2ps** Intel AVX512 instructions [7]. Similar to the previous algorithms, if \(\oplus\) is associative, the inner loop could be replaced by the parallel reduction for maximum parallel speedup.
## 4 Experiments
We have implemented the sliding window convolution as an alternate execution path in the ONNX framework [2]. Figure 1 shows the achieved speedup when compared to the baseline --emphMlasConv procedure applied to the large 1-D input and the filters of various sizes. The speedup is approximately proportional to the logarithm of the kernel size.
Additionally, we have recreated the scenario for the very large dilated kernel described in [4]. We have achieved up to 6.8x speedup on the small data set and around 4x speedup across the board approaching the GPU performance numbers.
```
procedurePingPong(\(x_{0}\dots x_{N-1}\)) for\(i=0\) to N step 2P-w+1 do \(Y\leftarrow\left(x_{i},x_{i+1},\dots,x_{i+p-1}\right)\) \(X\leftarrow\left(x_{i+P},x_{i+P+1},\dots,x_{i+2P-1}\right)\) \(Y1\leftarrow\Big{(}\underbrace{w-1}_{j=0}^{w-1}Y[j],\sum_{j=1}^{w}Y[j],\dots, \sum_{j=P-w}^{P-1}Y[j],\sum_{j=P-w}^{P-1}Y[j],\dots,Y_{P-1}\Big{)}\) \(y_{i}\dots y_{i+P-w}\gets Y[0]\dots Y[P-w]\) \(Y1\gets Y1\lll(P-w)\) \(X1\leftarrow\Big{(}\underbrace{X[0],X[0]\oplus X[1],\dots,\sum_{j=0}^{w-2}X[j],\sum_{j=0}^{w-1}X[j],\dots,\sum_{j=p-w}^{P-1}X[j]\Big{)}\) \(Y1\gets Y1\oplus X1\) \(y_{i+P-w+1}\dots y_{i+2P-w}\gets Y[0]\dots Y[P-1]\) endfor endprocedure
```
**Algorithm 3** Ping Pong
```
procedureSlide(\(Y1,Y2,offset\)) \(Y\gets CONCAT(Y1,Y2)\) return\(\big{(}\underbrace{Y[offset],Y[offset+1],\dots,Y[offset+P-1]}_{P}\big{)}\) endprocedureprocedureVectorSlide(\(x_{0}\dots x_{N-1}\)) \(Y\leftarrow(x_{0},x_{1},\dots,x_{P-1})\) for\(i=P\) to \(N\) step \(P\)do \(Y1\leftarrow\Big{(}x_{i},x_{i+1},\dots,x_{i+p-1}\Big{)}\) \(X\gets Y1\) for\(k=1\) to \(w-1\)do \(X\gets X\oplus\)Slide(\(Y,Y1,P-k\)) endfor \(y_{i}\dots y_{i+p-1}\gets X[0]\dots X[p-1]\) \(Y\gets Y1\) endfor endprocedure
```
**Algorithm 4** Vector Slide
## 5 Conclusion
We have demonstrated excellent performance of the Sliding Sum algorithms using the commodity hardware without the need for the specialized accelerators. Despite the promising results, there is plenty of work ahead.
The most obvious next step is extending the sliding convolution approach to more than one dimension covering the majority of the DNN applications.
The most common filter sizes in the DNN applications are 3 an 5 in every dimension. With the filter this small the current sliding convolution algorithms demonstrate very modest speedup since the number of the arithmetic instructions per the memory load is low. The situation improves in the multiple dimensions but still could require custom compute kernels for the small filter sizes.
Lastly, since the accelerators for the matrix multiplication are already present in the current generation of the hardware, it would be wise re-using them. Thus, it is important to re-formulate our algorithms in terms of the small matrix multiplication completing the circle.
|
2306.12231 | Predicting protein variants with equivariant graph neural networks | Pre-trained models have been successful in many protein engineering tasks.
Most notably, sequence-based models have achieved state-of-the-art performance
on protein fitness prediction while structure-based models have been used
experimentally to develop proteins with enhanced functions. However, there is a
research gap in comparing structure- and sequence-based methods for predicting
protein variants that are better than the wildtype protein. This paper aims to
address this gap by conducting a comparative study between the abilities of
equivariant graph neural networks (EGNNs) and sequence-based approaches to
identify promising amino-acid mutations. The results show that our proposed
structural approach achieves a competitive performance to sequence-based
methods while being trained on significantly fewer molecules. Additionally, we
find that combining assay labelled data with structure pre-trained models
yields similar trends as with sequence pre-trained models.
Our code and trained models can be found at:
https://github.com/semiluna/partIII-amino-acid-prediction. | Antonia Boca, Simon Mathis | 2023-06-21T12:44:52Z | http://arxiv.org/abs/2306.12231v2 | # Predicting protein variants with
###### Abstract
Pre-trained models have been successful in many protein engineering tasks. Most notably, sequence-based models have achieved state-of-the-art performance on protein fitness prediction while structure-based models have been used experimentally to develop proteins with enhanced functions. However, there is a research gap in comparing structure- and sequence-based methods for predicting protein variants that are better than the wildtype protein. This paper aims to address this gap by conducting a comparative study between the abilities of equivariant graph neural networks (EGNNs) and sequence-based approaches to identify promising amino-acid mutations. The results show that our proposed structural approach achieves a competitive performance to sequence-based methods while being trained on significantly fewer molecules. Additionally, we find that combining assay labelled data with structure pre-trained models yields similar trends as with sequence pre-trained models.
Our code and trained models can be found at: [https://github.com/semiluna/partIII-amino-acid-prediction](https://github.com/semiluna/partIII-amino-acid-prediction).
Machine Learning, ICML
## 1 Introduction
In recent years, pre-trained models have garnered significant attention in the field of protein representation. Notably, models have been developed to deal with both the sequence and structure modalities of proteins (Rives et al., 2021; Elnaggar et al., 2022; Zhang et al., 2023). These models have demonstrated their potential in various applications such as protein fitness prediction (Meier et al., 2021; Notin et al., 2022) while being employed in a "zero-shot" manner, without the need for additional training data. Their success has also shown promising experimental results in protein engineering (Shroff et al., 2020; Lu et al., 2022). Additionally, Hsu et al. (2021) have observed that augmenting simple models for assay labelled data with fitness predictions extracted from pre-trained sequence models can enhance their performance.
Despite the experimental success of pre-trained structural methods for protein engineering, particularly those based on predicting residues given local atom environments (Torng and Altman, 2017; Lu et al., 2022), several crucial aspects remain unexplored. Firstly, these methods have not been systematically compared with sequence-based approaches using the same datasets. Secondly, their potential to augment assay labelled data, when available, has not been evaluated.
This paper aims to fill this research gap by conducting a study of the comparative performance of structure-based and sequence-based methods on predicting variants _that are better than the wildtype protein_. We compare representatives of the most successful equivariant graph neural networks (EGNNs) on the task of residue identity prediction, namely GVP (Jing et al., 2021) and EQGAT (Le et al., 2022), with representatives of the most successful sequence-based approaches: Tranception (Notin et al., 2022), ESM-1v (Meier et al., 2021) and the MSA Transformer (Rao et al., 2021).
By undertaking this comparative analysis, we aim to provide insights into the performance and suitability of geometric GNNs in protein engineering, specifically in the context of predictions based on the local atomic environment. Our contributions are as follows:
* We apply the most successful pre-training approach for structural methods (Shroff et al., 2020) to equivariant GNNs by using the ATOM3D RES dataset (Townsend et al., 2022) for residue identity prediction (Table 1);
* We benchmark the resulting structure-based pre-trained models with the most successful zero-shot sequence-based approaches (Table 2). We observe that structure does not trump sequence in downstream tasks when used in this way, although the amount of available structures used during pre-training is significantly lower than the number of sequences used in training large language models;
* We extend the simple combination approach for assay labelled data and pre-trained model outputs (Hsu et al., 2021) to the structure pre-trained domain. We find the same general trends as with sequence pre-trained models, as assay-labelled data quickly allows us to surpass zero-shot pre-trained sequence-based models with at few as 100 datapoints (Figure 2).
## 2 Methodology
We pre-train two equivariant graph neural networks on the task of residue identity prediction, also known as the RES task (Townshend et al., 2022). We choose the Geometric Vector Perceptron (Jing et al., 2021) and the Equivariant Graph Attention Network (Le et al., 2022). While Lu et al. (2022) used 3D-CNNs to engineer plastic enzymes, Jing et al. (2021) benchmark 3D-CNNs on the RES task and show that the GVP outperforms them, so we choose to focus on this structural method instead.
Table 1 shows a comparison between the reported accuracies of the two models and the accuracies achieved in this paper. We achieve a higher performance on the GVP model than originally reported in Jing et al. (2021). This jump in performance can be explained by the fact that Jing et al. (2021) only use a third of the original training dataset to train the GVP, possibly due to computational constraints. More details on our training parameters can be found in A.9.
### RES task formalism
We formalise the RES classification task as follows. For a given point-cloud atomic graph \(G=(V,E)\) with nodes \(i,j\in V\) and edges \((i\to j)\in E\). Given a node \(t\in V\) representing the \(\text{C}_{\alpha}\) of a residue in the atomic graph, we can define the _node classification function_\(\text{RES}:\mathcal{V}\times\mathcal{G}\rightarrow\mathbb{R}^{20}\) that takes as input node \(t\) and a _masked_ atomic graph \(G_{t}\) from which we have removed the side-chain atoms of node \(t\) and returns the likelihood scores of each of the 20 naturally occurring amino-acids to be part of the side-chain of node \(t\). A more extended version of this formalism can be found in A.1.
### The scoring function
We now formalise the function we use to score each amino-acid mutation in a sequence. For a wildtype protein sequence \(x_{1}\dots x_{n}\) with \(x_{i}\in\mathcal{A}=\{1,2,\dots,20\}\) we associate the point-cloud atomic graph \(G=(V,E)\) corresponding to the protein's structure. Edges are drawn between any two atoms that are less than 4.5A apart.
Then, using the formalism defined in 2.1, the score associated with the presence of amino-acid \(a\in\mathcal{A}\) at position \(i\) can be defined as:
\[S(i,a)=[\text{RES}(g(i),G)]_{a} \tag{1}\]
Where \(g:\{1,2,\dots,n\}\rightarrow\{1,2,\dots,|V|\}\) is a mapping function from positions to the index of the node representing the central \(\text{C}_{\alpha}\) of the amino-acid residue present at each position. Here, \(G_{g(i)}\) denotes the masked graph from which we removed the side-chain attached to node \(g(i)\).
Equation 1 essentially represents the score of amino-acid \(a\) for target position \(i\), associated with node \(g(i)\) in the atomic graph. Note that the true amino-acid at the same position is denoted by \(x_{i}\).
### Mutation generation
Once the equivariant models have been trained on the RES task, we use them to inform the generation of single-point mutations in monomers and homo-oligomers from the ProteinGym substitutions dataset (Notin et al., 2022). For each wildtype sequence we recover its structure, mask each amino-acid residue in turn, and retrieve the scores generated by the EGNN model for each of the 20 naturally occuring amino-acids. These scores are then ranked according to two strategies to determine the most promising single-point mutations. Figure 1 illustrates this approach visually.
Structure recovery.The ProteinGym substitutions dataset contains 87 molecular sequences; for each of these sequences, a number of experimentally tested mutations are scored according to their _fitness_. We evaluate our methods
\begin{table}
\begin{tabular}{l c c} \hline \hline Model & Reported & Our \\ & test accuracy & test accuracy \\ \hline EQGAT & 0.540 & 0.524 \\ GVP & 0.527 & **0.580** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Classification accuracies on the ATOM3D RES dataset.
Figure 1: For every sequence, we recover the structure from the PDB and mask each amino-acid in turn. We pass the masked graph through a pre-trained EGNN model to recover the score associated with each amino-acid, which we then rank. The key idea is that this pre-training allows the model to identify amino acids which seem “unusual” given their local environment and propose better fitting candidates instead.
on a subset of the original dataset for which we could find either monomeric or homo-oligomeric structures. For each wildtype sequence, we recover the corresponding biological assembly from the Protein Data Bank (Berman et al., 2000). When multiple assemblies are available, we choose one at random. When assemblies are incomplete, we instead use the monomeric AlphaFold prediction (Jumper et al., 2021) if available. Otherwise, we discard the sequence.
### Mutation ranking
Our approach allows us to score every possible residue mutation for each position in a sequence. Our goal is to generate meaningful mutations that have a higher chance of being bio-physically relevant, so we discard positions where the equivariant model makes the wrong prediction. A more detailed analysis of this design choice can be found in Appendix A.4.
Global ranking.We rank the remaining mutations according to two strategies: _global_ and _positional_. When performing global ranking, we sort mutations in descending order of their score, regardless of their position. If we denote the single-point mutation to amino-acid \(a\) at position \(i\) by \(\mathbf{m}_{i}^{a}\), then \(\forall i,j\) and \(\forall a,b\in\mathcal{A}\) s.t. \(a\neq x_{i}\) and \(b\neq x_{j}\), we say that:
\[\mathbf{m}_{i}^{a}\text{ is better than }\mathbf{m}_{j}^{b}\iff S(i,a)>S(j,b) \tag{2}\]
Positional ranking.The second approach follows when we prioritise the positions we want to mutate instead of the amino-acids we mutate to. Formally, this can be quantified as:
\[\begin{split}&\mathbf{m}_{i}^{a}\text{ is better than }\mathbf{m}_{j}^{b}\\ \iff&\Big{(}S(i,x_{i})<S(j,x_{j})\Big{)}\vee\\ &\Big{(}S(i,x_{i})=S(j,x_{j})\wedge S(i,a)>S(j,b)\Big{)}\end{split} \tag{3}\]
Note that when we perform positional ranking, we only keep the 3 top mutations for each position.
### Protein fitness prediction
The GVP and EQGAT trained on the ATOM3D RES task can be thought of as unsupervised models that can suggest amino-acid mutations. We extend our original approach to perform fitness prediction using a ridge regression model augmented with the positional scores generated by equivariant GNNs, in a similar manner to that introduced by Hsu et al. (2021). For a given sequence of amino-acids \(x_{1}\dots a_{i}\dots x_{n}\) with a single-point mutation at position \(i\), we embed each amino-acid using either the one-hot encoding or _AAIndex_ embeddings (Kawashima et al., 1999) on which we perform PCA to render 19-dimensional features per amino-acid. We flatten and concatenate these encodings to render feature vectors \(\mathbf{h}_{\text{one-hot}}\in\mathbb{R}^{20\times n}\) and \(\mathbf{h}_{\text{aa-index}}\in\mathbb{R}^{19\times n}\). To this feature vector we concatenate the score predicted by the GNN model for amino-acid \(a_{i}\) at position \(i\):
\[\mathbf{x}_{\text{one-hot}} =[\mathbf{h}_{\text{one-hot}}\mid\mid S(i,a_{i})] \tag{4}\] \[\mathbf{x}_{\text{aa-index}} =[\mathbf{h}_{\text{aa-index}}\mid\mid S(i,a_{i})] \tag{5}\]
Here, \(S(i,a_{i})\) is the same scoring function defined in Equation 1. These features are then used to train a ridge regression model to predict protein fitness using subsets of single-point mutated sequences for each of the ProteinGym DMS assays we have model scores for.
## 3 Results
### Mutation generation
We generate single-point mutations for 49 out of the 87 DMS assays in the ProteinGym substitutions dataset (Notin et al., 2022). When we generate mutations, we discard any that we cannot find in the experimental dataset of the target sequence. We are interested in understanding how good our models are at suggesting mutations that are _better than the wildtype_ sequence, hence we propose three metrics through which to perform comparisons: (1) Spearman's rank correlation restricted to better than wildtype sequences, (2) the precision of the top 10 mutations, and (3) the recall of the top 10 mutations. To compute the last two metrics we only considered whether a mutation proposed by the model is better than the wildtype, disregarding its actual score. Table 2 shows the performance of our models, depending on the type of ranking used. We note that the equivariant models have a competitive performance to Tranception (Notin et al., 2022) when ranking mutations that are better than the wildtype, indicating that they represent a viable strategy for aiding the discovery process in protein engineering. Per-dataset performance metrics can be found in A.2.
EGNN models require a significantly smaller number of protein structures during training in order to reach a similar ranking correlation coefficient to Tranception for mutations that are better than the wildtype. While Tranception is trained on the UniRef100 database (Suzek et al., 2015), which contains over 4 million source sequences, our models are trained on the ATOM3D RES dataset (Townshend et al., 2022), which contains fewer than 22k molecules from which local environments are sampled.
Structure vs Sequence.We believe EGNNs may require less training because structure is more informative than sequence for fitness prediction. While sequence-based models attend the full protein and subsequently learn to focus on the important bits, EGNNs attend only local environments, thus learning to identify important atoms faster. Further experiments could be run to compare the power of sequence
and structure-based models when their level of training is comparable. However, we point out that training EGNNs to the same level as present state-of-the-art sequence models may be infeasible due to both data and computational constraints.
Correlation to sequence-based models.As part of our analysis, we also compute the correlation between the better than wildtype predictions made by our EGNN models and Tranception. Per-model and per-dataset statistics can be found in A.3; we note that the highest rank correlation we find is **0.212**, in the case of the EQGAT model. Since these approaches seem to be weakly correlated, we believe there are improvements to be gained from ensembling both structure- and sequence-based approaches.
The impact of design choices.As mentioned in Section 2.4, we discard mutations at positions where the EGNNs make the wrong prediction, as we find that incorporating these is detrimental to the overall performance (see A.4). This indicates that these structure-based models are still undertrained, with potential for improvement coming both from larger datasets and more data engineering.
### Protein fitness prediction
We train 4 types of ridge regression models on each of the 49 DMS datasets separately. The baseline non-augmented model uses only features \(\mathbf{h}_{\text{one-hot}}\) or \(\mathbf{h}_{\text{aa-index}}\) defined in Section 2.5; the remaining 3 models are augmented with single-point mutation scores from GVP, EQGAT, and Tranception, respectively. For each model type and each DMS array we first set aside 20% of the single-point mutated sequences for testing; We train the regression on increasingly larger training subsets. We repeat the process 20 times with different random subsets and report the average Spearman rank correlation on better than wildtype sequences, as seen in Figure 2. The performance on other metrics can be found in A.8.
Similar to the results reported by Hsu et al. (2021), the augmented linear models allow us to surpass the baseline zero-shot fitness prediction models with as few as 100 datapoints in the case of the model augmented with EQGAT scores. While the linear model augmented with Tranception scores performs best overall, we point out that Tranception is fine-tuned to predict protein fitness, while the scores retrieved from our models merely represent the confidence in a certain amino-acid for a target position.
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline Model & Ranking strategy & \begin{tabular}{c} Top 10 \\ precision \\ \end{tabular} &
\begin{tabular}{c} Top 10 \\ recall \\ \end{tabular} & \multicolumn{4}{c}{Spearman’s rank correlation} \\ \cline{3-6} & & & Average & Worse than WT & Better than WT \\ \hline EQGAT & Positional & 0.486 & 0.187 & 0.223 & 0.128 & 0.118 \\ EQGAT & Global & 0.491 & 0.072 & 0.262 & 0.154 & 0.157 \\ GVP & Positional & 0.462 & **0.419** & 0.106 & \(-0.009\) & **0.276** \\ GVP & Global & 0.426 & 0.100 & 0.202 & 0.128 & \(-0.011\) \\ \hline Tranception & & 0.619 & 0.012 & 0.429 & 0.299 & 0.143 \\ ESM-1v & & 0.618 & 0.018 & 0.407 & 0.288 & 0.135 \\ MSA Transformer & & **0.638** & 0.018 & **0.434** & **0.327** & 0.135 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Ranking performance of the models across 49 DMS assays. Numbers in **bold** represent the highest score per column, while numbers with an underline represent the second highest score per column. We note that two equivariant GNNs have the highest rank correlation for better than wildtype mutations.
Figure 2: Performance on mutations that are better than the wildtype for four regression models using two types of embeddings. Statistics are aggregated across 49 DMS assays. We note that we can improve the fitness prediction performance above the Tranception baseline (in black) across all regression models by training on as few as 144 data points.
## 4 Limitations and future work
We apply pre-trained EGNNs to both mutation generation and protein fitness prediction, and find that structural approaches are a competitive approach to sequence-based language models for the prediction of mutations that are better than the wildtype, while also requiring **181x** fewer molecules to train.
While the results look promising, this comparison is limited in scope, as our approach does not deal with more complex (hetero-oligomeric) structures from the ProteinGym dataset.
Types of fitness.Additionally, the benchmarking dataset contains a wide range of sequences for which "fitness" can be interpreted in many different ways. DMS assays in the ProteinGym dataset come from humans, viruses, prokaryotes, and eukaryotes. In particular, in the subset of 49 DMS assays used in this paper, **5** come from eukaryotes, **21** from humans, **18** from prokaryotes, and **5** from viruses. Fitness, in the case of viruses, is interpreted as infectivity or the likelihood of mutation. In the rest of the cases, fitness can range from stress resistance to efficiency. For example, in their experimental paper, Lu et al. (2022) focused on improving thermal stability. Hence, the fitness score used by Notin et al. (2022) in the ProteinGym dataset represents a "fuzzy" concept that is context-dependent. Future work could focus more closely on identifying the types of fitness structure-based approaches excel at.
AcknowledgementsSVM was supported by the UKRI Centre for Doctoral Training in Application of Artificial Intelligence to the study of Environmental Risks (EP/S022961/1).
|
2307.13206 | Transferability of Graph Neural Networks using Graphon and Sampling
Theories | Graph neural networks (GNNs) have become powerful tools for processing
graph-based information in various domains. A desirable property of GNNs is
transferability, where a trained network can swap in information from a
different graph without retraining and retain its accuracy. A recent method of
capturing transferability of GNNs is through the use of graphons, which are
symmetric, measurable functions representing the limit of large dense graphs.
In this work, we contribute to the application of graphons to GNNs by
presenting an explicit two-layer graphon neural network (WNN) architecture. We
prove its ability to approximate bandlimited graphon signals within a specified
error tolerance using a minimal number of network weights. We then leverage
this result, to establish the transferability of an explicit two-layer GNN over
all sufficiently large graphs in a convergent sequence. Our work addresses
transferability between both deterministic weighted graphs and simple random
graphs and overcomes issues related to the curse of dimensionality that arise
in other GNN results. The proposed WNN and GNN architectures offer practical
solutions for handling graph data of varying sizes while maintaining
performance guarantees without extensive retraining. | A. Martina Neuman, Jason J. Bramburger | 2023-07-25T02:11:41Z | http://arxiv.org/abs/2307.13206v2 | # Transferability of Graph Neural Networks using Graphon and Sampling Theories
###### Abstract
Graph neural networks (GNNs) have become powerful tools for processing graph-based information in various domains. A desirable property of GNNs is transferability, where a trained network can swap in information from a different graph without retraining and retain its accuracy. A recent method of capturing transferability of GNNs is through the use of graphons, which are symmetric, measurable functions representing the limit of large dense graphs. In this work, we contribute to the application of graphons to GNNs by presenting an explicit two-layer graphon neural network (WNN) architecture. We prove its ability to approximate bandlimited signals within a specified error tolerance using a minimal number of network weights. We then leverage this result, to establish the transferability of an explicit two-layer GNN over all sufficiently large graphs in a sequence converging to a graphon. Our work addresses transferability between both deterministic weighted graphs and simple random graphs and overcomes issues related to the curse of dimensionality that arise in other GNN results. The proposed WNN and GNN architectures offer practical solutions for handling graph data of varying sizes while maintaining performance guarantees without extensive retraining.
**Key words:** graphon, regularized sampling, graph neural network, transferability, random graph, curse of dimensionality
###### Contents
* 1 Introduction
* 2 Preliminaries
* 2.1 Graph Neural Networks
* 2.2 Graphons
* 2.3 Graphon neural networks
* 2.4 Bandlimited graphon signals and sampling
* 2.5 WNN and GNN architectures enabled by the sampling theory
* 3
Main Results
* 3.1 A uniform sampling theorem
* 3.2 Generalization using WNNs
* 3.3 Generalization on graphs and GNN-transferability
* 3.4 Ramifications of the results
* 4 Proof of Theorem 3.1
* 4.1 A regularized sampling result
* 4.2 Sampling with \(\mathcal{G}_{r,\sigma}\)
* 5 Proof of Theorem 3.2
* 5.1 Proof of Lemma 5.1
* 5.2 Proof of Lemma 5.2
* 6 Proof of Theorem 3.3
* 6.1 Proof of Lemma 6.1
* 7 Proof of Theorem 3.4
* 8 Discussion
* A Proofs of Proposition 2.1 and Lemma 2.1
## 1 Introduction
Falling under the category of geometric deep learning models [10], graph neural networks (GNNs) have become a powerful tool for processing information that can be represented on graphs [40, 53, 60]. GNNs are a class of neural networks that incorporate an underlying graph topology to facilitate information exchange among neighboring vertices; they have been applied to a variety of different domains including natural language processing [59], chemistry [21, 24, 30], citation networks [5, 15, 26], and recommender systems [22, 23, 28, 46, 47, 48, 60]. GNNs have been shown to outperform the predictive power of traditional neural networks [2, 38] and can generalize bandlimited functions using far fewer network weights than the best-known results for deep neural networks [43]. For a more complete introduction to the theory and application of GNNs see the review [61].
When it comes to GNNs, one of the most desirable properties is that of _transferability_. In this context transferability means that a GNN can be transported between different graphs without re-training, with performance guarantees. A simple example of transferability would be providing robustness guarantees on a GNN when there are alterations in the underlying edge or weight structure, measured by a suitable metric. Beyond just manipulating the edge structure of a graph, one can similarly ask for transferability between graphs of different sizes. An important example of when one would desire such transferability comes from recommender systems. In this case the vertices of the network represent
users/subscribers, while edge weights could represent a similarity measure between them. The goal is to leverage the knowledge of one user's taste or interests to curate recommendations for users deemed similar. In this situation one should expect the number of users to vary frequently as new ones sign up for the platform and others end their subscriptions. Certainly, one does not want to re-train a recommender neural network each time a user is added or lost, especially since all of the structure in the graph remains the same between users who continue on the platform. Thus, one seeks to identify a single GNN architecture that exhibits transferability between these similar user networks with varying numbers of vertices.
To achieve transferability of GNNs over similar networks of different sizes, [48] introduced the concept of a _graphon neural network_ (WNN). The key ingredient is a graphon - a symmetric, measurable function \(W:[0,1]^{2}\rightarrow[0,1]\) that can be used to represent the limit of large dense graphs as the number of vertices tends to infinity [6, 25, 29, 36]. Members of a sequence of graphs converging to a graphon \(W\) can be seen as sharing structural characteristics, despite not being of the same size, much along the line of our motivating example of recommender systems. The ability for graphons to capture similarity of graphs of different sizes was employed in [48] to prove transferability of GNNs for sufficiently large graphs coming from the same sequence that converges to a graphon.
Graphons continue to be employed to capture transferability and other desirable properties of GNNs. The work [39] uses graphons to prove transferability of spectral graph neural networks, while GNN stability with respect to graphon and graph perturbations has also been investigated [31, 52]. Transferability results are examined experimentally in [51] where GNNs are trained on moderately sized graphs and then transferred to large graphs to evaluate theoretical performance guarantees. Graphons have also been estimated from data to train GNNs [27], and used to perform pooling and sampling in GNNs, with the latter application demonstrating that graphon pooling GNNs are less prone to overfitting [45]. While the concept of a WNN primarily exists in theory to describe transferability, [13] proposes a technique for learning a WNN by training GNNs on growing networks sampled from the graphon. Finally, there is also an emerging literature of signal processing using graphons [42, 49, 50, 52] that is particularly useful in describing structurally-similar graph signals over varying network sizes that are used to train GNNs.
In this work we contribute to the emerging application of graphons to data science by providing an explicit two layer WNN architecture and proving that it can approximate a bandlimited signal within an \(\varepsilon>0\) error tolerance using \(\mathcal{O}(\varepsilon^{-10/9})\) network weights. This result is then leveraged to prove transferability of an explicit two layer GNN among all sufficiently large graphs in a sequence converging to a graphon. In particular, transferability is accounted for between both simple deterministic weighted graphs and simple random graphs that belong to the same graphon family, of which the latter is often overlooked in the WNN literature. Importantly, graphons allow us to circumvent any issues related to the curse of dimensionality, and in particular, keep the number of layers bounded independently of \(\varepsilon\). This is because graphons embed data into the one-dimensional interval \([0,1]\). The reader should compare with similar results on approximating bandlimited functions on
high-dimensional domains [14, 41], where one requires the numbers of weights and layers to become unbounded as \(\varepsilon\to 0^{+}\).
Our restriction to bandlimited functions enables a sampling result that motivates the WNN architecture we present herein, and builds upon a growing literature on the ability of neural networks to approximate bandlimited functions [14, 17, 41, 43, 44, 57, 58]. Further, we consider bandlimited functions in the traditional sense that they are a linear combination of only finitely many Fourier modes. This is different from some emerging related literature where bandlimited signals replace the Fourier modes with eigenfunctions of the underlying graphon or manifold [50, 58]. In practice one rarely has access to the graphon and graphon signals beyond finitely-many samples of them and so we view working with Fourier bandlimited functions as potentially more practical. Nonetheless, we note that in the case of graphons that only depend on the distance \(|x-y|\) (so-called ring graphons) the eigenfunctions are exactly the Fourier modes [9], causing the bandlimited definitions to coincide.
We summarize our results in this paper as follows:
1. We prove a sampling theorem that gives an explicit reconstruction of bandlimited functions on \([0,1]\), with a subgeometric convergence rate, and provides a foundation for our WNN and GNN architectures.
2. Informed by our sampling theorem, we provide an explicit shallow WNN architecture comprised of only two layers. We prove a generalization theorem that shows that this architecture can reproduce bandlimited graphon signals with an \(L^{2}\) error \(\varepsilon>0\) using only \(2N=\mathcal{O}(\varepsilon^{-10/9})\) evenly spaced samples from \([0,1]\).
3. Through a discretization of the interval \([0,1]\), the WNN architecture leads to a transferable GNN architecture for which graph adjacency matrices are simply swapped into the filter computational unit. We show performance guarantees on the transferability of these GNNs for all sufficiently large simple deterministic weighted graphs and simple random graphs belonging to the same graphon family.
This paper is organized as follows. We begin in SS2 with a review of all of the important concepts, definitions, and auxiliary results that we will use throughout the remainder of the paper. Precisely, SS2.1 reviews GNNs, SS2.2 introduces graphons and SS2.3 defines WNNs as a generalization of GNNs, bandlimited functions are discussed in SS2.4, and finally SS2.5 introduces our specific WNN and GNN architectures. Our main results are presented in SS3, organized into subsections according to the summarized contributions above, followed by a concluding discussion in SS3.4 on their ramifications. The proof of our sampling result is left to SS4, the proof of WNN generalization is in SS5, and GNN proofs can be found in Sections 6 and 7. We conclude in SS8 with a discussion of our results and some important avenues for future investigation.
Preliminaries
We introduce here the symbols, notations, and conventions that will be used consistently throughout this paper. The symbol \(\mathbb{N}\) will denote the set of natural numbers. We preserve the letters \(j,k,l,n\) to represent integers, while \(\mathfrak{m},L,M,N,d,m\) specifically represent natural numbers, and the latter two indicating dimensions. For \(N\in\mathbb{N}\), we define an integer interval \(B_{N}\) by
\[B_{N}:=\{-N,-N+1,\cdots,0,\cdots,N-2,N-1\}.\]
Given a set \(X\) of objects, we denote its cardinality by the notation \(\hash X\).
We employ a conventional abuse of notation for the symbol \(|\cdot|\). When \(I\) is an interval, then \(|I|\) means the length of \(I\). When \(x\) is an element in a Euclidean space, \(|x|\) denotes its Euclidean norm.
For \(p=1,2\), we will consider the Banach spaces \(L^{p}(X;\mathbb{C}^{d})\) consisting of all functions \(f:X\to\mathbb{C}^{d}\) for which
\[\|f\|_{L^{p}(X;\mathbb{C}^{d})}:=\bigg{(}\int_{X}|f(x)|^{p}\,\mathrm{d}x\bigg{)} ^{1/p}\]
is finite. Here, the integral is interpreted in the Bochner sense. When \(X\) is discrete the integral reduces to a summation over the individual elements of \(X\), i.e.
\[\|f\|_{L^{p}(X;\mathbb{C}^{d})}=\bigg{(}\sum_{x\in X}|f(x)|^{p}\bigg{)}^{1/p}.\]
We preserve the symbols \(\ell^{1}\) and \(\ell^{2}\) for when \(X=\mathbb{Z}\), giving
\[\|f\|_{\ell^{p}(\mathbb{Z};\mathbb{C}^{d})}:=\bigg{(}\sum_{j\in\mathbb{Z}}|f(j )|^{p}\bigg{)}^{1/p},\quad p=1,2.\]
We will futher consider the case of \(p=\infty\), which leads to the \(L^{\infty}\)-norm of a function \(f\):
\[\|f\|_{L^{\infty}(X;\mathbb{C}^{d})}:=\sup_{x\in X}|f(x)|.\]
For convenience, when \(d=1\) we simply write \(L^{p}(X)\) and \(\ell^{p}(\mathbb{Z})\).
We also employ another abuse of notation when referring to the congruence symbol \(\cong\). When \(X\), \(Y\) are two sets, then \(X\cong Y\) means \(X,Y\) are isomorphic as sets. For example, the torus \(\mathbb{T}\cong[0,1)\) or \(\mathbb{T}\cong[-1/2,1/2)\) as sets. When \(X,Y\) are two Lebesgue measure sets, then \(X\cong Y\) means that the set difference \(X\Delta Y\) has Lebesgue measure zero. For example, \([0,1]\cong[0,1)\). Lastly, when \(X,Y\) are both groups, then \(X\cong Y\) signifies that they are isomorphic as groups, however this usage only appears in Appendix A.
### Graph Neural Networks
We represent a graph by the triple \(G=(V,E,w)\). Here \(V\) denotes the set of graph vertices and \(E\subset V\times V\) the set of graph edges. Suppose \(\#V=n\), for some \(n\in\mathbb{N}\). By adopting a predetermined labeling for the vertices, we simply express \(V\) as \(V=\{v_{1},v_{2},\ldots,v_{n}\}\). The edge weight function \(w:V\times V\to[0,1]\) describes the connections among the vertices. That is, \(w(v_{k},v_{l})>0\) if and only if there exists an edge connecting \(v_{k},v_{l}\), i.e. \((v_{k},v_{l})\in E\). In this paper, we restrict ourselves to the case of simple, undirected graphs, meaning that \(w\) meets two conditions: symmetry, \(w(v_{k},v_{l})=w(v_{l},v_{k})\) and absence of self-loops, \(w(v_{k},v_{k})=0\). Associated with the edge weight function is the \(n\times n\) graph adjacency matrix, symbolized by \(\mathbf{A}\), whose \(kl\)-entry satisfies \([\mathbf{A}]_{kl}=w(v_{k},v_{l})\).
A _graph signal_ is a function \(f\in L^{2}(V;\mathbb{C}^{m})\), for some \(m\in\mathbb{N}\), giving each vertex \(v_{k}\in V\), a set of features \(f(v_{k})\). Often in many applications of GNNs, vertices are assigned coordinate vectors that depict their locations in space, say \(v_{k}\) is given as \(X_{k}\in\mathbb{R}^{d}\). In this case, the graph signal \(f\) can be interpreted as a function in \(L^{2}(\mathbb{R}^{d};\mathbb{C}^{m})\). From an analytical standpoint, a GNN \(\Psi_{G}\) on \(G\) operates as a graph signal, which means, in this context, \(\Psi_{G}\in L^{2}(\mathbb{R}^{d};\mathbb{C}^{m})\). The input of the GNN is the collection of all of the feature vectors \(X_{k}\), called the (input) _feature matrix_ and denoted by
\[\mathbf{X}:=\begin{bmatrix}X_{1}&X_{2}&\cdots&X_{n}\end{bmatrix}\in\mathbb{R} ^{d\times n}. \tag{2.1}\]
The output feature of \(\Psi_{G}\) at each vertex is a vector in \(\mathbb{C}^{m}\); the collection of such vectors is the (output) feature matrix
\[\mathbf{Y}:=\begin{bmatrix}\Psi_{G}(X_{1})&\Psi_{G}(X_{2})&\cdots&\Psi_{G}(X_ {n})\end{bmatrix}\in\mathbb{C}^{m\times n}.\]
The input and output dimensions, respectively, \(d,m\), are problem dependent. In terms of structure, the defining characteristic of a GNN as a neural network lies in its architecture. Specifically, GNNs are built by combining multiple iterations of two distinct computational units, given as follows:
* **Multilayer Perceptron (MLP)**: An MLP is a two-step process of first applying an affine transformation and then a nonlinear activation function. For example, for a weight matrix \(\mathbf{W}\in\mathbb{C}^{m\times d}\), a _bias vector_\(\mathbf{b}\in\mathbb{C}^{m}\), and a nonlinear activation function \(\rho\), an MLP unit acts symbolically on \(\mathbf{Z}\in\mathbb{C}^{d\times n}\) as \[\mathbf{Z}\mapsto\rho(\mathbf{WZ}+\mathbf{b}),\] where \(\rho\) is applied componentwise. These units are the fundamental building blocks of feedforward neural networks. Throughout this work we consider ReLU (rectified linear unit) activation functions, \(ReLU(x)=\max\{x,0\}\), for which the resulting GNN will be called a _ReLU GNN_.
* **Filter**: A graph filter unit \(\mathfrak{F}\) is what distinguishes a GNN from a standard feedforward NN architecture. Generally, a graph filtering process is any process that takes in nodal
features (e.g. \(\mathbf{X}\) in (2.1)) _and_ graphical structure \((V,E,w)\) and outputs a new set of nodal features. There are two types of graph filters: spatial-based and spectral-based. The spatial filters explicitly leverage the graph connections to perform a feature refining process, whereas the spectral ones utilize spectral graph theory to design filtering in the spectral domain. Moreover, some well-known spectral filters can be considered spatial filters [38].
With the above, the operation of a GNN can be expanded as:
\[\mathbf{Y}\equiv\rho_{L}(\mathbf{W}^{(L)}\psi_{L-1}\circ\psi_{L-2}\circ\cdots \circ\psi_{1}(\mathbf{X})+\mathbf{b}^{(L)}). \tag{2.2}\]
Here, \(L\in\mathbb{N}\), and each \(\psi_{j}\) in (2.2) is a (intermediate) _network layer_, which is one composition of an MLP and a filter units, e.g.
\[\mathbf{H}_{j} =\psi_{j}(\mathbf{H}_{j-1})=\mathfrak{F}(\rho(\mathbf{W}^{(j)} \mathbf{H}_{j-1}+\mathbf{b}^{(j)})),\quad j=1,\cdots,L-1, \tag{2.3}\] \[\mathbf{H}_{0} \equiv\mathbf{X}.\]
This says that at the \(j\)th layer, the output of the previous layer \(\mathbf{H}_{j-1}\), is fed to an MLP (with weight matrix \(\mathbf{W}^{(j)}\), bias vector \(\mathbf{b}^{(j)}\) and activation \(\rho\)) and then to a graph filter \(\mathfrak{F}\). A common alternative to (2.3) is
\[\mathbf{H}_{j}=\psi_{j}(\mathbf{H}_{j-1})=\rho(\mathfrak{F}(\mathbf{W}^{(j)} \mathbf{H}_{j-1}+\mathbf{b}^{(j)})),\]
where there is a switch between the filter and activation applications. In this work, we will specifically employ the configuration (2.3). Note from (2.2) that \(\mathfrak{F}\) is not performed at the last \(L\)th layer and that the last activation \(\rho_{L}\) is optional - for example, one can take \(\rho_{L}\) to be a softmax function to ensure that the output is bounded. Furthermore, \(\mathfrak{F}\) should be enabled at a minimum of one - but not necessarily all - intermediate layers. The GNN _network parameter_, often denoted by \(\theta\), is the set of all entries of all the weight matrices, all the bias vectors, and the number of layers, i.e.
\[\theta=\{\{\mathbf{W}^{(j)}\}_{kl},\mathbf{b}^{(j)},j=1,\cdots,L\}.\]
Throughout this work we will focus on (linear) spatial-based graph filters. Such filtering exchanges information between vertices of the graph. This is achieved by a _graph filter kernel_ (sometimes referred to as a _graph shift operator_[48]) \(\mathbf{K}\in\mathbb{C}^{n\times n}\) which encodes the topology of the graph \(G\). Namely, if \(\mathbf{Z}\in\mathbb{C}^{d\times n}\), then the filter layer takes the form
\[\mathfrak{F}:\quad\mathbf{X}\mapsto\mathbf{K}\mathbf{Z}^{T}. \tag{2.4}\]
The choice of \(\mathbf{K}\) can be determined by the user and is often problem dependent. As will become apparent in the forthcoming subsections, we explore graph filters of the form
\[\mathbf{K}=\mathbf{G}\circ\mathbf{A}, \tag{2.5}\]
where \(\circ\) is the Hadamard product, and \(\mathbf{A}\) is again the adjacency matrix of \(G\). The matrix \(\mathbf{G}\in\mathbb{C}^{n\times n}\) in (2.5) is used to localize information spread by introducing a near-sparsity pattern to \(\mathbf{K}\). This sparsification effect is particularly helpful when \(G\) is a dense graph, since then \(\mathbf{A}\) is a dense matrix, and so information \(\mathbf{Z}\) in (2.4) would be spread globally over \(G\) simply through matrix multiplication by \(\mathbf{K}\).
### Graphons
A _graphon_ is a symmetric, Lebesgue-measurable function \(W:[0,1]^{2}\to[0,1]\). The terminology graphon is a combining graph and function and is a continuum generalization of a graph adjacency matrix. This interpretation comes from envisioning \([0,1]\) as a graph of an uncountable number of vertices, where the values \(W(x,y)\in[0,1]\) represents the weight of an edge between vertices \(x,y\in[0,1]\) - as is common with weighted graphs, one interprets \(W(x,y)=0\) as no edge being present.
Graphons as limit objects.Graphons arise as limits of sequences of graphs on increasing numbers of vertices. To give a meaningful interpretation of graph convergence, we introduce the concept of "homomorphism density" from a graph \(G\) into another graph \(H\) as follows:
\[t(G,H):=\frac{\#\mathrm{Hom}(G,H)}{(\#V_{H})^{\#V_{G}}},\]
where \(V_{H}\), \(V_{G}\) denote the number of vertices in graphs \(G\), \(H\), respectively, and \(\#\mathrm{Hom}(G,H)\) is the number of adjacency preserving maps (_graph homomorphisms_) from \(G\) to \(H\). Thus, the ratio that defines \(t(G,H)\) can be interpreted as the probability that a map from the vertices in \(G\) to those in \(H\) will be a homomorphism, with \((\#V_{H})^{\#V_{G}}\) being the total number of all possible maps. A sequence of graphs \(\{G_{n}\}_{n=1}^{\infty}\) is said to converge if for all finite simple graphs \(F\) the limit of the real-valued sequences \(\{t(F,G_{n})\}_{n=1}^{\infty}\) exist. On the other hand, the homomorphism density of a graph \(F\) into a graphon \(W\) can be defined in an analogous manner [35, Chapter 7.2], resulting in a ratio denoted as \(t(F,W)\). Then, as is shown in [35, Chapter 11], for every convergent sequence of graphs \(\{G_{n}\}_{n=1}^{\infty}\) there exists a graphon \(W\) so that
\[\lim_{n\to\infty}t(F,G_{n})=t(F,W), \tag{2.6}\]
for every finite simple graph \(F\). We observe that (2.6) resembles the conventional notion of pointwise convergence in analysis. Therefore, through (2.6) we may think of the graphs \(\{G_{n}\}_{n=1}^{\infty}\) as belonging to the same graphon family. Next, we present two important sequences of graphs from the same family that are particularly relevant to our discussion.
Generating graphs from graphons.A major application of graphons is to generate graphs on finitely many vertices. Typically this is done by discretizing the unit interval \([0,1]\) into \(n\in\mathbb{N}\) points as
\[x_{k}:=\frac{k-1}{n},\quad k=1,\cdots,n, \tag{2.7}\]
which represent graph vertices. Denote \(\mathcal{X}_{n}:=\{x_{1},\cdots,x_{n}\}\), and the resulting intervals of length \(1/n\) by \(I_{k}:=[(k-1)/n,k/n)\), \(k=1,\cdots,n\).
One can use \(W\) to prescribe a simple _deterministic weighted graph_\(G_{n}^{\mathrm{det}}\) on \(n\) vertices \(v_{1},\cdots,v_{n}\), identified with \(x_{1},\cdots,x_{n}\), respectively. To do so, associate with \(G_{n}^{\mathrm{det}}\) the sym
metric adjacency matrix \(\mathbf{A}_{n}^{\det}\), defined by
\[[\mathbf{A}_{n}^{\det}]_{k,l}:=\begin{cases}W(x_{k},x_{l})&k\neq l\\ 0&k=l\end{cases},\]
for \(k,l=1,\cdots,n\). Hence the edge weight \([\mathbf{A}_{n}^{\det}]_{k,l}\) between \(v_{k}\), \(v_{l}\) is given by the value of \(W\) in the bottom left corner of the square \(I_{k}\times I_{l}=[x_{k},x_{k+1})\times[x_{l},x_{l+1})\). Furthermore, we assert that an edge exists between \(v_{k}\), \(v_{l}\) if and only if \([\mathbf{A}_{n}^{\det}]_{k,l}>0\).
Likewise, one can also use \(W\) to generate a simple _random graph_\(G_{n}^{\mathrm{ran}}\), denoted in analogy with the deterministic graph presentation, on \(n\) vertices \(v_{1},\cdots,v_{n}\). In this case, the associated (random) adjacency matrix \(\mathbf{A}_{n}^{\mathrm{ran}}\) is given by
\[[\mathbf{A}_{n}^{\mathrm{ran}}]_{k,l}:=\begin{cases}\xi_{k,l}&k\neq l\\ 0&k=l\end{cases},\]
for \(k,l=1,\cdots,n\). Here, \(\xi_{k,l}=\xi_{l,k}\) are independent Bernoulli random variables whose probability distribution is given by
\[\mathbb{P}(\xi_{k,l}=1)=1-\mathbb{P}(\xi_{k,l}=0)=W(x_{k},x_{l}),\qquad\forall k >l.\]
Again, all relevant graph information is captured by the adjacency matrix \(\mathbf{A}_{n}^{\mathrm{ran}}\): an edge appears between \(v_{k},v_{l}\) if \(\xi_{k,l}=\xi_{l,k}=1\).
The graphs in both sequences \(\{G_{n}^{\det}\}_{n=1}^{\infty}\) and \(\{G_{n}^{\mathrm{ran}}\}_{n=1}^{\infty}\) belong to the graphon family of \(W\). Indeed, for all finite simple graphs \(F\), one has
\[\lim_{n\to\infty}t(F,G_{n}^{\det})=t(F,W), \tag{2.8}\]
and
\[\lim_{n\to\infty}t(F,G_{n}^{\mathrm{ran}})=t(F,W), \tag{2.9}\]
with probability 1 [35, Chapter 11].
Embedding graphs into the graphon space.Graphs can be lifted into the space of graphons. Let \(G=(V,E,w)\) be a finite simple graph on \(\#V=n\) vertices \(v_{1},\cdots,v_{n}\). We define the step graphon \(W_{n}:[0,1]^{2}\to[0,1]\) by
\[\overline{W}_{n}(x,y):=\sum_{k,l=1}^{n}w(v_{k},v_{l})\chi_{I_{k}\times I_{l}} (x,y). \tag{2.10}\]
That is, the vertices \(v_{k}\) of \(G\) are identified with the points \(x_{k}\in[0,1]\) as in (2.7), while \(\overline{W}_{n}\) is a simple function taking on the \(n^{2}\) edge weight values of \(w\) on each of the squares \(I_{k}\times I_{l}\).
In particular, when \(G\) is a simple deterministic graph generated from a graphon \(W\), the formula (2.10) becomes
\[\overline{W}_{n}(x,y)=\sum_{k,l=1}^{n}w(v_{k},v_{l})\chi_{I_{k}\times I_{l}}(x,y )=\sum_{\begin{subarray}{c}k,l=1\\ k\neq l\end{subarray}}^{n}W(x_{k},x_{l})\chi_{I_{k}\times I_{l}}(x,y).\]
Note that \(\overline{W}_{n}(x_{k},x_{l})=w(v_{k},v_{l})=W(x_{k},x_{l})\), \(k\neq l\).
As a point of completion, we mention that the space of graphons is typically endowed with the so-called _cut norm_, a metric given by
\[\|W\|_{\square}:=\sup_{S,T}\bigg{|}\int_{S\times T}W(x,y)\mathrm{d}x\mathrm{d} y\bigg{|}. \tag{2.11}\]
Importantly, the convergence (2.8) and (2.9) in the homomorphism density is equivalent to the convergence of the respective step graphons to \(W\) in the cut norm [35, Theorem 11.3].
Graph and graphon signals.Similar to the representation of graph signals, a _graphon signal_ is a vector-valued function assumed to belong to \(L^{2}([0,1];\mathbb{C}^{m})\). An \(m\)-dimensional graph signal \(g\) on a graph \(G\) of \(n\) vertices has a corresponding graphon signal representative, defined as follows. As usual, identify the vertices \(v_{k}\) of \(G\) with \(x_{k}\in\mathcal{X}_{n}\) as in (2.7). In this context, \(g\) can be viewed as a function defined on \(\mathcal{X}_{n}\): \(g(v_{k})=g(x_{k})\). We then embed \(g\) into \(L^{2}([0,1];\mathbb{C}^{m})\) as the step function
\[\overline{g}(x):=\sum_{k=1}^{n}g(x_{k})\chi_{I_{k}}(x)=\sum_{k=1}^{n}g(v_{k}) \chi_{I_{k}}(x),\quad\forall x\in[0,1]. \tag{2.12}\]
### Graphon neural networks
Drawing upon the analogy between graphs and graphons, we can define a WNN as an extension of the GNN framework. Specifically, a WNN can be expressed as a function \(\Psi:[0,1]\to\mathbb{C}^{m}\), and just like a GNN, is constructed through a finite number of iterated compositions involving two distinct computational units:
* **MLP**: An MLP layer for a WNN is again a two-step process. Let \(b\in\mathbb{C}^{m}\) be the bias vector, \(\mathbf{W}\in\mathbb{C}^{m\times d}\) a weight matrix, and \(\rho\) be a nonlinear activation function. Then, for \(g\in L^{2}([0,1];\mathbb{C}^{d})\), an MLP in a WNN takes the form \[g(x)\mapsto\rho(\mathbf{W}g(x)+b),\quad\forall x\in[0,1],\] where \(\rho\) is applied componentwise. We will again consider \(\rho=ReLU\) and refer to such WNN as a _ReLU WNN_.
* **Graphon filter**: A graphon filter is a generalization of a graph filter. Namely, let \(\mathcal{K}:[0,1]^{2}\to\mathbb{C}\) such that \(\mathcal{K}\in L^{\infty}([0,1]^{2})\). Then the graphon filter is an operator \(T_{\mathcal{K}}\) acting on \(g=(g_{1},\cdots,g_{m})\in L^{2}([0,1];\mathbb{C}^{m})\) as \[\begin{split} T_{\mathcal{K}}g(x)&=(T_{\mathcal{K }}g_{1}(x),\cdots,T_{\mathcal{K}}g_{m}(x))\\ &:=\bigg{(}\int_{0}^{1}\mathcal{K}(x,y)g_{1}(y)\,\mathrm{d}y, \cdots,\int_{0}^{1}\mathcal{K}(x,y)g_{m}(y)\,\mathrm{d}y\bigg{)},\quad\forall x \in[0,1].\end{split}\] (2.13)
The choice of \(\mathcal{K}\) can be either user or problem determined. For example, by taking \(\mathcal{K}\) to be a graphon \(W\), we obtain the operator \(T_{W}\) which is well-studied in the literature [29, 35, 49]. For arbitrary \(\mathcal{K}\), the action of a WNN closely mirrors that of a GNN, which if we adopt the configuration (2.3), can be expressed symbolically as follows:
\[\Psi(g_{0})(x)\equiv\rho_{L}(\mathbf{W}^{(L)}\psi_{L-1}\circ\psi_{L-2}\circ \cdots\circ\psi_{1}(g_{0})(x)+b^{(L)}),\quad\forall x\in[0,1].\]
Here, \(L\in\mathbb{N}\), with the input graphon signal \(g_{0}\in L^{2}([0,1];\mathbb{C}^{d})\), and each intermediate layer \(\psi_{j}\) is presented as
\[g_{j}(x)=\psi_{j}(g_{j-1})(x)=T_{\mathcal{K}}(\rho(\mathbf{W}^{(j)}g_{j-1}(x) +b^{(j)})),\quad j=1,\cdots,L-1.\]
The last activation \(\rho_{L}\) is optional, and filtering is performed at a minimum of one - but not necessarily all - intermediate layer.
### Bandlimited graphon signals and sampling
Let \(f=(f_{1},\cdots,f_{m}):[0,1]\to\mathbb{C}^{m}\) be a graphon signal. We assume \(f\in L^{2}([0,1];\mathbb{C}^{m})\), and therefore \(f\) can be expressed as a Fourier series,
\[f(x)=\sum_{k\in\mathbb{Z}}\hat{f}(k)e^{i2\pi nx},\]
where \(\hat{f}(k)=(\hat{f}_{1}(k),\cdots,\hat{f}_{m}(k))\), and the equal sign equates two members of \(L^{2}([0,1];\mathbb{C}^{m})\). We are interested in profiles \(f\) whose Fourier coefficients
\[\hat{f}(k)=(\hat{f}_{1}(k),\cdots,\hat{f}_{m}(k)):=\int_{0}^{1}f(x)e^{-i2\pi kx }\,\mathrm{d}x \tag{2.14}\]
are zero for all but a finite number of modes \(k\in\mathbb{Z}\). To avoid confusion with another notion of bandlimitedness circulated in the current graphon literature [48], we call such \(f\)_Fourier bandlimited_.
**Definition 2.1**.: Let \(\mathfrak{m}\in\mathbb{N}\) and \(f=(f_{1},\cdots,f_{m})\in L^{2}([0,1];\mathbb{C}^{m})\). Then \(f\) is said to be \(\mathfrak{m}\)-Fourier bandlimited, or \(f\in\mathcal{B}_{\mathfrak{m}}\), if
\[\hat{f}(k)=0,\quad\forall k\not\in B_{\mathfrak{m}}=\{-\mathfrak{m},\cdots,0, \cdots,\mathfrak{m}-1\}.\]
or equivalently,
\[\hat{f}_{j}(k)=0,\quad\forall k\not\in B_{\mathfrak{m}}=\{-\mathfrak{m},\cdots, 0,\cdots,\mathfrak{m}-1\}\]
for every \(j=1,\cdots,m\).
It is well-known that a Fourier bandlimited \(f\) is almost everywhere equal to a continuous function \(f_{c}\) on \([0,1]\) where \(f_{c}(0)=f_{c}(1)\) and
\[f_{c}(x)=\sum_{k=-\mathfrak{m}}^{\mathfrak{m}-1}\hat{f}(k)e^{i2\pi kx}. \tag{2.15}\]
Therefore, we can and will identify \(f\) with this continuous version on \([0,1]\) and on \(\mathbb{T}\cong[0,1)\). A function that is Fourier bandlimited is significant in the sense that all its information is stored in its spatial sampling, as encapsulated by the following proposition.
**Proposition 2.1**.: _Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and \(N\geq\mathfrak{m}\). Then,_
\[f(x)=\sum_{j=0}^{2N-1}f(j/2N)s_{N}(x-j/2N),\quad\forall x\in[0,1], \tag{2.16}\]
_where_
\[s_{N}(x):=\frac{1}{2N}\sum_{k=-N}^{N-1}e^{i2\pi kx},\quad\forall x\in[0,1]. \tag{2.17}\]
Proposition 2.1 is a straightforward consequence of the Kluvanek's sampling theorem [33], with the proof left to Appendix A. The function \(s_{N}\) is referred to as a _sampling function_. The reasoning behind the choice of \(s_{N}\), as well as a derivation of (2.16), is fully detailed in Appendix A - see in particular (A.7) and (A.8). One notable observation from the requirement \(N\geq\mathfrak{m}\) is that, when \(N=\mathfrak{m}\), the sampled values (2.20) are said to be sampled at the Nyquist rate [4].
In terms of information, (2.16) represents a remarkable trade-off, in that, to acquire the values of the signal \(f\) at every point on the interval \([0,1]\), one only needs to know its values on a discrete lattice of \([0,1]\). Therefore, the gains achieved substantially outweigh the supply cost. In the following subsection, we will develop a systematic approach to implement the sampling series on the right-hand-side of (2.16) (but more specifically, its regularized variants) into a WNN architecture, which then will be used to generate GNNs capable of generalizing effectively on both deterministic and random graphs.
We conclude this subsection with the following useful lemma that serves as a fundamental connection between sampling theory and Fourier theory on the torus group \(\mathbb{T}\). The second conclusion of the lemma, in particular, provides a practical means for accessing the total graphon signal energy through its spatial samples. This crucial point will be a recurring element in our analysis. The proof is again left to Appendix A.
**Lemma 2.1**.: _Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and let \(N\geq\mathfrak{m}\). Then, for \(\hat{f}\) be as in (2.14), we have_
\[\hat{f}(k)=\begin{cases}\frac{1}{2N}\sum_{j=0}^{2N-1}f(j/2N)e^{-i2\pi kj/2N}& k\in B_{\mathfrak{m}}\\ 0&\text{otherwise}\end{cases}, \tag{2.18}\]
_and_
\[\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}^{2}=\|f\|_{L^{2}(\mathbb{T}; \mathbb{C}^{m})}^{2} =\|\hat{f}\|_{\ell^{2}(\mathbb{Z};\mathbb{C}^{m})}^{2}\] \[=\sum_{k=-\mathfrak{m}}^{\mathfrak{m}-1}|\hat{f}(k)|^{2}=\sum_{k=- N}^{N-1}|\hat{f}(k)|^{2}=\sum_{j=0}^{2N-1}|f(j/2N)|^{2}. \tag{2.19}\]
### WNN and GNN architectures enabled by the sampling theory
With the groundwork laid in the previous subsections, we are now in a position to describe the specific network architectures that are used to achieve our main results.
WNN architecture.Let \(f:[0,1]\to\mathbb{C}^{m}\) and suppose that for some \(N\geq 1\) we have access to the vector of values
\[f_{\mathrm{samp}}=\begin{bmatrix}f(0)&f(1/2N)&\cdots&f((2N-1)/2N)\end{bmatrix} \in\mathbb{C}^{m\times 2N}. \tag{2.20}\]
The objective is to design a WNN that can predict the value of \(f\) at some \(x\in[0,1]\) using only the knowledge of \(f_{\mathrm{samp}}\). Our WNN architecture, using ReLU activations and a graphon filter
\[T_{\mathcal{K}}g(x)=\int_{0}^{1}\mathcal{K}(x,y)g(y)\,\mathrm{d}y, \tag{2.21}\]
will be comprised of two hidden layers: a filter layer and an NN layer. Precisely, it is built according to the following steps:
1. **Input:** The input for our WNN is the function \(g_{0}(x)=x\) for all \(x\in[0,1]\).
2. **First hidden layer:** Given the input \(g_{0}\), the output function \(g_{1}\) of the first layer is given by an application of componentwise activation followed by a graphon filtering, \[g_{0}(x)=x\stackrel{{\rho}}{{\mapsto}}\begin{bmatrix}ReLU(x)\\ ReLU(x-\frac{1}{2N})\\ \vdots\\ ReLU(x-\frac{2N-1}{2N})\end{bmatrix}\stackrel{{ T_{\mathcal{K}}}}{{\mapsto}} \begin{bmatrix}T_{\mathcal{K}}ReLU(x)\\ T_{\mathcal{K}}ReLU(x-\frac{1}{2N})\\ \vdots\\ T_{\mathcal{K}}ReLU(x-\frac{2N-1}{2N})\end{bmatrix}=g_{1}(x),\quad\forall x\in[ 0,1].\]
3. **Second hidden layer:** Taking \(g_{1}\) as the input for the second layer, the output \(g_{2}\) is given by \[g_{1}(x)\mapsto f_{\mathrm{samp}}\cdot g_{1}(x)=\sum_{j=0}^{2N-1}f(j/2N)T_{ \mathcal{K}}ReLU(x-j/2N)=g_{2}(x),\quad\forall x\in[0,1]\] where '\(\cdot\)' denotes matrix multiplication between the matrix \(f_{\mathrm{samp}}\) and the vector-valued function \(g_{1}\).
4. **Output:** The output of our WNN is the function \(g_{2}(x)\), for each \(x\in[0,1]\).
The formula for the output WNN,
\[\sum_{j=0}^{2N-1}f(j/2N)T_{\mathcal{K}}ReLU(x-j/2N), \tag{2.22}\]
resembles the sampling form (2.16) on \([0,1]\). As we progress further in this paper, it will become apparent that (2.22) nearly approximates (2.16) (hence in turn, \(f\)). This realization is a compelling testament to the fact that networks can effectively harness sampling principles. Precisely, this will be achieved by taking the graphon kernel \(\mathcal{K}\) of the form
\[\mathcal{K}(x,y)=\mathcal{G}^{*}(x,y)W(x,y), \tag{2.23}\]
for a "Gaussian-like" function \(\mathcal{G}^{*}\) whose specifics will be presented along with our main results. For now, we note the similarity of (2.23) with (2.5). The function \(\mathcal{G}^{*}\) is used to localize the integration in (2.21) to put more preference on "vertices" close to each \(x\in[0,1]\). We therefore assume that \(W\) possesses the following "local" regularity, for (2.23) to be useful in our work.
**Assumption 2.1**.: There exist \(\kappa,\eta\in(0,1)\), \(K>0\), such that for every \(x\in[0,1]\) and almost every pair \((x,y)\) and \((x,z)\) in the diagonal region
\[\mathcal{D}_{\kappa}:=\{(x,y)\in[0,1]^{2}:|x-y|\leq\kappa\} \tag{2.24}\]
we have
\[W(x,y)\geq\eta\quad\text{ and }\quad|W(x,y)-W(x,z)|\leq K|y-z|. \tag{2.25}\]
We emphasize that we do not believe this assumption to be overly restrictive in practice. The second condition in (2.25) is a (one-dimensional) _local Lipschitz_ condition, while the first, the _nonvanishing_ condition \(W(x,y)\geq\eta\), simply guarantees that "vertices" \(x,y\) that are sufficiently close together have some minimal level of influence upon each other in the network. On the other hand, if the contrary holds true, i.e., \(W(x,y)=0\) for almost every \(y\in[-\kappa+x,x+\kappa]\), then any WNN using \(W\) will fail to predict the value \(f(x)\) for all graphon signals \(f\) that are essentially supported in a neighborhood of \(x\). For a simple demonstration of this, note that an application of \(T_{W}\) to such an \(f\) would lead to
\[\bigg{|}\int_{0}^{1}W(x,y)f(y)\,\mathrm{d}y\bigg{|}=\text{ small }\neq|f(x)|,\]
which indicates that the filtering loses information regarding \(f\) at \(x\).
GNN architecture.Running parallel to the presented WNN architecture is our GNN architecture. Let \(G_{n}\) be a graph on \(n\) vertices generated from a graphon \(W\), in the sense presented in SS2.2. We identify a vertex \(v_{k}\) of \(G_{n}\) with \(x_{k}=\frac{k-1}{n}\), where \(k=1,\cdots,n\). Let \(f_{n}\) be an associated graph signal, identified as a function on \(\mathcal{X}_{n}=\{x_{1},\cdots,x_{n}\}\) via \(f_{n}(x_{k})=f_{n}(v_{k})\). Suppose further that \(f_{n}(x_{k})=f(x_{k})\) for all \(k\), for some graphon signal \(f\), and that, for a fixed \(N\geq 1\), we have sampled
\[f_{\mathrm{samp}}=\begin{bmatrix}f(0)&f(1/2N)&\cdots&f((2N-1)/2N)\end{bmatrix} \in\mathbb{C}^{m\times 2N}.\]
We design a GNN that uses only the knowledge of \(f_{\mathrm{samp}}\) to predict the value of the graph signal \(f_{n}\) at some \(x_{k}\). Our GNN architecture uses ReLU activations and a graph filter
\[\mathfrak{F}(g)(x_{k})=\frac{1}{n}\sum_{l\neq k,l=1}^{n}\mathcal{K}(x_{k},x_{ l})g(x_{l}), \tag{2.26}\]
where \(\mathcal{K}\) is the graphon kernel (2.23) above. Notably, (2.26) is a discretization of (2.21) to the "vertices" \(\{x_{k}=(k-1)/n\}_{k=1}^{n}\). The architecture is comprised of two hidden layers: a filter layer and an NN layer, described as follows.
1. **Input:** The input for our GNN is the function \(g_{0}(x_{k})=x_{k}=\frac{k-1}{n}\) for each \(k=1,\ldots,n\).
2. **First hidden layer:** Given the input \(g_{0}\), the output function \(g_{1}\) of the first layer is given by an application of component-wise activation followed by a graph filtering: \[g_{0}(x_{k})=x_{k}\stackrel{{\rho}}{{\mapsto}}\begin{bmatrix}ReLU (x_{k})\\ ReLU(x_{k}-\frac{1}{2N})\\ \vdots\\ ReLU(x_{k}-\frac{2N-1}{2N})\end{bmatrix}\stackrel{{\mathfrak{F}}}{ {\mapsto}}\begin{bmatrix}\mathfrak{F}(ReLU)(x_{k})\\ \mathfrak{F}(ReLU)(x_{k}-\frac{1}{2N})\\ \vdots\\ \mathfrak{F}(ReLU)(x_{k}-\frac{2N-1}{2N})\end{bmatrix}\equiv g_{1}(x_{k}),\] for all \(k=1,\ldots,n\).
3. **Second hidden layer:** Taking \(g_{1}\) as the input for the second layer, the output \(g_{2}\) is given by \[g_{1}(x_{k})\mapsto f_{\mathrm{samp}}\cdot g_{1}(x_{k})=\sum_{j=0}^{2N-1}f(j/2 N)\mathfrak{F}(ReLU)(x_{k}-j/2N)\equiv g_{2}(x_{k}),\] for all \(k=1,\ldots,n\).
4. **Output:** The output of our GNN is the function \(g_{2}(x_{k})\) for each \(k=1,\ldots,n\).
We make three observations. Firstly, as our GNN only requires two hidden layers, the parameter of the network consists of the nonunital linear weights that are the \(2N\) entries of \(f_{\mathrm{samp}}\). Secondly, the formula for the GNN output
\[\sum_{j=0}^{2N-1}f(j/2N)\mathfrak{F}(ReLU)(x_{k}-j/2N), \tag{2.27}\]
like the one in (2.22), carries the form of a sampling principle. Thirdly, it's evident from (2.26) that our choice for graph filter kernel assumes the form
\[\mathcal{K}(x_{k},x_{l})=\mathcal{G}^{*}(x_{k},x_{l})W(x_{k},x_{l}),\quad\forall k \neq l.\]
We again note the similarity with (2.5).
**Remark 2.1**.: _(\(d\)-dimensional input features versus one-dimensional input features)_
Our GNN construction exclusively operates on the input features \(x_{k}\in[0,1]\) assigned to the vertices \(v_{k}\) during the embedding of \(G_{n}\) into the graphon space. While the graph vertices may have initially been associated with Euclidean feature vectors in \(\mathbb{R}^{d}\), we disregard them and instead adopt the vertex locations on the interval \([0,1]\) as the input for our GNN. This distinguishes our approach from the conventional GNN framework, which typically relies on vectors in \(\mathbb{R}^{d}\). By simplifying the input to single scalar values, we enable the construction of our GNN with two hidden layers and \(2N\) nonunital linear weights corresponding to the entries of \(f_{\text{samp}}\). The network output value \(g_{2}(x_{k})\) represents an estimate of the target function \(f_{n}\) at the vertex \(v_{k}\).
**Remark 2.2**.: _(embedded sampling principle)_ As demonstrated, we explicitly employ the order (2.3) for both of our networks. This deliberate choice serves a purpose that is to allow a seamless integration of sampling theory into the network architectures. The emerging sampling principle will provide all the required network parameters for achieving effective generalization, thereby removing the need for a learning processes. A demonstration of this link in a similar context can be found in [43].
## 3 Main Results
In this section we present the main contributions of this paper. We present four theorems. First, in SS3.1 we provide a uniform sampling theorem on \([0,1]\). Then, in SS3.2 we provide a theorem that establishes WNNs' capacity to generalize graphon signals from evenly spaced samples. We leverage these two theoretical results to derive transferability results for GNNs in SS3.3, applying to both deterministic and random graph sequences generated from a single graphon. We conclude this section with a discussion of the ramifications of our results to practical applications in SS3.4. All proofs are left to the sections that follow this one.
As an aside, through the remainder of this paper we adhere to the analysis practice where universal constants denoted by \(C\) may vary in value from one instance to another.
### A uniform sampling theorem
To begin, let \(r\in(0,1/2)\) and define the \(1\)-periodic function \(\mathcal{G}_{r,\sigma}\) on \(\mathbb{R}\) to be
\[\mathcal{G}_{r,\sigma}(x):=\begin{cases}\mathcal{G}_{\sigma}(x):=c(\sigma)\sum _{n\in\mathbb{Z}}e^{-n^{2}\sigma^{-2}/2}e^{i2\pi nx},&-r\leq x\leq r\\ 0,&\text{otherwise}\end{cases} \tag{3.1}\]
where \(r\) is a truncation parameter, \(\sigma\) a variance parameter, and \(c(\sigma)>0\) is a normalization constant such that \(\mathcal{G}_{r,\sigma}(0)=\mathcal{G}_{\sigma}(0)=1\). Due to its periodicity, \(\mathcal{G}_{r,\sigma}\) can equivalently be viewed as a function on \(\mathbb{T}\). Now supposing \(N>\mathfrak{m}\), for \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and \(\mathcal{G}_{r,\sigma}\), we consider the reconstruction scheme of \(f\) from its uniform samples \(f_{\rm samp}=\begin{bmatrix}f(0)&f(1/2N)&\cdots&f((2N-1)/2N)\end{bmatrix}\) given by
\[\mathcal{R}_{r,\sigma}f(x):=\sum_{j=0}^{2N-1}f(j/2N)s_{N}(y-j/2N)\mathcal{G}_{ r,\sigma}(x-j/2N), \tag{3.2}\]
where \(s_{N}\) is as in (2.17). The following theorem is our first result of this section, an interesting sampling theorem in its own right. It shows that, with the right choice of \(r,\sigma\) and \(N\), the reconstruction scheme in (3.2) produces a subgeometric convergence rate in \(L^{2}\) norm. It will enable our results on WNNs and GNNs that follow. The proof is left to SS4.
**Theorem 3.1**.: _Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and \(\mathcal{R}_{r,\sigma}f\) be as in (4.18). Let \(0<\alpha<\beta<1\), \(N>\mathfrak{m}\), and set_
\[\sigma=\frac{(N-\mathfrak{m})^{\beta}}{\sqrt{6}\pi}\quad\text{ and }\quad r= \frac{3\pi}{(N-\mathfrak{m})^{\alpha}}. \tag{3.3}\]
_Then there exists \(C>0\) such that the followings hold:_
\[\|f-\mathcal{R}_{r,\sigma}f\|_{L^{2}([0,1];\mathbb{C}^{m})}\leq C\widetilde{ \mathcal{E}}(N,\mathfrak{m},\alpha,\beta)\|f\|_{L^{2}([0,1];\mathbb{C}^{m})} \tag{3.4}\]
_for sufficiently large \(N\), where_
\[\widetilde{\mathcal{E}}(N,\mathfrak{m},\alpha,\beta):=e^{-3\pi^{2}(N- \mathfrak{m})^{2(1-\beta)}}\max\left\{1,(N-\mathfrak{m})^{2\beta-1}\right\}+ (N-\mathfrak{m})^{\alpha+\beta}e^{-3\pi^{2}(N-\mathfrak{m})^{2(\beta-\alpha)}}. \tag{3.5}\]
### Generalization using WNNs
The sampling result in Theorem 3.1 will play a crucial role in enabling us to define the kernel (2.23) used in constructing the filter layer of our WNN architecture in SS2.5. We begin by considering a graphon \(W:[0,1]^{2}\to[0,1]\), the function \(\mathcal{G}_{r,\sigma}\) as given in (3.1), and, for some \(N\geq 1\), \(s_{N}\) as given in (2.17). Then, suppressing the dependence on \((r,\sigma,N)\) for the ease of presentation, we define an (asymmetric) kernel \(\mathcal{K}\) (see (2.21)) by
\[\mathcal{K}(x,y)=\bigg{(}\frac{\mathrm{d}^{2}}{\mathrm{d}y^{2}}\,(s_{N}\, \mathcal{G}_{r,\sigma})(x-y)\bigg{)}\bigg{(}\frac{W(x,y)}{\mathcal{W}_{x}} \bigg{)}, \tag{3.6}\]
where, for each \(x\in[0,1]\) we set
\[\mathcal{W}_{x}:=\frac{1}{|\mathfrak{I}_{x}|}\int_{\mathfrak{I}_{x}}W(x,y) \,\mathrm{d}y\quad\text{ and }\quad\mathfrak{I}_{x}:=[0,1]\cap[-r+x,x+r], \tag{3.7}\]
and for every \(j\in\mathbb{N}\),
\[\frac{\mathrm{d}^{j}}{\mathrm{d}x^{j}}\mathcal{G}_{r,\sigma}(x)=\mathcal{G}_{r, \sigma}^{(j)}(x):=\begin{cases}\mathcal{G}_{\sigma}^{(j)}(x)&-r\leq x\leq r\\ 0&\text{otherwise}\end{cases}. \tag{3.8}\]
We now state our result on the generalization capabilities of WNNs for Fourier bandlimited graphon signals. The proof can be found in SS5.
**Theorem 3.2**.: _Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and \(W\) a graphon satisfying Assumption 2.1. Let \(\alpha=0.96\), \(\beta=0.98\), and \(\varepsilon\in(0,1)\). Then there exist \(C>0\) and a ReLU WNN \(\Psi_{f}\), using the graphon kernel \(\mathcal{K}\) in (3.6), with \(r,\sigma\) specified by_
\[r=\frac{3\pi}{(N-\mathfrak{m})^{\alpha}}\quad\text{ and }\quad\sigma=\frac{(N- \mathfrak{m})^{\beta}}{\sqrt{6}\pi},\]
_where \(N=\lceil\varepsilon^{-10/9}\rceil\gg\mathfrak{m}\), such that_
\[\|\Psi_{f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})}\leq C\eta^{-1}K\,\varepsilon \,\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}. \tag{3.9}\]
_More precisely, \(\Psi_{f}\) assumes the structure described in SS2.5, with two layers, including one filter layer, and \(2N=2\lceil\varepsilon^{-10/9}\rceil\) linear weights that are supplied by the sampled functional values of \(f\)._
**Remark 3.1**.: The specific choices of \(\alpha,\beta\) are made for the sake of concreteness. In fact, it is possible to choose \(\alpha\) in such a way that we obtain \(N=\lceil\varepsilon^{-\delta}\rceil\), where \(\delta\) can be as close to \(1\) as possible. The choices we make are motivated by the following considerations:
\[1-\beta=\beta-\alpha\leq 1/4\quad\text{ and }\quad\alpha>3/5.\]
The last condition will become evident during the proof of the theorem (see (5.21)), while the first condition arises from our effort to equate the two geometric rates in (3.5).
The foundation of Theorem 3.2 relies on the result established in Theorem 3.1. However, the two differ in the scope of their predictions. While our sampling result guarantees predictions on the entire interval \([0,1]\), Theorem 3.2 provides guarantees for the specific _predictable_ zone \([r,1-r]\), which, since \(r=C(N-\mathfrak{m})^{-\alpha}\) and \(N=\lceil\varepsilon^{-10/9}\rceil\), widens to \([0,1]\) as \(\varepsilon\to 0^{+}\). This distinction arises from a crucial implementation of an integration-by-parts result in Theorem 3.2 (see Proposition 5.1), which secures its conclusion but in the process, inherently restricts the prediction range.
### Generalization on graphs and GNN-transferability
Now, consider a graphon \(W:[0,1]^{2}\to[0,1]\) and let \(\{G_{n}\}_{n=1}^{\infty}\) be a sequence of simple graphs on \(n\) vertices, generated from \(W\) as in SS2.2. Further, we denote \(\mathbf{A}_{n}\in\mathbb{R}^{n\times n}\) as the
adjacency matrix associated to each \(G_{n}\). Taking \(\mathcal{G}_{r,\sigma}\) to be as in (3.1) and \(s_{N}\) as in (2.17) for some fixed \(N\geq 1\), for each \(n\geq 1\) we define the graph filter kernel (see (2.26))
\[\mathcal{K}_{n}(x_{k},x_{l})=\frac{1}{n}\bigg{(}\frac{\mathrm{d}^{2}}{\mathrm{d }x^{2}}\,(s_{N}\,\mathcal{G}_{r,\sigma})(x_{k}-x_{l})\bigg{)}\bigg{(}\frac{[ \mathbf{A}_{n}]_{k,l}}{\mathcal{W}_{x_{k}}}\bigg{)}. \tag{3.10}\]
Here \(\mathcal{W}_{x_{k}}\) is defined from the graphon \(W\) as in (3.7) for \(x=x_{k}\).
The sequence \(\{G_{n}\}_{n=1}^{\infty}\) can be comprised of either deterministic or random graphs. When we need to differentiate between the two cases, we adopt specific notations. When \(G_{n}\) is deterministic, we denote it as \(G_{n}^{\mathrm{det}}\), and in this scenario, \([\mathbf{A}_{n}]_{k,l}=W(x_{k},x_{l})\), for \(k\neq l\). When \(G_{n}\) is random, we represent it as \(G_{n}^{\mathrm{ran}}\). In this case, \(\mathbf{A}_{n}\) becomes a random matrix, and each \(\mathcal{K}_{n}(x_{k},x_{l})\) is a random variable for \(k\neq l\). A realization of \(G_{n}^{\mathrm{ran}}\) yields a graph with a binary adjacency matrix \(\mathbf{A}_{n}\) whose entries \([\mathbf{A}_{n}]_{k,l}\in\{0,1\}\). In short, regardless of whether \(G_{n}\) is deterministic or random or realized, we only need to substitute the corresponding adjacency matrix into (3.10).
We now state our results on the generalization capabilities of GNNs for graphs belonging to the same graphon family. Their proofs can be found in SS6, SS7, with respect to the order in which the theorems are presented.
**Theorem 3.3**.: _(Deterministic GNNs) Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and \(W\) a graphon satisfying Assumption 2.1. Let \(\varepsilon\in(0,1)\), \(n\geq 1\), \(G_{n}^{\mathrm{det}}\) be a deterministic graph generated from \(W\), and \(f_{n}\) an associated graph signal such that \(f_{n}(x_{k})=f(x_{k})\) for all \(x_{k}\). Then there exist \(C>0\) and a ReLU GNN \(\Psi_{n,f}\), using the graph kernel \(\mathcal{K}_{n}\) in (3.10) with \(r,\sigma\) specified by_
\[r=\frac{3\pi}{(N-\mathfrak{m})^{\alpha}}\quad\text{ and }\quad\sigma=\frac{(N- \mathfrak{m})^{\beta}}{\sqrt{6}\pi},\]
\(\alpha=0.96\)_, \(\beta=0.98\), \(N=\lceil\varepsilon^{-10/9}\rceil\gg\mathfrak{m}\), such that for all \(n\geq\varepsilon^{-13/3}\), it holds that_
\[\|\overline{\Psi}_{n,f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})}\leq C\eta^{-2}(1+K )\,\varepsilon\,\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}, \tag{3.11}\]
_where_
\[\overline{\Psi}_{n,f}(x):=\sum_{k=1}^{n}\Psi_{n,f}(x_{k})\chi_{I_{k}}(x), \quad\forall x\in[0,1]. \tag{3.12}\]
_More precisely, \(\Psi_{n,f}\) assumes the structure described in SS2.5, with two layers, including one filter layer, and \(2N=2\lceil\varepsilon^{-10/9}\rceil\) linear weights that are supplied by the sampled functional values of the graphon signal \(f\)._
**Theorem 3.4**.: _(Random GNNs) Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and \(W\) a graphon satisfying Assumption 2.1. Let \(\varepsilon\in(0,1)\), \(n\geq 1\), \(G_{n}^{\mathrm{ran}}\) be a simple random graph generated from \(W\), and \(f_{n}\) an associated graph signal such that \(f_{n}(x_{k})=f(x_{k})\) for all \(x_{k}\). Then there exist \(C>0\) and a ReLU GNN \(\Psi_{n,f}\), using the graph kernel \(\mathcal{K}_{n}\) in (3.10) with \(r,\sigma\) specified by_
\[r=\frac{3\pi}{(N-\mathfrak{m})^{\alpha}}\quad\text{ and }\quad\sigma=\frac{(N- \mathfrak{m})^{\beta}}{\sqrt{6}\pi},\]
\(\alpha=0.96\), \(\beta=0.98\), \(N=\lceil\varepsilon^{-10/9}\rceil\gg\mathfrak{m}\), such that for all \(n\geq\varepsilon^{-13/3}\), it holds that_
\[\|\overline{\Psi}_{n,f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})}\leq C\eta^{-2}(1+K) \,\varepsilon\,\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}, \tag{3.13}\]
_where \(\overline{\Psi}_{n,f}\) is defined in (3.12), with a probability at least_
\[1-2n\varepsilon^{10(1-\alpha)/9}\exp\bigg{(}-\frac{C\eta^{2}n}{\varepsilon^{4 (15\beta-5\alpha-2)/9}}\bigg{)}. \tag{3.14}\]
_More precisely, \(\Psi_{n,f}\) assumes the structure described in SS2.5, with two layers, including one filter layer, and \(2N=2\lceil\varepsilon^{-10/9}\rceil\) linear weights that are supplied by the sampled functional values of the graphon signal \(f\)._
It should be apparent in (3.14) that as the number of graph vertices \(n\) increases, the likelihood of (3.13) holding also increases. We make a brief remark that the lower bound of \(\varepsilon^{-13/3}\) for \(n\) can be improved to be as near \(\varepsilon^{-4}\) as possible (see also Remark 6.1). The lower bound we obtain for \(n\) in both theorems is a direct consequence of the choices we make for \(\alpha,\beta\).
**Remark 3.2**.: We would like to highlight an alternative generation of simple random graphs using a specific graphon \(W\), as follows. Given \(n\geq 1\) vertices, labeled as \(v_{1},\cdots,v_{n}\), one can independently sample them as random variables \(\xi_{1},\cdots,\xi_{n}\) from the uniform distribution on the interval \([0,1]\). The vertices \(v_{k}\) and \(v_{l}\), \(k>l\), are connected by an edge with an edge-weight of \(W(\xi_{k},\xi_{l})\). This results in a distinct type of random graph, different from the primary ones considered in this paper. Nevertheless, a variant of Theorem 3.4 can be adapted to analyze these types of random graphs and provide similar estimations. To derive this version, we anticipate utilizing the Bernstein inequality [7]. For a practical demonstration of how this inequality is applied in this context, interested readers are referred to [11, Lemma 1].
### Ramifications of the results
Having now presented our main results, we now highlight their most important ramifications.
1. The two major contributions of this work are the GNN results presented in Theorems 3.3 and 3.4. What they provide is the production of a shallow GNN structure that uses a small number of generated samples from the graphon signal and gives a reliable prediction on any large graph within the graphon family. As the GNNs are constructed with predetermined network parameters, our approach does not involve any learning process.
2. Our approach yields a dimensionless result for the network structure, which is the consequence of our taking in of one-dimensional input features. This lack of dimensional-dependence, as explained in Remark 2.1, is made possible by the graphon presence. The existence of a macroscopic graphon structure is crucial since it enables
us to leverage the transition from a multi-dimensional generalization process to a one-dimensional one, hence circumventing the curse of dimensionality. As a simple demonstration of this efficacy, note that the generalization depicted in Theorem 3.3 provides accurate predictions within, after some appropriate scaling by universal and intrinsic constants, an error of approximately \(0.1\), for at least 19700 vertices in a graph containing at least 21500 vertices, while using a low-cost network with only 26 linear weights, therefore resulting in a cost ratio of approximately \(0.0006\).
3. Additionally, our approach offers a seamless transferability of the network architecture across graphs of different sizes. This transferability, which is of paramount importance, involves a straightforward substititon of the relevant adjacency matrix into the kernel (3.10) while ensuring comparable signal generalization estimates. The subsequent corollary, which we give without proof, serves as a validation of this notable outcome. **Corollary 3.1**.: _(GNN transferability) Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{m}\) and \(W\) be a graphon satisfying Assumption 2.1. Let \(\varepsilon\in(0,1)\) and let \(G_{n_{1}}\), \(G_{n_{2}}\) be two graphs generated from \(W\) (random or deterministic) where \(n_{1}\leq n_{2}\). Denote \(\Psi_{n_{1},f}\) as the ReLU GNN associated with \(G_{n_{1}}\), assuming the structure described in SS3.3, and \(\Psi_{n_{2},f}\) the similar ReLU GNN associated with \(G_{n_{2}}\). Suppose that (3.11) holds for \(\Psi_{n_{1},f}\), in the case that \(G_{n_{1}}\) is deterministic, or with a probability at least_ \[1-2n_{1}\varepsilon^{10(1-\alpha)/9}\exp\bigg{(}-\frac{C\eta^{2}n_{1}}{ \varepsilon^{4(15\beta-5\alpha-2)/9}}\bigg{)}.\] _in the case that \(G_{n_{1}}\) is random. Then (_3.11_) also holds for \(\Psi_{n_{2},f}\), in the case that \(G_{n_{2}}\) is deterministic, or with a probability at least_ \[1-2n_{2}\varepsilon^{10(1-\alpha)/9}\exp\bigg{(}-\frac{C\eta^{2}n_{2}}{ \varepsilon^{4(15\beta-5\alpha-2)/9}}\bigg{)}.\] _in the case that \(G_{n_{2}}\) is random._ As an expository application, take the recommender systems that were used as motivation in the introduction and provided the first application of WNNs in [48]. An \(m\)-dimensional graph signal encodes the ratings given by an individual user, represented as a vertex, for each of the \(m\) products that the service recommends. Our approach permits a GNN to be constructed from the ratings obtained from \(2N\) users, which can then predict the ratings that \(n\gg 2N\) users would assign to each product based on the sampled information. This avoids having to retrain the GNN structure as users are added or subtracted from the service, allowing for a more efficient and scalable recommender system that can adapt to changes in the user base without the burden of frequent model updates. Furthermore, our approach extends the methodology of [48], which constructs deterministic graphs based on pairwise correlations of user rankings, by interpreting these correlations as the likelihood of two users having
overlapping tastes, therefore enabling the construction of random graphs. Our GNNs then provide the same level of prediction accuracy with high probability on these random graphs. This probabilistic framework enhances the robustness and reliability of the predictions generated by the GNN-based recommender system.
4. Our results to some degree strengthen the findings presented in [43], where a similar strategy of incorporating the sampling principle into a GNN structure was employed. A limitation of said work is the unavoidable growth in the number of layers with respect to the input feature dimension, attributed to its use of one-dimensional numerical integration methods. In contrast, as our approach utilizes input features in \([0,1]\), it eliminates the dependency on the input dimension and results in a streamlined GNN consisting of only two layers. In the graphon context, the grid lattice employed in [43] falls within the family of the graphons that are almost everywhere constant in a neighborhood of the diagonal. Consequently, with our approach, as detailed in Remark 5.2, the number of weights would only accumulate to \(N=C\lceil(\log(1/\varepsilon))^{1/(2(\beta-\alpha))}\rceil\). This further serves as a testament to the potential and the unique advantage that graphons offer in GNN applications.
## 4 Proof of Theorem 3.1
In this section, we make the necessary steps toward establishing the validity of Theorem 3.1 in SS4.2 below. The main idea for the proof centers around the use of a truncated and regularized variant of Kluvanek's sampling formulation [33]. More precisely, let \(\mathfrak{m},N\in\mathbb{N}\) and suppose \(N\geq\mathfrak{m}\). For any \(f\in\mathcal{B}_{\mathfrak{m}}\), by Proposition 2.1 we have
\[f(x)=\sum_{j=0}^{2N-1}f(j/2N)s_{N}(x-j/2N),\quad\forall x\in[0,1], \tag{4.1}\]
where \(s_{N}\) is as in (2.17). Our goal is to replace the series on the right-hand-side of (4.1) with
\[\sum_{j=0}^{2N-1}f(j/2N)\mathcal{G}(x-j/2N)\]
where \(\mathcal{G}\) is some function exhibiting a "Gaussian-like" behavior, but only supported in a vicinity of \(x\) of some appropriate radius \(r\). To begin, we need to establish a general result for regularized sampling. In this section as well as others that follow, we will make repeated use of the McLaurin-Cauchy integral test [34, SS3.3, Theorem 3] and the Mills' ratio formula [8], which we cite here for the reader's convenience:
\[\int_{x}^{\infty}e^{-t^{2}/2}\,\mathrm{d}t\leq\frac{\pi e^{-x^{2}/2}}{\sqrt{( \pi-2)^{2}x^{2}+2\pi}+2x}, \tag{4.2}\]
for every \(x>0\).
### A regularized sampling result
Let \(\phi:[0,1]\to\mathbb{C}\) be a continuous function such that \(\phi(0)=\phi(1)=1\) and its Fourier coefficients are absolutely summable, i.e. \(\hat{\phi}\in\ell^{1}(\mathbb{Z})\). Then \(\hat{\phi}\in\ell^{2}(\mathbb{Z})\) as well, and from the Fourier inversion theorem [20] we have \(\phi\in L^{2}([0,1])\) with
\[\sum_{l\in\mathbb{Z}}\hat{\phi}(l)=\phi(0)=1. \tag{4.3}\]
For any \(N\in\mathbb{N}\), let \(\chi_{B_{N}}\) denote a function that is one on \(B_{N}=\{-N,\ldots,N-1\}\subset\mathbb{Z}\) and zero on \(\mathbb{Z}\setminus B_{N}\). For each \(k\in\mathbb{Z}\) we define
\[\mu(k):=\chi_{B_{N}}*\hat{\phi}(k)=\sum_{l\in\mathbb{Z}}\chi_{B_{N}}(k-l)\hat{ \phi}(l)=\sum_{l\in k-B_{N}}\hat{\phi}(l), \tag{4.4}\]
and
\[\nu(k):=\sum_{l\not\in k-B_{N}}\hat{\phi}(l). \tag{4.5}\]
We gather from (4.3), (4.4), (4.5) that
\[\sum_{l\in\mathbb{Z}}\mu(k+l2N)=\sum_{l\in\mathbb{Z}}\hat{\phi}(l)=1=\nu(k)+ \mu(k),\quad\forall k\in\mathbb{Z}, \tag{4.6}\]
and so we deduce
\[\nu(k)=\sum_{l\in\mathbb{Z}\setminus\{0\}}\mu(k+l2N),\quad\forall k\in \mathbb{Z}. \tag{4.7}\]
Now, let \(f\in\mathcal{B}_{\mathfrak{m}}\) and take \(N\geq\mathfrak{m}\). We define
\[\mathcal{R}_{\phi}f(x):=\sum_{j=0}^{2N-1}f(j/2N)s_{N}(x-j/2N)\phi(x-j/2N),\quad \forall x\in[0,1], \tag{4.8}\]
where, from the definition (2.17) of \(s_{N}\), we can write
\[\hat{s}(k)=\frac{1}{2N}\chi_{B_{N}}(k),\quad\forall k\in\mathbb{Z}.\]
Since all the functions involved in (4.8) are continuous on \(\mathbb{T}\cong[0,1)\), we treat the argument addition in (4.8) as a group addition on \(\mathbb{T}\), i.e. it is taken modulo \(1\). (Alternatively, we can consider treating them as \(1\)-periodic functions on \(\mathbb{R}\). This perspective will be used in SS5.) Reasonably, we can no longer expect \(f=\mathcal{R}_{\phi}f\). However, we claim that the regularized sampling error, i.e. \(f-\mathcal{R}_{\phi}f\), can be understood in terms of \(\mu,\nu\) in (4.4) and (4.5), respectively.
**Lemma 4.1**.: _Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\) and \(N\geq\mathfrak{m}\). Then_
\[\hat{f}(k)-\widehat{\mathcal{R}_{\phi}f}(k)=\begin{cases}\hat{f}(k)\nu(k),&k \in B_{\mathfrak{m}}\\ -\hat{f}(k-2lN)\mu(k),&\exists l\neq 0\text{ s.t }k-2lN\in B_{\mathfrak{m}}\\ 0,&\text{otherwise}\end{cases}.\]
Proof.: Recall from Lemma 2.1 that
\[\hat{f}(k)=\begin{cases}\frac{1}{2N}\sum_{j=0}^{2N-1}f(j/2N)e^{-i2\pi kj/2N}&k\in B _{\mathfrak{m}}\\ 0&\text{otherwise}\end{cases}. \tag{4.9}\]
Let \(k\in B_{N}\). By combining (4.9) with (4.4), (4.8), and the definition of \(s_{N}\), we further obtain
\[\widehat{\mathcal{R}_{\phi}f}(k)=\frac{1}{2N}\sum_{j=0}^{2N-1}f(j/N)e^{-i2\pi kj /2N}\mu(k)=\hat{f}(k)\mu(k).\]
Therefore, from (4.6)
\[\hat{f}(k)-\widehat{\mathcal{R}_{\phi}f}(k)=\hat{f}(k)\nu(k), \tag{4.10}\]
which from (4.9), in turn implies \(\hat{f}(k)-\widehat{\mathcal{R}_{\phi}f}(k)=0\), if \(k\in B_{N}\setminus B_{\mathfrak{m}}\).
Now suppose \(k\not\in B_{N}\) but \(k-2lN\in B_{N}\) for some \(l\neq 0\). Then
\[\begin{split}\hat{f}(k)-\widehat{\mathcal{R}_{\phi}f}(k)& =-\widehat{\mathcal{R}_{\phi}f}(k)\\ &=-\frac{1}{2N}\sum_{j=0}^{2N-1}f(j/N)e^{-i2\pi(k-2lN)j/2N}\mu(k )=-\hat{f}(k-2lN)\mu(k),\end{split} \tag{4.11}\]
where we have again used (4.9). In this case, if \(k-l2N\in B_{N}\setminus B_{\mathfrak{m}}\) then it follows from (4.9) and (4.11) that
\[\hat{f}(k)-\widehat{\mathcal{R}_{\phi}f}(k)=0. \tag{4.12}\]
Combining (4.10), (4.11), (4.12), we conclude the lemma.
We now provide the bounds on the difference between \(f\) and \(\mathcal{R}_{\phi}f\) in both the \(L^{2}\) and \(L^{\infty}\) norms, which will eventually be employed to prove Theorem 3.1 in the following subsection SS4.2.
**Lemma 4.2**.: _Let \(f\in L^{2}([0,1];\mathbb{C}^{m})\cap\mathcal{B}_{\mathfrak{m}}\). Then_
\[\overline{\varepsilon}_{1}\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}\leq\|f-\mathcal{ R}_{\phi}f\|_{L^{2}([0,1];\mathbb{C}^{m})}\leq\,\overline{\varepsilon}_{2}\|f\|_{ L^{2}([0,1];\mathbb{C}^{m})}, \tag{4.13}\]
_where_
\[\overline{\varepsilon}_{1} :=\min_{k\in B_{\mathfrak{m}}}\bigg{\{}|\nu(k)|^{2}+\sum_{l\in \mathbb{Z}\setminus\{0\}}|\mu(k+l2N)|^{2}\bigg{\}}^{1/2}\] \[\overline{\varepsilon}_{2} :=\max_{k\in B_{\mathfrak{m}}}\bigg{\{}|\nu(k)|^{2}+\sum_{l\in \mathbb{Z}\setminus\{0\}}|\mu(k+l2N)|^{2}\bigg{\}}^{1/2}.\]
Proof.: By applying Lemma 4.1 and utilizing Plancherel's theorem, we obtain
\[\|f-\mathcal{R}_{\phi}f\|_{L^{2}([0,1];\mathbb{C}^{m})}^{2}=\sum_{k\in B_{ \mathfrak{m}}}|\hat{f}(k)\nu(k)|^{2}+\sum_{l\in\mathbb{Z}\setminus\{0\}}\sum_ {k\in B_{\mathfrak{m}}}|\hat{f}(k)\mu(k+2l\pi)|^{2}, \tag{4.14}\]
from which (4.13) automatically follows. We note that the \(L^{2}\)-bounds cannot be improved, due to the equality (4.14).
### Sampling with \(\mathcal{G}_{r,\sigma}\)
In this subsection we will apply Lemma 4.2 to specific regularizers \(\phi\), resulting in the proof of Theorem 3.1.
Let \(\sigma>0\) and recall the regularizer
\[\mathcal{G}_{\sigma}(x)=c(\sigma)\sum_{k\in\mathbb{Z}}e^{-k^{2}\sigma^{-2}/2}e ^{i2\pi kx}=2c(\sigma)\sum_{k=0}^{\infty}e^{-k^{2}\sigma^{-2}/2}\cos(2\pi kx),\quad\forall x\in[0,1]. \tag{4.15}\]
presented previously in (3.1). Since \(\mathcal{G}_{\sigma}(0)=\mathcal{G}_{\sigma}(1)\), we consider \(\mathcal{G}_{\sigma}\) as a function on \(\mathbb{T}\cong[0,1)\cong[-1/2,1/2)\). The parameter \(\sigma\) is a variance parameter, and \(c(\sigma)\) is a normalization constant guaranteeing that
\[\mathcal{G}_{\sigma}(0)=\|\hat{\mathcal{G}}_{\sigma}\|_{\ell^{1}(\mathbb{Z}) }=c(\sigma)\sum_{k\in\mathbb{Z}}e^{-k^{2}\sigma^{-2}/2}=1,\]
where \(\hat{\mathcal{G}}_{\sigma}(k)=c(\sigma)e^{-k^{2}\sigma^{-2}/2}\) according to (4.15). Note that \(c(\sigma)\leq 1\).
The motivation for the definition (4.15) stems from the fact that \(\mathcal{G}_{\sigma}\) mimics "Gaussian"-like behavior. We highlight this with the following lemma.
**Lemma 4.3**.: _The function \(\mathcal{G}_{\sigma}\), as defined in (4.15), satisfies_
\[\mathcal{G}_{\sigma}(x)>0,\quad\forall x\in\mathbb{T}, \tag{4.16}\]
_is even, and_
\[\mathcal{G}_{\sigma}(x)=\sum_{l\in\mathbb{Z}}\mathfrak{g}(x+l),\quad\forall x \in\mathbb{T}. \tag{4.17}\]
_where \(\mathfrak{g}(\xi):=d(\sigma)e^{-2\xi^{2}\pi^{2}\sigma^{2}}\), with \(d(\sigma):=\sigma c(\sigma)\sqrt{2\pi}\)._
Proof.: For any \(g\in L^{2}(\mathbb{R})\) we denote the Fourier transform and its inverse by
\[\mathcal{F}_{\mathbb{R}}g(\xi):=\int_{\mathbb{R}}g(u)e^{-i2\pi u\xi}\,\mathrm{ d}u\quad\text{ and }\quad\mathcal{F}_{\mathbb{R}}^{-1}g(\xi):=\int_{\mathbb{R}}g(u)e^{i2\pi u\xi}\, \mathrm{d}u.\]
Precisely, it is known that \(\mathcal{F}_{\mathbb{R}}\circ\mathcal{F}_{\mathbb{R}}^{-1}=Id_{L^{2}(\mathbb{ R})}=\mathcal{F}_{\mathbb{R}}^{-1}\circ\mathcal{F}_{\mathbb{R}}\)[20]. Now, the function \(\mathfrak{g}^{*}(\xi):=c(\sigma)e^{-\xi^{2}\sigma^{-2}/2}\) is such that \(\mathfrak{g}^{*}(l)=\hat{\mathcal{G}}_{\sigma}(l)\) for all \(l\in\mathbb{Z}\), and it's the Fourier transform of the function
\[\mathcal{F}_{\mathbb{R}}^{-1}\mathfrak{g}^{*}(\xi)=\mathfrak{g}(\xi)=d( \sigma)e^{-2\xi^{2}\pi^{2}\sigma^{2}},\quad\forall\xi\in\mathbb{R},\]
where \(d(\sigma)=\sigma c(\sigma)\sqrt{2\pi}\). Hence, by invoking the Poisson summation formula [20], for each \(x\in\mathbb{T}\) we obtain
\[\mathcal{G}_{\sigma}(x)=\sum_{l\in\mathbb{Z}}\mathcal{G}_{\sigma}(l)e^{i2\pi l x }=\sum_{l\in\mathbb{Z}}\mathfrak{g}^{*}(l)e^{i2\pi lx}=\sum_{l\in\mathbb{Z}} \mathfrak{g}(x+l)>0,\]
which proves both (4.16) and (4.17). Finally, that \(\mathcal{G}_{\sigma}\) is even can be seen from definition (4.15).
Next, we introduce a truncated version of \(\mathcal{G}_{\sigma}\), also presented earlier in (3.1). Let \(r\in(0,1/2)\) and define, for \(x\in[-1/2,1/2)\cong\mathbb{T}\), the function
\[\mathcal{G}_{r,\sigma}(x)=\begin{cases}\mathcal{G}_{\sigma}(x)=c(\sigma)\sum_{k \in\mathbb{Z}}e^{-k^{2}\sigma^{-2}/2}e^{i2\pi kx},&-r\leq x\leq r\\ 0,&\text{otherwise}\end{cases}.\]
Note that \(\mathcal{G}_{r,\sigma}=\mathcal{G}_{\sigma}\chi_{I_{r}}\), where \(\chi_{I_{r}}\) is the indicator function on the interval \(I_{r}=[-r,r]\). Since \(\mathcal{G}_{\sigma}\) is even and real, so is \(\hat{\mathcal{G}}_{r,\sigma}\) on \(\mathbb{Z}\). Recall the following truncated regularized sampling series of \(f\) introduced in (3.2):
\[\mathcal{R}_{r,\sigma}f(x)=\sum_{j=0}^{2N-1}f(j/2N)s(x-j/2N)\mathcal{G}_{r, \sigma}(x-j/2N). \tag{4.18}\]
We compute that
\[\widehat{\mathcal{R}_{r,\sigma}f}(k)=\frac{1}{2N}\sum_{j=0}^{2N-1}f(j/2N)e^{- i2\pi kj/2N}\mu_{r,\sigma}(k)\]
where, we have defined
\[\mu_{r,\sigma}(k):=\chi_{B_{N}}*\hat{\mathcal{G}}_{r,\sigma}(k)=\sum_{l\in k- B_{N}}\hat{\mathcal{G}}_{r,\sigma}(l). \tag{4.19}\]
If we let
\[\nu_{r,\sigma}(k):=\sum_{l\not\in k-B_{N}}\hat{\mathcal{G}}_{r,\sigma}(l), \tag{4.20}\]
then we gather that
\[\nu_{r,\sigma}(k)+\mu_{r,\sigma}(k)=\sum_{l\in\mathbb{Z}}\hat{\mathcal{G}}_{r,\sigma}(l)=1\quad\text{ and }\quad\nu_{r,\sigma}(k)=\sum_{l\in\mathbb{Z}\setminus\{0\}}\mu_{r, \sigma}(k+l2N),\quad\forall k\in\mathbb{Z}. \tag{4.21}\]
Both \(\nu_{r,\sigma},\mu_{r,\sigma}\) are even on \(\mathbb{Z}\). It should be clear from the past analysis that \(\mu_{r,\sigma}\) will play the role of \(\mu\) in (4.4). Therefore, to access the upper bound in (4.13), Lemma 4.2, we would need an estimate for
\[\max_{k\in B_{\text{\rm m}}}\bigg{\{}|\nu_{r,\sigma}(k)|^{2}+\sum_{l\in \mathbb{Z}\setminus\{0\}}|\mu_{r,\sigma}(k+l2N)|^{2}\bigg{\}}^{1/2}.\]
For ease of computation, we will replace this quantity with
\[\max_{k\in B_{\text{\rm m}}}|\nu_{r,\sigma}(k)|+\max_{k\in B_{\text{\rm m}}} \bigg{(}\sum_{l\in\mathbb{Z}\setminus\{0\}}|\mu_{r,\sigma}(k+l2N)|^{2}\bigg{)} ^{1/2}. \tag{4.22}\]
We first handle \(\max_{k\in B_{\mathfrak{m}}}|\nu_{r,\sigma}(k)|\). Referring to definition (4.20), observe that for any \(k\in\mathbb{Z}\),
\[\nu_{r,\sigma}(k) =1-\sum_{l\in k-B_{N}}\hat{\mathcal{G}}_{r,\sigma}(l)\] \[=1-\sum_{l\in k-B_{N}}\bigg{(}\hat{\mathcal{G}}_{\sigma}(l)-\int_ {u\not\in[-r,r]\cap[-1/2,1/2)}\mathcal{G}_{\sigma}(u)e^{-i2\pi lu}\,\mathrm{d }u\bigg{)}\] \[=\sum_{l\not\in k-B_{N}}\hat{\mathcal{G}}_{\sigma}(l)+\int_{u \not\in[-r,r]\cap[-1/2,1/2)}\mathcal{G}_{\sigma}(u)\sum_{l\in k-B_{N}}e^{-i2 \pi lu}\,\mathrm{d}u\] \[=\sum_{l\not\in k-B_{N}}\hat{\mathcal{G}}_{\sigma}(l)+\int_{u \not\in[-r,r]\cap[-1/2,1/2)}\mathcal{G}_{\sigma}(u)\cos(2\pi(k-N+1)u)\bigg{(} \frac{1-e^{-i4\pi Nu}}{1-e^{-i2\pi u}}\bigg{)}\,\mathrm{d}u. \tag{4.23}\]
Note that the first sum on the right-hand-side above is \(\nu(k)\) in (4.5) with \(\phi=\mathcal{G}_{\sigma}\). This is the _regularization_ error. The integral on the right-hand-side, carrying an \(r\) in its expression, is the _truncation_ error.
A quick calculation from (4.23) gives
\[\max_{k\in B_{\mathfrak{m}}}|\nu_{r,\sigma}(k)|\leq\sum_{l\not\in\mathfrak{m}- 1-B_{N}}\hat{\mathcal{G}}_{\sigma}(l)+\frac{2\mathcal{G}_{\sigma}(r)}{|1-e^{- i2\pi r}|}. \tag{4.24}\]
Therefore, a bound on \(\max_{k\in B_{\mathfrak{m}}}|\nu_{r,\sigma}(k)|\) can be derived from an upper bound for the right-hand-side above.
**Proposition 4.1**.: _Let \(\nu_{r,\sigma}\) be as in (4.20). Let \(r,\sigma\) be as in (3.3). Then_
\[\max_{k\in B_{\mathfrak{m}}}|\nu_{r,\sigma}(k)|\leq C\widetilde{\mathcal{E}}_ {1}(N,\mathfrak{m},\alpha,\beta),\]
_for some \(C>0\), and_
\[\widetilde{\mathcal{E}}_{1}(N,\mathfrak{m},\alpha,\beta):=e^{-3\pi^{2}(N- \mathfrak{m})^{2(1-\beta)}}\max\bigg{\{}1,(N-\mathfrak{m})^{2\beta-1}\bigg{\}} +(N-\mathfrak{m})^{\alpha+\beta}e^{-3\pi^{2}(N-\mathfrak{m})^{2(\beta-\alpha)}}.\]
Proof.: Since \(e^{-x^{2}\sigma^{-2}/2}\) is even on \(\mathbb{R}\) and strictly decreasing on \([0,\infty)\), we have
\[\sum_{l\not\in\mathfrak{m}-1-B_{N}}\hat{\mathcal{G}}_{\sigma}(l)\leq 2\sum_{l \geq N-\mathfrak{m}}\hat{\mathcal{G}}_{\sigma}\leq 2\hat{\mathcal{G}}_{\sigma}(N- \mathfrak{m})+2\int_{N-\mathfrak{m}}^{\infty}e^{-u^{2}\sigma^{-2}/2}\,\mathrm{ d}u, \tag{4.25}\]
and so using Mills' ratio (4.2) we obtain
\[\int_{N-\mathfrak{m}}^{\infty}e^{-u^{2}\sigma^{-2}/2}\,\mathrm{d}u<\frac{\pi \sigma e^{-(N-\mathfrak{m})^{2}\sigma^{-2}/2}}{\sqrt{(\pi-2)^{2}(N-\mathfrak{ m})^{2}\sigma^{-2}+2\pi}+2(N-\mathfrak{m})\sigma^{-1}}. \tag{4.26}\]
By combining (4.25) and (4.26), and performing the necessary simplifications, we arrive at
\[\sum_{l\not\in\mathfrak{m}-1-B_{N}}\hat{\mathcal{G}}_{\sigma}(l)\leq 4e^{-(N- \mathfrak{m})^{2}\sigma^{-2}/2}\max\bigg{\{}1,\frac{\sigma^{2}}{N-\mathfrak{m }}\bigg{\}}.\]
Keeping in mind that \(\sigma=(N-\mathfrak{m})^{\beta}/(\sqrt{6}\pi)\) in (3.3) allows for the estimate
\[\sum_{l\not\in\mathfrak{m}-1-B_{N}}\hat{\mathcal{G}}_{\sigma}(l)\leq 4e^{-3\pi^{2} (N-\mathfrak{m})^{2(1-\beta)}}\max\bigg{\{}1,(N-\mathfrak{m})^{2\beta-1} \bigg{\}}. \tag{4.27}\]
On the other hand, since \(r\in(0,1/2)\), the function \(e^{-2(x+r)^{2}\pi^{2}\sigma^{2}}\) is strictly decreasing on \([0,\infty)\) and increasing on \((-\infty,-1]\). Thus, we deduce from (4.17) and Mills' ratio that
\[\mathcal{G}_{\sigma}(r) =\sum_{l\in\mathbb{Z}}\mathfrak{g}(r+l)\leq 3d(\sigma)e^{-2r^{2} \pi^{2}\sigma^{2}}+2d(\sigma)\int_{1-r}^{\infty}e^{-2\pi^{2}\sigma^{2}u^{2}} \,\mathrm{d}u\] \[\leq 3\sigma\sqrt{2\pi}e^{-2r^{2}\pi^{2}\sigma^{2}}+\frac{\sqrt{ \pi}e^{-2\pi^{2}\sigma^{2}(1-r)^{2}}}{\sqrt{(\pi-2)^{2}\pi^{2}\sigma^{2}(1-r)^ {2}+\pi}+2\pi\sigma(1-r)},\]
which, by the selections of \(r,\sigma\) in (3.3), simplifies to
\[\mathcal{G}_{\sigma}(r)\leq C(N-\mathfrak{m})^{\beta}e^{-3\pi^{2}(N- \mathfrak{m})^{2(\beta-\alpha)}} \tag{4.28}\]
for some \(C>0\). Since \(r=3\pi(N-\mathfrak{m})^{-\alpha}\), when \(N\) is sufficiently large, we can ensure that \(1-2\pi r\geq 1/2\). Hence
\[\frac{\mathcal{G}_{\sigma}(r)}{|1-e^{-i2\pi r}|}\leq\frac{C(N-\mathfrak{m})^{ \beta}}{r(1-2\pi r)}\bigg{(}e^{-3\pi^{2}(N-\mathfrak{m})^{2(\beta-\alpha)}} \bigg{)}\leq C(N-\mathfrak{m})^{\alpha+\beta}e^{-3\pi^{2}(N-\mathfrak{m})^{2( \beta-\alpha)}}. \tag{4.29}\]
By integrating (4.24), (4.27) and (4.29), we acquire the conclusion of the proposition.
We will now shift our focus to the components involving \(\mu_{r,\sigma}\) in (4.22).
**Proposition 4.2**.: _Let \(\mu_{r,\sigma}\) be as in (4.19). Let \(r,\sigma\) be as in (3.3). Then there exists \(C>0\) such that_
\[\max_{k\in B_{\mathfrak{m}}}\bigg{(}\sum_{l\in\mathbb{Z}\setminus\{0\}}|\mu_{ r,\sigma}(k+l2N)|^{2}\bigg{)}^{1/2}\leq C\widetilde{\mathcal{E}}_{2}(N, \mathfrak{m},\alpha,\beta), \tag{4.30}\]
_where_
\[\widetilde{\mathcal{E}}_{2}(N,\mathfrak{m},\alpha,\beta):=(N-\mathfrak{m})^{ \beta}e^{-3\pi^{2}(N-\mathfrak{m})^{2(\beta-\alpha)}}+(N-\mathfrak{m})^{2 \beta-\alpha-1}e^{-3\pi^{2}(N-\mathfrak{m})^{2(1-\beta)}}.\]
Proof.: Since \(\mu_{r,\sigma}\) is even on \(\mathbb{Z}\) and \(N>\mathfrak{m}\), it is enough to prove the convergences in (4.30) for all integers of the form \(k^{\prime}=k+2l^{\prime}N\geq 0\), where \(l^{\prime}\in\mathbb{N}\), and so \(k^{\prime}-B_{N}\) consists of positive integers. Fix one such \(k^{\prime}\). Then, by definition (4.19)
\[\mu_{r,\sigma}(k+2l^{\prime}N)=\mu_{r,\sigma}(k^{\prime})=\sum_{l\in k^{ \prime}-B_{N}}\hat{\mathcal{G}}_{r,\sigma}(l)=\sum_{l\in k^{\prime}-B_{N}}\int_ {-r}^{r}\mathcal{G}_{\sigma}e^{-i2\pi lu}\,\mathrm{d}u. \tag{4.31}\]
From the Poisson formula (4.17), we obtain for each \(l\in k^{\prime}-B_{N}\) in (4.31) that
\[\begin{split}\int_{-r}^{r}\mathcal{G}_{\sigma}e^{-i2\pi lu}\, \mathrm{d}u&=d(\sigma)\sum_{j\in\mathbb{Z}}\int_{-r}^{r}e^{-2(u+j) ^{2}\pi^{2}\sigma^{2}}e^{-i2\pi lu}\,\mathrm{d}u\\ &=d(\sigma)\sum_{j\in\mathbb{Z}}\int_{j-r}^{j+r}e^{-2u^{2}\pi^{2} \sigma^{2}}e^{-i2\pi lu}\,\mathrm{d}u\\ &=d(\sigma)e^{-l^{2}/(2\sigma^{2})}\sum_{j\in\mathbb{Z}}\int_{j-r }^{j+r}e^{-2\pi^{2}\sigma^{2}(u+il/(2\pi\sigma^{2}))^{2}}\,\mathrm{d}u\\ &=:d(\sigma)\sum_{j\in\mathbb{Z}}\mathcal{I}_{j,l}.\end{split} \tag{4.32}\]
Fix one \(j\in\mathbb{Z}\) and one \(l\in k^{\prime}-B_{N}\). We consider the contour integration of the holomorphic function \(e^{-l^{2}/(2\sigma^{2})}e^{-2\pi^{2}\sigma^{2}z^{2}}\) over a rectangle consisting of the following four lines on the complex plane:
\[\begin{split}\text{vertical:}\quad\{(j+r,y):0\leq y\leq l/(2\pi \sigma^{2})\},&\quad\{(j-r,y):0\leq y\leq l/(2\pi\sigma^{2})\}\\ \text{horizontal:}\quad\{(x,0):j-r\leq x\leq j+r\},& \quad\{(x,l/(2\pi\sigma^{2})):j-r\leq x\leq j+r\}.\end{split} \tag{4.33}\]
Cauchy's integral theorem [55, Theorem 2.2] then gives that
\[\begin{split} 0=&-\mathcal{I}_{j,l}+e^{-l^{2}/(2 \sigma^{2})}\int_{j-r}^{j+r}e^{-2\pi^{2}\sigma^{2}(x+i(l/(2\pi\sigma^{2})-1/( 2\pi\sigma^{2})))^{2}}\,\mathrm{d}x\\ &+e^{-l^{2}/(2\sigma^{2})}\bigg{(}\int_{l/(2\pi\sigma^{2})}^{0}e ^{-2\pi^{2}\sigma^{2}(j-r+iy)^{2}}\,i\mathrm{d}y+\int_{0}^{l/(2\pi\sigma^{2})} e^{-2\pi^{2}\sigma^{2}(j+r+iy)^{2}}\,i\mathrm{d}y\bigg{)}.\end{split} \tag{4.34}\]
The contribution of the first vertical line in (4.33) is
\[\begin{split} e^{-l^{2}/(2\sigma^{2})}\bigg{|}\int_{0}^{l/(2\pi \sigma^{2})}e^{-2\pi^{2}\sigma^{2}(j+r+iy)^{2}}\,i\mathrm{d}y\bigg{|}\leq& \frac{e^{-2\pi^{2}\sigma^{2}(j+r)^{2}}}{\sqrt{2}\pi\sigma}\int_{0}^{l/(\sqrt{ 2}\sigma)}e^{y^{2}-l^{2}/(2\sigma^{2})}\,\mathrm{d}y\\ &=\frac{e^{-2\pi^{2}\sigma^{2}(j+r)^{2}}}{\sqrt{2}\pi\sigma}\int_{ 0}^{l/(\sqrt{2}\sigma)}e^{(y-l/(\sqrt{2}\sigma))(y+l/(\sqrt{2}\sigma))}\, \mathrm{d}y.\end{split} \tag{4.35}\]
We note that the second and third integrals appearing above take the form \(e^{-a^{2}}\int_{0}^{a}e^{-u^{2}}\,\mathrm{d}u\), which is a _Dawson's integral_[12]. To handle it, we make a convenient change of variables as follows. Let \(u\geq 0\) be such that \(-u=y-l/(\sqrt{2}\sigma)\). Then since \(0\leq y\leq l/(\sqrt{2}\sigma)\),
\[-\frac{2l}{\sqrt{2}\sigma}u\leq y^{2}-\frac{l^{2}}{2\sigma^{2}}=-u(y+\frac{l}{ \sqrt{2}\sigma})\leq-\frac{l}{\sqrt{2}\sigma}u.\]
Putting this back into (4.35) gives us
\[e^{-l^{2}/(2\sigma^{2})}\bigg{|}\int_{0}^{l/(2\pi\sigma^{2})}e^{-2 \pi^{2}\sigma^{2}(j+r+iy)^{2}}\,i\mathrm{d}y\bigg{|} \leq\frac{e^{-2\pi^{2}\sigma^{2}(j+r)^{2}}}{\sqrt{2}\pi\sigma}\int _{0}^{l/(\sqrt{2}\sigma)}e^{-ul/(\sqrt{2}\sigma)}\,\mathrm{d}u\] \[\leq\frac{e^{-2\pi^{2}\sigma^{2}(j+r)^{2}}}{l\pi}\int_{0}^{l^{2}/ (2\sigma^{2})}e^{-u}\,\mathrm{d}u\] \[=:\frac{e^{-2\pi^{2}\sigma^{2}(j+r)^{2}}\mathcal{J}_{l}}{l\pi},\]
where, \(\mathcal{J}_{l}\to 1\) as \(l\to\infty\). By the Poisson summation formula (4.17) again,
\[\sum_{l\in k^{\prime}-B_{N}}\frac{\mathcal{J}_{l}}{l\pi}\sum_{j\in\mathbb{Z}} d(\sigma)e^{-2\pi^{2}\sigma^{2}(j+r)^{2}}=\sum_{l\in k+2l^{\prime}N-B_{N}} \frac{\mathcal{G}_{\sigma}(r)\mathcal{J}_{l}}{l\pi}.\]
We square-sum the final term above over \(l^{\prime}\in\mathbb{N}\), acquiring for any \(k\in B_{\mathfrak{m}}\)
\[\sum_{l^{\prime}\in\mathbb{N}}\bigg{|}\sum_{l=k+(2l^{\prime}-1)N+ 1}^{k+(2l^{\prime}+1)N}\frac{\mathcal{G}_{\sigma}(r)\mathcal{J}_{l}}{l\pi} \bigg{|}^{2} \leq\frac{2N\mathcal{G}_{\sigma}(r)^{2}}{\pi^{2}}\sum_{l^{\prime} \in\mathbb{N}}\sum_{l=k+(2l^{\prime}-1)N+1}^{k+(2l^{\prime}+1)N}\frac{1}{l^{2}} \tag{4.36}\] \[=\frac{2N\mathcal{G}_{\sigma}(r)^{2}}{\pi^{2}}\sum_{l=k+N+1}^{ \infty}\frac{1}{l^{2}}\] \[\leq\frac{2N\mathcal{G}_{\sigma}(r)^{2}}{\pi^{2}}\int_{k+N}^{ \infty}\frac{1}{l^{2}}\] \[\leq\frac{2N\mathcal{G}_{\sigma}(r)^{2}}{\pi^{2}(N-\mathfrak{m})}.\]
Employing the same method for the contribution of the second vertical line in (4.33), and keeping in mind that \(\mathcal{G}_{\sigma}(r)=\mathcal{G}_{\sigma}(-r)\), we also arrive at an analogous bound. On the other hand, consideration of the bottom horizontal integral in (4.34) leads to:
\[e^{-l^{2}/(2\sigma^{2})}d(\sigma)\sum_{j\in\mathbb{Z}}\int_{j-r}^{j+r}e^{-2 \pi^{2}\sigma^{2}x^{2}}\,\mathrm{d}x=e^{-l^{2}/(2\sigma^{2})}\int_{-r}^{r} \mathcal{G}_{\sigma}(x)\,\mathrm{d}x\leq\frac{2e^{-l^{2}/(2\sigma^{2})}}{(N- \mathfrak{m})^{\alpha}}.\]
Similarly as before, since \(l\in k^{\prime}-B_{N}\), where \(k^{\prime}=k+2l^{\prime}N\), \(k\in B_{\mathfrak{m}}\) and \(l^{\prime}\in\mathbb{N}\), summing over \(l^{\prime}\in\mathbb{N}\) for an arbitrary \(k\in B_{\mathfrak{m}}\) results in
\[\sum_{l^{\prime}=1}^{\infty}\quad\sum_{l\in k+2l^{\prime}N-B_{N} }e^{-l^{2}/(2\sigma^{2})}=\sum_{l=k+N+1}^{\infty}e^{-l^{2}/(2\sigma^{2})} \leq\int_{N+k}^{\infty}e^{-x^{2}/(2\sigma^{2})}\,\mathrm{d}x\] \[\leq\frac{C\sigma^{2}e^{-(N+k)^{2}/(2\sigma^{2})}}{N+k}\] \[\leq\frac{C\sigma^{2}e^{-(N-\mathfrak{m})^{2}/(2\sigma^{2})}}{N- \mathfrak{m}},\]
where Mills' ratio (4.2) has entered at the second to last inequality. Then an application of the embedding of the \(\ell^{p}\) spaces leads to
\[\begin{split}\frac{1}{(N-\mathfrak{m})^{\alpha}}\bigg{(}\sum_{l^{ \prime}=1}^{\infty}\bigg{|}\sum_{l\in k+2l^{\prime}N-B_{N}}e^{-l^{2}/(2\sigma^{ 2})}\bigg{|}^{2}\bigg{)}^{1/2}&\leq\frac{1}{(N-\mathfrak{m})^{ \alpha}}\sum_{l=k+N+1}^{\infty}e^{-l^{2}/(2\sigma^{2})}\\ &\leq\frac{C\sigma^{2}e^{-(N-\mathfrak{m})^{2}/(2\sigma^{2})}}{(N -\mathfrak{m})^{\alpha+1}}.\end{split} \tag{4.37}\]
Therefore, by combining (4.31), (4.32), (4.34) (4.36), (4.37), along with (4.28), we obtain
\[\begin{split}\bigg{(}\sum_{l^{\prime}\in\mathbb{N}}|\mu_{r, \sigma}(k+2l^{\prime}N)|^{2}\bigg{)}^{1/2}&\leq\frac{C\sigma^{2 }e^{-(N-\mathfrak{m})^{2}/(2\sigma^{2})}}{(N-\mathfrak{m})^{\alpha+1}}+C \mathcal{G}_{\sigma}(r)\\ &\leq C(N-\mathfrak{m})^{2\beta-\alpha-1}e^{-3\pi^{2}(N- \mathfrak{m})^{2(1-\beta)}}+C(N-\mathfrak{m})^{\beta}e^{-3\pi^{2}(N-\mathfrak{ m})^{2(\beta-\alpha)}}\\ &=\widetilde{\mathcal{E}}_{2}(N,\mathfrak{m},\alpha,\beta),\end{split}\]
from which and the symmetry mentioned at the start of the proof, (4.30) follows.
Proof of Theorem 3.1.: The proof is a combination of the observation made in (4.22), the proof of Lemma 4.2 and Propositions 4.1, 4.2.
## 5 Proof of Theorem 3.2
We begin by reminding the reader of some important points that will be useful for this section. Firstly, let \(f\in\mathcal{B}_{\mathfrak{m}}\) and assume that \(N>\mathfrak{m}\). We have asserted that
\[\mathcal{R}_{r,\sigma}f(x)=\sum_{j=0}^{2N-1}f(j/2N)(s_{N}\,\mathcal{G}_{r, \sigma})(x-j/2N)\approx f(x), \tag{5.1}\]
in the \(L^{2}\) norm on \([0,1]\), with precise error bounds provided in Theorem 3.1. Importantly, we require in \(\mathcal{G}_{r,\sigma}\),
\[\sigma=\frac{(N-\mathfrak{m})^{\beta}}{\sqrt{6}\pi}\quad\text{ and }\quad r=\frac{3\pi}{(N-\mathfrak{m})^{\alpha}},\]
where \(0<\alpha<\beta<1\). To facilitate convenience in future calculations, we now identify \(s_{N}\), \(\mathcal{G}_{r,\sigma}\) with their 1-periodic counterparts, respectively. Then \(s_{N}\in C^{\infty}(\mathbb{R})\), and for every \(j\in\mathbb{N}\), \(\mathcal{G}_{r,\sigma}^{(j)}=d^{j}\mathcal{G}_{r,\sigma}/dx^{j}\) exists almost everywhere. Recall that we have defined in (3.8)
\[\mathcal{G}_{r,\sigma}^{(j)}(x)=\begin{cases}\mathcal{G}_{\sigma}^{(j)}(x),& \exists k\in\mathbb{Z}\text{ s.t. }k-r\leq x\leq k+r\\ 0,&\text{otherwise.}\end{cases} \tag{5.2}\]
This extension allows us to interpret the argument addition in
\[\sum_{j=0}^{2N-1}f(j/2N)(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2N),\]
as taking place on \(\mathbb{R}\).
Secondly, we have established in SS2.5 that the output of our WNN will take the form
\[\sum_{j=0}^{2N-1}f(j/2N)T_{\mathcal{K}}ReLU(x-j/2N),\quad\forall x\in[0,1]. \tag{5.3}\]
Therefore, by juxtaposing (5.1) and (5.3), it becomes evident that we would complete most of the proof if we can demonstrate that:
\[T_{\mathcal{K}}ReLU(x-j/2N)=(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2N)+\mathcal{ E}, \tag{5.4}\]
for a small \(\mathcal{E}\) error term and \(x\) in an appropriately large subset of \([0,1]\). If \(\mathcal{E}\) can be bounded and shown to vanish as \(N\to\infty\), then the overall, accumulated, discrepancy between the network output and \(\mathcal{R}_{r,\sigma}f\) can be made small uniformly for \(x\) in the same subset. The proof is then completed by recalling (5.1).
We proceed as planned with the task of bounding the error in (5.4) with the following proposition.
**Proposition 5.1**.: _Let \(\mathfrak{m}\in\mathbb{N}\) and \(\varepsilon>0\). Suppose \(W\) satisfies Assumption 2.1 and \(N>\mathfrak{m}\) is large enough so that_
\[r=\frac{3\pi}{(N-\mathfrak{m})^{\alpha}}\leq\kappa \tag{5.5}\]
_where \(\kappa\) is as in (2.24). Fix \(x\in[r,1-r]\) and \(j=0,\cdots,2N-1\). If \(x-j/2N\in[-r,r)\), then there exists \(C>0\) such that the following holds_
\[|T_{\mathcal{K}}ReLU(x-j/2N)-(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2 N)|\\ \leq C\eta^{-1}\bigg{(}KNr^{2}+(N-\mathfrak{m})^{\beta}e^{-(N- \mathfrak{m})^{2\beta}/24}\bigg{)}. \tag{5.6}\]
The proof of Proposition 5.1 requires the knowledge of two auxiliary lemmas below. One is an integration-by-parts result, and the other gives estimates of \(s_{N}\,\mathcal{G}_{r,\sigma}\) that are not only essential for the present section but also for all others. Their proofs are given in SS5.1 and SS5.2, respectively.
**Lemma 5.1**.: _Fix \(r\in(0,1)\), \(x\in[r,1-r]\) and \(j=0,\cdots,2N-1\). Suppose \(x-j/2N\in[-r,r)\). Then_
\[(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2N)=(x+r-j/2N)(s_{N}\, \mathcal{G}_{r,\sigma})^{\prime}(-r)+(s_{N}\,\mathcal{G}_{r,\sigma})(-r)\\ +\int_{x-r}^{x+r}ReLU(y-j/2N)(d^{2}/dy^{2})(s_{N}\,\mathcal{G}_{r,\sigma})(x-y)\,\mathrm{d}y. \tag{5.7}\]
**Lemma 5.2**.: _Given a pair of \(r,\sigma\) as in (3.3), with \(0<\alpha<\beta<1\). There exists \(C>0\) such that for all \(N>\mathfrak{m}\) we have_
1. \(|(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime}(r)|\leq C(N-\mathfrak{m})^{\beta}e^{-(N -\mathfrak{m})^{2\beta}/24}\)_,_
2. \(\|(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime}\|_{L^{\infty}([0,1])}\leq CN\)__
3. \(\|(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime\prime}\|_{L^{\infty}([0,1])}\leq C \max\{N^{2},N^{3\beta}\}\)_,_
4. \(\|(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime\prime\prime}\|_{L^{\infty}([0,1])} \leq CN\max\{N^{2},N^{3\beta}\}\)_._
Equipped with these lemmas, we now delve into the proof of Proposition 5.1.
Proof of Proposition 5.1.: We introduce abbreviations that will be used in this proof as well as in the proofs of Theorems 3.3, 3.4 to enhance a compact presentation. Set
\[\mathcal{G}^{*}(x,y):=\frac{\mathrm{d}^{2}}{\mathrm{d}y^{2}}(s_{N}\,\mathcal{ G}_{r,\sigma})(x-y)\]
and
\[\rho_{j}(x):=ReLU(x-j/2N)=ReLU_{j/2N}(x)\]
for each for \(j=0,\cdots,2N-1\). Begin by noting that if \(x\in[r,1-r]\), then from definition (3.7), \(\mathfrak{I}_{x}=[-r+x,x+r]\). Now if \(x-j/2N\in[-r,r)\), then from Lemma 5.1
\[(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2N) =\int_{x-r}^{x+r}\rho_{j}(y)\mathcal{G}^{*}(x,y)\,\mathrm{d}y \tag{5.8}\] \[\quad+(x+r-j/2N)(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime}(-r)+(s_{ N}\,\mathcal{G}_{r,\sigma})(-r).\]
I.e.,
\[\int_{\mathfrak{I}_{x}}\rho_{j}(y)\mathcal{G}^{*}(x,y)\,\mathrm{d}y=(s_{N}\, \mathcal{G}_{r,\sigma})(x-j/2N)+\mathcal{E}_{1}, \tag{5.9}\]
and
\[\mathcal{E}_{1}:=-(x+r-j/2N)(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime}(-r)-(s_{ N}\,\mathcal{G}_{r,\sigma})(-r).\]
From Lemma 5.2 and (4.28), we obtain
\[|\mathcal{E}_{1}|\leq C(N-\mathfrak{m})^{\beta}e^{-(N-\mathfrak{m})^{2\beta} /24}. \tag{5.10}\]
Next, we compare \(T_{\mathcal{K}}ReLU(x-j/2N)=T_{\mathcal{K}}\rho_{j}(x)\) with \(\int_{\mathfrak{I}_{x}}\rho_{j}(y)\mathcal{G}^{*}(x,y)\,\mathrm{d}y\). Due to (5.5), \(\{(x,y):y\in\mathfrak{I}_{x}\}\subset\mathcal{D}_{\kappa}\). Therefore, it follows from Assumption 2.1 on \(W\) that \(\mathcal{W}_{x}\geq\eta\) and
\[\begin{split}|\mathcal{W}_{x}-W(x,y)|&=\left|\frac{ 1}{|\mathfrak{I}_{x}|}\int_{\mathfrak{I}_{x}}(W(x,u)-W(x,y))\,\mathrm{d}u \right|\\ &\leq\frac{1}{|\mathfrak{I}_{x}|}\int_{\mathfrak{I}_{x}}|W(x,u)-W( x,y)|\,\mathrm{d}u\\ &\leq 2Kr\end{split} \tag{5.11}\]
for almost every \(y\in\mathscr{I}_{x}\). Moreover, by the Lipschitz continuity assumption, \((\mathrm{d}/\mathrm{d}y)W(x,y)\) exists almost everywhere on \(I_{x}\) (Radamacher's theorem) [18, SS5.8.3, Theorem 5] and that
\[\bigg{|}\frac{\mathrm{d}}{\mathrm{d}y}W(x,y)\bigg{|}\leq K; \tag{5.12}\]
therefore
\[\begin{split}&\int_{\mathscr{I}_{x}}\rho_{j}(y)\mathcal{G}^{*}(x,y) \bigg{(}W(x,y)-\mathcal{W}_{x}\bigg{)}\,\mathrm{d}y=\int_{j/2N}^{x+r}\rho_{j}(y )\mathcal{G}^{*}(x,y)\bigg{(}W(x,y)-\mathcal{W}_{x}\bigg{)}\,\mathrm{d}y\\ &=-\int_{j/2N}^{x+r}(\mathrm{d}/\mathrm{d}y)(s_{N}\,\mathcal{G}_ {r,\sigma})(x-y)\bigg{\{}\rho_{j}(y)(\mathrm{d}/\mathrm{d}y)W(x,y)+W(x,y)- \mathcal{W}_{x}\bigg{\}}\,\mathrm{d}y+\mathcal{E}_{2}.\end{split} \tag{5.13}\]
Here
\[\mathcal{E}_{2}:=(\mathrm{d}/\mathrm{d}y)(s_{N}\,\mathcal{G}_{r,\sigma})(x-y) \rho_{j}(y)\bigg{(}W(x,y)-\mathcal{W}_{x}\bigg{)}\bigg{|}_{y=j/2N}^{y=x+r}\]
and so as a result of Lemma 5.2 again
\[|\mathcal{E}_{2}|\leq C(N-\mathfrak{m})^{\beta}e^{-(N-\mathfrak{m})^{2\beta}/ 24}. \tag{5.14}\]
Going back to the third integral in (5.13), we see that
\[\begin{split}&\bigg{|}\int_{j/2N}^{x+r}(\mathrm{d}/\mathrm{d}y)(s_{N }\,\mathcal{G}_{r,\sigma})(x-y)\bigg{\{}\rho_{j}(y)(\mathrm{d}/\mathrm{d}y)W(x,y)+W(x,y)-\mathcal{W}_{x}\bigg{\}}\,\mathrm{d}y\bigg{|}\\ &\leq CN\bigg{(}K\int_{0}^{2r}y\,\mathrm{d}y+Kr^{2}\bigg{)}\leq CK Nr ^{2}\end{split} \tag{5.15}\]
where the first bound comes from the definition of \(\rho_{j}=ReLU_{j/2N}\) for \(j/2N\in[x-r,x+r)\), Lemma 5.2, (5.11) and (5.12). Then, by synthesizing the findings of (5.12), (5.13), (5.14), (5.15), we acquire
\[\begin{split}\bigg{|}T_{\mathcal{K}}\rho_{j}(x)-\int_{\mathscr{I }_{x}}\rho_{j}(y)\mathcal{G}^{*}(x,y)\,\mathrm{d}y\bigg{|}&=\frac {1}{\mathcal{W}_{x}}\bigg{|}\int_{\mathscr{I}_{x}}\rho_{j}(y)\mathcal{G}^{*}(x, y)\bigg{(}W(x,y)-\mathcal{W}_{x}\bigg{)}\,\mathrm{d}y\bigg{|}\\ &\leq C\eta^{-1}\bigg{(}KNr^{2}+(N-\mathfrak{m})^{\beta}e^{-(N- \mathfrak{m})^{2\beta}/24}\bigg{)}.\end{split} \tag{5.16}\]
As the final step, we combine (5.9), (5.10), (5.16) and arrive at the inequality (5.6), proving the proposition.
Having now successfully established the proof of Proposition 5.1, we proceed to the proof of Theorem 3.2.
Proof of Theorem 3.2.: Without loss of generality, we may assume \(\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}=1\). From Lemma 2.1 we further have
\[\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}^{2}=\sum_{j=0}^{2N-1}|f(j/2N)|^{2}=1. \tag{5.17}\]
At the outset, we will make a temporary assumption that (5.5) holds. Fix \(x\in[r,1-r]\) and suppose that
\[x-j/2N\neq r,\quad\forall j=0,\cdots,2N-1. \tag{5.18}\]
Note that there are only at most \(\lceil rN\rceil\) indices \(j\) such that \(x-j/2N\in[-r,r)\). Define
\[f_{\sharp}(y):=\sum_{j=0}^{2N-1}f(j/2N)\rho_{j}(y),\quad\forall y\in[0,1]. \tag{5.19}\]
Then \(T_{\mathcal{K}}f_{\sharp}(x)=\sum_{j=0}^{2N-1}f(j/2N)T_{\mathcal{K}}\rho_{j}( x)=\Psi_{f}(x)\) (see SS2.5). On the other hand, recall the regularized sampling series
\[\mathcal{R}_{r,\sigma}f(x)=\sum_{j=0}^{2N-1}f(j/2N)(s_{N}\,\mathcal{G}_{r, \sigma})(x-j/2N).\]
Therefore, as a direct consequence of (5.17), Proposition 5.1 and the \(L^{p}\)-embedding property for finite measure spaces,
\[|\Psi_{f}(x)-\mathcal{R}_{r,\sigma}f(x)| =|T_{\mathcal{K}}f_{\sharp}(x)-\mathcal{R}_{r,\sigma}f(x)|\] \[\leq C\eta^{-1}r^{1/2}N^{1/2}\bigg{(}KNr^{2}+(N-\mathfrak{m})^{ \beta}e^{-(N-\mathfrak{m})^{2\beta}/24}\bigg{)}.\]
Combining this and the result of Theorem 3.1 - and ignoring all the exponential error parts - we obtain
\[\|\Psi_{f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})}\leq C\eta^{-1}KN^{3/2-\alpha 5 /2}. \tag{5.20}\]
We now set
\[3/2-\alpha 5/2=0.9\quad\text{ and }\quad\beta-\alpha=0.02, \tag{5.21}\]
hence, \(\alpha=0.96\), \(\beta=0.98\). Set
\[N=\lceil\varepsilon^{-10/9}\rceil;\]
then it follows from (5.20), (5.21) that
\[\|\Psi_{f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})}\leq C\eta^{-1}K\varepsilon\]
for every \(x\in[r,1-r]\) that satisfies (5.18). We now note that (5.5) can be guaranteed by taking
\[\frac{3\pi}{\kappa}\leq\varepsilon^{-1},\]
which can be accomplished by taking \(\varepsilon\in(0,1)\) to be sufficiently small. The proof is now concluded.
**Remark 5.1**.: It should be noted that the choices made for \(r,\sigma\) in (3.3) are made specifically to ensure that, when \(\alpha=0.96\), \(\beta=0.98\), all exponential error terms that should appear in (5.20) are dominated by the rational term on its right-hand side even for small \((N-\mathfrak{m})\). In general, for given \(0<\alpha<\beta<1\), one can find \(c_{1}(\alpha,\beta),c_{2}(\alpha,\beta)>0\) such that, if
\[r=\frac{c_{1}(\alpha,\beta)}{(N-\mathfrak{m})^{\alpha}}\quad\text{ and }\quad \sigma=\frac{(N-\mathfrak{m})^{\beta}}{c_{2}(\alpha,\beta)},\]
then a similar effect of keeping the exponential terms small, as observed in (5.20), is achieved.
**Remark 5.2**.: It is important to note that the favorable subgeometric sampling convergence rate established Theorem 3.1 has been forfeited in the proof of Theorem 3.2 due to the implementation of the integration by parts given in Lemma 5.1. Let us suppose for a moment that \(W\) is constant over the diagonal neighborhood \(\mathcal{D}_{\kappa}\), in which case, a diligent study of the proof presented would lead to the conclusion that
\[\|\Psi_{f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})}=\mathcal{O}(e^{-CN^{2(\beta- \alpha)}}),\]
and it would have been enough to select \(N=C\lceil(\log(1/\varepsilon))^{1/(2(\beta-\alpha))}\rceil\).
### Proof of Lemma 5.1
The lemma is a direct consequence of the following known result which we provide for the reader.
**Theorem 5.1**.: _(Abel's identity) [3, Theorem 4.2] Let \(\{a_{n}\}_{n\geq 0}\) be a real-valued sequence. Define, for \(t\geq 0\)_
\[A(t):=\sum_{n\leq t}a_{n}, \tag{5.22}\]
_and \(A(t)=0\) if \(t<0\). Then for every \(g\in C^{1}[u,v]\), one has,_
\[\sum_{u<n\leq v}a_{n}g(n)=A(v)g(v)-A(u)g(u)-\int_{u}^{v}A(y)g^{\prime}(y)\, \mathrm{d}y. \tag{5.23}\]
To apply Theorem 5.1, we define \(\{a_{n}\}_{n\geq 0}\) be such that \(a_{0}=1\) and \(a_{n}=0\) if \(n\neq 0\). Let \(A\) be as in (5.22), so
\[A(t)=\chi_{\{t\geq 0\}}(t). \tag{5.24}\]
For \(x\) and \(j\) as stated in the lemma, we define
\[\tilde{\mathcal{G}}(y):=(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2N-y).\]
Observe that \(\tilde{\mathcal{G}}\in C^{1}([x-r-j/2N,x+r-j/2N])\). Therefore it follows from (5.23) and (5.24) that
\[\sum_{x-r-j/2N<n\leq x+r-j/2N}a_{n}\tilde{\mathcal{G}}(n) =A(x+r-j/2N)\tilde{\mathcal{G}}(x+r-j/2N)-\int_{0}^{x+r-j/2N}( \mathrm{d}/\mathrm{d}y)\tilde{\mathcal{G}}(y)\,\mathrm{d}y\] \[\Rightarrow(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2N) =(s_{N}\,\mathcal{G}_{r,\sigma})(-r)+\int_{-r}^{x-j/2N}(\mathrm{ d}/\mathrm{d}y)(s_{N}\,\mathcal{G}_{r,\sigma})(y)\,\mathrm{d}y. \tag{5.25}\]
On the other hand,
\[\int_{x-r}^{x+r}ReLU(y-j/2N)(d^{2}/dy^{2})(s_{N}\,\mathcal{G}_{r, \sigma})(x-y)\,\mathrm{d}y\] \[\qquad=\int_{-r}^{x-j/2N}(x-y-j/2N)(d^{2}/dy^{2})(s_{N}\, \mathcal{G}_{r,\sigma})(y)\,\mathrm{d}y\] \[\qquad=-(x+r-j/2N)(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime}(-r)+ \int_{-r}^{x-j/2N}(\mathrm{d}/\mathrm{d}y)(s_{N}\,\mathcal{G}_{r,\sigma})(y) \,\mathrm{d}y, \tag{5.26}\]
and so combining (5.25) and (5.26) yields
\[\int_{x-r}^{x+r}ReLU(y-j/2N)(d^{2}/dy^{2})(s_{N}\,\mathcal{G}_{r, \sigma})(x-y)\,\mathrm{d}y\\ =-(x+r-j/2N)(s_{N}\,\mathcal{G}_{r,\sigma})^{\prime}(-r)-s_{N}\, \mathcal{G}_{r,\sigma}(-r)+(s_{N}\,\mathcal{G}_{r,\sigma})(x-j/2N),\]
which is what we want.
### Proof of Lemma 5.2
For \(k=1,2,3\) we have, from (5.2), that
\[(s_{N}\,\mathcal{G}_{r,\sigma})^{(k)}(x)=\sum_{l=0}^{k}\binom{k}{l}(s^{(l)}\, \mathcal{G}_{\sigma}^{(k-l)})(x),\quad\forall x\in[-r,r]. \tag{5.27}\]
We first prove (a), so we take \(k=1\). We utilize the Poisson formulation (4.17), which states
\[\mathcal{G}_{\sigma}(x)=\sum_{l\in\mathbb{Z}}\mathfrak{g}(x+l),\quad\forall x \in[0,1].\]
where \(\mathfrak{g}(x)=d(\sigma)e^{-2x^{2}\pi^{2}\sigma^{2}}\) on \(\mathbb{R}\) and \(d(\sigma)=\sigma c(\sigma)\sqrt{2\pi}\). Therefore,
\[\mathcal{G}_{\sigma}^{\prime}(r)=\sum_{l\in\mathbb{Z}}\mathfrak{g}^{\prime}(r +l)=-4\pi^{2}\sigma^{2}d(\sigma)\sum_{l\in\mathbb{Z}}(r+l)e^{-2(r+l)^{2}\pi^{2} \sigma^{2}}.\]
Since \(r\in(0,1/2)\), simple dominations and an application of Mills' ratio yield
\[\begin{split}|\mathcal{G}^{\prime}_{\sigma}(r)|&\leq C \sigma^{2}d(\sigma)\bigg{(}e^{-2\pi^{2}\sigma^{2}(1-r)^{2}}+\int_{1-r}^{\infty} e^{-\pi^{2}y^{2}\sigma^{2}}\,\mathrm{d}y\bigg{)}\\ &\leq C\sigma^{3}e^{-2\pi^{2}\sigma^{2}(1-r)^{2}}+C\sigma e^{- \pi^{2}\sigma^{2}(1-r)^{2}}\\ &\leq C(N-\mathfrak{m})^{\beta}e^{-(N-\mathfrak{m})^{2\beta}/24}. \end{split} \tag{5.28}\]
Now, it's evident that
\[\|s^{\prime}\|_{L^{\infty}([0,1])}\leq CN,\quad\|s^{\prime\prime}\|_{L^{\infty }([0,1])}\leq CN^{2},\quad\|s^{\prime\prime\prime}\|_{L^{\infty},([0,1])}\leq CN ^{3}, \tag{5.29}\]
and that
\[|\mathcal{G}_{\sigma}(r)|\leq C(N-\mathfrak{m})^{\beta}e^{-3\pi^{2}(N- \mathfrak{m})^{2(\beta-\alpha)}} \tag{5.30}\]
was demonstrated in (4.28). Thus, combining (5.27), (5.28), (5.29), (5.30) with that \(|\mathcal{G}_{\sigma}(r)|=|\mathcal{G}_{r,\sigma}(r)|\), \(|\mathcal{G}^{\prime}_{\sigma}(r)|=|\mathcal{G}^{\prime}_{r,\sigma}(r)|\), we have the proof of statement (a).
We will now prove statements (b), (c), (d) simultaneously. If \(x\in[-r,r]\), then similar to the calculation done in (5.28), we can obtain
\[|\mathcal{G}^{\prime}_{r,\sigma}(x)|=|\mathcal{G}^{\prime}_{\sigma}(x)|\leq C (N-\mathfrak{m})^{\beta}e^{-(N-\mathfrak{m})^{2\beta}/24}, \tag{5.31}\]
which is of order \(\mathcal{O}(1)\) whenever \(N\) is sufficiently large. Moreover, by definition (4.15)
\[\mathcal{G}^{(k)}_{r,\sigma}(x)=\mathcal{G}^{(k)}_{\sigma}(x)=(i2\pi)^{k}c( \sigma)\sum_{l\in\mathbb{Z}}l^{k}e^{-l^{2}\sigma^{-2}/2}e^{i2\pi lx}\]
for \(k=1,2,3\). Hence,
\[|\mathcal{G}^{(k)}_{r,\sigma}(x)|=|\mathcal{G}^{(k)}_{\sigma}(x)|\leq C \sigma^{k+1}\sum_{l\in\mathbb{N}}\bigg{(}\frac{l^{k}}{\sigma^{k}}e^{-l^{2} \sigma^{-2}/2}\bigg{)}\frac{1}{\sigma}\leq C\sigma^{k+1}\bigg{(}1+\int_{0}^{ \infty}x^{k}e^{-x^{2}}\,\mathrm{d}x\bigg{)}\]
which, together with (5.29), (5.31), yields (b), (c), (d), as desired.
## 6 Proof of Theorem 3.3
We start out with some preparation. We continue to assume (5.5) holds with \(\alpha=0.96\). Let the graph \(G_{n}^{\mathrm{det}}\) and its graph signal \(f_{n}\) be as in the premise of Theorem 3.3. As illustrated by SS2.3, SS2.5, we can identify the graph signal \(f_{n}\) with a function on \(\mathcal{X}_{n}=\{x_{1},\cdots,x_{n}\}\), where
\[x_{k}=\frac{k-1}{n}\in[0,1].\]
Recall that \(f_{n}(x_{k})=f(x_{k})\), for every \(x_{k}\), and the following abbreviations set in the proof of Theorem 3.2:
\[\mathcal{G}^{*}(x,y)=\frac{\mathrm{d}^{2}}{\mathrm{d}y^{2}}(s_{N}\,\mathcal{G }_{r,\sigma})(x-y)\quad\text{ and }\quad\rho_{j}(x)=ReLU_{j/2N}(x).\]
Then, from SS2.5, the GNN instantiated by \(\Psi_{n,f}\) is expressed as
\[\Psi_{n,f}(x_{k})=\sum_{j=0}^{2N-1}f(j/2N)\mathfrak{F}(\rho_{j})(x_{k}).\]
Since \(f\in\mathcal{B}_{\mathfrak{m}}\), we infer from Theorem 3.2 that the WNN machinery described therein yields the following outcome
\[\Psi_{f}(x)=\sum_{j=0}^{2N-1}f(j/2N)T_{\mathcal{K}}\rho_{j}(x)\approx f(x)\]
in the \(L^{2}\) sense on the predictable zone \([r,1-r]\). Therefore, by establishing that
\[\mathfrak{F}(\rho_{j})(x)\approx T_{\mathcal{K}}(\rho_{j})(x) \tag{6.1}\]
in some appropriate sense, we would complete a substantial portion of our proof. However, as \(\mathfrak{F}(\rho_{j})\) is a graph signal and \(T_{\mathcal{K}}(\rho_{j})\) a graphon signal, to make sense of (6.1), we must extend the former to a graphon signal. We proceed with the necessary steps below.
We write our graph filter (see (2.26), (3.10)) as
\[\mathfrak{F}(g_{n})(x_{k}) =\frac{1}{n\mathcal{W}_{x_{k}}}\sum_{l=1}^{n}\mathcal{G}^{*}(x_{ k},x_{l})[\mathbf{A}_{n}]_{k,l}g_{n}(x_{l})\] \[=\frac{1}{n\mathcal{W}_{x_{k}}}\sum_{l\neq k,l=1}^{n}\mathcal{G}^ {*}(x_{k},x_{l})W(x_{k},x_{l})g_{n}(x_{l}),\]
for a graph signal \(g_{n}\). For each \(j=0,\cdots,N-1\), we define a step graphon signal
\[\overline{\mathfrak{F}(\rho_{j})}(x):=\sum_{k=1}^{n}\mathfrak{F}(\rho_{j})(x_ {k})\chi_{I_{k}}(x)\quad\forall x\in[0,1], \tag{6.2}\]
where, recall that \(I_{k}=[(k-1)/n,k/n)\). Note that, \(\overline{\mathfrak{F}(\rho_{j})}(x_{k^{\prime}})=\mathfrak{F}(\rho_{j})(x_{ k^{\prime}})\) for any \(k^{\prime}=1,\cdots,n\), and
\[\begin{split}\overline{\Psi}_{n,f}(x)&=\sum_{k=1}^{ n}\Psi_{n,f}(x_{k})\chi_{I_{k}}(x)=\sum_{k=1}^{n}\bigg{(}\sum_{j=0}^{2N-1}f(j/2N) \mathfrak{F}(\rho_{j})(x_{k})\bigg{)}\chi_{I_{k}}(x)\\ &=\sum_{j=0}^{2N-1}f(j/2N)\overline{\mathfrak{F}(\rho_{j})}(x) \end{split} \tag{6.3}\]
by definition (3.12). With that, we can now formalize (6.1) as follows.
**Lemma 6.1**.: _Let \(\alpha,\beta\) be as prescribed by Theorem 3.3. Then there exists \(C>0\) such that, for each \(k=1,\cdots,n\) and \(j=0,\cdots,2N-1\), we have_
\[|T_{\mathcal{K}}\rho_{j}(x_{k})-\overline{\mathfrak{F}(\rho_{j})}(x_{k})|\leq C \eta^{-1}(1+K)\bigg{(}\frac{N^{3\beta+1}}{n^{2}}+\frac{N^{3\beta-\alpha+1}}{n} \bigg{)}. \tag{6.4}\]
The proof of Lemma 6.1 is given in SS6.1, at the end of this section, so as for us to proceed with the proof of Theorem 3.3.
Proof of Theorem 3.3.: Without loss of generality, we assume \(\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}=1\). Recall the following function (5.19) from SS5:
\[f_{\sharp}(x)=\sum_{j=0}^{2N-1}f(j/2N)\rho_{j}(x),\quad\forall x\in[0,1].\]
As previously demonstrated, \(T_{\mathcal{K}}f_{\sharp}(x)=\sum_{j=0}^{2N-1}f(j/2N)T_{\mathcal{K}}\rho_{j}(x )=\Psi_{f}(x)\). Define
\[\overline{\mathfrak{F}(f_{\sharp})}(x):=\sum_{j=0}^{2N-1}f(j/2N)\overline{ \mathfrak{F}(\rho_{j})}(x),\quad\forall x\in[0,1]. \tag{6.5}\]
Then it's ready from (6.3) that \(\overline{\mathfrak{F}(f_{\sharp})}=\overline{\Psi}_{n,f}\) and \(\overline{\mathfrak{F}(f_{\sharp})}(x_{k})=\overline{\Psi}_{n,f}(x_{k})=\Psi _{n,f}(x_{k})\), for every \(k=1,\cdots,n\).
Let us examine the difference \(|T_{\mathcal{K}}f_{\sharp}(x_{k})-\overline{\mathfrak{F}(f_{\sharp})}(x_{k}) |=|\Psi_{f}(x_{k})-\Psi_{n,f}(x_{k})|\). By definition, \(T_{\mathcal{K}}\rho_{j}(x_{k})=0=\mathfrak{F}(\rho_{j})(x_{k})\) if \(|x_{k}-j/2N|>r\). Therefore,
\[\begin{split}|\Psi_{f}(x_{k})-\Psi_{n,f}(x_{k})|& =|T_{\mathcal{K}}f_{\sharp}(x_{k})-\overline{\mathfrak{F}(f_{\sharp})}(x_{k}) |\\ &\leq\sum_{j=0}^{2N-1}|f(j/2N)||T_{\mathcal{K}}\rho_{j}(x_{k})- \overline{\mathfrak{F}(\rho_{j})}(x_{k})|\\ &\leq C\eta^{-1}(1+K)N^{1/2-\alpha/2}\bigg{(}\frac{N^{3\beta+1}} {n^{2}}+\frac{N^{3\beta-\alpha+1}}{n}\bigg{)},\end{split} \tag{6.6}\]
where the last line follows from Lemmas 2.1 and 6.1 and from the fact that there are only \(\lceil rN\rceil\) indices \(j\) partaking in (6.6).
On the other hand, it can be readily assumed that
\[n>2N>N^{\alpha}. \tag{6.7}\]
Recall that \(\alpha=0.96\) and we have selected \(N\geq\lceil\varepsilon^{-10/9}\rceil\), this condition implies \(n\geq\varepsilon^{-1}\). It also follows that, if \(x\in[(k-1)/n,k/n)=I_{k}\) then \(x\in\mathfrak{I}_{x_{k}}\), and moreover, there can only be one \(j/2N\) in \((\mathfrak{J}_{x_{k}}\setminus\mathfrak{J}_{x})\cup(\mathfrak{J}_{x}\setminus \mathfrak{J}_{x_{k}})\). Let \(j=0,\cdots,2N-1\) be such that \(T_{\mathcal{K}}\rho_{j}(x_{k})\neq 0\) and \(T_{\mathcal{K}}\rho_{j}(x)\neq 0\), i.e., \(j/2N\in\mathfrak{I}_{x_{k}}\cap\mathfrak{I}_{x}\). Then for almost every \(x\in I_{k}\)
\[|T_{\mathcal{K}}\rho_{j}(x_{k})-T_{\mathcal{K}}\rho_{j}(x)| =\bigg{|}\int_{0}^{1}\bigg{(}\frac{\mathcal{G}^{*}(x_{k},y)W(x_{k },y)}{\mathcal{W}_{x_{k}}}-\frac{\mathcal{G}^{*}(x,y)W(x,y)}{\mathcal{W}_{x}} \bigg{)}\rho_{j}(y)\,\mathrm{d}y\bigg{|}\] \[=\bigg{|}\int_{\mathfrak{J}_{x_{k}}\cap\mathfrak{J}_{x}}\bigg{(} \frac{\mathcal{G}^{*}(x_{k},y)W(x_{k},y)}{\mathcal{W}_{x_{k}}}-\frac{ \mathcal{G}^{*}(x,y)W(x,y)}{\mathcal{W}_{x}}\bigg{)}\rho_{j}(y)\,\mathrm{d}y \bigg{|}\] \[\leq\frac{C\eta^{-2KN^{3\beta-\alpha}}}{n}+\frac{C\eta^{-1}N^{3 \beta-\alpha+1}}{n}+\frac{C\eta^{-1}KN^{3\beta-\alpha}}{n}, \tag{6.8}\]
since, by Assumption 2.1, \(|W(x_{k},y)-W(x,y)|\leq K/n\) for every \(y\in\mathfrak{I}_{x_{k}}\cap\mathfrak{I}_{x}\), and since
\[|\mathcal{G}^{*}(x_{k},y)-\mathcal{G}^{*}(x,y)|\leq\frac{CN^{3\beta+1}}{n},\]
by Lemma 5.2, and lastly, similar to what was done in (5.11)
\[\bigg{|}\frac{1}{\mathcal{W}_{x_{k}}}-\frac{1}{\mathcal{W}_{x_{k}}}\bigg{|} \leq\eta^{-2}\bigg{(}|\mathcal{W}_{x_{k}}-W(x_{k},x)|+|W(x_{k},x)-\mathcal{W}_ {x}|\bigg{)}\leq\frac{2K\eta^{-2}}{n}.\]
If \(j=0,\cdots,2N-1\) is such that \(T_{\mathcal{K}}\rho_{j}(x_{k})=0\) and \(T_{\mathcal{K}}\rho_{j}(x)\neq 0\) or \(T_{\mathcal{K}}\rho_{j}(x_{k})\neq 0\) and \(T_{\mathcal{K}}\rho_{j}(x)=0\), then \(j/2N\in[x_{k}+r,x+r]\cap[0,1]\) or \(j/2N\in[x_{k}-r,x-r]\cap[0,1]\), respectively. In either scenario, we obtain
\[|T_{\mathcal{K}}\rho_{j}(x_{k})-T_{\mathcal{K}}\rho_{j}(x)|\leq C\eta^{-1}N^{ 3\beta}\int_{0}^{1/n}y\,\mathrm{d}y\leq\frac{C\eta^{-1}N^{3\beta}}{n^{2}}. \tag{6.9}\]
With (6.6), (6.8), (6.9) at hand, we can now estimate \(|T_{\mathcal{K}}f_{\sharp}-\overline{\mathfrak{F}(f_{\sharp})}|=|\Psi_{f}- \overline{\Psi}_{n,f}|\) on \([r,1-r]\). Let \(x_{k^{*}}\) denote the first \(x_{k}\in[r,1-r]\). Then
\[[r,x_{k^{*}})\subset[x_{k^{*}-1},x_{k^{*}})=\mathfrak{I}_{x_{k^{*}-1}}\quad \text{ and }\quad[x_{k^{*}},1-r]\subset\bigcup_{x_{k}\in[r,1-r]}[x_{k},x_{k+1}).\]
Keeping this in mind, and combining (6.6), (6.8), (6.9), we deduce that for almost every \(x\in[(k-1)/n,k/n)\), where either \(x_{k}=x_{k^{*}-1}\) or \(x_{k}\in[r,1-r]\)
\[|T_{\mathcal{K}}f_{\sharp}(x)-\overline{\mathfrak{F}(f_{\sharp}) }(x)| \leq\sum_{j=0}^{2N-1}|f(j/2N)|\bigg{(}|T_{\mathcal{K}}\rho_{j}(x)- T_{\mathcal{K}}\rho_{j}(x_{k})|+|T_{\mathcal{K}}\rho_{j}(x_{k})-\overline{ \mathfrak{F}(\rho_{j})}(x_{k})|\bigg{)}\] \[\leq C\sum_{j=0}^{2N-1}|f(j/2N)|\bigg{(}\frac{\eta^{-2}(1+K)N^{3 \beta-\alpha+1}}{n}+\frac{\eta^{-1}N^{3\beta}}{n^{2}}\bigg{)}\] \[\leq C\eta^{-2}N^{1/2-\alpha/2}\bigg{(}\frac{(1+K)N^{3\beta-\alpha +1}}{n}+\frac{N^{3\beta}}{n^{2}}\bigg{)},\]
since, by the arguments presented above, there are at most \(\lceil rN\rceil+1\) indices \(j\) participating in the sum. Therefore,
\[\|T_{\mathcal{K}}f_{\sharp}-\overline{\mathfrak{F}(f_{\sharp})}\|_{L^{2}([r,1 -r];\mathbb{C}^{m})}\leq C\eta^{-2}N^{1/2-\alpha/2}\bigg{(}\frac{(1+K)N^{3 \beta-\alpha+1}}{n}+\frac{N^{3\beta}}{n^{2}}\bigg{)},\]
which together with Theorem 3.2, yields
\[\|\overline{\Psi}_{n,f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})} \leq\|\overline{\mathfrak{F}(f_{\sharp})}-T_{\mathcal{K}}f_{\sharp }\|_{L^{2}([r,1-r];\mathbb{C}^{m})}+\|T_{\mathcal{K}}f_{\sharp}-f\|_{L^{2}([r,1 -r];\mathbb{C}^{m})} \tag{6.10}\] \[\leq C\eta^{-2}N^{1/2-\alpha/2}\bigg{(}\frac{(1+K)N^{3\beta-\alpha +1}}{n}+\frac{N^{3\beta}}{n^{2}}\bigg{)}+C\eta^{-1}K\varepsilon.\]
Since \(\beta=0.98\), we only need to impose
\[n\geq\frac{N^{3\beta-3\alpha/2+3/2}}{\varepsilon}\geq\varepsilon^{-13/3}. \tag{6.11}\]
Note that (6.11) implies (6.7). Putting (6.11) back in (6.10), we obtain
\[\|\overline{\Psi}_{n,f}-f\|_{L^{2}([r,1-r];\mathbb{C}^{m})}\leq C\eta^{-2}(1+K)\varepsilon\]
thereby concluding the proof.
**Remark 6.1**.: A quick calculation shows that the smallest possible power of \(\varepsilon\) in (6.11) that could be achieved for \(n\) is \(4\). Indeed, let \(\Delta=\beta-\alpha\). Then \(3\beta-3\alpha/2+3/2=3\alpha/2+3\Delta+3/2\). Getting the power \(\delta\) in \(N^{-\delta}\sim\varepsilon\) as close to \(1\) as possible requires \(\alpha\) to be also close to \(1\), and \(\Delta\) close to \(0\), giving the smallest possible value of \((3\beta-3\alpha/2+3/2)/\delta\) to be \(3\).
### Proof of Lemma 6.1
Fix one \(x_{k}\), and let \(j=0,\cdots N-1\). Since \(|x_{k}-j/2N|>r\) implies \(T_{\mathcal{K}}\rho_{j}(x_{k})=0=\mathfrak{F}\rho_{j}(x_{k})\). Therefore, we only consider those \(j\) where \(|x_{k}-j/2N|\leq r\). Take one such \(j\). Write
\[T_{\mathcal{K}}\rho_{j}-\overline{\mathfrak{F}(\rho_{j})}=T_{\mathcal{K}} \rho_{j}-T_{\mathcal{K}}\overline{\rho}_{j}+T_{\mathcal{K}}\overline{\rho}_{ j}-\overline{\mathfrak{F}(\rho_{j})} \tag{6.12}\]
where
\[\overline{\rho}_{j}(x):=\sum_{l=1}^{n}\rho_{j}(x_{l})\chi_{I_{l}}(x),\quad \forall x\in[0,1].\]
The difference \(T_{\mathcal{K}}\rho_{j}-T_{\mathcal{K}}\overline{\rho}_{j}\) is straightforward to address. In fact, from Lemma 5.2 we can manage
\[\|T_{\mathcal{K}}(\rho_{j}-\overline{\rho}_{j})\|_{L^{\infty}([0,1])} \leq\eta^{-1}\|\mathcal{G}^{*}\|_{L^{\infty}([0,1])}\|\rho_{j}- \overline{\rho}_{j}\|_{L^{1}([0,1])} \tag{6.13}\] \[\leq\frac{C\eta^{-1}\max\{N^{2},N^{3\beta}\}}{n}\] \[\leq\frac{C\eta^{-1}N^{3\beta}}{n},\]
since \(\beta=0.98\). The second to last bound above is due to
\[\|\rho_{j}-\overline{\rho}_{j}\|_{L^{1}([0,1])}\leq\sum_{k=1}^{n}\frac{1}{n^{ 2}}=\frac{1}{n},\]
as the functions \(\rho_{j}\) are ReLU functions, the maximum difference \(|\rho_{j}(x)-\rho_{j}(x_{k})|\leq 1/n\) for every \(x\) belonging to the interval \(I_{k}\) of length \(1/n\).
The second difference \(T_{\mathcal{K}}\overline{\rho}_{j}-\overline{\mathfrak{F}}(\rho_{j})\) on the right-hand-side of (6.12) requires a more delicate treatment. Using the definition (6.2) introduced at the beginning of this section, we get
\[|T_{\mathcal{K}}\overline{\rho}_{j}(x_{k})-\overline{\mathfrak{F} (\rho_{j})}(x_{k})|\\ \leq\frac{1}{\mathcal{W}_{x_{k}}}\sum_{l=1}^{n}\bigg{|}\int_{(l-1 )/n}^{l/n}\{\mathcal{G}^{*}(x_{k},y)W(x_{k},y)-\mathcal{G}^{*}(x_{k},x_{l})[ \mathbf{A}_{n}]_{k,l}\}\rho_{j}(x_{l})\,\mathrm{d}y\bigg{|}. \tag{6.14}\]
Observe that at most \(\lceil 2rn\rceil\) indices \(l\) participate in the sum above; namely those that satisfy
\[I_{l}=\left[\frac{l-1}{n},\frac{l}{n}\right)\cap\mathfrak{I}_{x_{k}}\neq \emptyset. \tag{6.15}\]
Among all the indices that satisfy (6.15), there will be at most two "boundary" \(l\) such that
\[I_{l}=\left[\frac{l-1}{n},\frac{l}{n}\right)\not\subset\mathfrak{I}_{x_{k}}, \tag{6.16}\]
on at most one of which,
\[\mathcal{G}^{*}(x_{k},x_{l})=0. \tag{6.17}\]
Let \(l^{*}\) denote this index and \(l_{*}\) denote the other index that satisfies (6.16). Let \(S\) be the set of the remaining, "interior", indices, i.e., those \(l\) that satisfy (6.15) but not (6.16). Among these include \(l=k\), in which case it follows directly from definition that
\[[\mathbf{A}_{n}]_{k,l}=[\mathbf{A}_{n}]_{k,k}=0. \tag{6.18}\]
Consider
\[D_{1} :=\frac{1}{\mathcal{W}_{x_{k}}}\bigg{|}\int_{(l^{*}-1)/n}^{l^{*}/ n}(\mathcal{G}^{*}(x_{k},y)W(x_{k},y)-\mathcal{G}^{*}(x_{k},x_{l^{*}})[ \mathbf{A}_{n}]_{k,l^{*}})\rho_{j}(x_{l^{*}})\,\mathrm{d}y\bigg{|}\] \[=\frac{1}{\mathcal{W}_{x_{k}}}\bigg{|}\int_{(l^{*}-1)/n}^{l^{*}/ n}\mathcal{G}^{*}(x_{k},y)W(x_{k},y)\rho_{j}(x_{l^{*}})\,\mathrm{d}y\bigg{|},\]
due to (6.17). We find, as a consequence of Lemma 5.2, that
\[D_{1}\leq\frac{1}{\mathcal{W}_{x_{k}}}\int_{(l^{*}-1)/n}^{l^{*}/ n}|\mathcal{G}^{*}(x_{k},y)W(x_{k},y)||\rho_{j}(x_{l^{*}})|\,\mathrm{d}y \leq\frac{C\eta^{-1}N^{3\beta}}{n}. \tag{6.19}\]
Likewise, by virtue of (6.18),
\[D_{2} :=\frac{1}{\mathcal{W}_{x_{k}}}\bigg{|}\int_{(k-1)/n}^{k/n}( \mathcal{G}^{*}(x_{k},y)W(x_{k},y)-\mathcal{G}^{*}(x_{k},x_{k})[\mathbf{A}_{n }]_{k,k})\rho_{j}(x_{k})\,\mathrm{d}y\bigg{|} \tag{6.20}\] \[=\frac{1}{\mathcal{W}_{x_{k}}}\bigg{|}\int_{(k-1)/n}^{k/n} \mathcal{G}^{*}(x_{k},y)W(x_{k},y)\rho_{j}(x_{k})\,\mathrm{d}y\bigg{|}\] \[\leq\frac{C\eta^{-1}N^{3\beta}}{n}.\]
Next, let
\[D_{3}:=\frac{1}{\mathcal{W}_{x_{k}}}\sum_{l\neq k,l\in S}\bigg{|}\int_{(l-1)/n}^{l /n}(\mathcal{G}^{*}(x_{k},y)W(x_{k},y)-\mathcal{G}^{*}(x_{k},x_{l})[\mathbf{A}_ {n}]_{k,l})\rho_{j}(x_{l})\,\mathrm{d}y\bigg{|}. \tag{6.21}\]
We estimate, on one of these intervals \(I_{l}\), that
\[\begin{split}&|\mathcal{G}^{*}(x_{k},x_{l})[\mathbf{A}_{n}]_{k,l}- \mathcal{G}^{*}(x_{k},y)W(x_{k},y)|\\ &\leq|\mathcal{G}^{*}(x_{k},x_{l})-\mathcal{G}^{*}(x_{k},y)|+|[ \mathbf{A}_{n}]_{k,l}-W(x_{k},y)||\mathcal{G}^{*}(x_{k},y)|\\ &=|\mathcal{G}^{*}(x_{k},x_{l})-\mathcal{G}^{*}(x_{k},y)|+|W(x_{ k},l\,)-W(x_{k},y)||\mathcal{G}^{*}(x_{k},y)|\leq\frac{CN^{3\beta+1}}{n}+\frac{ CKN^{3\beta}}{n}\end{split} \tag{6.22}\]
where the last inequality follows from Lemma 5.2 and Assumption 2.1 on \(W\). By plugging this bound back in (6.21), we gain
\[D_{3}\leq C\eta^{-1}(1+K)\bigg{(}\sum_{l\neq k,l\in S}\frac{1}{n}\bigg{(}\frac {N^{3\beta+1}}{n}\bigg{)}\bigg{)}\leq C\eta^{-1}(1+K)\bigg{(}\frac{N^{3\beta- \alpha+1}}{n}\bigg{)}, \tag{6.23}\]
since \(\hash S\leq\lceil 2rn\rceil\). Finally, let
\[D_{4}:=\frac{1}{\mathcal{W}_{x_{k}}}\bigg{|}\int_{(l_{*}-1)/n}^{l_{*}/n}( \mathcal{G}^{*}(x_{k},y)W(x_{k},y)-\mathcal{G}^{*}(x_{k},x_{l_{*}})[\mathbf{A }_{n}]_{k,l_{*}})\rho_{j}(x_{l_{*}})\,\mathrm{d}y\bigg{|}.\]
Then following a similar calculation as in (6.22), we derive
\[|\mathcal{G}^{*}(x_{k},x_{l_{*}})[\mathbf{A}_{n}]_{k,l_{*}}-\mathcal{G}^{*}(x _{k},y)W(x_{k},y)|\leq\frac{CN^{3\beta+1}}{n}+\frac{CKN^{3\beta}}{n}\]
and so
\[D_{4}\leq C\eta^{-1}(1+K)\bigg{(}\frac{N^{3\beta+1}}{n^{2}}\bigg{)}. \tag{6.24}\]
Taking into account (6.12), (6.13), (6.14), (6.19), (6.20), (6.23), and (6.24), we arrive at (6.4), as desired.
## 7 Proof of Theorem 3.4
Throughout this section we continue to assume (5.5) holds. We continue to work with the shorthand abbreviations established in the previous sections, which are
\[\mathcal{G}^{*}(x,y)=\frac{\mathrm{d}^{2}}{\mathrm{d}y^{2}}(s_{N}\,\mathcal{G} _{r,\sigma})(x-y)\quad\text{ and }\quad\rho_{j}(x)=ReLU_{j/2N}(x).\]
The proof will be a straightforward application of the bounded-difference inequality and Theorem 3.2. As usual, we begin with some preliminary arrangements.
First, recall that in the case of a simple random graph \(G_{n}^{\text{ran}}\) generated from a graphon \(W\), the event of two vertices \(v_{k},v_{l}\) being connected by an edge is a random variable
\[\xi_{k,l}\sim\text{Bernoulli}(W(x_{k},x_{l})),\quad k>l. \tag{7.1}\]
Since \(W(x_{k},x_{l})=W(x_{l},x_{k})\), we have the undirected symmetry \(\xi_{lk}=\xi_{k,l}\) of the graph; nevertheless, each of the sets
\[\{\xi_{k,l}:k,l=1,\cdots,n\text{ s.t }k>l\}\quad\text{ and }\quad\{\xi_{k,l}:k,l=1, \cdots,n\text{ s.t }k<l\}\]
is an independent set of random variables. A realization of the random graph \(G_{n}^{\text{ran}}\) is then a simple graph whose associated adjacency matrix \(\mathbf{A}_{n}\) satisfies
\[[\mathbf{A}_{n}]_{k,l}\in\{0,1\}.\]
Using this matrix, the graph filter \(\mathfrak{F}\)'s application on a graph signal \(g_{n}\) has the value
\[\mathfrak{F}(g_{n})(x_{k})=\frac{1}{n\mathcal{W}_{x_{k}}}\sum_{l=1}^{n} \mathcal{G}^{*}(x_{k},x_{l})[\mathbf{A}_{n}]_{k,l}g_{n}(x_{l}).\]
Until \(\xi_{k,l}\) are all realized, the quantity
\[\mathfrak{F}^{\text{ran}}(g_{n})(x_{k}):=\frac{1}{n\mathcal{W}_{x_{k}}}\sum_{ l\neq k,l=1}^{n}\mathcal{G}^{*}(x_{k},x_{l})\xi_{k,l}g_{n}(x_{l}) \tag{7.2}\]
is a random variable, for each \(k=1,\cdots,n\), as indicated by the superscript 'ran'. Fix a \(k\) and \(j=0,\cdots,2N-1\). Set \(g_{n}=\rho_{j}\) in (7.2), suppressing the dependence on \(j\) for simplicity. We define the random variables
\[Y_{\mathcal{L}_{k}} :=\frac{1}{n\mathcal{W}_{x_{k}}}\sum_{l\in\mathcal{L}_{k}} \mathcal{G}^{*}(x_{k},x_{l})\xi_{k,l}\rho_{j}(x_{l})\] \[Y_{\mathcal{U}_{k}} :=\frac{1}{n\mathcal{W}_{x_{k}}}\sum_{l\in\mathcal{U}_{k}} \mathcal{G}^{*}(x_{k},x_{l})\xi_{k,l}\rho_{j}(x_{l}),\]
where
\[\mathcal{L}_{k} :=\{l<k:\mathcal{G}^{*}(x_{k},x_{l})>0,\rho_{j}(x_{l})>0\}\] \[\mathcal{U}_{k} :=\{l>k:\mathcal{G}^{*}(x_{k},x_{l})>0,\rho_{j}(x_{l})>0\};\]
note that
\[\text{\#}\mathcal{L}_{k},\text{\#}\mathcal{U}_{k}\leq\lceil nr\rceil. \tag{7.3}\]
We first focus on \(Y_{\mathcal{L}_{k}}\). Observe from (7.1) that
\[\mathbb{E}[Y_{\mathcal{L}_{k}}]=\frac{1}{n\mathcal{W}_{x_{k}}}\sum_{l\in \mathcal{L}_{k}}\mathcal{G}^{*}(x_{k},x_{l})W(x_{k},x_{l})\rho_{j}(x_{l}).\]
Moreover, \(Y_{\mathcal{L}_{k}}\) has the form of a function \(g_{\mathcal{L}_{k}}\) of \(L_{k}:=\#\mathcal{L}_{k}\) one-dimensional variables in \([0,1]\), applied to \(\{\xi_{k,l}:l\in\mathcal{L}_{k}\}\), where
\[g_{\mathcal{L}_{k}}((z_{l})_{l\in\mathcal{L}_{k}}):=\frac{1}{n\mathcal{W}_{x_{ k}}}\sum_{l\in\mathcal{L}_{k}}\mathcal{G}^{*}(x_{k},x_{l})\rho_{j}(x_{l})z_{l}.\]
Such a function \(g_{\mathcal{L}_{k}}\) is of bounded difference. Indeed, let \(z,z^{\prime}\) be two \(L_{k}\)-tuples that differ at only one coordinate entry. It's due to (5.5) that \(\mathcal{W}_{x_{k}}\geq\eta\), and Lemma 5.2 further provides
\[|g_{\mathcal{L}_{k}}(z)-g_{\mathcal{L}_{k}}(z^{\prime})|\leq\frac{C\eta^{-1}N ^{3\beta}}{n}. \tag{7.4}\]
As mentioned earlier, the central element of our proof is a bounded-difference inequality, presented as follows.
**Theorem 7.1**.: _(adapted from [56, Theorem 2.9.1]) Let \(X_{1},\cdots,X_{L}\) be independent random variables. Let \(g:\mathbb{R}^{L}\to\mathbb{R}\). Assume that the value of \(g(x)\) can be changed by at most \(c_{j}>0\) under an arbitrary change of a single coordinate of \(x\in\mathbb{R}^{L}\). Then for any \(\delta>0\), we have_
\[\mathbb{P}(|g(X)-\mathbb{E}[g(X)]|>\delta)\leq 2\exp\bigg{(}-\frac{2\delta^{2}} {\sum_{j=1}^{L}c_{j}^{2}}\bigg{)}\]
_where \(X=(X_{1},\cdots,X_{L})\)._
Proof of Theorem 3.4.: Applying Theorem 7.1 to \(Y_{\mathcal{L}_{k}}\), and using (7.3), (7.4), we acquire
\[\mathbb{P}(|Y_{\mathcal{L}_{k}}-\mathbb{E}[Y_{\mathcal{L}_{k}}]|>\varepsilon) \leq 2\exp\bigg{(}-\frac{C\varepsilon^{2}\eta^{2}n^{2}}{N^{6\beta- \alpha}}\bigg{)}.\]
A similar argument in the case of \(\mathcal{U}_{k}\) would also result in
\[\mathbb{P}(|Y_{\mathcal{U}_{k}}-\mathbb{E}[Y_{\mathcal{U}_{k}}]|>\varepsilon) \leq 2\exp\bigg{(}-\frac{C\varepsilon^{2}\eta^{2}n}{N^{6\beta-\alpha}} \bigg{)}.\]
Since \(Y_{\mathcal{L}_{k}}+Y_{\mathcal{U}_{k}}=\mathfrak{F}^{\mathrm{ran}}(\rho_{j}) (x_{k})\), we conclude that
\[\mathbb{P}(|\mathfrak{F}^{\mathrm{ran}}(\rho_{j})(x_{k})-\mathbb{E}[\mathfrak{ F}^{\mathrm{ran}}(\rho_{j})(x_{k})]|>\varepsilon)\leq 2\exp\bigg{(}-\frac{C \varepsilon^{2}\eta^{2}n}{N^{6\beta-\alpha}}\bigg{)}, \tag{7.5}\]
for every \(x_{k}\in\mathcal{X}_{n}\) and each fixed \(j=0,\dots,2N-1\).
Now, allowing \(j\) to vary gives
\[\mathbb{P}\bigg{(}\bigg{|}\sum_{j=0}^{2N-1}f(j/2N)\mathfrak{F}^{ \text{ran}}(\rho_{j})(x_{k})-\sum_{j=0}^{2N-1}f(j/2N)\mathbb{E}[\mathfrak{F}^{ \text{ran}}(\rho_{j})(x_{k})]\bigg{|}>\varepsilon\|f\|_{L^{2}([0,1];\mathbb{C}^ {m})}\bigg{)}\] \[\leq \mathbb{P}\bigg{(}\sum_{j=0}^{2N-1}|f(j/2N)||\mathfrak{F}^{\text{ ran}}(\rho_{j})(x_{k})-\mathbb{E}[\mathfrak{F}^{\text{ran}}(\rho_{j})(x_{k})]|> \varepsilon\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}\bigg{)}\] \[\leq \mathbb{P}\bigg{(}\bigg{(}\sum_{j=0}^{2N-1}|\mathfrak{F}^{\text{ ran}}(\rho_{j})(x_{k})-\mathbb{E}[\mathfrak{F}^{\text{ran}}(\rho_{j})(x_{k})]|^{2} \bigg{)}^{1/2}>\varepsilon\bigg{)}\] \[\leq 2N^{1-\alpha}\exp\bigg{(}-\frac{C\varepsilon^{2}\eta^{2}n}{N^{6 \beta-2\alpha+1}}\bigg{)}. \tag{7.6}\]
The number of indices \(j\) taking part in these sums above is again at most \(\lceil rN\rceil\). Therefore, the second to last inequality follows from the \(L^{p}\)-embedding for finite measures and the last from (7.5). Note that, by design
\[\sum_{j=0}^{2N-1}f(j/2N)\mathfrak{F}^{\text{ran}}(\rho_{j})(x_{k})\]
is the GNN network \(\Psi_{n,f}\) applying to the random graph \(G_{n}^{\text{ran}}\) (see (2.27)). In this case
\[\overline{\Psi}_{n,f}(x)=\sum_{k=1}^{n}\bigg{(}\sum_{j=0}^{2N-1}f(j/2N) \mathfrak{F}^{\text{ran}}(\rho_{j})(x_{k})\bigg{)}\chi_{I_{k}}(x),\]
and that from (6.2), (6.5)
\[\mathbb{E}[\overline{\Psi}_{n,f}(x)] =\sum_{j=0}^{2N-1}f(j/2N)\bigg{(}\sum_{k=1}^{n}\mathbb{E}[ \mathfrak{F}^{\text{ran}}(\rho_{j})(x_{k})]\chi_{I_{k}}(x)\bigg{)}\] \[=\sum_{j=0}^{2N-1}\frac{f(j/2N)}{n\mathcal{W}_{x_{k}}}\sum_{k=1}^ {n}\bigg{(}\sum_{l\neq k,l=1}^{n}\mathcal{G}^{*}(x_{k},x_{l})W(x_{k},x_{l}) \rho_{j}(x_{l})\bigg{)}\chi_{I_{k}}(x)\] \[=\sum_{j=0}^{2N-1}f(j/2N)\overline{\mathfrak{F}(\rho_{j})}(x)= \overline{\mathfrak{F}(f_{\sharp})}(x).\]
Therefore, based on (7.6), we deduce that for every \(x\in[r,1-r]\),
\[|\overline{\Psi}_{n,f}(x)-\overline{\mathfrak{F}(f_{\sharp})}(x)|\leq \varepsilon\|f\|_{L^{2}([0,1];\mathbb{C}^{m})} \tag{7.7}\]
with probability at least \(1-2nN^{1-\alpha}\exp(-\frac{C\varepsilon^{2}\eta^{2}n}{N^{6\beta-2\alpha+1}})\). On the other hand, we obtain from the proof of Theorem 3.3 that for almost every \(x\in[r,1-r]\)
\[\left|\overline{\mathfrak{F}(f_{\sharp})}(x)-T_{\mathcal{K}}f_{\sharp}(x) \right|\leq C\eta^{-2}(1+K)\,\varepsilon\,\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}, \tag{7.8}\]
whenever \(n\geq\lceil\varepsilon^{-13/3}\rceil\). By combining (7.7), (7.8), and recalling that \(N=\lceil\varepsilon^{-10/9}\rceil\), we infer that
\[|\Psi_{n,f}(x_{k})-f(x_{k})|\leq C\eta^{-2}(1+K)\,\varepsilon\,\|f\|_{L^{2}([0,1];\mathbb{C}^{m})}\]
holds for all \(x_{k}\in[r,1-r]\), with a probability at least
\[1-2n\varepsilon^{10(1-\alpha)/9}\exp\bigg{(}-\frac{C\eta^{2}n}{\varepsilon^{4 (15\beta-5\alpha-2)/9}}\bigg{)},\]
where \(\alpha=0.96\), \(\beta=0.98\), so as long as \(n\geq\varepsilon^{-13/3}\), leading us to the conclusion of the proof.
## 8 Discussion
In this work we have provided powerful novel results regarding the generalizability of WNNs and the transferability of GNNs. Our results were enabled first through the sampling routine in Theorem 3.1, which was used to inform our network architecture for both WNNs and GNNs. In the case of WNNs we provide bounds on the number of samples required to achieve the approximation of graphon signals to arbitrary accuracy using our proposed WNN architecture. These results were then leveraged to provide transferability results for GNNs across graphs belonging to the same graphon family. This included both deterministic weighted graphs and simple random graphs. Together these results constitute a significant advancement in the budding theory of graphons applied to neural networks and the expressive capabilities of WNNs.
We emphasize that these results mark only an initial step towards a unified theory of graphons and their application to GNNs. Moving forward we wish to expand the class of graphons for which our results apply beyond those that satisfy Assumption 2.1. For example, popular graphs/graphons in application are stochastic block models [1, 54] which do not satisfy our assumption. However, one may subdivide the domain of a stochastic block model according to each of the blocks, in which case our results can be applied piecewise to the distinct blocks. Hence, it is important that a follow-up work generalize our results to as wide a class of graphons as possible to provide the greatest applicability of our results. One direction in which such a generalization could be achieved is by replacing the graphon domain \([0,1]^{2}\) with \(\Omega^{2}\), for an arbitrary compact set \(\Omega\). In the case of a stochastic block model \(\Omega\) would take the form of a union over the finitely-many (compact) blocks. A presentation of graphons with arbitrary \(\Omega\) is done in [29] where much of the theory laid out in SS2.2 can still be applied, but the presentation becomes more delicate
at points. Therefore, such a generalization marks an immediate point for a follow-up investigation of our work herein.
Given that our work describes an explicit network architecture, we have therefore provided a simple GNN/WNN architecture that can be readily applied in experiments. As with all statements in mathematical analysis, our results are given in the worse case scenario and so it remains to benchmark our network's performance on real-world data. In particular, it would be interesting to compare the performance of our network architecture against some of the other architectures for both WNNs and GNNs that have been provided throughout the literature. Such experiments may provide key insights into better architectures and tighter bounds than those which are reported here.
As a final aside, we note that graphons can only describe _dense_ graphs. To fully generalize our results to accommodate a more diverse range of graph structures one should hope to be able to apply our results to _sparse_ graphs as well. There is theory for capturing sparse graph structures using graphons [6, 19, 32, 37] which could form the basis for an extension of our work in this paper. We expect such an extension to be highly nontrivial and leave it for future work.
## Acknowledgements
JJB was supported by an NSERC Discovery grant.
|
2307.11411 | Deep Directly-Trained Spiking Neural Networks for Object Detection | Spiking neural networks (SNNs) are brain-inspired energy-efficient models
that encode information in spatiotemporal dynamics. Recently, deep SNNs trained
directly have shown great success in achieving high performance on
classification tasks with very few time steps. However, how to design a
directly-trained SNN for the regression task of object detection still remains
a challenging problem. To address this problem, we propose EMS-YOLO, a novel
directly-trained SNN framework for object detection, which is the first trial
to train a deep SNN with surrogate gradients for object detection rather than
ANN-SNN conversion strategies. Specifically, we design a full-spike residual
block, EMS-ResNet, which can effectively extend the depth of the
directly-trained SNN with low power consumption. Furthermore, we theoretically
analyze and prove the EMS-ResNet could avoid gradient vanishing or exploding.
The results demonstrate that our approach outperforms the state-of-the-art
ANN-SNN conversion methods (at least 500 time steps) in extremely fewer time
steps (only 4 time steps). It is shown that our model could achieve comparable
performance to the ANN with the same architecture while consuming 5.83 times
less energy on the frame-based COCO Dataset and the event-based Gen1 Dataset. | Qiaoyi Su, Yuhong Chou, Yifan Hu, Jianing Li, Shijie Mei, Ziyang Zhang, Guoqi Li | 2023-07-21T08:10:26Z | http://arxiv.org/abs/2307.11411v3 | # Deep Directly-Trained Spiking Neural Networks for Object Detection
###### Abstract
Spiking neural networks (SNNs) are brain-inspired energy-efficient models that encode information in spatiotemporal dynamics. Recently, deep SNNs trained directly have shown great success in achieving high performance on classification tasks with very few time steps. However, how to design a directly-trained SNN for the regression task of object detection still remains a challenging problem. To address this problem, we propose EMS-YOLO, a novel directly-trained SNN framework for object detection, which is the first trial to train a deep SNN with surrogate gradients for object detection rather than ANN-SNN conversion strategies. Specifically, we design a full-spike residual block, EMS-ResNet, which can effectively extend the depth of the directly-trained SNN with low power consumption. Furthermore, we theoretically analyze and prove the EMS-ResNet could avoid gradient vanishing or exploding. The results demonstrate that our approach outperforms the state-of-the-art ANN-SNN conversion methods (at least 500 time steps) in extremely fewer time steps (only 4 time steps). It is shown that our model could achieve comparable performance to the ANN with the same architecture while consuming 5.83\(\times\) less energy on the frame-based COCO Dataset and the event-based Gen1 Dataset. Our code is available in [https://github.com/BICLab/EMS-YOLO](https://github.com/BICLab/EMS-YOLO).
## 1 Introduction
Object detection is a key and challenging problem in computer vision. It aims to recognize multiple overlapped objects and locate them with precise bounding boxes. This task has many applications in various fields, such as autonomous driving [3], security surveillance [46], and medical imaging [28]. Most existing frameworks (, YOLO series [37], RCNN series [13]) for object detection use artificial neural networks (ANNs), which have high performance but also high computational complexity and energy consumption. Spiking neural networks (SNNs), known as the third generation of neural networks [31, 39], potentially serves as a more efficient and biologically inspired way to perform object detection. Specifically, SNNs utilize binary signals (spikes) instead of continuous signals for neuron communication, which reduces data transfer and storage overhead. Furthermore, the SNNs exhibit asynchronous computation and event-driven communication, which could avoid unnecessary computation and synchronization overhead. When deployed on neuromorphic hardware [32, 35], SNNs show great energy efficiency.
However, most SNNs for object detection are converted from ANNs, which have some limitations. For example, Spiking-Yolo [23, 22] needs at least 3500 time steps to match the performance of the original ANN. Spike Calibration [25] can reduce the time steps to hundreds, but it still depends on the performance of the original ANN model. Moreover, most methods for converted SNNs are only applicable for static images, and not suitable for sparse event datas, because their dynamics are designed to approximate the expected activation of the ANN and fail to capture the spatiotemporal information of DVS data [10]. A promising approach is to train SNNs directly with surrogate gradient, which can achieve high performance with few time steps and process both static images and event data efficiently.
Another challenge is to deal with the multi-scale object features in object detection, which demands the network has sufficient representation capability. Correspondingly, deep structure training is needed. Existing models on object detection are limited to shallow structures [7] or hybrid
structures [26, 20] that may not be deployed on some neuromorphic hardware [8, 2, 29] where only spike operation is allowed. To achieve deep direct training of SNNs, Hu _et al_. [17] and Fang _et al_. [12] explored on classification tasks and proposed MS-ResNet and SEW-ResNet respectively to overcome the vanishing/exploding gradient problems and advanced the directly-trained SNNs to depths greater than 100 layers. Unfortunately, multi-scale transformation of channels and dimensions when extracting features of objects of different sizes will cause the problem of increased energy consumption due to non-spike convolutional operations in their networks to be prominent in the object detection task. Therefore, the problem of high energy consumption caused by the non-spike convolutional operations urgently needs to be addressed.
To tackle these problems, we propose a novel directly trained SNN for object detection based on the YOLO framework (EMS-YOLO). Our model is the first to use surrogate gradients to train a deep and large-scale SNN for object detection without converting from ANNs. Specially, to deal with the multi-scale object features in object detection, we design a new full-spike energy-efficient residual block, EMS-ResNet, that avoids redundant MAC operations caused by non-spike convolution. Our model can achieve high performance with few time steps and handle both static images and event data efficiently. Compared with other converted or hybrid SNNs for object detection, our model has higher performance and lower energy consumption.
Our major contributions of this paper can be summarized as follows:
* We propose EMS-YOLO, a novel directly trained spiking neural network for object detection, which could achieve better performance than the advanced ANN-SNN conversion methods while requiring only 4 time steps and inferencing in real time.
* We design an **E**nergy-efficient **M**embrane-Shortcut ResNet, EMS-ResNet, that enables full spiking in the network thus reducing power consumption. Moreover, we theoretically analyze that it can be trained deeply since it avoids gradient disappearance or explosion.
* The experiments on COCO and the Gen1 Datasets demonstrate that our models could achieve comparable performance to the ANN with the same architecture meanwhile reducing \(5.83\times\) energy consumption.
## 2 Related Work
### Deep Spiking Neural Networks
The training strategies for deep SNNs are mainly divided into ANN-SNN conversion and directly training SNNs. The essence of ANN-SNN conversion is to approximate the average firing rate of SNNs to the continuous activation value of ANNs that use ReLU as the nonlinearity [5, 11]. The performance of the converted SNN relies on the original ANN, and it is tough to get high-performance SNNs with low time delay and suffers performance losses during conversion. Moreover, the converted SNNs cannot work well on the sparse event data which can be effectively combined with neuromorphic hardware.
Inspired from the explosive development of ANNs, the researchers use the surrogate gradient to achieve directly training of SNNs. The mature back-propagation mechanism and diverse coding schemes [33, 21] have enabled directly-trained SNNs to work well on short time steps while requiring low power consumption. Zheng _et al_. [48] proposed the threshold-dependent batch normalization (TDBN) technique which could extend SNNs from a shallow structure (\(<\)10 layers) to a deeper structure (50 layers) based on the framework of STBP [41]. Hu _et al_. [17] and Fang _et al_. [12] advanced the achievement of high performance on classification tasks. Currently, there is some work that uses deep directly training SNN for regression tasks like object tracking [47, 43], image reconstruction [49], while the object detection task has not yet been explored.
### Energy-Efficient Object Detection
Significant vision sensors in object detection include frame-based and event-based cameras [24, 36], where the latter can handle challenging scenes such as motion blur, overexposure, and low light, and have become a hot spot in recent years. The mainstream deep learning-based detectors mainly fall into two categories: two-stage frameworks (RCNN series) [13], and one-stage frameworks (YOLO series [37], SSD [30], Transformer series [50]). They are implemented based on ANNs, which achieve high performance but also bring high energy consumption. Therefore, some explorations of SNN-based object detection have attempted to provide more energy-efficient solutions.
The earliest attempts [23, 22, 25] were based on ANN-SNN conversion method which requires long inference time and cannot be applied to event camera data due to the inherent limitations of the approach. Some hybrid architectures [26, 20] tried to use directly trained SNN backbones and ANN detection heads for object detection, while these detection heads introduce an additional amount of parameters. In this work, we present the first attempt of object detection with fully and deep directly trained SNNs.
### Spiking Residual Networks
The ANN-SNN conversion does not concern the design of residual blocks oriented to the trainability of deep SNNs, while the residual block is mainly utilized to achieve lossless accuracy [18, 40]. For directly training of SNNs, the residual structure empowers it to train deeply. Zheng _et al_. [48] firstly obtain directly trained ResNet-34/50 with
surrogate gradient. SEW-ResNet [12] and MS-ResNet [17] extended the depth of the SNN model to over 100 layers. However, the former is essentially an integer multiplication operation of the residual network. The latter focuses mainly on the spiking of residual paths and ignores the non-spiking structure on shortcut paths. When applied to object detection tasks with varying dimensionality and number of channels, these non-spike convolutions can result in heavy energy consumption. Therefore, we design a full spiking residual network to exploit the energy efficiency of SNN.
## 3 The Preliminaries of SNNs
### Spiking Neuron
Neurons are the basic units of a neural network, which convert a barrage of synaptic inputs into meaningful action potential outputs. In ANNs, artificial neurons discard temporal dynamics and propagate information only in the spatial domain. In contrast, in SNNs, spiking neurons are more biologically plausible as they mimic the membrane potential dynamics and the spiking communication scheme. Typically, the Leaky Integrate-and-Fire (LIF) model [1], the Hodgkin-Huxley (H-H) model [15] and the Izhikevich model [19] are the most famous ones. Among them, LIF models are widely adopted to construct SNNs due to its good trade-off between bio-plausibility and complexity. Also, they contain abundant biological features and consume less energy than the ANN neurons. In our work, we use the iterative LIF model proposed by Wu _et al._[42] in the SNN model, which can be described as:
\[V_{i}^{t+1,n+1}=\tau V_{i}^{t,n+1}(1-X_{i}^{t,n+1})+\sum_{j}W_{ij}^{n}X_{j}^{t +1,n} \tag{1}\]
\[X_{i}^{t+1,n+1}=H(V_{i}^{t+1,n+1}-V_{th}) \tag{2}\]
where the \(V_{i}^{t,n+1}\) is the membrane potential of the \(i\)-th neuron in the \(n+1\) layer at the timestep \(t\), \(\tau\) is a decay factor for leakage. The input to a synapse is the sum of \(j\) spikes \(X_{j}^{t+1,n}\) with synaptic weights \(W_{ij}^{n}\) from the previous layer \(n\). \(H(\cdot)\) denotes the Heaviside step function which satisfies \(H(x)=1\) for \(x\geq 0\), otherwise \(H(x)=0\). As shown in the Figure 2, a firing activity is controlled by the threshold \(V_{th}\), and the \(V^{t+1,n+1}\) will be reset to \(V_{rest}\) once the neuron emits a spike at time step \(t+1\).
### Training Strategies
In order to solve the problem that the spike cannot be differentiated in back-propagation, we use the surrogate gradient [41] which can be represented as:
\[\frac{\partial X_{i}^{t,n}}{\partial V_{i}^{t,n}}=\frac{1}{a}sign(|V_{i}^{t,n }-V_{th}|\leq\frac{a}{2}) \tag{3}\]
where \(a\) is introduced to ensure the integral of the gradient is 1 and determines the curve steepness.
We use the TDBN [48] normalization method which considers spatial and temporal domains. The TDBN can be described as:
\[V_{i}^{t+1,n+1}=\tau V_{i}^{t,n+1}(1-X_{i}^{t,n+1})+\mathrm{TDBN}(I_{i}^{t+1}) \tag{4}\]
\[\mathrm{TDBN}(I_{i}^{t+1})=\lambda_{i}\frac{\alpha V_{th}(I_{i}^{t+1}-\mu_{ci })}{\sqrt{\sigma_{ci}^{2}+\epsilon}}+\beta_{i} \tag{5}\]
where \(\mu_{ci},\sigma_{ci}^{2}\) are the mean and variation values for every channel using a mini-batch of sequential inputs \(\{I_{i}^{t+1}=\Sigma_{j}W_{ij}^{n}X_{j}^{t+1,n}|t=0,...,T-1\}\), \(\epsilon\) is a tiny constant to avoid dividing by zero, \(\lambda_{i},\beta_{i}\) are two trainable parameters, and \(\alpha\) is a threshold-dependent hyper-parameter.
### Energy Consumption
The number of operations is often used to measure the computational energy consumption of neuromorphic hardware. In ANNs, each operation involves multiplication and addition (MAC) of floating point numbers, and Times of floating-point operations (FLOPs) are used to estimate computational burden. SNNs have the energy-efficient property in neuromorphic hardware since the neurons only participate in the accumulation calculation (AC) when they spike and could achieve the calculation with about the same number of synaptic operations (SyOPs). However, many current SNNs introduce additional MAC operations due to their design flaws. Thus, we quantify the energy consumption of vanilla SNNs as \(E_{SNN}=\sum_{n}E_{b}\), for each block \(n\):
\[E_{b}=T\times(fr\times E_{AC}\times OP_{AC}+E_{MAC}\times OP_{MAC}) \tag{6}\]
where \(T\) and \(fr\) represents the total time steps and the block firing rate. The blocks are normally convolutional or fully connected, and the energy consumption is determined by the number of AC and MAC operations (\(OP_{AC},OP_{MAC}\)). In this work, we adopt the same structure of SNN and ANN to compare the energy consumption and assume that the data for various operations are 32-bit floating-point implementation in 45nm technology [16], where \(E_{MAC}=4.6pJ\) and \(E_{AC}=0.9pJ\).
## 4 Method
### Input Representation
Static Images InputsTypically, considering the spatio-temporal feature of SNNs, the static images generated by the frame cameras are copied and used as the input frame for each time step [17, 12, 44].
Event-based InputsEvent cameras work completely differently from frame cameras where each pixel responds
independently to changes in light. An event \(e_{n}=(x_{n},y_{n},t_{n},p_{n})\) is generated for a pixel \((x_{n},y_{n})\) at the timestamp \(t_{n}\) when the logarithmic light change \(I(x,y,t)\) exceeds the threshold \(\theta_{th}\). The polarity \(p_{n}\in\{-1,1\}\) denotes the increase or decrease of light intensity.
Given the spatio-temporal window \(\zeta\), the asynchronous event stream \(E=\{e_{n}\in\zeta:n=1,...,N\}\) represents a sparse grid of points in 3D space. In this work, we split \(E\) into temporal bins with a constant temporal window \(dt\), which maps the events into image-like 2D representations [2]. The network processes \(T\) fixed time steps each time, and the total sequence \(\Gamma=T\times dt\).
### The Energy-Efficient Resisual Block
Currently, the main structures used for deep directly training in SNNs are SEW-ResNet and MS-ResNet. Here, we define the output of the L-th residual block, denoted by \(\mathbf{X}^{L}\), as:
\[\mathbf{X}^{L}=Add(\mathbf{F}^{r}(\mathbf{X}^{L-1}),\mathbf{F}^{s}(\mathbf{X }^{L-1})) \tag{7}\]
where the residual path is \(\mathbf{F}^{r}(\cdot)\), and the shortcut path is represented as \(\mathbf{F}^{s}(\cdot)\). As shown in Figure 1a, SEW-ResNet implements residual learning by restricting the final LIF activation function to each of the residual and shortcut paths. When both paths transmit spikes, \(Add(\mathbf{F}^{r}(\mathbf{X}^{L-1}),\mathbf{F}^{s}(\mathbf{X}^{L-1}))=2\), which means that the non-spike convolution operation in the next block will introduce MAC operations. Although using either AND or IAND operation to avoid this problem has been tried, it comes with an unbearable performance loss. For the MS-ResNet in the Figure 1b, it is apparent that it ignores the non-spike convolution operations on shortcut paths. When the dimensionality of the network or the number of channels is constantly changing, the energy consumption caused by this component is not negligible. According to Equation 6, to achieve energy efficiency, we design a full-spike residual block (EMS-Block) from the perspective of reducing parameters, and avoiding MAC operations.
As illustrated in Figure 1c, our proposed EMS-ResNet is designed differently for channel number and dimension variation. The idea of MS-ResNet is adopted on the residual path. On the shortcut path, when the number of channels changes, an additional LIF is added before the convolution for converting the information into sparse spikes which enables the entire network can be fully spiked. We transform the EMS-Block into two formats (see Figure 2). The EMS-Block1 is used when the channel number is constant or decreasing. For increasing channel numbers, we design the EMS-Block2 that uses concatenation operations to feature reuse while reducing parameters. Considering features are usually extracted by constant downsampling in the object detection task, we use the maxpool to reduce parameters. Our design improves flow of information and the output flow on the shortcut path is conceptually approximate to the sum of synaptic inputs to neuronal membranes. The full spike feature implies energy efficient properties for the network, so we name our network as the Energy-Efficient Menbrane-Shortcut ResNet (EMS-ResNet).
### The EMS-YOLO Model
Our goal is to predict the classification and position of the objects from the given static image or event stream that can be represented as \(\mathbf{X}=\{X_{t}\}_{t=1}^{T}\). The dimensions of the input data \(X_{t}\) for each time step \(t\) are \(C\times H\times W\), where \(C\) is the channel number, \(H\times W\) is the resolution. To achieve this, we calculate the information of N objects \(\mathbf{B}=\{B_{n}\}_{n=1}^{N}\) by:
\[\mathbf{B}=\mathcal{D}(\mathbf{X}) \tag{8}\]
where each \(B_{n}=\{x_{n},y_{n},w_{n},h_{n},c_{n},f_{n}\}\) is the corresponding object's bounding box position and class prediction. \((x_{n},y_{n}),w_{n},h_{n}\) represent the upper-left spatial coordinates, width, and length of the bounding box, respectively. \(c_{n},f_{n}\) are the class and confidence level of the object, respectively. \(\mathcal{D}\) refers to our proposed EMS-YOLO, which could achieve performance comparable to that of a same-structure ANN, while inferring in real time.
Figure 1: **The Sew-ResNet, the MS-ResNet and proposed EMS-ResNet.** (a) The sum of spikes in SEW-ResNet causes non-spike convolution operations. (b) MS-ResNet introduces non-spike convolution on shortcut paths where the dimensionality and number of channels changes. (c) The full-spike EMS-ResNet.
As shown in Figure 2, our EMS-YOLO is a variation of the YOLO framework, consisting of two modules: the backbone for feature extraction and the detection heads. The analog pixel values \(\mathbf{X}\) of an image are directly applied to the input layer of EMS-YOLO. For the backbone, the first convolutional layer is trained to convert inputs into spikes where LIF neurons integrate the weighted inputs and generate output spike trains when the membrane potential exceeds the trained firing threshold. Then we employ the EMS-Modules to extract object features from different dimensions and number of channels, which can enhance the robustness of the network. The number of EMS-Blocks and the channel width can be dynamically adjusted to the particular task, that Ablation experiments are shown in Sec 5.3, and EMS-ResNet18 is shown in the Figure 2 as an example.
For the detection head, to avoid the loss of SNN performance due to the multi-layer direct-connected convolution structure [48] of the conventional detection head, in this work we take the yolov3-tiny detection head [38] as an example and replace multiple directly connected convolutions with EMS-Blocks.
The main challenge of object detection, as a regression task with SNN models, is to convert the features extracted with spike trains into accurate continuous value representations of the bounding boxes coordinates. Here, we feed last membrane potential of the neurons [49] into each detector to generate anchors of different sizes. After NMS processing, the final category and bounding box coordinates of different objects can be obtained. Our end-to-end EMS-YOLO is trained with the cross-entropy loss function1.
Footnote 1: [https://github.com/ultralytics/yolov3](https://github.com/ultralytics/yolov3)
### Analysis of Gradient Vanishing/Explosion Problems
To explore the potential of our EMS-ResNet to enable deep training, we analyze the feasibility from a theoretical perspective. According to Gradient Norm Equality (GNE) theory [6], our EMS-ResNet could avoid exploding and vanishing gradients.
**Lemma 1**.: _Consider a neural network that can be represented as a series of blocks as and the \(j\)th block's jacobian matrix is denoted as \(J_{j}\). If \(\forall j;\phi(J_{j}J_{j}^{\mathsf{T}})\approx 1\) and \(\varphi(J_{j}J_{j}^{\mathsf{T}})\approx 0\), the network achieves "Block Dynamical Isometry" and can avoid gradient vanishing or explosion._
Here, \(J_{j}\) means the Jacobian matrix of the block \(j\), \(j\) is the index of the corresponding block. \(\phi\) means the expectation of the normalized trace. \(\varphi\) means \(\phi(\mathbf{A}^{2})-\phi^{2}(\mathbf{A})\).
Briefly, the theory ensures the gradient of the network will not decrease to \(0\) or explode to \(\infty\) since every block have \(\phi(J_{j}J_{j}^{\mathsf{T}})\approx 1\). And \(\varphi(J_{j}J_{j}^{\mathsf{T}})\approx 0\) makes sure that accident situation won't happen. And in most cases[48][17], \(\phi(J_{j}J_{j}^{\mathsf{T}})\approx 1\) is enough for avoiding gradient vanish or exploding. Detailed description of the notation and the theory are in [6].
**Definition 1**.: _(General Linear Transform) Let \(\mathbf{f}(\mathbf{x})\) be a transform whose Jacobian matrix is \(\mathbf{J}\). \(f\) is called general linear transform when it satisfies:_
Figure 2: **The proposed directly-trained SNN for object detection (EMS-YOLO). EMS-YOLO mainly consists of backbone and head, which are mainly composed of EMS-Blocks. EMS-Module1 and EMS-Module2 are EMS-Block1 and MS-Block, EMS-Block2 and MS-Block connections respectively. EMS-Block2 is used when the number of output channels increases, otherwise, EMS-Block1 is used.**
\[E\left[\frac{\|\mathbf{f}(\mathbf{x})\|_{2}^{2}}{\operatorname{len}(\mathbf{f}(\mathbf{x}))} \right]=\phi\left(\mathbf{J}\mathbf{J}^{T}\right)E\left[\frac{\|\mathbf{x}\|_{2}^{2}}{ \operatorname{len}(\mathbf{x})}\right]. \tag{9}\]
According to the random matrix and mean field theory [34], the data flow propagating in the network can be regarded as random variables. Thus, \(\mathbf{x}\) is considered as a random variable. We denote the notation \(E\left[\frac{\|\mathbf{x}\|_{2}^{2}}{\operatorname{len}(\mathbf{x})}\right]\) as the \(2^{th}\) moment of input element.
The definition is useful for analysis the gradient. Because once the output of an EMS-Block is normalized by the BN layer, the \(2^{th}\) moment \(E\left[\frac{\|\mathbf{f}(\mathbf{x})\|_{2}^{2}}{\operatorname{len}(\mathbf{f}(\mathbf{x}))}\right]\) which we denote as \(\alpha_{2}\) is clear.
**Lemma 2** (Multiplication).: _(Theorem 4.1 in [6]) Given \(\mathbf{J}:=\prod_{j=L}^{1}\mathbf{J}_{j}\), where \(\{\mathbf{J}_{j}\in\mathbb{R}^{m_{j}\times m_{j-1}}\}\) is a series of independent random matrices. If \((\prod_{j=L}^{1}\mathbf{J}_{j})(\prod_{j=L}^{1}\mathbf{J}_{j})^{T}\) is at least the \(1^{st}\) moment unitarily invariant, we have_
\[\phi\left((\prod_{j=L}^{1}\mathbf{J}_{j})(\prod_{j=L}^{1}\mathbf{J}_{j})^{T}\right)= \prod_{j=L}^{1}\phi(\mathbf{J}_{j}\mathbf{J}_{j}{}^{T}). \tag{10}\]
**Lemma 3** (Addition).: _(Theorem 4.2 in [6]) Given \(\mathbf{J}:=\prod_{j=L}^{1}\mathbf{J}_{j}\), where \(\{\mathbf{J}_{j}\in\mathbb{R}^{m_{j}\times m_{j-1}}\}\) is a series of independent random matrices. If at most one matrix in \(\mathbf{J}_{j}\) is not a central matrix, we have_
\[\phi(\mathbf{J}\mathbf{J}^{T})=\sum_{j}\phi(\mathbf{J}_{j}\mathbf{J}_{j}{}^{T}). \tag{11}\]
The multiplication and addition principle provide us a technique for analysising the network with serial connections and parallel connections.
**Discussion for General Linear Transform.** Since the Jacobian matrix of pooling can be regarded as a matrix \(\mathbf{J}\) that the element of matrix \(\left[\mathbf{J}\right]_{ik}\in\{0,1\}\), \(0\) for the element not chosen while \(1\) for element chosen. Thus the pooling layer can be regarded as a general linear transform. Similarly, the UpSampling layer in the detection head is also a generalized linear transformation. Concatenation is general linear transform too, because the function of \(\mathbf{f}(\mathbf{x})=[\mathbf{x},\mathbf{\hat{f}}(\mathbf{x})]\) can be expressed as \(\mathbf{f}(\mathbf{x})=[\mathbf{I}\quad\mathbf{\tilde{J}}]\mathbf{x}\) if the function \(\mathbf{\hat{f}}\) is general linear transform. Since the BN and CONV layers are already discussed in [6], so we only need to assume that the LIF layer satisfy general linear transformation, which is already used in proof by [48]. Since the EMS-ResNet is a serial of basic EMS-Blocks and MS-Blocks, we can separately analysis those blocks and multiply them together.
**Proposition 1**.: _For EMS-Block1 and EMS-Block2, the Jacobian matrix of the block can be represented as \(\phi(\mathbf{J}_{j}\mathbf{J}_{j}^{T})=\frac{2}{\alpha_{2}^{1-1}}\)._
Proof.: It is detailed in **Supplementary Material Proof A.1 and Proof A.2**.
**Proposition 2**.: _For the EMS-ResNet, \(\phi(\mathbf{J}\mathbf{J}^{T})\approx 1\) can be satisfied by control the \(2^{th}\) moment of the input._
Proof.: It is detailed in **Supplementary Material Proof A.3**.
**Discussion about the proposition.** According to [6], \(\phi(\mathbf{J}\mathbf{J}^{T})\approx 1\) is the formal expression for GNE which ensures gradient vanishing or explosion will not happen. However, it is enough for solving gradient problems by just avoiding the exponential increase or decrease [6]. In our backbone, the MS-Block, the only factor to evoke exponential increase of gradient, whose increasing is stopped by the interspersing of EMS-Blocks. Even if the initialize of BN do not satisfy the constant for \(\phi(\mathbf{J}\mathbf{J}^{T})\approx 1\), the gradient of each block will not increase as the network goes deeper. Briefly, we improve the property of network at a structural level by our EMS-Blocks.
\begin{table}
\begin{tabular}{c c c c c} \hline \hline Method & Work & Model & Time Step(T) & [email protected] \\ \hline \multirow{3}{*}{Backpropagation} & \multirow{3}{*}{ANN} & Tiny-Yolo & / & 0.262 \\ & & ResNet50 & / & 0.460 \\ & & ResNet34 & / & 0.565 \\ \hline \multirow{6}{*}{ANN-SNN} & Spiking-Yolo [23] & & 3500 & 0.257 \\ & Bayesian Optimization [22] & Tiny-Yolo & 500 & 0.211 \\ & & & 5000 & 0.258 \\ \cline{2-4} & \multirow{3}{*}{Spike Calibration [25]} & & 64 & 0.331 \\ & & ResNet50+Burst+ & 128 & 0.436 \\ & & MLIPooling+SpiCalib & 256 & 0.453 \\ & & & 512 & 0.454 \\ \hline
**Directly-Trained** & \multirow{2}{*}{EMS-YOLO} & EMS-ResNet34 & **4** & **0.501** \\
**SNN** & & & & \\ \hline \hline \end{tabular}
\end{table}
Table 1: Results on the COCO2017 DataSet.
## 5 Experiments
To fully validate the effectiveness of our model, we conduct experiments on the frame-based COCO2017 Dataset [27] and the event-based Gen1 Dataset [9]. The detailed introduction of the Datasets are in the **Supplementary Material B**. For the object detection task, the most widely used model evaluation metric is the mean Average Precision (mAP). We report the mAP at IOU=0.5 ([email protected]) and the average AP between 0.5 and 0.95 ([email protected]:0.95).
### Experimental Setup
In all experiments, we set the reset value \(V_{reset}\) of LIF neurons to 0, the membrane time constant \(\tau\) to 0.25, the threshold \(V_{th}\) to 0.5, and the coefficient \(\alpha\) to 1. We mainly train models on 8 NVIDIA RTX3090 GPUs and adopt the SGD optimizer, the learning rate is set to \(1e^{-2}\). The network is trained for 300 epochs on the COCO2017 Dataset with a batch size of 32. On the Gen1 Dataset, we trained the model for 100 epochs, with the batch size of 128.
### Effective Test
COCO2017 DatasetOur models are trained on Mosaic data augmentation techniques [4] and tested to detect 80 objects of the COCO Dataset [27] on the validation set. As the first one to implement object detection task with directly trained SNNs, the main quantitative results are presented in Table 1. For comparison with the current best performance model Spike Calibration [25] based on ANN-SNN conversion method, we do experiments based on EMS-ResNet34, which has a reasonable number of parameters compared with ResNet50. We demonstrate that the directly training method can achieve higher performance at only 4 time steps, while the ANN-SNN conversion approach requires at least a several hundred time steps. Furthermore, with the same experimental settings and data augmentation methods, the performance of our model is comparable to that of the ANN with the same structure while reducing **5.83\(\times\)** of energy consumption.
GEN1 Automotive Detection DatasetAs the largest event camera-based dataset, it contains two categories (pedestrians and cars) [9]. Currently, only Cordone _et al_. [7] have experimented with the SNN method so far. They divided the event data into five temporal bins for each input to the network. In this paper, all the experiments on the Gen1 Dataset follow the same experimental setup with them.
The backbone of their shallow model is based on the lightweight structure of Sew-ResNet, and the detection head uses SSD. For fair comparison, we train a model with only 6.20 M parameters based on the EMS-ResNet10 structure while reducing the number of channels. The results in Table 2 show that our method can achieve the [email protected]:0.95 of 0.267 at the same number of time steps, which far outperforms their performance of 0.189. It is remarkable that our full-spike model is more sparse, with a spike firing rate of 21.15%, which implies lower energy consumption. We also conducted comparison experiments with an ANN-ResNet10 [14] of the same structure with reduced number of channels and discovered we even achieved better performance than the ANN network, which indicates that the SNN network may be more competitive in processing event data.
### Ablation Experiments
We conducted ablation experiments to better understand the effectiveness of different residual modules on reducing energy consumption, the effect of network depth and time step on model performance. All ablation experiments are performed by following the experimental setup in Sec 5.1, if not otherwise specified.
Different Residual BlocksTo explore the structural superiority of our EMS-Block, we made comparative experiments based on the Gen1 Dataset (shown in Table 3). All
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{Method} & \multirow{2}{*}{Model} & \multirow{2}{*}{Params} & \multicolumn{2}{c}{Firing Rate} & mAP & mAP \\ & & & & Rate & @0.5:0.95 & @0.5 \\ \hline \multirow{6}{*}{Sew-Reset} & MobileNet & \multirow{2}{*}{12.64M} & \multirow{2}{*}{5} & \multirow{2}{*}{22.22\%} & \multirow{2}{*}{0.174} & \multirow{2}{*}{/} \\ & -64+SSD & & & & & \\ & DenseNet & \multirow{2}{*}{24.26M} & \multirow{2}{*}{5} & \multirow{2}{*}{29.44\%} & \multirow{2}{*}{0.147} & \multirow{2}{*}{/} \\ & 121-24+SSD & VGG & & & & \\ & -11+SSD & & & & & \\ \hline ANN & ResNet10 & \multirow{4}{*}{8.20M} & / & / & 0.247 & 0.504 \\ EMS-ResNet & EMS-Res10 & & **6.20M** & 5 & **21.15\%** & **0.267** & **0.547** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Results on Gen1 Dataset.
Figure 3: **Object detection results on the Gen1 Dataset.**
experiments are trained with only 50 epochs, and the batch-size is set to 64. From the experimental results, we found that the performance of our full-spike EMS-ResNet is comparable to those of the other two ResNets with non-spikes and the sparsity of the network is also maintained. The full-spike property of EMS-ResNet enables the network to be energy efficiency. According to Equation 6, we calculated the energy consumption of the network, excluding the convolutional energy consumption from the first coding layer. The energy consumption on ANN-ResNet18 is around \(9.65mJ\), which we denote this baseline energy consumption as \(1\times\). Our EMS-Res18 can reduce up to \(4.91\times\) of energy consumption.
Numbers of Residual BlocksIn Sec 4.4, we theoretically analyze that our EMS-ResNet can achieve deep training. Here we report results in Table 4 on the Gen1 Dataset based on EMS-Res10, EMS-Res18, and EMS-Res34, respectively. When the scale of the network is larger, the feature extraction ability becomes stronger (see Figure 3).
Size of Time StepsDue to the sparsity of event streams, different event sampling strategies may affect the ablation experiment of time steps on Gen1 Dataset. Thus, we report the performance of EMS-ResNet10 based on the COCO2017 Dataset for T = 1, 3, 5, 7 in Table 5. The time steps can be dynamically adjusted to achieve a balance of effectiveness and efficiency according to the needs of the actual task. We show some detection results on the test set compared in Figure 4, where it can be found that the accuracy of object detection is higher when the time step is longer. Here, we first train the model based on T=1, and then use the training model with T=1 as a pre-training model with multiple time steps, which can effectively reduce the training time.
\begin{table}
\begin{tabular}{c c c c c} \hline \hline Model & \begin{tabular}{c} mAP \\ @0.5 \\ \end{tabular} & \begin{tabular}{c} mAP \\ @0.5:0.95 \\ \end{tabular} & Params &
\begin{tabular}{c} Firing \\ Rate \\ \end{tabular} \\ \hline EMS-Res10 & 0.547 & 0.267 & 6.20M & 21.15\% \\ EMS-Res18 & 0.565 & 0.286 & 9.34M & 20.09\% \\ EMS-Res34 & 0.590 & 0.310 & 14.40M & 17.80\% \\ \hline \hline \end{tabular}
\end{table}
Table 4: Ablation studies of different numbers of residual blocks on Gen1 Dataset.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Model & \begin{tabular}{c} mAP \\ @0.5 \\ \end{tabular} & \begin{tabular}{c} mAP \\ @0.5:0.95 \\ \end{tabular} & Params & \begin{tabular}{c} Firing \\ Rate \\ \end{tabular} &
\begin{tabular}{c} Energy \\ Efficiency \\ \end{tabular} \\ \hline ANN-Res18 & 0.537 & 0.290 & 9.56M & / & 1\(\times\) \\ MS-Res18 & 0.560 & 0.285 & 9.49M & 17.08\% & 2.43\(\times\) \\ Sew-Res18 & 0.561 & 0.286 & 9.56M & 18.80\% & 2.00\(\times\)* \\ EMS-Res18 & **0.565** & 0.286 & **9.34M** & 20.09\% & **4.91\(\times\)** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Impact of different residual blocks on Gen1 Dataset.
*Non-spike convolution blocks are calculated as MAC operations.
Figure 4: **Object detection results on the COCO Dataset**. The first three columns compare the effect of time steps on performance for the same network structure. The third and fourth columns compare the effect of the depth of the network on performance.
\begin{table}
\begin{tabular}{c c c c c} \hline \hline T & 1 & 3 & 5 & 7 \\ \hline [email protected] & 0.328 & 0.362 & 0.367 & 0.383 \\ [email protected]:0.95 & 0.162 & 0.184 & 0.189 & 0.199 \\ \hline \hline \end{tabular}
\end{table}
Table 5: Impact of different size of time steps on COCO Dataset.
## 6 Conclusion
In this work, we are the first to use the deep directly trained SNN for the object detection task. Considering that object detection involves extracting multi-scale object features, we design a novel energy-efficient full-spike residual block, EMS-ResNet, that eliminates the redundant MAC operations generated by non-spike convolution on shortcut paths and residual connections. The full-spike EMS-ResNet makes it easier to deploy on neuromorphic chips. Moreover, our results show that our model (EMS-YOLO) can achieve comparable performance to that of a same-structure ANN in a very short time step and performs well on both static images and event data. We believe that our model will drive the exploration of SNN for various regression tasks while becoming possible in neuromorphic hardware deployment.
|
2308.01939 | Numerical Uncertainty of Convolutional Neural Networks Inference for
Structural Brain MRI Analysis | This paper investigates the numerical uncertainty of Convolutional Neural
Networks (CNNs) inference for structural brain MRI analysis. It applies Random
Rounding -- a stochastic arithmetic technique -- to CNN models employed in
non-linear registration (SynthMorph) and whole-brain segmentation (FastSurfer),
and compares the resulting numerical uncertainty to the one measured in a
reference image-processing pipeline (FreeSurfer recon-all). Results obtained on
32 representative subjects show that CNN predictions are substantially more
accurate numerically than traditional image-processing results (non-linear
registration: 19 vs 13 significant bits on average; whole-brain segmentation:
0.99 vs 0.92 S{\o}rensen-Dice score on average), which suggests a better
reproducibility of CNN results across execution environments. | Inés Gonzalez Pepe, Vinuyan Sivakolunthu, Hae Lang Park, Yohan Chatelain, Tristan Glatard | 2023-08-03T02:17:07Z | http://arxiv.org/abs/2308.01939v1 | # Numerical Uncertainty of Convolutional Neural Networks Inference for Structural Brain MRI Analysis
###### Abstract
This paper investigates the numerical uncertainty of Convolutional Neural Networks (CNNs) inference for structural brain MRI analysis. It applies Random Rounding--a stochastic arithmetic technique--to CNN models employed in non-linear registration (SynthMorph) and whole-brain segmentation (FastSurfer), and compares the resulting numerical uncertainty to the one measured in a reference image-processing pipeline (FreeSurfer recon-all). Results obtained on 32 representative subjects show that CNN predictions are substantially more accurate numerically than traditional image-processing results (non-linear registration: 19 vs 13 significant bits on average; whole-brain segmentation: 0.99 vs 0.92 Sorensen-Dice score on average), which suggests a better reproducibility of CNN results across execution environments.
Keywords:Numerical Stability Convolutional Neural Networks Nonlinear Registration Whole-Brain Segmentation
## 1 Introduction
A motivating factor to study numerical uncertainty in neuroimaging is to establish measures of reliability in the tools observed, particularly in light of the reproducibility crisis [1, 2, 3]. Numerical uncertainty is key to the robustness of neuroimaging analyses. Small computational perturbations introduced in execution environments-- including operating systems, hardware architecture, and parallelization--may amplify throughout analytical pipelines and result in substantial differences in the final outcome of analyses [4, 5]. Such instabilities have been observed across many different tools and imaging modalities [6, 7], and are likely to impact the reproducibility and robustness of analyses.
Convolutional Neural Networks (CNNs) are increasingly adopted for registration [8, 9, 10] and segmentation [11, 12, 13, 14] of structural MRIs. Once trained, CNNs are orders of magnitude faster than traditional image-processing methods, achieve comparable accuracy, and seem to exhibit better generalizability to image modalities and orientations. However, the numerical uncertainty associated with CNN predictions in neuroimaging remains largely unexplored. While previous
works suggested that CNNs might be subject to numerical instability [15, 16, 17], it is unclear how such instabilities manifest in specific CNN architectures used in structural brain MRI, and how the resulting numerical uncertainty compares to the one of traditional methods.
This paper measures the numerical uncertainty associated with CNN inference in neuroimaging, focusing specifically on non-linear registration and whole-brain segmentation of structural MRIs. To do so, it applies Random Rounding (RR) [18, 19]--a practical stochastic arithmetic technique to estimate numerical uncertainty--to state-of-the-art CNN models SynthMorph [8] and FastSurfer [12], and compare their numerical uncertainty to the one measured from the FreeSurfer [20] "recon-all" reference neuroimaging tool.
## 2 Materials & Methods
We measured the numerical uncertainty of CNN models SynthMorph (non-linear registration) and FastSurfer (whole-brain segmentation) using RR. We applied these models to 35 subjects randomly selected in the CoRR dataset, using the FreeSurfer recon-all pipeline as a baseline for numerical uncertainty comparison.
### Random Rounding
Random Rounding (RR) [18] is a form of Monte-Carlo Arithmetic (MCA) [21] that simulates rounding errors by applying the following perturbation to all floating-point (FP) operations of an application:
\[random\_rounding(x\circ y)=round(inexact(x\circ y))\]
where \(x\) and \(y\) are FP numbers, \(\circ\) is an arithmetic operation, and \(inexact\) is a random perturbation defined at a given virtual precision:
\[inexact(x)=x+2^{e_{x}-t}\xi\]
where \(e_{x}\) is the exponent in the FP representation of \(x\), \(t\) is the virtual precision, and \(\xi\) is a random uniform variable of \((-\frac{1}{2},\frac{1}{2})\). To measure numerical uncertainty, we applied a perturbation of 1 ulp (unit of least precision, a.k.a the spacing between two consecutive FP numbers), which corresponds to a virtual precision of \(t=24\) bits for single-precision and \(t=53\) bits for double-precision.
We applied RR to the CNN models using Verrou [19][22], a tool that implements MCA through dynamic binary instrumentation with Valgrind [23], without needing to modify or recompile the source code. We instrumented the entire executables with RR, additionally using Verrou's custom libmath implementation named Interlibmath to avoid incorrect random perturbations in mathematical functions. We applied RR to FreeSurfer using "fuzzy libmath" [6], a version of the GNU mathematical library instrumented with the Verificarlo [24] compiler following the same principle as Verrou's Interlibmath instrumentation.
### Numerical Uncertainty Metrics
We quantified numerical uncertainty by calculating the number of significant bits across multiple independent RR samples. The number of significant bits is informally defined as the number of bits in common between RR samples for a given FP value. We estimated the number of significant bits using the general non-parametric method described in [25] and implemented in the significant_digits package [26]. Given an RR sample \(X_{i}\) (\(i\leq n\)), this method computes the significance \(S_{i}^{k}\) of the \(k^{th}\) bit in the mantissa of \(X_{i}\) as:
\[S_{i}^{k}=\mathbb{1}_{|Z_{i}|<2^{-k}}\]
where \(Z_{i}=X_{i}-x_{\text{IEEE}}\) and \(x_{\text{IEEE}}\) is the unperturbed result computed with IEEE. The \(k^{th}\) bit in the mantissa is considered significant if the absolute value of \(Z_{i}\) is less than \(2^{-k}\). The number of significant bits across samples, \(\hat{s_{b}}\), is then obtained as the maximal bit index that is significant for all samples:
\[\hat{s_{b}}=\max\left\{k\in\llbracket 1,m\rrbracket\text{ such that }\forall i\in \llbracket 1,n\rrbracket,\ S_{i}^{k}=\mathbb{1}\right\}\]
where \(m\) is the size of the mantissa, i.e., 53 bits for double precision numbers and 24 bits for single precision numbers. A value of 0 significant bits means that \(X\) bears no information while a value of \(m\) means that it has maximal information given the FP format used. The difference between the maximal and achieved values quantifies the information loss resulting from numerical uncertainty.
The number of significant bits is a versatile metric that applies to any program that produces results encoded as FP values. This is, however, not the case of segmentation tools that generally produce categorical variables encoded as integers representing segmentation labels despite the use of intermediate FP operations. Therefore, in order to assess the impact of stochastic rounding in these intermediate FP operations we used the minimum Sorensen-Dice scores computed pairwise across RR samples as uncertainty metric for segmentations. In addition, to have a more local uncertainty metric for segmentation results, we defined an entropy metric at each voxel:
\[E=-\sum_{i=1}^{r}p_{i}\ln p_{i} \tag{1}\]
where \(r\) is the number of segmented regions, and \(p_{i}\) is the probability of region \(i\) at the voxel, computed across \(n\) Random Rounding samples. The entropy is 0 when the voxel is labeled with the same region across all RR samples, and it is maximal when the voxel is labeled differently for each RR sample.
### Non-Linear Registration
SynthMorph[8] is a 3D convolutional U-Net [27] that performs non-linear image registration robustly across MRI contrasts. The encoding section of the U-Net consists of 4 convolutional blocks, while the decoding section consists of 3 blocks
with a skip connection to its respective encoding block. SynthMorph was trained from synthetic label maps created from geometric shapes from which images were generated with various contrasts, deformations, and artifacts. A contrast-invariant loss that measures label overlap was used to optimize model performance. SynthMorph's registration accuracy was shown to outperform state-of-the-art registration methods both within and across contrasts. We applied the SynthMorph "sm-brains" pre-trained model available on GitHub [28] to the linearly registered image produced by FreeSurfer recon-all (output of recon-all's -canorm step), using the MNI305 atlas as reference image. The subject and atlas images were cropped through visual inspection to match the 160 x 192 x 224 dimension required by the model, and intensities were min-max scaled to [0-1]. We applied Verrou directly to the sm-brains model, by instrumenting the entirety of the model and using Verrou's Interlibmath implementation. SynthMorph takes a couple of minutes to run, but when instrumented with Verrou, the runtime increased to a span of 2-3 days.
FreeSurfer "recon-all" [20] is a widely-used neuroimaging pipeline that implements spatial normalization to a brain template, whole-brain segmentation, and cortical surface extraction. The non-linear registration algorithm (mri_ca_register tool) minimizes through gradient descent an error functional that includes an intensity term, a topology constraining one, a metric preservation term, a smoothness term, and a label term [29]. We first ran recon-all on all the subjects with steps --motioncor --talairach --nuitnensitycor --normalization --skullstrip --gcareg --canorm without RR, to obtain the linear registration used as input of SynthMorph. Then we ran the FreeSurfer recon-all step --careg that implements non-linear registration using our FreeSurfer version instrumented with fuzzy libmath. This command typically takes 3 hours to run, but when instrumented with fuzzy libmath, the runtime increased to a span of 6 hours.
### Whole-Brain Segmentation
FastSurfer [12] is a CNN model that performs whole-brain segmentation, cortical surface reconstruction, fast spherical mapping, and cortical thickness analysis. The FastSurfer CNN is inspired from the QuickNAT model [11], which is composed of three 2D fully convolutional neural networks--each associated with a different 2D slice orientation--that each have the same encoder/decoder U-net architecture with skip connections, unpooling layers and dense connections as QuickNAT. The FastSurfer segmentations were shown to surpass state-of-the-art methods, as well as being generalizable to unseen datasets and having better test-retest reliability. We used the pre-trained model from FastSurfer available on GitHub [30] and we applied Verrou directly to this model, in the same way it was applied to SynthMorph. FastSurfer typically takes 30 minutes to run, but when instrumented with Verrou, the runtime increased to a span of 16-17 days.
FreeSurfer recon-all also implements whole-brain segmentation [20], through a maximum a-posteriori estimation of the segmentation based on the non-linear
registration of the subject image to an atlas. Due to time constraints, only the subcortical structures and brain tissues were segmented by FreeSurfer whereas FastSurfer also segmented cortical structures, therefore a mask was applied to FastSurfer's cortical labels to identify them by the super classes "Left/Right Cerebral Cortex". Only regions common to both were further analysed (see list in Fig. 2a). Similar to FreeSurfer recon-all's non-linear registration, RR was applied to FreeSurfer recon-all's whole brain segmentation through Verificarlo's fuzzy libmath. The FreeSurfer recon-all commands --motioncor up to --calabel, the command that specifically performs subcortical segmentation were run. Typically, the segmentation takes around 4 hours to complete, but with FreeSurfer instrumented with Verificarlo, the runtime increased to 10-12 hours.
### Dataset and processing
We used the Consortium for Reliability and Reproducibility (CoRR) dataset [31], a multi-centric, open resource aimed to evaluate test-retest reliability and reproducibility. We randomly selected 35 T1-weighted MRIs from 35 different subjects, one from each CoRR acquisition site, and accessed them through Datalad [32][33]. The selected images included a range of image dimensions, voxel resolutions and data types (Appendix A). We excluded 2 subjects that failed linear registration with FreeSurfer recon-all and a third subject that failed segmentation with FastSurfer. Each pipeline or model was run in Singularity containers over 10 RR samples from which we measured numerical uncertainty. Due to long computing times induced by Verrou instrumentation (\(\approx 17\) days per subject) we were only able to get 4 RR samples for FastSurfer, which we complemented with an IEEE (non-RR) sample conceptually identical to an RR sample.
We processed the data with SynthMorph and FreeSurfer recon-all on the Narval cluster from Ecole de Technologie Superieure (ETS, Montreal), managed by Calcul Quebec and The Digital Alliance of Canada which include AMD Rome 7502, AMD Rome 7532, and AMD Milan 7413 CPUs with 48 to 64 physical cores, 249 GB to 4000 GB of RAM and Linux kernel 3.10. We executed FastSurfer on the slashbin cluster at Concordia University with 8 \(\times\) compute nodes each with an Intel Xeon Gold 6130 CPU, 250 GB of RAM, and Linux kernel 4.18.0-240.1.1.el8_Justre.x86_64.
We used FreeSurfer v7.3.1, SynthMorph v0.2, FastSurfer v2.1.1, Fuzzy v0.9.1, and Singularity/Apptainer v1.1. Verrou v3.21.0 was used for FastSurfer, while Verrou v3.20.0 with a special fix available on GitHub [34] was used for SynthMorph due to compatibility issues between the model and Verrou's Interlibmath. The scripts and Dockerfiles for this experiment can be found on GitHub [35].
## 3 Results
The numerical uncertainty measured for the SynthMorph CNN model was lower than for Freesurfer recon-all (Fig. 1a, as measured both in the resampled images (\(p<10^{-6}\), two-tailed paired t-test) and in the warp fields (\(p<10^{-5}\)) despite
only the libmath libraries in FreeSurfer being instrumented in contrast to the entirety of SynthMorph. The number of significant bits in warp fields was computed as the average number of significant bits across the x,y and z components. On average, out of 24 bits available, the SynthMorph resampled image had 19.56 significant bits while FreeSurfer recon-all's had only 13.43 significant bits; the SynthMorph warp field had 18.55 significant bits while FreeSurfer recon-all's had only 14.12 significant bits. These important differences show a clear superiority of the CNN model compared to FreeSurfer recon-all in terms of numerical uncertainty. Moreover, we also observed a larger variability of the numerical uncertainty across subjects in FreeSurfer recon-all compared to SynthMorph.
The differences in average numerical uncertainty observed between FreeSurfer and SynthMorph were confirmed by visual inspection of the non-linearly registered images and warp fields (Fig. 1b). The numerical uncertainty in registered images was structurally consistent, with higher uncertainty in the gray matter and at the border of the brain than in the white matter, both for SynthMorph and for FreeSurfer recon-all. The numerical uncertainty in warp fields exhibited interesting structural patterns that would benefit from further investigation.
The numerical uncertainty of FastSurfer segmentations was significantly lower than for FreeSurfer recon-all in 31 out of 35 brain regions (Fig. 2a, with very substantial differences in some regions. Here again, a larger variability was observed in FreeSurfer recon-all segmentations than in FastSurfer segmentations. Overall, FastSurfer averages a Sorensen-Dice score of 0.99 across all regions, while FreeSurfer is at 0.92. The differences in Sorensen-Dice scores observed between FreeSurfer recon-all and FastSurfer were confirmed in local entropy maps (Fig. 2b where we visually noted a substantial discrepancy between both methods. For FreeSurfer recon-all, clusters of non-zero entropy values were observed across the brain, whereas for FastSurfer non-zero entropy values were limited to scattered voxels. The entropy maps, in addition to visual inspection, confirm that, despite the relatively high average Sorensen-Dice scores, FreeSurfer recon-all exhibited variability identifying the edges of subcortical structures, while FastSurfer remained certain in its segmentations.
## 4 Conclusion
The numerical uncertainty measured in CNN models SynthMorph and FastSurfer was substantially lower than in FreeSurfer recon-all, amounting to differences in the order of 4 to 6 significant bits in non-linearly registered images, and of up to 0.4 Sorensen-Dice score values in segmentations. We believe that the high numerical uncertainty observed in FreeSurfer recon-all compared to CNN models results from the use of numerical optimization techniques in FreeSurfer recon-all while CNN models only involve low-dimensional convolutions, max-pooling operators, and simple activation functions. The low numerical uncertainty found in CNN models is consistent with previous observations in the very different task of protein function prediction [36]. The numerical uncertainty found in FreeSurfer
recon-all is also consistent with previous observations on FreeSurfer recon-all non-linear registration [6] and segmentation [37].
Our results suggest that neuroimaging CNN models are significantly more robust to small numerical perturbations than traditional image processing approaches. Therefore, we expect CNN results to be more reproducible across execution environments than traditional image processing approaches, implying better portability across software and hardware systems.
Our results report on the numerical uncertainty resulting from CNN _inference_, which is a relevant proxy for the uncertainty experienced by model end-users across different execution environments. However, the numerical uncertainty resulting from CNN _training_ was not measured in our experiments. We speculate that some of the numerical uncertainty observed in FreeSurfer recon-all results is intrinsic to the problems of subject-to-template non-linear registration and whole-brain segmentation, and should therefore manifest during CNN training. Mathematically, training CNN models involves numerical optimization in high-dimensional spaces, which we expect to be less numerically stable than CNN inference, and comparably stable to FreeSurfer recon-all. Should this assumption be accurate, the numerical uncertainty of predictions made by a sample of CNN models trained with Random Rounding should be substantial,
Figure 1: Numerical uncertainty measured in the non-linearly registered images and warp fields produced by FreeSurfer recon-all and the SynthMorph CNN model.
Figure 2: Numerical uncertainty measured in the segmentations produced by FreeSurfer recon-all and the FastSurfer CNN model.
which we plan to leverage in our future work by building efficient ensemble models capturing the numerical variability associated with non-linear registration or segmentation, possibly resulting in improved predictions.
## 5 Acknowledgements
Computations were made on the Narval and Beluga supercomputers from Ecole de Technologie Superieure (ETS, Montreal), managed by Calcul Quebec and The Digital Alliance of Canada. The operation of these supercomputers are funded by the Canada Foundation for Innovation (CFI), le Ministere de l'Economie, des Sciences et de l'Innovation du Quebec (MESI) and le Fonds de recherche du Quebec - Nature et technologies (FRQ-NT).
|
2305.04665 | Riesz networks: scale invariant neural networks in a single forward pass | Scale invariance of an algorithm refers to its ability to treat objects
equally independently of their size. For neural networks, scale invariance is
typically achieved by data augmentation. However, when presented with a scale
far outside the range covered by the training set, neural networks may fail to
generalize.
Here, we introduce the Riesz network, a novel scale invariant neural network.
Instead of standard 2d or 3d convolutions for combining spatial information,
the Riesz network is based on the Riesz transform which is a scale equivariant
operation. As a consequence, this network naturally generalizes to unseen or
even arbitrary scales in a single forward pass. As an application example, we
consider detecting and segmenting cracks in tomographic images of concrete. In
this context, 'scale' refers to the crack thickness which may vary strongly
even within the same sample. To prove its scale invariance, the Riesz network
is trained on one fixed crack width. We then validate its performance in
segmenting simulated and real tomographic images featuring a wide range of
crack widths. An additional experiment is carried out on the MNIST Large Scale
data set. | Tin Barisin, Katja Schladitz, Claudia Redenbach | 2023-05-08T12:39:49Z | http://arxiv.org/abs/2305.04665v2 | # Riesz networks: scale invariant neural networks
###### Abstract
Scale invariance of an algorithm refers to its ability to treat objects equally independently of their size. For neural networks, scale invariance is typically achieved by data augmentation. However, when presented with a scale far outside the range covered by the training set, neural networks may fail to generalize.
Here, we introduce the Riesz network, a novel scale invariant neural network. Instead of standard 2d or 3d convolutions for combining spatial information, the Riesz network is based on the Riesz transform which is a scale equivariant operation. As a consequence, this network naturally generalizes to unseen or even arbitrary scales in a single forward pass.
As an application example, we consider detecting and segmenting cracks in tomographic images of concrete. In this context,'scale' refers to the crack thickness which may vary strongly even within the same sample. To prove its scale invariance, the Riesz network is trained on one fixed crack width. We then validate its performance in segmenting simulated and real tomographic images featuring a wide range of crack widths. An additional experiment is carried out on the MNIST Large Scale data set.
**Keywords:** scale invariance, Riesz transform, neural networks, crack segmentation, generalization to unseen scales, computed tomography, concrete
## 1 Introduction
In image data, similar objects may occur at highly varying scales. Examples are cars or pedestrians at different distances from the camera, cracks in concrete of varying thickness or imaged at different resolution, or blood vessels in biomedical applications (see Fig. 1). It is natural to assume that the same object or structure at different scales should be treated equally i.e. should have equal or at least similar features. This property is called scale or dilation invariance and has been investigated in detail in classical image processing [1, 2, 3].
Neural networks have proven to segment and classify robustly and well in many computer vision tasks. Nowadays, the most popular and successful neural networks are Convolutional Neural Networks (CNNs). It would be desirable that neural networks share typical properties of human vision such as translation, rotation, or scale invariance. While this is true for translation invariance, CNNs are not scale or rotation invariant by default. This is due to the excessive use of convolutions which are local operators. Moreover, training sets often contain a very limited number of scales. To overcome this problem, CNNs are often trained with rescaled images through data augmentation. However, when a CNN is given input whose scale is outside the range covered by the training set, it will not be able to generalize [4, 5]. To overcome this problem, a CNN trained at a fixed scale can be applied to several rescaled versions of the input image and the results can be combined. This, however, requires multiple runs of the network.
One application example, where the just described challenges naturally occur is the task of segmenting cracks in 2d or 3d gray scale images of concrete. Crack segmentation in 2d has been a vividly researched topic in civil engineering, see [6] for an overview. Cracks are naturally multiscale structures (Fig. 1, left) and hence require multiscale treatment. Nevertheless, adaption to scale (crack thickness1) has not been treated explicitly so far.
Footnote 1: Crack scale, thickness, and width refer to the same characteristic and will be interchangeably used throughout the paper.
Recently, crack segmentation in 3d images obtained by computed tomography (CT) has become a subject of interest [6, 7]. Here, the effect of varying scales is even more pronounced [8]: crack thicknesses can vary from a single pixel to more than 100 pixels. Hence, the aim is to design and evaluate crack segmentation methods that work equally well on all possible crack widths without complicated adjustment by the user.
In this work, we focus on 2d multiscale crack segmentation in images of concrete samples. We design the Riesz network which replaces the popular 2d convolutions by first and second order Riesz transforms to allow for a scale invariant spatial operation. The resulting neural network is provably scale invariant in only one forward pass. It is sufficient to train the Riesz network on one scale or crack thickness, only. The network then generalizes automatically without any adjustments or rescaling to completely unseen scales. We validate the network performance using images with simulated cracks of constant and varying widths generated as described in [6, 10]. Our network is compared with competing methods for multiscale segmentation and finally applied to real multiscale cracks observed in 2d slices of tomographic images.
There is just one publicly available dataset which allows for testing scale equivariance - MNIST Large Scale [5]. Additional experiments with the Riesz network on this dataset are reported in Appendix A.
### Related work
#### The Riesz transform
The Riesz transform is a generalization of the Hilbert transform to higher dimensional spaces, see e.g. [11]. First practical applications of the Riesz transform arise in signal processing through the definition of the monogenic signal [12] which enables a decomposition of higher dimensional signals into local phase and local amplitude. First, a bandpass filter is applied to the signal to separate the band of frequencies. Using the Riesz transform, the local phase and amplitude can be calculated for a selected range of frequencies. For more details we refer to [12, 13].
As images are 2d or 3d signals, applications of the Riesz transform naturally extend to the fields of image processing and computer vision through the Poisson scale space [14, 15] which is an alternative to the well-known Gaussian scale space. Kothe [16] compared the Riesz transform with the structure tensor from a signal processing perspective. Unser and van de Ville [17] related higher order Riesz transforms and derivatives.
Figure 1: Examples of similar objects appearing on different scales: section of a CT image of concrete showing a crack of locally varying thickness (left) and pedestrians at difference distances from the camera (right, taken from [9]).
Furthermore, they give a reason for preferring the Riesz transform over the standard derivative operator: The Riesz transform does not amplify high frequencies.
Higher order Riesz transforms were also used for analysis of local image structures using ideas from differential geometry [18, 19]. Benefits of using the first and second order Riesz transforms as low level features have also been shown in measuring similarity [20], analyzing and classification of textures [11, 21], and orientation estimation [22, 23]. The Riesz transform can be used to create steerable wavelet frames, so-called _Riesz-Laplace wavelets_[17, 24], which are the first ones utilizing the scale equivariance property of the Riesz transform and have inspired the design of _quasi monogenic shearlets_[25].
Interestingly, in early works on the Riesz transform in signal processing or image processing [12, 13, 15], scale equivariance has not been noticed as a feature of the Riesz transform and hence remained sidelined. Benefits of the scale equivariance have been shown later in [17, 19].
Recently, the Riesz transform found its way into the field of deep learning: Riesz transform features are used as supplementary features in classical CNNs to improve robustness [26]. In our work, we will use the Riesz transforms for extracting low-level features from images and use them as basis functions which replace trainable convolutional filters in CNNs or Gaussian derivatives in [27].
#### Scale invariant deep learning methods
Deep learning methods which have mechanisms to handle variations in scale effectively can be split in two groups based on their scale generalization ability.
_Scale invariant deep learning methods for a limited range of scales_
The first group can handle multiscale data but is limited to the scales represented either by the training set or by the neural network architecture. The simplest approach to learn multiscale features is to apply the convolutions to several rescaled versions of the images or feature maps in every layer and to combine the results by maximum pooling [4] or by keeping the scale with maximal activation [28] before passing it to the next layer. In [29, 30], several approaches based on downscaling images or feature maps with the goal of designing robust multiscale object detectors are summarized. However, scaling is included in the network architecture such that scales have to be selected a priori. Therefore, this approach only yields local scale invariance, i.e. an adaption to the scale observed in a given input image is not possible after training.
Another intuitive approach is to rescale trainable filters, i.e. convolutions, by interpolation [31]. In [29], a new multiscale strategy was derived which uses convolution blocks of varying sizes sequenced in several downscaling layers creating a pyramidal shape. The pyramidal structure is utilized for learning scale dependent features and making predictions in every downsampling layer. Layers can be trained according to object size. That is, only the part of the network relevant for the object size is optimized. This guarantees robustness to a large range of object scales. Similarly, in [30], a network consisting of a downsampling pyramid followed by an upsampling pyramid is proposed. Here, connections between pyramid levels are devised for combining low and high resolution features and predictions are also made independently on every pyramid level. However, in both cases, scale generalization properties of the networks are restricted by their architecture, i.e. by the depth of the network (number of levels in the image pyramid), the size of convolutions as spatial operators as well as the size of the input image.
Spatial transformer networks [32] focus on invariance to affine transformations including scale. This is achieved by using a so-called _localisation network_ which learns transformation parameters. Finally, using these transformation parameters, a new sampling grid can be created and feature maps are resampled to it. These parts form a trainable module which is able to handle and correct the effect of the affine transformations. However, spatial transformer networks do not necessarily achieve invariant recognition [33]. Also, it is not clear how this type of network would generalize to scales not represented in the training set.
In [34], so-called _structured receptive fields_ are introduced. Linear combinations (\(1\times 1\) convolutions) of basis functions (in this case Gaussian derivatives up to 4th order) are used to learn complex features and to replace convolutions (e.g. of size \(3\times 3\) or \(5\times 5\)). As a consequence, the number of parameters is reduced, while the expressiveness of the neural network is preserved. This type of network works better than classical CNNs in the case where little training data is available. However, the standard deviation parameters of the Gaussian kernels are manually selected and kept fixed. Hence, the scale generalization ability remains limited.
Making use of the semi-group property of scale spaces, _scale equivariant neural networks_ motivate the use of _dilated convolutions_[35] to define scale equivariant convolutions on the Gaussian scale space [36] or morphological scale spaces [37]. Unfortunately, these neural networks are unable to generalize to scales outside those determined by their architecture and are only suitable for downscale factors which are powers of 2,
i.e. \(\{2,4,8,16,\cdots\}\). Furthermore, scale equivariant steerable networks [38] show how to design scale invariant networks on the scale-translation group without using standard or dilated convolutions. Following an idea from [34], convolutions are replaced by linear combinations of basis filters (Hermite polynomials with Gaussian envelope). While this allows for non-integer scales, scales are still limited to powers of a positive scaling factor \(a\). Scale space is again discretized and sampled. Hence, a generalization to arbitrary scales is not guaranteed.
#### Scale invariant deep learning methods for arbitrary scales
The second group of methods can generalize to arbitrary scales, i.e. any scales that are in range bounded from below by image resolution and from above by image size, but not necessarily contained in the training set. Our Riesz network also belongs to this second group of methods.
An intuitive approach is to train standard CNNs on a fixed range of scales and enhance their scale generalization ability by the following three step procedure based on image pyramids: downsample by a factor \(a>1\), forward pass of the CNN, upsample the result by \(\frac{1}{a}\) to the original image size [5, 8]. Finally, forward passes of the CNN from several downsampling factors \(\{a_{1},\ \cdots\,a_{n}\ >\ 0\quad|\quad n\in\mathbb{N}\}\) are aggregated by using the maximum or average operator across the scale dimension. This approach indeed guarantees generalization to unseen scales as scales can be adapted to the input image and share the weights of the network [5]. However, it requires multiple forward passes of the CNN and the downsampling factors have to be selected by the user.
Inspired by Scattering Networks [39, 40], normalized differential operators based on first and second order Gaussian derivatives stacked in layers or a cascade of a network can be used to extract more complex features [41]. Subsequently, these features serve as an input for a classifier such as a support vector machine. Varying the standard deviation parameter \(\sigma\) of the Gaussian kernel, generalization to new scales can be achieved. However, this type of network is useful for creating _handcrafted_ complex scale invariant features, only, and hence is not trainable.
Its expansion to trainable networks by creating so-called Gaussian derivative networks [27] is one of the main inspirations for our work. For combining spatial information, \(\gamma\)-normalized Gaussian derivatives are used as scale equivariant operators (\(\gamma=1\)). Similarly as in [34], linear combinations of normalized derivatives are used to learn more complex features in the spirit of deep learning. During the training step, prior knowledge of the scale for every instance in the training set is required, i.e. the standard deviation parameter \(\sigma\) of the Gaussian kernel is set to reflect the scale of every instance, while the trainable weights are shared.
In the inference step, the scale dimension needs to be discretized, sampled, and for each scale \(\sigma\), the forward pass of the network has to be executed.
## 2 The Riesz transform
Let \(L_{2}(\mathbb{R}^{d})=\{f:\mathbb{R}^{d}\rightarrow\mathbb{R}\ |\ \int_{ \mathbb{R}^{d}}|f(x)|^{2}dx<\infty\}\) be the set of square integrable functions.
Formally, for a \(d\)-dimensional signal \(f\in L_{2}(\mathbb{R}^{d})\) (i.e. an image or a feature map), the Riesz transform of first order \(\mathcal{R}=(\mathcal{R}_{1},\cdots,\mathcal{R}_{d})\) is defined in the spatial domain as \(\mathcal{R}_{j}:L_{2}(\mathbb{R}^{d})\to L_{2}(\mathbb{R}^{d})\)
\[\mathcal{R}_{j}(f)(x)=C_{d}\lim_{\epsilon\to 0}\int_{\mathbb{R}^{d} \setminus B_{\epsilon}}\frac{y_{j}f(x-y)}{|y|^{d+1}}dy,\]
where \(C_{d}=\Gamma((d+1)/2)/\pi^{(d+1)/2}\) is a normalizing constant and \(B_{\varepsilon}\) is ball of radius \(\varepsilon\) centered at the origin. Alternatively, the Riesz transform can be defined in the frequency domain via the Fourier transform \(\mathcal{F}\)
\[\mathcal{F}(\mathcal{R}_{j}(f))(u)=-i\frac{u_{j}}{|u|}\mathcal{F}(f)(u)=\frac{ 1}{|u|}\mathcal{F}(\partial_{j}f)(u),\]
for \(j\in\{1,\cdots,d\}\). Higher order Riesz transforms are defined by applying a sequence of first order Riesz transforms. That is, for \(k_{1},k_{2},...,k_{d}\in\mathbb{N}\cup\{0\}\) we set
\[\mathcal{R}^{(k_{1},k_{2},...,k_{d})}(f)(x):=\mathcal{R}_{1}^{k_{1}}( \mathcal{R}_{2}^{k_{2}}(\cdots(\mathcal{R}_{d}^{k_{d}}(f(x)))),\]
where \(\mathcal{R}_{j}^{k_{j}}\) refers to applying the Riesz transform \(\mathcal{R}_{j}\)\(k_{j}\) times in a sequence.
The Riesz transform kernels of first and second order resemble those of the corresponding derivatives of smoothing filters such as Gaussian or Poisson filters (Fig. 2). This can be explained by the following relations
\[\mathcal{R}(f)=(-1)(-\triangle)^{-1/2}\nabla f\] \[\mathcal{R}^{(k_{1},k_{2},...,k_{d})}(f)(x)=(-1)^{N}(-\triangle)^ {-N/2}\frac{\partial^{N}f(x)}{\partial^{k_{1}}x_{1}\cdots\partial^{k_{d}}x_{ d}},\]
for \(k_{1}+...+k_{d}=N\) and \(N\in\mathbb{N}\). The fractional Laplace operator \(\triangle^{N/2}\) acts as an isotropic low-pass filter. The main properties of the Riesz transform can be summarized in the following way [17]:
* **translation equivariance:** For \(x_{0}\in\mathbb{R}^{d}\) define a translation operator \(\mathcal{T}_{x_{0}}(f)(x):L_{2}(\mathbb{R}^{d})\to L_{2}(\mathbb{R}^{d})\) as \(\mathcal{T}_{x_{0}}(f)(x)=f(x-x_{0})\). It holds that \[\mathcal{R}_{j}(\mathcal{T}_{x_{0}}(f))(x)=\mathcal{T}_{x_{0}}(\mathcal{R}_{j }(f))(x),\] where \(j\in\{1,\cdots,d\}\). This property reflects the fact that the Riesz transform commutes with the translation operator.
* **steerability:** The directional Hilbert transform \(\mathcal{H}_{v}:L_{2}(\mathbb{R}^{d})\to L_{2}(\mathbb{R}^{d})\) in direction \(v\in\mathbb{R}^{d}\), \(||v||=1\), is defined as \(\mathcal{F}(\mathcal{H}_{v}(f))(u)=i\ \text{sign}(\langle u,v\rangle)\). \(\mathcal{H}_{v}\) is steerable in terms of the Riesz transform, that is it can be written as a
linear combination of the Riesz transforms
\[\mathcal{H}_{v}(f)(x)=\sum_{j=1}^{d}v_{j}\mathcal{R}_{j}(f)(x)=\langle\mathcal{R} (f)(x),v\rangle.\]
Note that in 2d, for a unit vector \(v=(\cos\theta,\sin\theta)\), \(\theta\in[0,2\pi]\), the directional Hilbert transform becomes \(\mathcal{H}_{v}(f)(x)=\cos(\theta)\mathcal{R}_{1}(f)(x)+\sin(\theta)\mathcal{ R}_{2}(f)(x)\). This is equivalent to the link between gradient and directional derivatives [17] and a very useful property for learning oriented features.
* **all-pass filter [12]:** Let \(H=(H_{1},\cdots,H_{d})\) be the Fourier transform of the Riesz kernel, i.e. \(\mathcal{F}(\mathcal{R}_{j}(f))(u)=i\frac{u_{j}}{|u|}\mathcal{F}(f)(u)=H_{j}(u )\mathcal{F}(f)(u)\). The energy of the Riesz transform for frequency \(u\in\mathbb{R}^{d}\) is defined as the norm of the \(d\)-dimensional vector \(H(u)\) and has value \(1\) for all non-zero frequencies \(u\neq 0\), i.e. \[||H(u)||=1,\quad u\neq 0.\] The all-pass filter property reflects the fact that the Riesz transform is a non-local operator and that every frequency is treated fairly and equally. Combined with scale equivariance, this eliminates the need for multiscale analysis or multiscale feature extraction.
* **scale (dilation) equivariance:** For \(a>0\) define a dilation or rescaling operator \(L_{a}:L_{2}(\mathbb{R}^{d})\to L_{2}(\mathbb{R}^{d})\) as \(L_{a}(f)(x)=f(\frac{x}{a})\). Then \[\mathcal{R}_{j}(L_{a}(f))(x)=L_{a}(\mathcal{R}_{j}(f))(x),\]
Figure 2: Visualizations of Riesz transform kernels of first and second order. First row (from left to right): \(\mathcal{R}_{1}\) and \(\mathcal{R}_{2}\). Second row (from left to right): \(\mathcal{R}^{(2,0)}\), \(\mathcal{R}^{(1,1)}\), and \(\mathcal{R}^{(0,2)}\).
for \(j\in\{1,\cdots,d\}\). That is, the Riesz transform does not only commute with translations but also with scaling.
Scale equivariance enables an equal treatment of the same objects at different scales. As this is the key property of the Riesz transform for our application, we will briefly present a proof. We restrict to the first order in the Fourier domain. The proof for higher orders follows directly from the one for the first order.
**Lemma 1**.: _The Riesz transform is scale equivariant, i.e._
\[[\mathcal{R}_{i}f\Big{(}\frac{\cdot}{a}\Big{)}](x)=[\mathcal{R}_{i}f]\Big{(} \frac{x}{a}\Big{)}. \tag{1}\]
_for \(f\in L_{2}(\mathbb{R}^{d})\) and every \(x\in\mathbb{R}^{d}\)._
Proof.: Remember that the Fourier transform of a dilated function is given by \(\mathcal{F}(f(\alpha\cdot))(u)=\frac{1}{\alpha^{2}}\mathcal{F}(f)(\frac{u}{ \alpha})\). Setting \(g(x)=f(\frac{x}{a})\), we have \(\mathcal{F}(g)(u)=a^{d}\mathcal{F}(f)(au)\). This yields
\[\mathcal{F}\Bigg{(}\mathcal{R}_{j}\Big{(}f\big{(}\frac{\cdot}{a} \big{)}\Big{)}\Bigg{)}(u)=\mathcal{F}\Big{(}\mathcal{R}_{j}(g)\Big{)}(u)=\] \[=i\frac{u_{j}}{|u|}\mathcal{F}(g)(u)=i\frac{u_{j}}{|u|}a^{d} \mathcal{F}(f)(au)=\] \[=a^{d}\Big{(}i\frac{au_{j}}{a|u|}\Big{)}\mathcal{F}(f)(au)=a^{d} \mathcal{F}\Big{(}\mathcal{R}_{j}(f)\Big{)}(au)=\] \[=\mathcal{F}\Bigg{(}\mathcal{R}_{j}(f)\Big{(}\frac{\cdot}{a} \Big{)}\Bigg{)}(u).\]
Fig. 3 provides an illustration of the scale equivariance. It shows four rectangles with length-to-width ratio 20 and varying width (3, 5, 7, and 11 pixels) together with the gray value profile of the second order Riesz transform \(R^{(2,0)}\) along a linear section through the centers of the rectangles. In spite of the different widths, the Riesz transform yields equal filter responses for each rectangle (up to rescaling). In contrast, to achieve the same behaviour in Gaussian scale space, the scale space has to be sampled (i.e. a subset of scales has to be selected), the \(\gamma\)-normalized derivative [1] has to be calculated for every scale, and finally the scale yielding the maximal absolute value has to be selected. In comparison, the simplicity of the Riesz transform achieving the same in just one transform without sampling scale space and without the need for a scale parameter is striking.
## 3 Riesz transform neural networks
In the spirit of structured receptive fields [34] and Gaussian derivative networks [27], we use the Riesz transforms of first and second order instead of standard convolutions to define Riesz layers. As a result, Riesz layers are scale equivariant in a single forward pass. Replacing standard derivatives with the Riesz transform has been motivated
by [16], while using a linear combination of Riesz transforms of several order follows [21].
### Riesz layers
The base layer of the Riesz networks is defined as a linear combination of Riesz transforms of several orders implemented as 1d convolution across feature channels (Fig. 4). Here, we limit ourselves to first and second order Riesz transforms. Thus, the linear combination reads as
\[J_{\mathcal{R}}(f) =C_{0}+\sum_{k=1}^{d}C_{k}\cdot\mathcal{R}_{k}(f)+\] \[+ \sum_{k,l\in\mathbb{N}_{0},k+l=2}C_{k,l}\cdot\mathcal{R}^{(k,l)} (f), \tag{2}\]
where \(\{C_{0},C_{k}|k\in\{1,\cdots,d\}\}\cup\{C_{k,l}|l,k\in\mathbb{N}_{0},l+k=2\}\) are parameters that are learned during training.
Now we can define the general layer of the network (Fig. 4). Let us assume that the \(K\)th network layer takes input \(F^{(K)}=(F^{(K)}_{1},\cdots,F^{(K)}_{c^{(K)}})\in\mathbb{R}^{H\times W\times c ^{(K)}}\) with \(c^{(K)}\) feature channels and has output \(F^{(K+1)}=(F^{(K+1)}_{1},\cdots,F^{(K+1)}_{c^{(K+1)}})\in\mathbb{R}^{H\times W \times c^{(K+1)}}\) with \(c^{(K+1)}\) channels. Then the output in channel \(j\in\{1,\cdots,c^{(K+1)}\}\) is given by
\[F^{(K+1)}_{j}=\sum_{i=1}^{c^{(K)}}J^{(j,i)}_{K}(F^{(K)}_{i}). \tag{3}\]
Here, \(J^{(j,i)}_{K}\) is defined in the same way as \(J_{\mathcal{R}}(f)\) from Eq. (2), but trainable parameters may vary for different input channels \(i\) and output channels
Figure 3: Illustration of the Riesz transform on a mock example of \(550\times 550\) pixels: aligned rectangles with equal aspect ratio and constant gray value \(255\) (left) and response of the second order Riesz transform \(\mathcal{R}^{(2,0)}\) of the left image sampled horizontally through the centers of the rectangles (right).
\(j\), i.e.
\[J_{K}^{(j,i)}(f) =C_{0}^{(j,i,K)}+\sum_{k=1}^{d}C_{k}^{(j,i,K)}\cdot\mathcal{R}_{k}( f)+\] \[+\sum_{k,l\in\mathbb{N}_{0},k+l=2}C_{k,l}^{(j,i,K)}\cdot\mathcal{R }^{(k,l)}(f). \tag{4}\]
In practice, the offset parameters \(C_{0}^{(i,j,K)}\), \(i=1,\cdots,c^{(K)}\) are replaced with a single parameter defined as \(C_{0}^{(j,K)}:=\sum_{i=1}^{c^{(K)}}C_{0}^{(j,i,K)}\).
### Proof of scale equivariance
We prove the scale equivariance for \(J_{\mathcal{R}}(f)\). That implies scale equivariance for \(J_{K}^{(j,i)}(f)\) and consequently for \(F_{j}^{(K+1)}\) for arbitrary layers of the network. By construction (see Section 3.3), this will result in provable scale invariance for the whole network. Formally, we show that \(J_{\mathcal{R}}(f)\) from equation (2) is scale equivariant, i.e.
\[J_{\mathcal{R}}\Bigg{(}f(\frac{\cdot}{a})\Bigg{)}(x)=J_{\mathcal{R}}(f)(\frac {x}{a}),\]
for \(f\in L_{2}(\mathbb{R}^{d})\) and every \(x\in\mathbb{R}^{d}\).
Proof.: For any scaling parameter \(a>0\) and \(x\in\mathbb{R}^{d}\), we have
\[J_{\mathcal{R}}\Bigg{(}f(\frac{\cdot}{a})\ \Bigg{)}\ \ (x)=C_{0}+\sum_{k=1}^{d}C_{k}\cdot \mathcal{R}_{k}\Bigg{(}f(\frac{\cdot}{a})\Bigg{)}(x)+\] \[\ \
Generally, a layer consists of the following sequence of transformations: batch normalization, Riesz layer, and ReLU. Batch normalization improves the training capabilites and avoids overfitting, ReLUs introduce non-linearity, and the Riesz layers extract scale equivariant spatial features. For every layer, the number of feature channels has to be selected. Hence, our network with \(K\in\mathbb{N}\) layers can be simply defined by a \(K\)-tuple specifying the channel sizes e.g. \((c^{(0)},c^{(1)},\cdots c^{(K)})\). The final layer is defined as a linear combination of the features from the previous layer followed by a sigmoid function yielding the desired probability map as output.
The four layer Riesz network we apply here can be schematically written as \(1\to 16\to 32\to 40\to 48\to 1\) and has \((1\cdot 5\cdot 16+16)+(16\cdot 5\cdot 32+32)+(32\cdot 5\cdot 40+40)+(40\cdot 5 \cdot 48+48)+(48\cdot 1+1)=18\,825\) trainable parameters.
## 4 Experiments and
applications
In this section we evaluate the four layer Riesz network defined above on the task of segmenting cracks in 2d slices from CT images of concrete. Particular emphasis is put on the network's ability to segment multiscale cracks and to generalize to crack scales unseen during training. To quantify these properties, we use images with simulated cracks. Being accompanied by an unambiguous ground truth, they allow for an objective evaluation of the segmentation results.
Figure 4: Building blocks of Riesz networks: the base Riesz layer from equation (2) (left) and the full Riesz layer from equation (3) (right).
Additionally, in Appendix A scale equivariance of the Riesz network is experimentally validated on the MNIST Large Scale data set [5].
_Data generation:_
Cracks are generated by the fractional Brownian motion (Experiment 1) or minimal surfaces induced by the facet system of a Voronoi tessellation (Experiment 2). Dilated cracks are then integrated into CT images of concrete without cracks. As pores and cracks are both air-filled, their gray value distribution should be similar. Hence, the gray value distribution of crack pixels is estimated from the gray value distribution observed in air pores. The crack thickness is kept fixed (Experiment 1) or varies (Experiment 2) depending on the objective of the experiment. As a result, realistic semi-synthetic images can be generated (see Fig. 5). For more details on the simulation procedure, we refer to [6, 10]. Details on number and size of the images can be found below. Finally, we show applicability of the Riesz network for real data containing cracks generated by tensile and pull-out tests.
_Quality metrics:_
As metrics for evaluation of the segmentation results we use precision (P), recall (R), F1-score (or dice coefficient, Dice), and Intersection over Union (IoU). The first three quality metrics are based on true positives _tp_ - the number of pixels correctly predicted as crack, true negatives _tn_ - the number of pixels correctly predicted as background, false positives _fp_ - the number of pixels wrongly predicted as crack, and false negatives _fn_ - the number of pixels falsely predicted as background. Precision, recall, and dice coefficient are then defined via
\[P=tp/(tp+fp),\quad R=tp/(tp+fn),\]
\[\text{Dice}=2PR/(P+R).\]
IoU compares union and intersection of the foregrounds \(X\) and \(Y\) in the segmented image and the corresponding ground truth, respectively. That is
\[IoU(X,Y)=\frac{|X\cap Y|}{|X\cup Y|}.\]
All these metrics have values in the range \([0,1]\) with values closer to 1 indicating a better performance.
_Training parameters:_
If not specified otherwise, all models are trained on cracks of fixed width of 3 pixels. Cracks for the training are generated in the same way as for Experiment 1 on \(256\times 256\) sections of CT images of concrete. Then, 16 images of size \(64\times 64\) are cropped without overlap from each of the generated images. In this way, images without cracks are present in the training set. After data augmentation by flipping and rotation, the training set
consists of \(1\,947\) images of cracks. Some examples are shown in Fig. 5. For validation, another set of images with cracks of width \(3\) is used. The validation data set's size is a third of the size of the training set.
All models are trained for \(50\) epochs with initial learning rate \(0.001\) which is halved every \(20\) epochs. ADAM optimization [43] is used, while the cost function is set to binary cross entropy loss.
Crack pixels are labelled with \(1\), while background is labelled with \(0\). As there are far more background than crack pixels, we deal with a highly imbalanced data set. Therefore, crack and pore pixels are given a weight of \(40\) to compensate for class imbalance and to help distinguishing between these two types of structures which hardly differ in their gray values.
### Measuring scale equivariance
Measures for assessing scale equivariance have been introduced in [36, 38]. For an image or feature map \(f\), a mapping function \(\Phi\) (e.g. a neural network or a subpart of a network), and a scaling function \(L_{a}\) we define
\[\Delta_{a}(\Phi):=\frac{||L_{a}(\Phi(f))-\Phi(L_{a}(f))||_{2}}{||L_{a}(\Phi(f) )||_{2}}.\]
Ideally, this measure should be \(0\) for perfect scale equivariance. In practice, due to scaling and discretization errors we expect it to be positive yet very small.
To measure scale equivariance of the full Riesz network with randomly initialized weights, we use a data set consisting of \(85\) images of size \(512\times 512\) pixels with crack width \(11\) and use downscaling factors \(a\in\{2,4,8,16,32,64\}\). The evaluation was
Figure 5: Cracks of width \(3\) used for training: before (first row) and after cropping (second row). Image sizes are \(256\times 256\) (first row) and \(64\times 64\) (second row).
repeated for 20 randomly initialized Riesz networks. The resulting values of \(\Delta_{a}\) are given in Fig. 6.
The measure \(\Delta_{a}\) was used to validate the scale equivariance of Deep Scale-spaces (DSS) in [36] and scale steerable equivariant networks in [38]. In both works, a steep increase in \(\Delta_{a}\) is observed for downscaling factors larger than 16, while for very small downscaling factors, \(\Delta_{a}\) is reported to be below 0.01. In [38], \(\Delta_{a}\) reaches 1 for downscaling factor 45. The application scenario studied here differs from those of [36, 38]. Results are thus not directly comparable but can be considered only as an approximate baseline. For small downscaling factors, we find \(\Delta_{a}\) to be higher than in [38] (up to 0.075). However, for larger downscaling factors (\(a>32\)), \(\Delta_{a}\) increases more slowly e.g. \(\Delta_{64}=0.169\). This proves the resilience of Riesz networks to very high downscaling factors, i.e. large changes in scale.
### Experiment 1: Generalization to unseen scales
Our models are trained on images of fixed crack width 3. To investigate their behaviour on crack widths outside of the training set, we generate cracks of widths \(\{1,3,5,7,9,11\}\) pixels in images of size \(512\times 512\), see Fig. 9. Each class contains 85 images. Besides scale generalization properties of the Riesz network, we check how well it generalizes to random variations in crack topology or shapes, too.
#### 4.2.1 Ablation study on the Riesz network
We investigate how network parameters and composition of the training set affect the quality of the results, in order to learn how to design this type of neural networks efficiently.
#### Size of training set:
First, we investigate robustness of the Riesz network to the size of the training set. Literature [34] suggests that neural networks based on _structure receptive fields_ are less data hungry, i.e. their performance with respect to the size of the training set is more stable than that of conventional CNNs. Since the Riesz network uses the Riesz transform instead of a Gaussian derivative as in [34], it is expected that the same would hold here, too.
Figure 6: Measure of scale equivariance \(\Delta_{a}\) for the four layer Riesz network with randomly initialized parameters w.r.t. the downscaling factor a. Mean (black), minimum, and maximum (gray) of 20 repetitions. Points on the line correspond to \(a\in\{1,2,4,8,16,32,64\}\).
The use of smaller training sets has two main benefits. First, obviously, smaller data sets reduce the effort for data collection, i.e. annotation or simulation. Second, smaller data sets reduce the training time for the network if we do not increase the number of epochs during training.
We constrain ourselves to three sizes of training sets: 1 947, 975, and 489. These numbers refer to the sets after data augmentation by flipping and rotation. Hence, the number of original images is three times smaller. In all three cases we train the Riesz network for 50 epochs and with similar batch sizes (\(11,13\), and \(11\), respectively). Results on unseen scales with respect to data set size are shown in Table 1 and Fig. 7 (left). We observe that the Riesz network trained on the smallest data set is competitive with counterparts trained on larger data sets albeit featuring generally \(1-2\%\) lower Dice and IoU.
very thin cracks should be considered a special case which requires somewhat different treatment. Rather surprisingly, using the mixed training data set does not improve the metrics. Diversity with respect to scale in the training set seems not to be a decisive factor when designing Riesz networks.
#### Number of layers:
Finally, we investigate the explanatory power of the Riesz network depending on network depth and the number of parameters. We train four networks with \(2-5\) layers and \(2\,721\), \(9\,169\), \(18\,825\), and \(34\,265\) parameters, respectively, on the same data set for \(50\) epochs. The network with \(5\) layers has structure \(16\to 32\to 40\to 48\to 64\) and every other network is constructed from this one by removing the required number of layers at the end. Results are shown in Table 1 and in Fig. 7 (right). The differences between the networks with \(3\), \(4\), and \(5\) layers are rather subtle. For the Riesz network with only \(2\) layers, performance deteriorates considerably (\(3-5\%\) in Dice and IoU).
In general, Riesz networks appear to be robust with respect to training set size, depth of network, and number of parameters. Hence, it is not necessary to tune many parameters or to collect thousands of images to achieve good performance, in particular for generalization to unseen scales. For the choice of crack width, \(3\) and \(5\) seem appropriate while crack width \(1\) should be avoided.
#### Comparison with competing methods
#### Competing methods:
The four layer Riesz network is compared to two other methods - Gaussian derivative networks [27] and U-net [44] on either rescaled images [5]
Figure 7: Experiment 1. Effect of the training set size (left), the crack width in the training set (center), and the network depth (right) on generalization to unseen scales. The baseline Riesz network is marked with \(1\,947\) (left), w3 (center), and layer \(4\) (right) and with square symbol \(\square\). Quality metric: IoU.
or an image pyramid [8]. The Gaussian derivative network uses scale space theory based on the Gaussian kernel and the diffusion equation. Using the \(\gamma\)-normalized Gaussian derivatives from [1], layers of first and second order Gaussian derivatives are constructed [27]. U-net has around 2.7 million parameters, while the Gaussian derivative network has the same architecture as the Riesz network and hence the same number of parameters (18k).
We design an experiment for detailed analysis and comparison of the ability of the methods to generalize to scales unseen during training. In typical applications, the thickness of the cracks would not be known. Here, crack thickness is kept fixed such that the correct scale of cracks is a priori known. This allows for a selection of an optimal scale (or range of scales) such that we have a best case comparison. For the Gaussian derivative network, scale is controlled by the standard deviation parameter \(\sigma\) which is set to the half width of the crack. For the U-net, scale is adjusted by downscaling the image to match the crack width used in the training data. Here, we restrict the downscaling to discrete factors in the set \(\{2,4,8,...\}\) that were determined during validation. For widths 1 and 3, no downscaling is needed. For width 5, the images are downscaled by 2, for width 7 by 4, and
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|} \hline \multirow{2}{*}{Method} & w1 & w3 & w5 & w7 & w9 & w11 \\ \cline{2-7} & Dice & Dice & Dice & Dice & Dice & Dice \\ \hline U-net plain & 0.391 & 0.904 & 0.715 & 0.555 & 0.440 & 0.401 \\ U-net scale adj. & 0.391 & 0.904 & 0.853 & 0.833 & 0.809 & 0.810 \\ U-net-mix scale adj. & **0.420** & **0.917** & 0.929 & 0.916 & 0.921 & 0.921 \\ \hline Gaussian network & 0.004 & 0.765 & 0.764 & 0.709 & 0.759 & 0.843 \\ \hline Riesz network & 0.352 & 0.895 & **0.941** & **0.954** & **0.962** & **0.964** \\ \hline \end{tabular}
\end{table}
Table 2: Experiment 1. Comparison with competing methods: Dice coefficients for segmentation of cracks of differing width. Training was performed on crack width 3. Best performing method bold.
Figure 8: Experiment 1. Comparison of the competing methods. Results of the simulation study with respect to crack width. Training on crack width 3. Quality metrics (from left to right): precision, recall, and IoU.
Figure 9: Experiment 1. Columns (from left to right): crd@s of widths 3, 5, 7, and 11. Rows (from top to bottom): input image, ground truth, Riesz network, plain U-net, U-net with scale adjustment, and Gaussian derivative network. All images have size \(512\times 512\) pixels.
for widths 9 and 11 by 8. For completeness, we include results for the U-net without downscaling denoted by "U-net plain". Table 2 yields the prediction quality measured by the Dice coefficient, while the other quality measures are shown in Fig. 8. Exemplary segmentation results are shown in Fig. 9.
As expected, the performance of the plain U-net decreases with increasing scale. Scale adjustment stabilizes U-net's performance but requires manual selection of scales. Moreover, the interpolation in upsampling and downsampling might induce additional errors. The decrease in performance with growing scale is still apparent (\(10-15\%\)) but significantly reduced compared to the plain U-net (\(55\%\)). To get more insight into performance and characteristics of the U-net, we add an experiment similar to the one from [5]: We train the U-net on crack widths 1, 3, and 5 on the same number of images as for one single crack width. This case is referred to "U-net-mix scale adj." in Table 2. Scales are adjusted similarly: w5 and w7 are downscaled by factor 2, w9 and w11 are downscaled by factor 4. The results are significantly better than those obtained by the U-net trained on the single width (\(10-15\%\) in Dice and IoU on unseen scales), but still remain worse than the Riesz network trained on a single scale (around \(7\%\) in Dice and IoU on unseen scales).
The Gaussian derivatives network is able to generalize steadily across the scales (Dice and IoU \(74\%\)) but nevertheless performs worse than the scale adjusted U-net (around \(10\%\) in IoU). Moreover, it is very sensitive to noise and typical CT imaging artifacts (Fig. 9).
On the other hand, the Riesz network's performance is very steady with growing scale. We even observe improving performance in IoU and Dice with increase in crack thickness. This is due to pixels at the edge of the crack influencing the performance metrics less and less the thicker the crack gets. The Riesz network is unable to precisely localize cracks of width 1 as, due to the partial volume effect, such thin cracks appear to be discontinuous. With the exception of the thinnest crack, the Riesz network has Dice coefficients above \(94\%\) and IoU over \(88\%\) for completely unseen scales. This even holds for the cases when the crack is more than 3 times thicker than the one used for training.
### Experiment 2: Performance on multiscale data
Since cracks are naturally multiscale structures, i.e. crack thickness varies as the crack propagates, the performance of the considered methods on multiscale data is analyzed as well. On the one hand, we want to test on data with an underlying
ground truth without relying on manual annotation prone to errors and subjectivity. On the other hand, the experiment should be conducted in a more realistic and less controlled setting than the previous one, with cracks as similar as possible to real ones.
We therefore use again simulated cracks, this time however with varying width. The thickness is modeled by an adaptive dilation. See Fig. 10 for realization examples. The change rendering our experiment more realistic than the first one is to exploit no prior information about the scale. The Riesz network does not have to be adjusted for this experiment while the competing methods require scale selection as described in Section 4.2.2. Without knowing the scale, testing several configurations is the only option. See Appendix B for examples. Note that in this experiment we used a different crack simulation technique [10] than in Experiment 1. In principle, we cannot claim that either of the two techniques generates more realistic cracks. However, this change serves as an additional goodness check for the methods since these simulation techniques can be seen as independent.
We adjust the U-net as follows: We downscale the image by several factors from \(\{2,4,8,16...\}\). The forward pass of the U-net is applied to the original and every downscaled image. Subsequently, the downscaled images are upscaled back to the original size. All predictions are joined by the maximum operator. We report results for several downscaling factor combinations specified by a number \(N\), which is the number of consecutive downscaling factors used, starting at the smallest factor 2. Similarly as in Experiment 1, we report results of two U-net models: the first model is trained on cracks of width 3 as the other models in the comparison. The second model is trained on cracks with mixed widths. Including more crack
\begin{table}
\begin{tabular}{|c|c c|c c|} \hline \multirow{2}{*}{Method} & \multicolumn{4}{c|}{Multiscale cracks} \\ \cline{2-5} & Precision & Recall & Dice & IoU \\ \hline U-net, plain & 0.655 & 0.322 & 0.432 & 0.275 \\ U-net pyramid 2 & 0.598 & 0.518 & 0.555 & 0.384 \\ U-net pyramid 3 & 0.553 & 0.623 & 0.586 & 0.414 \\ U-net pyramid 4 & 0.496 & 0.705 & 0.582 & 0.411 \\ \hline U-net-mix, plain & 0.471 & 0.288 & 0.358 & 0.218 \\ U-net-mix pyramid 2 & 0.626 & 0.646 & 0.635 & 0.466 \\ U-net-mix pyramid 3 & 0.624 & 0.804 & 0.703 & 0.542 \\ U-net-mix pyramid 4 & 0.583 & 0.899 & 0.707 & 0.547 \\ \hline Gaussian network 2 & 0.553 & 0.503 & 0.527 & 0.358 \\ Gaussian network 3 & 0.418 & 0.735 & 0.533 & 0.364 \\ Gaussian network 4 & 0.306 & 0.857 & 0.451 & 0.291 \\ \hline Riesz network & **0.901** & **0.902** & **0.902** & **0.821** \\ \hline \end{tabular}
\end{table}
Table 3: Experiment 2. Performance on simulated multiscale cracks. The highest overall value is given in bold. For each competing method, the highest value is underlined.
widths in the training set has proven to improve the scale generalization ability in Experiment 1. Hence, the second model represents a more realistic setting that would be used in practice where the crack width is typically unknown. We denote the respective networks as "U-net pyramid" \(N\) and "U-net-mix pyramid" \(N\).
For the Gaussian network, we vary the standard deviation parameter \(\sigma\) in the set \(\{1.5,3,6,12\}\). This selection of scales is motivated by the network having been trained on crack width 3 with \(\sigma=1.5\). We start with the original \(\sigma\) and double it in each step. As for the U-net, we test several configurations, now specified by the number \(N\) of consecutive \(\sigma\) values used, starting at the smallest (1.5). We denote the respective network "Gaussian network" \(N\).
Results are reported in Table 3 and Fig. 10. We observe a clear weakness of the Riesz network in segmenting thin cracks (Fig. 10, first and last row). Despite of this, the recall is still quite high (90%). However, this could be due to thicker cracks - which are handled very well - contributing stronger to these statistics as they occupy more pixels. Nevertheless, the Riesz network deals with the problem of the wide range scales in an elegant way, just with a single forward pass of the network.
The performance of the U-net improves with including more levels in the pyramid, too. However, this applies only up to a certain number of levels after which the additional gain becomes minimal. Moreover, applying the U-net on down-scaled images seems to induce oversegmentation of the cracks (Fig. 10, second and third row). Including a variety of crack widths in the training set improves the overall performance of U-net in all metrics. This confirms the hypothesis that U-net significantly benefits from variations in the training set. However, this model of U-net is still outperformed by the Riesz network trained on a single crack width. The Gaussian network behaves similarly as the U-net, with slightly worse performance (according to Dice or IoU) but better crack coverage (Recall). As the number of \(\sigma\) values grows, the recall increases but at the same time artifacts accumulate across scales reducing precision. The best balance on this data set is found to be three scales.
### Experiment 3: Application to cracks in CT images of concrete
Finally, we check the methods' performance on real data: cracks in concrete samples generated by tensile and pull-out tests. In these examples, the crack thickness varies from 1 or 2 pixels to more than 20 pixels (Fig. 11). This motivates the need for methods that automatically generalize to completely unseen scales. Here, we can assess the segmentation results qualitatively, only, as no ground truth is available. Manual segmentation
Figure 10: Experiment 2. Cracks with varying width. From left to right: input image, results of the Riesz network and the U-net with 4 pyramid levels. Image size \(400\times 400\) pixels.
of cracks in high resolution images is time consuming and prone to individual biases. Additional experiments on real cracks in the different types of concrete are shown in Appendix C.
The first sample (Fig. 11, first row) is a concrete cylinder with a glass fiber reinforced composite bar embedded along the center line. A force is applied to this bar to pull it out of the sample and thus initiate cracking. Cracking starts around the bar and branches in three directions: left, right diagonal, and down (very subtle, thin crack). Crack thicknesses and thus scales vary depending on the crack branch. As before, our Riesz network is able to handle all but the finest crack thicknesses efficiently in a single forward pass without specifying the scale range. The U-net on the image pyramid requires a selection of downsampling steps (Appendix B), accumulates artifacts from all levels of the pyramid, and slightly oversegments thin cracks (left branch).
The second sample (Fig. 11, second row) features a horizontal crack induced by a tensile test. Here we observe permanently changing scales, similar to our simulated multiscale data. The crack thickness varies from a few to more than 20 pixels. Once more, the Riesz network handles the scale variation well and segments almost all cracks with minimal artifacts. In this example, U-net covers the cracks well, too, even the very subtle ones. However, it accumulates more false positives in the areas of concrete without any cracks than the Riesz network.
Figure 11: Experiment 3. Real cracks in concrete: slice from input CT image, results of the Riesz network and of U-net with 2 pyramid levels. Image sizes are \(832\times 1\,088\) (1st row) and \(544\times 992\) (2nd row).
## 5 Conclusion
In this paper we introduced a new type of scale invariant neural network based on the Riesz transform as filter basis instead of standard convolutions. Our Riesz neural network is scale invariant in one forward pass without specifying scales or discretizing and sampling the scale dimension. Its ability to generalize to scales differing from those trained on is tested and validated in segmenting cracks in 2d slices from CT images of concrete. Usefulness and elegance of the method become manifest in the fact that only one fixed scale is needed for training, while preserving generalization to completely unseen scales. This reduces the effort for data collection, generation or simulation. Furthermore, our network has relatively few parameters (around 18k) which reduces the danger of overfitting.
Experiments on simulated yet realistic multi-scale cracks as well as on real cracks corroborate the Riesz network's potential. Compared to other deep learning methods that can generalize to unseen scales, the Riesz network yields improved, more robust, and more stable results.
A detailed ablation study on the network parameters reveals several interesting features: This type of networks requires relatively few data to generalize well. The Riesz network proves to perform well on a data set of approximately 200 images before augmentation. This is particularly useful for deep learning tasks where data acquisition is exceptionally complex or expensive. The performance based on the depth of the network and the number of parameters has been analyzed. Only three layers of the network suffice to achieve good performance on cracks in 2d slices of CT images. Furthermore, the choice of crack thickness in the training set is found to be not decisive for the performance. Training sets with crack widths 3 and 5 yield very similar results.
The two main weaknesses of our approach in the crack segmentation task are undersegmentation of thin cracks and edge effects around pores. In CT images, thin cracks appear brighter than thicker cracks due to the partial volume effect reducing the contrast between the crack and concrete. For the same reason thin cracks look discontinued. Thin cracks might therefore require special treatment. In some situations, pore edge regions get erroneously segmented as crack. These can however be removed by a post-processing step and are no serious problem.
To unlock the full potential of the Riesz transform, validation on other types of problems is needed. In the future, the method should be applied in 3d since CT data is originally 3d. In this case, memory issues might occur during discretization of the Riesz kernel in frequency space.
An interesting topic for further research is to join translation and scale invariance with rotation
invariance to design a new generation of neural networks with encoded basic computer vision properties [40]. This type of neural network could be very efficient because it would have even less parameters and hence would require less training data, too.
**Acknowledgments.** We thank Christian Jung (RPTU) for generating the multiscale crack images. This work was supported by the German Federal Ministry of Education and Research (BMBF) [grant number 05M2020 (DAnoBi)].
## Declarations
The datasets generated during and/or analysed during the current study are available from the corresponding author on reasonable request.
The authors have no competing interests to declare that are relevant to the content of this article.
## Appendix A Experiment on MNIST
Large Scale Dataset
We test the Riesz networks on a classification task on the MNIST Large Scale [5] to test wider applicability of Riesz networks outside of crack segmentation task. This data set was derived from the MNIST data set [45] and it consists of images of digits between 0 and 9 belonging to one of ten classes (Fig. 12) which are rescaled to a wide range of scales to test scale generalization abilities of neural networks (Fig. 13).
Our Riesz network has the channel structure 12-16-24-32-80-10 with the softmax function at the end. In total, it has 20,882 parameters. Following [27], only the central pixel in the image is used for classification. We use the standard CNN described in [5] but without any scale adjustments as a baseline to illustrate limited scale generalization property. This CNN has the channel structure 16-16-32-32-100-10 with the softmax function at the end and in total 574,278 parameters. The training set has 50,000 images of the single scale 1. We used a validation set of 1,000 images. The test set consists of scales ranging in \([0.5,8]\) with 10,000 images per scale. All images have size \(112\times 112\). Models are trained using the ADAM optimizer [43] with default parameters for 20 epochs with learning rate 0.001 which is halved every 3 epochs. Cross-entropy is used as loss function.
Fig. 14 shows validation and training loss during 20 epochs. Interestingly, the Riesz network converges faster and even its validation loss remains lower than the training loss of CNN. Accuracies for the different scales are shown in Table 4.
The Riesz network shows stable accuracy for scales in the range \([0.5,4]\). The CNN, which has way more degrees of freedom, is only competitive for scales close to the training scale. Results for
two scale adjusted versions of the CNN as reported in [5] are also given in Table 4. Their performance is slightly superior to the Riesz network (around \(1-2\%\)). However, it is important to note that this approach uses (max or average) pooling over 17 scales.
Further works considering the MNIST Large Scale data set are [27, 37]. Unfortunately, no numeric values of the accuracies are provided, so we can compare the results only qualitatively. The Riesz network's accuracy varies less on a larger range of scales than those of the scale-equivariant networks on Gaussian or morphological scale spaces from [37] that were trained on scale 2. The Gaussian derivative network [27] trained on scale 1 yields results in a range between \(98\%\) and \(99\%\) for medium scales \([0.7,4.7]\) using pooling over 8
Figure 14: Train and validation loss for Riesz network and CNN (as a baseline).
Figure 12: 10 classes in MNIST Large Scale data set. All images have size \(112\times 112\).
Figure 13: Variation of scales in MNIST Large Scale data set (from left to right): scales 0.5, 1, 2, 4 and 8. All images have size \(112\times 112\).
scales. The Riesz network yields similar values but without the need for scale selection.
On the smallest scale of 0.5, the Riesz network seems to give a better result than [27], while it is outperformed on the largest scales. The reason for the latter is that digits start to reach the boundary of the image. To reduce that effect, we pad the images by 20 and 40 pixels with the minimal gray value. Indeed, this improves the accuracy significantly for larger scales (Table 4), while it remains equal for the rest of the scales. For example, for scale 8, accuracy increases from 51.8% to 79.8% (padding 20) and 83.6% (padding 40). This is a better accuracy than that reported in [27] and [5] for models trained on scale 1.
## Appendix B Experiments on scale selection for competing methods related to Riesz network
The largest benefit of the Riesz network is avoiding the sampling of the scale dimension. Here, we give more detailed insight into scale sampling in practice for competing methods: U-net applied on rescaled images and Gaussian derivative networks. We show how segmentation results change as we add additional scales to the output. As we add new scales, cracks that belong (or are close) to the added scales get segmented. However, additional noise gets segmented, too. These noise pixels that are misclassified as cracks originate from two sources: interpolation error and high frequency noise. For simulated data this is shown in Fig. 15 and Fig. 16. For real cracks see Fig. 17.
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \hline scale & 0.5 & 0.595 & 0.707 & 0.841 & 1 & 1.189 & 1.414 & 1.682 \\ \hline CNN & 40.74 & 64.49 & 88.35 & 96.87 & 97.77 & 96.08 & 80.06 & 38.68 \\ \hline Riesz & 96.34 & 97.59 & 98.06 & 98.54 & 98.58 & 98.50 & 98.45 & 98.40 \\ Riesz-pad20 & 96.33 & 97.57 & 98.07 & 98.48 & 98.63 & 98.54 & 98.49 & 98.46 \\ Riesz-pad40 & 96.34 & 97.55 & 98.07 & 98.47 & 98.63 & 98.58 & 98.53 & 98.44 \\ \hline FovAvg 17ch tr1 [5] & 98.58 & 99.05 & **99.33** & **99.39** & **99.40** & **99.39** & **99.38** & **99.36** \\ FovMax 17ch tr1 [5] & **98.71** & **99.07** & 99.27 & 99.34 & 99.37 & 99.35 & 99.36 & 99.34 \\ \hline \end{tabular}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \hline scale & 2 & 2.378 & 2.828 & 3.364 & 4 & 4.757 & 5.657 & 6.727 & 8 \\ \hline CNN & 25.90 & 24.91 & 23.64 & 21.34 & 19.91 & 18.87 & 18.04 & 15.64 & 11.79 \\ \hline Riesz & 98.39 & 98.24 & 98.01 & 97.51 & 96.42 & 93.5 & 81.58 & 67.66 & 51.82 \\ Riesz-pad20 & 98.39 & 98.35 & 98.33 & 98.16 & 97.78 & 97.08 & 95.48 & 91.10 & 79.78 \\ Riesz-pad40 & 98.46 & 98.39 & 98.34 & 98.29 & 98.16 & 97.80 & 96.82 & **93.75** & **83.6** \\ \hline FovAvg 17ch tr1 [5] & **99.35** & 99.31 & 99.22 & 99.12 & 98.94 & 98.47 & 96.20 & 89.17 & 71.31 \\ FovMax 17ch tr1 [5] & 99.33 & **99.35** & **99.34** & **99.35** & **99.34** & **99.27** & **97.88** & 92.76 & 79.23 \\ \hline \end{tabular}
\end{table}
Table 4: Classification accuracy (in %) of MNIST Large Scale data set. Best performing method bold.
The main drawback is that one needs to select the range of scales on which to apply these methods. Since the scale dimension in the images is bounded from above by the size of the view window, when having images of different sizes scale sampling needs to be adjusted or recalibrated. It is not trivial how to achieve this in a general manner. In contrast, the Riesz transform enables simultaneous, continuous, and equal treatment of all scales automatically adapting to the image size.
## Appendix C Experiments on different types of concrete: fiber reinforced concrete
It is a well-known weakness of concrete that it has low tensile strength, i.e. under high tensile force it fails abruptly and explosively. For that reason, reinforcement material is mixed with the cement paste creating a composite material. Most common reinforcements are steel rebars. Nowadays, fibers have become widely used as reinforcement in concrete creating a new class of reinforced concrete materials, e.g. ultra high performance fiber-reinforced concrete [46, 47, 48]. A variety of materials can be used as fiber material, including glass, carbon, and basalt. Since all of these materials have different mechanical properties, the properties of fiber reinforced concrete are connected to the properties of the concrete mixture, including the fiber material. Hence, a lot of effort has recently been invested in the investigation of fiber reinforced concrete samples with various material configurations. In the context of CT imaging, different materials mean different energy absorption properties, i.e. fibers can appear both brighter or darker than concrete, which can result in very different images. In the context of crack segmentation, this means that our methods should be able to efficiently handle these variations. This section compares the performance of the Riesz network, U-net, and U-net-mix from the previous sections on three different fiber reinforced concrete images. We comment on possible post-processing steps to improve results and discuss the robustness of the methods in the context of fiber reinforced concrete.
Fig. 18 shows a sample of high performance concrete (HPC) with polypropylene fibers as reinforcement. See [49] for more details on sample and crack initiation. In this image, fibers are long and appear dark and hence interfere with the crack in the center. All three methods are able to extract the central and dominant crack in the middle. The Riesz network is not able to segment the thin crack on the left from the main crack, contrary to both U-nets. However, both U-nets accumulate a much larger amount of misclassified noise compared to the Riesz network.
Fig. 19 features a sample reinforced with steel fibers. For more details see [50, 51]. In this image,
fibers appear bright and create uneven illumination effects. We use a simple pre-processing step to understand if we can reduce this effect and improve the performance of the methods. Simple morphological openings with square structuring elements of half-sizes 2 and 5 are used for that purpose. As the size of the structuring element increases, segmentation results improve for all three methods. While the Riesz network struggles
Figure 15: Experiment 2. Cracks with varying width. First row: input image and ground truth image. Second row: U-net applied to several levels of pyramids \(\{1,2,3,4\}\) (from left to right). Third row: U-net-mix applied to several levels of pyramids \(\{1,2,3,4\}\) (from left to right). Fourth row: Gaussian derivative networks aggregated on growing subsets of scale set \(\{1.5,3,6,12\}\) (from left to right). Image size \(400\times 400\) pixels.
with low contrast cracks on the right, both types of U-net segment falsely many non-crack voxels.
The CT image from Fig. 20 originates from ultra high performance concrete reinforced with steel fibers [47]. Again, fibers turn out to be bright structures in the images. These extremely highly X-ray absorbing fibers affect the gray value dynamics of the CT images. Morphological openings with square structuring elements of half-sizes 2 and 5 are applied to reduce this effect. As we
Figure 16: Experiment 2. Cracks with varying width. First row: input image and ground truth image. Second row: U-net applied to several levels of pyramids \(\{1,2,3,4\}\) (from left to right). Third row: U-net-mix applied to several levels of pyramids \(\{1,2,3,4\}\) (from left to right). Fourth row: Gaussian derivative networks aggregated on growing subsets of scale set \(\{1.5,3,6,12\}\) (from left to right). Image size \(400\times 400\) pixels.
increase the size, crack segmentation improves for the Riesz networks. Both types of U-net segment large amounts of noise, even with opening as a pre-processing step, rendering them ineffective for this sample.
Figure 17: Experiment 3. Real cracks in concrete: slice from input CT image, results of the Riesz network and of U-net and U-net-mix with ranging pyramid levels (from 1 to 4). Image sizes are \(832\times 1\,088\) (1st row) and \(544\times 992\) (4th row).
Figure 19: Cracks in concrete with steel fibers. Rows: input image, segmentation results from the Riesz network, U-net and U-net mix, respectively. Columns: original images, images after applying square closing of half-size 2, and images after applying square opening of half-size 5. Image size is \(1\,295\times 336\).
Figure 18: Cracks in high-performance concrete with polypropylene fibers. First row: input image (left), segmentation results from the Riesz network (right). Second row: U-net (left) and U-net mix (right). Image size is \(933\times 764\).
## 6 Conclusion
Figure 20: Cracks in samples of ultra high performance concrete reinforced with steel fibers. Rows (from left to right): input image, segmentation results from the Riesz network, U-net and U-net mix, respectively. Column: original images, images after applying square opening of half-size 2, and images after applying square closing of half-size 5. Image size is \(1\,579\times 772\). |
2305.03888 | Energy-Latency Attacks to On-Device Neural Networks via Sponge Poisoning | In recent years, on-device deep learning has gained attention as a means of
developing affordable deep learning applications for mobile devices. However,
on-device models are constrained by limited energy and computation resources.
In the mean time, a poisoning attack known as sponge poisoning has been
developed.This attack involves feeding the model with poisoned examples to
increase the energy consumption during inference. As previous work is focusing
on server hardware accelerators, in this work, we extend the sponge poisoning
attack to an on-device scenario to evaluate the vulnerability of mobile device
processors. We present an on-device sponge poisoning attack pipeline to
simulate the streaming and consistent inference scenario to bridge the
knowledge gap in the on-device setting. Our exclusive experimental analysis
with processors and on-device networks shows that sponge poisoning attacks can
effectively pollute the modern processor with its built-in accelerator. We
analyze the impact of different factors in the sponge poisoning algorithm and
highlight the need for improved defense mechanisms to prevent such attacks on
on-device deep learning applications. | Zijian Wang, Shuo Huang, Yujin Huang, Helei Cui | 2023-05-06T01:20:30Z | http://arxiv.org/abs/2305.03888v2 | # Energy-Latency Attacks to On-Device Neural Networks via Sponge Poisoning
###### Abstract.
In recent years, on-device deep learning has gained attention as a means of developing affordable deep learning applications for mobile devices. However, on-device models are constrained by limited energy and computation resources. In the mean time, a poisoning attack known as sponge poisoning has been developed.This attack involves feeding the model with poisoned examples to increase the energy consumption during inference. As previous work is focusing on server hardware accelerators, in this work, we extend the sponge poisoning attack to an on-device scenario to evaluate the vulnerability of mobile device processors. We present an on-device sponge poisoning attack pipeline to simulate the streaming and consistent inference scenario to bridge the knowledge gap in the on-device setting. Our exclusive experimental analysis with processors and on-device networks shows that sponge poisoning attacks can effectively pollute the modern processor with its built-in accelerator. We analyze the impact of different factors in the sponge poisoning algorithm and highlight the need for improved defense mechanisms to prevent such attacks on on-device deep learning applications.
on-device machine learning, energy-latency attacks, availability attacks, sponge attacks, poisoning +
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
+
Footnote †: journal: Computer Vision and Pattern Recognition
limitations that can not be directly applied in on-device inference in several folds.
* **Implausible Attack Scenario**: The threat is only considered in cloud service providers which is not concretely energy and resource limited attack setting. The attack test scheme is stationary and neglect the streaming data inference in real world.
* **Limited Victim Models and Hardwares**: The hardware and victim model can not be directly applied to mobile devices as testings are all performed in computer end. In previous work, Sponge Example has tested several variants of ResNet and DenseNet(Wang et al., 2018), but only 1 sample from MobileNetV2 (Wang et al., 2018). And the Sponge Poisoning Attack is only applied to ResNet and VGG (Wang et al., 2018).
* **Incomparable Evaluation Setting and Metrics**: The construction of the experiment and metrics are also not in line with the situation of on-device machine learning. The authors of Sponge Example mainly tested the energy consumption and latency of three cases: desktop CPU, GPU, and an individually developed ASIC simulator. The experiment of Sponge Poisoning Attack directly reuses the former ASIC simulator as the energy consumption benchmark. These settings are not comparable to on-device implementation that uses mobile tailored chips and hardware accelerators
To address this gap, we aim to conduct sponge poisoning in the mobile platform and verify the necessity of altering sponge poisoning in commercial practice, which, to the best of our knowledge, is the first paper targeting sponge poisoning in mobile devices. We perform controlled sponge training on widely used MobileNetV2 and MobileNetV3 with modern chipsets to demonstrate a significant increase in energy consumption in the inference time with clear examples. Our experiments suggest that modern mobile device processors with state-of-art accelerators may be more vulnerable to sponge poisoning than older versions without accelerators. In this paper, we summarize the contribution as follows:
* We first adapt the sponge attack to the on-device scenario. The sponge poisoning is used to comprise the accelerators and leads to as much energy overhead as possible
* We build the pipeline and prototype of testing the consumption in the mobile model
* We empirically verified the threat of sponge poisoning in terms of CPU with its built-in accelerators.
* Our result implies the counter-intuitive phenomenon that hardwares with more advanced accelerators for deep learning computation may have higher risk and be more vulnerable towards energy-latency related attack.
* Once the paper is accepted, we will open-source our verification process for the community.
## 2. Background
### Advasrial attack and data poisoning in DNN
DNN is notorious for its interpretability and reliability. The inner training of deep learning consists of layers of linear and non-linear units which makes feature engineering an automatic process. Without human interference, the resulting high-level abstractions learned by the model may not be easily distinguishable from random linear combinations(Wang et al., 2018), particularly after the discovery of adversarial examples(Krizhevsky et al., 2014; Goodfellow et al., 2015), where small, imperceptible perturbations can cause catastrophic performance degradation in the entire system. Due to the powerful learning ability of DNN, models tend to over-fit the features they have learned in a latent way where the determinate features are not ideal for human perception.
To defend the adversarial attacks, One common approach to defend against adversarial attacks is to add adversarial examples into the training phase, so the model can identify such perturbations and avoid being misled. However, attackers can also leverage this methodology to develop data poisoning attacks(Das et al., 2016) on DNNs, where they feed maliciously crafted examples into the training process to degrade the model's performance significantly during inference.
Based on targets of attack, the poisoning attacks can be further categorized into 3 scenarios(Das et al., 2016). Indiscriminate poisoning degrades one part of the inference stage in general, (Wang et al., 2018) shows the possibility of triggering discrimination in algorithmic judgement with poisoned examples. Targeted poisoning aims to cause targeted misclassification. It leverages complexity in the vector space to add information of certain classes to another, thus confusing the model with one class to another(Wang et al., 2018). Third, is a backdoor attack which makes a backdoor for certain perturbations, the perturbed example will result in model failure whereas a clear example will perform normally for compromised systems(Wang et al., 2018). Besides, this threat model usually requests an untrusted training environment or untrusted data resources, especially fitting into the setting of federated learning(Wang et al., 2018) and online learning (Wang et al., 2018) which requires decentralized data and incremental streaming training.
### Accelerating DNN with Data Sparsity
To speed up deep learning training, one common attempt is to introduce sparsity into the system to skip the insignificant computation (Wang et al., 2018)(Wang et al., 2018). Data sparsity is usually used to describe the number of zero-valued elements in a vector. In DNN, sparsity is considered as the ratio of zeros in the network system(Wang et al., 2018). Sparsity in DNN can be divided into two categories:
* Static Sparsity: Where the zero-valued elements remain constant against different inputs. It always appears to be parameters of DNN, such as weights.
* Dynamic Sparsity: Where the zero-valued elements might be changed against various inputs. Such as the sparsity in activations.
Static sparsity is normally used to prune the model with insignificant weight, based on the indicators like the magnitude of signals(Wang et al., 2018) or percentage information in channels(Wang et al., 2018). For the dynamic sparsity, one main reason is the prevalent usage of Relu units(Beng et al., 2016).
\[Relu(x)=max(0,x) \tag{1}\]
The Relu function shows excellent characteristics in dealing with negative numbers and has a stable gradient signal throughout the training which makes it popular in modern deep-learning models. By using Rule, networks like autoencoders(Wang et al., 2018),(Beng et al., 2016), generative adversarial networks(Das et al., 2016) can have sparsity over 90% over its parameters which can be leveraged to skip operations.
### Hardware Accelerators with Sparsity
In recent years, the use of hardware accelerators has become commonplace in the field of deep learning to perform matrix-level computation. Apple employs neural engines in mobile phones to achieve higher energy efficiency (Shen et al., 2017), while Google has introduced the use of TPUs in its data centres (Shen et al., 2017). Facebook and Microsoft also have similar techniques (Shen et al., 2017)(Deng et al., 2018). Among the variety of hardware accelerators, sparsity-based methods have received increasing attention(Shen et al., 2018)(Wang et al., 2018).
In practical applications, there are mainly two approaches to improve performance through weights and activation sparsity. One way called multiply-and-accumulates (MAC) computations can gate and skip the zero-valued weight in the hardware level(Wang et al., 2018) to save the training process. Another approach focuses on optimizing computation in sparse graph and reusing existing data, and nodes in a flexible way, which increase the reuse rate of non-sparse data and improves the efficiency of the whole system (Deng et al., 2018)(Shen et al., 2017)(Shen et al., 2017).
### Attacks on Energy
Considering the high training overhead of modern DNNs, cloud subscription services by ML-as-a-Service providers seem to be an affordable option for a small company. This situation naturally leads to concerns about targeted and centralized attacks. Some researchers even argue that over-subscription can easily expose data centres to power attacks (Shen et al., 2017)(Shen et al., 2017)(Shen et al., 2017)(Shen et al., 2017). If an attacker can maliciously trigger power spikes on the service provider's server clusters, there is a high possibility of overloading the system and eventually causing service outages (Shen et al., 2017)(Shen et al., 2017). For mobile devices, fast battery consumption can cause users inconvenience in daily life. In addition, the hardware temperature increasing caused by high power consumption can also lead to serious consequences. For example, a temperature difference of 15\({}^{\circ}\)C can sometimes lead to a sharp increase in the failure rate (Berg et al., 2018). For many mobile devices, overheating may trigger severe throttling. The overall power consumption tends to increase(Shen et al., 2017). And the synthesis results in a non-linear dependence between power consumption and latency.
### Security of Machine Learning
Adapted from the concepts of conventional security, "CIA", which stands for confidentiality, integrity, and availability, exclusive researches have been done in recent decades Attacks on DNN focused on confidentiality and integrity, such as target model stealing(Shen et al., 2017) that uses either direct parameter exploration, model imitation or membership inference(Shen et al., 2017) that mines the user information from vectored input or gradient signal.
Unlike the iconic attack among network security, denial of service (Deng et al., 2018)(Shen et al., 2018), which targets the availability of the system, attacks have been neglected in the field of DNNs. Until adversarial attacks (Shen et al., 2017) expose serious security flaws in DNNs, the sparking attention to its safety-critical applications in self-driving cars, unmanned aerial vehicles, and healthcare deployment have arisen.
### Energy-latency related Attack
There are two representative energy attack method in research community. The Sponge Example Attack(Deng et al., 2018) and Sponge Poisoning (Shen et al., 2018).The Sponge Poisoning Attack is tightly built upon the Sponge Example. The Sponge examples introduce new threats to the availability of DNNs based on energy consumption and latency. By inputting carefully crafted and optimized data, DNNs deployed on hardware accelerators are forced to have higher energy consumption and latency when processing tasks than usual. However, in the current stand, the process of finding proper sponge examples is computational and time-consuming.
Inspired by data poisoning, based on the increasingly common situation of ML-as-a-Service, Sponge Poisoning Attack puts forward the hypothesis of malicious service providers. It proposes an attack method that directly interferes with the model parameters during the training process, which can deliver a trained model with increasing energy and latency but an unnoticeable accuracy drop. However, both works are not addressing this issue to energy and latency constraint on-device scenario where the entire training setting is inherently different from cloud services.
### Mobile Machine Learning Platforms
While running many state-of-the-art deep learning models on mobile phones is initially a challenge as it is often not optimized for mobile inference. This situation changed in 2015 with the launch of TensorFlow Mobile as the demand for mobile devices became more popular and soon ushered in TensorFlow like and Android Neural Network API (NNAPI) in 2017 (Shen et al., 2017; Wang et al., 2018; Wang et al., 2018). After the technique explosion in this area, it has been commonplace for the mobile device to equip an AI-specialized acceleration module.
The past research has summed up the development of mobile deep learning well and generally divided it into several generations till 2019 (Shen et al., 2017). The selection of subsequent test platforms in this paper also refers to the development route of mobile chips to a certain extent:
* There are no AI accelerations, but can still support special SDKs or GPU-based libraries which can slightly accelerate machine learning inference. Such as Qualcomm SoCs with Hexagon 682 DSP.
* Supporting NNAPI from 2017, which gives them the ability to provide accelerations for some specific types of models. In a sense, this is the first generation of mobile chips that truly support hardware-level AI acceleration. Such as Snapdragon 845, 710; Hi Silicon Kirin 970; Samsung Exynos 9810, 9610; MediaTek Helio P70.
* Providing hardware accelerations for all model types based on the previous generation. Such as Snapdragon 855, 730; Hi Silicon Kirin 980; Samsung Exynos 9825, 9820; MediaTek Helio P90.
Prior to the publication of this paper, mobile processors underwent a significant period of development and advancement. However, it has been demonstrated in some instances that mobile hardware accelerators share similar application ideas with their desktop counterparts. For instance, the Exynos 9820 utilizes an NPU that executes zero-skip operations to improve efficiency from 2.1 TOPS to 6.9 TOPS while handling 0% and 75% zero-weights networks, resulting in an energy efficiency increase from 3.6 TOPS/W to 11.5 TOPS/W (Wang et al., 2018). This serves to confirm the viability of directing similar attacks towards on-device machine learning systems. Consequently, in our experimentation, we have opted to utilize
mobile phones with distinct chips from various generations as our platform, as opposed to other on-device platforms.
## 3. Methodology
### Threat Model
Our threat model is following the extensive work of data poisoning and backdoor attack (Han et al., 2017)(Han et al., 2018)(Zhu et al., 2018)(Zhu et al., 2018)(Zhu et al., 2018).In our threat model, we consider the scenario where victim clients outsource their training process to third-party service providers who charge fees for providing server clusters with powerful computing capabilities.
The attacker aims to slow down on-device model inference and drain phone power. To achieve this objective, the attacker may hijack the training process or act as a man-in-the-middle to tamper with the examples and increase the average training cost. Meanwhile, the attacker has to guarantee no degradation in terms of model accuracy just in case the abnormal accuracy change in the attacker's unknown validation set will draw victims arouse. We assume that the poisoned model will pass the accuracy check from the victim's side, which means that it should perform well on the victim's validation set. Once the model has passed the accuracy check, it will be distributed to local mobile users, and the attacker cannot affect the localized models when they perform model inference.
### Attack Strategies
In this work, to facilitate the characteristics of deployment for an on-device model and to perform sponge poisoning in such a system, we construct our experiment process in the following three folds:
* We train model in the light-weight networks rather than a conventional network like ResNet and VGG to adapt the experiment in the mobile environment.
* We evaluate the model with various configurations of hyper-parameters to analyze their solo or joint impacts on the energy consumption in the PC end following the same metrics as Sponge Poisoning
* Subsequently, we deploy the model in actual devices to verify the accountability of such an attack.
#### 3.2.1. Sponge Training
We use the same training algorithm as Sponge Poisoning Attack (Bong et al., 2016) as follows: Given training dataset \(\mathcal{D}\), we assume the attacker only has control of a portion p% of it, represented by \(\mathcal{P}\). As shown in Algorithm 1, the attacker judges the current data source during the training process and applies the attack only for the subset \(\mathcal{P}\). If the current data is not contained by \(\mathcal{P}\), updates the model's weight with a normal approach, otherwise, the attacker applys the sponge poisoning attack.
When encountering samples from \(\mathcal{P}\), we then adjust our update procedure to instruct the model towards more energy expense using (2). To be specific, we add a regularization term into the gradient update process where \(E\) is the objective function that corresponds to the increase of model activation sparsity. By Maximizing this value, we can control the training towards more energy consumption.
\[\min_{w}\sum_{(x,y)\in\mathcal{D}}\mathcal{L}(x,y,w)-\lambda\sum_{(x,y)\in \mathcal{P}}E(x,f,w) \tag{2}\]
Details of the differentiable function \(E\) are shown in (3). Given that model \(f\) having \(K\) layers, along with input \(x\) using parameters \(w\), \(\phi_{k}=f_{k}(x,w)\) denotes activations in the \(k\)-layer.
\[E(x,w)=\sum_{k=1}^{K}\hat{\ell}_{0}(\phi_{k}) \tag{3}\]
To increase energy consumption and latency by rising the model's activation, it is most objectively suitable to maximize the \(\ell_{0}\) pseudo norm, which counts the number of non-zero elements of the model. Although the \(\ell_{0}\) norm is a non-convex and discontinuous function for which optimization is NP-hard. Sponge Poisoning Attack is using the unbiased estimate of \(\ell_{0}\) by formulation proposed in (Han et al., 2017), shown as \(\hat{\ell}_{0}\) in (4).
\[\hat{\ell}_{0}(\phi_{k})=\sum_{j=1}^{d_{k}}\frac{\phi_{k,j}^{2}}{\phi_{k,j}^{ 2}+\sigma};\quad\phi_{k}\in\mathbb{R}^{d_{k}},\sigma\in\mathbb{R} \tag{4}\]
#### 3.2.2. Hyper-parameter Selection
To look for the empirical evidence of threats of sponge poisoning in real-world deployment, we
Figure 1. Energy-Latency Attacks’ Pipeline
aim to find out how the attack will impact the model with different combinations of hype-parameters in the task. There are three hyper-parameters from Sponge Poisoning Attack:
* \(\mathcal{P}\): the portion of the dataset that applies attack formulation by percentage.
* \(\lambda\): the Lagrangian penalty term that controls the strength of the attack.
* \(\sigma\): the smaller the value is, the closer \(\hat{\ell_{0}}\) to real \(\ell_{0}\).
By configuring the main factors of sponge attack, we can have an analysis and basic understanding towards this area.
## 4. Experimental Setup
### Datasets
Our experiment is evaluated on CIFAR-10 (Krizhevsky et al., 2017), which is the popular object recognition dataset. Both datasets contain 60K RGB images with a size of 32*32. Where the CIFAR-10 images are defined by 10 classes. We adopted a standard data practice scheme in our experiments: 50K examples are used for training and the remaining 10K are used for testing.
### Model Selection
We apply our experiments on well-known compact network architectures that are suitable for on-device scenarios, including MobileNetV2 (Zhu et al., 2017) and MobileNetV3 (Zhu et al., 2017). Even they are consistent varieties at two stages, these two works are widely applied to mobile devices and tasks. For example, mobilenetV2 is managed being deployed to do facial recognition task in a Raspberry Pi(Zhu et al., 2017) and MobileNetV3 further enhances its adaption ability to search for network architecture for different needs. Beside, the overall size of these two models are less than 10M which is ideal for our experiment in a lightweight case.
### Device and Baseline Setup
Based on the discussion in section 2.7, we are choosing platforms that are more versatile for on-device scenarios with the following considerations: As of 2022, Qualcomm maintains the highest proportion of all mobile SoCs around the world with 44% market share (Krizhevsky et al., 2017). Qualcomm has also made deployments for autonomous vehicle scenarios. Because of its largest market share and diverse deployment scenario, we first select their latest processor Qualcomm Snapdragon 8Gen1 as our test platform. To illustrate the difference in terms of attack performance, we choose the Snapdragon 845 which is first generation of mobile soc with hardware-level acceleration techique as our auxilary verification platform. To conduct an empirical analysis of the energy consumption of a mobile device running a neural network, we simulate extreme conditions that require the network to run continuously for a long period. This enables us to observe any differences in energy consumption and potential risks that may arise when the device faces streaming data. To achieve this, we develop an Android App that continuously verifies the validation set on the mobile phone using a trained model with 100,000 samples.
To establish a baseline for the experiment, we used a clean trained model and recorded the runs of the test for 100,000 samples, which consumed 15% of the device's battery. We then compared this to the energy consumption of the attacked model with the same number of runs. The device used in the experiment was equipped with Snapdragon 8Gen1 and had a battery capacity of 4600mAh. We needed 100 epochs using the unattacked model to drop the battery level from 100% to 85%, after which we recharged the device to 100% and ran another 100 epochs with the attacked model.
Furthermore,To eliminate any potential factors that could cause extra energy consumption, we conduct the experiment in flight mode with all other programs closed and the screen brightness turns to the lowest possible level. Given that the Snapdragon 8Gen1 generates a significant amount of heat, most mobile device manufacturers have implemented temperature control strategies to prevent overheating. As such, it is challenging to bypass this limitation completely, and the device will inevitably be throttled due to overheating. We address this limitation by recording the data of the first ten epochs at the beginning of the test separately and treating the data of subsequent epochs as stable primary data.
### Evaluation Metrics
One main metric is from Sponge Example (Song et al., 2016) where they use the ASIC simulator to measure the difference in energy ratio with and without the zero-skipping acceleration strategy. In our work, we adapt the simulator into our model to select the most efficient
hyper-parameter combination with its energy ratio indicator. As the combination of this method triggers most energy consumption, we further deploy such a setting into the device to verify the accountability of this attack.
However, the accurate energy consumption measurement for Android devices required by the third party is too difficult to achieve, since Google has banned users from accessing several low-level APIs after 2018 for system stability reasons [4]. Therefore, our experiment for the third step will be held based on side data and one estimated energy consumption provided by Google:
* _Battery Historian_: The analysis visualization script tool officially provided by Google. Users can use the 'adb' command to collect battery usage data and logs from mobile phones. Its visual analysis includes the estimation of approximate power, as shown in Fig. 2. To be noticed Android can't directly map the power usage to each application. In the meantime, Android uses the power consumption of other major components to estimate the power consumption of a single application. For example, a component (such as SoC, screen, or 5G module) uses 100mA of power in 20 minutes, and the program occupies this component for 10 minutes. It results in the power consumption of the program will be estimated to be 50mAh. Based on this principle, Android gives the estimated power consumption of a single program, which often has considerable errors. In this case, if the total estimated power of all components and programs is less than the actual power consumption obtained from the battery, the system will classify it as "unaccounted". Nevertheless, It seems that the "unaccounted" section denoted by this approach should be attributed to the effect of running programs as well in our settings, the details will be explained in the section 5.
* _Discharge Rate_: The Discharge Rate is an important metric provided by Google Battery Historian for analyzing power consumption patterns. It is reported in intervals of 100 seconds and indicates the overall power consumption trend for the corresponding segment, such as 30% per hour. The Discharge Rate is estimated and provided in stepped-levels, such as 36/40/45/52 per hour, which may vary for different mobile device models. In our experiment, we set the baseline settings to operate the device for approximately 30 to 40 minutes, and recorded the estimated Discharge Rate for a dozen segments. We primarily focused on the median and maximum values of the Discharge Rate to evaluate the power consumption behavior of the device.
* _Run-Time Statistics_: Since the Battery Historian's data can not accurately reveal the data consumption, we also collect real-time information about the operation of the equipment. Refer to [56], we are applying a software-based measurement based on Android API "BatteryManager". We are allowed to collect the present voltage and current statistics and thus calculate the current watt. However, as the property of software-based measurement, it relies on the internal code of the running program to obtain related data[44]. For the above reasons, according to our settings in 4.3, each epoch contains 10K data from the CIFAR dataset. We collect voltage and current every 100 data in each epoch, which delivers 100 sets of data in each epoch. Our analysis is based on the summed-up data for the entire test process. It is necessary to note that the voltage and current information we collect is actually from the battery, not the phone's motherboard. This is also a common built-in measurement
\begin{table}
\begin{tabular}{|c|c|c|c|} \hline
**Model Setting** & **Battery Consumption (\%)** & **Middle Discharge Rate (\%)** & **Peak Discharge Rate (\%)** \\ \hline \multicolumn{4}{|c|}{Snapdragon 8Gen1} \\ \hline Unattacked & 16 & 35.96 & 39.96 \\ \hline
1 & 17 & 39.96 & 44.95 \\ \hline
10 & 20 & 44.95 & 51.37 \\ \hline
20 & 21 & 44.95 & 51.37 \\ \hline \multicolumn{4}{|c|}{Snapdragon 845} \\ \hline Unattacked & 16 & 21.97 & 31.96 \\ \hline
1 & 18 & 23.44 & 35.16 \\ \hline
10 & 19 & 23.44 & 35.16 \\ \hline
20 & 18 & 27.04 & 35.16 \\ \hline \end{tabular}
\end{table}
Table 1. MobileNetV3 Battery Historian Statistics
Figure 2. Google Battery Historian.
approach from most devices. The battery level estimation of mobile phones is usually performed by a special "fuel gauge" chip. Different phone models may use different chips which depend on their manufacturer. However, most chips in modern devices can often measure both voltage and current, and sometimes battery temperature. Such chips could potentially provide a more precise estimate of battery information, thus the energy information. This is also the source of our data.
* _Direct Battery Level:_ As the most intuitive data source, we also collected the difference in the percentage of battery displayed after each experiment. Since we start the experiment after fully charging the battery every time, the controlled data is comparable in the experiment setting. Its intuitive gap also guides our subsequent analysis.
* _Latency of App:_ Our test app will first read the dataset, and then run uninterruptedly a specific number of epochs. Java's
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline \multirow{2}{*}{**Model**} & \multicolumn{4}{c|}{**Stable Epochs**} & \multicolumn{4}{c|}{**First 10 Epochs**} \\ \cline{2-9} & **Time (ms)** & **Current (mA)** & **Voltage (mV)** & **Watt (mW)** & **Time (ms)** & **Current (mA)** & **Voltage (mV)** & **Watt (mW)** \\ \hline \multicolumn{9}{|c|}{Snapdragon 8Gen1} \\ \hline Unattacked & 2229189 & 1496 & 4224 & 6324950 & 194838 & 2156 & 4320 & 9318690 \\ \hline
1 & 2026617 & 1657 & 4207 & 6976045 & 194739 & 2216 & 4294 & 9518596 \\ \hline
10 & 1933137 & 1688 & 4131 & 6977514 & 186602 & 2178 & 4249 & 8259166 \\ \hline
20 & 2032738 & 1697 & 4168 & 7080550 & 196894 & 2239 & 4269 & 9564242 \\ \hline \multicolumn{9}{|c|}{Snapdragon 845} \\ \hline Unattacked & 1442148 & 838 & 4048 & 3395663 & 399311 & 1090 & 4032 & 4399836 \\ \hline
1 & 1438346 & 850 & 4026 & 3426386 & 396349 & 1096 & 4004 & 4383840 \\ \hline
10 & 1438437 & 851 & 4033 & 3435771 & 392823 & 1128 & 3998 & 4510960 \\ \hline
20 & 1416057 & 855 & 4025 & 3445101 & 387300 & 1150 & 3979 & 4578618 \\ \hline \end{tabular}
\end{table}
Table 2. MobileNetV3 Software-based Data Collection
built-in method is employed to record the running time of each epoch and the overall running time.
## 5. Analysis of Results and Discussion
### MobileNetV3 Results
#### 5.1.1. Impact of \(\sigma\)
We first conduct an attack training against MobileNetV3. As mentioned in the section 3.2, we test different hyper-parameters and select the most potential result for the next step of verification. At the same time, it is also worthwhile to provide a certain preset basis for subsequent experiments on other network architectures. We first perform hyper-parameter sensitivity on MobileNetV3.
We firstly inspect the impact for different value choices of \(\sigma\), Fig. 3 shows the variation of energy ratio by training attacked models with different \(\sigma\) with fixed \(\mathcal{P}\) and \(\lambda\). There are two sets of \(\mathcal{P}\) and \(\lambda\) chosen which represent simulated extreme attack scenarios. Based on our assumption, the attacker is supposed to manipulate the process as less as possible, thus we choose \(\mathcal{P}=0.05\) which means only 5% of the dataset will be attacked during the training process. We also set \(\lambda\) to a relatively low level that \(\lambda=1\). In the second set of data, \(\mathcal{P}\) and \(\lambda\) are approaching the limit envisaged by the threat model. That almost one-third of the dataset will be compromised, and \(\lambda\) is also set to a value stable enough to observe the difference. However, it appears that the hyper-parameter \(\mathcal{P}\)'s impact is limited after a certain percentage from the figure.
Our observation shows that too large or small values of \(\sigma\) are both likely to make the result worse in terms of accuracy and estimated energy ratio. The higher the value of \(\sigma\) is, the lower the approximation of \(\hat{\ell}_{0}\) will be. It makes the attack result less obvious. On the contrary, with the extreme well-fit approximation to \(\hat{\ell}_{0}\), the \(\hat{\ell}_{0}\) is not sufficiently smooth to facilitate attack formulation. According to the results obtained by our test, combining the comprehensive consideration of attack effect and accuracy factors, the learning rate for the model around 1e-06 is more suitable for MobileNetV3. Thus, the following experiments take \(\sigma=1e-06\) as the default with \(\lambda\) of 20. Comparing its stable phase data with the set with \(\lambda\) value of 1, the delay is greater when the power consumption is higher. The first 10 epochs' readings further magnify and affirm this conclusion. On the contrary, it is difficult to deliver an obvious and positive conclusion for Snapdragon 845's data in this table. Referring to the observation results in Table. 1 from previous paragraphs, we may not be able to observe obvious differences due to the characteristics of the Snapdragon 845.
### MobileNetV2 Results
Following the same experiment process of MObileNetV3, to investigate the impact of \(\sigma\) on training, we first start with fixed \(\mathcal{P}\)=0.25 which is optimal for the last model. As shown in Fig. 6, we can see as _lambda_ gets upwards, the energy ratios raise in an inclined trend. It reaches stable with an energy ratio around 98% in the _lambda_ over 25%. The validation accuracy declines in a consistent way when _lambda_ goes larger. To be noticed, with small _lambda_ before 10%, validation accuracy surprisingly outperforms the unattacked model. With small _lambda_, one reasonable guess is that it introduced noise to prevent overfitting.
Based on 2 plots in Fig. 6, we use _lambda_ 10 as our optimal value. Then we further implement the experiment to choose \(\mathcal{P}\). According to Fig. 7, the optimal learning rate is around 1e-6 which is the highest in validation accuracy with an enery ratio of around 94%.
As experiments show consistency in terms of mobile platform test results along with the estimated result on the PC end, empirical results on the device present a similar curve as in the server. It verifies our concern in the mobile platform with no extra hardware accelerators. We further conduct an experiment to address the feasibility of this attack to different processors to show the most potential attack case. Attacks on these two processors do rise the energy consumption in models. For 8Gen1 and 845 there is 20% and 14% extra consumption rising compared with the unattacked model. From data collected from the PC end, there is little difference to draw the conclusion of relations with performance between attacked and unattacked models. From the reading of 10 runs of work, the peak data shows that there is a longer ruining time at high power consumption. The test for the Snapdragon 845, however, does not show a significant gap. Neither the Battery Historian results nor the software-based collection readings, we can not deliver a firm conclusion on the attack effect. It also coincides with the experimental results of MobileNetV3. As we discussed before, Snapdragon 845 has inherent deficiencies in deep learning hardware acceleration. Besides, MobileNetV2 itself is more power-hungry than MobileNetV3, which makes it difficult to even observe the difference in discharge rate.
### Experiment Discussion
To summarize, the experiment from these two processors and models, we find that for Snapdragon 8Gen1, the energy ratio incline goes as expected for optimal attack configuration both in MobileNetV2 and MobileNetV3, the test on the PC end and the on-device end is consistent to show the realistic concerns of the potential for sponge poisoning in the real world. For older processor 845 which has less modern AI accelerators in contrast does not show enough sensitivity towards sponge poisoning. Without compact hardware accelerator, it can be full computation power involved for SnapDragon 845.
## 6. Conclusion and Future Work
In this paper, we conduct an extensive exploration based on Sponge Poisoning Attack (P
investigation in this field. This work merely considers the sponge poisoning with a specific method, other measurement techniques, networks method and metrics can be explored as future work.
## Acknowledgments
This work was supported in part by the National Key R&D Program of China (No. 2021YFB2900100), and the National Natural Science Foundation of China (No. 62002294, U22B2022).
|
2306.05017 | Non-Intrusive Load Monitoring (NILM) using Deep Neural Networks: A
Review | Demand-side management now encompasses more residential loads. To efficiently
apply demand response strategies, it's essential to periodically observe the
contribution of various domestic appliances to total energy consumption.
Non-intrusive load monitoring (NILM), also known as load disaggregation, is a
method for decomposing the total energy consumption profile into individual
appliance load profiles within the household. It has multiple applications in
demand-side management, energy consumption monitoring, and analysis. Various
methods, including machine learning and deep learning, have been used to
implement and improve NILM algorithms. This paper reviews some recent NILM
methods based on deep learning and introduces the most accurate methods for
residential loads. It summarizes public databases for NILM evaluation and
compares methods using standard performance metrics. | Mohammad Irani Azad, Roozbeh Rajabi, Abouzar Estebsari | 2023-06-08T08:11:21Z | http://arxiv.org/abs/2306.05017v1 | # Non-Intrusive Load Monitoring (NILM) using Deep Neural Networks: A Review
###### Abstract
Demand-side management now encompasses more residential loads. To efficiently apply demand response strategies, it's essential to periodically observe the contribution of various domestic appliances to total energy consumption. Non-intrusive load monitoring (NILM), also known as load disaggregation, is a method for decomposing the total energy consumption profile into individual appliance load profiles within the household. It has multiple applications in demand-side management, energy consumption monitoring, and analysis. Various methods, including machine learning and deep learning, have been used to implement and improve NILM algorithms. This paper reviews some recent NILM methods based on deep learning and introduces the most accurate methods for residential loads. It summarizes public databases for NILM evaluation and compares methods using standard performance metrics.
Smart Grids, NILM, Deep Learning, Energy Management.
## I Introduction
The non-intrusive load monitoring (NILM) method has gained popularity in recent years as a way to monitor appliance and electrical utility energy usage in buildings and events (on/off) using a single energy meter. If consumers had data on appliance-level energy usage, they could better understand their energy consumption behavior and take action to reduce it. The aim of this study is to present an overview of the latest algorithms currently being investigated by researchers to create a precise non-intrusive load monitoring (NILM) method for effective energy management. The article discusses the potential applications of NILM across different fields, along with future research objectives. The development of sustainable and smart cities has been made possible by advancements in artificial intelligence (AI), smart meters, the internet of things (IoT), and smart grids, as cited in [1] and [2]. Effective energy management is a crucial component of sustainable city development, which aims to utilize resources responsibly, protect the environment, and enhance society's well-being. The objective of energy management is to promote energy system self-reliance and sustainability [1].
Energy management involves monitoring and controlling electrical utilities to optimize energy use and reduce consumption. However, with the increase in energy needs, energy conservation has become a challenge in recent years [3]. Greater energy use can lead to an energy crisis, climate change, and a negative impact on the economy [4]. It is estimated that the rise in carbon emissions will increase global temperatures by 2.5 to 10 \({}^{\circ}\)C this century, causing more frequent floods, droughts, a rise in sea level, and the spread of infectious illnesses [5]. Therefore, it is essential to reduce carbon emissions across all sectors, including construction, industry, and transportation, to mitigate climate change. Researchers are working on developing technology solutions for energy conservation [3]. Buildings are one of the major contributors to energy consumption [6], with energy consumption in this sector steadily increasing over time. In order to mitigate carbon emissions, optimizing energy consumption in residential and commercial buildings is crucial. This can be achieved through the construction or design of energy-efficient structures, as well as improving energy usage in existing buildings.
The paper is organized as follows. Section II introduces the mathematical definition of the NILM problem. Section III discusses deep learning-based NILM methods. Section IV provides a summary of the public NILM datasets. Section V presents a comparison study of NILM methods, and finally, Section VI concludes the paper.
## II NILM Problem Definition
### _Mathematical Problem Definition_
The issue at hand can be described as follows: at a given time \(t\), the total active power consumed by a system is represented by \(y(t)\), while \(y_{i}(t)\) represents the active power consumed by the \(i\)th appliance at the same time. The overall load is the sum of the energy consumed by individual appliances and an unmeasured residual load, expressed as:
\[y(t)=\sum_{i=1}^{N}y_{i}(t)+e(t), \tag{1}\]
where \(N\) denotes the number of appliances considered, and \(e(t)\) represents the undetermined residual load. The aim is to estimate \(F(y(t))\) by determining the values of \(y_{i}(t)\), given only the value of \(y(t)\), as:
\[y_{1}(t),y_{2}(t),...,y_{i}(t),...,y_{N}(t)=F(y(t)), \tag{2}\]
where \(F\) is an operator that produces \(N\) distinct values when applied to the total active power. These numbers represent the most accurate estimate of the power consumed by each appliance. It should be noted that \(y_{i}(t)\) typically does not reflect the entire set of home appliances but rather a subset of them. As a result, the unknown term \(e(t)\) takes into account the loads caused by unmonitored appliances. If simultaneous measurements of the aggregate consumption and load of each appliance are available, approximating the \(F\) operator can be considered a supervised learning problem. When mainly concerned with activation times and cumulative consumption, as is the case in real situations, the estimated individual appliance consumption (\(\hat{y}_{i}(t)\)) can be obtained using functions that are constant over the device's activation period:
\[\hat{y}_{i}(t)=p_{i}\hat{a}_{i}(t), \tag{3}\]
where \(p_{i}\) represents the average consumption of appliance \(i\), and \(\hat{a}_{i}(t)\) represents an estimate of the activation state of the particular appliance at time \(t\). Its value is one if the device is in use and uses energy, and zero otherwise. Therefore, starting with the aggregate load, a technique is provided to derive the most accurate and feasible assessment of the activation state of the appliances:
\[\hat{a}_{1}(t),\hat{a}_{2}(t),...,\hat{a}_{i}(t),...,\hat{a}_{N}(t)=F_{a}(y(t)), \tag{4}\]
After learning the average nominal consumption of the considered equipment, one can use Equation 3 to estimate consumption.
### _Appliance types_
Based on their operational characteristics, appliances can be classified into four types as discussed in [7]. Type I appliances have two modes of operation - on and off. These include appliances such as kettles, toasters, and light bulbs, which consume energy only when turned on. Type I appliances are predominantly resistive with few linear reactive components. Type II appliances are characterized as multi-state or finite state machines with a limited number of operational states that may be run repeatedly. Changes in these appliances' states can be observed by monitoring the power consumption's falling/rising edges over time. Stove burners, refrigerators, and washing machines are some examples of Type II appliances [7, 8]. Figure 1 demonstrates the distinct appliance operation conditions.
Category III appliances, also known as Continuously Variable Devices (CVDs), exhibit a non-repetitive power usage pattern, which poses a challenge for energy consumption disaggregation. Examples of Type III appliances include power drills and dimmer lights [8]. Type IV appliances are those that run continuously for extended periods of time, typically lasting several days or weeks. Examples of Type IV equipment include wireless telephone devices and cable TV receivers [8]. Therefore, the Non-Intrusive Load Monitoring (NILM) system is required to have the ability to differentiate between various types of appliance events, which may happen concurrently or independently and at varying time intervals.
## III Deep Learning Based NILM methods
NILM techniques can be broadly categorized into two groups: supervised and unsupervised methods [9]. In supervised NILM, individual appliance power usage is used to train the models. On the other hand, unsupervised methods can only utilize aggregate power usage data. Examples of unsupervised NILM techniques include Hidden Markov models (HMM) [10, 11], factorial HMM (FHMM) [12, 13], and techniques based on event detection and clustering [14, 15]. These techniques have been thoroughly examined in previous studies [9, 16]. With the advent of deep neural networks (DNNs), many neural network-based supervised NILM techniques have been developed [17, 18]. Convolutional neural networks (CNN) have also recently made significant advances [19, 20]. Graph signal processing [21], HMM [12, 13, 15, 22, 23], and DNNs [24, 25] are commonly used in suggested NILM approaches. As the cost of employing appliance data for training has grown dramatically, researchers have focused on developing unsupervised approaches and incorporating appliance models. Despite the significant progress made in NILM research in recent years, challenges remain in terms of application, identification accuracy, training time, and online deployment techniques in smart metering frameworks.
### _Event-Based Non-Intrusive Detection_
The event-based NILM method is based on the concept of detecting and categorizing events within a combined electrical signal. Figure 2 shows the block diagram of the this approach. A robust event detector should be developed to cope with noisy fluctuations and identify events with decay and growth patterns, which is a bottleneck and inherent difficulty in existing event detectors [26]. One approach includes the steps of event detection, extraction, clustering, and matching in the event-based block [27]. It should be noted that the accuracy of previous event-based frameworks is dependent on the power features that are introduced. Since some appliances may have identical active power curves but radically distinct reactive power trends, increasing the number of features can enhance the accuracy of the appliance model, particularly for non-linear
Fig. 1: A pictorial representation illustrates the different types of appliances categorized based on their operating states.
loads. One of the advantages of incorporating reactive power is that it enables discrimination between different types of devices.
### _NILM Disaggregation by CNN_
The proposed method [28] employs a convolutional neural network (CNN) that takes the time interval of a home's energy consumption as input and predicts the activation status of each device at every time step. The network architecture, referred to as Temporal Pooling NILM (TP-NILM), is an updated version of Zhao et al.'s PSPNet (Pyramid Scene Parsing Network) used for semantic image segmentation [29]. The TP-NILM follows the conventional approach to image segmentation, with an encoder comprising pooling and convolutional layers that enhance the feature space of the signal but decrease its temporal resolution, and a decoder module that uses these features to approximate the activation state of the devices at the original resolution. To establish a temporal context that covers extended periods without compromising the signal's resolution, the TP-NILM incorporates a Temporal Pooling module that accumulates features at various resolutions, enabling accurate reconstruction of the activation state.
Figure 3 illustrates the architecture of the network used in this study. The encoder uses a rectified linear unit activation function, batch-independent normalization downstream of the activations, and a regularization dropout layer, with three convolutional filters interleaved by max-pooling layers. The encoder reduces the signal's temporal resolution by a factor of eight and raises the number of output characteristics from a single aggregate power consumption value to 256. The TP block provides context information to the decoding block, allowing it to create extra features for decoding by aggregating encoder output with various resolutions. The encoder output is passed through four average pooling modules with various filter sizes, which degrade the temporal resolution while maintaining the number of features, before being convolutional with a unit filter size. This reduces the number of characteristics to one-quarter of those used in the input. The convolutional results are used as the input for a rectified linear unit activation function, which is then batch normalized. Lastly, linear up-sampling yields a temporal resolution at the TP block's output that is equal to the encoder's output. A dropout is also added to the output, allowing the network to be controlled. The context features generated by this block are connected to the encoder's detail features, doubling the total number of features in the decoder's input. To raise the signal's temporal resolution and lower the number of features, the decoder contains a transposed convolutional layer with a stride and kernel size of 8. The ReLU is still used as the activation function, followed by an extra convolutional layer with an unified kernel size that keeps the temporal resolution and increases the number of output channels to match the number of devices being analyzed. In the output, a sigmoid function is used. This is because in the semantic segmentation of photos, each pixel is connected to a single class, however in the current application, many appliances might be in use at the same time. While working in this manner, the network decomposes all appliances at the same time. This should enable an encoder to use more broad convolutive filters that aren't specialized for a single kind of appliance, boosting the neural network's capacity to generalize. Gradient descent optimization may be used to find the net's weights. The loss function is a binary crossentropy applied to each output channel that assesses the disparity between the activations predicted by the net \(\hat{a}_{i}(t)\) and the actual ones \(a_{i}(t)\) for each appliance under consideration and for each instant of the period under consideration.
## IV NILM Public Datasets
To develop NILM (non-intrusive load monitoring) algorithms and assess their performance, the research community provides various NILM datasets in the public domain [30]. Since each dataset monitors different appliances
Fig. 3: Outline of network structure for NILM by CNN.
Fig. 2: Block diagram scheme of event-based NILM.
in diverse environments and buildings over a varied time period, each dataset has its own specific criteria [31, 32]. However, it has been observed that many public datasets have structural variations that require pre-processing before usage. To address this issue, the dsCleaner Python module was developed to standardize, clean, and convert time series data into a consistent file format, and also includes a resampling method for datasets. Typically, NILM datasets consist of aggregated energy data from a single meter and the actual energy consumption of each appliance, which is measured by plug-level meters and serves as the ground truth for evaluating NILM algorithms. Table I lists the most popular publicly accessible NILM datasets for research purposes [30].
In 2011, the Reference Energy Disaggregation Dataset (REDD) [32] became available as the first openly accessible dataset designed specifically to aid NILM research. Following this, the building-Level fully-labeled dataset for Electricity Disaggregation (BLUED) [33] was released in 2012, which contained data from a single household.
The Almanac of Minutely Power dataset (AMPds) [34], on the other hand, was made public in 2013 and comprised both aggregate and sub-metered power data from a single household. The Almanac of Minutely Power dataset Version 2 (AMPds2) [35] is another dataset that captures all three primary types of consumption, including electricity, water, and natural gas, over an extended period of 2 years. Furthermore, it provides 11 measurement characteristics for electricity. The data in AMPds2 has been pre-cleaned to ensure consistent and comparable accuracy results among researchers and machine learning algorithms.
The REFIT Electrical Load Measurements [36] dataset is another one that includes cleaned electrical consumption data in Watts for 20 households at both aggregate and appliance levels, timestamped and sampled at 8-second intervals. It is designed to support research into energy conservation and advanced energy services, ranging from non-intrusive appliance load monitoring, demand response measures, tailored energy and retrofit advice, appliance usage analysis, consumption and time-use statistics, and smart home/building automation. Finally, the UK Domestic Appliance-Level Electricity data set (UK-DALE) [37] was released, containing data from four households.
The available NILM datasets have varying sample rates ranging from 1 Hz to 100 kHz and cover individual appliances as well as residential complexes. While data collected from individual appliances can be valuable for modeling and training the NILM system, its performance may not be optimal when tested on the entire residential building. Conversely, relying solely on whole-household datasets may not be appropriate for training the algorithms, especially when individual appliance data is unavailable.
Furthermore, certain databases provide primary current and voltage signals, whereas others provide calculated electrical parameters such as active power, reactive power, apparent power, and power factor. However, in order to create an effective NILM system, it is crucial to obtain unprocessed electrical signals in order to extract fundamental and harmonic characteristics.
## V Experimental Results
### _Evaluation Metrics_
To evaluate the performance of algorithms in recognizing appliance switching ON or OFF, the classification metrics presented in Eqs. 5-8 were used. The metrics are calculated using True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN). TP represented the number of times a device was correctly recognized as ON, whereas TN represented the number of correctly identified OFF occurrences. FP highlighted instances when ON states were recorded despite the appliance not consuming power. On the other hand, FN displayed the number of OFF occurrences that were incorrectly recognized.
\[\text{Accuracy}=\frac{\text{TP}+\text{TN}}{\text{TP}+\text{TN}+\text{FP}+ \text{FN}} \tag{5}\]
\[\text{Presicion}=\frac{\text{TP}}{\text{TP}+\text{FP}} \tag{6}\]
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{7}\]
\[F_{1}=2*\frac{\text{Presicion}*\text{Recall}}{\text{Presicion}+\text{Recall}} \tag{8}\]
The recall metric in Eq. 7 measures the ratio of correctly identified positive instances (TP) to the total number of positive instances in the dataset. On the other hand, the precision metric in Eq. 6 represents the ratio of correctly identified positive instances (TP) to the total number of instances identified as positive by the algorithm. The \(F_{1}\) score is a weighted mean of precision and recall, which is used to determine the accuracy of the algorithm in identifying appliance states. Higher \(F_{1}\) scores indicate better algorithm performance in recognizing appliance state transitions.
The mean absolute error (MAE) and proportion of energy correctly allocated (PECA) metrics in Eqs. 9 and 10, respectively, are non-event-based metrics used to evaluate the accuracy of load disaggregation systems in calculating and assigning electricity usage. MAE measures the average absolute difference between the estimated and actual energy usage, while PECA evaluates the percentage of energy correctly allocated to individual appliances.
\[\text{MAE}=1/T*\sum_{t=1}^{T}|\hat{y}_{t}^{i}-y_{t}^{i}| \tag{9}\]
\[\text{FECA}=1-\frac{\sum_{t=1}^{T}\sum_{i=1}^{N}|\hat{y}_{t}^{i}-y_{t}^{i}|}{ 2\sum_{t=1}^{T}\bar{y}_{t}} \tag{10}\]
In the preceding equations, \(\hat{y}_{t}^{i}\) and \(y_{t}^{i}\) are the estimated and ground-truth power of the \(i^{th}\) device at time step t, respectively. Furthermore, \(\bar{y}_{t}\) is the total power at time t [24].
### _Performance Evaluation and Comparison Study_
In this part, the disaggregation findings for the NILM approaches using the REDD, UK-DALE, and REFIT datasets are shown. The performance indicators obtained by executing the tests on these datasets shows that \(F_{1}\) produced the best results for refrigerators, air conditioners, freezers, televisions, and washing machines across the three datasets, with values greater than 0.70. Toasters and electronics, on the other hand, have lower \(F_{1}\) scores of roughly 0.25 owing to misclassification caused by the non-uniform pattern of these items.
The accuracy metrics of the findings were compared for published methods: on-line NILM [27], NILM-TK [14], an FHMM implementation; Neural-NILM [7], a DNN adaption for energy estimation. The Neural-NILM used three DNN architectures: i) long short-term memory, ii) de-noising auto-encoders, and iii) rectangles. Rectangle networks, in particular, regress the start-time, end-time, and average power of appliance activation.
In experiments using UK-DALE dataset, a comparison of on-line NILM, NILM-TK and Neural-NILM methods for five appliances (fridge, washing machine, dishwasher, microwave, and kettle) is done. The microwave gives the lowest marks for all three methods. MAE and an \(F_{1}\) score of roughly 195 Watts and 0.01, respectively, are reported by NILM-TK. The best MAE of 6 Watts and an \(F_{1}\) score of 0.21 is shown by the neural-NILM. With an \(F_{1}\) score of about 0.35, the on-line NILM method outperforms the other two. The MAE and \(F_{1}\) scores reported by NILM-TK are roughly 67 watts and 0.55, respectively. The Neural-NILM has an MAE of 18 Watts and an F1 score of 0.82. In terms of energy estimate, the Neural-NILM outperformed the suggested technique, particularly for complicated equipment like dishwashers and washing machines. Nonetheless, the time and computational resources required to train the neural network and generate the models need a large amount of appliance-level data. The on-line NILM technique, on the other hand, may generate appliance models using aggregate data without the necessity for appliance-level sub-metered data.
## VI Conclusion
The three-phase distribution network often feeds the final residential customers through single phase cables. It is important to make the loads balanced. Demand side management and different optimisation techniques would help on this. However, understanding the contribution of different appliances to energy consumption is beneficial. NILM is demonstrated to be a good approach to this end. The accuracy of NILM depends on the method applied. This paper reviewed some deep learning-based methods which outperform other existing NILM algorithms. The paper compared the results of applying these advanced methods to provide a basis for future implementation. These datasets have public access and are widely used in NILM literature. Several performance criteria are formulated to analyze the performance of the methods.
|
2310.13193 | Heterogeneous Graph Neural Networks for End-to-End Traffic Assignment
and Traffic Flow Learning | The traffic assignment problem is one of the significant components of
traffic flow analysis for which various solution approaches have been proposed.
However, deploying these approaches for large-scale networks poses significant
challenges. In this paper, we leverage the power of heterogeneous graph neural
networks to propose a novel data-driven approach for end-to-end traffic
assignment and traffic flow learning. Our model integrates an adaptive graph
attention mechanism with auxiliary "virtual" links connecting
origin-destination node pairs, This integration enables the model to capture
spatial traffic patterns across different links, By incorporating the
node-based flow conservation law into the overall loss function, the model
ensures the prediction results in compliance with flow conservation principles,
resulting in highly accurate predictions for both link flow and flow-capacity
ratios. We present numerical experiments on urban transportation networks and
show that the proposed heterogeneous graph neural network model outperforms
other conventional neural network models in terms of convergence rate and
prediction accuracy. Notably, by introducing two different training strategies,
the proposed heterogeneous graph neural network model can also be generalized
to different network topologies. This approach offers a promising solution for
complex traffic flow analysis and prediction, enhancing our understanding and
management of a wide range of transportation systems. | Tong Liu, Hadi Meidani | 2023-10-19T23:04:09Z | http://arxiv.org/abs/2310.13193v2 | # Heterogeneous Graph Neural Networks for Data-driven Traffic Assignment
###### Abstract
The traffic assignment problem is one of the significant components of traffic flow analysis for which various solution approaches have been proposed. However, deploying these approaches for large-scale networks poses significant challenges. In this paper, we leverage the power of heterogeneous graph neural networks to propose a novel data-driven approach for traffic assignment and traffic flow learning. The proposed model is capable of capturing spatial traffic patterns across different links, yielding highly accurate results. We present numerical experiments on urban transportation networks and show that the proposed heterogeneous graph neural network model outperforms other conventional neural network models in terms of convergence rate, training loss, and prediction accuracy. Notably, the proposed heterogeneous graph neural network model can also be generalized to different network topologies. This approach offers a promising solution for complex traffic flow analysis and prediction, enhancing our understanding and management of a wide range of transportation systems.
keywords: traffic assignment, graph neural network, traffic flow prediction, flow conservation +
Footnote †: journal: Transportation Research Part C: Emerging Technologies
## 1 Introduction
The traffic assignment problem, as a significant component of transportation network performance analysis, helps understand spatial and temporal traffic flow patterns for effective transportation network management and provides insights into bottlenecks, and traffic congestion (Nie et al., 2004). Congestion is a major concern in urban areas, leading to increased travel times, fuel consumption, and environmental pollution. By identifying the bottlenecks in transportation networks, city planners can make a strategic plan to increase road capacities to mitigate traffic congestion.
To this end, the objective of the traffic assignment problem is to determine the traffic flow distribution and identify traffic bottlenecks on a given road network. Numerous mathematical models have been proposed to tackle traffic assignment problems. The user equilibrium (UE) principle and system optimum (SO) principles are two fundamental but effective solutions to traffic assignment problems. The UE principle, also known as Wardrop's first principle, states that drivers between each origin-destination (OD) pair cannot unilaterally reduce travel costs by unilaterally shifting to another route (Kuang et al., 2021). The system optimum assignment, which is based on Wardrop's second principle, emphasizes driver cooperation to minimize the total system travel time (Seliverstov et al., 2017). These models have been used extensively in practice to estimate traffic flow patterns and optimize transportation infrastructure investments. However, these approaches are computationally expensive for a large-scale network. Substantial efforts have been made to find efficient algorithms to solve this problem (Nie et al., 2004; Di Lorenzo et al., 2015). Furthermore, researchers have proposed various extensions to the UE and SO models, such as the stochastic user equilibrium (Damberg et al., 1996), multi-modal traffic assignment (Pi et al., 2019), and dynamic traffic assignment (Ben-Akiva et al., 2012). These models incorporate additional factors, such as travel time variability, driver behaviors, and network capacity constraints, to provide more realistic traffic assignment solutions. However, there is still a pressing need for more effective and accurate methods for traffic assignment problems, particularly for traffic planning and optimization.
To perform transportation performance analysis, OD demand needs first to be obtained, which is a significant component in traffic assignment problems. OD demand estimation has been widely studied in the transportation engineering literature. The statistical model is one of the common approaches for OD estimation. It leverages multiple data sources to estimate vehicle flow between different locations in a network (Hazelton, 2008; Jin et al., 2014). Furthermore, the increasing availability of crowdsourced data, including GPS data and social media, enables us to extract OD demand and traffic flow data at a large scale and over extended periods (Toole et al., 2015; Zhang et al., 2020). Besides, neural network approaches (Tang et al., 2021; Zhang et al., 2021) have also been applied to estimate OD estimation, which allows for the extraction of complex patterns from high-dimensional and noisy transportation data.
In recent years, data-driven approaches have leveraged the availability of large-scale transportation data and computational resources in various transportation problems. For instance, the recurrent neural network (RNN), including the long short-term memory (LSTM) and gated recurrent unit (GRU) networks, have been applied to different prediction tasks in transportation (Zhaowei et al., 2020; Fang et al., 2022). However, standalone RNNs lack the ability to learn spatial correlation. To overcome this weakness and capture the spatio-temporal relationship of traffic flows at different locations, Ye et al. (2019) combines convolutional neural networks (CNN) with LSTM to predict multiple transportation demands using real-world taxi and sharing bike demand data. Recently, the graph neural network (GNN) has emerged as a powerful tool in transportation performance analysis because of its capability to effectively model and analyze data represented in the form of a graph. Compared with RNNs and CNNs, a key advantage of GNNs is their ability to capture spatial and relational information inherent in transportation networks.
Graph neural networks have been shown to be effective in network modeling and management of transportation systems (Rahman and Hasan, 2022; Liu and Meidani, 2023a). However, these models encountered a few limitations. Firstly, the proposed GNN models can only be trained on a fixed topology, and need to be re-trained whenever the topology of the road network changes. Additionally, these studies didn't adequately consider the dynamic nature of traffic flow, e.g., when link capacities alter due to traffic accidents or damages to roadways. These drawbacks limit the adaptability and applicability of these models in real-world scenarios.
To address this challenge, in this paper, we propose a novel GNN-based approach for static traffic assignment. Specifically, we focus on predicting the flow-capacity ratio of different scenarios in the context of traffic assignment. In particular, to address the long-range effects caused by OD pairs that are multiple-hops apart, we create a heterogeneous GNN that consists of additional "virtual" links. The major contributions of this work are as follows: (1) a heterogeneous GNN model is proposed with "virtual" OD-links and the "real" roadway links, which incorporates the attention-based mechanism and message-passing mechanism; (2) the proposed model also integrates a physics-based loss based on the flow conservation law into the total loss function to accelerate the learning process; (3) the proposed model is generalizable to different road network topologies, link characteristics, and OD demands.
The remainder of this article is structured as follows. General backgrounds on the traffic assignment problem, the neural network and graph neural network models are presented in Section 2. Section 3 includes the explanation of the proposed heterogeneous graph neural network for traffic flow learning. Furthermore, the experiments with urban road networks and generalized synthetic networks are presented to demonstrate the accuracy and generalization capability of the proposed framework in Section 4. Finally, the conclusion and discussion of the proposed framework are presented in Section 5.
## 2 Technical Background
### Traffic Assignment Problem
The traffic assignment problem involves assigning traffic volumes or flows to each edge in the network. Given a transportation network represented as a graph \(\mathcal{G}=(\mathcal{V},\mathcal{E})\), where nodes \(\mathcal{V}\) represent intersections of roads and edges \(\mathcal{E}\) represent roads or links connecting these locations, The general form of traffic assignment problem can be considered as an optimization task:
\[\min_{f}:\quad\sum_{e\in\mathcal{E}}Z_{e}(f_{e}), \tag{1}\]
where \(f_{e}\) and \(Z_{e}(f_{e})\) are the total flow and the link cost function on link \(e\), respectively. The link cost function can be expressed in terms of travel time, travel distance, or other relevant factors. Therefore, the objective function is to minimize the summation of link cost over the graph. The traffic assignment problem can have different formulations depending on the specific objectives and constraints considered in the optimization process. For instance, under user equilibrium formulation, the traffic assignment problem could be solved by optimizing Beckmann's formulation (Beckmann et al., 1956):
\[\begin{split}\min:& z(x)=\sum_{e\in\mathcal{E}} \int_{0}^{x_{e}}t_{e}(\omega)\mathrm{d}\omega\\ \text{s.t.}&\sum_{k}f_{k}^{rs}=q_{rs},\ \forall r,s\in \mathcal{V},\\ & f_{k}^{rs}\geq 0,\ \forall k,r,s\in\mathcal{V},\\ & x_{e}=\sum_{rs}\sum_{k}f_{k}^{rs}\zeta_{e,k}^{rs},\forall e\in \mathcal{E},\end{split} \tag{2}\]
where \(t_{e}(f_{e})\) is the link travel time function, \(q_{rs}\) is the total demand from source \(r\) to destination \(s\), \(f_{k}^{rs}\) represents the flow on \(k^{\text{th}}\) path from \(r\) to s. \(\zeta_{e,k}^{rs}\) is the binary value, which equals to 1 when link \(e\) is on \(k^{\text{th}}\) connecting \(r\) and \(s\).
### Neural Network
Without loss of generality, we will start by considering a neural network with only one layer. Given a \(p\)-dimensional input vector \(h^{k}\in\mathbb{R}^{p}\), \(q\)-dimensional the output \(h^{k+1}\in\mathbb{R}^{q}\) of single layer neural network, The single-layer neural network with index \(k\) can be expressed as:
\[\mathbf{h}^{k+1}=\sigma(\mathbf{h}^{k}\mathbf{W}_{k}+\mathbf{b}_{k}), \tag{3}\]
where \(\mathbf{W}_{k}\in\mathbb{R}^{p\times q}\) and \(\mathbf{b}_{k}\in\mathbb{R}^{1\times q}\) represent the weight and bias term, respectively. The non-linear activation function \(\sigma(\cdot)\) is utilized in the neural network. Theoretically, a single-layer neural network with an infinite number of neurons can approximate any continuous function to arbitrary accuracy, given a sufficiently large dataset (Hornik et al., 1989). However, due to limitations in network width, dataset size, and the challenge of tuning parameters, a single-layer network is not optimal for achieving top performance, which leads to overfitting and poor generalization performance. To alleviate the limitation, multiple neural network layers are stacked together to enhance its expressibility and capture complex hierarchical features.
### Graph Neural Network
Neural networks have shown remarkable performance in various applications. In most neural network applications, input data structures are normally fixed, which is also called Euclidean data. However, non-Euclidean data structure such as graph-structured data is pervasive in different applications. The complexity and variability of the graph structure data make it difficult to model with conventional neural network architectures. To address this challenge, GNNs are specifically designed to handle graph-structured data. It operates on the node features and edge features and learns to extract embedding from nodes and edges, aiming to capture the underlying graph structure.
There are different types of graph neural network formulation. One of the popular approaches is the spectral approach (Wang and Zhang, 2022). Spectral graph convolution is a type of convolution operation on graph signals that uses the graph Fourier transform. It operates in the frequency domain and utilizes the eigenvalues and eigenvectors of the graph Laplacian to filter the node features. Given a graph \(\mathcal{G}=(\mathcal{V},\mathcal{E})\) with adjacency matrix \(\mathbf{A}\) and diagonal degree matrix \(\mathbf{D}=\text{diag}(\mathbf{A}\mathbf{\bar{1}})\), the Laplacian matrix and normalized Laplacian matrix of the graph is defined as \(\mathbf{L}=\mathbf{D}-\mathbf{A}\) and \(\mathbf{L}_{\text{norm}}=\mathbf{D}^{-\frac{1}{2}}\mathbf{L}\mathbf{D}^{-\frac{1}{2}}\), respectively. The spectral graph convolution is defined mathematically as:
\[g_{\theta}*\mathbf{x}=\mathbf{U}g_{\theta}(\mathbf{U}^{T}\mathbf{x}), \tag{4}\]
where \(g_{\theta}\) is a filter with learnable parameters \(\theta\), \(\mathbf{x}\in\mathbb{R}^{|\mathcal{V}|\times N_{F}}\) is the input features with \(|\mathcal{V}|\) nodes and \(N_{F}\) features per node, and \(\mathbf{U}\) is the eigenvectors of \(\mathbf{L}_{\text{norm}}\). The input signal is first transformed into the spectral
domain. The features are passed through the learnable filter and transformed back into the spatial domain. The graph spectral operator can be applied to graphs of varying sizes. As a different approach to modeling graph data, the graph attention network (GAT) learns the graph feature by computing attention scores for each node based on its features and the features of its neighbors (Velickovic et al., 2017). The graph attention network computes the new node representation \(\mathbf{x}_{i}^{\prime}\) for each node \(i\) as follows:
\[\mathbf{x}_{i}^{\prime}=\sigma\left(\sum_{j=1}^{N}\alpha_{ij}\mathbf{W}_{x}\mathbf{x}_{j} \right), \tag{5}\]
where \(\sigma\) is an activation function, \(\mathbf{W}_{x}\) is a learnable weight matrix, and \(\alpha_{ij}\) is the attention weight assigned to the node \(j\) related to its neighbour node \(i\). The attention weights are computed as follows:
\[\alpha_{ij}=\frac{\exp(\sigma(\mathbf{a}^{T}[\mathbf{W}_{x}\mathbf{x}_{i}\oplus\mathbf{W}_{x} \mathbf{x}_{j}]))}{\sum_{k\in\mathcal{N}(i)}\exp(\sigma(\mathbf{a}^{T}[\mathbf{W}_{x}\mathbf{ x}_{i}\oplus\mathbf{W}_{x}\mathbf{x}_{j}]))}, \tag{6}\]
where \(\mathbf{a}\) is a learnable weight vector, \(\mathcal{N}(i)\) is the set of neighboring nodes of node \(i\), \(\oplus\) denotes concatenation function. The graph attention mechanism can be stacked into multiple layers, with each layer learning increasingly complex representations of the graph. The attention mechanism allows the network to learn the different importance of different nodes within a neighborhood, which can improve model performance.
The aforementioned formulation is valid for homogeneous graphs, where all nodes and edges have the same semantic meaning. However, it is noted that real-world graphs are not always homogeneous. For instance, in the literature citation graph, nodes can represent various entities such as papers, authors, and journals, while edges may denote different semantic relationships. When the graph contains different types of nodes or edges, it is considered as a heterogeneous graph. Utilizing GNNs on heterogeneous graphs offers notable advantages over homogeneous counterparts, particularly in the ability to learn type-specific representations for each node and edge type (Wang et al., 2019; Fu et al., 2020). This allows for more accurate and targeted modeling of each entity and relationship, leading to improved performance on downstream tasks (Zhao et al., 2021). In the following sections, we will leverage the expressiveness of the heterogeneous graph neural network to estimate the traffic flow performance under different OD demand settings.
## 3 Traffic Flow Learning using Heterogeneous Graph Neural Networks
In this section, we elaborate on the proposed architecture of the heterogeneous graph neural network for traffic flow learning. The detail of the proposed model is shown in Fig. 1. It consists of the embedding preprocessing block, the heterogeneous graph attention block, and the prediction block. The details of each module are described as follows.
### Graph Construction & Feature Preprocessing
The heterogeneous graph \(\mathcal{G}=(\mathcal{V},\mathcal{E}_{r},\mathcal{E}_{v})\) for traffic flow learning consists of one type of node representing the intersections of road segments and two edge types: real links and virtual links. The real links represent the road segments in the road network, while the virtual links represent the auxiliary link between the origin and destination nodes. The auxiliary links can be considered as the edge augmentation technique to enhance the feature updating. The node features \(\mathbf{X}_{n}\in\mathbb{R}^{|\mathcal{V}|\times|\mathcal{V}|+2}\) are the origin-destination demand of each node and the node geocordinates. The real link features \(\mathbf{X}_{e,r}\in\mathbb{R}^{|\mathcal{E}_{r}|\times 2}\) include the free-flow travel time and the link capacity, while the virtual link features \(\mathbf{X}_{e,v}\in\mathbb{R}^{|\mathcal{E}_{v}|\times 1}\) are binary values indicating the existence of OD demand between origin and destination nodes.
Furthermore, the original node features are often sparse and non-normalized. To address this issue, we employ a preprocessing step to encode the raw features into a lower-dimensional representation that captures the essential characteristics of the data while preserving the semantic information. The generated node feature embedding size is \(\mathbf{X}_{n}^{0}\in\mathbb{R}^{|\mathcal{V}|\times N_{v}}\), where \(N_{v}\) is the embedding size. Similarly, the edge features are also normalized before being propagated in the message passing. The normalized edge feature of real edges and virtual edges are denoted as \(\mathbf{X}_{e,r}^{0}\in\mathbb{R}^{|\mathcal{E}_{r}|\times 2}\) and \(\mathbf{X}_{e,v}^{0}\in\mathbb{R}^{|\mathcal{E}_{r}|\times 1}\), respectively. Additionally, it should be noted that there is an overlap between the real links and virtual links in the heterogeneous graph because it is possible that a road and an OD demand both exist between the same node pair.
### Graph Spatial Features Extraction
As discussed in Section 2.3, effectively aggregating information from nodes and edges of different types is a major challenge for heterogeneous graphs. In order to address this challenge, we propose a novel approach that leverages attention mechanisms on both real links and virtual links. This allows our model to selectively focus on the most relevant information from each edge type, improving the overall performance of the model.
As the first step of spatial feature extraction, to enhance the modeling capability and capture more fine-grained relationships, we employ a key-query-value mechanism on node features in addition to the weighted sum operation. For single-head attention, the node features are transformed into key, query, and value matrices through linear transformations:
\[\mathbf{K},\mathbf{Q},\mathbf{V}=[\mathbf{W}_{Q}\mathbf{X}_{n}^{0},\mathbf{W}_{K}\mathbf{X}_{n}^{0},\mathbf{W}_ {V}\mathbf{X}_{n}^{0}], \tag{7}\]
where \(\mathbf{W}_{K}\in\mathbb{R}^{N_{v}\times N_{h}}\), \(\mathbf{W}_{Q}\in\mathbb{R}^{N_{v}\times N_{h}}\), and \(\mathbf{W}_{V}\in\mathbb{R}^{N_{v}\times N_{h}}\) are learnable weight matrices. \(N_{h}\) is the output size of the linear transformation. The value matrix captures the learned representations and importance scores for each node. The query matrix represents the target node's characteristics, while the key matrix contains the features of neighboring nodes. The attention scores between the query vector and each key are calculated with the dot product, normalized by a softmax function to ensure that the weights sum up to one:
\[s_{ji}=\frac{\exp(\mathbf{q}_{j}^{T}\mathbf{k}_{i})}{\sum_{k\in\mathcal{N}(i)}\exp( \mathbf{q}_{k}^{T}\mathbf{k}_{i})}, \tag{8}\]
where \(\mathbf{k}_{i}\) and \(\mathbf{q}_{j}\) denote the \(i^{\text{th}}\) and \(j^{\text{th}}\) column of matrix \(\mathbf{K}\) and \(\mathbf{Q}\), respectively. The attention scores are then used in the weighted sum of the corresponding values, allowing the model to focus on more informative features. When the edge consists of multiple features, the output of the attention layer \(\mathbf{R}\in\mathbb{R}^{|\mathcal{V}|\times(N_{h}\times h)}\) is calculated using the attention score from Equation 8, value vector, and edge features from the neighbor of node \(i\):
\[\mathbf{R}=\bigoplus_{i=1}^{N}\left(\sum_{l=1}^{L}\sum_{k\in\mathcal{N}(i)}s_{ik} \mathbf{v}_{k}x_{ik,l}\right), \tag{9}\]
where \(\mathbf{v}_{k}\) denote the \(k^{\text{th}}\) column of value matrix \(\mathbf{V}\), \(x_{ik,l}\) represent the \(l^{\text{th}}\) edge feature on link \((i,k)\). This allows the model to focus on the most relevant output vectors for a given input vector. For multi-head
Figure 1: The illustration of the heterogeneous graph neural network for traffic flow learning. The original node feature is transformed using multi-layer perception. Then, the node feature and edge feature are first passed through the virtual links and then passed through the real links. The flow-capacity ratio of each link is calculated using the source node feature, destination node feature, and edge feature.
attention, the process of Equation 7, 8, and 9 is repeated \(h\) times to get multiple head attention output \([\mathbf{R}^{(0)},\mathbf{R}^{(1)},,\mathbf{R}^{(h-1)}]\), where \(h\) is the number of heads. The learned embedding of original node features is then passed into a linear transformation layer. We concatenate the output tensors \(\mathbf{R}^{(0)},\mathbf{R}^{(1)},\ldots,\mathbf{R}^{(h-1)}\) along the feature dimension and multiply a learnable weight matrix to produce the final output tensor \(\mathbf{O}\):
\[\mathbf{O}=\bigoplus_{i=0}^{h-1}\left(\mathbf{W}_{o}\mathbf{R}^{(i)}\right). \tag{10}\]
where \(\mathbf{W}_{o}\in\mathbb{R}^{(N_{h}\times h)\times N_{o}}\), \(N_{o}\) is the output dimension of the final node embedding of a single layer GNN.
As shown in Figure 1, multiple GNN layers are stacked to extract spatial features. The first GNN layer aggregates the node features along the virtual links. While the following GNN layers aggregate the node features along the real link. Compared with the homogeneous graph constructed with only real links, the link augmentation and message passing through virtual links can be considered as a dimension-reduction technique to reduce the number of hops required for distant nodes to gather messages. As a result, it requires fewer GNN layers for effective feature aggregation and following edge prediction in the heterogeneous graph.
### Graph Edge Prediction
To predict the transportation performance at the edge level, the node embedding of the source node and destination node, and the real edge feature are concatenated and passed into the multi-layer perceptron to have the flow prediction \(\tilde{f}_{e}\) of real link \(e\):
\[\tilde{f}_{e}=\texttt{MLP}([\mathbf{O}_{e,src}\oplus\mathbf{O}_{e,dst}\oplus\mathbf{X}_{ e,r}];\mathbf{W}_{e},\mathbf{b}_{e}), \tag{11}\]
where \(\mathbf{O}_{e,src}\) and \(\mathbf{O}_{e,dst}\) represent the source node embedding and destination node embedding, respectively. \(\mathbf{W}_{e}\) and \(\mathbf{b}_{e}\) is the learnable parameters associated with the multilayer perception. After generating the final prediction, selecting an appropriate loss function becomes crucial to ensure the model's effective convergence. The proposed model utilizes a twofold loss function. The first part is the supervised loss, which measures the discrepancy between prediction and ground truth:
\[L_{s}=\frac{1}{|\mathcal{E}_{r}|}\sum_{e\in\mathcal{E}_{r}}\|f_{e}-\tilde{f}_ {e}\|, \tag{12}\]
where the \(f_{e}\) and \(\tilde{f}_{e}\) represent the ground truth and prediction of flow on link \(e\in\mathcal{E}\). The second part of the loss function is from the node-based flow conservation law, where the total flow of traffic entering a node equals the total flow of traffic exiting that node. The node-based flow conservation law can be represented mathematically:
\[\sum_{k}f_{ki}-\sum_{j}f_{ij}=\Delta f_{i}=\begin{cases}&\sum_{v\in\mathcal{V }}O_{v,i}-\sum_{v\in\mathcal{V}}O_{i,v},\quad\text{ if }i\in\mathcal{V}_{OD},\\ &0\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad \text{ otherwise },\end{cases} \tag{13}\]
where \(f_{ki}\) denotes the flow on the link \((k,i)\), \(\Delta f_{i}\) represents the difference between flow receiving and sending at node \(i\), \(O_{v,i}\) represents the number of OD demand from \(v\) to \(i\). \(\mathcal{V}\) and \(\mathcal{V}_{OD}\) denote the entire node set and the origin-destination node set, respectively. The node-based flow conservation law can be considered as a normalization loss or auxiliary loss to ensure the predicted traffic flow at each node satisfies the flow conservation principle. One common way to incorporate conservation law into the loss function is to define a residual loss function:
\[L_{f}=\sum_{i}\ |\sum_{k\in\mathcal{N}_{i}(i)}\tilde{f}_{ki}-\sum_{j\in \mathcal{N}_{o}(i)}\tilde{f}_{ij}-\Delta f_{i}|, \tag{14}\]
where \(\mathcal{N}_{i}(i)\) and \(\mathcal{N}_{o}(i)\) represent the incoming edges and outcoming edges of node \(i\), respectively. The normalization loss \(L_{f}\) measures how the flow prediction satisfies the flow conservation law. Minimizing this loss function during training will encourage the model to learn traffic flow patterns that satisfy the conservation law. The total loss for the flow prediction \(L_{total}\) is the weighted summation of the supervised loss and the conservation loss:
\[L_{total}=w_{s}L_{s}+w_{f}L_{f}, \tag{15}\]
where the \(w_{s}\) and \(w_{f}\) represent the normalized weight for supervised loss and the conservation loss, respectively.
## 4 Numerical Experiments
To evaluate the accuracy, efficiency, and generalization capability of the proposed graph neural network, two numerical experiments are conducted. The first experiment is on urban transportation networks with synthetic traffic data. The second experiment is on multiple synthetic graphs with different topologies. Furthermore, we also synthesized variations in the OD demand and link capacity, as will be explained later.
### Experiments on Urban Transportation Networks
As case studies, three urban transportation networks are selected: Sioux Falls network, East Massachusetts Network (EMA), and Anaheim network. The information about the network topology, link capacity, and the default OD demand of these networks are obtained from (Bar-Gera et al., 2023). The details of the network topologies are shown in Table 1. To create demand variation, we scaled the demand by a scaling factor according to
\[\tilde{O}_{s,t}=\delta^{o}_{s,t}\ O_{s,t}, \tag{16}\]
where \(O_{s,t}\) is the default OD demand between source \(s\) and destination \(t\) and \(\delta^{o}_{s,t}\sim U(0.5,1.5)\) is the uniformly distributed random scaling factor for the OD pair (\(s\), \(t\)). Additionally, to account for variations in network properties, variable link capacities are created according to
\[\tilde{c}_{a}=\delta^{c}_{a}\ c_{a}, \tag{17}\]
where \(c_{a}\) is the original link capacity for link \(a\), and \(\delta^{c}_{a}\) is the scaling factor for link \(a\). Capacity variations are considered to be due to traffic accidents, road construction/damage, and adverse weather conditions, which reduce the link capacity. In this work, three levels of capacity reduction are considered: (L): light disruption with \(\delta^{c}_{a}\sim U(0.8,1.0)\); (M) moderate disruption with \(\delta^{c}_{a}\sim U(0.5,1.0)\); (H) high disruption with \(\delta^{c}_{a}\sim U(0.2,1.0)\). The size of the dataset for each network at each disruption scenario is 5000, which is split into the training set and the testing set with a ratio of 80% and 20%, respectively.
\begin{table}
\begin{tabular}{c c c c c} \hline \hline Network Name & \(|\mathcal{V}|\) & \(|\mathcal{E}|\) & Average Degree & OD Demand \\ \hline Sioux Falls & 24 & 76 & 3.17 & 188,960 \\ EMA & 74 & 258 & 3.49 & 132,106 \\ Anaheim & 416 & 914 & 3.05 & 226,279 \\ \hline \hline \end{tabular}
\end{table}
Table 1: The detail of urban transportation network. Three networks, including Sioux Falls, East Massachusetts, and Anaheim, are considered.
Figure 2: The illustrations of urban transportation networks, including Sioux Falls, EMA, and Anaheim. The link color represents the link capacity of each link.
The ground truth data used in training and testing steps is obtained from the user equilibrium (UE)-based traffic assignment. Specifically, the traffic flow and flow-capacity ratio (v/c ratio) of each link are the quantities of interest. The GNN model is implemented using PyTorch (Paszke et al., 2019), and DGL (Wang et al., 2019). The preprocessing layer consists of a three-layer fully connected neural network with an embedding size of 64. The number of GNN layers in the proposed model is 3. The first layer is applied on virtual links, and the following layers are applied on real links. The number of heads in the attention block is 8. For hyper-parameter selection, the hidden layer size is chosen as 64, which is common in neural network implementation (Liu and Meidani, 2023). Rectified Linear Unit (ReLU) activation (Agarap, 2018) is chosen to introduce nonlinearity. Mini-batch stochastic gradient descent was implemented in the training process. More specifically, the adaptive moment estimation (Adam) optimizer (Kingma and Ba, 2014) is adopted with a learning rate of 0.001. The batch size of training is 128. The weights for supervised loss and the conservation loss in equation 15 are chosen as 1.0 and 0.001, respectively, in order to keep both loss terms in the same order of magnitude. We evaluated the performance of our proposed heterogeneous GNN model (referred to by HetGAT) and compared it with three benchmark models: a fully connected neural network (FCNN), a homogeneous graph attention network (GAT), and a homogeneous graph convolution network (GCN). The FCNN consisted of five fully connected layers with an embedding size of 64. The GAT and GCN both have three layers of graph message passing layer, followed by three layers of FCNN with an embedding size of 64. The metrics to evaluate performance include the mean absolute error (MAE) and the normalized conversation loss \(L_{f}\) given by
\[\text{MAE}=\frac{1}{N}\sum_{i=1}^{N}|y_{i}-\tilde{y}_{i}|, \tag{18}\]
\[L_{f}=\frac{\sum_{i}|\sum_{k\in\mathcal{N}_{i}(i)}\tilde{f}_{ki}-\sum_{j\in \mathcal{N}_{o}(i)}\tilde{f}_{ij}-\Delta f_{i}|}{\sum_{s}\sum_{t}\tilde{O}_{s,t}}, \tag{19}\]
where \(y\) and \(\tilde{y}\) respectively represent the ground truth and predicted values for the flow-capacity ratio. Furthermore, we use the coefficient of determination, denoted by \(R^{2}\) to measure the goodness-of-fit between the GNN prediction and the ground truth. The training histories of the studied models are shown in Figure 3. The results indicate that the FCNN model performed poorly during training compared to GNN-based models, as shown by the high training loss and early stagnation. In contrast, GCN and GAT models exhibited similar convergence rates. Our proposed model outperformed both GCN and GAT in terms of training loss. Especially when used for larger networks, the proposed model demonstrated superior convergence performance compared to GCN and GAT; for the Anaheim network, the training loss of the proposed model is almost 1/3 of that of GAT in the first 25 iterations. This is because GCN and GAT only consider homogeneous edges, which limits the message passing to adjacent nodes. In contrast, the proposed GNN model uses virtual links and provides augmented connectivity to long-hop node pairs, which makes the node feature updating in HetGAT more efficiently.
After the training is finished, the model performance is evaluated on the testing set. The experiments under the urban road network are conducted in three different settings. The first setting, referred to as
Figure 3: Training loss history under urban transportation network. Three benchmarks, including FCNN, GCN, and GAT, are compared with HetGAT.
LMH-LMH, involved using all levels of disruption (flow reduction scaling levels) in both the training and testing sets. The second setting, namely L-M, involves training the model on light disruption data and testing it on medium disruption data. The third case, which is labeled as M-H, involves training on medium disruption data and testing on high disruption data. The L-M and M-H scenarios will therefore involve unseen cases that don't exist in the training data. Figure 4 plotted the predicted value and ground truth of the flow-capacity ratio on multiple samples in the Anaheim network under the LMH-LMH setting. In total, the flow-capacity ratio on 10,000 edges is predicted using HetGAT, GAT, and GCN, respectively. Figure 4 indicates that HetGAT has a relatively higher correlation coefficient, which outperforms GAT and GCN. Table 2 summarizes the prediction performance of all methods under different settings, and shows that HetGAT, compared to other models, offers better performance. When the graph size increases, the proposed model can maintain a relatively low MAE compared to GCN and GAT. For instance, in the Anaheim network, HetGAT offers MAE values that are 39%, 19%, and 31% lower than GAT values, in LMH-LMH, L-M, and M-H settings, respectively. Also, the conservation errors of HetGAT are 52%, 29%, and 55% smaller in LMH-LMH, L-M, and M-H settings, respectively. This shows that the inclusion of virtual links can assist GNN models in better learning the traffic flow patterns.
As an additional experiment, we consider a realistic scenario where the demand values are not known for the entire OD pairs. To evaluate the accuracy and robustness of the proposed model under incomplete OD demand scenarios, we introduce a random mask to the original OD demand, to simulate these missing
\begin{table}
\begin{tabular}{c c c c c|c c c c|c c} \hline \hline \multirow{2}{*}{Network} & \multirow{2}{*}{Model} & \multicolumn{3}{c}{LMH-LMH} & \multicolumn{3}{c}{L-M} & \multicolumn{3}{c}{M-H} \\ \cline{3-11} & & MAE & \(L_{f}\) & \(R^{2}\) & MAE & \(L_{f}\) & \(R^{2}\) & MAE & \(L_{f}\) & \(R^{2}\) \\ \hline \multirow{4}{*}{Sioux Falls} & FCNN & 0.158 & 0.324 & 0.728 & 0.139 & 0.062 & 0.812 & 0.215 & 0.238 & 0.643 \\ & GAT & 0.046 & 0.092 & 0.956 & **0.022** & 0.018 & **0.991** & 0.085 & 0.057 & 0.889 \\ & GCN & 0.046 & 0.096 & 0.955 & 0.023 & 0.019 & 0.990 & 0.086 & 0.060 & 0.889 \\ & HetGAT & **0.028** & **0.054** & **0.985** & 0.026 & **0.018** & 0.986 & **0.062** & **0.039** & **0.937** \\ \hline \multirow{4}{*}{EMA} & FCNN & 0.238 & 0.422 & 0.621 & 0.225 & 0.144 & 0.795 & 0.263 & 0.446 & 0.771 \\ & GAT & 0.063 & 0.131 & 0.952 & 0.046 & 0.033 & 0.991 & 0.132 & 0.090 & 0.842 \\ & GCN & 0.071 & 0.167 & 0.944 & 0.034 & 0.043 & 0.986 & 0.161 & 0.135 & 0.814 \\ & HetGAT & **0.038** & **0.090** & **0.982** & **0.034** & **0.027** & **0.989** & **0.090** & **0.055** & **0.921** \\ \hline \multirow{4}{*}{ Anaheim} & FCNN & 0.111 & 0.721 & 0.822 & 0.199 & 0.237 & 0.801 & 0.186 & 0.386 & 0.840 \\ & GAT & 0.051 & 0.263 & 0.951 & 0.042 & 0.081 & 0.958 & 0.090 & 0.184 & 0.881 \\ \cline{1-1} & GCN & 0.072 & 0.402 & 0.903 & 0.062 & 0.109 & 0.911 & 0.116 & 0.245 & 0.827 \\ \cline{1-1} & HetGAT & **0.031** & **0.126** & **0.981** & **0.034** & **0.059** & **0.979** & **0.062** & **0.082** & **0.939** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Performance comparison of HetGAT with benchmark methods. Three different settings are included: LMH-LMH, L-M, M-H. The mean absolute error, normalized conservation loss, and correlation coefficient are used to evaluate the prediction performance on the testing set.
Figure 4: Comparison of predicted flow-capacity ratio between ground truth and surrogate modeling in the Anaheim network under LMH-LMH setting.
demand scenarios. Specifically, given a specific missing ratio, we randomly select a number of OD pairs and mask their corresponding OD demand values as zeros in the input node feature. This way, the model is expected to learn the inherent patterns and structures of the traffic network, even when some of the demand information is missing. The effectiveness of the proposed model under incomplete OD demand scenarios will be evaluated by comparing the predicted traffic flows against the ground truth data obtained from the complete OD demand. Three missing ratios are considered in the experiment: 20%, 30%, and 40%. The training setting and the hyperparameters remain the same as those in the aforementioned experiments. Table 3 summarizes the results of prediction performance under different missing rate scenarios for the LMH-LMH setting. The FCNN model is not considered in these experiments because of their very poor performance in the previous experiments under full OD demand. As expected, overall the performances under incomplete OD demand drop, compared to that in the complete demand scenario, reported in Table 2. However, HetGAT still outperforms GAT and GCN under different networks and different missing ratios. In particular, the MAE values are about 50% smaller to those offered by GAT and GCN under various missing ratios. Also, the flow predictions by HetGAT have better compliance with the flow conservation law compared with GAT and GCN.
### Experiments on Generalized Synthetic Networks
In this set of experiments, we study the performance of the proposed model when generalized to networks with different topologies. To do so, we generate synthetic networks by starting with a grid graph and adding links between randomly selected nodes in the grid. Then, a few nodes and edges are randomly removed to emulate the real road network and increase the variability. It should be noted that the proposed HetGAT involves a node feature whose dimension is equal to the total number of nodes in the graph. Therefore, our model can be generalized to different graphs as long as the total number of nodes remain the same. Therefore, the various topologies in synthetic road networks all have the same number of nodes. Two sizes of the synthetic generalized dataset are included in the experiments: 100 and 300. For each graph size, 100 different graph topologies are generated. Three of these randomly generated graphs are shown in Figure 5. The OD demand and the link capacity are also randomly generated using the scaling factor according to Equation 16 and 17, respectively. Furthermore, the UE-based traffic assignment is used to generate the ground truth data, similarly to Section 4.1.
It should be noted that in fully connected neural networks (FCNN), the output dimension and the order of the entries should be fixed. This is while in our synthetic networks, even though the number of nodes are fixed, the number of edges are not necessarily the same in different topologies. Because of this, FCNN is not suitable for experiments on generalized synthetic networks. Therefore, GAT and GCN are the only two models that are compared with the proposed HetGAT model.
In the training, the same hyperparameters used in the previous experiments are used here, as well. Figure 6 presents the training history for the three models, and shows that GCN and GAT models struggle during the training process. In contrast, the HetGAT model can successfully learn the flow dynamics across multiple graphs, leading to a decrease in training loss over time. For a graph size of 100, GCN and GAT had a training
\begin{table}
\begin{tabular}{c c c c c|c c c c|c c c} \hline \hline \multirow{3}{*}{Network} & \multirow{3}{*}{Model} & \multicolumn{6}{c}{Missing Ratio} \\ \cline{3-11} & & \multicolumn{3}{c}{20\%} & \multicolumn{3}{c}{30\%} & \multicolumn{3}{c}{40\%} \\ \cline{3-11} & & MAE & \(L_{f}\) & \(R^{2}\) & MAE & \(L_{f}\) & \(R^{2}\) & MAE & \(L_{f}\) & \(R^{2}\) \\ \hline \multirow{4}{*}{Sioux Falls} & GAT & 0.048 & 0.098 & 0.954 & 0.049 & 0.102 & 0.953 & 0.049 & 0.099 & 0.952 \\ & GCN & 0.049 & 0.102 & 0.951 & 0.049 & 0.101 & 0.953 & 0.049 & 0.101 & 0.952 \\ & HetGAT & **0.033** & **0.068** & **0.981** & **0.034** & **0.069** & **0.979** & **0.033** & **0.068** & **0.982** \\ \hline \multirow{4}{*}{EMA} & GAT & 0.068 & 0.145 & 0.938 & 0.070 & 0.149 & 0.931 & 0.070 & 0.149 & 0.933 \\ & GCN & 0.079 & 0.200 & 0.936 & 0.079 & 0.204 & 0.935 & 0.077 & 0.188 & 0.939 \\ & HetGAT & **0.046** & **0.111** & **0.970** & **0.048** & **0.115** & **0.970** & **0.048** & **0.105** & **0.972** \\ \hline \multirow{4}{*}{Anaheim} & GAT & 0.067 & 0.152 & 0.924 & 0.061 & 0.135 & 0.933 & 0.071 & 0.156 & 0.914 \\ & GCN & 0.105 & 0.225 & 0.835 & 0.109 & 0.237 & 0.802 & 0.106 & 0.239 & 0.827 \\ \cline{1-1} & HetGAT & **0.035** & **0.060** & **0.975** & **0.034** & **0.069** & **0.969** & **0.034** & **0.058** & **0.977** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of the performance of HetGAT with that of GAT and GCN under incomplete OD demand. Three missing ratios are considered in the experiments: 20%, 30%, and 40%. The mean absolute error (MAE), normalized conservation loss (\(L_{f}\)), and the coefficient of determination, \(R^{2}\), are used to evaluate the prediction performance on the testing set.
loss of 0.114 and 0.124, respectively, whereas HetGAT achieved a training loss of 0.032, representing a 70% improvement. The prediction performance metrics on testing sets are compared in Table 4, where the mean absolute error of HetGAT outperformed GAT and GCN for graph sizes of 100 and 300, with values of 0.033 and 0.051, respectively.
## 5 Conclusion and Discussion
In this paper, we proposed a novel approach for traffic assignment and traffic flow learning using heterogeneous graph neural networks. We conducted extensive experiments on three real-world traffic networks to evaluate the performance of the proposed heterogeneous GNN model and compared it with the state-of-the-art models. The results show that the proposed model outperforms other models in terms of
\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{Graph Size} & \multirow{2}{*}{Metric} & \multicolumn{3}{c}{Model} \\ \cline{3-5} & & GAT & GCN & HetGAT \\ \hline \multirow{3}{*}{100} & MAE & 0.143 & 0.179 & **0.033** \\ & \(L_{f}\) & 0.016 & 0.014 & **0.013** \\ & \(R^{2}\) & 0.602 & 0.372 & **0.979** \\ \hline \multirow{3}{*}{300} & MAE & 0.291 & 0.316 & **0.051** \\ & \(L_{f}\) & 0.018 & 0.016 & **0.013** \\ \cline{1-1} & \(R^{2}\) & 0.412 & 0.316 & **0.977** \\ \hline \hline \end{tabular}
\end{table}
Table 4: Comparison of the performance of HetGAT with that of GAT and GCN on generalized synthetic networks. Two graph sizes of 100 and 300 are considered in the experiments. The mean absolute error (MAE), normalized conservation loss (\(L_{f}\)), and coefficient of determination (\(R^{2}\)) are used to evaluate the prediction performance on the testing set.
Figure 5: The illustrations of sampled generalized synthetic networks. The network size is 100. The link color represents the link capacity of each link.
Figure 6: Training loss history under generalized synthetic networks. Two network sizes of 100 and 300 are selected for training and testing. Two benchmarks including GCN and GAT are compared with HetGAT.
convergence rate, training loss, and prediction accuracy. The proposed model can also be generalized to different network topologies, with different topologies or network parameters, which demonstrates its potential in real-world applications. Currently, the proposed HetGAT model only learns and predicts the static traffic flow patterns. As a potential extension of this work, the proposed framework can be extended to learn the dynamic traffic flow patterns. Furthermore, the current proposed GNN model uses training data collected from conventional solvers of static traffic assignment. In future work, we will study how these models can be trained on traffic data collected from sensors, such as loop detectors, cameras, or GPS devices.
## 6 Acknowledgment
This work was supported in part by the National Science Foundation under Grant CMMI-1752302.
|
2305.18270 | How Two-Layer Neural Networks Learn, One (Giant) Step at a Time | We investigate theoretically how the features of a two-layer neural network
adapt to the structure of the target function through a few large batch
gradient descent steps, leading to improvement in the approximation capacity
with respect to the initialization. We compare the influence of batch size and
that of multiple (but finitely many) steps. For a single gradient step, a batch
of size $n = \mathcal{O}(d)$ is both necessary and sufficient to align with the
target function, although only a single direction can be learned. In contrast,
$n = \mathcal{O}(d^2)$ is essential for neurons to specialize to multiple
relevant directions of the target with a single gradient step. Even in this
case, we show there might exist ``hard'' directions requiring $n =
\mathcal{O}(d^\ell)$ samples to be learned, where $\ell$ is known as the leap
index of the target. The picture drastically improves over multiple gradient
steps: we show that a batch-size of $n = \mathcal{O}(d)$ is indeed enough to
learn multiple target directions satisfying a staircase property, where more
and more directions can be learned over time. Finally, we discuss how these
directions allows to drastically improve the approximation capacity and
generalization error over the initialization, illustrating a separation of
scale between the random features/lazy regime, and the feature learning regime.
Our technical analysis leverages a combination of techniques related to
concentration, projection-based conditioning, and Gaussian equivalence which we
believe are of independent interest. By pinning down the conditions necessary
for specialization and learning, our results highlight the interaction between
batch size and number of iterations, and lead to a hierarchical depiction where
learning performance exhibits a stairway to accuracy over time and batch size,
shedding new light on how neural networks adapt to features of the data. | Yatin Dandi, Florent Krzakala, Bruno Loureiro, Luca Pesce, Ludovic Stephan | 2023-05-29T17:43:44Z | http://arxiv.org/abs/2305.18270v3 | # Learning Two-Layer Neural Networks, One (Giant) Step at a Time
###### Abstract
We study the training dynamics of shallow neural networks, investigating the conditions under which a limited number of large batch gradient descent steps can facilitate feature learning beyond the kernel regime. We compare the influence of batch size and that of multiple (but finitely many) steps. Our analysis of a single-step process reveals that while a batch size of \(n=O(d)\) enables feature learning, it is only adequate for learning a single direction, or a single-index model. In contrast, \(n=O(d^{2})\) is essential for learning multiple directions and specialization. Moreover, we demonstrate that "hard" directions, which lack the first \(\ell\) Hermite coefficients, remain unobserved and require a batch size of \(n=O(d^{\ell})\) for being captured by gradient descent. Upon iterating a few steps, the scenario changes: a batch-size of \(n=O(d)\) is enough to learn new target directions spanning the subspace linearly connected in the Hermite basis to the previously learned directions, thereby a staircase property. Our analysis utilizes a blend of techniques related to concentration, projection-based conditioning, and Gaussian equivalence that are of independent interest. By determining the conditions necessary for learning and specialization, our results highlight the interaction between batch size and number of iterations, and lead to a hierarchical depiction where learning performance exhibits a stairway to accuracy over time and batch size, shedding new light on feature learning in neural networks.
## 1 Introduction
A number of theoretical efforts have been directed toward understanding the dynamics of training neural networks with gradient descent, aiming to uncover the underlying principles that govern their learning capabilities. By iteratively adjusting the network's weights based on the gradients of a chosen objective function, gradient descent seeks to minimize the discrepancy between predicted and true outputs. In this process, the network adapts to the data, learning which features in the input data are most important for explaining the labels. This adaptivity is in contrast to other machine learning pipelines such as random feature or kernel methods, and is behind the success of neural networks in efficiently solving problems from image classification to text generation.
In this paper, we delve into the training dynamics of shallow neural networks, focusing on the conditions that facilitate effective feature learning beyond the kernel or random features regime. We aim to answer the following fundamental question: can we precisely capture the presence of feature learning in the _early phase_ of gradient descent training? We shall thus investigate how the _very first few gradient steps_ on the first-layer parameters impact the representation abilities. Given we only perform a few steps, it will have to be giant ones, and we will use large, aggressive, learning rates. Our investigation highlights the crucial role of batch size in the training process in order to learn a meaningful representation in a few gradient steps, and the interplay between batch size, number of iterations and the complexity of the function one is attempting to learn. In fact, we shall establish the presence of a hierarchy in the learning of the different directions of the function to learn, in terms of their Hermite coefficients, as illustrated in Fig. 1 (for a single steps) and Fig. 2 (for multiple steps).
### Setting
We consider fully connected neural networks with \(p\) hidden neurons: given \(W\in\mathbb{R}^{p\times d}\) and \(\mathbf{a}\in\mathbb{R}^{p}\), the network function is defined as
\[\hat{f}(\mathbf{z};W,\mathbf{a})=\frac{1}{\sqrt{\rho}}\sum_{i=1}^{p}a_{i}\sigma( \langle\mathbf{w}_{i},\mathbf{z}\rangle)=\frac{1}{\sqrt{p}}a^{\top}\sigma(W\mathbf{z}), \tag{1}\]
where \(\sigma\) is the non-linear activation function applied elementwise. We study the performance of learning a distribution \(\rho\) on pairs \(\mathbf{z},y\), which corresponds to minimizing the _population loss_
\[\mathcal{R}(W,\mathbf{a})=\mathbb{E}_{(\mathbf{z},y)\sim\rho}\left[\mathcal{L}(\hat{f}( \mathbf{z};W,\mathbf{a}),y)\right], \tag{2}\]
where \(\mathcal{L}\) is the chosen loss function. In this work, we will focus on the case of the square loss
\[\mathcal{L}(\hat{y},y)=\frac{1}{2}\left(\hat{y}-y\right)^{2}\]
Data model --We assume the training data \((\mathbf{z},y)\in\mathbb{R}^{d+1}\) is sampled from the following generative model:
\[y=f^{*}(\mathbf{z})=\sum_{k=1}^{r}\sigma_{k}^{*}(\langle\mathbf{w}_{k}^{\star},\mathbf{z} \rangle), \mathbf{z}\sim\mathcal{N}(0,I_{d}). \tag{3}\]
where the weights \(W^{*}\in\mathbb{R}^{r\times d}\) are assumed normalized and orthogonal \(W^{*}{W^{*}}^{\top}=I_{r}\). This hypothesis class is a particular example of more general _multi-index functions_\(g(\langle\mathbf{w}_{1}^{\star},\mathbf{z}\rangle,\ldots,\langle\mathbf{w}_{r}^{\star}, \mathbf{z}\rangle)\) for which the target \(f^{*}\) only depends on the input data \(\mathbf{z}\) through \(r\) low-dimensional projections. Note that this can also be seens as fully-connected two-layer neural network with width \(r\). Learning this class with a two-layer network therefore boils down to learning the directions \(\mathbf{w}_{k}^{\star}\) on the top of the non-linear activations, therefore requiring _specialization_ of the hidden-units \(\mathbf{w}_{i}\) to the target directions [1]. Some of our results also hold for the more general multi-index model, where the dependency in the \(\langle\mathbf{w}_{k}^{\star},\mathbf{z}\rangle\) is arbitrary.
Training procedure --Similarly to [2, 3], we use a symmetric initialization to ensure that the network function is identically zero at the start of training: assuming that \(p\) is even,
\[a_{i}^{0}=-a_{p-i+1}^{0}\quad\text{and}\quad\mathbf{w}_{i}^{0}=\mathbf{w}_{p-i+1}^{0} \quad\text{for all}\;i\in[p/2]. \tag{4}\]
This condition is mainly necessary when \(p\) is small, as the initial network function might not concentrate around zero. Apart from this restriction, we draw
\[\sqrt{p}\cdot a_{i}^{0}\overset{i.i.d}{\sim}\operatorname{Unif}(\{-1,1\}) \quad\text{and}\quad w_{i}^{0}\overset{i.i.d}{\sim}\operatorname{Unif}( \mathcal{S}^{d-1}). \tag{5}\]
The distribution of the \(a_{i}\) can be replaced by any other distribution with positive variance, at least when \(p\) grows. After initialization, we split the training into two parts:
Figure 1: **Learning with a single gradient step: Illustration of the relationship between batch size and learning multi-index functions with a single giant steps with learning rate \(\mathcal{O}(p\sqrt{n/d})\), showcasing the stairway to generalization phenomenon: (a) a batch size of \(n=\mathcal{O}(d)\) results in learning only a single direction, approximating the target function with a single index function, (b) a larger batch size of \(n=\mathcal{O}(d^{2})\) facilitates specialization, allowing for learning multiple directions and coupling to all their Hermite coefficients, though directions with a null second Hermite coefficient remain unseen, (c) employing \(n=\mathcal{O}(d^{3})\) enables learning hard directions with the first nonzero coefficient of 3-degree (light blue neurons) and more generally, directions with \(\ell\)-Hermite coefficient zero require a batch size of \(n=\mathcal{O}(d^{\ell})\). (hard blue neurons)**
1. _First layer training_: we perform \(T\) steps of full-batch gradient descent \[\mathbf{w}_{i}^{t+1}=\mathbf{w}_{i}^{t}-\frac{\eta}{n}\sum_{\nu=1}^{n}\nabla_{\mathbf{w}_{j} }\mathcal{L}\left(\hat{f}(\mathbf{z}^{\nu};W^{t},\mathbf{a}),y^{\nu}\right),\] (6) where the training set \(\{(\mathbf{z}^{\nu},y^{\nu})\}_{\nu=1}^{n}\) is drawn i.i.d according to (3). We will assume that the training set for each gradient step is a fresh one, so that the total sample complexity for this step is \(Tn\).
2. _Second layer training_: once the first layer is trained, we perform a simple ridge regression with \(\ell_{2}\) penalty for the second layer: \[\hat{\mathbf{a}}=\operatorname*{arg\,min}_{\mathbf{a}\in\mathbb{R}^{p}}\frac{1}{n} \sum_{\nu=1}^{n}\mathcal{L}\left(\hat{f}(\mathbf{z}^{\nu};W^{t},\mathbf{a}),f^{\star} (\mathbf{z}^{\nu})\right)+\lambda\|\mathbf{a}\|^{2}.\] (7) Such a separation of the training between the first and second layer is a common setup for the theoretical study of training [3, 4, 5], and allows for a more tractable study of convergence.
Hermite expansion -We recall the definition of a Hermite expansion:
**Definition 1**.: _Let \(f:\mathbb{R}\to\mathbb{R}\) be a function that is square integrable w.r.t the Gaussian measure. There exists a unique sequence of real numbers \((c_{j})_{j\in\mathbb{N}}\), called the Hermite coefficients of \(f\), such that_
\[f(x)=\sum_{j=0}^{\infty}\frac{c_{j}}{j!}\operatorname{He}_{j}(x), \tag{8}\]
_with \(\operatorname{He}_{j}\) denoting the probabilist's Hermite polynomials [6]._
In the following, we will denote by \((\mu_{j})_{j\in\mathbb{N}}\) the Hermite coefficients of the activation function \(\sigma\), and \((\mu_{k,j}^{\star})_{j\in\mathbb{N}}\) those of the target function \(\sigma_{k}^{\star}\).
### Summary of main results
Our first set of results discuss the case of **a single gradient step**, which are illustrated in Fig. 1 (A particular numerical example is shown in Fig. 5). In this case:
Figure 2: **Learning with a few gradient steps:** Illustration of the staircase phenomenon when using few giants steps with learning rate \(\mathcal{O}(p\sqrt{n/d})\) in the linear regime \(n\approx d\). Upon iteration, one can learn more directions, one at a time, but _only_ in the subspace of directions “linearly connected” in the Hermite basis to the learned directions of the previous time-step (see text). In contrast to Fig. 1, this allows to generalize with multiple directions with \(\mathcal{O}(n)\) batches and does not require cancellation of previous directions, but this specialization is restricted to staircase functions (and “hard” neurons with zero first Hermite coefficients still require \(\mathcal{O}(d^{2})\) samples).
* For a large batch size \(n=\mathcal{O}(d)\) and learning rate \(\eta=\mathcal{O}(p\sqrt{n/d})\), meaningful feature learning can be obtained that surpasses random features. However, this is limited in that only a _single_ direction can be learned. Thus, if \(r>1\), only a single-neuron approximation of the target function will be obtained, specifically for the directions with non-zero Hermite coefficients.
* Surpassing the single direction approximation _requires_ utilizing a larger batch size of dimension \(n=\mathcal{O}(d^{2})\). Suppressing the main learned direction, we show that with a batch size of \(n=\mathcal{O}(d^{2})\) the gradient spans the space of many directions. This allows for the _specialization_ of the network weights, that is, learning multiple directions. In these directions, the learning process couples _all_ of the non-zero Hermite coefficients of the target function.
* Nonetheless, the "hard" directions (those for which the first \(\ell\) Hermite coefficients are zero), will continue to be disregarded. Learning these directions necessitates a batch size of \(n=\mathcal{O}(d^{\ell})\), as well as supressing the directions learned at \(n=\mathcal{O}(d^{\ell-1})\).
The situation drastically changes when allowing for **multiple gradient steps**. In this case, focusing on the linear batch size \(n=\mathcal{O}(d)\) regime, the phenomenology, as illustrated in Fig. 2, is as follows:
* While with a single step we can only learn a single direction in the teacher space, each additional gradient step allows for learning a new perpendicular direction, one at a time, upon the important condition that these directions are coupled through a staircase property (see sec.2.2 for details and definitions). Therefore, taking multiple steps allows to learn a multiple-index target with only \(n=\mathcal{O}(d)\) data, provided the staircase condition is met.
* However, directions that are not coupled through the staircase and with zero first Hermite coefficient cannot be learned in any finite number of steps. In fact, as discussed previously they require a batch size of \(n=\mathcal{O}(d^{2})\). In other words, while multiple steps help specialization, they do not allow for the identification of "hard" target directions.
We note that aside from the difference in the specialization capacity, taking a single or multiple steps have an important difference. Indeed, with one step learning with \(n=\mathcal{O}(d^{\ell})\) is only possible if the directions obtained from the gradient with \(n=\mathcal{O}(d^{\ell-1})\) are removed, for instance by learning the second layer or pre-processing the data. In contrast, each new step can add a new direction without the need to adapt the second layer weights.
The code to reproduce our figures is available on GitHub, and we refer to App. A for details on the numerical implementations.
### Related Works
The analysis of high-dimensional asymptotics of kernel regression has provided valuable insights into the advantages and limitations of kernel methods [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]. In particular, a similar stairway picture as in Fig. 1 emerged from these works [19]. The key difference, however, is that at each regime \(n=\mathcal{O}(d^{\ell})\), kernels can only learn the \(\ell\)-th Hermite polynomial of the target. This should be contrasted with our feature learning regime where, once a direction is learned, all its Hermite coefficients are learned. Feature learning corrections to kernel methods have been investigated in [20, 21, 22, 23, 24, 25, 26]. On a complementary line of work, exact asymptotic results for the the random features models have been derived in the literature [27, 28, 29, 30, 31, 32, 33]. A large part of these results are enabled by the Gaussian equivalence property [34, 35, 36, 37].
In the context of neural network training dynamics, [38] established that the sample complexity of learning single-index targets with one-pass SGD is entirely determined by the first non-zero Hermite coefficient, which define an _information exponent_.
Closer to us are [39, 3] showed a sufficiently large single gradient step allows to beat a kernel method. However, their results are limited to single-index target and to a single (giant) gradient step. Here, we build on their results and consider multi-index targets and multiple steps. [3] proved that a batch size of \(n=d^{2}\) is _sufficient_ for learning multiple directions of a multi-index target. However, they did not establish whether this batch size is _necessary_, and were again limited to a single step. Our results reveal that a batch size of \(n=\mathcal{O}(d^{2})\) is indeed necessary for learning multiple directions in a single step, and we characterize which class of multi-index targets can be instead learned with \(n=O(d)\) with multiple steps.
In a related but different vein, [40], building upon the earlier work of [41] show how a "staircase" property of target functions characterizes the sample complexity arises for infinite width two-layer networks trained by one-pass SGD, a.k.a. the mean-field regime [42, 43, 44, 45]). Their focus, however, was on the peculiar case of _sparse boolean functions_ depending solely on linear coefficients, without considering direction-specific specialization. More recently, [4] provided partial results for the case of isotropic Gaussian data, always in the regime of one-pass SGD. Here we consider the more generic case of multi-index target functions with Gaussian data with large-batch SGD, and show that a "directional staircase" behavior arises when iterating a few giant gradient steps, while a related, but definitely different, picture arises with single steps depending on the batch size.
Finally, our results illustrate that during the early stage of training, neural networks first learn a single direction and require the learning of the linear part of the target function before specializing. This corroborates the findings of [46],
who showed that the neural network first fits the best linear classifier and subsequently learns functions of increasing complexity.
## 2 Main theoretical results
### Single gradient step
Our starting point is a _single_ giant gradient step, and the phenomenology described in Fig.1.
Feature learning in the first layer -Let us first focus on the effect of the batch learning of (6) on the first layer \(W\). For any \(i\in[p],k\in[r]\), we introduce the following quantities:
\[M\in\mathbb{R}^{p\times r}=\{m_{ik}\}_{i\in[p],k\in[r]},\quad m_{ik}=\langle \mathbf{w}_{i},\mathbf{w}_{k}^{\star}\rangle\quad\text{ and }\quad q_{i}=\|\mathbf{w}_{i}\|^{2}, \tag{9}\]
and the normalized correlation matrix
\[\Pi_{ik}=\frac{1}{\sqrt{p}}\frac{m_{ik}}{\sqrt{q_{i}}}. \tag{10}\]
We say that the first layer is (resp. isn't) _learned_ when \(\|\Pi\|_{F}=\Omega(1)\) (resp. \(o(1)\)). More specifically, let \(V^{\star}=\operatorname{span}\big{(}\{\mathbf{w}_{k}^{\star}\}_{k\in[r]}\big{)}\); we say that the subspace learned by \(W\) is \(U\subseteq V^{\star}\) if \(\|M\mathbf{u}\|=\Omega(1)\) for any \(\mathbf{u}\in U\), and \(\|M\mathbf{u}\|=o(1)\) for any \(\mathbf{u}\in U^{\perp}\).
Those definitions will be motivated in the next result section, which investigates the performance of the network when the first layer has/hasn't learned. For now, let us state our results. We define the _leap index_ of the learning problem as the first integer \(\ell\) such that \(\mu_{k,\ell}^{\star}\neq 0\) for some \(k\in[r]\).
**Theorem 1**.: _Let \(\ell\) be the leap index of the problem, and assume that \(\mu_{\ell}\neq 0\). Then, with high probability, after one step:_
1. _If_ \(\ell=1\) _and_ \(n=\Omega(d)\)_, let_ \[\mathbf{v}^{\star}=\sum_{k=1}^{r}\mu_{k,1}^{\star}\mathbf{w}_{k}^{\star}.\] (11)
_Then, when taking \(\eta=p\) the first layer learns, but it only learns the subspace \(\operatorname{span}(\mathbf{v}^{\star})\)._
2. _If_ \(\ell>1\) _and_ \(n=\Omega(d^{\ell})\)_, let_ \[V_{\ell}^{\star}=\operatorname{span}\big{(}\{\mathbf{w}_{k}^{\star}:\mu_{k,\ell}^ {\star}\neq 0\}\big{)}\,.\] (12)
_Then when taking \(\eta=p\sqrt{\nicefrac{{n}}{{d}}}\) the first layer learns, but it only learns \(V_{\ell}^{\star}\)._
3. _If_ \(n=\mathcal{O}(d^{\ell-\varepsilon})\) _for some_ \(\varepsilon>0\)_, then the first layer never learns._
Aspects of these results were already present in previous works: [39] shows the existence of a rank-one property of the gradient at initialization for \(n=\Theta(d)\), and [3] implies the positive part of our result for \(n=\Theta(d^{2})\), provided that \(V_{2}^{\star}=V^{\star}\) (which corresponds to their Assumption 2). We complement those results by providing matching lower bounds, as well as providing the picture for higher powers of \(d\).
### Few giant steps and the staircase phenomenon
We now move to the effect of multiple gradient steps, as described in Fig.2. As we shall see, while the effect of multiple steps is limited to a subclass of functions, it allows to learn them meaningfully with few iterations. For simplicity, we restrict ourselves to the case \(n=\mathcal{O}(d)\), although we expect a similar picture to hold in the other regimes. Informally, the picture is similar to a the "staircase" phenomenon observed in [4, 40]: once we learn a direction in the first-layer weights, the next gradient step can use the already learned subspace as a ladder to learn the next ones, which become linear when conditioning on the spike directions. To formalize this, we introduce the notion of _subspace conditioning_:
**Definition 2** (Subspace conditioning).: _Let \(V\) be a vector space, and \(U\subseteq V\) a subspace. For any function \(f:V\to\mathbb{R}\), and \(\mathbf{x}\in U\), we define the conditional function \(f_{U,\mathbf{x}}:U^{\perp}\to\mathbb{R}\) as_
\[f_{U,\mathbf{x}}(\mathbf{x}^{\perp})=f(\mathbf{x}+\mathbf{x}^{\perp}) \tag{13}\]
In short, the function \(f_{U,\mathbf{x}}\) corresponds to \(f\) "conditioned" on the projection of its argument in \(U\). Its first Hermite coefficient will be denoted as
\[\mu_{U,\mathbf{x}}(f)=\mathbb{E}_{\mathbf{x}^{\perp}\sim\mathcal{N}(0,I)}\left[\nabla _{\mathbf{x}^{\perp}}f_{U,\mathbf{x}}\right] \tag{14}\]
We are now equipped to state our conjecture:
**Conjecture 1**.: _Assume that \(n=\mathcal{O}(d)\), and \(\eta=\sqrt{p}\). Define a sequence of nested subspaces \(U_{0}^{\star}\subseteq U_{1}^{\star}\subseteq\dots\subseteq U_{t}^{\star} \subseteq\dots\) as_
* \(U_{0}^{\star}=\{0\}\)_,_
* _for any_ \(t\geq 0\)_,_ \(U_{t+1}^{\star}=U_{t}^{\star}\oplus\mathrm{span}\left(\{\mu_{U_{t}^{\star}, \mathbf{x}}(f^{\star}):\mathbf{x}\in U_{t}^{\star}\}\right)\)_._
_Then, after \(t\) gradient steps of the form (6), the first layer learns exactly \(U_{t}^{\star}\)._
It is easy to check that this conjecture is consistent with Theorem 1, since \(f_{\{0\},\mathbf{0}}=f\), and \(v^{\star}\) is exactly the first hermite of \(f^{\star}\).
Examples --As an illustration, we work out the subspaces \(U_{t}^{\star}\) for simplified versions of the examples in Figure 4. For simplicity, we will take \(\mathbf{w}_{k}^{\star}=e_{k}\), the \(k\)-th vector of the standard basis, so that \(\langle\mathbf{w}_{k}^{\star},\mathbf{z}\rangle=z_{k}\).
* \(f^{\star}(\mathbf{z})=z_{1}+z_{2}+z_{1}^{2}-z_{2}^{2}\): the normalized first hermite coefficient of \(f^{\star}\) is \(\mathbf{v}^{\star}=(e_{1}+e_{2})/\sqrt{2}\), so \(U_{1}^{\star}=\mathrm{span}(e_{1}+z_{2})\). Then, we can rewrite \(f^{\star}\) in the new basis \((\mathbf{v}^{\star},\mathbf{v}^{\perp})\), to get \[f^{\star}(\mathbf{z})=\sqrt{2}\langle\mathbf{v}^{\star},\mathbf{z}\rangle+2\langle\mathbf{v}^ {\star},\mathbf{z}\rangle\langle\mathbf{v}^{\perp},\mathbf{z}\rangle.\] Hence, if \(\mathbf{x}=\lambda\mathbf{v}^{\star}\), we have \(\mu_{U_{t}^{\star},\mathbf{x}}(f^{\star})=2\lambda\mathbf{v}^{\perp}\), and hence \(U_{2}^{\star}=V^{\star}\).
* \(f^{\star}(\mathbf{z})=z_{1}+z_{2}+z_{1}^{2}+z_{2}^{2}\): just as the above example, \(U_{1}^{\star}=\mathrm{span}(e_{1}+e_{2})\), and hence we perform the same change of basis. However, this time, \[f^{\star}(\mathbf{z})=\sqrt{2}\langle\mathbf{v}^{\star},\mathbf{z}\rangle+\langle\mathbf{v}^ {\star},\mathbf{z}\rangle^{2}+\langle\mathbf{v}^{\perp},\mathbf{z}\rangle^{2}.\] This implies that for any \(\mathbf{x}\in U_{1}^{\star}\), \(\mu_{U_{t}^{\star},\mathbf{x}}(f^{\star})=\mathbf{0}\), and the direction of \(v^{\perp}\) is never learned.
In Appendix B we provide a series of results and analytic predictions supporting Conjecture 1. In particular, the notion of subspace condition (Definition 2) arises through an inductive decomposition of the projections of the gradient along the teacher subspace. We are also able to verify the \(t=2\) case of Conjecture 1, under some technical conditions:
Figure 3: **Feature learning after a single step.** Specialization of hidden units in the \(n=\mathcal{O}(d^{\ell})\) regime (\(\ell=2,3\)). The plots show the cosine similarity with respect to the teacher vectors \((\mathbf{\theta}_{1},\mathbf{\theta}_{2})\) for the gradient of \(p=40\) different neurons, identified by different markers. The bisectrix of the first quadrant is shown as a continuous black line, the circle of unitary radius in black, and the circle of radius \(\nicefrac{{2}}{{\sqrt{d}}}\) in blue. In the upper panel, \((n,d)=(2^{18},2^{9})\), and \((n,d)=(2^{21},2^{7})\) in the lower one, and we use a symmetric \(2\)-index teacher, with matching student: \(\sigma=\sigma_{1}^{\star}=\sigma_{2}^{\star}\). **Left:**\(\sigma(z)=\mathrm{He}_{1}(z)\), **Center-Left:**\(\sigma(z)=\mathrm{He}_{2}(z)\), **Center-Right:**\(\sigma(z)=\mathrm{He}_{3}(z)\), **Right:**\(\sigma(z)=\mathrm{He}_{4}(z)\). We observe that for \(\ell=1\), we only learn a single direction, no matter the data quantity, while for \(\ell>1\) we learn every direction at once as soon as we reach \(n=d^{\ell}\). The small spread observed for \(\sigma=\mathrm{He}_{4}\) and \(n=d^{3}\) is likely caused by the small value of \(d\) used for the experiments. See details in App. A.
**Proposition 1** (Informal).: _In the setting of Conjecture 1, let \(\mathbf{v}^{\perp}\) be a vector in \(U_{2}^{\star}\cap{U_{1}^{\star}}^{\perp}\). Then, for any \(i\in[p]\) with \(a_{i}^{0}\) fixed to \(\frac{1}{\sqrt{p}}\) or \(-\frac{1}{\sqrt{p}}\),_
\[\left|\mathbb{E}\left[\langle\mathbf{w}_{i},\mathbf{v}^{\perp}\rangle\right]\right|= \Omega(1). \tag{15}\]
_On the other hand, for any \(\mathbf{v}\in U_{2}^{\star\perp}\) and \(i\in[p]\),_
\[\left|\mathbb{E}\left[\langle\mathbf{w}_{i},\mathbf{v}\rangle\right]\right|=o(1). \tag{16}\]
Furthermore, our theory leads to a precise prediction of the orientation of the gradient in the teacher subspace after a finite number of steps. This is illustrated in Figure 4.
### From feature learning to generalization bounds
We now investigate the consequence of Theorem 1 in the actual performance of the neural network. This is a fairly complex question: indeed, [12] shows that even in the absence of feature learning (i.e. when the first layer is fully random), it is possible to learn a polynomial approximation of \(f^{\star}\) of degree \(\ell\) as long as \(n,p=\Omega(d^{\ell+\delta})\) for some \(\delta>0\). Hence, our results and conjectures regarding generalization error need to depend on both the number of samples and the number of hidden neurons.
Finite \(p\) regime --This is the simplest case: in this setting, there is simply no way to fit anything beyond the learned directions, even with an infinite amount of data. This is formalized by the following proposition:
**Proposition 2**.: _Assume that \(p\) is bounded as \(n,d\to\infty\), and that the first layer \(W\) only learns a subspace \(U\subseteq V^{\star}\). For any choice of second layer \(\mathbf{a}\) such that \(\|\mathbf{a}\|_{\infty}\leq\mathbb{O}(1)\), we have_
\[\mathbb{E}\left[\left(f^{\star}(\mathbf{z})-\hat{f}(\mathbf{z};W,\mathbf{a})\right)^{2} \right]\geq\mathbb{E}\left[\operatorname{Var}\left(f^{\star}(\mathbf{z})\mid P_{ U}\mathbf{z}\right)\right]+o(1) \tag{17}\]
_where \(P_{U}\) is the orthogonal projection on \(U\)._
Figure 4: **Feature learning with multiple gradient steps. Top:** Generalization error as a function of \(n\) (\(d=512,p=256\)) after iterating the training procedure for six steps. **Bottom:** Cosine similarity of the projected gradient matrix \(G^{\perp}\) inside the teacher subspace for all the \(p\) neurons at a fixed ratio \(\nicefrac{{n}}{{d}}=4\), plotted at different stages of the training. The blue and purple lines are the theoretical prediction for the orientation of the gradient in the second step. We consider two different 2-index teacher functions: **Left:**\(\sigma_{1}^{\star}(z)=\sigma_{2}^{\star}(z)=\operatorname{He}_{1}(z)+\nicefrac{{ \operatorname{He}_{2}(z)}}{{2}}+\nicefrac{{\operatorname{He}_{4}(z)}}{{4!}}\). **Right:**\(\sigma_{1}^{\star}(z)=z-z^{2}\) and \(\sigma_{2}^{\star}(z)=z+z^{2}\). In accordance with Conjecture 1, the difference between the two cases is clear already after the first GD step: while on the left the gradient is stuck around the predicted rank-one spike after the first step (black line), on the right the gradient changes orientation in the second step, allowing to learn multiple features. See details in App. A.
The right-hand side of the above inequality corresponds to a predictor \(\hat{f}(\mathbf{z})=\mathbb{E}\left[f^{\star}(\mathbf{z})\mid P_{U}\mathbf{z}\right]\), which is the best predictor that depends only on \(P_{U}\mathbf{z}\). Conversely, we expect that with enough neurons, it is possible to approximate this predictor:
**Conjecture 2**.: _For any \(\delta>0\), there exists a \(p_{0}\in\mathbb{N}\) such that if \(p\geq p_{0}\), there exists a choice of second layer \(\mathbf{a}\) satisfying \(\|\mathbf{a}\|_{\infty}\leq\mathcal{O}(1)\), such that as \(n,p\to\infty\)_
\[\mathbb{E}\left[\left(f^{\star}(\mathbf{z})-\hat{f}(\mathbf{z};W,\mathbf{a})\right)^{2} \right]\leq\mathbb{E}\left[\mathrm{Var}\left(f^{\star}(\mathbf{z})\mid P_{U}\mathbf{z }\right)\right]+\delta+o(1) \tag{18}\]
Such a conjecture is proven in [3] for the specific case of \(U=V^{\star}\) (in which case the first term in the RHS is zero) and \(\sigma=\mathrm{relu}\), with additional bias terms.
Beyond the fixed regime --When the number of neurons is allowed to diverge, it is no longer impossible to learn the directions that are not present in \(M\), and the performance of the network may heavily depend on the training process for the second layer. We expect the following behavior:
1. On the directions present in \(W\), we are able to learn "everything".
2. On the orthogonal directions, we can do no better than a random feature model.
To formalize this conjecture, we introduce the following definition:
**Definition 3**.: _Let \(V\) be a vector space, and \(U\subseteq V\) a subspace. For any \(\ell\geq 0\), we define the space \(\mathcal{P}_{U,\ell}\) of functions \(f:V\to\mathbb{R}\) such that for any \(\mathbf{x}\in U\), the function \(f_{U,\mathbf{x}}\) introduced in Definition 2 is a polynomial of degree at most \(\ell\)._
Simply put, the space \(\mathcal{P}_{U,\ell}\) consists of polynomials in \(\mathbf{x}^{\perp}\) of degree at most \(\ell\), whose coefficients can be functions of \(\mathbf{x}\). We will denote by \(P_{U,\leq\ell}\) and \(P_{U,>\ell}\) the projections on \(\mathcal{P}_{U,\ell}\) and \(\mathcal{P}_{U,\ell}^{\perp}\) in \(\ell^{2}(\mathbb{R},\gamma)\), respectively, where \(\gamma\) is the Gaussian measure. Then, we conjecture the following:
**Conjecture 3**.: _Assume that \(p=\mathcal{O}(d^{\kappa_{1}})\) and \(n=\mathcal{O}(d^{\kappa_{2}})\), and that the first layer \(W\) only learns a subspace \(U^{\star}\subseteq V^{\star}\). Then, if \(\hat{\mathbf{a}}\) is obtained as in Eq. (7) for any value of \(\lambda\),_
\[\mathbb{E}\left[\left(f^{\star}(\mathbf{z})-\hat{f}(\mathbf{z};W,\hat{\mathbf{a}})\right) ^{2}\right]\geq\|P_{U^{\star},>\kappa}f^{\star}\|_{\gamma}^{2}+o(1), \tag{19}\]
_where \(\kappa=\min(\kappa_{1},\kappa_{2})\) and \(\|\cdot\|_{\gamma}\) is the norm in \(\ell^{2}(\mathbb{R},\gamma)\)._
It is easy to check that Proposition 2 corresponds to the \(\kappa=\kappa_{1}=0\) case of the above conjecture.
The linear case --We now show the \(\kappa_{1}=\kappa_{2}=1\) case of the above conjecture, often called the _proportional regime_. In this setting, the work [35] shows that for the random features \(W_{0}\), the minimization problem for the second layer (7) is equivalent to the one of a linear model; this result was extended in [39] to a trained first layer \(W_{1}\) for a "lazier" stepsize \(\eta=\mathcal{O}(1)\).
When \(\eta=\mathcal{O}(p)\), this equivalent model is not applicable anymore, due to the spike in the trained weight matrix \(W_{1}\); however, we show that this spike only allows the learning of non-linear functions parallel to the spike. Notice that the optimization problem (7) is equivalent to
\[\min_{\mathbf{a}\in\mathbb{R}^{p}}\frac{1}{n}\sum_{\nu=1}^{n}\left(\langle\mathbf{a}, \phi_{\text{CK}}(\mathbf{z}^{\nu})\rangle-f^{\star}(\mathbf{z}^{\nu})\right)^{2}+ \lambda\|\mathbf{a}\|^{2} \tag{20}\]
where \(\phi_{\text{CK}}(\mathbf{z})=\sigma(W\mathbf{z})/p\sqrt{n/d}\) is the feature map corresponding to the _conjugate kernel_ of the neural network. For a given direction \(\mathbf{v}\), we define the _conditional linear_ equivalent map \(\phi_{\text{CL}}(\mathbf{z};\mathbf{v})\) as follows: given the decomposition \(\mathbf{z}=z_{\mathbf{v}}\mathbf{v}+\mathbf{z}^{\perp}\),
\[\phi_{\text{CL}}(\mathbf{z};\mathbf{v})=\mu\left(z_{\mathbf{v}}\right)+\Psi(z_{\mathbf{v}})z^ {\perp}+\Phi(z_{\mathbf{v}})\mathbf{\xi} \tag{21}\]
where \(\mathbf{\xi}\sim\mathcal{N}(0,I_{p}-\mathbf{v}\mathbf{v}^{\perp})\), and \(\mu\in\mathbb{R}^{p},\Psi\in\mathbb{R}^{p\times d},\Phi\in\mathbb{R}^{p\times p}\) are chosen to match the first two conditional moments of \(\phi_{\text{CK}}\):
\[\mu(z_{\mathbf{v}}) =\mathbb{E}\left[\phi_{\text{CK}}(\mathbf{z})\mid z_{\mathbf{v}}\right], \quad\Psi(z_{\mathbf{v}})=\mathbb{E}\left[\phi_{\text{CK}}(\mathbf{z})(z^{\perp})^{ \top}\mid z_{\mathbf{v}}\right],\] \[\Phi(z_{\mathbf{v}}) =\mathrm{Cov}\left[\phi_{\text{CK}}(\mathbf{z})\mid z_{\mathbf{v}}\right]- \Psi(z_{\mathbf{v}})\Psi(z_{\mathbf{v}})^{\top}\]
Then, the following theorem holds:
**Theorem 2**.: _(informal) Assume that \(n,p=\Theta(d)\), and that the vector \(\mathbf{v}^{\star}\) defined in Theorem 1 is nonzero. Then, after one gradient step, there exists a vector \(\mathbf{v}\in\mathbb{R}^{p}\) such that:_
* _the projection of_ \(\mathbf{v}\) _on_ \(V^{\star}\) _is proportional to_ \(\mathbf{v}^{\star}\)_,_
* _the solutions_ \(\hat{\mathbf{a}}\)_,_ \(\tilde{\mathbf{a}}\) _to the optimization problem in (_20_) with the feature maps_ \(\phi_{\text{\sc cx}}(\mathbf{z})\) _and_ \(\phi_{\text{\sc cx}}(\mathbf{z};\mathbf{v})\) _yield the same generalization error._
The full statement of Theorem 2, with the relevant hypotheses, can be found in App. C. As we discuss in the Appendix, Theorem 2 also provides a proof of the case \(\kappa_{1}=\kappa_{2}=1\) of Conjecture 3:
**Corollary 1**.: _Conjecture 3 holds for \(\kappa_{1}=\kappa_{2}=1\)._
Informally, since anything orthogonal to \(\mathbf{v}\) maps to a linear model, we are only able to learn the linear part of \(f^{\star}\) on this subspace, which exactly corresponds to Conjecture 3.
## Conclusion
We provide a full picture of the learning dynamics when the first layer is trained using "large-batch" gradient steps. While some parts of those results are left as conjectures, we believe that they capture both the dynamics of multiple gradient steps, as well as the structure of the remaining directions. Proving those conjectures is likely to require fairly delicate concentration and random matrix arguments, which may be of independent mathematical interest.
## Acknowledgements
We thank Denny Wu, Theodor Misiakiewicz & Lenka Zdeborova for insightful discussions. We also acknowledge funding from the Swiss National Science Foundation grant SNFS OperaGOST, \(200021\_200390\) and the _Choose France - CNRS AI Rising Talents_ program.
Figure 5: **Learning with training of the second layer.** Simulation illustrating the different regimes in Fig.1, using \(d=512,p=1024\), a teacher function with two neurons and activation \(\sigma(z)=\operatorname{He}_{1}(x)+\operatorname{He}_{2}(x)/2!+ \operatorname{He}_{4}(x)/4!\), and a Relu student. (a) The first algorithm (green) applies a giant step and then learns the second layer. When \(n\gg d\), its performance goes beyond the linear predictor that would be obtained with a kernel method and reach the “single-index” regime in Fig.1. (b) To go beyond this regime, the second algorithm (blue) preprocesses the data to remove a plug-in estimate of the first Hermite coefficient. It reaches a lower plateau as \(n\approx d^{2}\), now beating the quadratic kernel. We contrast this behavior with the one of the random feature model (red). Details can be found in App. A. |
2305.06058 | Compressing neural network by tensor network with exponentially fewer
variational parameters | Neural network (NN) designed for challenging machine learning tasks is in
general a highly nonlinear mapping that contains massive variational
parameters. High complexity of NN, if unbounded or unconstrained, might
unpredictably cause severe issues including over-fitting, loss of
generalization power, and unbearable cost of hardware. In this work, we propose
a general compression scheme that significantly reduces the variational
parameters of NN by encoding them to deep automatically-differentiable tensor
network (ADTN) that contains exponentially-fewer free parameters. Superior
compression performance of our scheme is demonstrated on several
widely-recognized NN's (FC-2, LeNet-5, AlextNet, ZFNet and VGG-16) and datasets
(MNIST, CIFAR-10 and CIFAR-100). For instance, we compress two linear layers in
VGG-16 with approximately $10^{7}$ parameters to two ADTN's with just 424
parameters, where the testing accuracy on CIFAR-10 is improved from $90.17 \%$
to $91.74\%$. Our work suggests TN as an exceptionally efficient mathematical
structure for representing the variational parameters of NN's, which exhibits
superior compressibility over the commonly-used matrices and multi-way arrays. | Yong Qing, Ke Li, Peng-Fei Zhou, Shi-Ju Ran | 2023-05-10T11:24:27Z | http://arxiv.org/abs/2305.06058v2 | # Compressing neural network by tensor network with exponentially fewer variational parameters
###### Abstract
Neural network (NN) designed for challenging machine learning tasks is in general a highly nonlinear mapping that contains massive variational parameters. High complexity of NN, if unbounded or unconstrained, might unpredictably cause severe issues including over-fitting, loss of generalization power, and unbearable cost of hardware. In this work, we propose a general compression scheme that significantly reduces the variational parameters of NN by encoding them to multi-layer tensor networks (TN's) that contain exponentially-fewer free parameters. Superior compression performance of our scheme is demonstrated on several widely-recognized NN's (FC-2, LeNet-5, and VGG-16) and datasets (MNIST and CIFAR-10), surpassing the state-of-the-art method based on shallow tensor networks. For instance, about 10 million parameters in the three convolutional layers of VGG-16 are compressed in TN's with just \(632\) parameters, while the testing accuracy on CIFAR-10 is surprisingly improved from \(81.14\%\) by the original NN to \(84.36\%\) after compression. Our work suggests TN as an exceptionally efficient mathematical structure for representing the variational parameters of NN's, which superiorly exploits the compressibility than the simple multi-way arrays.
neural network, tensor network, machine learning, model compression, tensor decomposition.
## I Introduction
Neural network (NN) [1] has gained astounding success in a wide range of fields including computer vision, natural language processing, and most recently scientific investigations in, e.g., applied mathematics(e.g., [2, 3]) and physics(e.g., [4, 5, 6, 7, 8, 9, 10]). To improve the performance on handling complicated realistic tasks, the amount of variational parameters in NN rapidly increases from millions to trillions (e.g., Chat-GPT with 175 billion parameters [11]). Such a paradigm with the utilization of super large-scale NN's brought us several severe challenges. Though the representation ability of NN should be enhanced by increasing the complexity, over-fitting might occur and the generalization ability of NN might unpredictably be harmed. The increasing complexity also brings unbearable cost of hardware in academic investigations and practical applications.
The variational parameters in NN are usually stored as high-order tensors (or multi-linear arrays). Previous results show that generalization ability can be improved by suppressing or "refining" the degrees of freedom in such tensors by, e.g., network pruning [12, 13, 14], knowledge distillation [15, 16], weight sharing [17, 18], tensor decompositions [19, 20], etc. In recent years, shallow tensor networks (TN's) including matrix product state (MPS [21, 22], also known as tensor-train form [23]) and matrix product operator (MPO [24]) were applied to represent the tensors in neural networks, and achieved remarkable compression rates [25, 26, 27, 28, 29]. These inspiring successes strongly imply the existence of efficient mathematical structures over the simple multi-linear arrays for representing the variational parameters of NN's, which yet remains elusive.
In this work, we propose to adopt multi-layer TN [30] as an exceptionally efficient representation of variational parameters to fully exploit the compressibility of NN's. Our idea (illustrated in Fig. 1) is to encode the variational parameters of a considered NN layer into the contraction of a TN that contains exponentially fewer parameters. For instance, the number of parameters of the TN encoding \(2^{Q}\) parameters of NN just linearly as \(O(MQ)\), with \(M\sim O(1)\) the number of TN layers. Since the contraction process is differentiable, automatic differentiation technique [31, 32] is utilized to obtain the tensors of the TN to reach the optimal accuracy after compression. Thus we dub our scheme as automatically differentiable tensor network (ADTN).
The compression performance and generality of ADTN are demonstrated on various well-known NN's (FC-2, LeNet
Fig. 1: (Color online) The workflow of ADTN for compressing NN. (a) The illustration of a convolutional NN as an example, whose variational parameters (\(\mathbf{T}\)) are encoded in a ADTN shown in (b). The contraction of the ADTN results in \(\mathbf{T}\), in other words, where the ADTN contains much less parameters than \(\mathbf{T}\). In (c), we show the diagrammatic representation of the unitary conditions for the tensors in ADQC.
5 [33], and VGG-16 [34]) and datasets (MNIST [35] and CIFAR-10 [36]). For example, about \(10^{7}\) parameters in three convolutional layers of VGG-16 are compressed in three ADTNs with just \(632\) parameters, while the testing accuracy on CIFAR-10 is surprisingly improved from \(81.14\%\) of the original NN to \(84.36\%\) after compression. Such compression efficiency surpasses the state-of-the-art MPO method. Finally, we impose unitary conditions on the tensors of ADTN and propose automatically differentiable quantum circuit (ADQC [32]) to further reduce the parameter complexity. Our work implies a general way to reduce the excessive complexity of large-scale NN's by encoding the variational parameter into more compact and efficient mathematical form.
## II Method
A NN can be formally written as a mapping
\[\mathbf{y}=f(\mathbf{x};\mathbf{T},\mathbf{T}^{\prime},\ldots), \tag{1}\]
which maps the input features \(\mathbf{x}\) to the output vector \(\mathbf{y}\). We aim to compress the variational parameters \((\mathbf{T},\mathbf{T}^{\prime},\ldots)\) or a major part of them by ADTN. Note we do not assume the types of layers (linear, convolutional, etc.) in the NN as it makes no difference to our ADTN method.
Denoting the parameters to be compressed as tensor \(\mathbf{T}\), our idea is to represent \(\mathbf{T}\) as the contraction of ADTN with multiple layers. The structure of ADTN is flexible. Here, we choose the commonly used "brick-wall" structure; see an example of its diagrammatic representation in Fig. 1 (b). In simple words about the diagrammatic representation of TN, each block represents a tensor, and the bonds connected to a block represent the indexes of the corresponding tensor. Shared bonds represent the dumb indexes that should be summed up (contracted). The vertical black lines represent the activation function (e.g., ReLU). More details about TN contractions and the diagrammatic representation can be found in the Appendix B or Ref. [30].
For simplicity, we assume to compress \(2^{Q}\) variational parameters, i.e., \(\#(\mathbf{T})=2^{Q}\). Obviously, the contraction of ADTN should also give us a tensor (denoted as \(\mathbf{\mathcal{T}}\)) containing \(2^{Q}\) parameters. In our example, the ADTN results in a \(Q\)-th order tensor, where we take the dimension of each index as 2. These indexes are represented by the unshared bonds in the ADTN. See the blue bonds on the right boundary of the diagrammatic representation in Fig. 1 (b).
The main part of this exemplified ADTN is formed by the \((d\times d\times d\times d)\) tensors \(\{\mathbf{A}^{[k]}\}\) (\(k=0,\ldots,K-1\) with \(K\) their total number), which form the variational parameters of ADTN. We here take \(d=2\). On the left boundary of ADTN, we put several two-dimensional constant vectors \(\mathbf{v}\) for the convenience in formulating and analyzing. We may take \(\mathbf{v}=[1,0]\) for instance.
For the brick-wall structure, we define each \((Q-1)\) tensors in two neighboring columns [depicted in Fig. 1 (b)] as a TN layer. Contracting the tensors in one tensor layer essentially gives us a (\(2^{Q}\times 2^{Q}\)) matrix denoted as \(\mathbf{\mathcal{L}}\). The mapping represented by the whole ADTN can be written as
\[\mathbf{\mathcal{T}}=\mathbf{\mathcal{L}}\sigma(\ldots\mathbf{\mathcal{L}}\sigma(\mathbf{ \mathcal{L}}\sigma(\mathbf{\mathcal{L}}\prod_{\otimes q=1}^{Q}\mathbf{v}))), \tag{2}\]
with \(\otimes\) the tensor product and \(\sigma\) the activation function. In other words, \(\mathbf{\mathcal{T}}\) is obtained by implementing the mapping \(\sigma(\mathbf{\mathcal{L}}(*))\) for \(M\) times with \(M\) the number of TN layers. Be aware that one does not have to simulate the matrix \(\mathbf{\mathcal{L}}\), which is introduced here only for the convenience of understanding and expressing. The total number of variational parameters in such a brick-wall ADTN scales as
\[\#(\text{ADTN})\equiv\sum_{k}\#(\mathbf{A}^{[k]})\sim O(MQ), \tag{3}\]
with \(M\sim O(1)\) according to our results provided below. In plain words, we encode \(2^{Q}\) parameters in an ADTN that contains exponentially-fewer parameters.
There are two main stages to obtain \(\{\mathbf{A}^{[k]}\}\). The first is pretraining by minimizing the distance between \(\mathbf{T}\) and \(\mathbf{\mathcal{T}}\). We choose the loss function as Euclidean distance \(L^{\text{E}}=|\mathbf{\mathcal{T}}-\mathbf{\mathcal{T}}|\). After \(L^{\text{E}}\) converges, we start the second stage to minimize the loss function for implementing the machine learning task. One may choose the same loss function as the one used for training the NN, such as the cross entropy from the outputs of NN and the labels of the images' classifications. The feed-forward process is also the same as that for training the NN, except that the parameters (\(\mathbf{T}\)) of the target NN layer are replaced by the tensor (\(\mathbf{\mathcal{T}}\)) obtained by contracting the ADTN. Generally speaking, the first stage is to enhance the stability by finding a proper initialization of ADTN, and the second stage further improves the performance with an end-to-end optimization. The mapping given by NN in the second stage can be written as
\[\mathbf{y}=f(\mathbf{x};\{\mathbf{A}^{[k]}\},\mathbf{T}^{\text{res}}), \tag{4}\]
with \(\mathbf{T}^{\text{res}}\) denoting the uncompressed parameters.
The parameter complexity of ADTN can be further reduced by imposing unitary conditions on \(\{\mathbf{A}^{[k]}\}\). See the diagrammatic representation of the unitary condition in Fig. 1 (c). The ADTN formed by unitary tensors without activation functions is called ADQC [32], which was originally proposed for quantum state preparation [37]. The contraction of ADQC results in a unitary that "evolves the initial product state" \(\prod_{\otimes}\mathbf{v}\) to the final entangled state \(\mathbf{\mathcal{T}}\), in the terminology of quantum physics.
ADQC is expected to also possess generality for compressing NN thanks to its remarkable power on preparing a wide range of quantum states. One just needs to take care of the norm since unitary transformation preserves the norm, i.e., \(|\prod_{\otimes}\mathbf{v}|=|\mathbf{\mathcal{T}}|\). In our example where the dimension of tensors in ADTN is taken as \((2\times 2\times 2\times 2)\), the unitary conditions introduce additionally ten constraints for each tensor and reduce its number of free parameters from \(2^{4}\) to \(6=(16-10)\).
## III Results
Table I shows the performance of ADTN with \(M=1\) to compress various NN's. Our first example is FC-2 formed
by two linear layers, whose sizes are taken as \((784\times 256)\) and \((256\times 10)\), respectively (see Table III). We slice out \(2^{17}\) parameters from the first linear layer and compress them in an ADTN with 160 parameters. The testing accuracy on MNIST remains almost unchanged after compression.
Our second example is LeNet-5, which is a convolutional NN that contains three convolutional and two linear layers (see Table IV). Though LeNet-5 has much fewer parameters than FC-2, the more advanced and compact structure of the convolutional layers makes LeNet-5 to outperform FC-2 on processing images. We take \(2^{13}\) weights in the third convolutional layer and \(2^{15}\) weights in the first linear layer, which are respectively compressed to two ADTN's with in total 260 parameters. Still, the compression by ADTN does not cause any harm to the testing accuracy of LeNet-5, though LeNet-5 is already much more compact than FC-2.
Then we try to compress VGG-16, which is a much more complicated convolutional NN with thirteen convolutional and three linear layers (see Table V). We use three ADTNs with 632 parameters in total to compress \(2^{21}+2^{22}+2^{22}\simeq 10^{7}\) parameters in the last three convolutional layers. Amazingly, the testing accuracy increases for about \(2.2\%\) after such a significant compression.
By imposing unitary conditions, ADQC further reduces the number of parameters compared with ADTN, and manages to keep the testing accuracy unharmed compared with the original NN's. This demonstrates the astounding power of ADQC for squeezing out the parameter redundancy of NN.
We compare ADTN with the state-of-the-art compression scheme based on MPO [28, 29]. It is a mathematical structure generalized from the famous MPS [21, 22], and thus belongs to the shallow TN's. In contract, ADTN contains multiple layers of tensors, and belongs to the deep TN's. The testing accuracy \(\eta\) on CIFAR-10 after compressing the last three convolutional layers in VGG-16 versus the inverse of compression ratio \(1/\rho\) is shown in Fig. 2, where the compression ratio is defined as
\[\rho=\frac{\#(\text{ADTN})}{\#(\mathbf{T})}. \tag{5}\]
We vary the number of TN layers in ADTN from \(M=1\) to \(5\) to obtain different values of \(\rho\). Both ADTN and MPO improve the testing accuracy of the uncompressed NN (with \(\eta_{\text{NN}}=0.8114\)). ADTN demonstrates higher compression efficiency than MPO. For instance, to reach the test accuracy \(\eta\simeq 84\%\), MPO can reduce the number of parameters by about \(1/\rho\simeq 2000\) times, while ADTN reduces by more than \(1/\rho\simeq 17000\) times. For a similar compression ratio, say \(1/\rho\simeq 2000\) (see the vertical dash line), ADTN achieve higher testing accuracy (\(\simeq 0.857\)) than MPO (\(\simeq 0.833\)).
The superior performance of ADTN over MPO is consistent with the results for implementing quantum state preparation. In Ref. [32], the authors concluded that by writing an MPS to an ADQC acted on a trivial product state, the parameter complexity of the MPS can be significantly reduced, where the compression ratio approximately scales \(\rho\sim O(M\chi^{-2})\) with \(\chi\) a hyper-parameter of MPS to control its complexity. Thus, ADQC can compress the parameter complexity of MPS in most cases. The structure of MPO is essentially the same as MPS. It is reasonable that ADTN can compress MPO itself and thus surpass MPO for compressing NN's.
We further test ADTN by compressing different layers in VGG-16. The first column in Table II illustrates the amount of parameters in each layers, and the compressed ones are marked in red. In the first two cases where we compress the two or three layers with the highest parameter complexity, the training accuracy is almost \(100\%\) and the testing accuracy surpasses
\begin{table}
\begin{tabular}{|c|c c c c|c c c c c|} \hline & & \multicolumn{3}{c|}{**NN**} & \multicolumn{3}{c|}{**ADTN \& ADQC**} \\ \hline \multirow{2}{*}{**Dataset**} & \multirow{2}{*}{Model} & Testing & Total & Parameters & \multirow{2}{*}{\begin{tabular}{c} \# Compressed \\ layers (\(N\)) \\ \end{tabular} } & \multirow{2}{*}{\begin{tabular}{c} \# \\ unitary \\ (\(N\)) \\ \end{tabular} } & \multirow{2}{*}{\begin{tabular}{c} Total \\ parameters \\ (\(N\)) \\ \end{tabular} } & \multirow{2}{*}{\begin{tabular}{c} Testing \\ parameters \\ (\(N\)) \\ \end{tabular} } & \multirow{2}{*}{
\begin{tabular}{c} Compression \\ accuracy \\ (\(N\)) \\ \end{tabular} } \\ \hline \multirow{4}{*}{**MNIST**} & FC-2 & 97.94\% & 203530 & 131072 & No & 160 & 97.81\% & 99.69\% & \(1.2\times 10^{-3}\) \\ & & & & Yes & 80 & 97.79\% & 99.75\% & \(6.1\times 10^{-4}\) \\ \cline{2-10} & \multirow{2}{*}{LeNet-5} & \multirow{2}{*}{99.15\%} & \multirow{2}{*}{61706} & \multirow{2}{*}{40960} & No & 260 & 99.43\% & 100.25\% & \(6.4\times 10^{-3}\) \\ & & & & Yes & 130 & 99.40\% & 100.28\% & \(3.2\times 10^{-3}\) \\ \hline \multirow{2}{*}{**CIFAR-10**} & \multirow{2}{*}{VGG-16} & \multirow{2}{*}{81.14\%} & \multirow{2}{*}{14542474} & No & 632 & 84.36\% & 103.97\% & \(6.0\times 10^{-5}\) \\ & & & & Yes & 312 & 81.47\% & 100.40\% & \(3.0\times 10^{-5}\) \\ \hline \end{tabular}
\end{table} TABLE I: The performance (testing accuracy, compression radio, etc.) of ADTN and ADQC on compressing FC-2, LeNet-5 [33], and VGG-16 [34] trained for classifying the images in MNIST [35] and CIFAR-10 [36].
Fig. 2: (Color online) The testing accuracy \(\eta\) on CIFAR-10 of VGG-16 after compression versus the inverse of compression ratio (\(1/\rho\)). The last three convolutional layers are compressed by ADTN or MPO [28], respectively. The testing accuracy of VGG-16 before compression is \(\eta_{\text{NN}}=0.8114\), indicated by a horizontal dash line.
that of the original NN (\(\eta_{\text{NN}}=81.14\%\)). The ADTN with one TN layer (\(M=1\)) is sufficient to compress a minority of NN layers without harming the accuracies.
In the last column, we show the total compression ratio
\[\rho_{\text{tot}}=\frac{\#(\text{ADTN})+\#(\mathbf{T^{\text{res}}})}{\#(\text{NN})} \simeq\frac{\#(\mathbf{T^{\text{res}}})}{\#(\text{NN})}. \tag{6}\]
The approximation holds since in general we have \(\#(\text{ADTN})\ll\#(\mathbf{T^{\text{res}}})\ll\#(\text{NN})\). To further reduce \(\rho_{\text{tot}}\), one may consider to compress more layers by ADTN. In such cases, multiple TN layers are required to improve training and testing accuracies. For the example, to compress 12 layers in VGG-16, the testing accuracy is improved from \(72.13\%\) to \(78.95\%\) by increasing \(M\) from \(1\) to \(9\). The total compression ratio reaches \(\rho_{\text{tot}}\simeq 0.008\) (reducing for about \(1/\rho_{\text{tot}}\simeq 125\) times).
We finally compare the testing accuracies and (inverse of) compression ratios of ADTN and ADQC (Fig. 3). While all accuracies surpass that of the original VGG-16, ADTN achieves better accuracy than ADQC. This implies the additional compression by introducing unitary conditions will generally lower the accuracy (to a tolerable extent). Despite this, the validity of ADQC for compressing sheds light on applying quantum computing for compression. One just needs to restore all the parameters of the unitary tensors (quantum gates), and implement them on the initial product state \(\prod_{\otimes=1}^{Q}\mathbf{v}\). The tensor \(\mathbf{\mathcal{T}}\) can be reached by the quantum state tomography on the output state.
## IV Summary
In summary, we propose a general compression scheme to significantly reduces the variational parameters of neural networks (NN's). The key idea is to restore the high-order tensors that stores the variational parameters of NN by the contractions of multi-layer tensor networks (TN's), which contain exponentially less parameters than the high-order tensors. The performance of our scheme has been demonstrated on several well-known NN's including simple fully-connected NN and large-scale convolutional NN's. Our work suggest TN as a more efficient and compact mathematical form than high-order tensors to represent the variational parameters of NN's.
## Acknowledgments
We are indebted to Ze-Feng Gao for stimulative discussions. This work was supported by NSFC (Grant No. 12004266 and No. 11834014), Beijing Natural Science Foundation (Grant No. 1232025), Foundation of Beijing Education Committees (No. KM202010028013), and by the Academy for Multidisciplinary Studies, Capital Normal University.
## Appendix A Details of FC-2, LeNet-5, and VGG-16
Below, we provide the structure and hyper-parameters of the neural networks (FC2 in Table III, LeNet-5 in Table IV, and VGG-16 in Table V), for the convenience of reproducing our results.
\begin{table}
\begin{tabular}{c|c c c c c} \hline \begin{tabular}{c} Compressed \\ layers \\ _(and)_ \\ \end{tabular} & \begin{tabular}{c} Training \\ accuracy \\ (\(\bar{\eta}\)) \\ \end{tabular} & \begin{tabular}{c} Testing \\ accuracy \\ \end{tabular} & \begin{tabular}{c} Compression \\ \(\eta/\eta_{\text{NN}}\) \\ (\(\rho\)) \\ \end{tabular} & \begin{tabular}{c} Total \\ compression \\ ratio (\(\rho_{\text{tot}}\)) \\ \end{tabular} \\ \hline \multirow{4}{*}{\begin{tabular}{c} 1 \\ 3 \\ 5 \\ 5 \\ 100\% \\ \end{tabular} } & 19 & 98.9\% & 84.2\% & 103.86\% & \(5.0\times 10^{-5}\) \\ & 3 & 100\% & 85.5\% & 105.63\% & \(3.7\times 10^{-4}\) \\ & 5 & 100\% & 85.1\% & 105.63\% & \(3.7\times 10^{-4}\) \\ \hline \multirow{4}{*}{\begin{tabular}{c} 1 \\ 3 \\ 5 \\ 5 \\ 5 \\ 5 \\ 5 \\ 5 \\ 5 \\ 5 \\ 5 \\ 7 \\ \end{tabular} } & 19 & 99.9\% & 84.8\% & 103.9\% & 6.0 \(\times 10^{-5}\) \\ & 3 & 100\% & 85.1\% & 105.00\% & \(2.5\times 10^{-4}\) \\ & 5 & 100\% & 85.6\% & 105.66\% & \(4.0\times 10^{-4}\) \\ \hline \multirow{4}{*}{\begin{tabular}{c} 1 \\ 3 \\ 5 \\ 5 \\ 5 \\ 7 \\ 81.55\% \\ 9 \\ 81.95\% \\ \end{tabular} } & 19 & 98.8\% & 78.5\% & 96.7\% & 8.0 \(\times 10^{-5}\) \\ & 3 & 99.9\% & 83.2\% & 101.60\% & \(3.3\times 10^{-4}\) \\ & 5 & 100\% & 82.7\% & 102.02\% & \(5.9\times 10^{-4}\) \\ \hline \multirow{4}{*}{\begin{tabular}{c} 1 \\ 5 \\ 7 \\ 81.95\% \\ 9 \\ \end{tabular} } & 19 & 96.3\% & 65.93\% & 81.25\% & 1.0 \(\times 10^{-4}\) \\ & 3 & 99.94\% & 77.73\% & 95.78\% & \(4.2\times 10^{-4}\) \\ & 5 & 100\% & 79.15\% & 95.57\% & \(7.4\times 10^{-4}\) \\ & 7 & 100\% & 80.61\% & 99.35\% & \(1.1\times 10^{-3}\) \\ \hline \multirow{4}{*}{
\begin{tabular}{c} 3 \\ 5 \\ 7 \\ 9 \\ 81.95\% \\ \end{tabular} } & 37 & 75.78\% & 72.13\% & 88.90\% & \(1.0\times 10^{-4}\) \\ & 5 & 78.13\% & 74.24\% & 91.50\% & \(4.2\times 10^{-4}\) \\ & 7 & 81.54\% & 77.61\% & 95.65\% & \(7.4\times 10^{-4}\) \\ & 9 & 81.95\% & 78.59\% & 96.86\% & \(1.1\times 10^{-3}\) \\ \hline \end{tabular}
\end{table} TABLE II: The performance of ADTN on VGG-16 by compressing different NN layers. The parameter complexities of different layers of VGG-16 are illustrated by the lengths of bars in the first column, where the compressed ones are marked in red. The third and forth columns show the training and testing accuracies after compressing by ADTN with \(M\) TN layers. The fifth column show the testing accuracy after compression divided by that of the original VGG-16. The sixth and seventh columns show compression ratios for different layers and the total compression ratio [Eq. (6)].
Fig. 3: (Color online) The inverse of compression ratio \(1/\rho\) (left y-axis) and testing accuracy \(\eta\) (right y-axis) of compressing VGG-16 with ADTN and ADQC.
To explain how the high-order tensor \(\mathbf{\mathcal{T}}\) by contracting the ADTN, we show in Fig. 4 (a) and (b) the diagrammatic representations of two local contractions as an example. As shown in (a), the contraction of one tensor \(\mathbf{A}^{[0]}\) in ADTN and two vectors \(\mathbf{v}\) reads
\[u_{cd}^{[0]}=\sum_{ab}v_{a}v_{b}A_{abcd}^{[0]}. \tag{7}\]
Another example is the contraction shown in (b), which reads
\[w_{aefd}=\sum_{bc}u_{ab}^{[0]}u_{cd}^{[1]}A_{bcef}^{[3]}, \tag{8}\]
where \(\mathbf{u}^{[1]}\) denotes the contraction of \(\mathbf{A}^{[1]}\) and two \(\mathbf{v}\)'s. Generally speaking, the contraction formulas and their diagrammatic representations are in one-to-one correspondence. After contracting all shared bonds (indexes) by following the same rules as Eqs. (7) and (8), the ADTN results in a high-order tensor \(\mathbf{\mathcal{T}}\) that represents the variational parameters of NN, whose indexes are denoted by the blue bonds in (c).
With the presence of activations, the contractions should be done layer by layer, from left to right. After contracting one TN layer, each element of the obtained tensor will be put into the activation function. In the simulations, we take the ReLU activation, where an element \(x\) is mapped as
\[\sigma(x)=\max(0,x). \tag{9}\]
|
2305.17155 | Stability of implicit neural networks for long-term forecasting in
dynamical systems | Forecasting physical signals in long time range is among the most challenging
tasks in Partial Differential Equations (PDEs) research. To circumvent
limitations of traditional solvers, many different Deep Learning methods have
been proposed. They are all based on auto-regressive methods and exhibit
stability issues. Drawing inspiration from the stability property of implicit
numerical schemes, we introduce a stable auto-regressive implicit neural
network. We develop a theory based on the stability definition of schemes to
ensure the stability in forecasting of this network. It leads us to introduce
hard constraints on its weights and propagate the dynamics in the latent space.
Our experimental results validate our stability property, and show improved
results at long-term forecasting for two transports PDEs. | Leon Migus, Julien Salomon, Patrick Gallinari | 2023-05-26T13:58:48Z | http://arxiv.org/abs/2305.17155v2 | # Stability of Implicit Neural Networks for Long-term Forecasting in Dynamical Systems
###### Abstract
Forecasting physical signals in long time range is among the most challenging tasks in Partial Differential Equations (PDEs) research. To circumvent limitations of traditional solvers, many different Deep Learning methods have been proposed. They are all based on auto-regressive methods and exhibit stability issues. Drawing inspiration from the stability property of implicit numerical schemes, we introduce a stable auto-regressive implicit neural network. We develop a theory based on the stability definition of schemes to ensure the stability in forecasting of this network. It leads us to introduce hard constraints on its weights and propagate the dynamics in the latent space. Our experimental results validate our stability property, and show improved results at long-term forecasting for two transports PDEs.
## 1 Introduction and motivation
Numerical simulations are one of the main tools to study systems described by PDEs, which are essential for many applications including, e.g., fluid dynamics and climate science. However, solving these systems and even more using them to predict long term phenomenon remains a complex challenge, mainly due to the accumulation of errors over time. To overcome the limitations of traditional solvers and to exploit the available data, many different deep learning methods have been proposed.
For the task of forecasting spatio-temporal dynamics, Ayed et al. (2019) used a standard residual network with convolutions and Sorteberg et al. (2019); Lino et al. (2020); Fotiadis et al. (2020) used Long short-term memory (LSTM) and Convolutional neural network (CNN) for the wave equation. In Wiewel et al. (2019); Kim et al. (2019), a good performances is obtained by predicting within the latent spaces of neural networks. More recently, Brandstetter et al. (2022) used graph neural networks with several tricks and showed great results for forecasting PDEs solutions behavior. Importantly, these methods all solve the PDE iteratively, meaning that they are auto-regressive, the output of the model is used as the input for the next time step. Another line of recent methods that have greatly improved the learning of PDE dynamics are Neural Operators (Li et al., 2020). These methods can be used as operators or as auto-regressive methods to forecast. However, when used as operators, they do not generalize well beyond the times seen during training. Crucially, these auto-regressive methods tend to accumulate errors over time with no possible control, and respond quite poorly in case of change in the distribution of the data. This leads to stability problems, especially over long periods of time beyond the training horizon.
In the numerical analysis community, the stability issue has been well studied and is usually dealt with implicit schemes. By definition, they imply to solve an equation to go from a time step to the next one but they are generally more stable than explicit schemes. This can be seen on the test equation \(\frac{\mathrm{d}y}{\mathrm{d}t}=\lambda y\), where Euler implicit schemes are always stable while Euler explicit schemes are not. Interpreting residual neural networks as numerical schemes, one can apply such schemes and gain theoretical insights on the properties of neural networks. This has already been done in various forms in Haber and Ruthotto (2017); Chen et al. (2018), but not applied to forecasting. Moreover,
these works use either the stability of the underlying continuous equation or the stability of the numerical scheme on the test equation and its derivatives, which is not the stability of the numerical scheme on the studied equation. Since a network is discrete, the latter is the most relevant.
We therefore use the stability in norm of schemes, as defined in 2.1. In deep learning (DL), this definition has only been applied to image classification problems (Zhang and Schaeffer, 2020). To the best of our knowledge, this work is the first attempt to forecast PDEs with neural networks using stability as studied in the numerical analysis community.
Using implicit schemes in DL has already been done in different contexts. The earliest line of works tackles image problems, with Haber et al. (2019) designing semi-implicit ResNets and Li et al. (2020); Shen et al. (2020); Reshniak and Webster (2021) designing different implicit ResNets. The second line of works focuses on dynamical problems. In this way, Nonnenmacher and Greenberg (2021) designed linear implicit layers, which learn and solve linear systems, and Horie and Mitsume (2022) used an implicit scheme as part of an improvement of graph neural network solvers to improve forecasting generalization with different boundary condition shapes. Tackling different types of problems, none of these methods guarantees the forecast stability. For our analysis, we restrict ourselves to ResNet-type networks, i.e., networks with residual connections. We introduce hard constraints on the weights of the network and predict within the latent space of our network. Hence, by modifying the classic implicit ResNet architecture, our method can forecast dynamical system at long range without diverging. We apply these theoretical constraints in our architecture to two 1D transport problems: the _Advection equation_ and _Burgers' equation_.
To better investigate networks stability, we perform our experiments under the following challenging setting: for training, we only give to the networks the data from \(t=0\) to a small time \(t=\Delta t\), and consider the results in forecasting in the long time range at \(t=N\cdot\Delta t\), with \(N\gg 1\). Note that our setting is harder that the conventional setting presented for e.g. in Brandstetter et al. (2022). Indeed, we only use changes between a single time step for training.
## 2 Method
To guarantee structural forecasting stability, we take inspiration from implicit schemes. We focus our study on an implicit ResNet with a ReLU activation function. In our approach, an equation is solved at each layer, namely \(x_{n+1}:=x_{n}+R_{n}(x_{n+1})\) with \(x\) in \(\mathbb{R}^{M}\) and \(n\) in \(\mathbb{N}\) and \(R_{n}(x)=\text{ReLU}(W_{n}x+b_{n})\) where \(W_{n}\) is upper triangular. The latter constraint is motivated below.
### Implicit ResNet stability analysis
To ensure that our proposed architecture is well-defined, we need to solve \(x=x_{n}+R_{n}(x)\). This equation has a solution, as proven in El Ghaoui et al. (2019) and detailed in Appendix 5.1. We can then study its stability. The recursion defining \((x_{n})_{n\in\mathbb{N}}\) reads as an implicit Euler scheme with a step size of 1. As described in the introduction, an implicit scheme is usually more stable than an explicit one. We first recall the definition of stability for schemes. This property ensures that our architecture has an auto-regressive stability.
**Definition 2.1** (Stability in norm).: _A scheme \((x_{n})_{n\in\mathbb{N}}\) of dimension \(M\) is stable in norm \(L^{p}\) if there exists \(C(T)\) independent of the time discretization step \(\Delta t\) such that:_
\[\forall\;x_{0}\in\mathbb{R}^{M},\;n\geq 0;\;n\Delta t\leq T,\;\|x_{n}\|_{p} \leq C(T)\|x_{0}\|_{p}\,.\]
This general definition of stability in norm ensures that a scheme does not amplify errors. This definition is equivalent to several others in the numerical analysis community.
Suppose that the spectrum of \(W_{n}\) is contained in \([-1,0[\) for every integer \(n\), we can assert that \((x_{n})_{n\in\mathbb{N}}\) is well-defined, using theorem 5.2. The proof of the stability of our Implicit ResNet network is then by induction on the dimension and is given in appendix 5.4:
**Theorem 2.1** (Stability theorem).: _If the elements of the diagonal of \(W_{n}\) are in \([-1,0)\) for every integer \(n\), then \((x_{n})_{n\in\mathbb{N}}\) is stable in norm \(L^{p}\)._
This theorem leads to hard constraints on the weights of the network.
### Implementation
To validate practically our theoretical results, we choose a setting that highlights stability issues. We then test our implementation of an implicit ResNet. In order to respect the assumptions of theorem 2.1, we forecast the dynamics in the latent space, as detailed below.
SettingWe first learn the trajectory at a given small time step \(\Delta t\). We only give data \(t=0\) to \(t=\Delta t\) for the training. We then forecast in long-term, at \(N\cdot\Delta t\) with \(N\gg 1\). This very restricted setting allows us to see how the network will react in forecasting with changes in the distribution and error accumulation. Usually neural network forecasting methods use data from \(t=0\) to \(T=L\cdot\Delta t\) for the training which allows to use different tricks to stabilize the network, such as predicting multiple time steps at the same time. However, in this work, we want to analyze how the network behaves without any trick that can slow down divergence. Indeed, the tricks used in the other settings do not actually guarantee stability of the network. The training is performed with a mean-squared error (MSE) loss.
Implicit neural network architectureTo implement a neural network from Theorem 2.1, we use the following architecture; \(z_{\Delta t}=f_{dec}\circ f^{K}_{res}\circ...\circ f^{1}_{res}\circ f_{enc}(z_ {0})\), with \(f^{k}_{res}(x)=x+\text{ReLU}(W_{k-1}\cdot f^{k}_{res}(x)+b_{k-1})\). The encoder and decoder are linear, and the encoder projects the data to a smaller dimension \(M\). The full architecture is illustrated in Figure 2. The specificity of our architecture is that the residual blocks are connected with an implicit Euler scheme iteration. To do so, we use a differentiable root-finding algorithm (Kasim and Vinko, 2020). More precisely, we use the first Broyden method van de Rotten and Lunel (2005) to solve the root-finding problem. It is a quasi-Newton method. This helped getting better results compared to other algorithms.
Latent space forecastingAs in Wiewel et al. (2019); Kim et al. (2019), the forecast can be done within the latent space of the network; \(z_{N\cdot\Delta t}=f_{dec}\circ f_{block}\circ...\circ f_{block}\circ f_{enc}(z_ {0})\), with \(f_{block}=f^{K}_{res}\circ...\circ f^{1}_{res}\). To predict at time \(N\cdot\Delta t\) from time \(t=0\), we apply \(N\) times the residual blocks. It is illustrated in Figure 4. This propagation allows our network to respect the assumptions of theorem 2.1 and thus be stable.
## 3 Experiments
We evaluate the performance of our method on the _Advection equation_ and _Burgers' equation_.
Datasets_Advection equation_. We construct our first dataset with the following 1-D linear PDE, \(\frac{\partial\psi}{\partial t}=-\frac{1}{2}\frac{\partial\psi}{\partial z},z \in(0,2\pi)\), \(t\in\mathbb{R}^{+}\) and \(\psi(z,0)=f_{0}(z),z\in(0,2\pi)\).
Burgers' equation.In the second dataset, we consider the following 1-D non-linear PDE, \(\frac{\partial\psi}{\partial t}=-\frac{1}{2}\frac{\partial\psi^{2}}{\partial z }+\frac{\partial^{2}\psi^{2}}{\partial z},z\in(0,2\pi),\)\(t\in(0,1]\) and \(\psi(z,0)=f_{0}(z),z\in(0,2\pi)\).
Both equations have periodic boundary conditions. We approximate the mapping from the initial condition \(f_{0}\) to the solution at a given discretization time \(\Delta t\), i.e. \(u_{0}\mapsto u(\cdot,\Delta t)\). We then forecast to longer time ranges. \(\Delta t\) is set to 1 for the _Advection equation_ with a grid of 100 points and 0.0005 for _Burgers' equation_ with a grid of 128 points.
Baseline methodsWe compare our Implicit ResNet with respect to an Explicit ResNet with ReLU activation function and a Fourier Neural Operator (FNO) (Li et al., 2020). We have also implemented two Explicit ResNet, with a tanh activation function and with batch normalization. We design the Explicit ResNet in the same way as our implicit version, with \(K\) layers of residual blocks that are linked by \(x_{n+1}=x_{n}+R_{n}(x_{n})\). Traditional methods forecast by using the output of the network at time \(t\) to predict the dynamics at time \(t+\Delta t\). So to predict at time \(N\cdot\Delta t\) from time \(t=0\), the baseline networks are iteratively applied \(N\) times, as illustrated in Figure 3.
ResultsPrediction errors are reported in Table 1 for the _Advection equation_ and _Burgers' equation_. We also show the error according to the forecast time in Figure 1.
We found that traditional deep learning methods diverge with the forecast time. They reach a MSE of more than \(10^{8}\) for the _Advection equation_ and go to infinity for _Burgers' equation_, respectively at
time \(400\) and \(0.15\). Moreover, we see in Figure 1 that their curve in time is convex, so the increase in error is accelerating over time. We also found that our proposed Implicit ResNet presents better results by several orders of magnitude for both datasets. Moreover, we can see in Figure 1 that its curve in time is reaching a stable plateau, as expected from our theorem 2.1.
As for the training, traditional deep learning methods manage to learn very well the dynamics at \(t=\Delta t\), with two orders of magnitude better than our Implicit ResNet. However, the latter still manages to learn well the dynamics with a MSE of \(10^{-2}\) for the _Advection equation_ and \(10^{-3}\) for _Burgers' equation_. This difference in training can mainly be explained by the longer training time of the Implicit ResNet, which made us take a smaller number of epochs for this network (1250 against 2500).
DiscussionFigure 1 demonstrates the main benefits of our constrained implicit neural network. Our network is stable whereas the other methods diverge in time. However, although being stable and far better than the baselines, it does not manage to forecast accurately the long-term dynamics. This is further confirmed by Table 4, which shows high relative errors. Said otherwise, when stability is guaranteed, convergence is not. We can also note that constraining the weights makes our network harder to train, but guarantees structural forecasting stability.
## 4 Conclusion
In this work, we studied the challenging task of long-term forecasting in dynamical systems. To do so, we developed a theoretical framework to analyze the stability of deep learning methods for forecasting dynamical systems. We then designed a constrained implicit neural network out of this framework. To the best of our knowledge, this is the first work that proposes to study deep learning architectures for forecasting dynamical systems from a numerical schema standpoint. We showed improved results with respect to deep learning baselines for two transport PDEs.
This work opens new perspectives to study neural networks forecasting stability from a numerical schema standpoint, thus offering more robust architectures. However, this analysis still needs improvements. Even though it ensures forecasting stability of our proposed network, it does not guarantee good convergence properties. We believe that developing this line of research could help overcome these challenges, and provide more robust architectures for forecasting dynamical systems in long time range.
## Acknowledgments
We thank Yuan Yin and Etienne Le Naour for helpful insights and discussions on this project.
|
2310.01595 | Memory-efficient particle filter recurrent neural network for object
localization | This study proposes a novel memory-efficient recurrent neural network (RNN)
architecture specified to solve the object localization problem. This problem
is to recover the object states along with its movement in a noisy environment.
We take the idea of the classical particle filter and combine it with GRU RNN
architecture. The key feature of the resulting memory-efficient particle filter
RNN model (mePFRNN) is that it requires the same number of parameters to
process environments of different sizes. Thus, the proposed mePFRNN
architecture consumes less memory to store parameters compared to the
previously proposed PFRNN model. To demonstrate the performance of our model,
we test it on symmetric and noisy environments that are incredibly challenging
for filtering algorithms. In our experiments, the mePFRNN model provides more
precise localization than the considered competitors and requires fewer trained
parameters. | Roman Korkin, Ivan Oseledets, Aleksandr Katrutsa | 2023-10-02T19:41:19Z | http://arxiv.org/abs/2310.01595v1 | # Memory-efficient particle filter recurrent neural network for object localization
###### Abstract
This study proposes a novel memory-efficient recurrent neural network (RNN) architecture specified to solve the object localization problem. This problem is to recover the object states along with its movement in a noisy environment. We take the idea of the classical particle filter and combine it with GRU RNN architecture. The key feature of the resulting memory-efficient particle filter RNN model (mePFRNN) is that it requires the same number of parameters to process environments of different sizes. Thus, the proposed mePFRNN architecture consumes less memory to store parameters compared to the previously proposed PFRNN model. To demonstrate the performance of our model, we test it on symmetric and noisy environments that are incredibly challenging for filtering algorithms. In our experiments, the mePFRNN model provides more precise localization than the considered competitors and requires fewer trained parameters.
## 1 Introduction
We consider the object localization problem and propose a novel GRU-like architecture to solve it. Typically standard GRU-like models [1] are used to process sequential data, e.g. to predict the next item in a sequence, and classify or generate texts, audio, and video data. The object localization problem differs from the aforementioned problems since auxiliary data about the environment and particular measurements are available. Therefore, this additional knowledge should be incorporated into the GRU architecture properly. Such a modification can be based on the existing approaches to solve the object localization problem, which are discussed further.
One of the classical non-parametric methods to solve the object localization problem is particle filter [2], which estimates the filtered object state from the states of auxiliary artificial objects that are called particles. A modification of GRU and LSTM recurrent neural networks with particle filter ingredients is presented in [3], where a particle filter recurrent neural network (PFRNN) is proposed. The core element of PFRNN is the modified cell (GRU or LSTM) equipped with analogs of particles and the corresponding weights of particles to estimate the filtered state. However, PFRNN improves the performance of the general sequential data processing and does not consider specific features of the object localization problem. Therefore, we propose the novel _memory-efficient PFRNN (mePFRNN)_ that combines the model assumptions used in the classical filtering methods (e.g. Kalman filter and particle filter) and parametrization from the GRU architecture. Such a combination provides more accurate state estimation and improves robustness in noisy and symmetric environments. Also, the Soft resampling procedure is used to avoid the degeneracy issue and improve the stability of the filtered states.
The main contributions of our study are the following.
1. We propose a modification of the PFRNN architecture specified for the object localization problem. The proposed mePFRNN model does not exploit environment embeddings and extracts this data implicitly in the training stage.
2. We perform an extensive experimental comparison of the proposed GRU-like architecture with the existing recurrent neural networks and other non-parametric methods like the particle filter.
3. The proposed mePFRNN model requires the same number of parameters for environments of different sizes.
Related works.The object localization problem appears in a lot of applications like driving autonomous vehicles [4], navigation [5, 6], image processing [7], finance [8] and fatigue predictions [9]. Therefore, there are a lot of different approaches to solving it. We can split them into two classes: non-parametric and parametric. The first class consists of classical methods that do not require a training stage and perform filtering of the object states on the fly. Examples of such methods are Kalman filter [10, 11], and its modifications like extended [12], unscented [13], invariant extended [14] and ensembled [15] Kalman filters. Also, methods related to the particle filter, e.g. multiparticle Kalman filter [16], particle filters combined with genetic algorithms [17], and particle swarm technique [18], box particle filter [19] and others are non-parametric filtering methods. The second class consists of parametric methods such that a pre-training stage is necessary before starting filtering. Such methods are typically based on neural networks that are trained on the collected historical data and then tested on the new data from real-world simulations. Although the pre-training stage may require a lot of time, one can expect that the inference stage, in which filtering is performed, is sufficiently fast due to modern hardware acceleration. Moreover, since the neural network models can efficiently treat sequential data [20, 21], the parametric methods can provide more accurate filtering results compared to non-parametric methods.
Although the Transformer model [22] demonstrates superior performance over the considered GRU RNN in sequence processing tasks, it consumes a lot of memory to store parameters, requires special techniques for training [23] and may not fit in the on-device memory limits. The memory-efficient Transformer models [24, 25, 26] may be a remedy for the observed issue and will be investigated in future work.
## 2 Problem statement
Consider the trajectory of object states encoded as a sequence of \(d\)-dimensional vectors \(\mathbf{x}_{i}\in\mathbb{R}^{d}\), where \(i\) is an index of the time moment \(t_{i}\). For example, if the object's state consists of 2D coordinates and 2D velocity, then state dimension \(d=4\). The states are changed according to the motion equation, which combines the physical law and the control system of the object. Formally we can write the motion equation as follows
\[\mathbf{x}_{i}=f(\mathbf{x}_{i-1},\mathbf{u}_{i},\boldsymbol{\eta}_{i}), \tag{1}\]
where \(\mathbf{u}_{i}\) is a vector of control at the time moment \(t_{i}\), for example, external forces, and \(\boldsymbol{\eta}_{i}\) is a vector of noise corresponding to the object motion at the time moment \(t_{i}\). Since the object moves with some noise, we should use additional measurements to estimate states more precisely. Typically there are several beacons in the environment, which are used by objects to measure some quantities that can improve their state estimate. For example, distance to the \(k\)-nearest beacons can improve the estimate of the object's location. Formally, denote by \(\mathbf{y}_{i}\in\mathbb{R}^{k}\) a vector of measurements at time moment \(t_{i}\) that is related with state estimate through the measurement function \(g:\mathbb{R}^{d}\rightarrow\mathbb{R}^{k}\):
\[\mathbf{y}_{i}=g(\mathbf{x}_{i},\boldsymbol{\zeta}_{i}), \tag{2}\]
where \(\boldsymbol{\zeta}_{i}\) is the additional noise of measurement.
Object localization problem is the problem of estimating object trajectory from the given motion and measurement functions that represent the physical law of the environment and beacons' configuration, respectively. In this study, we introduce the parametric model \(h_{\boldsymbol{\theta}}:\mathbb{R}^{d}\times\mathbb{R}^{k}\times\mathbb{R}^{ n}\rightarrow\mathbb{R}^{d}\) that depends on the unknown parameters \(\boldsymbol{\theta}\in\mathbb{R}^{n}\) and performs filtering of the inexact state estimate \(\mathbf{x}_{i}\) based on the additional measurements \(\mathbf{y}_{i}\). Assume we have training trajectory of the ground-truth states \(\{\mathbf{x}_{i}^{*}\}_{i=1}^{N}\). Then we can state the optimization problem to fit our parametric model to the training data \(\{\mathbf{x}_{i}^{*}\}_{i=1}^{N}\) and evaluate the generalization ability of the resulting model. In particular, the standard loss function in such a problem is the mean square error loss function
\[MSE=\frac{1}{N}\sum_{i=1}^{N}\|h_{\boldsymbol{\theta}}(\mathbf{x}_{i},\mathbf{ y}_{i})-\mathbf{x}_{i}^{*}\|_{2}^{2} \tag{3}\]
such that the motion function \(f\) and the measurement functions \(g\) give the state estimate \(\mathbf{x}_{i}\) and measurement vector \(\mathbf{y}_{i}\), respectively.
We further focus on the plane motion setup, where the state vector consists of 2D coordinates \(\mathbf{c}\in\mathbb{R}^{2}\) and a heading \(\alpha\in[0,2\pi]\), which defines the direction of movement, i.e. \(\mathbf{x}=[\mathbf{c},\alpha]\in\mathbb{R}^{3}\). Therefore, we follow [3] in slightly
adjusting the MSE objective function (3) to treat coordinates and angles separately and compose the weighted MSE loss function:
\[wMSE=\underbrace{\frac{1}{N}\sum_{i=1}^{N}\|\mathbf{c}_{i}-\mathbf{c}_{i}^{*}\|_ {2}^{2}}_{=\mathrm{MSE}_{c}}+\frac{\beta}{N}\sum_{i=1}^{N}(\alpha_{i}-\alpha_{i }^{*})^{2},\quad\text{where}\quad[\mathbf{c}_{i},\alpha_{i}]=h_{\boldsymbol{ \theta}}(\mathbf{x}_{i},\mathbf{y}_{i}),\quad\mathbf{x}_{i}^{*}=[\mathbf{c}_{ i}^{*},\alpha_{i}^{*}], \tag{4}\]
where \(\beta>0\) is a given weight. However, the \(wMSE\) loss function treats angles \(2\pi-\epsilon\) and \(\epsilon\) as essentially different while they are physically close. Thus, we propose a novel modification of the mean squared loss function (3), that treats headings differently. In particular, we compare not angles but their sine and cosine in the following way:
\[L(\boldsymbol{\theta})=\mathrm{MSE}_{c}+\frac{\beta}{N}\sum_{i=1}^{N}\left[( \sin\alpha_{i}-\sin\alpha_{i}^{*})^{2}+(\cos\alpha-\cos\alpha_{i}^{*})^{2} \right], \tag{5}\]
where we use the same notation as in (4). Thus, we have the following optimization problem:
\[\boldsymbol{\theta}^{*} =\arg\min_{\boldsymbol{\theta}}L(\boldsymbol{\theta}),\] (6) s.t. \[\mathbf{x}_{i} =f(\mathbf{x}_{i-1},\mathbf{u}_{i},\boldsymbol{\eta}_{i})\] \[\mathbf{y}_{i} =g(\mathbf{x}_{i},\boldsymbol{\zeta}_{i}).\]
Additionally to the MSE-like loss function, we evaluate the resulting model with the Final State Error (FSE) loss function, which reads as
\[\mathrm{FSE}=\|\mathbf{c}_{N}-\mathbf{c}_{N}^{*}\|_{2}, \tag{7}\]
where \([\mathbf{c}_{N}^{*},\alpha_{N}^{*}]=\mathbf{x}_{N}^{*}\), \([\mathbf{c}_{N},\alpha_{N}]=h_{\boldsymbol{\theta}}(\mathbf{x}_{N},\mathbf{y }_{N})\) and \(t_{N}\) is a last-time moment in the considered period. Although the FSE loss function is widely used in previous studies [3, 27], it may overestimate the filter performance due to the uncertainty in the filtering process. The final coordinates may be filtered very accurately by accident while filtering the previous coordinates may be quite poor. Thus, we focus on the \(\mathrm{MSE}_{c}\) loss function as the main indicator of the filter performance.
The key ingredient of this approach is the selection of the proper parametric model \(h_{\boldsymbol{\theta}}\). Following [3] we modify the GRU model such that it solves the object localization problem specifically. A detailed description of our modification is presented in the next section.
## 3 Particle filter
One of the most efficient non-parametric approaches to solving the localization problem is the particle filter. This filter considers artificially generated particles with states \(\mathbf{p}_{i}^{(k)}\in\mathbb{R}^{d}\) at the \(i\)-th time step and the corresponding weights \(w_{i}^{k}\geq 0,\sum_{k=1}^{K}w_{i}^{k}=1\) such that the estimate of the object state at the \(i\)-th time step is computed as follows
\[\tilde{\mathbf{x}}_{i}=\sum_{k=1}^{K}w_{i}^{k}\mathbf{p}_{i}^{(k)},\]
where \(K\) is the number of particles. Particles' weights are updated according to the corresponding measurements and state updates based on the Bayes rule and likelihood estimation, see [28] for details. The important step in the particle filter is resampling, which corrects the updated particle weights and states to improve the accuracy of estimate \(\tilde{\mathbf{x}}_{i}\). The resampling step addresses the degeneracy issue, which means a few number of particles have non-zero weights. This phenomenon indicates the poor representation of the target object state. The purely stochastic resampling samples particles' indices from the multinomial distribution according to the updated weights and then update particle states, respectively, see (8). After resampling the resulting particle states are slightly perturbed with random noise to avoid equal particles' states.
\[\begin{split}& i_{1},\ldots,i_{K}\sim\mathrm{Multinomial}(w_{i+1}^{ 1},\ldots,w_{i+1}^{K})\\ &\mathbf{p}_{i+1}^{1},\ldots,\mathbf{p}_{i+1}^{K}\leftarrow \mathbf{p}_{i+1}^{i_{1}},\ldots,\mathbf{p}_{i+1}^{i_{K}}\\ & w_{i+1}^{k}=\frac{1}{K}.\end{split} \tag{8}\]
Since the particle filter processes sequential data through the recurrent updates of the particles and weights, the natural idea is to incorporate a similar approach in the recurrent neural network architecture. The particle filter recurrent neural network is proposed in [3] and we briefly describe it in the next section to highlight the difference with the proposed mePFRNN.
## 4 Recurrent neural networks inspired by particle filter
This section presents our RNN cell based on the particle filter idea, explicitly measured data, and beacons' positions. Since our model is a modification of the PFRNN [3] model, we briefly provide the main ingredients of this model.
PFRNN.Denote by \(K\) a number of particles that are emulated in the PFRNN model. Below we consider motion \(\mathbf{x}_{i}^{(k)}\) and measurement \(\mathbf{y}_{i}^{(k)}\) vectors corresponding to the \(k\)-th particle at the \(i\)-th time moment, so \(k=1,\ldots,K\) and \(i=1,\ldots,N\). PFRNN considers the environment as a 2D array and constructs its embedding through the following encoder subnetwork:
\[\mathrm{Conv}\rightarrow\mathrm{ReLU}\rightarrow\mathrm{Conv}\rightarrow \mathrm{ReLU}\rightarrow\mathrm{Conv}\rightarrow\mathrm{ReLU}\rightarrow \mathrm{Flatten}\rightarrow\mathrm{Linear}\rightarrow\mathrm{ReLU}, \tag{9}\]
where \(\mathrm{Conv}\) is a convolution layer, \(\mathrm{ReLU}\) denotes element-wise ReLU non-linearity, \(\mathrm{Linear}\) denotes a linear layer and \(\mathrm{Flatten}\) denotes a vectorization operation that reshapes the input tensor to a vector. The output of this subnetwork is the environment embedding vector \(\mathbf{e}_{env}\). At the same time, the embeddings for observations \(\mathbf{y}_{i}^{(k)}\) and motions \(\mathbf{x}_{i}^{(k)}\) are constructed via two linear layers and followed by ReLU activations and denoted by \(\mathbf{n}_{i}^{(k)}\) and \(\mathbf{m}_{i}^{(k)}\), respectively. Note that the dimensions of \(\mathbf{n}_{i}^{(k)}\) and \(\mathbf{m}_{i}^{(k)}\) are the same. Then, one transforms the environment embedding \(\mathbf{e}_{env}\) to adjusted embeddings \(\hat{\mathbf{n}}_{i}^{(k)}\) and \(\hat{\mathbf{m}}_{i}^{(k)}\) via two linear layers and followed ReLU activations. Now, the dimensions of \(\hat{\mathbf{n}}_{i}^{(k)}\), \(\hat{\mathbf{m}}_{i}^{(k)}\), \(\mathbf{n}_{i}^{(k)}\) and \(\mathbf{m}_{i}^{(k)}\) are the same. Finally, the input to the PFRNN cell described below (see (11)) is a set of vectors \(\mathbf{v}_{i}^{(k)}\) composed by concatenation of vectors \(\hat{\mathbf{n}}_{i}^{(k)}\odot\mathbf{n}_{i}^{(k)}\) and \(\hat{\mathbf{m}}_{i}^{(k)}\odot\mathbf{m}_{i}^{(k)}\), where \(\odot\) denotes element-wise product.
The baseline PFRNN cell is presented in both a graphical way (see Figure 1) and an analytical way (see equation (11)) for the reader's convenience. We note that this cell includes a reparametrization trick and updates not only the hidden states for every particle \(\mathbf{h}_{i}^{(k)}\) but also the corresponding weights \(w_{i}^{(k)}\) that are used in the resampling step. These weights typically correspond to the probability of the particle being equal to the ground-truth object state. However, in our experiment such weights are the logarithm of the corresponding probabilities, therefore the normalization step after update has the given form (see the last line in (11). After that, we adjust the resampling step to deal with the logarithms of the weights properly, see the paragraph below.
Resampling procedure.After the inference stage in the considered RNN cells, one has to make resampling, to mitigate the potential degeneracy problem. There are different approaches to performing resampling [29, 30]. The main requirement for the resampling procedure in the parametric model is to be differentiable. Therefore, the stochastic resampling (8) is not directly fitted to the considered model. Instead, the Soft Resampling procedure [3] was proposed as a trade-off between the accuracy and the related costs. This approach to resampling considers a mixture of the distribution induced by weights and the uniform distribution with probabilities \(1/K\). Therefore, the formula for updating weights and hidden states reads as follows.
\[\begin{split}& i_{1},\ldots,i_{K}\sim\mathrm{Multinomial}(\alpha w_{i+ 1}^{1}+(1-\alpha)/K,\ldots,\alpha w_{i+1}^{K}+(1-\alpha)/K)\\ &\mathbf{h}_{i+1}^{1},\ldots,\mathbf{h}_{i+1}^{K}\leftarrow \mathbf{h}_{i+1}^{i_{1}},\ldots,\mathbf{h}_{i+1}^{i_{K}}\\ & w_{i+1}^{k}\leftarrow\frac{w_{i+1}^{i_{k}}}{\alpha w_{i+1}^{i_{ k}}+(1-\alpha)/K},\end{split} \tag{10}\]
where \(\alpha>0\) to make the operation differentiable. Note that similar to the stochastic resampling, the updated hidden states \(\mathbf{h}_{i}^{k}\) are slightly perturbed. Section 5 provides more details on the usage of soft resampling in our experiments.
mePFRNN.Since PFRNN encodes the environment with the convolution operation, it requires training a number of parameters proportional to the environment size. To reduce the number of trainable parameters, we do not use the data about an environment as input to our model since such data, like beacons' and obstacles' positions, have to be implicitly extracted in the training stage. We expect such behavior of the considered mePFRNN since the environment is the external factor to the localization problem and stays the same over the particular trajectory. The motion and measurement vectors corresponding to every particle are embedded into a high dimensional space via linear layer and ReLU non-linearity. Then, the obtained embeddings are concatenated and processed by a linear layer with LeakyReLU non-linearity. The result of the latter operation is motion embedding \(\mathbf{e}_{\mathbf{u}}^{(k)}\) for every particle, which is additional input to the proposed mePFRNN cell. The encoding procedure described above is summarized in scheme (12).
\[\mathbf{x}_{i}^{(k)}\rightarrow\mathrm{Linear}\rightarrow\mathrm{ ReLU}\searrow \tag{12}\] \[\mathbf{y}_{i}^{(k)}\rightarrow\mathrm{Linear}\rightarrow\mathrm{ ReLU}\nearrow\]
Thus, mePFRNN is a voxel-independent model that can be easily used in very large environments without increasing the number of trainable parameters. One more benefit of the proposed approach becomes crucial if the beacons in the environment are located not in the middle of the artificially generated voxels in the PFRNN model. These voxels compose a grid for the considered environment to identify the beacons and obstacles with convolution encoding. In this case, the convolution operation does not adequately encode the beacons' positions and makes further filtering more noisy. The resulting cell is shown in Figure 2 graphically and in equations (13) analytically, where \(MLP\) consists of two sequential linear layers and intermediate \(\mathrm{LeakyReLU}\) nonlinearity. Note that, the Soft Resampling procedure is also used here similar to the PFRNN model described above.
\[\mathbf{e}_{i}^{(k)}= [\mathbf{e}_{\mathbf{u}}^{(k)},\mathbf{y}_{i}^{(k)}] \tag{13}\] \[\mathbf{z}_{i}^{(k)}= \sigma(\mathbf{W}_{z}[\mathbf{h}_{i-1}^{(k)},\mathbf{e}_{i}^{(k)}]+ \mathbf{b}_{z})\] \[\mathbf{r}_{i}^{(k)}= \sigma(\mathbf{W}_{r}[\mathbf{h}_{i-1}^{(k)},\mathbf{e}_{i}^{(k)}]+ \mathbf{b}_{r})\] \[\mathbf{\mu}_{i}^{(k)}= \mathbf{W}_{\mathbf{\mu}}[\mathbf{r}_{i}^{(k)}\odot\mathbf{h}_{i-1}^{(k)},\mathbf{e}_{i}^{(k)}]+\mathbf{b}_{\mathbf{\mu}}\] \[\mathbf{\Sigma}_{i}^{(k)}= \mathbf{W}_{\mathbf{\Sigma}}[\mathbf{r}_{i}^{(k)}\odot\mathbf{h}_{i-1}^{(k) },\mathbf{e}_{i}^{(k)}]+\mathbf{b}_{\mathbf{\Sigma}}\] \[\epsilon\sim \mathcal{N}(0,\mathbf{I})\] \[\mathbf{h}_{i}^{(k)}= \mathrm{LeakyReLU(BN}(\mathbf{\mu}_{i}^{(k)}+\mathbf{\Sigma}_{i}^{(k)} \odot\epsilon))\] \[\mathbf{h}_{i}^{(k)}= (1-\mathbf{z}_{i}^{(k)})\odot\mathbf{d}_{i}^{(k)}+\mathbf{z}_{i}^ {(k)}\odot\mathbf{h}_{i-1}^{(k)}\] \[\mathbf{p}_{i}^{(k)}= \mathbf{W}_{w}[\mathbf{o}_{i},\mathbf{h}_{i}^{(k)}]+b_{w}\] \[w_{i}^{(k)}= \mathbf{p}_{i}^{(k)}+w_{i-1}^{(k)}-\] \[-LogSumExp(\mathbf{p}_{i}^{(k)}+w_{i-1}^{(k)})\]
Figure 1: Baseline PFRNN cell design, where \(\mathbf{a},\mathbf{o},\mathbf{z},\mathbf{c}\) denote the linear layers that are used in computing the corresponding intermediate embeddings. For simplicity, we skip the superscript \(k\) that indicates the particle index. This cell updates both particle hidden states and weights. Denote element-wise addition and multiplication by \(+\) and \(\odot\).
Figure 2: The proposed mePFRNN cell. Square block means elementwise square of the input. MLP consists of two sequential linear layers and LeakyReLU intermediate nonlinearity. Other notation is similar to the PFRNN.
Alternative GRU-based models.In addition to the proposed mePFRNN model, we also propose two approaches to exploiting the classical GRU model (see Figure 3 and equations (14)) in the object localization problem. Namely, the EnsembleGRU model consists of many small GRU cells whose predictions are averaged to estimate the target object state. The number of models in the ensemble and the number of trained parameters in every model are selected such that the total number of the trained parameters is approximately equal to # parameters in PFRNN times # particles. The complementary approach is just to use the single GRU cell, where the number of trained parameters is equal to # particles times # parameters in PFRNN. Both approaches are complementary to the PFRNN and mePFRNN models since they do not exploit particles. Also, note that the input to the GRU cell in EnsembleGRU and HeavyGRU models is the same as the input to the PFRNN cell.
## 5 Computational experiment
In this section, we demonstrate the performance of our model and compare it with alternative neural networks and non-parametric models. For training the compared neural networks we use RMSProp optimizer [31] since it shows more stable convergence compared to Adam [32] and SGD with momentum [33], learning rate equal to \(5\cdot 10^{-4}\) and every batch consists of 150 trajectories. The maximum number of epochs is 5000 for the considered environments. During the training stage, a validation set of trajectories is used to identify the overfitting. Therefore, different environments require a different number of epochs before overfitting occurs. In particular, overfitting does not occur after 5000 epochs in the world \(10\times 10\). At the same time, overfitting is observed after 600 and 200 epochs in the World \(18\times 18\) and WORLD \(27\times 27\), respectively.
Trajectories generation procedure.To evaluate the considered methods and demonstrate the performance of the proposed mePFRNN, we consider four environments, see Figure 4. Environments world \(10\times 10\), World \(18\times 18\), and WORLD \(27\times 27\) are symmetric and therefore challenging for object localization since symmetric parts can be confused by a filtering method. Environment _Labyrinth_ is not symmetric and medium challenging for filtering methods. Thus, the considered filtering methods are compared comprehensively due to the diversity in the testing environments.
To train the parametric models we need to generate a set of trajectories \(\{\mathbf{x}_{i}^{\star}\}_{i=1}^{N}\). Since our tests assume that the object's initial state is unknown, we set the initial state \(\mathbf{x}_{0}^{\star}\) randomly for all generated trajectories. Initial states do not intersect with obstacles. Then, every next iteration updates the object state according to the motion equation, where external velocity \(u\in[0,0.2]\) is known and the direction is preserved from the previous step within the noise. In the case of a collision with an obstacle, the object's direction is changed randomly such that the next state does not indicate the collision. To simulate engine noise, the velocity \(u\) is perturbed by \(\eta_{r}\sim\mathcal{U}[-0.02,0.02]\). To simulate uncertainty in the object control system, the direction \(\phi\) is also perturbed by \(\eta_{\phi}\sim 2\pi\alpha\), where \(\alpha\sim\mathcal{U}[-0.01,0.01]\). The measurements \(\mathbf{y}_{i}\) are the distances to the five nearest beacons, which are also noisy with the noise distributed as \(\zeta\sim\mathcal{U}[-0.1,0.1]\). In the considered environments, we set the number of time steps in every trajectory \(N=100\).
To train the considered parametric models, we generate 8000 trajectories, 1000 trajectories for validation, and an additional 10000 trajectories for the testing stage. During the training process, the MSE loss is computed for the validation trajectories and if the obtained value is smaller than the current best one, then the best model is updated. This scheme helps to store the best model during the training and avoid overfitting.
Figure 3: Standard GRU cell, where \(\mathbf{z}\) and \(\mathbf{r}\) denote the linear layers to compute \(\mathbf{z}_{i}\) and \(\mathbf{r}_{i}\), Lin denotes linear layers to compute \(\hat{\mathbf{h}}_{i}\), see (14).
The list of compared models.We compare the proposed mePFRNN model with the following competitors combined in two groups. The first group consists of alternative recurrent neural networks that can solve the object localization problem, in particular the baseline PFRNN model from [3], HeavyGRU, and EnsembleGRU models. Following the study [3] we use the \(wMSE\) loss function (4) to train alternative neural network models and use \(L\) loss function (5) to train the proposed mePFRNN model. Such a choice of training setup highlights the benefit of the proposed loss function \(L\). In both settings, we use \(\beta=0.1\).
The second group consists of the particle filter (PF) and the multiparticle Kalman filter (MKF). We include these methods in the experiments to compare the performance of the parametric and non-parametric models. The performance is measured in terms of MSE\({}_{c}\), FSE, number of trained parameters, training time, and inference time. Note that, non-parametric models do not require training, therefore they are more lightweight. However, to get high accuracy a lot of particles are needed which leads to long runtime. Thus, for adequate comparison with neural methods, the classical filters were used with fewer particles to show a similar runtime as neural network-based models in the inference mode. In addition, we use stochastic resampling in the non-parametric models and Soft Resampling in the parametric ones. However, the Soft Resampling procedure for the non-parametric models does not significantly change the final performance. The comparison of the aforementioned models is presented in the next paragraph.
Discussion of the results.In experiment evaluation, we compare non-parametric and parametric models with the four test environments described above. The obtained results are summarised in Table 1. Also, we track the number of trained parameters, the amount of memory that is necessary to store them, and the runtime to update the object state in one step. From this table follows that the proposed mePFRNN model gives the best or the second-best MSE\({}_{c}\) score for the considered environments. At the same time, the FSE score is typically smaller for HeavyGRU or EnsembleGRU in the considered environments. One more important factor is the number of trainable parameters. The smaller the number of parameters, the easier embedding the model in hardware. The mePFRNN model requires fewer trainable parameters compared with other parametric models, i.e. PFRNN, HeavyGRU, and EnsembleGRU. The last but not least feature of the considered models is the inference time, i.e. the runtime to update the object state from the \(i\)-th to the \((i+1)\)-th time step. mePFRNN is slightly faster than PFRNN, and HeavyGRU appears the fastest model in the inference stage. Thus, we can conclude that the proposed mePFRNN model provides a reasonable trade-off between MSE\({}_{c}\) score, number of trainable parameters, and inference time among the considered parametric and non-parametric models tested in the selected benchmark environments.
Figure 4: Visualization of test environments. Black crosses denote beacons, and grey blocks denote obstacles. The upper row represents the very symmetric environments that are especially challenging for solving the localization problem. The _Labyrinth_ environment is not symmetric and is similar to the environment, which was used for the evaluation of filtering methods in [27].
The number of particles chosen in Table 2 is such that the inference runtime is close to the inference runtime of the considered neural networks. Since in Table 1 we fix the particular number of particles in non-parametric models, we present the MSE\({}_{c}\) and FSE losses for the larger number of particles in Table 2. It shows that if the number of particles is sufficiently large, both MSE\({}_{c}\) and FSE values are smaller than the corresponding values for parametric models. However, such an accurate estimation of states requires a much slower inference runtime compared to the considered parametric models. Thus, the neural network-based filters are of significant interest since they can show better accuracy compared to non-parametric models and provide faster updates of the object's state.
## 6 Conclusion
We present the novel recurrent neural network architecture mePFRNN to solve the object localization problem. It combines the standard GRU RNN, particle filter, and explicit measurements of distances from the object to the beacons. The latter feature makes the proposed model memory-efficient since the number of trainable parameters does not depend on the environment size. We compare the proposed mePFRNN model with the general-purpose PFRNN model and two modifications of standard GRU RNN. The test environments consist of symmetric environments of different sizes and the non-symmetric _Labyrinth_ environment. Such diversity of the test environments leads to the comprehensive comparison of the considered parametric models to solve the object localization problem. The mePFRNN model is simultaneously slightly faster in inference than the baseline PFRNN and filters the object's coordinates more precisely in the considered symmetric environments along the trajectory. Moreover, mePFRNN does not exploit explicit data about the environment or the corresponding embeddings. At the same time, the proposed mePFRNN model outperforms competitors in MSE values for the most of considered test environments.
|
2303.13917 | Convolutional Neural Networks for the classification of glitches in
gravitational-wave data streams | We investigate the use of Convolutional Neural Networks (including the modern
ConvNeXt network family) to classify transient noise signals (i.e.~glitches)
and gravitational waves in data from the Advanced LIGO detectors. First, we use
models with a supervised learning approach, both trained from scratch using the
Gravity Spy dataset and employing transfer learning by fine-tuning pre-trained
models in this dataset. Second, we also explore a self-supervised approach,
pre-training models with automatically generated pseudo-labels. Our findings
are very close to existing results for the same dataset, reaching values for
the F1 score of 97.18% (94.15%) for the best supervised (self-supervised)
model. We further test the models using actual gravitational-wave signals from
LIGO-Virgo's O3 run. Although trained using data from previous runs (O1 and
O2), the models show good performance, in particular when using transfer
learning. We find that transfer learning improves the scores without the need
for any training on real signals apart from the less than 50 chirp examples
from hardware injections present in the Gravity Spy dataset. This motivates the
use of transfer learning not only for glitch classification but also for signal
classification. | Tiago S. Fernandes, Samuel J. Vieira, Antonio Onofre, Juan Calderón Bustillo, Alejandro Torres-Forné, José A. Font | 2023-03-24T11:12:37Z | http://arxiv.org/abs/2303.13917v1 | # Convolutional Neural Networks for the classification of glitches in gravitational-wave data streams
###### Abstract
We investigate the use of Convolutional Neural Networks (including the modern ConvNeXt network family) to classify transient noise signals (i.e. glitches) and gravitational waves in data from the Advanced LIGO detectors. First, we use models with a supervised learning approach, both trained from scratch using the Gravity Spy dataset and employing transfer learning by fine-tuning pre-trained models in this dataset. Second, we also explore a self-supervised approach, pre-training models with automatically generated pseudo-labels. Our findings are very close to existing results for the same dataset, reaching values for the F1 score of 97.18% (94.15%) for the best supervised (self-supervised) model. We further test the models using actual gravitational-wave signals from LIGO-Virgo's O3 run. Although trained using data from previous runs (O1 and O2), the models show good performance, in particular when using transfer learning. We find that transfer learning improves the scores without the need for any training on real signals apart from the less than 50 chirp examples from hardware injections present in the Gravity Spy dataset. This motivates the use of transfer learning not only for glitch classification but also for signal classification.
## I Introduction
The era of Gravitational-Wave (GW) Astronomy started in 2015 with the detection of the GWs emitted in the coalescence of two black holes [1] by the Advanced LIGO detectors [2]. To date, the LIGO-Virgo-KAGRA (LVK) collaboration [2; 3; 4] has reported results from three observing runs (O1, O2, and O3) which comprise 90 confident detections. All signals observed are consistent with being produced in compact binary coalescences (CBCs), namely mergers of binary black holes (BBH), binary neutron stars (BNS), and binaries of a neutron star and a black hole (NSBH) [5; 6; 7; 8; 9]. With the start of the fourth observing run (O4) in May 2023, the number of confident detections is expected to significantly increase, yielding an estimated CBC rate of about one detection per day [10].
GW detectors operate in extremely low noise conditions which may be disrupted by the ground motion surrounding the detectors or earthquakes, storms or even anthropogenic sources of noise [11]. More than 200 thousand auxiliary channels are constantly monitored to minimize instrumental noise [12]. These include angular drift of optics, light transmitted through mirrors as well as actuation signals used to control optic position in order to ensure optical cavity resonance [11; 12]. With a higher detection rate, transient noises of instrumental or environmental origin, commonly dubbed "glitches" [13], will become increasingly more of a concern for the LVK detectors. Since glitches can mimic actual GW signals they hinder the sensitivity of the detectors by increasing the false-alarm rate of true GW signals. Reducing the rate of glitches requires a deep understanding of their nature and physical origin, which in some cases is unclear. Blip glitches constitute a particularly harmful example for the LIGO detectors, where an average rate of two such glitches per hour of data was measured during O1 and O2 [14].
Many different approaches to classify noise transients and subtract them from strain data have been developed over the years [15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34]. Current LVK efforts include e.g. BayesWave [17] and gswubtract [25], which model glitches using sine-Gaussian wavelets and use a linear subtraction algorithm to remove them from the data stream. Moreover, GW searches (e.g. [35; 36; 37]) also use strategies to veto glitches, as e.g. the \(\chi^{2}\) time-frequency discriminator of [15] or a sine-Gaussian veto [24]. Glitch classification and mitigation using probabilistic principal component analysis has been put forward in [20; 18; 21]. Moreover, the Gravity Spy citizen-science project [13] has
allowed to confidently divide Advanced LIGO glitches into classes, and provides a reliably classified glitch catalog that can be used by noise classification and subtraction methods. Glitches from the Advanced Virgo detector have also been introduced in more recent versions of Gravity Spy. A similar citizen-science project focused on the Advanced Virgo detector, GwitchHunters [34], introduced the localization of glitches in time-frequency space, as well as the search for correlations in the detector's auxiliary channels. A variety of methods that are becoming increasingly important for glitch characterization are Machine Learning (ML) methods. Those have already been extensively applied to this topic (see [38] and references therein). For instance, ML and Deep Learning (DL) methods have been used to predict the existence of glitches using only auxiliary channel data [28; 16] or using both the GW strain and auxiliary channels [29]. Furthermore, dictionary learning techniques have been used to reconstruct and remove blips from GW data streams in [26; 27].
Another interesting line of work frames the glitch classification problem as a computer vision task, where glitches are converted from a time-series to spectrogram images, suitable for classification taking advantage of the rapid advances of DL methods for computer vision. In Ref. [23] this approach was successfully tested with simulated glitches, using a custom-made Convolutional Neural Network (CNN). After this initial success, images from the Gravity Spy dataset have also been used to train CNNs for glitch classification. First, custom-made CNNs with two to five layers were trained from scratch for 200 epochs, and individual models achieved satisfactory results, with accuracies over 95% [39]. Subsequently, deeper pre-trained networks with more powerful architectures were trained on the same dataset, and it was found that transfer learning reduced training time and improved results, reaching the state-of-the-art accuracy of 98.8% in the Gravity Spy dataset [21]. In that work, popular CNN architectures like Inception [40; 41], ResNets [42], and VGGs [43] were trained using transfer learning, for up to 100 epochs, and it was found that, for some architectures, transfer learning allowed to achieve accuracies higher than 98% within 10 epochs.
Recent advances in computer vision research, like the discovery of better training recipes [44; 45; 46; 47] or more powerful architectures [48; 49; 50; 51], could potentially improve glitch classification even more. With this in mind, this paper focuses on the classification of glitches in image format (spectrograms), using the latest available techniques to attempt to improve the state-of-the-art. In particular, we aim at improving present-day results by using the lcycle training policy [44], trying a more modern and powerful CNN architecture family, the ConvvNeXt [48], training models using both supervised and self-supervised methods, and using the typical three subset split (train/validation/test) for better assessment of the model-generalization performance. We also analyze in this paper the use of transfer learning applied to O3 data. It should be stressed that the networks are trained using glitches from the Gravity Spy catalog, which only includes O1 and O2 data, and they are not retrained or fine-tuned on O3 data. We find that transfer learning significantly increases the flexibility of the algorithms and their performance. This approach might be advantageous for future GW observing runs, as it is not as sensitive to changes in the detector background noise.
This paper is organized as follows: Section II discusses the supervised and self-supervised DL methods that we employ for our study. In Section III we present the dataset used. Section IV contains our results on glitch classification including, as well, a preliminary analysis of the performance of our methods with O3 data and actual GW signals. Finally, in Section V we present our main conclusions and outline our plans for future work.
## II Deep Learning Methods
Deep Learning is a subfield of Machine Learning that relies on artificial neural networks with many intermediate layers, each of which builds on the representations learned by the previous layer in order to automatically develop increasingly complex and useful representations of the data [52]. While shallow learning methods, i.e. methods with very few layers, rely on carefully handcrafted features to produce useful results, DL requires no feature engineering, as it can autonomously find what are the useful features, considerably simplifying ML workflows.
According to the experience1 the algorithms acquire during the training phase, DL methods can be categorized as unsupervised, supervised or self-supervised algorithms. In all cases, the algorithms experience an entire dataset, \(\mathbf{X}\), which is a collection of \(m\) data points \(\mathbf{x}^{(i)}=(x_{0},x_{1},...,x_{n})\), each of which has \(n\) features. Unlike unsupervised algorithms, in supervised learning algorithms each example \(\mathbf{x}^{(i)}\) has, in addition, an associated label, \(y^{(i)}\), which is the target for the prediction of the point. Similarly, self-supervised learning uses the same dataset composed of \(n\) samples, with targets for the predictions indicated by the labels. However, the labels of those same samples are replaced by automatically generated labels, referred to as pseudo-labels. In this work, both supervised and self-supervised algorithms are used.
Footnote 1: Here, “experience” is used with same meaning as in Tom Mitchell’s Machine Learning definition [53].
### Supervised Deep Learning
The ResNet architecture family [42] is used in this investigation as a baseline for the classification task. ResNets are a family of CNNs [54; 55] which use residual connections, i.e. direct paths between non-adjacent
layers, to allow training deeper models. In the original implementation, ResNets end with a fully connected layer with 1000 units, corresponding to the number of classes in the ImageNet dataset [56]. For other applications, the number of neurons in this last layer is changed to match the number of classes.
The models were trained using the fastai library [57], taking advantage of its implementation of the 1cycle training policy [44], and training using the AdamW optimizer [47]. In addition, the learning rates were selected using the learning-rate finder [44]. Mixed precision training [45] was also used to reduce the memory requirements and speed up training.
In this work we employ the cross-entropy loss, which for the case of a single example, is given by
\[\mathcal{L}(\mathbf{\theta})=-\sum_{k=1}^{K}y_{k}\log(\hat{p}_{k}). \tag{1}\]
Above, \(y_{k}\) denotes the target probability of class \(k\), typically either equal to 0 or 1, \(K\) denotes the total number of classes (equal to the number of neurons in the output layer), and \(\hat{p}_{k}\) denotes the probability that the example belongs to class \(k\). A weighted loss function was also tried, to penalize more the model for mistakes in the less represented classes, by introducing a class-dependent weight, \(w_{k}\), in the cross-entropy loss:
\[\mathcal{L}(\mathbf{\theta})=-\sum_{k=1}^{K}w_{k}\ y_{k}\log(\hat{p}_{k}). \tag{2}\]
This approach was tried using class weights inversely proportional to the number of samples in each class,
\[w_{k}=\frac{1}{N_{k}}, \tag{3}\]
with \(N_{k}\) being the total number of samples of class \(k\). In addition, the Effective Number of Samples (ENS) approach [58], which obtains the weights associated with each class using
\[w_{k}=\frac{1-\beta}{1-\beta^{N_{k}}}, \tag{4}\]
was also tried. Here, \(\beta\) is a hyperparameter that allows to control the re-weighting degree. Its value was fixed to \(\beta=0.99\), following the suggestion in [58]. In both cases, the class weights are normalized by dividing each class weight by the sum of the class weights and multiplying by the number of classes, in order to create weights closer to unity.
Moreover, the use of the focal loss function, introduced in Ref. [59], was also tested, since it adds to the cross-entropy loss a modulating factor which down-weights easy examples, that is, examples where the model is more confident. The focal loss is defined by
\[\mathcal{L}(\mathbf{\theta})=-\sum_{k=1}^{K}w_{k}\ (1-\hat{p}_{k})^{\gamma}\ y_{k} \log(\hat{p}_{k}), \tag{5}\]
where \(\gamma\) is the focusing parameter, which was kept to the default value of 2.0 [59].
In addition to training ResNets from scratch, transfer learning [60] has also been considered in our investigation. Transfer learning is a technique that allows to take advantage of knowledge learned in one domain, typically from a task that has many labelled examples, and to apply it to a different but related task which may have a limited number of examples. This technique is one of the cornerstones of the fastai library, as it allows to train more accurate models more quickly, and using less data, as compared to training the same models from scratch [61]. We found it interesting to explore transfer learning here to also understand if the networks (pre-trained in datasets which are different from the ones they are applied to) improve performance (in comparison to when no transfer learning is used), also allowing them to be more robust against changes in the detector background.
In the default fastai transfer-learning approach, after assigning the pretrained weights, the final layer is replaced with a fully connected layer with the correct number of outputs, and it is initialized with entirely random weights. Then, the networks are trained with fastai's fine_tune training schedule [62], which first trains the last layer with the others kept frozen, and then trains the whole network using lower learning rates, while also taking advantage of discriminative learning rates.
For the networks trained with transfer learning, the ConvNeXt network family [48] was also tried. The design of this CNN family is inspired on the successful Vision Transformers such as ViT [49], allowing it to achieve very competitive performances (see e.g. [63]). More details about the architectures used in this work can be found in the appendix of [64].
### Self-supervised Deep Learning
Self-supervised DL is a recently introduced method in the field of ML [65]. This method involves training a model for a pretext task before training the model for the desired (downstream) task, as sketched in Figure 1. For instance, a model can be trained to detect what kind of visual transformation is applied to an image and, after that, a transfer of knowledge be done to another model that is trained with labeled data for the downstream task. To solve the pretext task, the samples contained in the dataset must have their pseudo-labels generated, as observed in box (a) of Figure 1. In this case, each one is associated with the type of visual transformation applied to the image. The model is then trained, allowing it to learn features/patterns about the images in the context of this so-called pretext task. The training section is approached in the same way as in supervised learning, with the objective of minimizing the loss function in order to match the model's prediction to the targets, in this case given by the pseudo-labels.
Following this first training section, transfer learning is
applied by removing the last layer of the trained model and replacing it with a randomly initiated layer of the same type. This updated model is then trained for the downstream task, as shown in box (b) of Figure 1, where the dataset used to feed the neural network already has human-made labels. In theory, the pretext task allows the model to learn certain useful patterns from the images, making it so that the downstream model is easier to train. Usually the pretext task tackles a problem that is a subcategory of the problem associated with the pretext task. This technique is more appropriate if there is a high amount of samples, but only few of those are labelled.
The architecture we chose for the self-supervised approach was the ResNet18, with randomly initialized parameters. This model is trained using a dataset composed of images that only correspond to a specific time-span window. Data augmentation is used to increase the variety in the dataset and avoid overfitting. Similarly to the supervised DL methods discussed before, the AdamW optimizer and cross-entropy loss function are used during training, using the 1cycle training policy and the learning rate finder to select a learning rate.
### Model evaluation
The metric we select to compare possible model configurations is the F1 score. This is the harmonic mean of precision (the ratio of correct positive predictions to the total number of positive predictions) and recall (the ratio between the number of correct positive predictions and the total number of positive examples)
\[\text{F1 score}=\frac{2}{\frac{1}{\text{precision}}+\frac{1}{\text{recall}}}= \frac{\text{TP}}{\text{TP}+\frac{\text{FN}+\text{FP}}{2}}. \tag{6}\]
Above, TP, FP and FN respectively denote the total number, true positives, false positives and false negatives.
The F1 score can be computed for each class but this raises the issue of having multiple metrics. In order to have one single overall metric, the macro-averaged F1 score is used instead. This metric is calculated by plugging in the macro-averaged precision and macro-averaged recall, which are respectively the precision and recall averaged across all classes, in Eq. (6).
As models that train faster are easier to optimize and can also result in faster inference times, a new metric was created to penalize models that take longer to train:
\[\text{combined\_F1\_time}=\text{F1\_score}-\text{total\_runtime}/3\times 10^{4}. \tag{7}\]
The numerical value in the equation was conveniently chosen so that an increase of 0.2 percentage points in the F1 score will only be accepted if it adds less than 60 seconds to the training time. Thus, this metric allows to search for better models without increasing too much the training time.
The metrics were computed on the validation dataset for the candidate models, with only the best configurations being chosen for evaluation on the test set. The use of three separate subsets in the model training and evaluation process is of utmost importance. The inclusion of an intermediate validation set allows to evaluate different model candidates on this set and select them accordingly based on their performance. Then, the selected models can be evaluated on the test set, which had not been used to guide previous decisions, to provide a more accurate estimation of the models' generalization. Had the intermediate set not been used, the test set would provide an over-confident estimate of the models' performance, as they had been optimized for that same dataset.
## III Dataset
The Gravity Spy dataset, introduced in [13; 39], is a collection of spectrograms of (mostly) glitches identified during the O1 and O2 observing runs in the Advanced LIGO detectors. This dataset presents a multi-class classification problem, where the goal is to assign the only correct glitch class to each noise sample. Each sample contains four spectrogram images centered at the same
Figure 1: Scheme of the self-supervised DL framework during training. In the dashed green box (a), labels are automatically generated for a pretext task (i.e. the image transformation imposed on the data is to be predicted by the model). In the dashed purple box (b), the architecture’s last layer is changed to solve a related problem using labeled data.
instant in time but with different durations of 0.5, 1.0, 2.0 and 4.0 seconds, all represented as \(140\times 170\) pixels grey-scale images, as seen in Figure 2. In this work we directly use the public images from Gravity Spy. It can be observed that the glitch classes vary widely in duration, frequency range and shape. Nevertheless, some classes can be easily mistaken for each other due to their similar morphology, like the Blip and Tomte classes [31], or if they are not visualized using the appropriate time window. For instance, a Repeating_Blips sample may be identified as a Blip if the window is too small.
In the version of the dataset used in this work2, v1.0, there are 8583 glitch samples distributed unevenly over 22 different classes, which are thoroughly described in [13]. The majority of examples are Blips, with almost 1900 samples, while there are five minority classes (Paired_Doves, Wandering_Line, Air_Compressor, Chirp, and None_of_the_Above) with less than 190 examples (10% of the number of Blips), the less represented being the Paired_Doves, with only 27 examples. The Chirp class does not actually represent glitches but instead "hardware injections", which are simulated signals created to resemble real GWs from CBCs, and used for the testing and calibration of the detectors [39]. The Gravity Spy dataset is already split, using stratified sampling to ensure similar distributions in each subset, into training (70%), validation (15%) and test (15%) sets, to facilitate the comparison of different methods.
Footnote 2: [https://zenodo.org/record/1476156](https://zenodo.org/record/1476156)
## IV Results
### Supervised models
We start discussing the results of glitch classification for supervised DL models. For a quick search for a baseline classifier the ResNet18 and ResNet34 architectures were chosen, with an adapted number of inputs for the first convolutional layer, and using random weight initialization. Both architectures were trained from scratch with fastai's fit_one_cycle routine over 15 epochs with the steepest point from the learning rate finder as the maximum learning rate; with the other hyperparameters set to fastai's defaults.
Several approaches were tested regarding the amount and format of the information provided to the model. In
Figure 2: Examples of the different glitch classes from the Gravity Spy dataset. Note that the classes None_of_the_Above and No_Glitch are not represented in the figure. Moreover, the timescale is not equal for all images and the grey-scale spectrograms are shown with a colour map for better visualization.
the simplest approach, the model had only access to one of the four spectrograms for each example, always with the same duration. This corresponds to views labelled single1 (0.5 s), single2 (1.0 s), single3 (2.0 s) and single4 (4.0 s). Thus, these single-view models accepted batches of grey-scale (1-channel) \(140\times 170\) (height \(\times\) width) pixels images. The second approach was a merged view model inspired in [66], which consists of placing the four single view 140\(\times\)170 images next to each other, forming a \(280\times 340\) pixels image. Finally, we implemented an approach based on encoding information related to a different time duration in each image channel, as introduced in [67]. Encoded views with all combinations of two to four time durations were compared.
A hyperparameter grid search was run over the two model architectures and all the possible views, in order to select the best views and choose a baseline model. The results in terms of each view are shown in Figure 3. It was found that the single views were outperformed by almost all the other views. The highest average F1 scores were obtained by encoded134. Remarkably, this outperformed merged view and encoded1234, which use all the available information. Taking the total training time in consideration using the combined_f1_time metric from Eq. (7), we conclude that encoded134 is the best view, as the merged view takes about 6 more seconds per epoch (a 70% increase) than view encoded134, while achieving slightly worse performance regarding the F1 score. Therefore, encoded134 was selected as the view used for the rest of the supervised models.
In addition, the results of the grid search were also evaluated in terms of the chosen architecture, as depicted in Figure 4. This figure shows box plots of the combined_F1_time for the validation set3. We found that, on average, ResNet18 achieves better results both on the F1 score and the training time, resulting in a median combined_F1_time 0.6 percentage points higher than ResNet34. Thus, the ResNet18 was chosen for the baseline model.
Footnote 3: In box plots (which we employ in several figures in this paper) the lower limit of the box corresponds to the 25\({}^{\text{th}}\) percentile of the data, and the upper limit to the 75\({}^{\text{th}}\) percentile. The line which goes through the box represents the median of the observations. The whiskers represent the maximum and minimum (excluding outliers) of the quantity being displayed, and the individual points (if any) are outliers, i.e. points that are more than 1.5 inter-quartile distance away from the closest quartile.
After deciding the baseline configuration, five models were trained for 15 epochs each, using the same configuration as before, and selecting the ResNet18 architecture and the encoded134 view. The F1 scores of the five training runs range between 96.7% and 98.1%, and the best one was chosen as the baseline model.
An attempt was made to tune the learning-rate choice method, the number of epochs and the batch size, with the goal of further optimizing the model's performance. Hence, a Bayesian sweep was performed over 50 configurations of the following three hyperparameters: (a) number of epochs, between 8 and 25; (b) batch size, sampling from the set [256, 32, 64, 128]; and (c) learning rate finder function, sampling from the four available methods in fastai (steep, valley, slide, minimum). It was found that no model obtained an F1 score higher than the baseline, although some models reached a slightly better combined_f1_time score by maintaining a comparable F1 score while training for less epochs.
The weighted loss function from Eq. (2) was also tried, in order to further penalize the model for mistakes in the least represented classes. The re-weighting strategies were compared using the baseline configuration in
Figure 4: Box plots with the comparison of the architectures regarding combined_f1_time, computed over the validation set.
Figure 3: Comparison of the different views regarding combined_f1_time computed over the validation set. The horizontal bars show the average of the result of the two architectures, ResNet18 and ResNet34.
addition to a configuration equal to the baseline but with the ResNet34 architecture instead of the ResNet18. Each configuration/strategy combination was run for 10 times, yielding the results shown in Figure 5. When the inverse weighting strategy is introduced, the performance of the baseline decreases, while the ResNet34's F1 scores slightly increase. The effective re-weighting strategy seems to result in similar performance for the baseline in comparison to the models without re-weighting, while the ResNet34 models, once again, slightly improve their performance.
Next, the focal loss from Eq. (5) was tried by training the baseline configuration using this loss five times for each of the previous weighting strategies (including the absence of re-weighting). The results are shown in Figure 6. Focal loss does not seem to work with the inverse re-weighting strategy and yields similar performance without re-weighting and using the effective number of samples strategy. The results with focal loss are worse than the results with cross-entropy in all cases.
### Supervised models with transfer learning
After being unable to improve the baseline model while training from scratch, an approach using transfer learning was attempted. Initially, models pre-trained on the ImageNet dataset using the ResNet18 and ResNet34 architectures were trained with fastai's fine_tune routine with the same configuration as the baseline model. As the results suggested that the ResNet18 architecture may not be the best one for transfer learning, other architectures from the ResNet family were also tried (ResNet26 and ResNet50) as well as architectures from the ConvNeXt family (ConvNeXt_Nano and ConvNeXt_Tiny). Having chosen these six architectures, a grid sweep was performed in order to compare them. In particular, we trained each model for 4, 9 and 14 epochs (in addition to the initial frozen epoch), using two different learning rate functions, steep and minimum, while keeping the other hyperparameters at the default values. In total, each architecture was trained six times, with the results shown in Figure 7. It was observed that ResNet18 produced the best single run, but it appears to be worse than all the other architectures when averages and medians over multiple training runs are considered. The performance of the ResNet family seems to peak with the ResNet34 architecture but it is surpassed, on average, by the ConvNeXt family. ConvNeXt_Nano is close to ConvNeXt_Tiny in terms of F1 score but is preferable when the training time is considered, resulting in higher combined_f1_time values. For these reasons, ConvNeXt_Nano was chosen as the architecture for subsequent optimizations.
A Bayesian sweep was then performed to optimize the hyperparameters of the transfer learning model, with the ConvNeXt_Nano architecture. Fifty configurations were evaluated, given the following parameter space: (a) number of frozen_epochs, with a uniform integer distribution between 1 and 5; (b) number of unfrozen epochs, using a uniform integer distribution between 1 and 10; (c) batch size, sampling from the set [256, 256, 32, 64]; (d) learning rate finder function, sampling from the four available methods in fastai (slide, valley, steep. minimum); (e) loss function: either cross-entropy or focal loss; and (f) re-weighting strategy, which could be none, inverse of class frequency, or ENS.
The six overall best configurations of the sweep as well as the three best models trained for 6 epochs or less were more thoroughly evaluated by re-training them five times each. From these, the three most promising configurations in terms of F1 score were selected, which have the following hyperparameters: (a) tl_best5: 2 frozen and 8 unfrozen epochs, batch size of 64, minimum learn
Figure 5: Box plots of the F1 scores on the validation set for three different weighting strategies using three different configurations.
Figure 6: Box plots of the F1 scores on the validation set for the cross-entropy loss and focal loss functions, using the baseline configuration with three different re-weighting strategies.
ing rate selection function and cross-entropy loss with inverse class re-weighting; (b) tl_fast1: the same hyperparameters as tl_best5 except for a quicker training with 1 frozen and 5 unfrozen epochs; and (c) tl_best6: 1 frozen and 9 unfrozen epochs, batch size of 256, steep learning rate selection function and focal loss with ENF re-weighting. They were trained five more times, totaling ten models for each, and the results are shown in Figure 8.
The highest score was obtained by the best run of the tl_best5 configuration, which beat the baseline's best run. The tl_best5 and tl_fast1 configurations achieved F1 scores higher than the baseline median in all runs. Moreover, tl_fast1 has the highest median among all models.
The model with the highest overall score, corresponding to the best run of tl_best5, was chosen as the transfer learning classifier. In comparison with the baseline model, it only increases the F1 score from 98.07% to 98.21%, but the transfer learning configuration appears to result in more stable performances across multiple training trials, with its worst performance higher than the baseline median. In fact, the baseline configuration achieves an F1 score of \((97.4\pm 0.5)\%\), less than tl_best5's \((97.8\pm 0.2)\%\) and tl_fast1's \((97.9\pm 0.2)\%\). Note that the previous F1 scores are reported in the form \((\mu\pm\sigma)\%\), where \(\mu\) is the distribution average and \(\sigma\) its standard deviation. We highlight that these models were very quick to train, with training times between 1 and 2 minutes using a NVIDIA RTX A4000 GPU (16 GB VRAM).
### Self-supervised model
In contrast to supervised learning, self-supervised learning is a two-phase process that partly uses automatically generated labels, i.e. pseudo-labels, during the training of the architecture. This can be considered an advantage for datasets where data is abundant but the labeling of the samples is scarce or incorrect. As stated in Section II.2, the self-supervised learning framework first needs to solve the pretext task and then the downstream task. This means that this approach utilizes two distinct training phases, each one using its own independent dataset. The first training phase gives rise to the first model (I), which solves the pretext task. In the second phase, we apply transfer learning to the previous model, to obtain the second and final model (II), which solves the downstream task.
After applying the image transformations (in the first phase) or image augmentations (in the second phase), all the images for both datasets are then resized to 128\(\times\)128 pixels through interpolation. This is done to make the models train faster since the input's size is smaller. Just like in supervised models, the F1 score and accuracy are the metrics being examined. Both metrics are only applied to the validation dataset. In both phases the batch size is set to 64.
Model (I) was trained from scratch using pseudo-labels, with a dataset composed of single view images from all four time-span windows (0.5 s, 1.0 s, 2.0 s, and 4.0 s). Each signal has thus four independent single view images associated with it. The visual transformation is picked from a list of operations like random crops (crop), horizontal and vertical flips (flipVertical and flipHorizontal), color jitters (colorize), and rotations of 90\({}^{0}\) and 270\({}^{0}\) (rotate90 and rotate270). The no-transformation case was also used (labeled as noTransformation). For each image, one visual transformation is randomly selected from the list. Once the visual transformation is applied, a pseudo-label is as
Figure 8: Box plots of the F1 scores on the validation set of the ten runs for the baseline and the best three configurations selected from the second Bayesian sweep.
Figure 7: Box plots with the comparison of the architectures regarding combined_f1_time, computed over the validation set.
sociated with it. For instance, if the vertical flip option is selected from the list, the resulting image will be flipped vertically and then resized to 128 pixels by 128 pixels. The resulting pseudo-label is denominated as the flipVertical class.
For simplicity, model (II) only utilizes data with 4-second time windows, although we note that certain types of glitches require longer windows to be recognized. Similar to the previous dataset, all images are single views. As a consequence, the dataset used to train model (I) has four times more images for each epoch compared to the dataset from model (II). During the training phase of this model, the original labels are used instead of the pseudo-labels. In this phase, data augmentation is applied to avoid overfitting, as explained below. Before resizing the image, each one is rotated between -5 and 5 degrees, then undergoes a color jitter, and finally a random crop is applied. Note that since the original labels are used, there is no longer a correlation between the class and the type of augmentation applied to the image.
For both models, the learning rate finder is used to determine the values of the learning rate. For model (I) the learning rate is \(6.92\times 10^{-3}\), and for model (II) is \(5.75\times 10^{-4}\). Since the 1cycle policy is used during training, these values actually correspond to the maximum learning rate, instead of a single fixed learning rate value for all epochs.
Model (I) was trained during 10 epochs since both the values of the loss and the metrics quickly converged after the first few epochs, as shown in Figure 9(a) and (c). Model (II), however, was trained for 30 epochs. The evolution of the metrics for this model, as well as the loss, are represented in Figure 9(b) and (d). The values start to converge somewhere between the \(10^{\text{th}}\) and the \(15^{\text{th}}\) epoch. In the first five epochs, only the parameters of the last layer were allowed to change with a maximum learning rate determined by the learning rate finder. In the remaining 25 epochs, all architecture parameters can be modified, with the maximum learning rate being \(5.75\times 10^{-5}\), a 10 times smaller rate than in the first five epochs. The resulting final model (II) has an F1 score of 92.74% and an accuracy of 96.74%, evaluated on the validation dataset.
### Evaluation of the best models on the test set
The best models found in the previous sections are now evaluated on the test dataset, for both supervised and self-supervised approaches. It is worth recalling that this dataset was not used during the training of the neural networks.
From the supervised models, both the baseline and tl_best5 models were selected to be evaluated on the test dataset, based on their performance on the validation dataset. We found that the F1 score of the baseline slightly dropped to 97.18%, while tl_best5, the best model on the validation dataset, performed worse than the baseline on the test dataset, with an F1 score of 96.84%. Nevertheless, the F1 scores obtained on data which was never seen by the models nor used to perform choices regarding the hyperparameter optimization, are still very high for both models. The confusion matrix of the baseline model, using the predictions on the test dataset, is presented in Figure 10. Both precision and recall are, at least, 95% for 19 out of the 22 classes of glitches. The model appears to have more difficulties in the Air_Compressor and None_of_the_Above classes. This may be explained by the fact that, for these classes, the number of images in the training set is significantly smaller than for the other classes. Note that the None_of_the_Above class, in particular, has a very diverse distribution since it encompasses every glitch outside the defined classes. This class has been deprecated from the glitch classes for O3 data [68].
For the self-supervised model, the corresponding test dataset confusion matrix is shown in Figure 11. The model shows that the recall and precision scores are, at least, 95% for 14 out of the 22 glitch classes. This is slightly worse than the result obtained under the supervised approach, as expected. In particular, the model struggles to identify several other classes beyond those already signaled for the supervised approach above, like the Wandering_Line and Repeating_Blips classes. This happens due to the fact that, for simplicity, these models were only trained with datasets consisting of 4-second wide signals in contrast to some of the previous models that were trained with encoded views. As a result of the resized augmentation, the performance of the model
Figure 9: Epoch evolution of the accuracy and macro-averaged F1 score for training of model I (a) and model II (b). The corresponding losses are represented in panels (c) and (d).
might also be affected, as reducing the number of pixels will reduce the image's details. For these reasons, this model did not perform as well as the supervised trained models. However, the performance is still high, with an overall accuracy of 96.50% (relative to all classes) and an macro-averaged F1 score of 94.15% on the test dataset. For completeness, the confusion matrix of the model trained with pseudo-labels, before transfer learning is applied (first training phase), is also shown in Figure 12. We note that the model has some difficulties distinguishing between the pseudo-labels resize and flipHorizontal, which makes sense since some glitches have vertical symmetry.
The two best supervised models, as well as the best self-supervised model, were compared to the literature in terms of their F1 score and accuracy. The results are shown in Table 1. Both supervised models obtained competitive results, with accuracies higher than the merged view CNNs reported in [39, 66], and the baseline model's performance was also better than the hard fusion ensemble of CNNs [39]. This model, which uses a ResNet18 architecture trained from scratch, is only slightly worse than the fine-tuned ResNet50 from [21], with a decrease in F1 score of less than 0.2 percentage points. It should be stressed, however, that Ref. [21] used a different dataset split, without a validation dataset, resulting in more training data and a different test set. More importantly, the absence of a validation set could imply that the results reported by [21] are over-confident. They report the test set performance from the epochs selected because they had the higher test set performance themselves. On the other hand, our results from self
Figure 10: Normalized confusion matrix of the predictions of the baseline model over the test dataset, for the supervised approach.
supervised model scores show slightly lower values with respect to supervised approaches but the reported numbers are still interestingly high and promising, as they are close to the best performance achieved in Ref. [39] using a single view.
### Evaluation of the best models on GW signals
As mentioned before, the Gravity Spy dataset contains a few examples of the Chirp class, which are simulated GW signals from CBCs. In addition, the best models have shown perfect precision and recall for chirp classification in the Gravity Spy test dataset (cf. Figure 10). These two reasons motivated us to conduct a brief investigation of whether the models trained in this work would be able to identify real detections of GWs as Chirps, using data from the Advanced LIGO detectors collected during the third LVK observing run (O3).
The strain data for the confident detections in the O3 run, for each Advanced LIGO detector, Hanford ("H1") and Livingston ("L1"), was obtained from the Gravitational Wave Open Science Center (GWOSC) [69]. For each data sample, a Q-graph of the strain data in the 5 seconds around the GPS time of the detection was obtained using the q_transform method from the GWpy library [70]. Furthermore, four crops of this Q-graph, centered at the time with the highest energy, were obtained, one for each different single view duration in the Gravity Spy dataset. From the resulting 178 samples (89 events times, 2 detectors), many were discarded due to the GW signal being buried in the background noise, with no visible chirp, resulting in 50 samples with clearly visible chirps.
Figure 11: Normalized confusion matrix of the predictions of the self-supervised trained model (II), for the test dataset.
The views with 0.5, 2.0 and 4.0 seconds of duration were combined taking advantage of the RGB color channels, as done previously, to obtain the encoded134 view. The resulting images were passed through the baseline and tl_best5 model. The results are shown in panel (a) of Figure 13. The performance of the two supervised models tested with real GW signals from the O3 run is noticeably different, despite both having perfect performance in the chirp class of the test dataset. On the one hand, the baseline model is very dependent on the image creation pipeline. For this reason, an extra alignment step for the colour channels was necessary to improve its performance. Even for the aligned images, the model achieves a mere 10% recall, assigning most images to the None_of_the_Above class. On the other hand, the transfer learning model achieves a 52% recall for the aligned images, correctly identifying 26 out of the 50 GW samples. Moreover, the model is much more robust to samples which are different from the ones used to train it (i.e. with different background noise conditions), being practically unaffected by the colour channel misalignment. One possible explanation for the better performance and behaviour with samples slightly out of distribution could be the benefit of pre-trained features, which were reported in [71] to produce a boost in generalization even after fine-tuning.
Panel (b) of Figure 13 displays an illustrative sample of the O3 GW signals used to evaluate the model, as well as the respective tl_best5 model predictions. As expected, we found that the model performs well with chirps similar to those present in the Gravity Spy dataset (top row), typically from BBH mergers, but has more difficulties with different types of chirps (bottom row) which are either much longer (in the case of BNS coalescences) or much narrower (in the case of high-mass BBH mergers) than the chirps present in the training dataset.
Finally we discuss the results for the self-supervised model, applied to the 4-second view images. The results are plotted in Figure 14. Panel (a) of this figure indicates that most of the classified images are wrongly predicted as Blips. This is likely due to the fact that Chirps and Blips in the 4-second window images are quite similar to one another, as observed in panel (b) of Figure 14. In addition, the relatively small number of samples of Chirps in the dataset used for training might contribute to justify the very low GW detection rate. Nevertheless, the model has a similar recall value than the baseline supervised model. However, the value is significantly smaller than that achieved by the tl_best5 model.
Further studies to improve the performance of both the supervised and the self-supervised models by using an appropriate training on O3 data will be conducted in the future. We note, however, that no reliably labelled O3 dataset is yet available in the Gravity Spy project. The labels from the O3 dataset reported in [68] were automatically obtained using a model trained mostly using O1/O2. Until this dataset becomes available, the next step for self-supervised models will be to use encoded views similar to the supervised models. This could allow us to understand if self-supervised methods are worth pursuing.
\begin{table}
\begin{tabular}{l r r l} \hline \hline Model & F1 score (\%) & accuracy (\%) & Notes \\ \hline single2 view CNN [39] & not reported & 96.81 & custom shallow CNN using only one view \\ merged view CNN [66] & not reported & 96.89 & different dataset version (20 classes) \\ merged view CNN [39] & not reported & 97.67 & improved version of [66] \\ hard fusion ensemble [39] & not reported & 98.21 & combines four CNNs \\ fine-tuned ResNet50 [67; 21] & 97.65 & 98.84 & different split (no validation set) \\ baseline [this work] & 97.18 & 98.68 & ResNet18 trained from scratch \\ tl_best5 [this work] & 96.84 & 98.14 & fine-tuned ConvNeXt_Nano \\ self-supervised model [this work] & 94.15 & 96.50 & self-supervised trained ResNet18 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Performance of different models on the Gravity Spy dataset.
Figure 12: Normalized confusion matrix of the predictions of the self-supervised trained model (I) over the test dataset, before transfer learning is applied
## V Conclusion
The classification and mitigation of transient sources of noise, or "glitches", in GW data streams is a crucial task in detector characterization and GW data analysis. In this paper we have investigated the use of Convolutional Neural Networks to classify glitches included in the Gravity Spy dataset, corresponding to the O1 and O2 data-taking periods of the Advanced LIGO and Advanced Virgo detectors. We have used both supervised and self-supervised deep learning. First, we have trained models using a supervised learning approach, both trained from scratch and using transfer learning and hence fine-tuning already pre-trained models in the Gravity Spy dataset. The comparison with the best baseline model when using transfer learning shows a moderate increase of the F1 score (our metric of choice to compare different model configurations) from 98.07% to 98.21%. However, the transfer learning configuration results in more stable performances across multiple training trials. In the second part of this work we have assessed the use of self-supervised training. In this case models have been pre-trained with pseudo-labels corresponding to image transformations applied to the original images, and then fine-tuned with the original labels.
The results obtained from our best models are very close to the state-of-the-art results reported in the literature using the Gravity Spy dataset. Our best baseline and transfer learning supervised models reach accuracies higher than the merged view CNNs reported in [39; 66]. Moreover, the baseline model's performance is also better than the hard fusion ensemble of CNNs [39] and only slightly worse than the fine-tuned ResNet50 results from [21], despite the fact we use a significantly simpler ResNet18 architecture trained from scratch. On the other hand, the scores of our self-supervised models show slightly lower values with respect to supervised approaches, yielding an F1 score of 94.15%. This value,
Figure 14: Results of the predictions of the self-supervised model for O3 GW images. Left panel (a): A confusion matrix with only one row corresponding to the Chirp class. The majority of samples are classified as Blips. Right panel (b): examples of the model predictions together with its input images.
Figure 13: Results of the predictions of the supervised models for O3 GW images. Left panel (a): Confusion matrices with a single row each corresponding to the Chirp class. Right panel (b): examples of the tl_best5 model predictions.
however, is close to the best performance achieved in Ref. [39] using a single view.
In the last part of this study we have tested the models using actual GW signals from LIGO-Virgo's O3 run. We have found that despite the models having been trained using data from previous runs (O1 and O2), they show good performance, in particular the supervised model with transfer learning. When using transfer learning the scores improve in a significant way without the need for any training on actual GW signals (other than the less than 50 chirp examples from hardware injections present in the Gravity Spy dataset). This finding motivates the use of transfer learning not only for glitch classification but also for GW classification, as the model flexibility and undemanding generalization might help detect signals slightly different from the ones used during training. Transfer learning may thus provide a better coverage for glitch classification and GW detection with our ever-changing GW detection network.
To end, we note that an experiment worth performing elsewhere would be to fine-tune the transfer-learning model on O3 data. For this, we would need to classify O3 glitches for each class (including the new ones as e.g. Fast Scattering[72]) by hand, both for training and for testing. The task of producing a reliable O3 glitch dataset (like there is for O1 and O2) would probably take significant effort, but perhaps the outputs of our models, the Gravity Spy team's model, and the human labelling from the Gravity Spy citizen science project can help.
###### Acknowledgements.
We thank Osvaldo Freitas and Solange Nunes for fruitful discussions during the course of this work. We also thank Christopher Berry, Jools Clarke, Tom Dooney, Melissa Lopez, Jade Powell, Max Razzano, and Agata Trovato for useful comments. AO is supported by the FCT project CERN/FIS-PAR/0029/2019. JCB is supported by a fellowship from "la Caixa" Foundation (ID 100010434) and from the European Union's Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement No 847648 (fellowship code LCF/BQ/PI20/11760016). JCB is also supported by the research grant PID2020-118635GB-I00 from the Spain-Ministerio de Ciencia e Innovacion. ATF and JAF are supported by the Spanish Agencia Estatal de Investigacion (Grant PID2021-125485NB-C21) funded by MCIN/AEI/10.13039/501100011033 and ERDF A way of making Europe). Further support is provided by the EU's Horizon 2020 research and innovation (RISE) programme H2020-MSCA-RISE-2017 (FunFiCO-777740) and by the European Horizon Europe staff exchange (SE) programme HORIZON-MSCA-2021-SE-01 (NewFunFiCO-10108625). This material is based upon work supported by NSF's LIGO Laboratory which is a major facility fully funded by the National Science Foundation.
|
2307.07503 | Brain Tumor Detection using Convolutional Neural Networks with Skip
Connections | In this paper, we present different architectures of Convolutional Neural
Networks (CNN) to analyze and classify the brain tumors into benign and
malignant types using the Magnetic Resonance Imaging (MRI) technique. Different
CNN architecture optimization techniques such as widening and deepening of the
network and adding skip connections are applied to improve the accuracy of the
network. Results show that a subset of these techniques can judiciously be used
to outperform a baseline CNN model used for the same purpose. | Aupam Hamran, Marzieh Vaeztourshizi, Amirhossein Esmaili, Massoud Pedram | 2023-07-14T17:52:15Z | http://arxiv.org/abs/2307.07503v1 | # Brain Tumor Detection using Convolutional Neural Networks with Skip Connections
###### Abstract
In this paper, we present different architectures of Convolutional Neural Networks (CNN) to analyze and classify the brain tumors into benign and malignant types using the Magnetic Resonance Imaging (MRI) technique. Different CNN architecture optimization techniques such as widening and deepening of the network and adding skip connections are applied to improve the accuracy of the network. Results show that a subset of these techniques can judiciously be used to outperform a baseline CNN model used for the same purpose.
_Keywords-- Brain Tumor Detection, Magnetic Resonance Imaging, Convolutional Neural Networks, Skip Connections_
## I Introduction
The brain is one of the most complicated organs inside the human body that works with a very large number of cells. Brain tumors increase when there is an unregulated division of cells that forms an irregular mass. This group of cells will affect the normal function and activity pattern of the brain and damage the healthy brain cells [1]. X-ray images are typically used for evaluating and recognizing the body's tumor growth. Detecting a brain tumor is also possible with medical examination imaging techniques such as Magnetic Resonance Imaging (MRI) and computed tomography (CT) [2]. Digital image processing is a critical task in analyzing the MRI scans.
Tumor development takes place inside the skull. Tumors cause extreme brain pressure, which spread across the entire brain region. Some of these tumors can be malignant and lead to Cancer, a major cause of death and responsible for about 13 percent of all deaths worldwide. Today, a radiologist identifies the brain tumors by visual inspection. Tumor classification process can be extremely time consuming whose accuracy is a function of skills and experience of the radiologist. With the increase in the number of patients with MRI scans, the amount of data to be analyzed daily is large, which makes the reading based on visual interpretation expensive and slow.
Classification of brain tumors into various pathological types is more challenging than the binary classification. The related challenges are attributed to factors such as high variations in shape, size, and intensity of the same tumor type [3] and similar appearances for different pathological types [4]. A false negative diagnosis of a brain tumor can lead to a decreased chance of survival for the patient. A false positive diagnosis can result in traumatic experiences for the patients and their families. To overcome drawbacks of the manual diagnosis, there has been a surge of interest in designing automated image processing systems [5][6][7]. Many researchers have suggested techniques to improve the quality of the computer aided design (CAD) system that classifies tumors in brain MRI.
Machine learning (ML) methods used in the classification process are usually based on different steps such as preprocessing, dimension reduction, feature extraction, feature selection, and classification. The feature extraction represents the crucial phase in an effective CAD system [8]. It is a challenging task and requires prior knowledge about the problem domain since the classification accuracy depends strongly on the quality of the feature extraction. Traditional techniques for feature extraction can be classified into three types: spatial domain features, wavelet and frequency features and contextual and hybrid features. The state-of-the-art CAD methods yield an improved performance due to the use of deep learning (DL) technology.
DL represents a subset of ML, which does not require handcrafted features [9][10]. It has been successfully employed to reduce the gap between human brain and computers in many applications, including pattern recognition, object detection, natural language understanding, sensory data perception, and so on. DL has already surpassed state-of-the-art methods in several fields such as generating text [11], face verification [12], image description [13], the game of Go [14], and grand challenges [15]. According to [16] there were about 220 paper publication focusing on DL for medical image diagnosis in 2019. Around 190 of these works used Convolutional Neural Network (CNN). DL permits the use of pre-trained CNN models such as AlexNet [17], GoogLeNet [18], ResNet-34 [19] for medical image diagnosis especially for brain tumor classification.
CNNs have exhibited high performance as an inference engine after being carefully trained on huge, labeled datasets such as ImageNet [15] which contains more than one million images. However, it is hard to exploit such deep CNNs in the medical field. First, the size of the medical datasets is generally small because such datasets need the availability of expert radiologists to manually examine and label the images, which is time-consuming, laborious, and costly. Second, training
deep CNNs is a complex process especially with a small dataset. This is because of the pitfalls for over-fitting or divergence. Third, domain expertise is needed to repeatedly revise the model and adjust the learning parameters of DL models to achieve better performance.
This paper presents various neural network models for brain tumor classification. The remainder of the paper is organized as follows. In Section II, related works on brain tumor detection of MRI images using CNNs are reviewed. A review of some of the main topics discussed in the paper is presented in Section III and the details of the proposed framework are discussed in Section IV. In Section V, the effectiveness of the proposed framework is evaluated for brain tumor datasets and the paper is concluded in Section VI.
## II Related Work
In this section, some of the relevant prior works related to automated brain tumor diagnosis using CNNs are reviewed. This review is not meant to be comprehensive. In fact, we have only considered some of the recent related works that have utilized the same brain MRI dataset as us -- see [20] and [21].
In [22], a CNN was utilized to classify the brain MRI images to flag the presence or absence of brain tumors in the image. Three test cases were considered, where the convolution kernel size (size 2\(\times\)2 or 3\(\times\)3) and max pooling size (_e.g.,_ 2\(\times\)2) and hyper parameter values for training were different for each test case. Each of these cases were trained with 5 different epoch values {10, 20, 30, 40 and 50}. The number of convolutional (and max pooling) layers were considered as 2, 4 and 5 with two fully connected (FC) layers (with similar neuron counts). To check the robustness of the proposed network, the training data and the testing data were selected from [20] and [21], respectively.
In [23], first the MRI dataset (_e.g.,_ from [21]) was pre-processed (converted from RGB to grayscale and scaled down to 224\(\times\)224 pixels). Next, a CNN model was proposed consisting of six convolutional layers with different kernel sizes (1\(\times\)1, 3\(\times\)3, and 5\(\times\)5, each followed by a max pooling layer with size 2\(\times\)2). The next layers were two FC considering 50% dropout. Batch size of 32 was considered when training the network for 30 epochs.
A CNN model with three 3\(\times\)3 convolution layers (each followed by a max pooling layer) and two FC layers was trained for 250 epochs in [24] on the [21] dataset where the pixel values of the original images were scaled down. The batch size was set at 32. Next, data augmentation with random rotation, flip and zoom was applied to the image and the augmented images were added to the original dataset and fed to the model for retraining with the same parameters. It was shown that data augmentation provided better network accuracy. Due to the small size of brain tumor datasets generally, [25] proposed to use transfer learning [26]. In practice, several pre-trained CNN models with ImageNet [15] dataset were utilized as the backbone of the DL. A data augmentation technique consisting of rotation, horizontal and vertical flip was also performed on the normalized and scaled MRI images (_e.g.,_[21]). The different CNN models of ResNet, GoogleNet and EfficientNet (initialized with weights obtained by ImageNet [15] dataset) were considered with EfficientNet outperforming the other networks.
## III Background
In this section, a review of some important concepts related to CNNs and skip connections are provided. A brief discussion of MRI images and their usage in brain tumor detection concludes this section.
### _CNNs_
A CNN is a feedforward neural network (NN) architecture from the class of DL networks which was inspired by the human Visual Cortex [27]. These networks are useful for processing data with grid-like topologies such as pixel data processing and recognizing patterns in images [28]. CNNs are highly applicable in the fields of image processing, face recognition, object detections, computer vision and natural language processing.
Each CNN model contains different types of layers. The input of each layer in a CNN is called the input feature map while the output is called the output feature map. The most important layer in a CNN, which is also always the first one, is the convolutional (conv) layer. A conv layer is responsible for extracting features from the data. It consists of a set of 3D filters. During training of the network, each filter can be considered as a set of trainable cube-shaped weights. A filter can be considered as a set of 2-D kernels.
For each filter, the depth (called the number of channels) of the filter, which is also the number of kernels, is always the same as the depth of the input feature map. When designing a CNN architecture, the number of filters for each conv layer and the size of the kernels (_i.e._, height and width of the filter) are parameters chosen by the designer. Note that depending on these parameters, the conv layer can contain the most user-specified parameters of the network [29].
The pooling layer, known for down-sampling, is used to lower the size of the convolved output feature map. Similar to the conv layer, in the polling operation, a weight-less filter is applied to the input feature map and depending on the type of the pooling operation, the values of output feature map are calculated. As an example, in max pooling, the maximum of the values of the input feature map covered within each kernel of the filter represents the corresponding output feature map in max pooling operation. For average pooling, the average of the values within each kernel of the filter represent the corresponding output feature map [29].
Each CNN model can contain one or more conv layers followed by pooling layers. The final layers of the CNN architecture consist of fully connected (FC) layers. Each of the mentioned layers can have different parameters (_i.e._, weights and biases) that need to be optimized during the training of the network to perform different tasks on the input data.
### _Skip Connections in NNs_
With larger (deeper) networks, to solve the accuracy degradation issue, reference [30] proposed to use skip connections. The goal of a skip connection is to add the output of a layer in the network (_i.e.,_ identity mapping) to the output of a deeper layer before applying the activation function of the deeper layer. Fig. 1 shows an example of a basic block of skip connections, which we call a skip connection block (SCB). The number of conv layers in the direct path of the SCB may be varied. In addition, a set of conv layers may also be applied to the skipped value \(X\) in Fig. 1 on the upper path before the addition. The added skip connections do not add many extra parameters or increase the computational complexity of the network [30].
### _Brain Tumor Detection_
A brain tumor is an appearance of an unwanted mass of tissue in the brain due to the abnormal growth of brain cells which can be malignant (cancerous) or benign (non-cancerous). According to the National Brain Tumor Society [31], an estimated 700,000 people are living with a brain tumor in the United States where around 1800 will die from a malignant tumor. Therefore, early diagnosis of this deadly disease is highly critical for suitable treatments.
MRI is a form of scan that produces a detailed image of the inside of the tissue using high magnetic fields and radio waves [32]. A benign tumor has distinct, smooth and regular borders while a malignant tumor has irregular borders and grows faster than a benign tumor. Fig. 2 shows an MRI image of a non-cancerous and a cancerous brain tumor. To manually detect a brain tumor, an experienced specialist doctor is required to analyze the tumor which can be a time consuming process assuming the availability of the expert in the location. Therefore, automating the detection of brain tumors in their early stages is highly encouraged. In the early stages of research, different image processing and data mining techniques have been employed to analyze brain tumors [2]. Recently, with the advent of ML techniques, these networks have been employed in the process of tumor diagnosis with great success.
## IV Network Architecture Optimization
In this work, we describe our investigation to assess the efficacy of different network architectures targeting brain tumor detection. The objective of this study was to optimize the inference accuracy of the network for the classification of brain tumors to benign and malignant types. We considered different architectures for CNNs as well as the combination of CNNs and SCBs.
To obtain different CNN architectures, we used network widening (_i.e._, changing the number of filters in a conv layer) and network deepening (_i.e._, adding more conv \(+\) pooling layers to the network) techniques. We also changed the number of filters in the conv layer of the SCB. Note that in the networks, batch normalization (BN) and max pooling (Pool) are applied after each convolutional layer. We call the combination of a conv layer, BN, and Pool a conv block (CB).
The baseline architecture, which is depicted in Fig. 3, had two convolutional layers with sizes of 32 and 64 filters and two fully connected layers with sizes of 1024 and 256 neurons, respectively (this is denoted as Arch-1). Since the problem is a binary classification one, the last FC layer has one neuron for its output. In all networks considered in this work, the kernel sizes of the conv and pooling layers are set as 3\(\times\)3 and 2\(\times\)2, respectively. In this study, we assumed the size of the fully connected layer remains unchanged. For any architectures proposed, the impact of data augmentation on the output accuracy was also assessed. For data augmentation, we added horizontally and vertically flipped images (randomly generated) from the training dataset to the original set to obtain a larger (augmented) dataset.
To generate new network architectures, first we doubled the number of filters in both convolutional layers of the base model to obtain Arch-2 (network widening). Arch-3 was obtained by adding a new layer to the base model (network deepening) while in Arch-4, widening was performed on Arch-3 with doubled filter counts for all the convolutional layers (network deepening and widening of the original layers). Arch-5 was our largest model with four convolutional layers (deepening).
When evaluating the impact of incorporating SCBs into the CNN, first, Arch-6 (depicted in Fig. 4) was defined as the base model with a single SCB. In this study, similar to Fig. 1, on the direct path of the SCB, two conv layers were considered with a single conv layer located on the upper path for the skip connection. For all the conv layers in the SCB, the number of filters was chosen to be the same. This number represented by the SCBS parameter (_e.g._, SCBS \(=\) 3 in Fig. 4).
In this work, the SCB in the network architecture is always located after the CB, which means the output of the CB (_e.g._, the output of Pool2 layer in Fig. 3) is connected to the input of the skip connection (_i.e._, \(X\) in Fig. 1). The CNN baseline model was combined with SCBS = 3 in Arch-7 and represented in Fig. 5 as an example for the networks which combined CB and SCB. In Arch-8, the baseline model was deepened (to four layers like Arch-5) whereas in Arch-9, the network was both widened and deepened (to three layers like in Arch-4.) Finally, SCBS was increased to eight to see the impact of number of SCB filters on the network accuracy for the CNN baseline model combined with SCB.
## V Results and Discussions
We begin this section by explaining the experimental setup considered in this work. Next, we present the network accuracy values obtained for the different architectures with and without the data augmentation technique.
### _Experimental Setup_
Results of the experiments mentioned in Section IV are presented in Table 1 and Table 2. Table 1 presents the results for different configurations of CNN-based networks without SCB while Table 2 presents different configurations for CNN-based networks with SCB. For the dataset, we have considered the two datasets of [20] with 253 data values (155 cancerous and 98 non-cancerous) and [21] with 3000 data values (1500 cancerous and 1500 non-cancerous). Similar to [22], since training accurate DL models requires a large number of images, we have trained the network with the larger dataset [21] and tested that on the smaller dataset [20].
For the data augmentation technique, the mentioned flipping techniques are applied to all the samples in [21] and added to the original set. The results will be provided in the next section. For all networks, we set the training batch size to 15 and the number of epochs to 60.
### _Discussion of the Results_
In this section, the network performance, which is the inference accuracy of the different networks, is reported and discussed.
#### V-B1 Data Augmentation
Based on the results, in most cases (seven out of ten architectures), we see no improvement in neural network's output accuracy using augmentation. In the case of CNN models without SCB, for one case of widening (Arch-2) and one case of deepening (Arch-5), we see that augmentation has increased the network accuracy by on average 0.6%. The highest accuracy achieved in the case of CNN models is also obtained with augmentation applied to the largest network proposed (_i.e._, Arch-5).
When considering the combination of CNN and SCB, the network accuracy is increased using data augmentation in only one case of deepening for Arch-8 (which is similar to Arch-5 in the CNN part). As it can be seen from the results, the impact of data augmentation for the utilized training dataset of [21] is dependent on the architecture of the network.
Fig. 4: The baseline architecture (Arch-6) with SCB.
Fig. 5: Arch-7 as an example of a network which combines CNN and SCB.
Fig. 3: The baseline architecture (Arch-1), which is the smallest CNN utilized for classification of brain tumors.
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \cline{3-8} \multicolumn{1}{c}{} & \multicolumn{1}{c|}{} & \multicolumn{4}{c|}{Convs} & \multicolumn{2}{c|}{SCBs} & \multicolumn{2}{c|}{FCs} & \multicolumn{1}{c|}{} \\ \cline{2-8} \multicolumn{1}{c}{} & Augmentation & conv1 & conv2 & conv3 & conv4 & FC1 & FC2 & accuracy \\ \hline \multirow{3}{*}{Arch-1} & No & 32 & 64 & - & - & 1024 & 256 & 99.20 \\ \cline{2-8} & Yes & 32 & 64 & - & - & 1024 & 256 & 99.20 \\ \hline \hline \multirow{3}{*}{Arch-2} & No & 64 & 128 & - & - & 1024 & 256 & 99.80 \\ \cline{2-8} & Yes & 64 & 128 & - & - & 1024 & 256 & 99.20 \\ \hline \multirow{3}{*}{Arch-3} & No & 32 & 64 & 128 & - & 1024 & 256 & 99.20 \\ \cline{2-8} & Yes & 32 & 64 & 128 & - & 1024 & 256 & 99.20 \\ \hline \hline \multirow{3}{*}{Arch-4} & No & 32 & 64 & 128 & - & 1024 & 256 & 99.20 \\ \cline{2-8} & Yes & 32 & 64 & 128 & - & 1024 & 256 & 98.80 \\ \hline \hline \multirow{3}{*}{Arch-5} & No & 64 & 128 & 256 & - & 1024 & 256 & 99.20 \\ \cline{2-8} & Yes & 64 & 128 & 256 & - & 1024 & 256 & 99.20 \\ \hline \end{tabular}
\end{table}
Table 1: Accuracy values for various neural network models
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|} \cline{3-8} \multicolumn{1}{c}{} & \multicolumn{4}{c|}{Convs} & \multicolumn{2}{c|}{SCBs} & \multicolumn{2}{c|}{FCs} & \multicolumn{1}{c|}{} \\ \cline{2-10} \multicolumn{1}{c}{} & Augmentation & conv1 & conv2 & conv3 & conv4 & conv1 & FC1 & FC2 & accuracy \\ \hline \multirow{3}{*}{Arch-6} & No & - & - & - & - & 3 & 1024 & 256 & **99.60** \\ \cline{2-10} & Yes & - & - & - & - & 3 & 1024 & 256 & 98.80 \\ \hline \multirow{3}{*}{Arch-7} & No & 32 & 64 & - & - & 3 & 1024 & 256 & **99.60** \\ \cline{2-10} & Yes & 32 & 64 & - & - & 3 & 1024 & 256 & 98.80 \\ \hline \multirow{3}{*}{Arch-8} & No & 32 & 64 & 128 & 256 & 3 & 1024 & 256 & 98.80 \\ \cline{2-10} & Yes & 32 & 64 & 128 & 256 & 3 & 1024 & 256 & 98.80 \\ \hline \multirow{3}{*}{Arch-9} & No & 64 & 128 & 256 & - & 3 & 1024 & 256 & **99.60** \\ \cline{2-10} & Yes & 64 & 128 & 256 & - & 3 & 1024 & 256 & 98.80 \\ \hline \multirow{3}{*}{Arch-10} & No & 32 & 64 & - & - & 8 & 1024 & 256 & **99.60** \\ \cline{2-10} & Yes & 32 & 64 & - & - & 8 & 1024 & 256 & 99.20 \\ \hline \end{tabular}
\end{table}
Table 2: The accuracy values for CNNs with Skip Connections
#### V-C2 Network Architecture
Evaluating the accuracy values of the different network architectures, it can be seen that in the case of CNNs without SCBs (see Table 1), widening the network by one layer did not change the accuracy of the network (Arch-1 vs Arch-3 without data augmentation). The same result also holds when a deepened network (Arch-2) was widened (Arch-4). However, a combination of the proposed techniques (deepening, widening, and augmentation) produced the best accuracy result in Arch-5 where 99.60 accuracy was achieved.
On the other hand, for networks with SCBs, in almost all architectures (except Arch-8), the best accuracy value (_i.e._, 99.6%) was achieved without any data augmentation. With the same architectures, sometimes adding SCBs resulted in higher accuracy (Arch-1 vs Arch-7) while sometimes the CNN alone resulted in better accuracy (Arch-5 vs Arch-8). Increasing the number of filters in the SCB (_i.e._, SCBS) only had an impact when the data augmentation technique was utilized (Arch-7 vs Arch-10). Note that in this study, we did not change the size and number of FC layers. The reason was that we wanted to assess the efficacy of the convolutional and skip connection layers on the network accuracy. In fact, we have increased the number of FC layers for Arch-5 (best network in the CNN models) and observed that the network accuracy was lower than the maximum values obtained (_i.e._, 99.6%).
## VI Conclusions
In this paper, we studied the efficacy of Convolutional Neural Networks (CNNs) with the addition of skip connections to detect brain tumors from Magnetic Resonance Imaging (MRI) images. Considering different architectural CNNs such as widening and deepening techniques and the position of the skip connection, the accuracy of the network was compared with a baseline CNN model. The results showed that techniques such as deepening, widening, augmentation, and utilizing SCBs improved the accuracy results in general and the best results were obtained when a subset of the techniques were employed judiciously.
|
2308.15796 | A Neural Network Approach for Orienting Heavy-Ion Collision Events | A convolutional neural network-based classifier is elaborated to retrace the
initial orientation of deformed nucleus-nucleus collisions by integrating
multiple typical experimental observables. The isospin-dependent
Boltzmann-Uehling-Uhlenbeck transport model is employed to generate data for
random orientations of ultra-central uranium-uranium collisions at
$E_\text{beam} = 1\, \text{GeV/nucleon}$. Statistically, the data-driven
polarization scheme is essentially accomplished via the classifier, whose
distinct categories filter out specific orientation-biased collision events.
This will advance the deformed nucleus-based studies on nuclear symmetry
energy, neutron skin, etc. | Zu-Xing Yang, Xiao-Hua Fan, Zhi-Pan Li, Shunji Nishimura | 2023-08-30T06:58:46Z | http://arxiv.org/abs/2308.15796v2 | # A Neural Network Approach for Orienting Heavy-Ion Collision Events
###### Abstract
A convolutional neural network-based classifier is elaborated to retrace the initial orientation of deformed nucleus-nucleus collisions by integrating multiple typical experimental observables. The isospin-dependent Boltzmann-Uehling-Uhlenbeck transport model is employed to generate data for random orientations of ultra-central uranium-uranium collisions at \(E_{\rm beam}=1\,\)GeV/nucleon. Given the existence of pronounced fluctuations and the impact of spectators in specific scenarios, the classifier still encounters a non-neglectable accuracy loss. Statistically, the data-driven polarization scheme is essentially accomplished via the classifier, whose distinct categories filter out specific orientation-biased collision events. This will advance the studies on nuclear symmetry energy, neutron skin, and the high-momentum tail of deformed nuclei.
## I Introduction
The multipole deformation of atomic nuclei is commonly attributed to collective motion arising from the interactions among valence nucleons [1; 2; 3; 4]. Traditionally, the quadrupole deformation can be measured experimentally from the rotational spectra of the nuclear excited state or the electric quadrupole moments derived from the hyperfine splitting of the atomic spectral line [3]. Since the year 2000, research on deformed nuclei through heavy-ion collisions has been initiated in the uranium-uranium collision system [5]. Recently, at ultra-relativistic energies, a strong linear correlation between various-order anisotropic flows and multipole deformations has been discovered [6; 7], leading to significant implications for finding signatures of the nuclear deformation.
On the other hand, with the advancement of technology, machine learning has emerged as a powerful tool for investigating various properties of nuclear structure and reactions, particularly with respect to nuclear masses [8; 9; 10; 11] and nuclear radii [12; 13; 14; 15]. Aiming at nuclear deformation, deep neural network-based generative models are being developed for producing potential energy surfaces, rotational inertia, and vibrational inertia of deformed nuclei, which can be further utilized to investigate excitation spectra within the five-dimensional collective Hamiltonian approach [16; 17]. At the same time, a series of machine learning approaches, including support vector machine, artificial neural network [18], convolutional neural network (CNN) [19], and light gradient boosting machine [20], were employed to determine impact parameters in heavy-ion collisions based on the simulation via quantum molecular dynamics (QMD) [21; 22] and ultra-relativistic QMD (UrQMD) models [23; 24; 25], achieving impact parameter identification accuracy within 0.8 fm [26; 27; 28; 29]. Subsequently, the 2D distributions of protons and neutrons on transverse momentum and rapidity plane are input to find signatures of the nuclear symmetry energy [30], providing a reliable reference for experimental studies.
From the current research perspective, an important aspect missing in the studies of deformed nuclear reactions should be noted that, while the statistical effects of deformed nuclei on heavy-ion collisions have been revealed, the orientation issue regarding individual events has not yet garnered substantial focus. Absolutely or partially orienting the collision events will undoubtedly provide a wealth of information on the reactions and structure of deformed nuclei. For example, determining the symmetry dependence of collective flows in orientations without spectators would improve the description of the equation of state, which benefits nuclear astrophysics, such as binary neutron star merger simulations [31]. Moreover, exploring higher-order deformation effects through specific orientations would yield valuable insights.
This work aims to develop a multi-input CNN to map the nuclear initial state orientations of the uranium-uranium reaction systems. Since experimental orientation information is lacking, the network will be initially trained using simulated results based on the isospin-dependent Boltzmann-Uehling-Uhlenbeck (IBUU) transport model [32; 33]. Once trained with statistical observables matching experimental data reasonably well, the network can further filter the orientations for experiments.
## II Initialization of IBUU transport model
The IBUU transport model employs Monte Carlo method to simulate the phase-space evolution of baryons and mesons during heavy-ion collisions, encompassing essential physical processes such as elastic and inelastic scattering, particle absorption, and decay [34]. The version we employed [35; 36; 37; 38; 39] has incorporated the Coulomb effect [37], Pauli blocking, and medium effects on scattering cross sections [40], etc. The used single nucleon potential includes a Skyrme-type parametrization isoscalar term and an exponential isovector term [41; 36], which
reads
\[U(\rho)=A(\rho/\rho_{0})+B(\rho/\rho_{0})^{\sigma}, \tag{1}\]
where \(\sigma=1.3\), \(A=-232\,\)MeV accounts for the attractive part, and \(B=179\,\)MeV accounts for the repulsive part. These choices correspond to an incompressibility coefficient \(K=230\,\)MeV.
As for nucleon spatial distribution, we select a relativistic mean field (RMF)-based self-consistent calculation [42; 43] with the point-coupling PC-PK1 interaction [44] including the Bardeen-Cooper-Schrieffer pairing to initialize \({}^{238}\)U. Due to its superior capability in delineating the nuclear radii, profiles, and deformations for neutron-rich nuclei, the densities generated by RMF theories have recently been utilized to initialize the IBUU model [45; 46]. Shown in Fig. 1 is the nucleon density distribution of \({}^{238}\)U with a quadrupole deformation \(\beta_{2}=0.287\).
Initially, the intrinsic coordinate systems (\(xyz\)) of the colliding nuclei are set to align with the center-of-mass coordinate system (\(x^{\prime}y^{\prime}z^{\prime}\)) of the reaction. As shown in Fig. 2, an Euler rotation operator (\(\Omega(\varphi,\theta,0)=R_{z}(\varphi)R_{y}(\theta)R_{x}(0)\)) is applied independently to the target and the projectile, where only four degrees of freedom (\(\theta_{1},\varphi_{1}\) for the target, and \(\theta_{2},\varphi_{2}\) for the projectile) are required for each collision event due to the absence of triaxial deformation. Considering that spectator fragments from the projectile can be detected on an event-by-event basis in experiments, we confine the study to the events where the projectiles are completely obstructed by the targets as
\[\theta_{2}\in\begin{cases}[\theta_{1},180^{\circ}-\theta_{1}]&\theta_{1}<90^{ \circ}\\ [180^{\circ}-\theta_{1},\theta_{1}]&\theta_{1}\geq 90^{\circ}\end{cases} \tag{2}\]
and
\[\varphi_{2}=\varphi_{1} \tag{3}\]
with \(\theta_{1}\in[0^{\circ},180^{\circ}]\) and \(\varphi_{1}\in[0^{\circ},180^{\circ}]\). In experiments, events with the target spectator fragments appearing only in one direction can also be filtered out to determine ultra-central collisions. As a comparison, nucleon density distribution constrainingly calculated at \(\beta_{2}=0\) point are also exploited to initialize the spatial distribution. Under the present densities, the local density approximate Fermi gas method is employed to generate the momentum distributions. Within the intermediate energy range, increasing the beam energy enhances the deformation effects [45], and also produces more hadrons within a single event, which is advantageous to trace back the orientation. Accordingly, the beam energy is adjusted to \(1\,\)GeV/nucleon.
## III Convolutional orientation filter
In the IBUU transport model, the comprehensive information of the final state is stored in the phase-space distribution \(f(\vec{r},\vec{p},T)\), where \(\vec{r}\) and \(\vec{p}\) represent the coordinate and momentum of a hadron, respectively. The variable \(T\) denotes the type of the hadron, which includes \(p\), \(n\), \(\pi^{+}\), \(\pi^{0}\), \(\pi^{-}\), \(\Delta^{++}\), \(\Delta^{+}\), \(\Delta^{0}\), \(\Delta^{-}\). As reactions occur, the anisotropy in coordinate space is transferred to momentum space. As such, the redundant information in the phase-space can be eliminated, retaining only the physical quantities that are empirically considered relevant to the collision orientation and organized into three
Figure 2: Simulated schematic for uranium-uranium collision, where \(x-z\) plane is the reaction plane.
Figure 1: The ground-state proton (left panel) and neutron (right panel) densities for \({}^{238}\)U in the \(r_{\perp}-x\) (\(r_{\perp}=\sqrt{(y^{2}+z^{2})}\)) coordinate system calculated by relativistic mean field with PC-PK1 interaction.
aspects as follows:
1. The hadron counting \(C(p_{t},y_{0})\) and distributions of anisotropic flows \(v_{n=1,2,3,4}(p_{t},y_{0})\) in central rapidity \(y_{0}(=y/y_{\rm beam})\) and transverse momentum \(p_{t}\) (\(=\sqrt{p_{x}^{2}+p_{y}^{2}}\)). In practice, we adopted grid intervals of \(\Delta p_{t}=0.15\,\)GeV/c and \(\Delta y_{0}=0.1\) for transverse momentum and center rapidity bins, respectively.
2. Mean values of anisotropic flows \(\langle v_{n}\rangle\,(n=1,2,3,4)\) for all the emitted particles.
3. Counting of the high-momentum nucleons (\(p_{t}>0.5\,\)GeV/c) in transverse emission azimuth angle \(\phi\) (\(=\arccos\left(p_{x}/p_{t}\right)\)) and longitudinal emission angle \(\theta_{\perp}\) (\(=\arccos\left(p_{z}/|\vec{p}|\right)\)). The angular intervals are uniformly set at \(\Delta\theta_{\perp}(\Delta\phi)=30^{\circ}\).
In particular, the anisotropic flows are expressed as
\[v_{n}=\left\langle\cos(n\phi)\right\rangle. \tag{4}\]
The organized observables will serve as inputs for the network, as depicted in Fig. 3. Hereinafter, the network will be denoted as the convolutional orientation filter (COF). The output was anticipated to include \(\theta_{1}\), \(\theta_{2}\), \(\varphi_{1}\), and \(\varphi_{2}\), nevertheless, after multiple rounds of training and validation, we have arrived at the following conclusions: 1. According to the Heisenberg uncertainty principle, considering this issue as a linear regression task is relatively less reliable compared to adopting a classification approach; 2. The angle \(\varphi\) demonstrates limited sensitivity to the present inputs; 3. \(\theta=k\) and \(\theta=180^{\circ}-k\) are degenerate states and cannot be distinguished. As such, we categorize the output, based on the \(\theta_{1}\) and \(\theta_{2}\), into six cases (as illustrated in Table 1) and perform one-hot encoding for representation. In this case, a tip-body collision (\(\theta_{1}=0^{\circ},\theta_{2}=90^{\circ}\)) would be labeled as \([0,0,1,0,0,0]\).
The robustness of final-state harmonic flow information within a single event is significantly influenced by the number of emitted particles. At relativistic energies, the production of hadrons is often increased by orders of magnitude compared to intermediate energies, making the identification of the initial state orientation markedly more reliable. To provide a preliminary estimation, we temporarily neglect the stronger shadow effect originating from spectator fragments under intermediate energy reactions and consider an average of 20 events with identical initial orientations for comparative purposes.
The three aforementioned inputs are individually fed into multiple branch cells composed of convolutional, pooling, and fully connected layers. The outputs of these branch cells are then aggregated in a trunk cell and subjected to batch normalization [47], ensuring a stable feature distribution. An essential point that must be emphasized is that the network consists of 15 layers with intricate connections, whose complexity can lead to some neurons being trapped in the negative range and becoming deactivated under the commonly used ReLU
\begin{table}
\begin{tabular}{c|c c} \hline \hline Case & \(\theta_{1}\) (Target) & \(\theta_{2}\) (Projectile) \\ \hline
1 & \([0^{\circ},30^{\circ}]\cup[150^{\circ},180^{\circ}]\) & \([0^{\circ},30^{\circ}]\cup[150^{\circ},180^{\circ}]\) \\ \hline
2 & \([0^{\circ},30^{\circ}]\cup[150^{\circ},180^{\circ}]\) & \([30^{\circ},60^{\circ}]\cup[120^{\circ},150^{\circ}]\) \\ \hline
3 & \([0^{\circ},30^{\circ}]\cup[150^{\circ},180^{\circ}]\) & \([60^{\circ},120^{\circ}]\) \\ \hline
4 & \([30^{\circ},60^{\circ}]\cup[120^{\circ},150^{\circ}]\) & \([30^{\circ},60^{\circ}]\cup[120^{\circ},150^{\circ}]\) \\ \hline
5 & \([30^{\circ},60^{\circ}]\cup[120^{\circ},150^{\circ}]\) & \([60^{\circ},120^{\circ}]\) \\ \hline
6 & \([60^{\circ},120^{\circ}]\) & \([60^{\circ},120^{\circ}]\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: The initial collision orientations corresponding to the six classification cases.
Figure 3: Schematic diagram of the structure of the convolutional orientation filter (COF) neural network.
[48] activation function for nonlinearity, especially after multiple iterations. To address this issue and improve convergence, we adopt the LeakyReLU activation function [49] to avoid gradient vanishing. Ultimately, through multiple iterations constraint via the cross-entropy loss function [50], the network generates orientation classifications that have been normalized by the Softmax function [51]. The meticulously designed hyperparameter set for the COF network architecture is listed in Appendix A, which can also be employed for other transport models, such as a multiphase transport model [52; 53; 54], UrQMD model [23; 24; 25], and antisymmetrized molecular dynamics model [55; 56], etc.
## IV Results and Analysis
In the classic picture, the orientation of collisions is random, necessitating averaging over all events to search for the signatures of deformation. Before discussing the COF generation, the observable \(\langle\langle v_{2}\rangle_{l}^{2}\rangle\) needs to be examined, as it has been proven to be a sensitive probe of quadrupole deformation [7]. The \(\langle\langle v_{2}\rangle_{l}^{2}\rangle\) is shown (the blue color series) in Fig. 4, where the inner and outer brackets respectively represent the averaging elliptic flow over \(l\) events with the same orientation and averaging over all orientations. The response relation between \(\langle\langle v_{2}\rangle_{l}^{2}\rangle\) and the quadrupole deformation \(\beta\) can be expressed as
\[\langle\langle v_{2}\rangle_{l}^{2}\rangle=a_{l}+f(\beta), \tag{5}\]
where the fluctuation \(a_{l}=\langle\langle v_{2}\rangle_{l}^{2}\rangle_{\beta=0}\) corresponds to the blue dashed curve and the deformation effect \(f(\beta)\) is manifested as the difference between the blue solid and dashed curves. Only \(l=1\) is experimental observable, while larger \(l\) characterizes the variations in the strength of deformation effects as the hadron yield increases in reaction systems. In this case, we define the strength of deformation effect as
\[I=\frac{f(\beta)}{a_{l}}, \tag{6}\]
which corresponds to the red curve of Fig. 4. As \(l\) increases, the number of produced hadrons in the same orientation increases, leading to a reduced fluctuation, while the \(f(\beta)\) remains constant during this process, resulting in increasing strength of deformation effect. The constant \(f(\beta)\) also indirectly indicates that the geometric effect is largely independent of the baryon number of a reaction system.
We shift our attention to the predictions of the COF network. Due to the abundance of simulated events for training, overfitting has been effectively mitigated, indicating that the results generated by the network exhibit strong generalization ability. The final analysis reveals that when combining 20 eve
Figure 4: The mean square elliptic flows resulting from the combination of \(l\) events with the same orientation (curves in the blue color series) and the strength of the deformation effect \(I\) (curves in the red color series). See text for details.
Figure 5: The probability distribution of the actual case at different predicted values (channel) with (a) combining 20 events \(l=20\) and (b) individual events \(l=1\).
tion for training, the accuracy reaches an impressive 67%, while in the case of event-by-event training, the accuracy dramatically drops to a mere 28%. The accuracy is positively correlated with \(I\), but even for \(l=20\), the deformation-induced effects remain comparable to the fluctuations (see Fig. 4). While future improvements might enhance COF performance, there will inherently remain unclassifiable events due to statistical fluctuation errors.
Displayed in Fig. 5 are the probability distributions of the actual cases at different predicted cases, where the normalization condition is \(\sum_{i(\text{or }j)}P_{i(\text{or }j)}=1\) with the subscript \(i,j\) representing the predicted and the true cases, respectively. Taking the black solid line in (a) as an example, the situation classified as case-1 is actually composed of \(\sim 80\%\) case-1 and \(\sim 20\%\) case-2. To avoid confusion and consider the statistical significance of each prediction, we will designate the six predictions as six channels. It is evident that channel-1 and -6 exhibit better discriminative power, which corresponds to the commonly mentioned body-body and tip-tip collisions [5; 7] and are crucial for investigating various properties of deformed nuclei. For Fig. 5(b), the network polarization performance explicitly diminishes, yet the partial polarization brought by channel-1 and -6 remains effective. It is worth emphasizing that, due to the limited capability of the IBUU model to accurately emulate spectator fragments, the capability of COF to distinguish between cases with only trace spectator fragments (case-1, -4, and -6) and cases with a larger number of spectator fragments (case-2, -3, and -5) may also be weakened. The spectator fragments are experimentally distinguishable on an event-by-event basis, we hence renormalize case-1, -4, and -6 in channel-1, obtaining the proportion of body-body collisions is 45% with \(l=1\).
Empirically, elliptic flow \(v_{2}\) is sensitive to collision orientations, the count proportion distributions of which across different channels are displayed in Fig. 6. The six channels are observed to be statistically divided into three categories in Fig. 6(a) with \(l=20\). Channel-1 exhibits a higher distribution in regions with stronger \(v_{2}\), channel-2 and -4, as the second tier, progressively cluster around the zero elliptic flow intensity, and channel-3, -5, and -6 encompass the category of events with the weakest elliptic flow. This order is clearly related to the initial state overlap eccentricity, where the overlap refers to the projection of the participants on the \(x-y\) plane [34]. Eventually, we discover that these three categories appear to be independent of the target orientation and are solely determined by the projectile orientation. Turning to the case of \(l=1\) as shown in (b), the corresponding patterns are largely attenuated as anticipated due to fluctuations. Statistical regularities also emphasize a key point that it is challenging to distinguish the orientations of colliding nuclei through conventional data processing methods since the appreciable amount of events with zero \(v_{2}\) regardless of channel. As such, the emerging artificial intelligence technologies geared toward combining multiple observables may be the only solution to this problem.
Finally, the mean squared elliptic flows \(\langle v_{2}^{2}\rangle\) across different channels are investigated and shown in Fig. 7. The \(\langle v_{2}^{2}\rangle\) for different orientation cases has been theoretically calculated and is represented by the blue dashed line, which can also be interpreted as the distribution predicted by the network with perfect accuracy. For the case of (a) \(l=20\), the \(\langle v_{2}^{2}\rangle\) of the screened events incredibly aligns exactly with the theoretical calculation, affirming the accuracy of COF reaches a level where it is no longer sensitive to the observable. Adhering to the Heisenberg uncertainty principle, this suggests that further improvement in accuracy is difficult. Compared to the average over all events (red dashed line), channel-1 vividly amplifies the effect of deformation, which corresponds virtually to the results shown in Fig. 6 (a). For (b) \(l=1\), a substantial disparity between the COF channels and the theoretical ideal cases occurs, which can be attributable to the non-constant fluctuations in different channels caused by the strong individual fluctuation in the training set. Hence, the fluctuation patterns need to be reconsidered in an orientation-dependent scheme as
\[\langle v_{2}^{2}\rangle_{\text{channel,Theo-2}}=a_{\text{channel}}+f(\beta)_{ \text{channel}} \tag{7}\]
Figure 6: The distributions of event count proportions in the elliptic flow across different predicted values (channels) with (a) combining 20 events \(l=20\) and (b) individual events \(l=1\).
with
\[f(\beta)_{\rm channel}=\langle v_{2}^{2}\rangle_{\rm channel,Theo-1}-a_{\rm avg,}, \tag{8}\]
where the fluctuation \(a_{\rm channel}=\langle v_{2}^{2}\rangle_{\rm channel,\beta=0}\) corresponds to the collisions between spherical nuclei, and the \(a_{\rm avg.}\) is the average value for all events (red parallel line). In particular, the \(a_{\rm channel}\) can be measured experimentally by selecting a nearby spherical nucleus, such as \({}^{208}\)Pb. The \(\langle v_{2}^{2}\rangle_{\rm channel}\) from the above calculation is represented by the magenta dash-dot line labeled as Theo-2. It can be seen that for channel-1, -4, and -6, which only involve a limited number of spectators, the difference between COF and the Theo-2 results is relatively minor, ascribed to the circumstance that when calculating fluctuations through ultra-central spherical nucleus collisions, spectators are entirely absent. This demonstrates that spectators play an important role in elliptic flow at current energy, deserving a more in-depth study. From another perspective, for the real scenarios represented by case-1, -4, and -6, it is feasible to accurately measure the response relation between initial eccentricity and elliptic flow.
With the aid of the COF network, orientation-dependent physical quantities would become experimentally measurable, which will enable us to capture more information from laboratories such as HIAF/IMP, J-PARC, FAIR, NICA, HIMAC, etc., and will greatly deepen our understanding of the geometric effects in heavy-ion collisions. In future research, utilizing the elliptic flow in channel-1 might offer a geometric effect-based means to further explore the impact of symmetry energy and equation of state. Furthermore, theoretical research [57] has indicated that high-momentum tails, resulting from short-range correlations, are more likely to manifest at the nuclear surface. Therefore deformed nuclei with larger surface areas will undoubtedly provide an excellent platform for investigating this phenomenon, which will also benefit from the COF network. In summary, this research would greatly broaden the horizons of heavy-ion collision studies, facilitating a deeper comprehension of both nuclear structure and nuclear reactions.
## V Summary
Based on the 1 GeV/nucleon uranium-uranium ultra-central collision data simulated using the IBUU transport model, we constructed a composite neural network of multiple observables in a supervised classification mode to retrospectively determine the initial state orientation of the deformed colliding nuclei. Although non-negligible errors persist, this data-driven polarization approach is applicable in a statistical sense. The different channels of the COF network filter out specific orientation-biased collision events. Evidently, the identification capability of the neural network is fundamentally positively correlated with the ratio of deformation effect to fluctuation, where the fluctuation is related to the number of final-state particles and the deformation effect can be diminished to some extent by the influence of spectators at 1 GeV/nucleon. We hence assert that the COF network will certainly be more effective in high-energy reactions.
By contrasting the elliptic flow distributions between the ideal and COF conditions, we observe that spectators indeed play a significant role in reactions, thereby also influencing the determination of orientations. Combining various deformation constraint points (which can be replaced in experiments by different reaction systems, such as Pb-Pb and U-U collision systems), it becomes possible to accurately measure the response relation between the initial eccentricity and the mean square elliptic flow at \(\theta_{1}\approx\theta_{2}\). More importantly, analyzing other observables for the selected events from one or several COF channels will enhance our understanding of geometric effects and aid us in utilizing these effects to explore other nuclear properties, such as the equation of state, short-range correlations, and neutron skin thickness. We anticipate the current network to be combined with a broader range of
Figure 7: The distribution of mean squared elliptic flow \(\langle v_{2}^{2}\rangle\) across different predicted values (channels) with (a) combining 20 events \(l=20\) and (b) individual events \(l=1\). The blue dashed lines represent the ideal scenario when perfect classification is achieved, referred to as Theo-1. The magenta dotted line represents the ideal scenario with an orientation-dependent fluctuation caused by the network, labeled as Theo-2. The red parallel lines represent the average value for all events.
transport models and applied to experimental data measurements as soon as possible.
## VI Acknowledgements
We acknowledge helpful discussions with Prof. Haozhao Liang. This work is supported by the National Natural Science Foundation of China under Grants Nos. 12005175, 11875225. the Fundamental Research Funds for the Central Universities under Grant No. SWU119076, the JSPS Grant-in-Aid for Early-Career Scientists under Grant No. 18K13549, the JSPS Grant-in-Aid for Scientific Research (S) under Grant No. 20H05648. This work was also partially supported by the RIKEN Pioneering Project: Evolution of Matter in the Universe and the INT Program INT-23-1a and Institute for Nuclear Theory.
## Appendix A The Hyperparameter Set of Convolutional Orientation Filter
As indicated in Table 2, the COF network consists of 6 cells, denoted as Cell-n (n=1-6), among which, except for cell-1, which is a convolutional neural network (CNN), all other cells are fully connected neural networks (FCNN). Each cell is composed of several unit layers, including convolutional layer (Conv.), average pooling layer (pooling), fully connected layer (Linear), and batch normalization layer (Batch-Norm).
In the presented table, the initial row and the concluding row of each cell respectively signify its input and output. In this context, \(\text{Input}_{1}\) comprises the following five matrices: \(C(p_{t},y_{0})\), \(v_{1}(p_{t},y_{0})\), \(v_{2}(p_{t},y_{0})\), \(v_{3}(p_{t},y_{0})\), \(v_{4}(p_{t},y_{0})\). \(\text{Input}_{2}\) denotes the mean values of anisotropic flows \(\langle v_{n}\rangle\) (where \(n=1,2,3,4\)) across all emitted particles. The \(\text{Input}_{3}\) and \(\text{Input}_{4}\) correspond to the hadron count in transverse and longitudinal emission azimuth angle. The input for Cell-5 is a combination of the outputs from Cell-3 and Cell-4 noted as \(\text{Output}_{3}\uplus\text{Output}_{4}\), where the symbol \(\uplus\) indicates splicing two vectors, e.g., \([1,3,2]\uplus[2,5,7]=[1,3,2,2,5,7]\). Similarly, the input for Cell-6 is a combination of the outputs from Cell-1, Cell-2, and Cell-5.
For the header of Table 2, "\(D\)" represents the output dimension of the layer, "\(C_{\text{in}}\)" denotes the input channels, "\(C_{\text{out}}\)" signifies the output channels, "\(K_{s}\)" refers to the size of the kernel which includes both convolutional and pooling dimensions, "\(S_{t}\)" indicates the stride used during convolution or pooling operations, and "\(g(x)\)" represents the non-linear activation function with LReLU is \(\text{LeakyReLU}(x)=\max\{0.01\times x,x\}\).
Furthermore, to mitigate the influence of absolute data magnitudes, all input features are subject to min-max normalization, ensuring they fall within the range of 0 to 1. During the training process, a dynamically decreasing learning rate, which reduces as the loss function converges, is applied with the Adaptive Momentum Estimation (Adam) [58] optimizer. The aforementioned definitions and concepts are entirely consistent with the patterns used in PyTorch [59].
|
2306.07158 | Riemannian Laplace approximations for Bayesian neural networks | Bayesian neural networks often approximate the weight-posterior with a
Gaussian distribution. However, practical posteriors are often, even locally,
highly non-Gaussian, and empirical performance deteriorates. We propose a
simple parametric approximate posterior that adapts to the shape of the true
posterior through a Riemannian metric that is determined by the log-posterior
gradient. We develop a Riemannian Laplace approximation where samples naturally
fall into weight-regions with low negative log-posterior. We show that these
samples can be drawn by solving a system of ordinary differential equations,
which can be done efficiently by leveraging the structure of the Riemannian
metric and automatic differentiation. Empirically, we demonstrate that our
approach consistently improves over the conventional Laplace approximation
across tasks. We further show that, unlike the conventional Laplace
approximation, our method is not overly sensitive to the choice of prior, which
alleviates a practical pitfall of current approaches. | Federico Bergamin, Pablo Moreno-Muñoz, Søren Hauberg, Georgios Arvanitidis | 2023-06-12T14:44:22Z | http://arxiv.org/abs/2306.07158v1 | # Riemannian Laplace approximations for Bayesian neural networks
###### Abstract
Bayesian neural networks often approximate the weight-posterior with a Gaussian distribution. However, practical posteriors are often, even locally, highly non-Gaussian, and empirical performance deteriorates. We propose a simple parametric approximate posterior that adapts to the shape of the true posterior through a Riemannian metric that is determined by the log-posterior gradient. We develop a Riemannian Laplace approximation where samples naturally fall into weight-regions with low negative log-posterior. We show that these samples can be drawn by solving a system of ordinary differential equations, which can be done efficiently by leveraging the structure of the Riemannian metric and automatic differentiation. Empirically, we demonstrate that our approach consistently improves over the conventional Laplace approximation across tasks. We further show that, unlike the conventional Laplace approximation, our method is not overly sensitive to the choice of prior, which alleviates a practical pitfall of current approaches.
## 1 Introduction
_Bayesian deep learning_ estimates the weight-posterior of a neural network given data, i.e. \(p(\theta|\mathcal{D})\). Due to the generally high dimensions of the weight-space, the normalization of this posterior is intractable and approximate inference becomes a necessity. The most common parametric choice approximates the posterior with a Gaussian distribution, \(p(\theta|\mathcal{D})\approx q(\theta|\mathcal{D})=\mathcal{N}(\theta|\mu,\Sigma)\), which is estimated _variationally_(Blundell et al., 2015), using _Laplace approximations_(MacKay, 1992) or with other techniques (Maddox et al., 2019). Empirical evidence, however, suggests that the log-posterior is not locally concave (Sagun et al., 2016), indicating that the Gaussian approximation is overly crude. Indeed, this approximation is known to be brittle as the associated covariance is typically ill-conditioned implying a suboptimal behavior (Daxberger et al., 2021; Farquhar et al., 2020), and for this reason, alternative approaches have been proposed to fix this issue (Mackay, 1992). Nonetheless, the Gaussian approximation is widely used due to the many benefits of parametric distributions, over e.g. _Monte Carlo sampling_(Neal, 1995) or _deep ensembles_(Lakshminarayanan et al., 2017).
**In this paper** we argue that the underlying issue is not with the Gaussian approximation, but rather with the weight-space over which the approximation is applied. We show that a Gaussian approximation can locally adapt to the loss by equipping the weight-space with a simple Riemannian metric and performing the approximation tangentially to the associated manifold. Practically, this ensures that samples from the Riemannian approximate posterior land in regions of weight-space yielding low training loss, which significantly improves over the usual Gaussian approximation. We obtain our
Figure 1: Our Riemannian Laplace approximation is a simple parametric distribution, which is shaped according to the local loss landscape through a Riemannian metric.
Riemannian approximate posterior using a generalization of the Laplace approximation (MacKay, 1992) to general Riemannian manifolds. Sampling from this distribution requires solving a system of ordinary differential equations, which we show can be performed efficiently by leveraging the structure of the used Riemannian metric and automatic differentiation. Empirically, we demonstrate that this significantly improves upon conventional Laplace approximations across tasks.
## 2 Background
Notation & assumptions.We consider independent and identically distributed (i.i.d.) data \(\mathcal{D}=\{\mathbf{x}_{n},\mathbf{y}_{n}\}_{n=1}^{N}\), consisting of inputs \(\mathbf{x}\in\mathbb{R}^{D}\) and outputs \(\mathbf{y}\in\mathbb{R}^{C}\). To enable _probabilistic modeling_, we use a likelihood \(p(\mathbf{y}|f_{\theta}(\mathbf{x}))\) which is either Gaussian (regression) or categorical (classification). This likelihood is parametrized by a deep neural network \(f_{\theta}:\mathbb{R}^{D}\rightarrow\mathbb{R}^{C}\), where \(\theta\in\mathbb{R}^{K}\) represent the weights for which we specify a Gaussian prior \(p(\theta)\). The predictive distribution of a new test point \(\mathbf{x}^{\prime}\) equals \(p(\mathbf{y}|\mathbf{x}^{\prime})=\int p(\mathbf{y}|\mathbf{x}^{\prime},\theta )p(\theta|\mathcal{D})\mathrm{d}\theta\) where \(p(\theta|\mathcal{D})\) is the true weight-posterior given the data \(\mathcal{D}\). To ensure tractability, this posterior is approximated. This paper focuses on the Laplace approximation, though the bulk of the methodology applies to other approximation techniques as well.
### The Laplace approximation
The Laplace approximation (la) is widely considered in _probabilistic_ models for approximating intractable densities (Bishop, 2007). The idea is to perform a second-order Taylor expansion of an unnormalized log-probability density, thereby yielding a Gaussian approximation. When considering inference of the true posterior \(p(\theta|\mathcal{D})\), la constructs an approximate posterior distribution \(q_{\textsc{la}}(\theta|\mathcal{D})=\mathcal{N}(\theta|\theta_{*},\Sigma)\) that is centered at the _maximum a-posteriori_ (map) estimate
\[\theta_{*}=\operatorname*{arg\,max}_{\theta}\left\{\log p(\theta|\mathcal{D}) \right\}=\operatorname*{arg\,min}_{\theta}\underbrace{\left\{-\sum_{n=1}^{N} \log p(\mathbf{y}_{n}\mid\mathbf{x}_{n},\theta)-\log p(\theta)\right\}}_{ \mathcal{L}(\theta)}. \tag{1}\]
A Taylor expansion around \(\theta_{*}\) of the regularized loss \(\mathcal{L}(\theta)\) then yields
\[\hat{\mathcal{L}}(\theta)\approx\mathcal{L}(\theta_{*})+\langle\nabla_{\theta} \mathcal{L}(\theta)\big{|}_{\theta=\theta_{*}},(\theta-\theta_{*})\rangle+ \frac{1}{2}\langle(\theta-\theta_{*}),\mathrm{H}_{\theta}[\mathcal{L}](\theta )\big{|}_{\theta=\theta_{*}}(\theta-\theta_{*})\rangle, \tag{2}\]
where we know that \(\nabla_{\theta}\mathcal{L}(\theta)\big{|}_{\theta=\theta_{*}}\approx 0\), and \(\mathrm{H}_{\theta}[\mathcal{L}](\theta)\in\mathbb{R}^{K\times K}\) denotes the Hessian of the loss. This expansion suggests that the approximate posterior covariance should be the inverse Hessian \(\Sigma=\mathrm{H}_{\theta}[\mathcal{L}](\theta)\big{|}_{\theta=\theta_{*}}^{-1}\). The marginal likelihood of the data is then approximated as \(p(\mathcal{D})\approx\exp(-\mathcal{L}(\theta_{*}))(2\pi)^{D/2}\det(\Sigma)^{ \nicefrac{{1}}{{2}}}\). This is commonly used for training hyper-parameters of both the likelihood and the prior (Immer et al., 2021a; Antoran et al., 2022). We refer to appendix A for further details.
Tricks of the trade.Despite the simplicity of the Laplace approximation, its application to modern neural networks is not trivial. The first issue is that the Hessian matrix is too large to be stored in memory, which is commonly handled by approximately reducing the Hessian to being diagonal, low-rank, Kronecker factored, or only considered for a subset of parameters (see Daxberger et al. (2021) for a review). Secondly, the Hessian is generally not positive definite (Sagun et al., 2016), which is commonly handled by approximating the Hessian with the generalized Gauss-Newton approximation (Foresee and Hagan, 1997; Schraudolph, 2002). Furthermore, estimating the predictive distribution using Monte Carlo samples from the Laplace approximated posterior usually performs poorly (Lawrence, 2001, Chapter 5)(Ritter et al., 2018) even for small models. Indeed, the Laplace approximation can place probability mass in low regions of the posterior. A solution, already proposed by (Mackay, 1992, Chapter 4), is to consider a first-order Taylor expansion around \(\theta_{*}\), and use the sample to use the "linearized" function \(f_{\theta}^{\text{lin}}(\mathbf{x})=f_{\theta_{*}}(\mathbf{x})+\langle\nabla_{ \theta}f_{\theta}(\mathbf{x})\big{|}_{\theta=\theta_{*}},\theta-\theta_{*}\rangle\) as predictive, where \(\nabla_{\theta}f_{\theta}(\mathbf{x})\big{|}_{\theta=\theta_{*}}\in\mathbb{R}^ {C\times K}\) is the Jacobian. Recently, this approach has been justified by Khan et al. (2019), Immer et al. (2021), who proved that the generalized Gauss-Newton approximation is the exact Hessian of this new linearized model. Even if this is a linear function with respect to the parameters \(\theta\), empirically it achieves better performance than the classic Laplace approximation.
Although not theoretically justified, optimizing the prior precision post-hoc has been shown to play a crucial role in the Laplace approximation (Ritter et al., 2018; Kristiadi et al., 2020; Immer et al., 2021; Daxberger et al., 2021). This is usually done either using cross-validation or by maximizing the log-marginal likelihood. In principle, this regularizes the Hessian, and the associated approximate posterior concentrates around the map estimate.
Strengths & weaknesses.The main strength of the Laplace approximation is its simplicity in implementation due to the popularization of automatic differentiation. The Gaussian approximate posterior is, however, quite crude and often does not capture the shape locally of the true posterior (Sagun et al., 2016). Furthermore, the common reduction of the Hessian to not correlate all model parameters limit the expressive power of the approximate posterior.
## 3 Riemannian Laplace approximations
We aim to construct a parametric approximate posterior that better reflects the local shape of the true posterior and captures nonlinear correlations between parameters. The basic idea is to retain the Laplace approximation but change the parameter space \(\Theta\) to locally encode the _training loss_. To realize this idea, we will first endow the parameter space with a suitable Riemannian metric (Sec. 3.1) and then construct a Laplace approximation according to this metric (Sec. 3.2).
### A loss-aware Riemannian geometry
For a given parameter value \(\theta\in\Theta\), we can measure the training loss \(\mathcal{L}(\theta)\) of the associated neural network. Assuming that the loss changes smoothly with \(\theta\), we can interpret the loss surface \(\mathcal{M}=g(\theta)=[\theta,\mathcal{L}(\theta)]\in\mathbb{R}^{K+1}\) as a \(K\)-dimensional manifold in \(\mathbb{R}^{K+1}\). The goal of Riemannian geometry (Lee, 2019; do Carmo, 1992) is to do calculations that are restricted to such manifolds.
The metric.We can think of the parameter space \(\Theta\) as being the _intrinsic coordinates_ of the manifold \(\mathcal{M}\), and it is beneficial to do all calculations directly in these coordinates. Note that a vector tangential to the manifold can be written as \(\mathbf{J}_{g}(\theta)\mathbf{v}\in\mathbb{R}^{K+1}\), where \(\mathbf{J}_{g}:\Theta\rightarrow\mathbb{R}^{K+1\times K}\) is the Jacobian of \(g\) that spans the tangent space \(\mathcal{T}_{g(\theta)}\mathcal{M}\) at the point \(g(\theta)\in\mathcal{M}\) and \(\mathbf{v}\in\mathbb{R}^{K}\) is the vector of _tangential coordinates_ for this basis of the tangent space. We can take inner products between two tangent vectors in the same tangent space as which, we note, is now expressed directly in the intrinsic coordinates. From this observation, we define the _Riemannian metric_\(\mathbf{M}(\theta)=\mathbf{J}_{g}(\theta)^{\mathsf{T}}\mathbf{J}_{g}(\theta)\), which gives us a notion of a local inner product in the intrinsic coordinates of the manifold (see ellipsoids in Fig. 2). The Jacobian of \(g\) is particularly simple \(\mathbf{J}_{g}(\theta)=[\mathbb{I}_{K},\nabla_{\theta}\mathcal{L}]\)! such that the metric takes the form
\[\mathbf{M}(\theta)=\mathbb{I}_{K}+\nabla_{\theta}\mathcal{L}(\theta)\nabla_{ \theta}\mathcal{L}(\theta)^{\mathsf{T}}. \tag{3}\]
The exponential map.A local inner product allows us to define the length of a curve \(c:[0,1]\rightarrow\Theta\) as \(\texttt{length}[c]=\int_{0}^{1}\sqrt{\langle\hat{c}(t),\mathbf{M}(c(t))\hat{ c}(t)\rangle}\mathrm{d}t\), where \(\hat{c}(t)=\partial_{t}c(t)\) is the velocity. From this, the _distance_ between two points can be defined as the length of the shortest connecting curve, where the latter is known as the _geodesic curve_. Such geodesics can be expressed as solutions to a system of second-order non-linear ordinary differential equations (odes), which is given in appendix B alongside further details on geometry. Of particular interest to us is the _exponential map_, which solves these odes subject to an initial position and velocity. This traces out a geodesic curve with a given starting point and direction (see Fig. 2). Geometrically, we can also think of this as mapping a tangent vector _back to the manifold_, and we write the map as \(\texttt{Exp}:\mathcal{M}\times T_{\theta}\mathcal{M}\rightarrow\mathcal{M}\).
The tangential coordinates \(\mathbf{v}\) can be seen as a coordinate system for the neighborhood around \(\theta\), and since the exponential map is locally a bijection we can represent any point locally with a unique tangent vector. However, these coordinates correspond to the tangent space that is spanned by \(\mathbf{J}_{g}(\theta)\), which implies that by changing this basis the associated coordinates change as well. By
Figure 2: The parameter space \(\Theta\) of the bnn together with examples of the Riemannian metric and the exponential map. Note that the Riemannian metric adapts to the shape of the loss which causes the geodesic to follow its shape.
orthonormalizing this basis we get the _normal coordinates_ where the metric vanishes. Let \(\mathbf{v}\) the tangential coordinates and \(\bar{\mathbf{v}}\) the corresponding normal coordinates, then it holds that
\[\langle\mathbf{v},\mathbf{M}(\theta)\mathbf{v}\rangle=\langle\bar{\mathbf{v}}, \bar{\mathbf{v}}\rangle\Rightarrow\mathbf{v}=\mathbf{A}(\theta)\bar{\mathbf{v }}\quad\text{with}\quad\mathbf{A}(\theta)=\mathbf{M}(\theta)^{-\nicefrac{{1}}{ {2}}}. \tag{4}\]
We will use the normal coordinates when doing Taylor expansions of the log-posterior, akin to standard Laplace approximations.
### The proposed approximate posterior
In order to Taylor-expand the loss according to the metric, we first express the loss in normal coordinates of the tangent space at \(\theta_{*}\), \(h(\bar{\mathbf{v}})=\mathcal{L}(\text{Exp}_{\theta_{*}}(\mathbf{M}(\theta_{* })^{-\nicefrac{{1}}{{2}}}\bar{\mathbf{v}}))\). Following the standard Laplace approximation, we perform a second-order Taylor expansion of \(h\) as
\[\hat{h}(\bar{\mathbf{v}})\approx h(0)+\langle\partial_{\bar{\mathbf{v}}}h( \bar{\mathbf{v}})\big{|}_{\bar{\mathbf{v}}=0},\bar{\mathbf{v}}\rangle+\frac{1 }{2}\langle\bar{\mathbf{v}},\text{H}_{\bar{\mathbf{v}}}[h](\bar{\mathbf{v}}) \big{|}_{\bar{\mathbf{v}}=0}\bar{\mathbf{v}}\rangle, \tag{5}\]
where \(\partial_{\bar{\mathbf{v}}}h(\bar{\mathbf{v}})\big{|}_{\bar{\mathbf{v}}=0}= \mathbf{A}(\theta_{*})\bar{\mathbf{v}}\nabla_{\theta}\mathcal{L}(\theta)\big{|} _{\theta=\theta_{*}}\approx 0\) as \(\theta_{*}\) minimize the loss and \(\text{H}_{\bar{\mathbf{v}}}[h](\bar{\mathbf{v}})\big{|}_{\bar{\mathbf{v}}=0}= \mathbf{A}(\theta_{*})\bar{\mathbf{v}}\text{H}_{\theta}[\mathcal{L}](\theta) \mathbf{A}(\theta_{*})\big{|}_{\theta=\theta_{*}}\) with \(\text{H}_{\theta}[\mathcal{L}](\theta)\) the standard Euclidean Hessian matrix of the loss. Further details about this step can be found in appendix B.
**Tangential Laplace.** Similar to the standard Laplace approximation, we get a Gaussian approximate posterior \(\bar{q}(\bar{\mathbf{v}})=\mathcal{N}(\bar{\mathbf{v}}\mid 0,\ \overline{ \Sigma})\) on the tangent space in the normal coordinates with covariance \(\overline{\Sigma}=\text{H}_{\bar{\mathbf{v}}}[h](\mathbf{v})\big{|}_{\bar{ \mathbf{v}}=0}^{-1}\). Note that changing the normal coordinates \(\bar{\mathbf{v}}\) to tangential coordinates \(\mathbf{v}\) is a linear transformation and hence \(\mathbf{v}\sim\mathcal{N}(0,\mathbf{A}(\theta_{*})\overline{\mathbf{\Sigma}} \mathbf{A}(\theta_{*})\bar{\mathbf{v}})\), which means that this covariance is equal to \(\text{H}_{\theta}[\mathcal{L}](\theta)\big{|}_{\theta=\theta_{*}}^{-1}\) since \(\mathbf{A}(\theta_{*})\) is a symmetric matrix, and hence, it cancels out. The approximate posterior \(q_{\mathcal{T}}(\mathbf{v})=\mathcal{N}(\mathbf{v}\mid 0,\Sigma)\) in tangential coordinates, thus, matches the covariance of the standard Laplace approximation.
**The predictive posterior.** We can approximate the predictive posterior distribution using Monte Carlo integration as \(p(y|\mathbf{x}^{\prime},\mathcal{D})=\int p(y|\mathbf{x}^{\prime},\mathcal{D},\theta)q(\theta)\mathrm{d}\theta=\int p(y|\mathbf{x}^{\prime},\mathcal{D}, \text{Exp}_{\theta_{*}}(\mathbf{v}))q_{\mathcal{T}}(\mathbf{v})\mathrm{d} \mathbf{v}\approx\frac{1}{3}\sum_{s=1}^{S}p(y|\mathbf{x}^{\prime},\mathcal{D},\text{Exp}_{\theta_{*}}(\mathbf{v}_{s})),\ \mathbf{v}_{s}\sim q_{\mathcal{T}}(\mathbf{v})\). Intuitively, this generates tangent vectors according to the standard Laplace approximation and maps them back to the manifold by solving the geodesic ode. This lets the Riemannian approximate posterior take shape from the loss landscape, which is largely ignored by the standard Laplace approximation. We emphasize that this is a general construction that applies to the same Bayesian inference problems as the standard Laplace approximation and is not exclusive to Bayesian neural networks.
The above analysis also applies to the linearized Laplace approximation. In particular, when the \(f_{\theta}^{\text{lin}}(\mathbf{x})\) is considered instead of the \(f_{\theta}(\mathbf{x})\) the loss function in (1) changes to \(\mathcal{L}^{\text{lin}}(\theta)\). Consequently, our Riemannian metric is computed under this new loss, and \(\nabla_{\theta}\mathcal{L}^{\text{lin}}(\theta)\) appears in the metric (3).
**Example.** To build intuition, we consider a logistic regressor on a linearly separable dataset (Fig. 3). The likelihood of a point \(\mathbf{x}\in\mathbb{R}^{2}\) to be in one class is \(p(C=1|\mathbf{x})=\sigma(\mathbf{x}^{\prime}\theta+b)\), where \(\sigma(\cdot)\) is the sigmoid function, \(\theta\in\mathbb{R}^{2}\) and \(b\in\mathbb{R}\). After learning the parameters, we fix \(b_{*}\) and show the posterior with respect to \(\theta\) together with the corresponding standard Laplace approximation (Fig. 2(a)).
Figure 3: The la assigns probability mass to regions where the true posterior is nearly zero, and a sample from this region corresponds to a poor classifier. Considering this sample as the initial velocity for the exponential map, the generated sample falls within the true posterior and the associated classifier performs well. As a result, our model quantifies better the uncertainty.
We see that the approximation assigns significant probability mass to regions where the true posterior is near-zero, and the result of a corresponding sample is a poor classifier (Fig. 2(b)). Instead, when we consider this sample as the initial velocity and compute the associated geodesic with the exponential map, we generate a sample at the tails of the true posterior which corresponds to a well-behaved model (Fig. 2(c)). We also show the predictive distribution for both approaches and even if both solve easily the classification problem, our model better quantifies uncertainty (Fig. 2(e)).
### Efficient implementation
Our approach is a natural extension of the standard Laplace approximation, which locally adapts the approximate posterior to the true posterior. The caveat is that computational cost increases since we need to integrate an ode for every sample. We now discuss partial alleviations.
Integrating the ode.In general, the system of second-order nonlinear odes (see appendix B for the general form) is non-trivial as it depends on the geometry of the loss surface, which is complicated in the over-parametrized regime (Li et al., 2018). In addition, the dimensionality of the parameter space is high, which makes the solution of the system even harder. Nevertheless, due to the structure of our Riemannian metric (3), the ode simplifies to
\[\ddot{c}(t)=-\nabla_{\theta}\mathcal{L}(c(t))\left(1+\nabla_{\theta}\mathcal{ L}(c(t))^{\intercal}\nabla_{\theta}\mathcal{L}(c(t))\right)^{-1}\langle\dot{c}(t ),\mathrm{H}_{\theta}[\mathcal{L}](c(t))\dot{c}(t)\rangle, \tag{6}\]
which can be integrated reasonably efficiently with standard solvers. In certain cases, this ode can be further simplified, for example when we consider the linearized loss \(\mathcal{L}^{\text{lin}}(\theta)\) and Gaussian likelihood.
Automatic-differentiation.The ode (6) requires computing both gradient and Hessian, which are high-dimensional objects for modern neural networks. While we need to compute the gradient explicitly, we do not need to compute and store the Hessian matrix, which is infeasible for large networks. Instead, we rely on modern automatic-differentiation frameworks to compute the Hessian-vector product between \(\mathrm{H}_{\theta}[\mathcal{L}](c(t))\) and \(\dot{c}(t)\) directly. This both reduces memory use, increases speed, and simplifies the implementation.
Mini-batching.The cost of computing the metric, and hence the ode, scales linearly with the number of training data, which can be expensive for large datasets. A reasonable approximation is to mini-batch the estimation of the metric when generating samples, i.e. construct a batch \(\mathcal{B}\) of \(B\) random data points and use the associated loss in the ode (6). As usual, we assume that \(\mathcal{L}(\theta)\approx(\nicefrac{{N}}{{B}})\mathcal{L}_{\mathcal{B}}( \theta)\). Note that we only mini-batch the metric and not the covariance of our approximate posterior \(q_{\mathcal{T}}(\mathbf{v})\).
We analyze the influence of mini-batching in our methods and provide empirical evidence in Fig. 4. In principle, the geometry of the loss surface \(\mathcal{L}(\theta)\) controls the geodesics via the associated Riemannian metric, so when we consider the full dataset we expect the samples to behave similarly to \(f_{\theta_{*}}(\mathbf{x})\). In other words, our approximate posterior generates weights near \(\theta_{*}\) resulting in models with similar or even better loss. When we consider a batch the geometry of the associated loss surface \(\mathcal{L}_{\mathcal{B}}(\theta)\) controls the generated geodesic. So if the batch represents well the structure of the full dataset, then the resulting model will be meaningful with respect to the original problem, and in addition, it may exhibit some variation that is beneficial from the Bayesian perspective for the quantification of the uncertainty. The same concept applies in the linearized version, with the difference that when the full dataset is considered the geometry of \(\mathcal{L}^{\text{lin}}(\theta)\) may over-regularize the geodesics. Due to the linear nature of \(f_{\theta}^{\text{lin}}(\theta)\) the associated Riemannian metric is small only close to \(\theta_{*}\) so the generated samples are similar to \(f_{\theta_{*}}(\mathbf{x})\). We relax this behavior and potentially introduce variations in the resulting models when we consider a different batch whenever we generate a sample. Find more details in appendix D.
Figure 4: Analysis of mini-batching
Related work
**Bayesian neural networks.** Exact inference for bnn is generally infeasible when the number of parameters is large. Several methods rely on approximate inference, which differs in their trade-off between computational cost and the goodness of the approximation. These techniques are usually based on the Laplace approximation (MacKay, 1992), variational inference (Graves, 2011; Blundell et al., 2015; Khan et al., 2018), dropout (Gal and Ghahramani, 2016), stochastic weight averaging (Izmailov et al., 2018; Maddox et al., 2019) or Monte Carlo based methods (Neal, 1995), where the latter is often more expensive.
**Laplace approximations.** In this work, we are primarily focused on Laplace approximations, although the general geometric idea can be used in combination with any other inference approach listed above. Particularly, Laplace's method for bnn was first proposed by Mackay (1992) in his _evidence_ framework, where a closed-form approximation of predictive probabilities was also derived. This one uses a first-order Taylor expansion, also known as _linearization_ around the map estimate. For long, Laplace's method was infeasible for modern architectures with large networks due to the exact computation of the Hessian. The seminal works of Martens and Grosse (2015) and Botev et al. (2017) made it possible to approximate the Hessian of large networks, which made Laplace approximations feasible once more (Ritter et al., 2018). More recently, the Laplace approximation has become a go-to tool for turning trained neural networks into bnn in a _post-hoc_ manner, thanks to easy-to-use software (Daxberger et al., 2021) and new approaches to scale up computation (Antoran et al., 2022). In this direction, other works have only considered a subset of the network parameters (Daxberger et al., 2021; Sharma et al., 2023), especially the last-layer. This is _de facto_ the only current method competitive with _ensembles_(Lakshminarayanan et al., 2017).
**Posterior refinement.** Much work has gone into building more expressive approximate posteriors. Recently, Kristiadi et al. (2022) proposed to use normalizing flows to get a non-Gaussian approximate distribution using the Laplace approximation as a base distribution. Although this requires training an additional model, they showed that few bijective transformations are enough to improve the last-layer posterior approximation. Immer et al. (2021), instead, propose to refine the Laplace approximation by using Gaussian variational Bayes or a Gaussian process. This still results in a Gaussian distribution, but it has proven beneficial for linearized Laplace approximations. Other approaches rely on a mixture of distributions to improve the goodness of the approximation. Miller et al. (2017) expand a variational approximation iteratively adding components to a mixture, while Eschenhagen et al. (2021) use a weighted sum of posthoc Laplace approximations generated from different pre-trained networks. Havasi et al. (2021), instead, introduces auxiliary variables to make a local refinement of a mean-field variational approximation.
**Differential geometry.** Differential geometry is increasingly playing a role in inference. Arvanitidis et al. (2016) make a Riemannian normal distribution locally adapt to data by learning a suitable Riemannian metric from data. In contrast, our metric is derived from the model. This is similar in spirit to work that investigates pull-back metrics in latent variable models (Tosi et al., 2014; Arvanitidis et al., 2018; Hauberg, 2018). In addition to that, the geometry of the latent parameter space of neural networks was recently analyzed by Kristiadi et al. (2023) focusing on the invariance of flatness measures with respect to re-parametrizations. Finally, we note that Hauberg (2018) considers Laplace approximations on the sphere as part of constructing a recursive Kalman-like filter.
## 5 Experiments
We evaluate our Riemannian la (riem-la) using illustrative examples, image datasets where we use a convolutional architecture, and real-world classification problems. We compare our method and its linearized version to standard and linearized la. All predictive distributions are approximated using Monte Carlo (MC) samples. Although last-layer la is widely used lately, we focus on approximating the posterior of all the weights of the network. In all experiments, we maximize the marginal log-likelihood to tune the hyperparameters of the prior and the likelihood as proposed in (Daxberger et al., 2021). To evaluate the performance in terms of uncertainty estimation we considered the standard metrics in the literature: negative log-likelihood (NLL), the Brier score (BRIER), the expected calibration error (ECE), and the maximum calibration error (MCE). More experiments are available in appendix D together with the complete training and modeling details.
### Regression problem
We consider the toy-regression problem proposed by Snelson and Ghahramani (2005). The dataset contains 200 data points, and we randomly pick 150 examples as our training set and the remaining 50 as a test set. As shown by Lawrence (2001), Ritter et al. (2018), using samples from the LA posterior performs poorly in regression even if the Hessian is not particularly ill-conditioned, i.e. when the prior precision is optimized. For this reason, the linearization approach is necessary for regression with standard LA. Instead, we show that even our basic approach fixes this problem when the prior is optimized. We tested our approach by considering two fully connected networks, one with one hidden layer with 15 units and one with two layers with 10 units each, both with tanh activations. Our approach approximates well the true posterior locally, so the resulting function samples follow the data. Of course, if the Hessian is extremely degenerate our approach also suffers, as the initial velocities are huge. When we consider the linearized version of our approach the result is the same as the standard LA-linearization, which we include in the appendix D, where we also report results for in-between uncertainty as proposed by Foong et al. (2019).
### Classification problems
Illustrative example.We consider a 2-dimensional binary classification problem using the banana dataset which is shown in Fig. 6. We train a 2-layer fully connected neural net with 16 hidden units per layer and tanh activation. For all methods, we use 100 MC samples for the predictive distribution.
As in regression, direct samples from the vanilla la lead to a really poor model (Fig. 5(a)) with high uncertainty both within and away from the data support. Instead, the other three methods (Fig. 5(b)-5(d)) show a better-behaved confidence that decreases outside of the data support. This is also supported by the metrics in Table 1, where remarkably riem-la performs better in terms of NLL and Brier score on a separate test set.
As we discussed in Sec. 3.3, using a subset of the dataset for computing the exponential map can be beneficial for our linearized manifold in addition to speeding up computation. In Fig. 5(d) we plot the confidence for our linearized approach using batches while in appendix D we show the confidence of the same approach using the full data for solving the odes. We can see that our linearized riem-la tends to be overconfident outside the data region and also close to the decision
Figure 5: Posterior samples under a simple _(top)_ and an overparametrized model _(bottom)_. Vanilla la is known to generate bad models, while our samples from riem-la quantify well the uncertainty.
Figure 6: Binary classification confidence estimate using \(100\) Monte-Carlo samples on the banana dataset. Vanilla la underfit, while the other three methods are able to be certain within the data and uncertain far away. Note, for linearized riem-la we solve the expmap using a different subset of the data. Confidence plots of all different methods can be found in the supplementary material. Black lines are the decision boundaries.
boundary. This behaviour can be found in the high NLL that linearized riem-la gets compared to our vanilla approach and linearized la.
UCI datasets.We compare our approach against the standard la on a set of six UCI classification datasets using a fully connected network with a single layer, 50 hidden units and tanh activation. The predictive distribution is estimated using MC with 30 samples from the approximate posterior of each approach. In Table 2 we compare the methods in terms of their negative log-likelihood (NLL) in the test set. All other metrics are reported in appendix D. We are considering the setting where we optimize the prior-precision post-hoc, which is the optimal setting for la and linearized la. We consider our standard approaches without using batches, which we have seen that specifically for our linearized approach may lead to sub-optimal performance.
From the results in Table 2 we see that our riem-la consistently performs better in terms of negative log-likelihood than vanilla and linearized la. We also observe that in two datasets the performance of our linearized riem-la is not optimal. This implies that the loss surface of the linearized loss potentially over-regularizes the geodesics as we analyzed in Sec. 3.3, and in this case, considering mini-batching could have been beneficial.
Image classification.We consider a small convolutional neural network on MNIST and FashionMNIST. Our network consists of two convolutional layers followed by average pooling layers and three fully connected layers. We consider a model of this size as the high dimensionality of the parameter space is one of the main limitations of the ode solver. For the training of the model, we subsample each dataset and we consider 5000 observations by keeping the proportionality of labels, and we test in the full test set containing 8000 examples. In Table 3 we compare the different methods with the prior precision optimized as this is the ideal setting for the linearized la. We refer to appendix D for the setting with the prior precision not optimized.
From the results we observe that our standard riem-la performs better than all the other methods in terms of NLL and Brier score, meaning that the models are better calibrated, but it also leads to a more accurate classifier than the MAP. In terms of ECE, it seems that considering the linearized approach is beneficial in producing better-calibrated models in both datasets. This holds both for our approach linearized riem-la and the standard la. Optimizing the prior precision post-hoc is crucial for the vanilla la and associated results can be seen in appendix D. Instead, both our methods appear to be robust and consistent, as they achieve similar performance no matter if the prior precision is optimized or not.
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline & \multicolumn{6}{c}{brain dataset} \\ \cline{2-7} & \multicolumn{3}{c}{prior optimized} & \multicolumn{3}{c}{pero not optimized} \\ \cline{2-7} method & Accuracy \(\uparrow\) & NLL\(\downarrow\) & Brier\(\downarrow\) & Accuracy \(\uparrow\) & NLL\(\downarrow\) & Brier\(\downarrow\) \\ \hline MAP & \(86.69\pm 0.34\) & \(0.333\pm 0.005\) & \(0.0930\pm 0.0015\) & \(86.69\pm 0.34\) & \(0.333\pm 0.005\) & \(0.0930\pm 0.0015\) \\ VAEIL-LA & \(95.50\pm 5.07\) & \(0.678\pm 0.009\) & \(0.2426\pm 0.0046\) & \(48.58\pm 2.32\) & \(0.700\pm 0.003\) & \(0.2534\pm 0.0017\) \\ LIN-LA & \(86.59\pm 0.37\) & \(0.325\pm 0.008\) & \(0.0956\pm 0.0023\) & \(86.92\pm 0.40\) & \(0.403\pm 0.012\) & \(0.1196\pm 0.0044\) \\ REM-LA & \(\mathbf{87.57\pm 0.07}\) & \(\mathbf{0.287\pm 0.002}\) & \(\mathbf{0.0886\pm 0.0006}\) & \(\mathbf{87.14\pm 0.20}\) & \(\mathbf{0.285\pm 0.001}\) & \(\mathbf{0.0878\pm 0.0006}\) \\ REM-LA (ACRES) & \(87.30\pm 0.08\) & \(\mathbf{0.286\pm 0.001}\) & \(\mathbf{0.0890\pm 0.0000}\) & \(\mathbf{87.32\pm 0.17}\) & \(\mathbf{0.294\pm 0.002}\) & \(\mathbf{0.0895\pm 0.0004}\) \\ LIN-BIBI-LA & \(87.02\pm 0.38\) & \(0.415\pm 0.029\) & \(0.0067\pm 0.0024\) & \(85.33\pm 0.31\) & \(0.884\pm 0.037\) & \(0.1252\pm 0.0022\) \\ LIN-BIBI-LA (AGRE) & \(\mathbf{87.72\pm 0.24}\) & \(0.298\pm 0.006\) & \(\mathbf{0.0887\pm 0.0012}\) & \(86.16\pm 0.21\) & \(0.352\pm 0.002\) & \(0.0934\pm 0.0011\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: In-distribution results in the banana dataset. We use 100 MC samples both for the la and our variants. ECE and MCE are computed using \(M=10\) bins. We report mean and standard error over 5 different seeds.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline & \multicolumn{6}{c}{prior precision optimized} \\ \cline{2-7} dataset & map & vanilla la & riem-la & linearized la & linearized rim-LA \\ \hline vehicle & \(0.975\pm 0.081\) & \(1.209\pm 0.020\) & \(\mathbf{0.454\pm 0.024}\) & \(0.875\pm 0.020\) & \(\mathbf{0.494\pm 0.044}\) \\ glass & \(2.084\pm 0.323\) & \(1.737\pm 0.037\) & \(\mathbf{1.047\pm 0.242}\) & \(1.365\pm 0.058\) & \(1.359\pm 0.299\) \\ ionosphere & \(1.032\pm 0.175\) & \(0.673\pm 0.013\) & \(\mathbf{0.344\pm 0.068}\) & \(0.497\pm 0.015\) & \(0.625\pm 0.110\) \\ waveform & \(1.076\pm 0.110\) & \(0.888\pm 0.030\) & \(\mathbf{0.459\pm 0.057}\) & \(0.640\pm 0.002\) & \(0.575\pm 0.065\) \\ australian & \(1.306\pm 0.146\) & \(0.684\pm 0.011\) & \(\mathbf{0.541\pm 0.053}\) & \(\mathbf{0.570\pm 0.016}\) & \(0.833\pm 0.108\) \\ breast cancer & \(\mathbf{0.225\pm 0.076}\) & \(0.594\pm 0.030\) & \(\mathbf{0.176\pm 0.092}\) & \(0.327\pm 0.022\) & \(\mathbf{0.202\pm 0.073}\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Negative log-likelihood (lower is better) on UCI datasets for classification. Predictive distribution is estimated using 30 MC samples. Mean and standard error over 5 different seeds.
Note that for the mini-batches for our approaches, we consider 20% of the data by randomly selecting 1000 observations while we respect the label frequency based on the full dataset. Clearly, the batch-size is a hyperparameter for our methods and can be estimated systematically using cross-validation. Even if we do not optimize this hyperparameter, we see that our batched version of riem-la and lin-riem-la perform better than the standard la and on-par with our lin-riem-la without batches, implying that a well-tuned batch-size can potentially further improve the performance. Nevertheless, this also shows that our method is robust with respect to the batch-size.
## 6 Conclusion
We propose an extension to the standard Laplace approximation, which leverages the natural geometry of the parameter space. Our method is parametric in the sense that a Gaussian distribution is estimated using the standard Laplace approximation, but it adapts to the true posterior through a nonparametric Riemannian metric. This is a general mechanism that, in principle, can also apply to, e.g., variational approximations. In a similar vein, while the focus of our work is on Bayesian neural networks, nothing prevents us from applying our method to other model classes.
Empirically, we find that our Riemannian Laplace approximation is better or on par with alternative Laplace approximations. The standard Laplace approximation crucially relies on both linearization and on a fine-tuned prior to give useful posterior predictions. Interestingly, we find that the Riemannian Laplace approximation requires neither. This could suggest that the standard Laplace approximation has a rather poor posterior fit, which our adaptive approach alleviates.
Limitations.The main downside of our approach is the computational cost involved in integrating the ode, which is a common problem in computational geometry (Arvanitidis et al., 2019). The cost of evaluating the ode scales linearly with the number of observations, and we have considered the 'obvious' mini-batching solution. Empirically, we find that this introduces some stochasticity in the sampling, which can actually be helpful in the posterior exploration. The computational cost also grows with the dimensionality of the parameter space, predominantly because the number of necessary solver steps increases as well. Our implementation relies on an off-the-shelf ode solver, and we expect that significant improvements can be obtained using a tailor-made numerical integration method.
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline & \multicolumn{5}{c}{CNN on MNIST - prior precision optimized} \\ \cline{2-6} method & Accuracy \(\uparrow\) & NLL\(\downarrow\) & Brier\(\downarrow\) & EC\(\downarrow\) & MCE\(\downarrow\) \\ \hline map & \(95.02\pm 0.17\) & \(0.167\pm 0.005\) & \(0.0075\pm 0.0002\) & \(1.05\pm 0.14\) & \(39.94\pm 14.27\) \\ vanilla la & \(88.69\pm 1.84\) & \(0.871\pm 0.026\) & \(0.0393\pm 0.0013\) & \(42.11\pm 1.22\) & \(50.52\pm 1.45\) \\ lin-la & \(94.91\pm 0.26\) & \(0.204\pm 0.006\) & \(0.0087\pm 0.0003\) & \(6.30\pm 0.8\) & \(39.30\pm 16.77\) \\ riem-la & \(\mathbf{96.74\pm 0.12}\) & \(\mathbf{0.115\pm 0.003}\) & \(\mathbf{0.0052\pm 0.0002}\) & \(2.48\pm 0.06\) & \(38.03\pm 15.02\) \\ riem-la (batches) & \(95.67\pm 0.19\) & \(0.170\pm 0.005\) & \(0.0072\pm 0.0002\) & \(5.40\pm 0.06\) & \(22.40\pm 0.51\) \\ lin-riem-la & \(95.44\pm 0.18\) & \(0.149\pm 0.004\) & \(0.0068\pm 0.0003\) & \(\mathbf{0.66\pm 0.03}\) & \(39.40\pm 14.75\) \\ lin-riem-la (batches) & \(95.14\pm 0.20\) & \(0.167\pm 0.004\) & \(0.0076\pm 0.0002\) & \(3.23\pm 0.04\) & \(\mathbf{18.10\pm 2.50}\) \\ \hline \hline \end{tabular}
\begin{tabular}{c c c c c c} \hline \hline & \multicolumn{5}{c}{CNN on FashionMNIST - prior precision optimized} \\ \cline{2-6} Method & Accuracy \(\uparrow\) & NLL\(\downarrow\) & Brier\(\downarrow\) & EC\(\downarrow\) & MCE\(\downarrow\) \\ \hline map & \(79.88\pm 0.09\) & \(0.541\pm 0.002\) & \(0.0276\pm 0.0000\) & \(\mathbf{1.66\pm 0.07}\) & \(24.07\pm 1.50\) \\ vanilla la & \(74.88\pm 0.83\) & \(1.026\pm 0.046\) & \(0.0482\pm 0.0019\) & \(31.63\pm 1.28\) & \(43.61\pm 2.95\) \\ lin-la & \(79.85\pm 0.13\) & \(0.549\pm 0.001\) & \(0.0278\pm 0.0000\) & \(3.23\pm 0.44\) & \(37.88\pm 17.98\) \\ riem-la & \(\mathbf{83.33\pm 0.17}\) & \(0.472\pm 0.001\) & \(\mathbf{0.0237\pm 0.0001}\) & \(3.13\pm 0.48\) & \(10.94\pm 2.11\) \\ riem-la (batches) & \(81.65\pm 0.18\) & \(0.525\pm 0.004\) & \(0.0263\pm 0.0002\) & \(5.80\pm 0.73\) & \(35.30\pm 18.40\) \\ lin-riem-la & \(81.33\pm 0.10\) & \(0.521\pm 0.004\) & \(0.0261\pm 0.0002\) & \(\mathbf{1.59\pm 0.40}\) & \(25.53\pm 0.10\) \\ lin-riem-la (batches) & \(80.49\pm 0.13\) & \(0.529\pm 0.003\) & \(0.0269\pm 0.0002\) & \(2.10\pm 0.42\) & \(\mathbf{6.14\pm 1.42}\) \\ \hline \hline \end{tabular}
\end{table}
Table 3: Image classification results using a CNN on MNIST and FashionMNIST. The network is trained on \(5000\) examples and we test the in-distribution performance on the test set, which contains 8000 examples. We use \(25\) Monte Carlo samples to approximate the predictive distribution and \(1000\) datapoints per batch in our batched manifolds. Calibration metrics are computed using \(M=15\) bins. We report mean and standard error for each metric over 3 different seeds.
## Acknowledgments and Disclosure of Funding
This work was funded by the Innovation Fund Denmark (0175-00014B) and the Novo Nordisk Foundation through the Center for Basic Machine Learning Research in Life Science (NNF20OC0062606). It also received funding from the European Research Council (ERC) under the European Union's Horizon 2020 research, innovation programme (757360). SH was supported in part by a research grant (42062) from VILLUM FONDEN.
|
2302.10886 | Some Fundamental Aspects about Lipschitz Continuity of Neural Networks | Lipschitz continuity is a crucial functional property of any predictive
model, that naturally governs its robustness, generalisation, as well as
adversarial vulnerability. Contrary to other works that focus on obtaining
tighter bounds and developing different practical strategies to enforce certain
Lipschitz properties, we aim to thoroughly examine and characterise the
Lipschitz behaviour of Neural Networks. Thus, we carry out an empirical
investigation in a range of different settings (namely, architectures,
datasets, label noise, and more) by exhausting the limits of the simplest and
the most general lower and upper bounds. As a highlight of this investigation,
we showcase a remarkable fidelity of the lower Lipschitz bound, identify a
striking Double Descent trend in both upper and lower bounds to the Lipschitz
and explain the intriguing effects of label noise on function smoothness and
generalisation. | Grigory Khromov, Sidak Pal Singh | 2023-02-21T18:59:40Z | http://arxiv.org/abs/2302.10886v4 | # Some Fundamental Aspects about Lipschitz Continuity
###### Abstract
Lipschitz continuity is a simple yet pivotal functional property of any predictive model that lies at the core of its robustness, generalisation, and adversarial vulnerability. Our aim is to thoroughly investigate and characterise the Lipschitz behaviour of the functions learned via neural networks. Despite the significant tightening of the bounds in the recent years, precisely estimating the Lipschitz constant continues to be a practical challenge and tight theoretical analyses, similarly, remain intractable. Therefore, _we shift our perspective and instead attempt to uncover insights about the nature of Lipschitz constant of neural networks functions_ -- by relying on the simplest and most general upper and lower bounds. We carry out an empirical investigation in a range of different settings (architectures, losses, optimisers, label noise, etc.), which reveals several fundamental and intriguing traits of the Lipschitz continuity of neural networks functions, In particular, we identify _a remarkable double descent trend in both upper and lower bounds to the Lipschitz constant_ which tightly aligns with the typical double descent trend in the test loss.
## 1 Introduction & Related Work
Lipschitz continuity of a function is a key quantity that reflects its smoothness as the input is perturbed (or more accurately, the maximum absolute change in the function value for a unit norm change in the input). Typically, in machine learning, our hope is that the learned predictive function is not overly sensitive to (non-adversarial) input changes. Otherwise, if the function changes too drastically for minuscule changes in the input, we can hardly hope that the learned function would generalise to unseen data drawn from the underlying distribution. On the flip side, when the value of the Lipschitz constant is extremely small (for the sake of the argument, think close to zero), this would imply a large bias [1] and essentially a useless function.
From these arguments sketched above, it is not hard to see why the Lipschitz constant plays a crucial role in various topics such as generalisation [2], robustness [3], vulnerability to adversarial examples [4], and more. As a result, there is also a significant body of literature in both theoretical [2; 5; 6; 7; 8; 9] and applied [10; 11; 12; 13; 14] directions, as discussed below in more detail.
The focus of our current study is on uncovering the fundamental aspects of Lipschitz continuity of neural network functions -- and thus contribute towards a better understanding of modern over-parameterised neural networks. Despite much progress achieved over the years -- owing to which we have a better estimate of the true Lipschitz constant [5] -- insights about their behaviour and characteristics for neural networks have been hard to come by. For instance, a plethora of fundamental questions, in the context of Lipschitz continuity of neural functions, remain to be understood:
* How does the Lipschitz constant behave for a wider versus narrow network? Shallow versus deeper networks? More broadly, how does it vary across different network architectures?
* Does the Lipschitz constant change significantly over the course of training or is it largely governed by the value at initialisation?
* How does its behaviour vary across different loss functions? Since, of course, we don't want to be misled by the nature of a particular loss function, and rather obtain 'functional' properties.
* Are there any notable differences between the Lipschitz continuity for different choices of optimisers?
* How does the nature of the learning task (i.e., in terms of the amount of signal or noise present) affect the Lipschitz continuity?
Our objective is precisely to contribute towards this end, with an emphasis on over-parameterised deep neural networks as trained in practice.
Approach.Part of the reason why important insights have been hard to come by through recent studies on the Lipschitz constant is that the newer methods, which produce tighter estimates of the true Lipschitz, are, more often than not, rather expensive computationally -- limiting their use. Or when simple bounds are utilised, there is an element of uncertainty whether the findings apply to the true Lipschitz constant or just that particular bound. We propose a simple way around this problem: track and investigate both upper and lower bounds to the Lipschitz constant. We will show this embarrassingly simple fix nevertheless lets us showcase intriguing traits about the Lipschitz constant of neural network functions in a multitude of settings. A key highlight is that we discover a double descent trend in both upper and lower bounds to the Lipschitz constant, which bears an intimate relationship with double descent trend in test loss [15].
Contributions:
* We begin by investigating the evolution of upper and lower bounds to the Lipschitz constant during the course of training for fully-connected and convolutional networks. In this setting, we also showcase the fidelity of the lower bounds to represent the true Lipschitz constant by evaluating them in a much wider vicinity of the training samples.
* We then study the effect of increasing network widths on the Lipschitz constant, within an extensive range of widths spanning about \(14\) orders of magnitude. Interestingly, we observe that double descent trend in the test loss is also mirrored through the upper and lower Lipschitz bounds.
* We also present a theoretical argument based on the bias-variance tradeoff and show that the variance is upper bounded by the squared Lipschitz constant (something which we also establish empirically).
* Next, we probe the effect of different loss functions and optimisers on the behaviour of Lipschitz continuity and hypothesise the reasons for the same. We find that with Cross-Entropy (CE) loss, the Lipschitz bounds are higher as compared to that when using Mean-Squared Error (MSE) loss. On the other hand, training with adaptive methods like Adam [16] results in higher values of the Lipschitz constant as compared to just using stochastic gradient descent (SGD).
* Furthermore, we also do another set of studies that illustrates the effect of depth, training set size, and label noise on the Lipschitz continuity of neural networks. This reveals an interesting trend where Lipschitz constant increases with more signal in the dataset (more clean training samples) and decreases in the presence of more noise.
* Lastly, we find that the distance of the network from the initialisation can capture many of the interesting trends in the Lipschitz constant.
Related Work.Theoretical interest in the Lipschitz constant of neural networks has been revived since Bartlett et al. [2] described how margin-based generalisation bounds are linearly dependent on the Lipschitz constant. Since generalisation bounds and robustness guarantees [3] are expressed in terms of the upper bound estimates of the true Lipschitz constant, extensive research has been done in
the field of its efficient and accurate estimation [5; 6; 8; 17]. As opposed to this direction of finding the tightest possible bounds, our aim in this work is rather to identify and uncover intriguing aspects of Lipschitz continuity in neural networks. But, in the future, we also aim to explore these tighter bounds in the context of neural networks.
On the practical side, Lipschitz constant has also been useful as a regularise while training regular neural networks [10; 11], but also for Generative Adversarial Networks (GANs) [13; 18], as well as addressing robustness to adversarial examples [12] and perturbations in input [14]. Most of these regularisation techniques enforce constraints on the parameters or the architecture in order to constrain the Lipschitz constant or its estimate.
Very recently, concurrent to our work, Gamba et al. [19] have also noted the connection between Lipschitz constant and the phenomenon of double descent [15]. In contrast to their work, which only tracks a reasonable yet heuristic estimate of the Lipschitz constant, we painstakingly track both lower and upper Lipschitz bounds. Besides, our focus is also much broader and covers many other settings where we explore the behaviour of Lipschitz constant.
## 2 Lipschitz constant of Neural Network functions
Before we start investigating the Lipschitz constant for neural networks, let us first recall the definition of Lipschitz-continuous functions.
**Definition 2.1** (Lipschitz continuous function).: _For function \(f:\mathbb{R}^{n}\mapsto\mathbb{R}^{m}\), defined on some domain \(dom(f)\subseteq\mathbb{R}^{n}\), \(f\) is called \(C\)-Lipschitz continuous, \(C>0\), w.r.t some \(\alpha\) norm if:_
\[\forall\mathbf{x},\mathbf{y}\in dom(f):\|f(\mathbf{x})-f(\mathbf{y})\|_{ \alpha}\leq C\|\mathbf{x}-\mathbf{y}\|_{\alpha}\]
Note that we are usually interested in the smallest \(C\), such that the above condition holds. This is what we call the Lipschitz constant of the function \(f\).
Unfortunately, the exact value of the Lipschitz constant is proven to be NP-hard to compute [17]. Therefore we focus on the upper and the lower bounds of the true Lipschitz constant. To lower bound the Lipschitz constant, we use another definition of the Lipschitz constant (see theorem 1 in [20] or proceed with [21]).
**Theorem 1** (Alternative definition of the Lipschitz constant).: _Let function \(f:\mathbb{R}^{n}\mapsto\mathbb{R}^{m}\), be defined on some domain \(dom(f)\subseteq\mathbb{R}^{n}\). Let \(f\) also be differentiable and \(C\)-Lipschitz continuous. Then the Lipschitz constant \(C\) is given by:_
\[C=\sup_{\mathbf{x}\in dom(f)}\|\nabla_{\mathbf{x}}f\|_{\alpha^{*}}\]
_where \(\nabla_{\mathbf{x}}f\) is the Jacobian of \(f\) w.r.t. to input \(\mathbf{x}\) and \(\alpha^{*}\) is the dual norm of \(\alpha\)._
For simplicity, we will focus on computing the 2-norm for the rest of the paper. Note that the dual norm for the 2-norm is also 2-norm. Hereafter, all the norms will denote the 2-norm, and thus we will omit it in the expressions.
In a typical machine learning setting, we would like to train a model that generalises well to samples drawn from the underlying distribution \(\mathcal{D}\). Thus, for our model \(f_{\boldsymbol{\theta}}\), we are interested in finding,
\[C=\sup_{\mathbf{x}\in\mathcal{D}}\|\nabla_{\mathbf{x}}f_{\boldsymbol{\theta}} \|_{2}\leq\sup_{\mathbf{x}\in dom(f)}\|\nabla_{\mathbf{x}}f_{\boldsymbol{ \theta}}\|_{2}\,,\]
where in the last step we consider the supremum over the entire domain of the function \(f\), i.e., even outside of the true data distribution \(\mathcal{D}\), which is usually unknown.
However, we can find a lower bound for our Lipschitz constant by limiting the supremum computation to the training set \(S\subseteq\mathcal{D}\):
\[C_{\text{lower}}=\sup_{\mathbf{x}\in S}\|\nabla_{\mathbf{x}}f_{\boldsymbol{ \theta}}\|_{2}\leq\sup_{\mathbf{x}\in\mathcal{D}}\|\nabla_{\mathbf{x}}f_{ \boldsymbol{\theta}}\|_{2}=C \tag{1}\]
Tight upper bounds to the Lipschitz constant, however, are far from trivial to compute. A lot of recent research has focused on producing different methods of upper bound estimation (as it has been discussed in the Section 1, under related work), each aiming to improve the tightness of the bound
and its computation speed. While this is a fascinating direction, in this paper, our aim is slightly different. Instead of getting encumbered by the demands of tighter bounds to the Lipschitz constant, _we shift the perspective towards understanding the nature and behaviour of the Lipschitz constant_ in a host of different settings. We do this by'sandwiching' the true Lipschitz by suitable lower and upper bounds to it, and tracking them both. Rather remarkably, we find that just focusing on the simplest possible bounds delivers intriguing insights which we will elaborate through the coming sections.
We start with describing our approach to compute the upper bound of the Lipschitz constant, inspired by the AutoLip algorithm introduced by [17]. To give a simple overview, let us analyse the case of sequential neural networks where each layer has a zero bias. Let our model \(f_{\mathbf{\theta}}\) with \(L\) layers be defined as \(f_{\mathbf{\theta}}:=f_{L}\circ f_{L-1}\circ\cdots\circ f_{1}\), which is a sequence of linear and non-linear transformations. For this case, the Lipschitz constant upper bound would be the product of Lipschitz constants of each individual layer:
\[C\leq\prod_{i=1}^{L}C_{f_{i}}=\prod_{i=1}^{L}\sup_{t_{i}\in dom(f_{i})}\| \nabla_{t_{i}}f_{i}\|_{2}\leq\prod_{i=1}^{L}\sup\|\nabla_{t_{i}}f_{i}\|_{2}=C _{\text{upper}} \tag{2}\]
More pedantically, one can see this by using Theorem 1 and chain rule as follows:
\[C =\sup_{\mathbf{x}\in\mathbf{D}}\|\nabla_{\mathbf{x}}f_{\mathbf{ \theta}}\|_{2}=\sup_{\mathbf{x}\in\mathcal{D}}\|\nabla_{f_{L-1}}f_{L}\cdot \nabla_{f_{L-2}}f_{L-1}\cdot\ \ldots\ \cdot\nabla_{f_{1}}f_{2}\cdot\nabla_{\mathbf{x}}f_{1}\|_{2}\] \[\leq\sup_{f_{L-1}(\mathbf{x})}\|\nabla_{f_{L-1}}f_{L}\|_{2}\cdot \sup_{f_{L-2}(\mathbf{x})}\|\nabla_{f_{L-2}}f_{L-1}\|_{2}\cdot\ \ldots\ \cdot\sup_{f_{1}(\mathbf{x})}\|\nabla_{f_{1}}f_{2}\|_{2}\cdot \sup_{\mathbf{x}\in\mathcal{D}}\|\nabla_{\mathbf{x}}f_{1}\|_{2} \tag{3}\] \[\leq\sup\|\nabla_{f_{L-1}}f_{L}\|_{2}\cdot\sup\|\nabla_{f_{L-2}}f _{L-1}\|_{2}\cdot\ \ldots\ \cdot\sup\|\nabla_{f_{1}}f_{2}\|_{2}\cdot\sup\|\nabla_{ \mathbf{x}}f_{1}\|_{2}=:C_{\text{upper}}\, \tag{4}\]
where in the last line we consider the unconstrained supremum. For each linear layer \(f_{i}(\mathbf{x})=\mathbf{W}_{i}\,\mathbf{x}\), we know that the upper bound to the Lipschitz constant is equal to \(\|\mathbf{W}_{i}\|_{2}\), since the Jacobian matrix for \(f_{i}\) is equal to the weight matrix. Note that convolution layers can be represented as suitable linear transformations [22] using doubly block Toeplitz matrices. As a result, the upper bound to their Lipschitz constant can be recovered as the 2-norm of this equivalent matrix that is only dependent on kernel weights. Meanwhile, activation functions (like ReLU) and pooling layers (such as max-pooling) are just \(1\)-Lipschitz. Therefore, for such sequential neural networks, where each layer has a \(1\)-Lipschitz activation function, the upper bound is just the product of the norms of the corresponding linear transformation matrices.
Deep CNN layers have rather large respective linear transformation matrices due to a high number of input and output channels, which complicates the calculation of the matrix 2-norm using standard tools. To speed the computation we have therefore implemented Power Method, which, in some cases, resulted in up to 10 times faster calculations.
Empirical evaluation of the evolution of Lipschitz constant.Having introduced the main concepts, let us begin by first exploring how the Lipschitz constant behaves during training. In other words, we would like to investigate the evolution of the Lipschitz constant during training for a given neural network. In Figure 1, we present the results of training a feed-forward neural network with ReLU activations (we will call such network FF ReLU later) and 1 hidden layer of width 256. The model was trained on MNIST1D dataset [23] using the SGD optimiser and Cross-Entropy loss until convergence and zero training loss.
We include the line for \(C_{\text{avg\_norm}}=\mathbb{E}_{\mathbf{x}\in\mathcal{S}}\|\nabla_{\mathbf{x} }f_{\mathbf{\theta}}\|_{2}\) to indicate that the supremum bound is relatively close to the expected value of the Jacobian norm, which indicates that the supremum computation is not heavily affected by potential outliers.
From Figure 1 we can see that the \(C_{\text{lower}}\) and the \(C_{\text{upper}}\) are increasing with epochs, diverging rapidly from each other. Similar Lipschitz evolution trends are depicted by networks in other settings as well. In later sections, we give more details on how the Lipschitz constant evolution changes with the choice of width (section 3) or depth of the network (section 6), as well as the loss and the optimiser (section 5). Similar trends seem to hold even for other network architecture choices, such as Convolutional Neural Networks (CNNs), as illustrated in Figure 4.
Fidelity of the lower bound to the Lipschitz.As the true Lipschitz constant lies somewhere between the upper and the lower bounds, one may ask: how loose are those bounds and where does the true Lipschitz constant lie?
To give more insight into this, we compute bound 1 on a larger set of examples \(S^{*}\). This set includes, apart from the previously presented training set \(S\), (a) the test1 set \(S^{\prime}\), and (b) random 100,000 convex combinations of samples from the train set and test set. The set of convex combinations (\(\lambda\mathbf{x}_{i}+(1-\lambda)\mathbf{x}_{j}\)) is computed for each \(\lambda=\{0.1,0.2,0.3,0.4,0.5\}\), making it 500,000 samples for the train and 500,000 samples for the test set. In the end, \(S^{*}\) contains 1,005,000 samples. Results are presented in Figures 2 and 3. We denote \(C_{S^{*}}\) as the Lipschitz constant computed on the set \(S^{*}\).
Footnote 1: MNIST1D train dataset contains 4000 samples, test dataset contains 1000 samples.
It is evident from the above Figure 2 that the bound for the Lipschitz constant computed on set \(S^{*}\) lies closer to the lower bound \(C_{\text{lower}}\). This indicates that even though the upper bound \(C_{\text{upper}}\) gives a loose Lipschitz constant bound for the model for the whole functional domain \(dom(\mathbf{f}_{\mathbf{\theta}})\), _the true Lipschitz constant lies relatively closer to the lower bound \(C_{\text{lower}}\)_.
This statement is important, as the gap between the upper and the lower bound can become extremely large in some cases, leading to a significant overestimation of the Lipschitz constant of the network function. For instance, this may be observed in the case of CNNs. Figure 4 shows the Lipschitz constant trend for the CNN model with width (i.e., number of channels) 7, trained on CIFAR-10 [24] using Cross-Entropy loss and SGD optimiser until convergence and zero training loss.
Figure 1: Plot of Lipschitz constant bounds by training epoch for **FF ReLU network** with 1 hidden layer with 256 neurons. The model was trained on MNIST1D using Cross-Entropy loss and SGD optimiser. Results are averaged over 4 runs. More details in appendix S1.
Figure 2: Plot of Lipschitz constant bounds on the **train set \(S\) and set \(S^{*}\)** by training epoch for **FF ReLU network** with 1 hidden layer with 256 neurons. The model was trained on MNIST1D using Cross-Entropy loss and SGD optimiser. Results are averaged over 4 runs. More details in appendix sections S1.
We have presented both linear and log scales to show that even though the upper bound is growing much faster than the lower and the average norm bounds, all three bounds still follow the same trend as it was first shown in Figure 1.
For the rest of the paper, we will present both upper and lower Lipschitz constant bounds. However, we would like to mention that since the lower bound \(C_{\text{lower}}\) is closer to representing the Lipschitz constant for the distribution \(\mathcal{D}\), it would serve the reader to pay more attention to it compared to other bounds. In fact, this fact can also be seen in some of the works which propose tighter upper-bounds to the Lipschitz [9].
Remark.As can be seen, we have evaluated the fidelity of our lower bound on samples in the input space that are outside of the data distribution (but are still somewhat meaningful). It would also be interesting to consider the case of adversarially generated samples [4] and see how much can the lower bounds be pushed up. We leave this for a future investigation.
## 3 Double Descent in Lipschitz constant: Effect of Width
To study how the Lipschitz constant changes with the width of the hidden layers of the model, we conduct an experiment where we trained 16 FF ReLU networks, with 1 hidden layer, of increasing width. All the networks were trained on MNIST1D using Cross-Entropy loss and SGD optimiser.
This experimental setting, where networks with increasing number of parameters are compared to one another, should be reminiscent of the Double Descent phenomenon [15]. In this study, we replicated Double Descent for the setting above, which requires us to train all models until convergence. In order to keep the hyperparameters consistent across all settings while still being able to handle networks
Figure 4: Plots of Lipschitz constant bounds by training epoch for **CNN network** with width 7. The model was trained on CIFAR-10 using Cross-Entropy loss and SGD optimiser. Results are averaged over 4 runs. More details in appendix S1.
Figure 3: Plot of lower Lipschitz constant bounds **on different dataset combinations** by training epoch for **FF ReLU network** with 1 hidden layer with 256 neurons. The model was trained on MNIST1D using Cross-Entropy loss and SGD optimiser. Results are averaged over 4 runs. More details in appendix sections S1.
with such varying widths, we utilize an initial learning rate warmup to the base learning rate (LR) of 0.005 (referred to as Warmup20000Step25 LR Scheduler) for our runs. More details on models and the training strategy are listed in the appendix S1.
Figure 5 clearly displays how all three Lipschitz constant bounds display a shape similar to Double Descent. The interpolation threshold for both Lipschitz bounds and the test loss is at width 80, which is also the theoretical threshold, as FF ReLU with no bias and 1 hidden layer with width 80, 40 values on input and 10 values on output, has \(40\cdot 80+80\cdot 10=4000\) parameters, which is the exact number of training samples in the MNIST1D dataset.
Similar trends in the Lipschitz constant could be seen for FF ReLU networks trained using MSE, as well as other models like CNNs. In Figures 6 and 7, we present the Lipchitz constant bounds of the models at their last epoch for these two settings. We also include additional experiments on top of previously observed double descent in test loss in the literature [25], where we simply plot the Lipschitz bounds and even observe a double descent trend for them. These figures are located in appendix S2.1. Besides, a few remarks are in order:
Location of Interpolation threshold.It should be noted that, in both of these cases, the empirical interpolation thresholds appear slightly before the theoretical ones. For MSE loss, the interpolation threshold should theoretically occur at \(p=K\cdot n\) where \(p\) denotes the number of parameters, \(n\) is the number of training samples, and \(K\) is the output dimension. This corresponds to a width of \(800\) in the case of a one-hidden layer fully connected network, while empirically the interpolation threshold already seems near width \(~{}256\). Likewise, for the CNN model trained on CIFAR10 with 50000 samples, theoretically, the interpolation threshold should occur between width 11 (with \(p=46915\)) and width 12 (with \(p=55716\)). However, empirically, we see that it occurs at width \(10\). But besides
Figure 5: Log-Log plots of Lipschitz constant bounds and train and test losses by width for **FF ReLU networks** with 1 hidden layer with varying number of hidden neurons. Models were trained using **Cross-Entropy loss** and SGD optimiser with learning rate 0.005 and Warmup20000Step25 learning rate scheduler. Results are presented for the last epoch for each individual model and are averaged over 4 runs. More details in appendix S1.
this slight difference in the location of the interpolation threshold, we can clearly see that both the test loss and Lipschitz constant (as seen through the upper and lower bounds) show a double descent trend. As a matter of fact, such a behaviour of the interpolation threshold is also implicit in past works [26].
Trend of the entire generalization bounds.The fact that Lipschitz constant shows the same trend as the test loss is in a way expected, given that several generalization bounds include it as a term [2]. It would also be interesting to investigate if such proposed bounds also capture double descent in their entirety, and not just when the trend of the Lipschitz constant is noted in isolation.
Potential indication of Triple Descent.Lastly, unlike the test loss, the upper Lipschitz for FF ReLU networks (and even the lower Lipschitz sometimes, although more faintly relative to the upper bound) seems to continue to increase after the second descent, which could be a connection to the Triple Descent phenomenon [27]. We leave this observation as a future research question.
## 4 Bias-Variance Tradeoff
### A textbook theoretical analysis
To give some theoretical ground for the observations in the previous section, we present how bias-variance tradeoff connects with the Lipschitz constant of the network. Let us denote the neural network function as \(f_{\mathbf{\theta}}(\mathbf{x},S,\zeta)\) and the ground-truth function as \(\mathbf{y}^{\star}(\mathbf{x})\). Here, \(S\) denotes the training set and \(\zeta\) indicates the noise in the function due to the choice of random initialization and the noise
Figure 6: Log-Log plots of Lipschitz constant bounds and train and test losses by width for **FF ReLU networks** with 1 hidden layer with varying number of hidden neurons. Models were trained using **MSE loss** and SGD optimiser with learning rate 0.005 and Warmup20000Step25 learning rate scheduler. Results are presented for the last epoch for each individual model and are averaged over 4 runs. More details can be found in appendix S1.
Figure 7: Log-Log plots of Lipschitz constant bounds and train and test losses by width for **CNN networks** with varying width parameter. Models were trained using **Cross-Entropy loss** and SGD optimiser with learning rate 0.01 and Cont100 learning rate scheduler. Results are presented for the last epoch for each individual model and are averaged over 4 runs. More details can be found in appendix S1.
introduced by a stochastic optimizer, like stochastic gradient descent (SGD). Or said differently, one can take \(\zeta\) as denoting the random seed used in practice. Then let us assume we have the square loss, i.e., \(\ell(\mathbf{x};\mathbf{f}_{\mathbf{\theta}})=\|y(\mathbf{x})-f_{\mathbf{\theta}}(\mathbf{x },S,\zeta)\|^{2}\). We can write the loss evaluated on a test set, \(S^{\prime}\), i.e., the test loss, as follows:
\[\mathcal{L}(\mathbf{\theta},S^{\prime},\zeta)=\mathbb{E}_{\,\mathbf{x}\sim S^{ \prime}}\left[\|y(\mathbf{x})-f_{\mathbf{\theta}}(\mathbf{x},S,\zeta)\|^{2}\right] \tag{5}\]
In practice, we typically average the test loss over several random seeds, hence inherently involving an expectation over the noise \(\zeta\). We derive a bias-variance tradeoff [1, 28] that rests upon this as the noise source. Also, we consider the fixed-design variant of the bias-variance tradeoff and as a result, we will not average over the choice of the training set sampled from the distribution. In any case, for a suitably large training set size, this is expected not to introduce a lot of fluctuations and in particular, for the phenomenon at hand, i.e. double descent the training set is generally considered to be fixed. Hereafter, for convenience, we will suppress the dependence of the network function on the training set.
Now we do the usual trick of adding and subtracting the expected neural network function over the noise source. Hence, we can rewrite the above as:
\[\mathcal{L}(\mathbf{\theta},S^{\prime},\zeta) =\mathbb{E}_{\,\mathbf{x}\sim S^{\prime}}\left[\|y(\mathbf{x})- \mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]+\mathbb{E}_{\,\zeta}[ f_{\mathbf{\theta}}(\mathbf{x},\zeta)]-f_{\mathbf{\theta}}(\mathbf{x},\zeta)\|^{2}\right]\] \[=\mathbb{E}_{\,\mathbf{x}\sim S^{\prime}}\left[\|y(\mathbf{x})- \mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]\|^{2}\right]+\mathbb{ E}_{\,\mathbf{x}\sim S^{\prime}}\left[\|\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}( \mathbf{x},\zeta)]-f_{\mathbf{\theta}}(\mathbf{x},\zeta)\|^{2}\right]\] \[+2\,\mathbb{E}_{\,\mathbf{x}\sim S^{\prime}}\left[\left(y( \mathbf{x})-\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]\right)^{ \top}\,(\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]-f_{\mathbf{\theta }}(\mathbf{x},\zeta))\right)\right]\]
Next, we take the expectation of the above test loss with respect to the noise source \(\zeta\) -- mirroring the empirical practice of reporting results averaged over multiple seeds. It is easy to see that when taking expectation, the cross-term vanishes and we are left with the following expression:
\[\mathbb{E}_{\,\zeta}\,\mathcal{L}(\mathbf{\theta},S^{\prime},\zeta) =\mathbb{E}_{\,\mathbf{x}\sim S^{\prime}}\left[\|y(\mathbf{x})- \mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]\|^{2}\right]+\mathbb{ E}_{\,\zeta}\,\mathbb{E}_{\,\mathbf{x}\sim S^{\prime}}\left[\|\mathbb{E}_{\, \zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]-f_{\mathbf{\theta}}(\mathbf{x},\zeta)\|^ {2}\right] \tag{6}\] \[=\mathbb{E}_{\,\mathbf{x}\sim S^{\prime}}\left[\|y(\mathbf{x})- \mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]\|^{2}\right]+\mathbb{ E}_{\,\mathbf{x}\sim S^{\prime}}\mathbb{E}_{\,\zeta}\left[\|\mathbb{E}_{\,\zeta}[f_{ \mathbf{\theta}}(\mathbf{x},\zeta)]-f_{\mathbf{\theta}}(\mathbf{x},\zeta)\|^{2}\right]\] (7) \[=\mathbb{E}_{\,\mathbf{x}\sim S^{\prime}}\left[\|y(\mathbf{x})- \mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]\|^{2}\right]+\mathbb{ E}_{\,\mathbf{x}\sim S^{\prime}}\,\mathrm{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{x}, \zeta)) \tag{8}\]
As a shorthand, we denote the above expected test loss as \(\overline{\mathcal{L}}(\mathbf{\theta},S^{\prime}):=\mathbb{E}_{\,\zeta}\,\mathcal{ L}(\mathbf{\theta},S^{\prime},\zeta)\). Overall, this results in the bias-variance tradeoff under our setting.
Upper-bounding the Variance term.Now, we want to a do a finer analysis of the variance term by involving the Lipschitz constant of the network function. Moreover, let's for the moment focus only on the part \(\mathrm{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{x},\zeta))\).
\[\mathrm{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{x},\zeta))=\mathbb{ E}_{\,\zeta}\left[\|\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]-f_{\mathbf{ \theta}}(\mathbf{x},\zeta)\|^{2}\right] \tag{9}\] \[=\mathbb{E}_{\,\zeta}\left[\|\underbrace{\mathbb{E}_{\,\zeta}[f_ {\mathbf{\theta}}(\mathbf{x},\zeta)]-\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x }^{\prime},\zeta)]}_{a}+\underbrace{\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}( \mathbf{x}^{\prime},\zeta)]-f_{\mathbf{\theta}}(\mathbf{x}^{\prime},\zeta)}_{b}+ \underbrace{f_{\mathbf{\theta}}(\mathbf{x}^{\prime},\zeta)-f_{\mathbf{\theta}}(\mathbf{x },\zeta)}_{c}\|^{2}\right] \tag{10}\]
where, we have considered some auxiliary point \(\mathbf{x}^{\prime}\), and added and subtracted some terms. Further recalling that for \(n\) vectors, \(\mathbf{x}_{1},\cdots,\mathbf{x}_{n}\), we can utilize the simple inequality:
\[\|\mathbf{x}_{1}+\cdots+\mathbf{x}_{n}\|^{2}\leq n\sum_{i=1}^{n}\|\mathbf{x}_{i }\|^{2}\]
which follows from \(n\) applications of the Cauchy-Schwarz inequality. Hence, the variance above can be upper-bounded as:
\[\mathrm{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{x},\zeta)) \leq 3\,\|\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)]- \mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x}^{\prime},\zeta)]\|^{2}+3\, \mathbb{E}_{\,\zeta}\,\|\mathbb{E}_{\,\zeta}[f_{\mathbf{\theta}}(\mathbf{x}^{ \prime},\zeta)]-f_{\mathbf{\theta}}(\mathbf{x}^{\prime},\zeta)\|^{2}\] \[+3\,\mathbb{E}_{\,\zeta}\,\|f_{\mathbf{\theta}}(\mathbf{x}^{\prime}, \zeta)-f_{\mathbf{\theta}}(\mathbf{x},\zeta)\|^{2}\]
We can think of \(\mathbb{E}\,_{\zeta}f_{\mathbf{\theta}}(\mathbf{x},\zeta)\) as the ensembled function mapping, and denote it by say \(\overline{f_{\mathbf{\theta}}}(\mathbf{x}):=\mathbb{E}\,_{\zeta}f_{\mathbf{\theta}}( \mathbf{x},\zeta)\), and let's assume that it is \(\overline{C}\)-Lipschitz. On the other hand, let's say that each individual function \(f_{\mathbf{\theta}}(\mathbf{x},\zeta)\) has Lipschitz constant \(C_{\zeta}\). Hence we can further reduce the upper bound to
\[\operatorname{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{x},\zeta))\leq 3\, \overline{C}^{2}\,\|\mathbf{x}-\mathbf{x}^{\prime}\|^{2}+3\,\operatorname{ Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{x}^{\prime},\zeta))+3\,\mathbb{E}\,_{ \zeta}\,C_{\zeta}^{2}\|\mathbf{x}-\mathbf{x}^{\prime}\|^{2}\,. \tag{11}\]
Now, we bring back the outer expectation with respect to samples from the test set, i.e., \(\mathbf{x}\sim S^{\prime}\):
\[\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\operatorname{Var}_{\zeta}(f_{\mathbf{ \theta}}(\mathbf{x},\zeta))\leq 3\,\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}} \operatorname{\overline{C}^{2}}\,\|\mathbf{x}-\mathbf{x}^{\prime}\|^{2}+3\, \mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\,\operatorname{Var}_{\zeta}(f_{\mathbf{ \theta}}(\mathbf{x}^{\prime},\zeta))+3\,\mathbb{E}\,_{\mathbf{x}\sim S^{ \prime}}\,\mathbb{E}\,_{\zeta}\,C_{\zeta}^{2}\|\mathbf{x}-\mathbf{x}^{\prime}\| ^{2}\]
Notice that while the Lipschitz constant of the neural network function do depend on the training data, the above expectation is with respect to samples from the test set. Hence, we can take the Lipschitz constants that appear above outside of the expectation. Besides, the middle term on the right-hand side has no dependency on the test sample \(\mathbf{x}\sim S^{\prime}\) and so the expectation goes away. Overall, this yields,
\[\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\operatorname{Var}_{\zeta}(f_{\mathbf{ \theta}}(\mathbf{x},\zeta))\leq 3\,(\overline{C}^{2}+\overline{C_{\zeta}^{ \prime}}^{2})\,\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\,\|\mathbf{x}-\mathbf{ x}^{\prime}\|^{2}+3\,\operatorname{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{x}^{ \prime},\zeta)) \tag{12}\]
where, for simplicity, we have denoted the Lipschitz constant \(C_{\zeta}\) averaged over the random seeds \(\zeta\), as \(\overline{C_{\zeta}}\). We can simplify the above upper bounds by taking \(\mathbf{x}^{\prime}=\mathbf{0}\) as the vector of all zeros, resulting in:
\[\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\operatorname{Var}_{\zeta}(f_{\mathbf{ \theta}}(\mathbf{x},\zeta))\leq 3\,(\overline{C}^{2}+\overline{C_{\zeta}^{ \prime}}^{2})\,\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\,\|\mathbf{x}\|^{2}+3 \,\operatorname{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{0},\zeta)) \tag{13}\]
and which now contains the variance of the network function at the input \(\mathbf{0}\) computed over the various seeds. As a shorthand let's denote \(\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\,\|\mathbf{x}\|^{2}\) as the \(r_{S^{\prime}}^{2}\).
At the cost of loosening the above upper bound, we can simplify it by using the fact that \(\overline{C}\leq\overline{C_{\zeta}}\). This is because (using Jensen's inequality):
\[\|\overline{f_{\mathbf{\theta}}}(\mathbf{x})-\overline{f_{\mathbf{\theta }}}(\mathbf{x}^{\prime})\| =\|\mathbb{E}\,_{\zeta}[f_{\mathbf{\theta}}(\mathbf{x},\zeta)-f_{\mathbf{ \theta}}(\mathbf{x}^{\prime},\zeta)]\|\] \[\leq\mathbb{E}\,_{\zeta}\|f_{\mathbf{\theta}}(\mathbf{x},\zeta)-f_{ \mathbf{\theta}}(\mathbf{x}^{\prime},\zeta)\|\] \[\leq\mathbb{E}\,_{\zeta}C_{\zeta}\|\mathbf{x}-\mathbf{x}^{\prime} \|=\overline{C_{\zeta}}\|\mathbf{x}-\mathbf{x}^{\prime}\|\,.\]
Hence, we have:
\[\mathbb{E}\,_{\mathbf{x}\sim S^{\prime}}\operatorname{Var}_{\zeta}(f_{\mathbf{ \theta}}(\mathbf{x},\zeta))\leq 6\,r_{S^{\prime}}^{2}\,\overline{C_{\zeta} }^{2}+3\,\operatorname{Var}_{\zeta}(f_{\mathbf{\theta}}(\mathbf{0},\zeta)) \tag{14}\]
As \(r_{S^{\prime}}^{2}\) is going to be network size agnostic (or e.g., when the data is on the unit sphere, simply unity), we can see that the variance term in the bias-variance tradeoff will be largely dictated by the average Lipschitz constant of the function over various seeds. Plus, close to interpolation and after, the bias term will be rather small. So, it is the Lipschitz constant which will control the upper bound on the generalization error.
### Empirical Evaluation
Bias-Variance tradeoff.In Figure 8, we present the empirical calculation for the relation of Variance and test loss. We use the same sweep of FF ReLU networks with varying width on the MNIST1D dataset using MSE loss from the Double Descent section 3.
Variance upper bounds.We also show empirical calculations for the bounds in the equations 13 and 14, presented in Figure 9. Empirical data was collected from the same models introduced in the previous paragraph.
## 5 Lipschitz Constant and the Optimisation procedure
In this section we explore how the choice of the optimisation strategy affects the Lipschitz constant of the Network. By optimisation strategy we mean the choice of the loss function and the optimisation algorithm. We will observe the effect of each choice separately.
Figure 8: Log-log plots of Variance and test loss against model width. Results are presented from training FF ReLU networks with varying width on MNIST1D using MSE loss and SGD optimiser. The expectations over random initialisations were computed as an average of 4 seeds. More details in appendix S1.
Figure 10: Plot of Lipschitz constant bounds for FF ReLU network with 1 hidden layer with 256 neurons, trained using **Cross-Entropy loss and MSE loss**. Both models were trained on MNIST1D with SGD using the same LR and LR scheduler. Results are averaged over 4 runs. More details in appendix S1.
Figure 9: Log-log plot of Variance and its upper bounds against model width. Results are presented from training FF ReLU networks with varying width on MNIST1D using MSE loss and SGD optimiser. The expectations over random initialisations were computed as an average of 4 seeds. More details in appendix sections S1 and S2.2.
### Effect of the loss function: CE vs MSE
Figure 10 shows the evolution of the Lipschitz constant for the FF ReLU models, trained on MNIST1D with SGD using Cross-Entropy and MSE loss.
The plots show that the bounds for MSE loss are by an order of magnitude smaller than the ones for Cross-Entropy. Our hypothesis is that this occurs due to the magnitude of possible values on the output. Since for the classification task with MSE loss our model has to ideally output a one-hot vector, the range of the norm of possible output values is smaller than in the case of Cross-Entropy, where outputs are further Softmax-ed. Note that we compute the Lipschitz constant with respect to the output of the model without Softmax, since classification could still be done by finding the argmax of the output.
Lipschitz evaluation including Softmax.To support our argument, we also compute the value of the lower Lipschitz constant bound on the FF ReLU 256 network trained on Cross-Entropy with an additional layer of Softmax applied. Results in Figure 11 empirically verify that Softmax pushes the lower bound for the Cross-Entropy trained network closer to the range of values of the MSE trained network.
### Effect of the optimisation algorithm: SGD vs Adam
In Figure 12, we show evolution of the Lipschitz constant for the FF ReLU models, trained on MNIST1D using Cross-Entropy with SGD and Adam optimisers.
Figure 11: Plot of lower Lipschitz constant bounds for FF ReLU network with 1 hidden layer with 256 neurons, trained using **Cross-Entropy loss and MSE loss**. A variant of **FF ReLU trained on Cross-Entropy with Softmax applied** is included as well. All models were trained on MNIST1D with SGD using the same LR and LR scheduler. Results are averaged over 4 runs. More details in appendix S1.
Figure 12: Plot of Lipschitz constant bounds for FF ReLU network with 1 hidden layer with 256 neurons, trained using **SGD and Adam**. Both models were trained on MNIST1D with Cross-Entropy, using the same LR and LR scheduler. Results are averaged over 4 runs. More details in appendix S1.
Figure 12 displays how Adam significantly increases all Lipschitz bounds, and we hypothesize that this might be linked to the nature of Adam optimisation. More concretely, we find that in the case of training with Adam the final model parameters travel further from initialisation as compared to that with SGD. This is illustrated in Figure 13, where we plot the norm of the parameter vector difference between current epoch and initialisation \(\|\mathbf{\theta}_{t}-\mathbf{\theta}_{0}\|_{2}\) over the epochs. But we leave a thorough exploration of this facet for future work.
We note that this trend also holds even if train the network with SGD for more epochs and the respective plots are in appendix S2.
An interesting by-product of the above finding is that actually \(\|\mathbf{\theta}_{t}-\mathbf{\theta}_{0}\|_{2}\) also exhibits Double Descent as in the setting of increasing network width. Results of the sweep are shown in Figure 14.
## 6 Miscellaneous Experiments
In this section we present more experiments to find dependencies between the Lipschitz constant of the network and other learning parameters. In particular, we present how Lipschitz depends on depth, number of training samples and different amounts of label noise.
### Lipschitz constant and the effect of Depth
To study the effects of depth we train a series of FF ReLU models with various number of hidden layers, from 1 to 5. Comparison of the evolution of Lipcschitz constant bounds are presented in Figure 15 and a summary plot is displayed in Figure 16.
Figure 14: Log-Log plots of Norms of the parameter difference and train and test losses by width for **FF ReLU networks** with 1 hidden layer with varying number of hidden neurons. Models were trained using **Cross-Entropy loss** and SGD optimiser with learning rate 0.005 and Warmup20000Step25 learning rate scheduler. Results are presented for the last epoch for each individual model and are averaged over 4 runs. More details in appendix S1.
Figure 13: Plot of the difference Lipschitz constant bounds for FF ReLU network with 1 hidden layer with 256 neurons, trained using **SGD and Adam**. Both models were trained on MNIST1D with Cross-Entropy, using the same LR and LR scheduler. Results are averaged over 4 runs. More details in appendix S1.
#### 6.1.1 At Convergence
#### 6.1.2 At Initialization
According to the plots, all Lipschitz bounds start to multiplicatively increase with each subsequent layer. Note that the increase is not immediate: deeper models start rapidly increasing the Lipschitz later than more shallow models, especially in the case for the lower bound. An interesting fact is that
Figure 16: Summary plot of Lipschitz constant bounds against the **number of hidden layers** of FF ReLU network **at the last epoch**. All models are trained on MNIST1D using Cross-Entropy loss and SGD. More details in appendix S1.
Figure 17: Summary plot of Lipschitz constant bounds against the **number of hidden layers** of FF ReLU network **at initialisation**. All models are trained on MNIST1D using Cross-Entropy loss and SGD. More details in appendix S1.
Figure 15: Plots of Lipschitz constant bounds against epochs for **various number of hidden layers** of FF ReLU network. All models are trained on MNIST1D using Cross-Entropy loss and SGD. More details in appendix S1.
the aforementioned trend does not hold for networks at initialisation, both for the case of increasing depth (Figure 17) and increasing width (Figure 18). Consequently, we also see how the effect of feature learning gets manifested in the bounds of the Lipschitz constant and that looking solely at initialisation (as in the style of the lazy regime [29]) would be insufficient.
### Lipschitz constant and the effect of the number of training samples
In this section we present Lipschitz constant bounds for FF ReLU model with width 256 on various sizes of MNIST1D: 4000, 1000, 500 and 100 training samples. Results are presented on Figure 19.
Figure 19 shows that increasing the number of samples in the training dataset increases the Lipschitz constant. This suggests that the networks need to become "less smooth" as the complexity of function increases to fit a larger number of points. It would be interesting to precisely tease out this behaviour in terms of relevant theoretical quantities, but we leave that for future work.
### Lipschitz constant and the effect of Label Noise
In this paragraph we have trained an FF ReLU model with width 256 on the modified version of MNIST1D, where labels are shuffled. We used datasets, where 0%, 10%, 15%, 20%, 25%, 50%, 75% and 100% of labels are shuffled. Results are presented on Figure 21.
Figure 21 shows that increasing the amount of shuffling reduces the lower and average norm Lipschitz constant bounds. These observations show that increasing label noise makes the function become injuriously smooth, which interferes with the ability of the network to generalize.
Figure 19: Plots of Lipschitz constant bounds against epochs for **various number of samples in the training dataset** for FF ReLU 256 network. All models are trained on MNIST1D using Cross-Entropy loss and SGD. Results are averaged over 4 runs. More details in appendix S1.
Figure 18: Log-log plot of Lipschitz constant bounds against the **width** of FF ReLU network **at initialisation**. All models are trained on MNIST1D using Cross-Entropy loss and SGD. More details in appendix S1.
## 7 Conclusion
To conclude, we have presented a wide-ranging study of the trends of the Lipschitz constant in various learning settings. First, we have shown evolution trends of various Lipschitz constant bounds for different networks, displaying the tightness of the simple lower bound with respect to the true Lipschitz constant. Second, we looked at the behaviour of Lipschitz constant in the Double Descent setting and have shown that both lower and upper Lipschitz bounds exhibit trends similar to test loss. We next presented theoretical statements, connecting Lipschitz constant with the variance term in the generalisation bound, and also gave experimental proof to those statements. In the subsequent sections, we discussed the effect of the choice of loss (between Cross-Entropy and MSE), optimisation algorithm (SGD versus Adam), depth of the network and training sample modifications, like variable dataset lengths and label noise.
Further research directions.We hope that this work inspires further research on uncovering and understanding the characteristics of the Lipschitz constant. One potential avenue for investigation is to explore more complex model classes, such as ResNets or different types of Transformers [30]. Additionally, it would be of great interest to compare tighter Lipschitz constant bounds, proposed in the literature, with the results presented in this study. Another promising area for future research is to examine how various forms of input noise affect the Lipschitz constant.
Figure 21: Plots of Lipschitz constant bounds against epochs for **various amounts of label shuffling of the training dataset** for FF ReLU 256 network. Results are averaged over 4 runs. All models are trained on MNIST1D using Cross-Entropy loss and SGD. More details in appendix S1.
Figure 20: Summary log-log plot of Lipschitz constant bounds against the **number of training samples** in MNIST1D. Plotted for the FF ReLU 256 networks at their last epoch. All models are trained using Cross-Entropy loss and SGD. Results are averaged over 4 runs. More details in appendix S1.
## Acknowledgements
We would like to thank Thomas Hofmann, Bernhard Scholkopf, and Aurelien Lucchi for their useful comments and suggestions. We are also grateful to the members of the DALab for their support. Sidak Pal Singh would like to acknowledge the financial support from Max Planck ETH Center for Learning Systems.
|
2306.08294 | Artificial Neural Networks and Guided Gene Expression Programming to
Predict Wall Pressure Spectra Beneath Turbulent Boundary Layers | This study evaluates the efficacy of two machine learning (ML) techniques,
namely artificial neural networks (ANN) and gene expression programming (GEP)
that use data-driven modeling to predict wall pressure spectra (WPS) underneath
turbulent boundary layers. Different datasets of WPS from experiments and
high-fidelity numerical simulations covering a wide range of pressure gradients
and Reynolds numbers are considered. For both ML methods, an optimal
hyperparameter environment is identified that yields accurate predictions. ANN
is observed to be faster and more accurate than GEP with an order of magnitude
lower training time and logarithmic mean squared error ($lMSE$), despite a
higher memory consumption. Novel training schemes are devised to address the
shortcomings of GEP. These include (a) ANN-assisted GEP to reduce the noise in
the training data, (b) exploiting the low and high-frequency trends to guide
the GEP search, and (c) a stepped training strategy where the chromosomes are
first trained on the canonical datasets followed by the datasets with complex
features. When compared to the baseline scheme, these training strategies
accelerated convergence and resulted in models with superior accuracy ($\approx
30\%$ reduction in the median $lMSE$) and higher reliability ($\approx 75\%$
reduction in the spread of $lMSE$ in the interquartile range). The final GEP
models captured the complex trends of WPS across varying flow conditions and
pressure gradients, surpassing the accuracy of Goody's model. | Nachiketa Narayan Kurhade, Nagabhushana Rao Vadlamani, Akash Haridas | 2023-06-14T07:04:11Z | http://arxiv.org/abs/2306.08294v1 | Artificial Neural Networks and Guided Gene Expression Programming to Predict Wall Pressure Spectra Beneath Turbulent Boundary Layers
###### Abstract
This study evaluates the efficacy of two machine learning (ML) techniques, namely artificial neural networks (ANN) and gene expression programming (GEP) that use data-driven modeling to predict wall pressure spectra (WPS) underneath turbulent boundary layers. Different datasets of WPS from experiments and high-fidelity numerical simulations covering a wide range of pressure gradients and Reynolds numbers are considered. For both ML methods, an optimal hyperparameter environment is identified that yields accurate predictions. ANN is observed to be faster and more accurate than GEP with an order of magnitude lower training time and logarithmic mean squared error (\(lMSE\)), despite a higher memory consumption. Novel training schemes are devised to address the shortcomings of GEP. These include (a) ANN-assisted GEP to reduce the noise in the training data, (b) exploiting the low and high-frequency trends to guide the GEP search, and (c) a stepped training strategy where the chromosomes are first trained on the canonical datasets followed by the datasets with complex features. When compared to the baseline scheme, these training strategies accelerated convergence and resulted in models with superior accuracy (\(\approx 30\%\) reduction in the median \(lMSE\)) and higher reliability (\(\approx 75\%\) reduction in the spread of \(lMSE\) in the interquartile range). The final GEP models captured the complex trends of WPS across varying flow conditions and pressure gradients, surpassing the accuracy of Goody's model.
+
Footnote †: preprint: Accelerated GEP to Predict Wall Pressure Spectra beneath Turbulent Boundary Layers
## I Introduction
Turbulent boundary layers (TBLs) developing over the surfaces induce wall-pressure fluctuations. These dynamic loads are highly undesirable as they increase structural vibrations and noise. Fatigue failure due to aeroacoustic loads is a critical problem in wind turbine and gas turbine blades [1; 2; 3; 4; 5]. Aerodynamic noise due to attached or separated TBLs contributes significantly towards medium and high-frequency sound pressure levels (SPL) of the cabin [6; 7]. Acoustic loads due to wall-pressure fluctuations are much more severe over the skin panels of high-speed vehicles. The amplitude and frequency of these loads can be significantly higher in certain regions which can potentially damage the vehicle.
Estimating the wall-pressure fluctuations beneath TBLs is hence crucial to facilitate the structural and aerodynamic design process. These fluctuations can either be estimated from high-fidelity eddy-resolving simulations or can be directly measured from experiments. Both these approaches are prohibitively expensive. Although eddy-resolving methods like Direct Numerical Simulations (DNS) [8; 9; 10] and Large Eddy Simulations (LES) [11; 12; 13] can accurately quantify the spatiotemporal variation of acoustic loads, they are computationally expensive to cater to the highly iterative design process. On the other hand, most of the experiments in the literature are confined to measuring wall pressure spectra (WPS) of TBLs developing over simple geometries like a flat plate subjected to zero, favorable, or adverse pressure gradients [14; 15; 16; 17] (ZPG, FPG, and APG).
One of the widely used approaches to overcome these limitations is to couple the empirical models of WPS with the mean boundary layer characteristics obtained from the Reynolds Averaged Navier-Stokes (RANS) simulations to predict acoustic loads [19]. These models rely on scaling laws based on the inner and outer regions of the boundary layer to estimate the sound pressure levels. Several empirical models for WPS were developed based on the theoretical foundations of Lighthill [20; 21] and Kraichnan [22]. Blake [23] integrates the Poisson equation for pressure fluctuation beneath a TBL. As noted by Grasso _et al._[24], the theoretical model involves repeated integration in multiple dimensions, and the computational cost increases exponentially with the number of dimensions. An alternate approach involves correlating the non-dimensionalized SPL distribution with boundary layer parameters like thickness, wall-shear stress, freestream velocity, etc. This approach, as reflected in the works of Chase [25] and Howe [26] has an evolutionary advantage as the subsequent models continued to modify the same baseline empirical structure to account for newer observations. Goody [27] further modified the Chase-Howe model to include Reynolds number effects and capture the frequency dependence. Goody's model is designed to predict the WPS of TBLs under ZPG with a \(\omega^{2}\) growth at low frequencies (in line with Kraichnan-Phillips' theorem), \(\omega^{-1}\) decay in the inertial range (in line with Bradshaw prediction [28]) and \(\omega^{-5}\) decay at the high-frequencies (in line with Blake's observations [23]). Subsequent works of Kamruzzaman _et al._[29], Rozenberg _et al._[19], Hu [30] and Lee [31] extended Goody's model to account for pressure gradients. Ritos _et al._[32] recognised that the existing models fall short in predicting the WPS beneath supersonic and hypersonic flat plate TBLs under ZPG conditions and modified Goody's model to account for the compressibility effects. Wind tunnel experiments of Thomson and Rocha [33] measured wall pressure fluctuations of TBL on a flat plate under FPG. They further tuned the parameters of the universal spectrum model (which is inspired by Goody's model) to incorporate FPG effects and improve predictions at high-frequencies. Thomson and Rocha [34] compare the performance of Goody's model on both the wind
tunnel data and flight test data. They highlight that the model accurately predicts the WPS of the former while underpredicts the latter and accordingly updated Goody's model to accurately fit the flight test data. Accounting for the different flow conditions and pressure gradients, Fritsch _et al._[35] developed a semi-empirical WPS model using numerical optimization algorithms. The predictions are shown to be sensitive to the values of constants involved and the optimized set is bound to evolve with an ever-evolving dataset. All these empirical models, however, were developed based on the respective datasets and hence their accuracy suffers when employed for 'extrapolated' flow conditions.
With increasing computational power and the databases of wall pressure spectra data published in public domains, robust wall pressure spectra models can be developed by exploiting the entire database. Additionally one can identify the range of TBL parameters covered by these databases [36]. These insights can then be used by modern machine learning (ML) algorithms to solve this regression problem. Haridas and Vadlamani [37] and Dominique _et al._[36] used artificial neural networks (ANN) for this purpose and obtained better predictions than any of the empirical models discussed above. The study conducted by Haridas and Vadlamani [37] used subsonic and supersonic datasets to train their ANN model. This approach also enabled Dominique _et al._ to quantify the confidence in their predictions and identify the input space where more data will be helpful in improving the predictions. ANN being the universal function approximator [38] is indeed best suitable for the job as it can be retrained with little effort on the new datasets. The downside with ANN is twofold: (a) It results in a highly non-linear function that is difficult to translate to a conventional functional form and (b) It provides little insight into the underlying physics of the problem [37]. On the other hand, Gene expression programming (GEP), a symbolic machine learning algorithm, operates on the input variables through generations to evolve into an analytical expression that tries to approximate provided data. Dominique _et al._[39] showed the capabilities of this technique to predict the WPS models that are close to the established empirical correlations in addition to discovering the new dependencies that were not considered earlier. GEP however suffers from converge issues. Also, for a given set of input features, the algorithm produces different analytical expressions, although their structures and predictions can be very similar.
The objective of the present work is multifold. We first compare the strength and weaknesses of ANN and GEP (with an optimized hyperparameter environment) against the same input data assessing the time taken to converge, and the computational resources utilized. Subsequently, we propose strategies (like ANN-assisted training incorporating physical insights) to accelerate the training of the GEP algorithm and mitigate its convergence issues. Finally, we demonstrate the efficacy of the training strategies and the robustness of the models predicted using the guided GEP approach.
The manuscript is structured as follows: We introduce the regression problem and the relevant WPS models in Section II. Section III presents a brief description and analysis of the input dataset and a short overview of ANN and GEP. We present the optimum hyperparameter environment and compare the computational efficacy of ANN and GEP in Section IV. Strategies to accelerate GEP training to mitigate the convergence issues are addressed in Section V. Lastly, Section VI concludes the key findings of the study.
## II Characterizing Turbulent Boundary Layer and Wall Pressure Spectrum
As mentioned in the introduction, the empirical models of WPS rely on the mean boundary layer characteristics to predict acoustic loads. All the TBLs have a negligible zero pressure gradient in the wall-normal direction (\(\partial_{x}p=0\)) but can be subjected to a considerable gradient (\(\partial_{x}p\)) in the streamwise direction. Figure 1 sketches a typical velocity profile \(U(y)\) at a distance \(x\) downstream of the leading edge for a general case where the equilibrium velocity at the boundary layer edge changes with \(x\) as \(U_{\epsilon}(x)\). The local boundary layer thickness (\(\delta(x)\)) is usually defined as the wall-normal distance at which \(U=0.99U_{\epsilon}(x)\). In this study, following Dominique _et al._, we use an alternate definition for boundary layer thickness based on the pseudo-velocity [9]\(U^{*}(x,y)=-\int_{0}^{y}\Omega_{z}(x,\xi)\,d\xi\) to account for the effect of pressure gradients on the outer flow velocity. Here, \(\Omega_{z}\) is the spanwise component of the mean vorticity \(\Omega=\nabla\times\widetilde{U}\), \(\overline{U}\) being the mean velocity vector and \(\xi\) is the length in wall-normal direction.
At the same point \(x\) downstream of the leading edge, a probe can be placed on the wall to record the pressure fluctuations due to TBL. The unsteady pressure signals \(p(\tau)\) can be decomposed into its mean and fluctuating components as follows:
\[p(x,\tau)=\overline{p}(x,\tau)+p^{\prime}(x,\tau) \tag{1}\]
The point-wise power spectral density (PSD) \(\Phi_{pp}\) of these pressure fluctuations is obtained from the following equation:
\[\Phi_{pp}(x,\omega)=\int_{-\infty}^{+\infty}R(x,\tau)e^{-i\omega t}\,d\tau \tag{2}\]
Here, \(R\) is the auto-correlation function defined as \(R(x,\tau)=\int_{0}^{\infty}p^{\prime}(x,t)p^{\prime}(x,t+\tau)\,dt\), \(\Phi_{pp}(x,\omega)\) is the PSD obtained from
Figure 1: Typical flat plate boundary layer
the fast Fourier transform of \(R\), \(\omega\) is the angular frequency and \(i=\sqrt{-1}\). Several empirical models in the literature express the empirical correlation for \(\Phi_{pp}\) in terms of the mean boundary layer parameters:
\[\Phi_{pp}(\omega)=f(\omega,\delta,\delta^{*},\theta,U_{e},\rho,\nu,\tau_{w}, \partial_{x}p,c,\Pi) \tag{3}\]
Where \(\delta^{*}=\int_{0}^{\delta}(1-U(x,y)/U_{e})\,dy\) is the displacement thickness, \(\theta=\int_{0}^{\delta}U(x,y)/U_{e}(1-U(x,y)/U_{e})\,dy\) represents the momentum thickness of the TBL, and \(\tau_{w}\) is the wall shear stress at location \(x\). \(\rho\), \(\nu\), and \(c\) represent the density, dynamic viscosity, and speed of sound in the freestream respectively. A TBL typically consists of four distinct regimes in the wall-normal direction: viscous sublayer closer to the wall, intermediate buffer layer, logarithmic region influenced by large turbulent scales, and the wake region. The deviation of the velocity profile from the log law in the wake region is characterized by the wake strength parameter [40], \(\Pi\). The number of independent variables in Eq. 3 can be reduced using the Buckingham-Pi theorem. Following the work of Dominique _et al._[36], Eq. 3 is rewritten in terms of the non-dimensionalize variables as:
\[\widetilde{\Phi}_{pp}=f(\widetilde{\omega},\Delta,H,M,\Pi,C_{f},R_{T},\beta) \tag{4}\]
Where,
\[\text{Dimensionless PSD:}\;\widetilde{\Phi}_{pp}=(\Phi_{pp}U_{e})/(\tau_{w}^{2}\delta)\]
\[\text{Dimensionless angular frequency:}\;\widetilde{\omega}=(\omega\delta)/U_{e}\]
\[\text{Zagarola-Smits's parameter}\]
\[\text{Shape factor:}\;H=\delta^{*}/\theta\]
\[\text{Mach number:}\;M=U_{e}/c\]
\[\text{Wake strength parameter}\]
\[\text{Friction coefficient:}\;C_{f}=\tau_{w}/(\rho U_{e}^{2})\]
\[\text{Outer-to-inner-layer timescale ratio:}\;R_{T}=(\delta/U_{e})/(\nu/U_{\tau}^{2})\]
\[\text{Clauser parameter:}\;\beta=(\theta/(\rho U_{\tau}^{2}))\partial_{x}p\]
### Goody's Model
One of the earliest empirical models, the Chase-Howe model [25; 26], proposed a correlation of PSD (\(\Phi_{pp}\)) as a sole function of angular frequency \(\omega\). It however fails to predict the high frequency \(\widetilde{\omega}^{-5}\) drop observed in the wall pressure spectra of TBLs under ZPG. Goody [27] proposed the following changes to the Chase-Howe model: (a) Since the largest coherent structures in TBL are of the order of boundary layer thickness, \(\delta^{*}\) is replaced with \(\delta\) based scaling (b) Ratio of outer-layer to inner-layer timescales, \(R_{T}\) (a different form of Reynolds number) is incorporated into the formulation to control the extent of inertial subrange. Goody's model, given in Eq. 5, accurately predicts ZPG turbulent boundary layers that are homogeneous in the spanwise direction. Hence it is considered as the baseline semi-empirical model although it does not account for pressure gradients.
\[\frac{\Phi_{pp}U_{e}}{\tau_{w}^{2}\delta}=\frac{3(\omega\delta/U_{e})^{2}}{[( \omega\delta/U_{e})^{0.75}+0.5]^{3.7}+[1.1R_{T}^{-0.57}(\omega\delta/U_{e})]^{ 7}} \tag{5}\]
### Dominique's GEP Model
Dominique _et al._[39] trained the gene expression programming algorithm on the datasets described in Section III.1 to come up with the following WPS model:
\[\widetilde{\Phi}_{pp}=\frac{\left(5.41+C_{f}\left(\beta+1\right)^{5,41}\right) \widetilde{\omega}}{\widetilde{\omega}^{2}+\widetilde{\omega}+(\beta+1)M+( \widetilde{\omega}+3.6)\frac{\widetilde{\omega}^{4.76}}{C_{f}R_{T}^{5.83}}} \tag{6}\]
Although derived from scratch, Dominique's GEP model reasonably captures the frequency dependencies. Their model shows a \(\widetilde{\omega}^{1}\) dependence at low frequencies, in contrast to the \(\widetilde{\omega}^{2}\) dependence proposed by Kraichnan [22]. This is considered a strong trait for modeling realistic scenarios using GEP where the data does not always agree with the theoretical models.
## III Methodology
### Data Collection
The dataset used in the present work stems from the study by Dominique _et al._[36] (also referred to as the von Karman Institute (VKI) team henceforth). It consists of the variation of \(\widetilde{\Phi}_{pp}\) with \(\widetilde{\omega}\) at subsonic Mach numbers, in addition to the mean TBL characteristics (reported in Eq. 4), collected from the following sources:
* Experiments of Salze _et al._[14] on a flat plate under ZPG, APG, and FPG.
* High-fidelity computations of Deuse and Sandberg [9], Hao _et al._[10] and, Christophe _et al._[12] on the configuration of the flow over a controlled diffusion (CD) airfoil, where the TBL spectra under APG and mild FPG are recorded at different stations.
Figure 2 plots all the 117 datasets, each of which has 500 logarithmically spaced points resampled from the experiments listed above. A machine learning algorithm is otherwise oblivious to the different experiments from which the dataset has been extracted. Rather, it solves the regression problem modeled using Eq. 4 treating the input as a set of independent data points with respective features and labels.
### Data analysis
A closer look at Fig. 2 shows the dominance of the APG dataset over the FPG and ZPG. It is essential to design ML
algorithms to handle this skewness, else it treats the underrepresented cases as outliers and the model predictions suffer. A common practice to balance out skewed databases is to identify similarity clusters and assign the respective weights. One of the widely used methods involves clustering based on the Euclidean distance, \(d=\sqrt{\sum_{i=1}^{n}(P_{i}-Q_{i})^{2}}\) between two vectors (say \(\overline{P}\) and \(\overline{Q}\)) which represent the independent flow parameters listed in Eq. 3.
In the current study, we demonstrate the similarity by comparing the trends of \(\widetilde{\Phi}_{pp}\) vs \(\widetilde{\omega}\) across datasets. A typical WPS, shown in Fig. 3, comprises three distinct regimes: a low-frequency region where \(\widetilde{\Phi}_{pp}\) rises monotonically with \(\widetilde{\omega}\) to reach its peak value, an inertial subrange at mid-frequencies (typically noticeable at high Reynolds numbers) and a \(\widetilde{\omega}^{-5}\) roll-off at higher frequencies due to dissipation. However, not all the datasets in Fig. 2 show this exact trend. The range of frequencies encompassing each of the regimes also differs across datasets. Hence, the following slope vector \(\overline{m}\) is extracted for each dataset of length \(n\):
\[m_{i}=\frac{\widetilde{\Phi}_{pp,i+1}(dB)-\widetilde{\Phi}_{pp,i}(dB)}{ \widetilde{\omega}_{i+1}-\widetilde{\omega}_{i}},i=[1,n-1] \tag{7}\]
It should be noted that the raw WPS dataset is noisy and hence should be smoothed out to extract meaningful trends. The present work used the predictions of an ANN model for the same. Since all datasets have an equal number of points, \(\overline{m}\) also captures the extent of respective regimes. We can now compute the cosine similarity, which results in a value between [-1,1], to quantify the closeness between two slope vectors as follows:
\[CS=cos(\overline{m}_{i},\overline{m}_{j})=\frac{\overline{m}_{i}\cdot\overline {m}_{j}}{||\overline{m}_{i}||\times||\overline{m}_{j}||},(i,j)=[1,117] \tag{8}\]
In a 3D space, \(CS=1\) represents similar vectors, \(CS=0\) indicates orthogonal vectors and \(CS=-1\) represents vectors pointing in opposite directions. In a multidimensional space such as ours, cosine similarity is merely representative of how similar trends are to each other; from identical to very dissimilar respectively. Figure 4 plots the heatmap of the resulting cosine similarity matrix. \(CS\approx 1\) within the boxes aligned along the diagonal indicate that the trends within a given experiment are similar. Bands of \(CS\approx 1\) (highlighted using solid arrows) represent similar WPS trends observed across the experiments with different flow conditions. In contrast, bands of \(CS\approx-1\) (highlighted using dashed arrows) represent dissimilar trends. For example, the inset plots in Fig. 4 illustrate the similarity of WPS extracted at points A, B, and C. It is apparent that the WPS at B and A are similar with a \(CS\approx 0.92\) while the WPS at C is dissimilar to that of A with a \(CS\approx-0.54\). This similarity matrix helps in identifying clusters that can be used to assign weights to the datasets and potentially improve model predictions. This aspect is further discussed in Section IV.2.
### Artificial neural networks
Artificial neural network (ANNs) is a powerful function approximator that is commonly used to fit non-linear data using supervised learning. A brief description of ANN is given here and readers can refer to the works of Goodfellow _et al._[43] for further details. Figure 5 illustrates a typical ANN architecture comprising an input layer (which can be normalized for improved scaling of data), several hidden layers (to accurately
Figure 3: Low and high-frequency trends in TBL wall pressure spectrum, black dashed lines as eye guides
Figure 2: Wall pressure spectra collected by the von Karman Institute(VKI) team rescaled to Goody’s scales
capture the complexity of the non-linear function that fits the data), and an output layer. The hidden layers consist of neurons. Each neuron generates a weighted sum \(\Sigma\) from its inputs (\(\overline{w}\cdot\overline{x}\)) with respective biases \(b\). A predefined activation function (\(\sigma\), usually a non-linear function) operates on this weighted sum \(\Sigma\) to produce an output \(y\). The bias is a constant value that is added to the weighted sum of the inputs to shift the activation function. It is mathematically expressed as \(y=\sigma\Sigma=\sigma(\overline{w}\cdot\overline{x}+b)\). The error between the expected output and the prediction is minimized by computing the gradient of the objective function with respect to the weights and biases of each neuron through backpropagation [44]. This helps in adjusting the weights and biases of the individual neurons, resulting in a potentially improved model.
The current study considers the data used by the VKI team and hence the optimal hyperparameters from their study have been used to build the ANN model. The neural network has three hidden layers of ten neurons each in a fully-connected feed-forward fashion. These hidden layers are preceded by a normalization layer. In this layer, the input vector \(\overline{x}=[\widehat{\mathbf{\omega}},\Delta,H,Ma,\Pi,C_{f},R_{T},\beta]\) from Eq. 4 is normalized using the mean and standard deviation of each feature to accelerate the learning process [45]. The output layer of the model is made up of a single neuron that predicts the value, \(y=10log_{10}(\Phi_{pp}U_{e}/\tau_{w}^{2}\delta)\). The training is carried out using
Figure 4: Cosine similarity matrix of WPS trends observed in collected datasets. Christophe:1-78, Salze:79-88, Deuse: 89-101: Hao: 102-117
Figure 5: Example of an Artificial neural network build
Nadam optimizer [46] and Selu activation function [47] at a learning rate of 0.0001 with a batch size of 32 randomly chosen samples. The dataset is randomly split into training data and validation data with an 80:20 split respectively. Logarithmic mean squared error (_IMSE_), defined in Eq. 9, is used as the objective function. Training of the ANN is driven by the training loss while the early stopping is identified by monitoring the validation loss.
\[\textit{IMSE}=\frac{1}{N}\sum_{i=1}^{N}W_{i}(10log_{10}(y_{i}^{ expected})-10log_{10}(y_{i}^{predicted}))^{2} \tag{9}\]
### Gene expression programming (GEP)
Like a genetic algorithm GEP discovers mathematical expressions to best represent a dataset. We present a brief summary of the method here and the readers can refer to the article by Candida F. [48] for a detailed discussion on GEP. Figure 6 and Table 1 illustrate the mainstream GEP algorithm, the entities, and the operations involved. The algorithm starts with constructing several fixed-length strings called genes using combinations of the functions and terminals. Part of such a gene (ORF) is interpreted as an expression tree (ET) which is a graphical representation of a mathematical expression. Chromosomes (strings with multiple genes) with linking functions are used to improve upon the complexity captured by the mathematical expression derived from a single gene. The fitness of these chromosomes is then evaluated based on their ability to match the predictions of a given dataset. Chromosomes with desired fitness are retained, reproduced, and modified through genetic operators to result in different expressions altogether. Well-performing combinations are thus retained and mutated over multiple generations until the one with desired fitness is discovered.
\begin{table}
\begin{tabular}{l|c}
**Term** & **Description** \\ \hline Functional set (F) & Set of operators that a GEP inferred mathematical expression can be built out of. \\ \hline Terminal set (T) & Set of variables that a GEP inferred mathematical expression can be built out of. \\ \hline Gene & Fixed length string that is a combination of members from the functional and the terminal set. \\ \hline Head & Part of the gene that is a combination of entities from the functional set and the terminal set. \\ \hline Tail & Part of the gene made exclusively out of the terminal set to ensure that enough terminals are available to result in a valid mathematical expression. \\ \hline Open reading frame (ORF) & Part of the gene that can be read into an expression tree. \\ \hline Expression tree (ET) & Plane tree structure with each node as a member of the functional set and each leaf as a member of the terminal set that can be read into a mathematical expression. \\ \hline Chromosome/Individual & Fixed length string that consists multiple genes. \\ \hline Sub Expression Tree (Sub - ET) & Expression tree that is derived from a gene present in a chromosome. \\ \hline Prescribed Linking function & Function prescribed at the start of GEP training that combines Sub - ETs to produce the final mathematical expression from a chromosome. \\ \hline Fitness & Performance of GEP individuals quantified through objective functions. \\ \hline Selection & Process of selecting parents for the next generation from a pool of individuals while discarding the rest. \\ \hline Reproduction & Process of filling up the population back to its original volume by deriving daughters from parent individuals. \\ \hline Genetic operators & Operators that genetically modify chromosomes. \\ \hline Evolution & Process of performing selection and reproduction on a population while retaining the desired genetic characteristics identified through fitness. \\ \hline Generation & Pool of individuals that undergoes fitness evaluation at any point of time through GEP evolution. \\ \hline \end{tabular}
\end{table}
Table 1: GEP Terminology
Figure 6: (a) GEP algorithm flowchart with least-square based local optimization. (b) Entities involved in GEP
\[Fit=100\times\sqrt{\alpha\frac{lMSE}{A_{log}^{2}}+(1-\alpha)\frac{MSE}{A_{lin}^{2}}} \tag{10}\]
where,
\[MSE=\frac{1}{N}\sum_{i=1}^{N}W_{i}(y_{i}^{expected}-y_{i}^{predicted})^{2} \tag{11}\]
Here, \(A_{log}\) and \(A_{lin}\) represent the maximum amplitude of training points in the respective scales. \(\alpha\) is a weight assigned to the objectives, which is set to 0.5 thus giving equal weight to both contributions. The idea to have such a multi-objective function is derived from the works of Dominique _et al._[39]. They postulated that while the _MSE_ penalizes the error in the amplitude of the spectrum, the _lMSE_ captures error in the trends at low and high frequencies effectively.
A set of experiments were conducted for 100 individuals of different head lengths [3, 4, 5, 6], over 1001 generations, and with optimization probability 0.005 (every generation is being optimized, but very few individuals are optimized in each generation). Figure 8 plots the errors in exponent predictions (which is defined as \(|Exponent_{expected}-Exponent_{observed}|\)) with \(Fit\). It is evident that the \(R_{T}\) and high-frequency errors tend to drop with a decrease in \(Fit\), implying a closer agreement with Goody's model. In almost all the cases, \(R_{T}\) error
Figure 8: Exponent error observed in GEP solution while predicting the Goody’s model
Figure 7: Training dataset for hyperparameter study of GEP (a) With added noise (b) Without any noise along with a typical GEP solution observed at h = 4, 10001 generations and, \(P_{opt}=0.1\)
has dropped below 0.5 for _Fit_\(<\) 5 and below 1.0 for _Fit_\(<\) 6. Similar behavior is observed for high-frequency error where the error drops below 1 for _Fit_\(<\) 6. However, it is evident that the low frequency \(\tilde{\omega}^{2}\) errors are quite unpredictable, although the errors are \(\leq\) 1.0 for all the cases. This unpredictable behavior is attributed to the high noise at low frequencies, a feature of input data that is observable in Fig. 7 (a). As pointed out by the Dominique _et al_[39], _Fit_ by definition is a cumulative error criterion. Hence, a lower value of _Fit_ for a solution does not guarantee the local closeness to the parent function (Goody's model) in small individual subdomains.
The value of _Fit_ with the noisy data reported in Fig. 8 is \(\approx\)\(\geq\) 4. Subsequent studies were hence carried out with clean data (see Fig. 7 (b)) to determine if the GEP predictions improved. Figure 9 (a), shows a scatter plot with varying radius and color to demonstrate the effect of hyperparameter setup (head length, local optimization probability, generations) on the model performance (\(log(Fit)\)). Here, the color and radius of the circle represent the \(log(Fit)\) and the number of generations evolved in each trial respectively. Following are the key inferences that can be drawn from the figure:
* As expected, improved values of _Fit_ (below 1.0) can be achieved with clean data when compared to noisy data.
* _Fit_ drops with increasing head length, although with larger head lengths there is a risk of making the model too complex. Note that the _Fit_ values were still higher with increasing head lengths (up to 10) with 1001 generations (not shown in the plot). However, with further optimization, _Fit_ is observed to drop below 1 for h = 10 and 3001 generations (refer to marker A in Figure 9 (a)). This is because a higher number of generations allow for more mutations, thereby improving the _Fit_. Decreasing the head length also demands a larger number of generations which translates to more time spent in model evolution. Local optimization can circumvent this issue by minimizing the divergence within the population generated by the added power feature using the local least squares optimizer discussed in Section III.4.
* Increasing the local optimization probability improves the _Fit_ even at lower head lengths with less number of generations. Nevertheless, this considerably increases the time per generation as illustrated in Fig. 9 (b). Figure 9 (a) shows that increasing the optimization probability from 0.005 to 0.1 drops _Fit_ below 1 for a head length of 4 trained over 10001 generations (refer to marker B in Figure 9 (a)). The fact that a solution at the complexity of h = 4 produced comparable predictions to the ones observed for h = 10 shows the potential of the local optimizer. Further increasing the optimization probability to 1, dropped the required number of generations to 1001 resulting in a _Fit_ below 1, (refer to marker C in Figure 9 (a)).
* Higher number of generations results in a lower _Fit_ even at lower head lengths and optimization probabilities (refer to marker B in Figure 9 (a)).
All these insights lead to the conclusion that a user should prioritize mutations by evolving GEP over a greater number of generations. The subsequent diverging behavior due to mutations, if any, can be controlled with increased use of the local optimization loop. If both these solutions are ineffective, the user can consider increasing the head length as the GEP expressions with a smaller head length may not be complex enough to capture the features of the data. Figure 9 (c), shows the encouraging trend that the proposed setup that reduces the _Fit_ error also reduces the low frequency \(\tilde{\omega}^{2}\) error which was found to be unpredictable earlier. Figure 7 (b) illustrates the typical curve fit obtained with GEP (with \(h=4\), \(P_{opt}=0.05\) and 10000 generations) where the _Fit_ drops below 1.
Due to its unsupervised evolutionary nature, GEP can produce ill-performing solutions and there is always a possibility
Figure 9: (a) _Fit_ (log(_Fit_) as colorbar) as a function of head length (x-axis), local optimization probability (y-axis), and number of generations (area of circle). (b) Effect of optimization probability on the computational time required to run the algorithm through 200 generations for h = 4 (c) Predictable drop observed in low-frequency error at low _Fit_ values
of the algorithm not converging to the desired accuracy. The aforementioned hyperparameter tuning strategies aim to minimize such issues with convergence. As will be demonstrated in Section V, unlike ANN, data of reasonable quality (with minimal noise and outliers) should also be provided to ensure convergence of GEP.
### Weights and Objective functions
It is established in Section III that the database used in this study derives from different experiments with their own set of flow conditions. Table 2 consolidates different experiments and the corresponding number of datasets, \(N\). It is worth noting that the datasets collected within the same experiment can be mutually similar and differ greatly from those of other experiments which have different flow conditions. If every dataset is given equal weight/importance in the overall objective function, the model will be biased towards the over-represented data (for example, the data from Christophe). The rest of the minority datasets have little effect on the direction of the solution and suffer from poor model predictions even if the datasets are just as important [49]. One way to mitigate this problem is through weighting datasets to balance the objective function. The selection of weights is a user decision and an optimization problem in itself which is beyond the scope of this work. To illustrate the effect of a weighted objective function on the ANN and GEP predictions, a rather simple weighting strategy is considered where the weight is estimated as the ratio of the number of datasets in the least represented experiments (the data from Salze) to the experiment considered i.e. \(W=N_{Salze}/N_{Experiment}\). The weights assigned this way are listed in Table 2.
Both GEP and ANN were trained on the same input data with weighted and unweighted objective functions. Technically training can be done indefinitely and the loss calculated by the objective function may continue to drop till it reaches a minimum. However, after a steep drop of the \(lMSE\), Fig. 10 shows a marginal improvement in an ANN model performance with a further increase in epochs. For practical purposes, an early stopping criterion is therefore used to halt the training process. This can be done in a number of ways, say by setting an upper bound on epochs or by setting a lower bound on the loss calculated by the objective function. Here for this test, 20% of the randomly sampled training data is set aside as validation data. The calculated loss against validation data was then monitored and training was stopped if there is no improvement for at least 20 epochs, followed by restoring ANN weights (not to be confused with database weights) to the ones observed for the epoch with the least validation loss. Figure 10 also shows that the rate of accuracy gain (indicated by the rate of drop of error reported as weighted \(lMSE\)) is higher for the ANN models trained with \(lMSE\) as the objective function than the ones trained with \(Fit\).
The effect of different objective functions (\(lMSE\) and \(Fit\)) on the predictions of wall pressure spectra (\(\Phi_{pp}\)) using ANN is illustrated in Fig. 11 (a-d). It is observed that the predictions of ANN models trained with weighted/unweighted \(lMSE\) as the objective function are more accurate than the models trained with weighted/unweighted \(Fit\). Hence, we use \(lMSE\) as the objective function for the rest of the study unless otherwise mentioned. Since GEP predicts a different mathematical expression every run, 10 trials with 100 individuals each, having a head length = 4, and optimization probability 0.05 were evolved over 5000 generations with weighted/unweighted \(lMSE\) as the objective function. Figures 11 (e) and (f) plot the Predicted vs True values of PSD (\(\Phi_{pp}\)) obtained from the corresponding best-performing expressions which are listed below:
Weighted:
\[\widetilde{\Phi}_{pp}=\frac{0.46\widetilde{\omega}^{0.99}(\beta+1)^{1.5}}{ \frac{R_{T}^{0.55}\widetilde{\omega}^{1.02}}{\Pi^{2.76}+\Delta}+M\Delta^{6.75} \left(\frac{R_{T}+\widetilde{\omega}^{5.07}}{R_{T}^{5.84}}\right)} \tag{12}\]
and Unweighted:
\[\widetilde{\Phi}_{pp}=\frac{\widetilde{\omega}\left(\Pi^{6.71}+(\beta+1)^{1.4 }\right)}{\widetilde{\omega}^{0.87}\Delta^{0.98}M^{0.44}(1+M^{0.97})+\frac{ \widetilde{\omega}^{5.31}}{R_{T}^{7.07}}(\Pi^{5.31}+\widetilde{\omega} \Delta^{6.09})} \tag{13}\]
Interestingly, Fig. 11 shows that ANN and GEP models trained with unweighted objective functions resulted in
\begin{table}
\begin{tabular}{l l l} Experiment & N(Datasets) & Weight \\ \hline Salze & 10 & 1.00 \\ \hline Deuse & 13 & 0.77 \\ \hline Hao & 16 & 0.62 \\ \hline Christophe & 78 & 0.13 \\ \hline Total & 117 \\ \end{tabular}
\end{table}
Table 2: Weights assigned to different experiments
Figure 10: Example of the evolution of model performance in ANN training with (a) weighted \(lMSE\) and (b) weighted \(Fit\) as objective functions respectively.
Figure 11: Predictions of ANN model trained with weighted (a) and unweighted (b) _IMSE_ as the objective function; weighted (c) and unweighted (d) _Fit_ as the objective function. Predictions of GEP models, Eq. 12 and Eq. 13, trained with weighted, (e), and unweighted _IMSE_, (f), respectively as the objective functions. (Every tenth point is reported for plotting purposes)
Figure 12: Salze dataset predictions suffering (a) and (c); Hao dataset predictions improving (b) and (d), from unweighted ANN training. Salze dataset predictions suffering (e), and Christophe dataset predictions improving (f) from unweighted GEP training with \(IMSE\) as the objective function
a lower _lMSE_ error than those with the weighted ones. Although this is an unexpected trend, Table 3 delves into the performance of the models with weighted objective functions on the minority datasets. As intended, the prediction of datasets in the minority experiment (Salze) has indeed improved with weighted objective functions. In contrast, the accuracy of the datasets from a majority experiment (Christophe) has suffered due to the choice of weights. Figure 12 plots the wall pressure spectra of the majority and minority datasets to further demonstrate the effect of weighted/unweighted objective functions across different training schemes. The results show that the weighted objective functions significantly improve predictions of minority datasets (Salze). This trend is particularly observed for poorly converging training methods such as ANN with _Fit_ or the GEP. While the prediction accuracy of the dominant datasets (Christophe and Hao) decreases with the weighted training schemes, the spectra are not far off. On the other hand, unweighted schemes are observed to overfit the dominant datasets retaining their features and deteriorating the accuracy of the minority dataset predictions (refer to the predictions of inertial subrange in Fig 12(c) and (d)). These effects, however, become less pronounced in the case of an aggressively converging training scheme such as ANN with _lMSE_ where both the weighted/unweighted datasets result in competitive predictions.
The aforementioned discussion highlights the importance of optimizing the weights assigned to skewed datasets which will (a) minimize any bias in the predictions of ML models and (b) improve the performance of poorly converging models as it allows the training algorithm to focus more on minority datasets.
### ANN vs GEP
The present section compares the computational efficacy of GEP and ANN in predicting the wall pressure spectra. Both the algorithms are trained against the same input data and with the same objective function (weighted _lMSE_, Eq. 9). The trials are conducted on a machine equipped with a dual node Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz, with 14 cores, and an Nvidia Tesla V100 32GB GPU.
Figure 13 (a) compares the convergence of ANN and GEP models with time. It is evident that the ANN achieves superior results in a shorter duration. This is in contrast to GEP which struggles to converge to the _lMSE_ achieved by ANN even after a significantly longer training. With GEP, the best-fitting model from a pool may or may not improve over the generations thereby resulting in a'stepwise' drop in _lMSE_. The mechanism for evolving a best-fitting model in GEP is mutation and the other genetic operators, but they do not necessarily result in a better model and are therefore considered diverging in nature. As a result, the next best-fitting model can appear anytime through evolution. While there are ways to control the divergence induced by mutation, such as balancing it out with aggressive selection or using a local optimization function, in general, the'stepped' convergence still follows.
Figure 13 (b) compares the virtual memory consumption with the present implementation of both algorithms. Space consumption of GEP is dependent on the size of the population, the length of each chromosome (which are basically fixed-length strings) and, additional storage required for performing actions such as evaluation, selection and, mutation. All these operations are inexpensive when compared to the ANN training. Although the memory occupied by the trainable parameters in ANN is minimal, the training process itself involves supervised learning that requires storage of gradients, and other intermediate computations that are memory intensive. Parallel computing using GPUs does help out in reducing this requirement by allowing for larger batch sizes that reduce the required number of forward and backward passes.
Figures 14 (a) and (b) compare the training time required with a reduced data resolution. As expected, both algorithms require less training time when trained against the same input data that has a lower resolution. With ANN, five trials were conducted to account for variation in the reported training time and one can observe a monotonic drop in training time with coarser input data. This is much easier to establish in the case of ANN models since they all converge aggressively resulting in competitive fits (see Fig. 14 (c)). Performing a similar analysis with GEP involves some practical complications. Different trials of the GEP algorithm require different runtimes to arrive at models with similar performance. It highlights the need to stop GEP training after a predefined number of generations although the models obtained this way can have different performances. Figure 14 (b) reports the _lMSE_ values from the 10 trials for each resolution of the sampled data. The plot shows that cases with coarser data input, in general, require less time for training and can still result in competitive predictions. To summarize, it seems beneficial to train models (specifically GEP) with coarsely sampled data, although ensuring that the local features of the data are not
\begin{table}
\begin{tabular}{l l|l l l|l l l} \hline \hline \multirow{2}{*}{Experiment} & N & \multirow{2}{*}{Weight} & \multicolumn{2}{l|}{ANN (_lMSE_ error)} & \multicolumn{2}{l}{GEP (_lMSE_ error)} & \multicolumn{1}{l}{\multirow{2}{*}{\%}} \\ \cline{4-4} \cline{6-7} & & _lMSE_ & _lMSE_ & & _lMSE_ & _lMSE_ & _lMSE_ & _lMSE_ \\ & & & (weighted) & (unweighted) & & w.r.t & (weighted) & (unweighted) & \\ & & & training & & weighted & training & training & w.r.t \\ \hline Salze & 10 & 1.00 & 0.24 & 0.33 & +37.50 & 6.98 & 9.43 & +35.10 \\ \hline Christophe & 78 & 0.13 & 0.39 & 0.23 & -41.03 & 7.41 & 3.81 & -48.58 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of _lMSE_s in predictions across experiments
lost in the re-sampling process.
## V Guided search in gene expression programming
GEP and ANN algorithms update the model parameters through every epoch to accurately fit the data. The superior performance of ANN (in terms of speed and reliability) is attributed to training algorithms like stochastic gradient descent that guide the direction in which the ANN model parameters should be updated. On the other hand, GEP updates the models through genetic operators which rely on the evolutionary approach of trial and error. Although this approach allows for a diverse search space, it is computationally expensive. Oftentimes, with some of the known dependencies, the search space can be reduced resulting in faster convergence. This guided search approach also facilitates the discovery of complex trends in the rest of the search space. The following subsections demonstrate several guided search strategies that have been explored to accelerate GEP training and reliability.
### GEP Training Schemes
In contrast to the baseline scheme that uses the raw data, the current section introduces three additional schemes: Noise reduction with ANN filter, Omega2, and Gene4, to accelerate the GEP training.
#### Raw data scheme
This is a baseline GEP training scheme that uses the default noisy raw data and the linking function, Eq. 15, to train the GEP population.
Figure 14: Lower training times achieved with low-resolution training data - (a) ANN, (b) GEP. (c) Effect of low-resolution training data on ANN predictions for datasets with complex trends
Figure 13: (a) Model performance evolution through time, and (b) the RAM and VRAM used by the ANN and GEP models while training
#### Noise reduction with ANN filter
Noisy input datasets can misguide GEP towards sub-optimal solutions where the resulting model fails to recognize the underlying trend. The absence of feedback in mutations increases the training time required for the GEP model to converge to a global optimum. Smoothing techniques, such as kernel smoothing or moving averages, can be used to reduce the noise although these might suffer from issues like uneven noise filtering and might filter important uncertainties in parts of the data. On the other hand, Artificial neural networks are well known for their ability to handle the trade-offs between retaining information and filtering noise. Sections IV.2 and IV.3 have also demonstrated their ability to produce well-performing models of WPS with reasonable training times. Hence, we explore the strategy of ANN-filtered input data to assist the GEP algorithm.
#### Omega2 Scheme
The canonical shape of the WPS remains more or less the same across TBLs and hence a good guess of the frequency dependence of PSD in the respective regimes can be made. For example, one of the popular WPS models by Goody has three parts A, B, and C:
\[\widetilde{\Phi}_{pp}=\frac{C_{2}\widetilde{\omega}^{2}}{\left(\widetilde{ \omega}^{0.75}+C_{1}\right)^{3.7}+\left(C_{3}\widetilde{\omega}\right)^{7}}= \frac{A}{B+C} \tag{14}\]
Where,
\[C_{1}=0.5;\,C_{2}=3.0;\,C_{3}=1.1R_{T}^{-0.57}\]
The numerator \(A\) dominates at low frequencies (\(\widetilde{\omega}\to 0\)), resulting in the \(\widetilde{\omega}^{2}\) trend, which is particularly valid under zero pressure gradients (ZPG) [27]. The exponent of \(\widetilde{\omega}\), however, changes with pressure gradients as observed in Figures 2 and 3. For example, WPS of a TBL subjected to APG exhibits a \(\approx\widetilde{\omega}^{0.5}\) rise at low frequencies (see Fig. 3 from experiments of Salze _et al._[14]). While both \(B\) and \(C\) in Eq. 14 dictate the mid-frequencies, the term \(C\) governs trends at higher frequencies. Goody's model exhibits a \(\widetilde{\omega}^{-5}\) trend at higher frequencies which is consistent with those observed in Fig. 3. Unlike the other contemporary models in literature [35], Goody's model is stiff and reasonably retains its shape over a range of flow conditions.
As discussed above, the shortcomings of Goody's model which only depends on \(R_{T}\) (in addition to \(\widetilde{\omega}\)) are apparent under pressure gradients and non-canonical flows. GEP algorithm is effective in seeking additional contributing variables and accelerates the development of semi-empirical models like Goody. To assist GEP search with the inherent nonlinearity of the WPS problem, Dominique _et al._[39] prescribed the following trigenic linking function, Eq. 15 which is analogous to Goody's model:
\[Y^{GEP}=\frac{Sub-ET_{1}}{Sub-ET_{2}+Sub-ET_{3}} \tag{15}\]
Where \(Sub-ET_{i}\) represents a sub-expression interpreted from a gene in the chromosome and \(Y^{GEP}\) represents the output model.
GEP still has a tough task of working out the correct combination, especially the strong dependence on frequency (\(\widetilde{\omega}\)) across different regimes. Since the WPS at low frequencies follows a \(\widetilde{\omega}^{2}\) trend for ZPG flows, we explore the benefit of premultiplying Eq. 15 with \(\widetilde{\omega}^{2}\) to build that dependency right into the solution. The scheme further uses assistance from ANN-filtered data (modified inputs) for improved predictions. Hereafter, this strategy will be referred to as the _Omega2 scheme_ which is implemented by modifying the objective function as follows:
\[\mathit{IMSE}=\frac{1}{N}\sum_{i=1}^{N}W_{i}\left(10log_{10}\left(\widetilde{ \omega}_{i}^{2}Y_{i}^{GEP}\right)-10log_{10}Y_{i}^{true}\right)^{2} \tag{16}\]
The proposed modification facilitates the algorithm to focus on finding a better combination \(Sub-ET_{1}\) using any of the variables (\(\widetilde{\omega},\Delta,H,M,\Pi,C_{f},R_{T},\beta\) ). Table 4 lists some of the sample models obtained using the Omega2 scheme. Interestingly, for the datasets where the low-frequency trend deviates from the \(\widetilde{\omega}^{2}\) dependence, GEP is observed to predict a \(Sub-ET_{1}\) with \(\widetilde{\omega}^{i}\) (i being some index) to accurately fit the low frequencies.
#### Gene4 Scheme
Extending the omega2 approach, the _Gene4 scheme_ is aimed at further incorporating the trends at high-frequencies into the GEP models. This is achieved by modifying the original linking function in Eq. 15 with (a) an \(\widetilde{\omega}^{2}\) term in the numerator (to predict lower frequencies), (b) a \(\widetilde{\omega}^{7}\) in the denominator (to predict higher frequencies) and (c) a timescale ratio dependency \(R_{T}^{4}\) from Goody's model, a dependency also observed in other contemporary empirical models, to further assist the search. The gene4 linking function is realized using four genes as formulated below:
\[Y^{GEP}_{gene4}=\frac{\widetilde{\omega}^{2}Sub-ET_{1}+Sub-ET_{2}}{\frac{ \widetilde{\omega}^{7}}{R_{T}^{4}}Sub-ET_{3}+Sub-ET_{4}} \tag{17}\]
We have used two \(Sub-ET\)s in the numerator with only \(Sub-ET_{1}\) being pre-multiplied with \(\widetilde{\omega}^{2}\). \(Sub-ET_{2}\) allows for searching the terms that are decoupled from the \(\widetilde{\omega}^{2}\) dependence and facilitates a faster convergence than the omega2 scheme (as the algorithm does not have to look for a complex division to eliminate the effect of pre-multiplication). Table 4 lists some of the competitive models predicted using the gene4 scheme. It is interesting to note that the \(Sub-ET_{2}\) term in models 1 and 2 is independent of \(\widetilde{\omega}^{2}\) while that in model 3 is closer to \(\widetilde{\omega}^{2}\).
### Comparisons
In this section, we compare the performance of the aforementioned schemes in terms of (a) convergence rate during training and (b) model accuracy at the end of GEP evolution. For each of the four schemes, 10 trials were conducted on a pool of 100 individuals, with a head length (\(h\)) of 4 trained over 20000 generations. The input data is resampled to 25% of the original resolution and for every iteration, the population passed through the least squares optimization loop with an optimization probability of \(P_{opt}=0.05\). We probe into the temporal evolution of the training statistics with weighted _IMSE_ as the objective function.
For different training schemes, Fig. 15 (a-e) compares the temporal evolution of the resampled training statistics (see Appendix A) from the 10 trials using _IMSE_ as the objective
\begin{table}
\begin{tabular}{l l l l l} Model & \(\dfrac{\widehat{\omega}^{2}Sub-ET_{I}+Sub-ET_{2}}{\dfrac{\widehat{\omega}^{7} }{R_{T}^{T}}Sub-ET_{3}+Sub-ET_{4}}\) & _IMSE_ & \(\widehat{\omega}\to 0\) & \(\widehat{\omega}\rightarrow\infty\) \\ model1 & \(\dfrac{\widehat{\omega}^{2}\left(\dfrac{\beta^{2.45}\Pi^{5.13}}{R_{T}^{1.22}} +\dfrac{0.015}{M}\right)+\left(\dfrac{C_{f}}{M^{2.08}}+\beta^{2.84}\right) \left(\dfrac{R_{T}}{M^{0.14}}\right)}{\dfrac{\widehat{\omega}^{7}\left( \dfrac{\Delta^{2.89}H^{7.62}}{R_{T}\omega^{1.12}}\right)+\left(R_{T}^{1.29}+ \Delta^{2.03}\right)\left(M^{0.34}+\beta\right)}}\) & 10.41 & 2 & -3.88 \\ model2 & \(\dfrac{\widehat{\omega}^{2}\left(\dfrac{\Pi^{0.74}+\widehat{\omega}^{0.65}}{ \Delta^{5.02}}\right)\left(0.1R_{T}^{1.27}\right)+\left(M^{-1}\Delta^{-1}+ \beta^{1.21}\right)}{\dfrac{\widehat{\omega}^{7}}{R_{T}^{1}}14.2M^{2.96}\left( M^{1.24}+1\right)+\widehat{\omega}+5.2\widehat{\omega}^{-0.35}}\) & 10.95 & 3 & -4.35 \\ model3 & \(\dfrac{\widehat{\omega}^{2}\left(\dfrac{\beta^{2.43}\left(\Delta+\Pi\right)}{ H\Delta^{1.15}}\right)+\dfrac{\omega^{2.64}}{M\left(R_{T}+\Pi^{0.06}\right)}}{ \dfrac{\widehat{\omega}^{7}\left(\dfrac{M\Delta^{6.79}}{R_{T}^{2.39}}\right)+ \widehat{\omega}^{1.55}\left(H+\widehat{\omega}^{0.94}\right)}}\) & 12.23 & 2.64 & -4.36 \\ \end{tabular}
\end{table}
Table 5: Sample WPS models generated using gene4 scheme
\begin{table}
\begin{tabular}{l l l l l} Model & \(\widetilde{\omega}^{2}\cdot Y^{GEP}\) & _IMSE_ & \(\widetilde{\omega}\to 0\) & \(\widetilde{\omega}\rightarrow\infty\) \\ model1 & \(\widetilde{\omega}^{2}\cdot\dfrac{\widetilde{\omega}^{-1.86}\beta^{1.34}M^{-0. 55}\Delta^{-0.78}\left(R_{T}+1\right)}{\widetilde{\omega}^{1.77}+R_{T}H^{1.86}+ \widetilde{\omega}^{6.60}\left(\dfrac{\Delta}{R_{T}}\right)^{6.18}}\) & 10.61 & 0.14 & -6.46 \\ model2 & \(\widetilde{\omega}^{2}\cdot\dfrac{\widetilde{\omega}^{-2}\beta^{1.42}\left( \Pi^{3.57}\widetilde{\omega}^{0.58}+R_{T}^{1.02}\right)}{\Delta\left( \widetilde{\omega}^{5.53}\dfrac{\Delta^{5.59}}{R_{T}^{6}}+R_{T}M^{0.37}\right)}\) & 11.17 & 0.58 & -4.95 \\ model3 & \(\widetilde{\omega}^{2}\cdot\dfrac{\widetilde{\omega}^{-1.7}\beta^{1.72}M^{-0.72}}{ \widetilde{\omega}^{1.99}+\Delta\left(\dfrac{\widetilde{\omega}^{4.98}H^{8.81} }{R_{T}^{4.28}+\beta^{5.63}}+1\right)}\) & 13.67 & 0.3 & -4.68 \\ \end{tabular}
\end{table}
Table 4: Sample WPS models generated using omega2 scheme
Figure 15: Comparison of fitness distribution of the best individuals across 10 trials with \(IMSE\) as the objective function for different schemes. Evolution of following statistics: (a) \(<y>_{E}\), (b) \(median(y)\), (c) \(y_{25-75}\) (d) \(y_{max}\) (e) \(y_{min}\), of GEP trials are plotted against time. (f) Box plot comparing unweighted \(IMSE\) for the last generation, showing the scatter in \(IMSE\) from minimum to maximum across the trials. The blue box represents the trials with \(IMSE\) between the \(25-75\) percentile and the intermediate line shows the median value.)
function. These metrics include \(<y>_{E}\), \(median(y)\), \(y_{25-75}\), \(y_{max}\), and \(y_{min}\) which are briefly described in Table 6. For every trial, the best-performing model at the end of the training is recorded. Figure 15 (f) compares the _IMSE_ distributions of these best models across different schemes. Table 7 provides a quantitative overview of the relative performance of these schemes with respect to the baseline scheme, probed every 5 hours into the training period. The following inferences can be drawn from the statistics presented in Fig. 15 and Table 7:
* The gene4 scheme predicts more accurate models than other schemes throughout the evolution. When compared to the baseline scheme, Table 7 shows the superior performance of gene4 with a consistent drop of \(\approx\) 25% in its ensemble averaged _IMSE_ and \(\approx\) 20% drop in its median _IMSE_. A \(\geq\approx\) 60% drop of _IMSE_ within the interquartile range, \(y_{25-75}\) with the gene4 scheme suggests that the scheme predicts more competitive models at any instance throughout the evolution. Compared to the baseline scheme, the \(y_{max}\)_IMSE_ (worst-performing model) and \(y_{min}\)_IMSE_ (best-performing model) from the gene4 scheme trials exhibit a \(\geq\) 30% and \(\geq\) 15% lower value respectively. Trends in figure 15(a-e) also illustrate that the aforementioned improvements from the gene4 scheme are consistently observed throughout the evolution which implies that the gene4 scheme converges faster than the rest. Since the evolution of different training schemes can stop at different times, Figure 15(f) compares the _IMSE_ statistics of the last generation. Across trials, gene4 scheme has a best-performing model with \(\approx\) 30% drop in the \(y_{min}\)_IMSE_, a \(\approx\) 17% drop in the median _IMSE_ and a \(\approx\) 40% reduction in _IMSE_ within the interquartile range, \(y_{25-75}\) implying that gene4 scheme predicts more accurate models with improved reliability.
* Statistical improvements in _IMSE_ obtained using the ann-filter scheme are similar to those of the gene4 scheme albeit to a lesser extent.
* In contrast, the omega2 scheme yields either marginal or inconsistent gains over the raw data scheme throughout the training resulting in arguably worse-performing last-generation models (see Figure 15(f)). This indicates that multiplying the entire numerator (\(Sub-ET_{1}\) of Eq. 15) with \(\widetilde{\omega}^{2}\) has resulted in poorly optimized expressions. As seen in the case of model 2 in Table. 4, the algorithm has probably worked more towards decoupling the frequency terms.
Considering all the inferences, it can be concluded that the strategies involved in the development of the gene4 scheme (which include using ann-filtered input data, built-in low and high-frequency trends, and a modified linking function) are justified. Hence, the Gene4 scheme serves as a faster, and more accurate alternative to the baseline scheme while inferring models out of WPS data using the GEP algorithm.
### Validation
In this section, we evaluate the performance of the gene4 scheme on unseen data to ensure that the scheme predicts the mathematical expressions of appropriate complexity. Four datasets are discarded from each experiment from the complete database. Gene4 scheme was trained on the rest of the data with the same hyperparameter setup used in the previous section. One of the models within the interquartile range, \(y_{25-75}\), is presented below:
\[\widetilde{\Phi}pp=\frac{\widetilde{\omega}^{2}\left(\frac{\Pi^{8.05}}{\Delta }+0.22\beta^{1.54}\right)+0.69\beta^{2.66}+\Pi^{8.22}}{\frac{ \widetilde{\omega}^{7}}{R_{T}^{4}}(M^{4.07}(100(10+\Delta)))+(M^{0.44}(H^{5.81 }+\widetilde{\omega}^{2.37}))} \tag{18}\]
Equation 18 shows that the model retains the built-in frequency trends and incorporates additional complexities of the pressure gradient (\(\beta\)) and Mach number dependence. Figure 16 plots the corresponding predictions of the unseen datasets. It is evident from Figure 16(a-c) that the model presented surpasses the predictions of both Goody's model and Dominique's GEP model (which has been trained over the entire database). This ensures that the model does not overfit the data, which is in fact an encouraging step towards the development of a generalized WPS model that can reasonably predict unseen data. However, Fig. 16 (d) illustrates that, although the model performance is superior to that of Goody, there is scope to improve it further. For example, the appearance of coefficients such as 100 and 10 in this sample model shows that at times the GEP algorithm may struggle to find correct coefficients from the RNC array (Section III.4) resulting in a sub-optimal mathematical solution. However, the
\begin{table}
\begin{tabular}{l|r r r|r r r|r r r|r r r|r r r} \multirow{2}{*}{Scheme} & \multicolumn{10}{c}{Percentage _IMSE_ change w.r.t raw scheme} \\ \cline{2-13} & \multicolumn{4}{c|}{\(<y>_{E}\)} & \multicolumn{4}{c|}{\(median(y)\)} & \multicolumn{4}{c|}{\(y_{25-75}\)} & \multicolumn{4}{c|}{\(y_{max}\)} & \multicolumn{4}{c}{\(y_{min}\)} \\ \cline{2-13} & 5 hrs & 10 hrs & 15 hrs & 5 hrs & 10 hrs & 15 hrs & 5 hrs & 10 hrs & 15 hrs & 5 hrs & 10 hrs & 15 hrs & 5 hrs & 10 hrs & 15 hrs \\ \hline ann-filter & -10.4 & -14.4 & -15.8 & -18.5 & -19.0 & -13.8 & -57.6 & -49.0 & -58.6 & -2.7 & -18.8 & -24.4 & 5.4 & 4.9 & 4.6 \\ omega2 & 2.7 & -5.3 & -4.1 & -5.9 & -12.3 & -5.9 & -57.7 & -37.7 & -54.0 & 18.7 & -1.8 & -1.8 & 29.0 & -5.9 & -5.9 \\ gene4 & -27.6 & -27.0 & -26.1 & -29.5 & -25.3 & -19.2 & -76.0 & -52.2 & -59.4 & -33.9 & -36.1 & -39.4 & -14.9 & -19.7 & -24.4 \\ \end{tabular}
\end{table}
Table 7: Quantitative overview of the evolution of the relative performance of the proposed GEP training schemes with respect to the baseline raw data scheme. This relative performance is evaluated every five hours into the training phase.
same gene/\(Sub-ET_{3}\) does not hold a frequency term implying that the built-in trend by gene4 is valid, and with more mutations, GEP can find a superior alternative.
### Stepped schemes
We have further explored the strategy of stepped training schemes which is analogous to the idea of learning a language. One should learn the basic features of the language first, to understand the intricate constructions in the literature. Likewise learning the basic trends of the datasets that show a close resemblance to the canonical WPS is a priority. Once the GEP population learns to fit these priority datasets satisfactorily it is allowed to further improve the formulations by exposing it to a dataset that has similar canonical features with added complexities. In the present work, we train the GEP algorithm in two steps. In step 1, we prioritize exposing the population to Salze datasets which have the highest similarity to the canonical form of WPS. After the first step, the entire population, which also includes the best individual, was saved. In step 2,
Figure 16: Performance a sample GEP model trained with gene4 scheme on unseen datasets.
Figure 17: Box plot comparing unweighted \(IMSE\) for the last generation (\(40000^{th}\)), showing the scatter in \(IMSE\) from minimum to maximum across the trials. The blue box represents the trials with \(IMSE\) between the 25 - 75 percentile and the intermediate line shows the median value.
Figure 18: Dataset-wise predictions of a GEP model, Eq. 19, trained with the stepped training scheme and comparison with ANN predictions along with the predictions of Dominique’s GEP model and Goody’s model
the entire population saved in step 1 is exposed to the complete dataset for further training. For each step, the GEP algorithm was trained with the same hyperparameter environment detailed in Section V.2. Figure 17 shows the stepped gene4 scheme exhibiting superior accuracy and reliability over its non-stepped counterpart with \(\approx 10\%\) reduction in the median (from 12.2 to 10.9) and \(\approx 60\%\) drop in the \(lMSE\) spread of the interquartile range (from 3.0 to 1.1). Hence, it can be deduced that at least half of the models trained using the stepped gene4 scheme are competitive with each other. A sample model, with \(lMSE=10.61\) lying within the interquartile range, reads as follows:
\[\widetilde{\Phi}_{pp}=\frac{\widetilde{\omega}^{3.12}+\beta^{2.14}\widetilde{ \omega}^{2.41}+\left(\frac{C_{f}}{M^{4.42}\Delta^{2.34}}\right)\widetilde{ \omega}^{2}+\beta^{2.14}R_{T}^{0.29}}{\left(M^{3.2}\Delta^{6.35}+R_{T}\right) \frac{\widetilde{\omega}^{7.71}}{R_{T}^{5}}+\Delta^{0.9}(\widetilde{\omega}^{ 2.97}+H^{2})} \tag{19}\]
where the low and the high frequency exponent predictions are,
\[\widetilde{\omega}\to 0=\widetilde{\omega}^{3.12};\ \widetilde{\omega} \rightarrow\infty=\widetilde{\omega}^{-4.59}.\]
Figure 18 further compares the WPS predictions of the sample GEP model (Eq. 19) obtained using stepped gene4 scheme across different datasets. Its superior accuracy as compared to Goody's model and Dominique's GEP model is apparent.
Figure 19: Predictions of a GEP model, Eq. 19, trained with the stepped training scheme and comparison with ANN predictions along with the predictions of Dominique’s GEP model and Goody’s model. (Every tenth point is reported for plotting purposes)
In particular, Figures 18 (a,b,e) illustrate the high complexity captured by this model. Interestingly, its frequency trends and magnitude are in close agreement with those predicted by the ANN model. Figure 18 (c) assures that its predictions of the canonical WPS are unaffected and competitive with other models. Despite its superior performance, Fig. 18 (b), (d), and (f), show that the model fails to capture some local features and under or over-predicts the trends in certain datasets.
The scatter plot in Figure 19 compares the predicted vs true values for the entire dataset comprising different flow conditions (APG, FPG, and ZPG). The aforementioned GEP model trained with the stepped gene4 scheme significantly improved the predictions across the entire dataset resulting in a _IMSE_ of 10.6 in contrast to _IMSE_ of \(\approx 60\) with Dominique's GEP model and \(\approx 90\) with Goody's model. In particular, the scatter in the predictions of datasets with APG and FPG has considerably reduced when compared to Dominique's GEP model and Goody's model. Despite these improvements, the _IMSE_ of the proposed GEP model is still an order of magnitude higher than that of the ANN. It implies that there is further scope to develop a generalized WPS model using GEP through improvements in training strategies.
## VI Conclusions
The study presents a machine learning-based framework that uses data-driven modeling to predict wall pressure spectra (WPS) underneath turbulent boundary layers. Different datasets of WPS from experiments and high-fidelity numerical simulations covering a wide range of pressure gradients and Reynolds numbers are considered for training. This dataset however appears to be skewed and a cosine-similarity matrix has been used to quantify the visual resemblance of WPS trends across the experiments. The efficacy of two machine learning techniques, namely artificial neural networks (ANN) and gene expression programming (GEP) is evaluated. Firstly, an optimal hyperparameter environment is identified that yields the most accurate predictions for the respective ML methods. This includes assessing the effect of objective functions (\(LMSE/Fit\)) on the convergence rate of ANN models. Of these, \(Fit\) (which is a multi-objective function comprising both _IMSE_ and mean squared error) is shown to converge at a slower rate. Interestingly, it has been observed that the prediction accuracy of such weakly converging training methods can be improved by increasing the weight of minority datasets.
For a given input database, the computational resources (training time and memory consumption) of some of the best-performing ANN and GEP models are compared. In terms of accuracy, the results show the clear superiority of ANN over GEP with the logarithmic mean squared error (_IMSE_) of ANN being less than 1 while that of GEP being around \(O(10)\). The corresponding training time of ANN models is also 8 times lower (\(\approx 3\)_hours_) than that of the GEP (\(\approx 24\)_hours_), despite a higher memory consumption. Nevertheless, the advantage of GEP lies in predicting a realizable closed-form mathematical expression. In contrast to the unconventional structure of ANN models, these expressions from GEP can provide direct physical insight.
Novel training schemes are devised to address the shortcomings of GEP. These include (a) ANN-assisted GEP to reduce the noise in the training data (b) exploiting the physical trends in the spectra observed at low and high frequencies to guide the GEP search (c) a stepped training strategy where the chromosomes are first trained on the canonical datasets followed by the datasets with complex features. The first two training strategies are shown to accelerate the convergence and yield more consistent models (\(\approx 40\%\) reduction in the spread of _IMSE_ in the interquartile range) with superior accuracy (\(\approx 17\%\) reduction in the median _IMSE_). Stepped training strategy further improves upon the reliability and accuracy with an additional reduction of \(\approx 60\%\) and \(\approx 10\%\) in the aforementioned statistics respectively. The predictions of the resulting GEP models appear to have captured the complex trends of WPS while surpassing the accuracy of both Dominique's GEP model and Goody's model.
With the inclusion of the ever-evolving data repository of WPS, the authors believe that the methods and insights from the present study will facilitate the discovery of more consistent and generalized models. The goal is to discover GEP models that result in competitive predictions to the ones produced by the ANN models. The analytical nature of GEP models will allow for the generalization of WPS beyond the trained regimes.
## Acknowledgements
The authors wish to acknowledge NVIDIA for generously awarding Quadro P6000 and A100 GPU cards under the Academic Hardware Grant Program. The authors also wish to acknowledge the VKI team: Joachim Dominique, Jan Van den Berghe, Dr. Christophe Schram, Dr. Miguel Alfonso Mendez, Dr. Julien Christophe, and Dr. Richard D. Sandberg (from the University of Melbourne) for making their source code and data publicly available. Dr. Nagabhushana Rao Vadlamani also acknowledges the financial support from Science and Engineering Research Board (SERB), India under Mathematical Research Impact Centric Support (MATRICS) scheme (MTR/2022/000807).
## Author declarations
### Conflict of Interest
The authors have no conflicts to disclose.
## Data availability statement
The data that support the findings of this study are available from the corresponding author upon reasonable request.
## Appendix A
Here, we provide details of the resampling procedure which maps generations in GEP evolution with wall-clock time. At the end of every generation, we probed the Weighted objective function values (of the best individual in the generation) and the wall-clock time spent for the generation. Although each of the 10 trials is trained for a fixed set of generations, the training can take different wall-clock times. Hence, the statistics are re-sampled over a common time interval using a Piece-wise Cubic Hermite Interpolating Polynomial (PCHIP) interpolator [50] as illustrated in Table 8. Although this shortens the observation window to the trial with the shortest runtime to reach 20000 generations, it facilitates the comparison of statistics in wall-clock time across different trials and training schemes. This approach of choosing the shortest window is justified since the interest lies in developing methods that converge faster.
## Nomenclature
\(<y>_{E}\): Ensemble average of the batch of outputs
\(\beta\): Clauser parameter
\(\Delta\): Zagarola-Smits's parameter
\(\delta\): Boundary layer thickness
\(\delta^{*}\): Displacement thickness
\(v\): Dynamic viscosity
\(\omega\): angular frequency \(\omega=2\pi f\)
\(\Omega_{z}\): Vorticity component in \(z\) (spanwise) direction
\(\overline{p}\): Mean pressure
\(\partial_{n}\): Partial derivative with respect to \(n^{th}\) coordinate
\(\Phi_{pp}\): Power spectral density
\(\Pi\): Wake strength parameter
\(\rho\): Density at wall
\(\tau\): Time
\(\tau_{w}\): Wall shear stress
\(\theta\): Momentum thickness
|
2308.09426 | Self-Supervised Single-Image Deconvolution with Siamese Neural Networks | Inverse problems in image reconstruction are fundamentally complicated by
unknown noise properties. Classical iterative deconvolution approaches amplify
noise and require careful parameter selection for an optimal trade-off between
sharpness and grain. Deep learning methods allow for flexible parametrization
of the noise and learning its properties directly from the data. Recently,
self-supervised blind-spot neural networks were successfully adopted for image
deconvolution by including a known point-spread function in the end-to-end
training. However, their practical application has been limited to 2D images in
the biomedical domain because it implies large kernels that are poorly
optimized. We tackle this problem with Fast Fourier Transform convolutions that
provide training speed-up in 3D microscopy deconvolution tasks. Further, we
propose to adopt a Siamese invariance loss for deconvolution and empirically
identify its optimal position in the neural network between blind-spot and full
image branches. The experimental results show that our improved framework
outperforms the previous state-of-the-art deconvolution methods with a known
point spread function. | Mikhail Papkov, Kaupo Palo, Leopold Parts | 2023-08-18T09:51:11Z | http://arxiv.org/abs/2308.09426v1 | # Self-Supervised Single-Image Deconvolution with Siamese Neural Networks
###### Abstract
Inverse problems in image reconstruction are fundamentally complicated by unknown noise properties. Classical iterative deconvolution approaches amplify noise and require careful parameter selection for an optimal trade-off between sharpness and grain. Deep learning methods allow for flexible parametrization of the noise and learning its properties directly from the data. Recently, self-supervised blind-spot neural networks were successfully adopted for image deconvolution by including a known point-spread function in the end-to-end training. However, their practical application has been limited to 2D images in the biomedical domain because it implies large kernels that are poorly optimized. We tackle this problem with Fast Fourier Transform convolutions that provide training speed-up in 3D microscopy deconvolution tasks. Further, we propose to adopt a Siamese invariance loss for deconvolution and empirically identify its optimal position in the neural network between blind-spot and full image branches. The experimental results show that our improved framework outperforms the previous state-of-the-art deconvolution methods with a known point spread function.
Keywords:Deconvolution Microscopy Deep learning.
## 1 Introduction and related work
Quality enhancement is central for microscopy imaging [26, 29]. Its two most important steps are noise removal and blur reduction that improve performance in downstream tasks for both humans and algorithms.
Denoising, approaches to which were developed decades ago [5], was given a boost by recent advances in deep learning methods [1, 3, 10, 11, 14, 26, 15, 19, 18], which substantially outperform classical algorithms [5, 2]. A direct approach to train a denoising neural network is to provide it with pairs of low and high-quality images [26], but such data are rarely available in practice, which raises the need for alternative techniques. Lehtinen \(et\)\(al.\)[14] proposed to supervise the training with an independently acquired noisy copy of the input, while Batson and Royer [1] concurrently with Krull \(et\)\(al.\)[10] developed a theory of a \(J\)-invariant blind-spot denoising network that operates on a single image in a self-supervised manner.
The latter theory is based on the idea that a network cannot learn the noise that is conditionally pixel-wise independent given the signal, so learning to predict the values of masked pixels can improve the performance in restoration. Xie _et al_. [27] further questioned the necessity of blind spots for efficient denoising. They proposed Noise2Same with Siamese invariance loss between outputs of masked and unmasked inputs to prevent the network from learning an identity function. This advance pushed the performance of self-supervised denoising at a cost of doubled training time.
In addition to noise, equipment imperfection imposes blur on the images via a point spread function (PSF) [24]. The blur can be efficiently removed with classical iterative approaches such as Lucy-Richardson [21], but these algorithms tend to amplify the noise with each iteration and require careful regularization and stopping criteria [12]. As supervised methods are not applicable to deconvolution problem due to the ground truth inaccessibility, Lim _et al_. [16] proposed CycleGAN [30] with linear blur kernel, which performed well in both simulation and real microscopy deconvolution. However, the models of this class are notoriously hard to train [17] and tends to converge to a perceptually conceiving solution that does not necessarily reflect the true underlying structure [13]. Besides, it requires clean data examples, albeit unpaired. Deep self-supervised denoising systems were also adopted for deconvolution purposes. Kobayashi _et al_. [9] assumed an intermediate output of the network to be a deconvolved representation and proposed to train Noise2Self [1] as a pseudo-inverse model with a known PSF kernel. This method was only applied to 2D data.
Our contribution is three-fold. Firstly, we adopt the Siamese invariance loss [27] to the deconvolution task and identify the optimal neural network's outputs to apply it. Secondly, we train the first, to our knowledge, 3D self-supervised deconvolutional network without the adversarial component. Lastly, we propose to alleviate the computational costs of training a Siamese network by using the Fast Fourier Transform (FFT) for convolution with the PSF kernel.
## 2 Methods
We propose a generalized self-supervised deconvolution framework. We follow Kobayashi _et al_. [9] and define the framework as a composition of trainable model \(f(\cdot)\) followed by the fixed PSF convolution \(g(\cdot)\). The framework (Figure 1) allows for both one-pass blind-spot training[10, 1, 9] and two-pass training [27].
For the training, we use two inputs, unmasked \(\mathbf{x}\) and masked \(\mathbf{x}_{J^{c}}\) where the pixels at locations \(J\) are replaced with Gaussian noise. We optimize the trainable model using the composition loss \(\mathcal{L}(f)\) of six terms in Eq. (1).
**Blind-spot loss.**\(\mathcal{L}_{bsp}\) is a mean-squared error (MSE) between the network's unmasked input \(\mathbf{x}\) and output from the masked forward pass \(g(f(\mathbf{x}_{J^{c}}))_{J}\) measured at the locations of the masked pixels \(J\)[10, 1].
**Reconstruction loss.**\(\mathcal{L}_{rec}\) is an MSE between the network's unmasked input \(\mathbf{x}\) and output from the unmasked forward pass \(g(f(\mathbf{x}))\)[27].
**Reconvolved invariance loss.**\(\mathcal{L}_{inv}\) is an MSE between the network's output from the masked forward pass \(g(f(\mathbf{x}_{J^{c}}))_{J}\) and output from the unmasked forward pass \(g(f(\mathbf{x}))_{J}\).
**Deconvolved invariance loss.**\(\mathcal{L}_{inv\,(d)}\) is an MSE between the network's output from the masked forward pass \(f(\mathbf{x}_{J^{c}})_{J}\) and output from the unmasked forward pass \(f(\mathbf{x})_{J}\) before PSF convolution \(g(\cdot)\). Both Siamese invariance losses are computed between the network's outputs from altered (masked and unmasked) inputs at the location of the masked pixels \(J\). They prevent the network from learning an identity function from \(\mathcal{L}_{rec}\) minimization, which is especially important in the single-image deconvolution task.
**Boundary losses**. \(\mathcal{L}_{bound\,(d)}\) and \(\mathcal{L}_{bound}\) regularize the outputs to be within \([min,max]\) boundaries before or after the PSF convolution respectively [9]. These losses are measured after destandardization. We use \(min=0\) and \(max=1\).
In this work, we compare three practical cases. The first one, Eq. (2), considers only the blind-spot loss \(\mathcal{L}_{bsp}\) and establishes a self-supervised \(J\)-invariant baseline.
Figure 1: The self-supervised deconvolution framework. The trainable model \(f(\cdot)\) takes noisy input \(\mathbf{x}\) in unmasked forward pass (solid) and masked noisy input \(\mathbf{x}_{J^{c}}\) in masked forward pass (dashed). The model produces two intermediate outputs (deconvolved representations). These outputs are convolved with a fixed PSF convolution \(g(\cdot)\) to obtain final outputs (reconvolved representations). The deconvolved and reconvolved invariance losses are computed between the respective outputs before and after the PSF. The reconstruction loss is computed between the noisy input and the unmasked forward pass output. The blind-spot loss is computed between the noisy input and masked forward pass output, it does not require an unmasked forward pass.
The second and the third ones are not \(J\)-invariant, both of them include reconstruction loss and invariance loss calculated before (Eq. (4)) or after (Eq. (3)) the PSF convolution. By default, we calculate boundary regularization loss and invariance loss from the same output. We set \(\lambda_{inv}\) and \(\lambda_{inv\,(d)}\) to 2 [27], \(\lambda_{bound}\) and \(\lambda_{bound\,(d)}\) to 0.1 [9] unless otherwise specified.
\[\begin{split}\mathcal{L}(f)=&\lambda_{bsp}\, \mathbb{E}_{J}\mathbb{E}_{x}\|g(f(\mathbf{x}_{J^{c}}))_{J}-\mathbf{x}_{J}\|^{2 }+\\ &\lambda_{rec}\,\mathbb{E}_{x}\|g(f(\mathbf{x}))-\mathbf{x}\|^{2} /m+\\ &\lambda_{inv}\,\mathbb{E}_{J}\left[\mathbb{E}_{x}\|g(f(\mathbf{x }))_{J}-g(f(\mathbf{x}_{J^{c}}))_{J}\|^{2}/|J|\right]^{1/2}+\\ &\lambda_{inv\,(d)}\,\mathbb{E}_{J}\left[\mathbb{E}_{x}\|f( \mathbf{x})_{J}-f(\mathbf{x}_{J^{c}})_{J}\|^{2}/|J|\right]^{1/2}+\\ &\lambda_{bound}\,\mathbb{E}_{x}\left(|min-g(f(\mathbf{x}))|+|g( f(\mathbf{x}))-max|\right)+\\ &\lambda_{bound\,(d)}\,\mathbb{E}_{x}\left(|min-f(\mathbf{x})|+|f( \mathbf{x})-max|\right)\end{split} \tag{1}\]
\[\mathcal{L}(f)_{\text{Noise2Self}} =\mathcal{L}_{bsp} \tag{2}\] \[\mathcal{L}(f)_{\text{Noise2Same}} =\mathcal{L}_{rec}+\lambda_{inv}\,\mathcal{L}_{inv}+\lambda_{bound }\,\mathcal{L}_{bound}\] (3) \[\mathcal{L}(f)_{\text{Noise2Same\,(d)}} =\mathcal{L}_{rec}+\lambda_{inv\,(d)}\,\mathcal{L}_{inv\,(d)}+ \lambda_{bound\,(d)}\,\mathcal{L}_{bound\,(d)} \tag{4}\]
#### 3.2.2 Neural network architecture
For 2D data, we use the previously proposed [10, 27] variation of a U-Net [22] architecture without modifications. The fully-convolutional network of depth 3 consists of an encoder and a decoder with concatenating skip connections at corresponding levels. The first convolutional layer outputs 96 features, and this number doubles with every downsampling step. For 3D data, we modify the network to have 48 output features from the first convolution. We also replace the concatenation operation with an addition in skip connections. Such modification allows for a reduction in training time for 3D convolutional networks without substantial performance sacrifices. We implement the network using PyTorch [20].
#### 3.2.3 Training
During training, we sample a patch (\(128\times 128\) pixels for 2D images, \(64\times 64\times 64\) for 3D), randomly rotate and flip it. We use batch sizes of 16 for 2D images and 4 for 3D images. Each image is standardized individually to zero mean and unit variance. For the masked forward pass, we randomly replace 0.5% of pixels from each training image with Gaussian noise (\(\sigma=0.2\)) [27]. We use Adam [8] optimizer and multiply its learning rate from \(4\cdot 10^{-4}\) by 0.5 every 500 steps out of 3k total for 2D data [9] and every 2k steps out of 15k total for 3D data. We train and evaluate all models on a single NVIDIA V100 16GB GPU.
#### 3.2.4 Inference
For inference, we do only unmasked forward pass and discard the PSF convolution during inference [9]. We use the last model checkpoint since we do not possess any reliable validation metric. For large images that do not fit in
GPU memory, we predict by overlapping patches and stitch the output together using pyramid weights [7] which allows for avoiding edge artifacts. In 3D data, we predict patches of \(128\times 128\times 128\) with overlaps of 32 pixels.
#### 2.0.2 Fast Fourier Transform Convolution
We use FFT for the convolution with a fixed PSF during training. Convolution operation \(x*k\) is equivalent to element-wise matrix multiplication in Fourier space \(F^{-1}(F(x)\odot F(k))\). If image \(x\) is \(M\times M\) pixels and kernel \(k\) is \(N\times N\) and both of them have dimensionality of \(d\), the complexity of an ordinary convolution is \(O(M^{d}N^{d})\), while the complexity of a Fourier convolution is \(O(M^{d}d\log M)\) and does not depend on \(N\). With large enough \(N\), convolution in Fourier space becomes computationally cheaper, and large kernels (even of the size of the image [24]) are common for PSF. It is recommended to use FFT with 2D kernels for \(N>25\) and with 3D kernels for \(N>9\)[6].
## 3 Experiments
We validate our approach on 2D and 3D data in a single image deconvolution task. In all the experiments we train one model per image to obtain a lower bound for the extreme self-supervised case. Every image is normalized within \([0,1]\). We generate blurry images by convolving them with a realistic Richards & Wolf PSF of a 0.8NA 16x microscope objective with \(17\times 17\) or \(17\times 17\times 17\) 0.406-micron pixels. Then we add a mixture of Poisson (\(\alpha=0.001\)), Gaussian (\(\sigma=0.1\)), and salt-and-pepper (only for 2D images, \(p=0.01\)) noise to these images and quantize them with 10 bit precision [9].
We compare the results against classical Lucy-Richardson (LR) deconvolution algorithm [21] and deep learning Self-Supervised Inversion (SSI) [9] algorithm. For LR evaluate the results after 2, 5, 10, and 20 iterations to observe the trade-off between deconvolution quality and noise amplification and report the best ones. We do not include in comparison other classical methods such as Conjugate Gradient optimization [4] and Chambole-Pock primal-dual inversion [4], because they were shown inferior to both LR and SSI [9]. We rerun the baseline experiments ourselves wherever possible.
We evaluate the model performance against clean images using root mean squared error (RMSE), peak signal-to-noise ratio (PSNR) [28], and structural similarity index(SSIM) [25]. For PSNR and SSIM, we explicitly set the data range to the true values \([0,1]\). Since it was not done in prior work [9], some values in Table 2 are missing to avoid confusion. Additionally, for 2D images, we report mutual information (MI) [23] and spectral mutual information (SMI) [9]. For all metrics except RMSE, higher is better.
### 2D dataset
First, we tested the deconvolution framework performance for the 2D case on a benchmark dataset of 22 single-channeled images [9] with size varying from
\(512\times 512\) to \(2592\times 1728\) pixels. We compared three different variants of loss function, Eqs. (2)- (4) (Table 1). Loss (4) performed best with \(\lambda_{inv\,(d)}=2\) and \(\lambda_{bound\,(d)}=0.1\), achieving \(\text{PSNR}=22.79\), \(\text{SSIM}=0.46\), and \(\text{RMSE}=0.078\).
We compared our model against the baseline LR and SSI methods (Table 2, Figure 2). It performed best by PSNR, SMI, and RMSE, and showed similar results by SSIM (0.01 less than LR) and MI (0.01 less than SSI).
### 3D dataset
We evaluated the framework performance for the 3D case on a single synthetic image of microtubules [24] of size \(128\times 256\times 512\). From the three variants of loss function, Eqs. (2)- (4), loss (3) performed best with \(\lambda_{inv}=2\) and \(\lambda_{bound}=0\) showing the results \(\text{PSNR}=24.08\), \(\text{SSIM}=0.39\), and \(\text{RMSE}=0.063\) (Table 3).
We also compared the best-performing model against the LR and SSI methods (Table 4, Figure 2). Our model surpassed baselines by a substantial margin (+1.5 PSNR against SSI and +1.7 against LR).
## 4 Discussion
Our Siamese neural network was superior in single-image deconvolution against both classical and deep learning baselines. The architecture is simple and did not require additional tricks such as masking schedule or adding noise to gradients [9] for training. Training converged to similar performance for all of the several tested random weight initializations.
Loss function performance was inconsistent between the 2D and 3D cases. Invariance loss applied to deconvolved representation proved best for 2D data but
Figure 2: Example deconvolution results on _Drosophila_ 2D image (top), microtubules 3D image, frontal max projection (bottom), magnified. For Lucy Richardson, the result is shown after the best iteration. Our algorithm uses loss from Eq. (4) with \(\lambda_{inv\,(d)}=2\), \(\lambda_{bound\,(d)}=0.1\). PSNR metric is reported for the presented images.
failed to give an advantage in 3D: despite the high SSIM, images appear noisy. We hypothesize that the optimal solution depends on the data; _e.g._ in microtubules, the 3D dataset signal is very sparse. Boundary loss did not drastically affect the training of Siamese networks.
Despite performance superiority, Siamese networks are twice more expensive in computation because they require two forward passes through the neural network. Additionally, Noise2Same U-Net architecture has 10x more trainable parameters than SSI (5.75M against 0.55M in 2D). This problem is exacerbated by the necessity of convolutions with large PSF kernels which are not optimized in modern GPUs. We propose to alleviate this problem by using FFT for convolution with PSF. It leads to 2.3x speed improvement for 3D deconvolution with PSF of size \(17\times 17\times 17\), and this advantage will grow for larger kernels. For example, while training with a PSF of \(31\times 31\times 31\) we observed a 14x speedup.
\begin{table}
\begin{tabular}{l c c c c c c c c} \hline \hline & \multicolumn{3}{c}{\(\lambda_{bsp}\)\(\lambda_{rec}\)\(\lambda_{inv\,(d)}\)\(\lambda_{inv}\)\(\lambda_{bound\,(d)}\)\(\lambda_{bound}\) PSNR \(\uparrow\) SSIM \(\uparrow\) RMSE \(\downarrow\)} \\ \hline input & & & & & & 17.77 & 0.18 & 0.130 \\ \hline \(\mathcal{L}(f)_{\text{Noise2Self}}\) & 1 & 0 & 0 & 0 & 0 & 0 & 22.49 & 0.27 & 0.079 \\ & 1 & 0 & 0 & 0 & 0 & 0.1 & 22.51 & 0.43 & 0.079 \\ \hline \(\mathcal{L}(f)_{\text{Noise2Same}}\) & 0 & 1 & 0 & 2 & 0 & 0 & 21.49 & 0.23 & 0.089 \\ & 0 & 1 & 0 & 2 & 0 & 0.1 & 21.81 & 0.41 & 0.085 \\ \hline \(\mathcal{L}(f)_{\text{Noise2Same (d)}}\) & 0 & 1 & 2 & 0 & 0 & 0 & **22.79** & 0.46 & **0.078** \\ & 0 & 1 & 2 & 0 & 0.1 & 0 & 22.67 & **0.46** & 0.078 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Denoising results for the 2D dataset with different coefficients for loss (1) components: \(\lambda_{bsp}\) — coefficient for the blind-spot loss, \(\lambda_{rec}\) — coefficient for the reconstruction loss, \(\lambda_{inv\,(d)}\) — coefficient for deconvolved invariance loss, \(\lambda_{inv}\) — coefficient for reconvolved invariance loss, \(\lambda_{bound}\) and \(\lambda_{bound\,(d)}\) — coefficients for boundary regularization loss for reconvolved and deconvolved images. For all metrics except RMSE, higher is better. The best values are highlighted in bold.
\begin{table}
\begin{tabular}{l c c c c c c c} \hline \hline & \multicolumn{3}{c}{PSNR \(\uparrow\) SSIM \(\uparrow\) MI \(\uparrow\) SMI \(\uparrow\) RMSE \(\downarrow\) Train \(t\) (s) Inference \(t\) (ms)} \\ \hline input & 17.8 & 0.18 & 0.07 & 0.18 & 0.131 & - & - \\ \hline LR \(n=2\) & 22.0 & **0.47** & 0.13 & 0.25 & 0.086 & - & 46 \\ LR \(n=5\) & 22.2 & 0.44 & 0.12 & 0.25 & 0.082 & - & 48 \\ SSI (reported [9]) & 22.5 & - & **0.14** & 0.27 & - & 238 & 26 \\ SSI (reproduced) & 22.0 & 0.46 & 0.14 & 0.26 & - & 442 & 26 \\ ours & **22.8** & 0.46 & 0.13 & **0.30** & **0.078** & 856 & 53 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Our best-performing method for 2D data compared to Lucy Richardson (LR) [21] and Self-Supervised Inversion (SSI) [9] baselines by denoising metrics (see Section 3 for details), training and inference time (measured for _Drosophila_ image \(1352\times 532\) pixels). For all metrics except RMSE, higher is better. The best values are highlighted in bold. Our algorithm uses loss (4) with \(\lambda_{inv\,(d)}=2\), \(\lambda_{bound\,(d)}=0.1\)
## 5 Conclusion
Blind-spot networks [10, 1] were seminal in self-supervised denoising and performed comparably to supervised methods [14, 26]. Their success was later translated to image deconvolution [9], a more complicated inverse problem. However, it was shown that \(J\)-invariance leads to suboptimal performance in denoising because masked pixels contain useful bits of information [27]. In this work, we presented a novel unified image deconvolution framework, which generalized the accumulated prior advances, and set a new standard for image quality enhancement performance. We investigated the contributions of various self-supervised loss components and empirically identified the optimal usage scenarios for 2D and 3D data. We also proposed using Fast Fourier Transform for the training of deconvolution neural networks, which drastically speeds up the computation, especially for large kernels. This advantage allows one to use our method for non-confocal microscopy with extremely big point spread functions.
\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline & \multicolumn{2}{c}{PSNR \(\uparrow\) SSIM \(\uparrow\) RMSE \(\downarrow\) Train \(t\) (s) Inference \(t\) (ms)} \\ \hline input & 21.2 & 0.64 & 0.087 & - & - \\ \hline LR \(n=2\) & 22.4 & 0.32 & 0.076 & - & 69 \\ SSI & 22.6 & 0.39 & 0.074 & 2814 (6580) & 578 \\ ours & **24.1** & **0.39** & **0.062** & 8160 (18900) & 734 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Our best performing method for 3D data compared to Lucy Richardson (LR) [21] and Self-Supervised Inversion (SSI) [9] baselines by denoising metrics (see Section 3 for details), training and inference time. For all metrics except RMSE, higher is better. The best values are highlighted in bold. Our algorithm uses loss (3) with \(\lambda_{inv}=2\), \(\lambda_{bound}=0\). Training time is reported with and without FFT (in brackets)
\begin{table}
\begin{tabular}{l c c c c c c c c} \hline \hline & \multicolumn{2}{c}{\(\lambda_{bsp}\)\(\lambda_{rec}\)\(\lambda_{inv\,(d)}\)\(\lambda_{inv}\)\(\lambda_{bound\,(d)}\)\(\lambda_{bound}\) PSNR \(\uparrow\) SSIM \(\uparrow\) RMSE \(\downarrow\)} \\ \hline input & & & & & & 21.21 & 0.64 & 0.087 \\ \hline \(\mathcal{L}(f)_{\text{Noise2Self}}\) & 1 & 0 & 0 & 0 & 0 & 0 & 23.71 & 0.39 & 0.065 \\ & 1 & 0 & 0 & 0 & 0 & 0.1 & 23.71 & 0.39 & 0.065 \\ \hline \(\mathcal{L}(f)_{\text{Noise2Same}}\) & 0 & 1 & 0 & 2 & 0 & 0 & **24.08** & 0.39 & **0.063** \\ & 0 & 1 & 0 & 2 & 0 & 0.1 & 24.02 & 0.39 & 0.063 \\ \hline \(\mathcal{L}(f)_{\text{Noise2Same (d)}}\) & 0 & 1 & 2 & 0 & 0 & 0 & 21.05 & **0.82** & 0.089 \\ & 0 & 1 & 2 & 0 & 0.1 & 0 & 21.05 & **0.82** & 0.089 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Denoising results for the 3D dataset with different coefficients for loss (1) components: \(\lambda_{bsp}\) — coefficient for the blind-spot loss, \(\lambda_{rec}\) — coefficient for the reconstruction loss, \(\lambda_{inv\,(d)}\) — coefficient for deconvolved invariance loss, \(\lambda_{inv}\) — coefficient for reconvolved invariance loss, \(\lambda_{bound}\) and \(\lambda_{bound\,(d)}\) — coefficients for boundary regularization loss for reconvolved and deconvolved images. For all metrics except RMSE, higher is better. The best values are highlighted in bold.
## Acknowledgements
This work was funded by Revvity Inc. (VLTAT19682) and Wellcome Trust (206194). We thank High Performance Computing Center of the Institute of Computer Science at the University of Tartu for the provided computing power.
|
2308.04102 | Asynchronous Evolution of Deep Neural Network Architectures | Many evolutionary algorithms (EAs) take advantage of parallel evaluation of
candidates. However, if evaluation times vary significantly, many worker nodes
(i.e.,\ compute clients) are idle much of the time, waiting for the next
generation to be created. Evolutionary neural architecture search (ENAS), a
class of EAs that optimizes the architecture and hyperparameters of deep neural
networks, is particularly vulnerable to this issue. This paper proposes a
generic asynchronous evaluation strategy (AES) that is then adapted to work
with ENAS. AES increases throughput by maintaining a queue of up to $K$
individuals ready to be sent to the workers for evaluation and proceeding to
the next generation as soon as $M<<K$ individuals have been evaluated. A
suitable value for $M$ is determined experimentally, balancing diversity and
efficiency. To showcase the generality and power of AES, it was first evaluated
in eight-line sorting network design (a single-population optimization task
with limited evaluation-time variability), achieving an over two-fold speedup.
Next, it was evaluated in 11-bit multiplexer design (a single-population
discovery task with extended variability), where a 14-fold speedup was
observed. It was then scaled up to ENAS for image captioning (a
multi-population open-ended-optimization task), resulting in an over two-fold
speedup. In all problems, a multifold performance improvement was observed,
suggesting that AES is a promising method for parallelizing the evolution of
complex systems with long and variable evaluation times, such as those in ENAS. | Jason Liang, Hormoz Shahrzad, Risto Miikkulainen | 2023-08-08T07:33:49Z | http://arxiv.org/abs/2308.04102v3 | # Asynchronous Evolution of
###### Abstract
Many evolutionary algorithms (EAs) take advantage of parallel evaluation of candidates. However, if evaluation times vary significantly, many worker nodes (i.e., compute clients) are idle much of the time, waiting for the next generation to be created. Evolutionary neural architecture search (ENAS), a class of EAs that optimizes the architecture and hyperparameters of deep neural networks, is particularly vulnerable to this issue. This paper proposes a generic asynchronous evaluation strategy (AES) that is then adapted to work with ENAS. AES increases throughput by maintaining a queue of up to \(K\) individuals ready to be sent to the workers for evaluation and proceeding to the next generation as soon as \(M<<K\) individuals have been evaluated. A suitable value for \(M\) is determined experimentally, balancing diversity and efficiency. To showcase the generality and power of AES, it was first evaluated in eight-line sorting network design (a single-population optimization task with limited evaluation-time variability), achieving an over two-fold speedup. Next, it was evaluated in 11-bit multiplexer design (a single-population discovery task with extended variability), where a 14-fold speedup was observed. It was then scaled up to ENAS for image captioning (a multi-population open-ended-optimization task), resulting in an over two-fold speedup. In all problems, a multifold performance improvement was observed, suggesting that AES is a promising method for parallelizing the evolution of complex systems with long and variable evaluation times, such as those in ENAS.
keywords: Evolutionary Computation, Parallelization, Asynchronous Evolution, Sorting Networks, Multiplexer Design, Neural Architecture Search, Neuroevolution +
Footnote †: journal: Arxiv
## 1 Introduction
Evolutionary algorithms (EAs) have recently been extended to solving computationally expensive problems, such as evolutionary neural architecture search (ENAS; Lu et al., 2018; Miikkulainen et al., 2019; Real et al., 2019). A main challenge in this domain is to reduce the amount of time spent in evaluating candidate solutions. For instance, when evolving architectures for deep neural networks (DNNs), a fitness evaluation includes training the network for multiple epochs, which is very time-consuming.
Fortunately, such evolutionary applications can take good advantage of parallel supercomputing resources that have recently become available. Each evaluation can be done on a separate machine (i.e., a GPU resource), and thus the whole population can be evaluated at the same time. However, individual evaluation times can vary significantly, making the process inefficient. A simple network may be trained in a few minutes, but larger ones may take several days on current GPUs (Miikkulainen et al., 2019; Liang et al., 2019, 2021). The EA has to wait for the longest evaluation to finish before the next generation can be created, during which time the other computational resources are idle (Scott and De Jong, 2015). As such, simple parallel EAs are not well suited for ENAS.
As a solution, this paper proposes an asynchronous evaluation strategy called AES that is designed to take full advantage of the available computational resources. At each generation, a constant number of \(K\) individuals are either being evaluated on the \(R\) compute workers, have just finished their evaluation, or are waiting in a queue to be evaluated. As compute workers become available, they pull candidates from the queue for evaluation. As soon as a predetermined batch size of \(M\) evaluations finish, \(M\) new individuals are generated and placed in the queue. In this manner, all available computational resources are used at all times. This process can be seen as a mix of generational and steady-state GAs (Goswami et al., 2023): Each batch of \(M\) new individuals can be seen as a generation, but individuals from several generations may be evaluated in parallel.
AES was evaluated in a series of three experiments in this paper. The first experiment showed that in sorting network design (i.e., a single-population optimization task with known optima), AES finds optimal solutions over twice as fast as synchronous evolution. However, evaluation times do not vary much in this domain; to demonstrate what is possible with higher variation, AES was applied to multiplexer design (i.e., a single-population discovery
task) with significantly more varied but still short enough evaluation times so that statistical significance could be measured. Further, the proper batch size \(M\) was determined to be roughly 1/4 of the total population. The third experiment then scaled up the approach to ENAS for image captioning (i.e., to multiple populations in an open-ended optimization task). In single production-size runs, AES was found to develop solutions of similar quality over twice as fast as synchronous evolution, and to find better solutions overall. AES is thus a promising tool for scaling up evolutionary algorithms to parallel computing resources.
The main contributions of the paper are:
* A new algorithm, AES, for asynchronous evolution.
* A demonstration of the effectiveness of AES over synchronous EAs experimentally on a typical EA as well as ENAS.
* A statistical analysis of how and why AES is able to gain this performance advantage.
The rest of the paper is organized as follows: Section 2 reviews related work on parallel EAs, asynchronous EAs, and neuroevolution of DNNs. Section 3 introduces the generic version of AES and describes how it can be adapted to ENAS. Section 4 presents experimental results comparing the performance of AES with synchronous evaluation in the sorting-network, multiplexer, and ENAS domains. Section 5 analyzes the sources of the speedup and proposes future work.
## 2 Related Work
This section reviews prior work on parallel evaluation strategies for EAs, asynchronous evaluation strategies, and methods for evolutionary neural architecture search.
### Parallel Evaluation Strategies
A common computation bottleneck in EAs is the evaluation step, where all individuals in the population must have their fitness determined. To overcome this bottleneck, the evaluation can be performed in parallel on multiple computing resources simultaneously. The simplest strategy is to run copies of a separate independent EA on each worker node and to return the
best result of all the independent runs (Sudholt, 2015). While this strategy works for EAs where evaluation times are relatively short, it does not scale to problems where evaluation time are extremely long, such as neuroevolution.
A more synergetic approach is global parallelization (Adamidis, 1998), where a single master node (server) assigns individuals to multiple worker nodes for evaluation. When all individuals have been evaluated, the master node proceeds onto the next generation. Thus, when evaluation times vary significantly, the master node will have to wait for the slowest worker node, during which time the other workers are idle. Global parallelization is thus poorly suited for neuroevolution, where evaluations are not only long, but also vary widely in length.
Another challenge with parallelizing EAs is the communication bottleneck that occurs when individuals are sent to workers. To overcome this challenge, an island model (Adamidis, 1998; Sudholt, 2015) can be used, where the population is divided into several subpopulations and each subpopulation is evolved and evaluated on a separate worker node. Periodically, the worker nodes exchange individuals in order to avoid converging to local optima. The topology in which the worker nodes are linked to each other is a major design concern for island models. An even more fine-grained parallelization approach is the cellular model (Sudholt, 2015), where each worker node is assigned to a single individual. Island and cellular models are typically synchronous and still suffer from the same issues as other synchronous EAs. Luckily for most problem domains, including neuroevolution, communication between workers is not the bottleneck, but rather the computation time spent by the worker nodes themselves.
### Asynchronous Evaluation Strategies
Asynchronous evaluation strategies are a way to overcome the issues with synchronous EAs. The key difference is that while synchronous EAs are based on a generational model, asynchronous EAs are a parallel version of steady state EAs (Scott and De Jong, 2015, 2015). In other words, they do not wait for the entire population to be evaluated but proceed with evolution when only a subset of the population has been evaluated. As a result, asynchronous EAs are well suited for problems with long, highly variable evaluation times. This class of EAs were proposed in the early 1990s, and have been occasionally used by practitioners (Rasheed and Davison, 1999; Depolli et al., 2013; Luke, 2014; Harada and Takadama, 2020). However, little work is done analyzing the behavior and benefits of such algorithms (see Zeigler and Kim, 1993; Kim,
1994; Scott and De Jong, 2015; Abdelhafez et al., 2019, for exceptions). Such methods have recently become more relevant when parameter tuning for large simulations has become more common (Kiran and Ozyildirim, 2022).
One asynchronous neuroevolution algorithm that is closely related to the AES is rtNEAT (Stanley et al., 2005; Papavasileiou et al., 2021). In that approach, a population of neural networks is evaluated asynchronously one at a time. Each neural network is tested in a video game, and its fitness is measured over a set time period. At the end of the period, it is taken out of the game; if it evaluated well, it is mutated and crossed over with another candidate to create an offspring that is then tested in the game. In this manner, evolution and evaluation are happening continually at the same time. The goal of rtNEAT is to make replacement less disruptive for the player; it was not designed to parallelize evolution to speed it up in a distributed environment. Thus, unlike AES, it does not provide a performance advantage (Stanley et al., 2005).
The rtNEAT approach to asynchronous neuroevolution assumes that the evaluation times are approximately the same. Therefore, it is not well suited for neuroevolution where evaluation times can vary significantly. Such variation is especially prominent in the training of deep neural network architectures, described in the next section. Another drawback of existing approaches is that they are only designed for a single population of individuals (Scott and De Jong, 2015; Chitty, 2021). As such, existing asynchronous EAs cannot deal with the coevolution of multiple populations, such as in the neuroevolution domain described later. AES was designed to overcome these limitations, and thus presents an improvement over rtNEAT and asynchronous EAs in general.
### Evolutionary Neural Architecture Search (ENAS)
DNNs have achieved state-of-the-art performance on many machine learning competitions and benchmarks in areas like computer vision, speech, and natural language processing (Collobert and Weston, 2008; Graves et al., 2013; Szegedy et al., 2016; Dosovitskiy et al., 2020). Often, hyperparameter choice and the structure of the network have a massive impact on its performance, and as a result, much research effort has been spent on discovering better architectures (He et al., 2016; Szegedy et al., 2016; Tan and Le, 2019; Wu et al., 2021).
Recently, EAs have been proposed as a viable way to optimize the architecture and hyperparameters of a DNN automatically (Miikkulainen et al.,
2019; Liang et al., 2018, 2019). Evolution can generate DNNs with diverse topologies and achieve state-of-the-art performance on large-scale visual domains (Real et al., 2019). In addition, they can optimize multiple conflicting objectives such as performance and network complexity (Lu et al., 2018). Advanced EAs like CMA-ES (Loshchilov and Hutter, 2016) can discover good hyperparameters in high-dimensional search spaces (Loshchilov and Hutter, 2016), performing comparably with statistical algorithms such as Bayesian optimization (Snoek et al., 2015).
In this paper, a powerful EA called CoDeepNEAT (Miikkulainen et al., 2019) is used to explore the search space for potential DNN topologies and hyperparameters. CoDeepNEAT consists of a population of blueprints and a population of modules. Each population is evolved separately with a modified version of NEAT (Stanley and Miikkulainen, 2002). NEAT automatically divides each population into subpopulations, or species, of similar individuals. An individual in the blueprint population is a graph where each node contains a pointer to a particular module species in the module population. An individual in a module population is a graph where each node represents a particular DNN layer and its corresponding hyperparameters (number of
Figure 1: A visualization of how CoDeepNEAT assembles networks for fitness evaluation. The blueprints and modules are evolved in separate populations, divided into species (or subpopulations). For evaluation, they are assembled into a network by replacing the blueprint nodes with modules drawn from the corresponding module species. This approach makes it possible to evolve repetitive and deep structures seen in many recent successful DNNs.
neurons, activation function, etc.). As shown in Figure 1, the modules and blueprints are combined to create a temporary population of assembled networks.
Each individual in this assembled population is then evaluated by training it on some supervised task, determining their performance on a dataset, and assigning that performance metric as fitness. The fitness of the individuals (networks) is attributed back to blueprints and modules as the average fitness of all the assembled networks containing that blueprint or module. One of the advantages of CoDeepNEAT is that it can discover modular, repetitive structures seen in state-of-the-art networks such as Googlenet and ResNet (Szegedy et al., 2016; He et al., 2016). CoDeepNEAT has achieved state-of-the-art performance in multiple problem domains, including image captioning, multitask learning, and automatic machine learning (Miikkulainen et al., 2019; Liang et al., 2019, 2021). However, CoDeepNEAT still suffers from the same issues as any synchronous EA. Improving CoDeepNEAT through asynchronous evaluation of the population is the main technical challenge solved in this paper.
## 3 The Asynchronous Evaluation Strategy Method (AES)
This section provides the motivation for the AES approach, presents a generic single-population version of it, as well as a multi-population version suitable for ENAS.
### Overview
A key problem that AES aims to solve is the inefficiency of synchronous evaluation strategies when running an EA in a parallel, distributed environment. This problem is especially challenging for the evolution of DNN architectures that have high variance in evaluation times due to the various amounts of time needed to train different networks. As a result, the slowest individuals' evaluation becomes a bottleneck. This problem can be alleviated through two mechanisms: (1) If there is a constant supply (i.e., a queue) of individuals to be readily evaluated, the worker nodes will have optimal throughput and minimal idle time: They can immediately pull new individuals from the queue after they have evaluated their current individual. (2) Server idle time can be minimized if evolution immediately proceeds to the next generation once a certain fraction of the total number of individuals in the queue has been returned.
Since the number of individuals in the queue exceeds the number of individuals in a generation, it is not scalable to have the EA server keep track of all the individuals being evaluated. The solution is simple: Distribute the bookkeeping to the workers. That is, after the server has placed the next generation of individuals into the Evaluation Queue, it no longer keeps track of them. Instead, as workers become available, they pull individuals from the queue, and when they are done evaluating them, return both the fitness values and the corresponding individuals back to the server. Thus, the server only needs to be activated periodically to generate the next generation of individuals.
Figure 2: An overview of generic single-population AES. \(R\) workers pull individuals from the Evaluation Queue, evaluate them, and return them (with fitnesses \(F\)) to the server. As soon as \(M\) individuals have been returned, the server uses them and the \(L\) elite individuals (from the previous generation) to create a new generation of \(M\) individuals. They are then placed into the Evaluation Queue, and the elite set is updated. In this manner, the workers in AES do not have to stay idle waiting for a generation to finish their evaluations. The ratio of \(M/K=D\) strikes a balance between diversity and efficiency.
```
1:Initialize the Evaluation Queue with \(K\) individuals (any idle workers will immediately pull individuals from the queue if it is not empty).
2:for target number of generations do
3: Wait for \(M\) individuals and their fitnesses \(F\) to return (where \(M*D=K\), \(D>1\)).
4: Select \(L+M\) parents from the \(L\) elites and the \(M\) returned individuals.
5: Generate \(M\) child individuals from parents using evolutionary operators.
6: Update the set of \(L\) elites with the \(M\) returned individuals.
7: Submit the \(M\) individuals to the Evaluation Queue.
8:endfor
```
**Algorithm 1** Generic Single-population AES
### Generic Single-Population AES
AES can be easily added onto parallel, synchronous EA with a single population, as shown in Figure 2 and Algorithm 1. They specify a generic version of AES with few assumptions regarding the underlying EA framework and no additional computational burden. The Evaluation Queue is initialized in the beginning with \(K\) randomly generated individuals (Step 1 in Algorithm 1). \(M\) is the size of the population, i.e., the number of individuals, AES waits to return (Step 3) before it creates the next generation of \(M\) individuals. \(D\) is a hyperparameter that controls the ratio between \(K\) and \(M\). Thus, the number of individuals in the Evaluation Queue decreases from \(K-R\) in the beginning of a generation to \(K-R-M\) in the end, then jumps back up to \(K-R\) as the \(M\) newly generated individuals are added to it.
Together, the \(M\) individuals that are returned and the \(L\) elite individuals from the previous generation constitute the population from which the next generation is created (Steps 4-5). If any of the returned individuals are better than the worst individuals in the current elite set, the elite set is updated, keeping its size constant at \(L\) (Step 6). The entire new generation of \(M\) individuals is then submitted for evaluation (Step 7). Note that individuals from multiple such generations may be under evaluation at the same time, so the process is not strictly generational, but can be seen as a mix of generational and steady-state GAs (Goswami et al., 2023).
As shown in Section 4, AES can be used to enhance the performance of an existing large-scale EA that utilizes hundreds of thousands of worker nodes.
### Multi-population AES for ENAS
Figure 3 and Algorithm 2 describe CoDeepNEAT-AES, i.e., a version of AES adapted for the CoDeepNEAT method of ENAS. The main difference between CoDeepNEAT-AES and the generic AES is that the evolutionary operations take place at the level of blueprints and modules, not the evaluated individuals. Therefore, an assembly step is needed before placing individuals into the Evaluation Queue, and a disassembly step before the evolutionary operations. Also, blueprint and module populations persist continuously across generations: While it would be possible to use only the elites and the returned individuals to construct the population for each generation (as is
Figure 3: An overview of CoDeepNEAT-AES. The AES process of Figure 2 is extended with blueprint and module populations. Complete networks are assembled from the blueprints and modules and sent to the Evaluation Queue. When \(M\) networks are returned, they are disassembled into their blueprints and modules, whose fitnesses are calculated as an average over all networks in which they participated. These blueprints and modules are then merged into the current populations, replacing any existing fitnesses. NEAT neuroevolution is run in each population, replacing the bottom \(N-L\) with new blueprints/modules, and updating the species. Similar to generic AES, the workers are fully employed in evaluating individuals, resulting in significant speedup over synchronized CoDeepNEAT.
done in the generic AES), larger and persistent populations provide more comprehensive and diverse source material, making evolution more effective.
There are two populations in CoDeepNEAT-AES: one for blueprints and another for modules. They are both evolved with the NEAT neuroevolution method. One important aspect of NEAT is that it speciates the population automatically, i.e., divides the population into subpopulations of similar individuals, runs evolution primarily within those species (with occasional crossover between species), and adjusts the size of the species according to their overall fitness. In this manner, species may emerge and die out over evolution.
More specifically, the species that emerge in the module population are numbered and used to supply the modules for each blueprint slot, as shown in Figure 1. This assembly step is unchanged in CoDeepNEAT-AES (Step
12 in Algorithm 2).
The disassembly step is more elaborate. It consists of identifying each blueprint and module in each of the returned individuals (Step 6), calculating their fitness as the average of all the networks in which they participated (Step 7), and merging them into the existing populations: If the blueprint or module already exists in the population, the new fitness is used to replace the old one, thus keeping the fitnesses up to date wrt. the current other network components (Step 8).
Each population is then evolved as usual with NEAT: Within each species, the top \(L\%\) members are preserved as the elite set, and the rest are discarded (Step 9; in CoDeepNEAT-AES, the elite size \(L\) is defined as a percentage of the species, instead of an absolute number of individuals as in generic AES). NEAT then assigns new individuals to be generated in each species proportional to their fitness, keeping the total population size is constant at \(N\) (Step 10). After these individuals have been generated, the \(S\) species are recreated based on the current similarities within the population (Step 11). In this manner, the species change and grow and shrink during evolution.
These extensions make it possible to run AES on a multi-population domain such as CoDeepNEAT ENAS. At the high-level, CoDeepNEAT-AES retains the efficiency of AES, as will be demonstrated experimentally in the next section.
## 4 Experimental Results
The generic version of AES was implemented in EC-STAR, a distributed genetic programming (GP) platform that is scalable to hundreds of thousands of worker nodes (Shahrzad and Hodjat, 2015). It was tested in two single-population domains: Eight-line sorting-network design with known optima, and 11-bit multiplexer design where the goal is to discover a valid solution. The two experiments serve to evaluate how effective AES is in speeding up evolution when the evaluation times vary a little and when they vary a lot. Since the evaluation times are relatively short in both domains, it was possible to repeat the runs multiple times and confirm that the differences are statistically significant. For the same reason, it was possible to determine an effective value for the hyperparameter \(D\). The third experiment, then, scaled up AES to ENAS, i.e., to CoDeepNEAT neuroevolution in the image-captioning domain. In contrast to the first two experiments, multiple populations are evolved at once, and the optimization is open-ended, i.e., the
optimal solution is not known. Also, as is common in deep learning experiments, extremely long evaluation times limit the experiment to comparing single runs. These three experiments thus evaluate AES in two contrasting settings.
### Sorting-Network Domain
A sorting network of \(n\) inputs is a fixed layout of comparison exchange operators (comparators) that sorts all possible inputs (Figure 4; Knuth, 1998). Since the same layout can sort any input, it represents an oblivious or data-independent sorting algorithm, that is, the layout of comparisons does not depend on the input data. Sorting-network design has been a fundamental problem in computer science for many years, providing an important element for graphics processing units, multi-processor computers, and switching networks (Baddar, 2009; Kipfer et al., 2004; Valsalam et al., 2013).
Beyond validity, the goal in designing sorting networks is to minimize the number of comparators. Designing such minimal sorting networks is a challenging optimization problem that has been the subject of active research since the 1950s (Knuth, 1998; Shahrzad et al., 2018, 2020; Valsalam et al.,
Figure 4: A Four-Input Sorting Network, represented as ((0,1),(2,3),(0,2),(1,3),(1,2)). This network takes as its input (left) four numbers and produces output (right) where those numbers are sorted (large to small, top to bottom). Each comparator (a connection between the lines) swaps the numbers on its two lines if they are not in order, otherwise it does nothing. This network has five comparators, and is the minimal four-input sorting network. Minimal networks are generally not known for input sizes larger than eight, and designing them is a challenging optimization problem.
2013). For smaller networks of up to eight lines, the optimal solutions are known, making it a verifiable optimization challenge.
Sorting networks can be represented as a sequence of two-leg comparators where each leg is connected to a different input line and the first leg is connected to a lower line than the second:
\[<\text{SortingNetworkConfiguration}>::= <\text{ComparatorList}>\] \[<\text{ComparatorList}>::= <\text{Comparator}>[<\text{ComparatorList}>]\] \[<\text{Comparator}>::= <(f_{i},s_{i})>,\text{where }f_{i}<s_{i},\ 0\leq f_{i},s_{i}<n\] Example: \[((f_{1},s_{1}),(f_{2},s_{2}),...,(f_{i},s_{i}))\]
Although the space of possible networks is infinite, it is relatively easy to test whether a particular network is correct: If it sorts all combinations of zeros and ones correctly, it will sort all inputs correctly (Knuth, 1998). This property makes it possible to evaluate networks systematically and efficiently: For instance for an eight-line network, only 256 inputs need to be evaluated to verify that the network is correct.
The evaluation times depend linearly on the size of the network. For instance, evaluating a valid 24-comparator network of eight inputs takes about 25% more time than evaluating an optimal network with 19 comparators. Such variation in evaluation times is much smaller than with ENAS networks, but provides a test of how much speedup is possible even in a limited case.
To determine the optimal parameter value for \(M\), \(K\) was set to 1000, \(L\) to 1, and experiments run with \(M=2\), 10, 50, 250, and 1000. In each experiment, the goal was to find the optimal eight-line sorting network, and the time required on a 32-core machine (i.e. \(R=32\)) was recorded. Each experiment was repeated 10 times.
The results are presented in Figure 5. The highest speedup is achieved in the midrange, i.e. when \(M=10\) (i.e. \(D=100\)). In that case, AES finds solutions 2.2 times faster than synchronous evolution (i.e., when \(M=K=1000\)). This result shows that even with minor variation in evaluation times, AES can achieve significant speedups. What happens with larger variations will be evaluated next.
### Multiplexer Domain
Multiplexer functions have long been used to evaluate machine-learning methods because they are difficult to learn but easy to check (Koza, 1990).
In general, the input to the multiplexer function includes \(u\) address bits \(A_{v}\) and \(2^{u}\) data bits \(D_{v}\), i.e., it is a string of length \(u+2^{u}\) of the form \(A_{u-1}...A_{1}A_{0}D_{2^{u-1}}...D_{1}D_{0}\). The value of the multiplexer function is the value (0 or 1) of the particular data bit that is singled out by the \(u\) address bits. For example, for the 11-Multiplexer, where \(u=3\), if the three address bits \(A_{2}A_{1}A_{0}\) are 110, the multiplexer singles out data bit number 6 (i.e., \(D_{6}\)) to be its output. A Boolean function with \(u+2^{u}\) arguments has \(2^{u+2^{u}}\) rows in its truth table. Thus, the sample space for the Boolean multiplexer is of size \(2^{u+2^{u}}\). When \(u=3\), the search space is of size \(2^{2^{11}}=2^{2048}\approxeq 10^{616}\)(Koza, 1990). However, since evolution can also generate redundant expressions that are all logically equal, the real size of the search space can be much larger,
Figure 5: An overview of how different values for \(M\) (batch size) affect the convergence time in the sorting-network domain. The settings \(K=1000\) and \(M=10\) (\(D=100\)) provide the best performance for this problem. The rightmost box (\(M\)=1000) amounts to synchronous evolution, thus demonstrating that AES results in over two-fold speedup even with limited variation in evaluation times. The differences are statistically significant with \(p=2.4\times 10^{-5}\) (\(M=10\) vs. \(M=1000\)), \(p=4.8\times 10^{-3}\) (\(M=50\) vs. \(M=1000\)), and \(p=8.9\times 10^{-3}\) (\(M=250\) vs. \(M=1000\)).
depending on the representation.
Following prior work on the 11-Multiplexer problem (Shahrzad and Hodjat, 2015), a rule-based representation was used where each candidate specifies a set of rules of the type
\[<\text{rule}>::=\text{$<$ conditions}>\,\rightarrow\,\text{$<$ action}>.\]
The conditions specify values on the bit string and the action identifies the index of the bit whose value is then output. For instance, the following rule outputs the value of data bit 6 when the first three bits are 110:
\[<A_{0}=0\ \&\ A_{1}=1\ \&\!A_{2}=0>\,\rightarrow\,D_{6}.\]
These rules were evolved through the usual genetic operators in genetic programming (Berlanga et al., 2010). Note that with this definition, although logical OR is not explicitly represented in the grammar, there may be several rules with the same action. Such a representation is equivalent to a logical OR and allows the representation to be functionally complete. In other words, the grammar above, which includes the AND, OR and NOT operators, can be used to express all possible Boolean functions. This system can produce a range of genes, from only a single condition rule, up to the maximum number of rules and conditions allowed per configuration. The maximum number of rules was set to 256 and the maximum number of conditions per rule to 64.
Like the sorting-network domain, the multiplexer domain employs a single population. The search space is much larger, however evolution terminates when a valid solution is found instead of a minimal solution. It is therefore still a simpler setting than ENAS, which includes multiple populations and open-ended optimization. Also, evaluation times are short enough so that runs can be repeated several times and statistical significance estimated. Like ENAS, multiplexer evolution starts with simple solutions and gradually makes them more complex; also, multiplexer solutions require sufficient complexity, as do successful neural networks. The conclusions from the multiplexer are thus likely to carry over to ENAS.
However, for the conclusions to carry, it is important to make the evaluation times vary in the multiplexer the same way as they do in ENAS. In principle, every fitness evaluation in the multiplexer domain takes a similar amount of time; therefore, an artificial delay was added to the end of every evaluation. The amount of delay was modeled after the evaluation timings
of an actual run of CoDeepNEAT on the CIFAR-10 image-classification domain (Miikkulainen et al., 2019). Two linear regression models were fit on a scatter plot of (1) the mean evaluation time vs. the number of generations elapsed, and (2) the standard deviation of evaluation time vs. the number of generations elapsed. During each generation of EC-Star, the two linear models were used to predict the mean and standard deviation; these values were used to construct a Gaussian distribution from which the delays for fitness evaluations were sampled.
In order to determine an appropriate value for \(M\), \(K\) was set to 4000, \(L\) to 100, and three different values of \(M\) tested (500, 1000, 4000). In each test, the amount of time necessary for EC-Star to converge and solve the multiplexer problem was recorded, using \(R=4000\). The experiments were
Figure 6: An overview of how different values for \(M\) (batch size) affect the convergence time in the multiplexer domain. The settings \(K=4000\) and \(M=1000\) (\(D=4\)) provide the best performance for this problem. The rightmost box (\(M\)=4000) amounts to synchronous evolution, thus demonstrating that AES results in a 14-fold speedup in this domain. The differences are statistically significant with \(p=1.03\times 10^{-11}\) (\(M=1000\) vs. \(M=4000\)) and \(p=6.29\times 10^{-09}\) (\(M=1000\) vs. \(M=500\)).
repeated 10 times for each value of \(M\).
The results are summarized in Figure 6, which plots convergence time for the different \(M\) values. Interestingly, setting \(M\) to an extremely low or high value can hurt performance. Too small batches are akin to too small populations: Enough diversity is needed in the batch to allow evolution to progress well. On the other hand, too large batches result in longer evolution. In cases where \(M=1000\), evolution shows the most substantial speedups. In this case \(D\) is approximately 4, in contrast with \(D=100\) in the sorting network domain. Thus, depending on the amount of variation in the evaluation times, \(D\) can be adjusted to obtain significant speedups. In the multiplexer domain, AES finds solutions 14 times faster than synchronous evolution (i.e., when \(M=K=4000\)), which is a remarkable speedup indeed.
### Image-Captioning Domain
Deep learning has recently provided state-of-the-art performance in image captioning, and several diverse architectures have been suggested (Vinyals et al., 2015; Xu et al., 2015; Karpathy and Li, 2015; You et al., 2016; Vedantam et al., 2017; Hossain et al., 2019). The input to an image-captioning system is a raw image, and the output is a text caption describing the contents of the image. In many of these architectures, a convolutional network is used to process the image into an embedding. This embedding is then given to recurrent layers such as LSTMs to generate coherent sentences with long-range dependencies.
As is common in existing approaches, a pretrained ImageNet model (Szegedy et al., 2016) was used to produce the initial image embeddings. The evolved network took an image embedding as input, along with a sequence of one-hot text inputs. During training, the text input contained the previous word of the ground truth caption; during inference, it contained the previous word generated by the model (Vinyals et al., 2015; Karpathy and Li, 2015). In the initial CoDeepNEAT population, the image and text inputs were fed to a shared embedding layer, which was densely connected to a softmax output over words. From this simple starting point, CoDeepNEAT evolved architectures that included fully connected layers, LSTM layers, pooling layers, concatenation layers, as well as sets of hyperparameters associated with each layer, along with a set of global hyperparameters (Miikkulainen et al., 2019). In fact, the well-known Show-and-Tell image-captioning architecture (Vinyals et al., 2015) is in this search space.
Two separate runs of CoDeepNEAT for evolving DNNs in the image-captioning domain were performed. The baseline version of CoDeepNEAT was synchronous, while the improved version, called CoDeepNEAT-AES, made use of asynchronous evaluations. To keep the computational costs reasonable, during evolution, the networks were trained for six epochs, and on one-fifth of the entire MSCOCO image-captioning dataset. Identical hyperparameters were used in both runs: Population sizes were \(N_{\mathrm{b}}=20\) and \(N_{\mathrm{m}}=60\), \(L_{\mathrm{b}}=L_{\mathrm{m}}=50\%\), divided into \(S_{\mathrm{b}}=1\) and \(S_{\mathrm{m}}=3\) species. For CoDeepNEAT-AES, \(K=300\) and \(M=100\) (i.e., \(D=3\), on par with \(D=4\) in the multiplexer experiment) were used. The worker nodes were composed of up to \(R=200\) Amazon EC2 spot instances with GPU support for training DNNs. Because EC2 spot instances are inherently unreliable and may be temporarily unavailable for any reason, both runs were started at the same time to remove a potential source of bias. Each method was run until convergence, which took about 89 hrs. Due to this cost (in terms of time, money, and carbon footprint) the conclusions were drawn from these single runs, as is common in modern deep-learning experiments.
The CoDeepNEAT and CoDeepNEAT-AES runs resulted in a similar range of architectures, similar to those reported in the original CoDeepNEAT experiments (Miikkulainen et al., 2019). From Figures 7, 8 and 9, it is clear that CoDeepNEAT-AES runs significantly faster than the synchronous version of CoDeepNEAT. Although both versions achieve similar fitness after the same number of generations (Figure 7), each generation of CoDeepNEAT-AES takes far less time (Figure 8), and as a result, CoDeepNEAT-AES progresses much faster in wall-clock time (Figure 9). At 130,000 seconds elapsed, CoDeepNEAT-AES was able to reach the same fitness as CoDeepNEAT at 300,000 seconds, thus resulting in a 2.3-fold speedup. Also, when run until 300,000 seconds, CoDeepNEAT-AES was able to find better solutions than CoDeepNEAT. Overall, the experimental results suggest that AES accelerates the convergence of CoDeepNEAT over two fold in the image-captioning domain.
variation, small. When \(D\) approaches 1 (i.e., \(M\) approaches \(K\)) AES becomes similar to synchronous evaluation, and increasingly needs to wait for the slowest individuals to finish evaluation. However, setting a value for \(D\) that is too large also hurts performance. This is likely because as \(M\) gets smaller, both the returned individuals and the new population that is generated from them become less diverse.
The histogram in Figure 10 reveals how AES improves performance over synchronous evaluation. This plot visualizes the distribution of times at which individuals (along with their fitness) return from evaluation over the duration of an average generation. In the synchronous version of CoDeepNEAT, individuals in the population are submitted at the same time, and all come back in the same generation before evolution can proceed. As a result, the histogram for synchronous CoDeepNEAT is roughly a Gaussian distribution, with some individuals returning early and some returning late.
Figure 7: A plot of fitness vs. number of generations elapsed for synchronous CoDeepNEAT and CoDeepNEAT-AES. The algorithms perform comparably at each generation. However, CoDeepNEAT-AES is much faster, as seen in Figures 7 and 9 (for this reason, the CoDeepNEAT was run only 14 generations while CoDeepNEAT-AES was run until 50.)
A lot of time is thus wasted waiting for the last few individuals. On the other hand, this delay does not occur with CoDeepNEAT-AES; the distribution is uniform, indicating that individuals are returned at a steady, regular rate over the course of a generation and there are no slow individuals that might bottleneck the EA.
There is one measure where the synchronous version of CoDeepNEAT has an advantage. This result is seen in the histogram in Figure 11, which visualizes the delay between when an individual is placed in the Evaluation Queue and when that same individual assigned to a worker node. The delay is slightly higher for CoDeepNEAT-AES than the synchronous version of CoDeepNEAT. The reason is that CoDeepNEAT-AES maintains more individuals in the Evaluation Queue. However, as the fitness plot in Figure 9 indicates, this longer delay does not affect performance significantly.
Another aspect of CoDeepNEAT-AES that differs from its synchronous counterpart is that it tends to favor candidates with lower evaluation times: Their lineage can go through more generations in the same amount of time. Evidence of this effect can be seen in Figure 8 where the mean amount of time spent per generation is significantly lower for CoDeepNEAT-AES than for CoDeepNEAT. While asynchronous EAs are known to have such evaluation
Figure 8: A histogram of time per generation for synchronous CoDeepNEAT and CoDeepNEAT-AES. CoDeepNEAT-AES uses significantly less time per generation.
bias, and efforts have been developed to avoid it (Guijt et al., 2023), it is not undesirable in the case of neuroevolution. Discovering DNNs that are faster to train is often a secondary goal of many architecture search algorithms, and as Figures 7 and 9 show, CoDeepNEAT-AES is able to achieve the same quality of solutions as CoDeepNEAT while taking much less time.
Although AES was developed primarily as a method for ENAS, it is a general method of asynchronous evolution. In future work, CoDeepNEAT-AES may be combined with other improvements such as age-layering and learning curve prediction (Hodjat et al., 2016; Klein et al., 2017). Furthermore, more extensive experiments can be done to analyze how different values for \(K\) and \(D\) will affect the performance of CoDeepNEAT-AES. It should also be possible to use the generic version of AES to scale up evolutionary experiments in many other domains as well.
Figure 9: A plot of fitness vs. wallclock time elapsed for synchronous CoDeepNEAT and CoDeepNEAT-AES. Each marker in the plot represents the fitness at a different generation. CoDeepNEAT-AES improves faster than regular CoDeepNEAT and achieves a higher fitness in the same amount of time.
## 6 Conclusion
This paper proposed a new asynchronous EA called AES designed for complex problems such as optimizing the architecture of DNNs. It can use the available distributed computing resources efficiently with both single and multi-population EAs and in verifiable discovery and open-ended optimization tasks. AES works by maintaining a queue of networks that are ready to be evaluated, and by proceeding with evolution once a fraction of the networks have returned from the workers. Experimental results in the sorting-network, multiplexer, and image-captioning domains show that AES can attain a two to 14-fold speedup over its synchronous counterpart with no loss in accuracy or final fitness. AES is thus a promising way to extend evolutionary optimization to complex domains where traditional parallelization methods are ineffective.
Figure 10: A histogram of the times when individuals return from evaluation over the course of an average generation for both algorithms. CoDeepNEAT-AES has a uniform distribution while CoDeepNEAT has a Gaussian distribution, thus demonstrating that CoDeepNEAT-AES wastes little time waiting for slow individuals. |
2302.12075 | Explorative analysis of human disease-symptoms relations using the
Convolutional Neural Network | In the field of health-care and bio-medical research, understanding the
relationship between the symptoms of diseases is crucial for early diagnosis
and determining hidden relationships between diseases. The study aimed to
understand the extent of symptom types in disease prediction tasks. In this
research, we analyze a pre-generated symptom-based human disease dataset and
demonstrate the degree of predictability for each disease based on the
Convolutional Neural Network and the Support Vector Machine. Ambiguity of
disease is studied using the K-Means and the Principal Component Analysis. Our
results indicate that machine learning can potentially diagnose diseases with
the 98-100% accuracy in the early stage, taking the characteristics of symptoms
into account. Our result highlights that types of unusual symptoms are a good
proxy for disease early identification accurately. We also highlight that
unusual symptoms increase the accuracy of the disease prediction task. | Zolzaya Dashdorj, Stanislav Grigorev, Munguntsatsral Dovdondash | 2023-02-23T15:02:07Z | http://arxiv.org/abs/2302.12075v1 | # Explorative analysis of human disease-symptoms relations using the Convolutional Neural Network
###### Abstract
In the field of health-care and bio-medical research, understanding the relationship between the symptoms of diseases is crucial for early diagnosis and determining hidden relationships between diseases. The study aimed to understand the extent of symptom types in disease prediction tasks. In this research, we analyze a pre-generated symptom-based human disease dataset and demonstrate the degree of predictability for each disease based on the Convolutional Neural Network and the Support Vector Machine. Ambiguity of disease is studied using the K-Means and the Principal Component Analysis. Our results indicate that machine learning can potentially diagnose diseases with the 98-100% accuracy in the early stage, taking the characteristics of symptoms into account. Our result highlights that types of unusual symptoms are a good proxy for disease early identification accurately. We also highlight that unusual symptoms increase the accuracy of the disease prediction task.
## Introduction
The past decades have brought remarkable advances in our understanding of human disease [1, 10]. In Mongolia, the rural population for 2021 was 1,045,010, a 1.21% increase from 2020, that is 31% of the total population. Due to insufficient doctors, nurses in rural areas, providing primary healthcare is a real challenge. The ability of artificial intelligence to process thousands of pages of clinical notes per second in search of the necessary information could provide the essential data that allows us to achieve outstanding results in diagnosing various types of diseases. Many applications have been developed, including health-care chatbots, and disease diagnosis by CT and MRI images. Symptoms are essential predictors to diagnose diseases and are commonly used in the early stage or during treatment [1-9]. A recent trend in health-care diagnosis research employs machine learning techniques [2-8]. [2] a weighted KNN algorithm was used to identify a disease based on the symptoms, age, and gender of an individual. The accuracy of the weighted KNN algorithm for the prediction was 93.5 %, approximately on 230 disease types. A particular disease, such as Parkinson's disease has been studied based on motor and non-motor symptoms and other symptoms like memory disorders, olfactory disorder, sleep disorders and many more [4]. Those symptoms were collected in the form of signals, images, videos, or clinical measures from the articles published between 2017 and 2019. Most of the work has been done on a smaller dataset. Large datasets are needed for generalization. Network analysis is helpful in many research and applications in terms of large-scale visualizations. [1] found that the symptom-based similarity of two diseases correlates strongly with the number of shared genetic associations and the extent to which their associated proteins interact. More specifically, [5] studied the predictability of heart disease using the Multilayer Perceptron Neural Network. Essential 76 characteristics describing heart health, such as age, gender and pulse rate, are
collected from the UCI Cleveland Library dataset. The average prediction was 91% of precision and 89% of recall. Similarly, diabetes [6] is a growing chronic, life-threatening disease that affects millions of people. Five hundred twenty instances are collected using direct questionnaires from the patients. The prediction rate was estimated between 87.5% and 97.4% using Naive Bayes Algorithm, Logistic Regression Algorithm, and Random Forest Algorithm. [7] analyzes older adults to predict hospitalization and mortality. Self-reported symptoms were collected; common symptoms were musculoskeletal pain, fatigue, back pain, shortness of breath and difficulty sleeping. A summary score was observed as a predictor score of hospitalization and mortality. However, there are few studies to discover to what extent type of symptoms can be used to diagnose a particular disease. [11] studied clinical notes for mining disease and symptoms relations based on word embedding learned through neural networks. Related diseases and symptoms were observed by the suggested approach applied in 154,738 clinical notes. [12] proposed a comprehensive framework to impute missing symptom values by managing uncertainty present in the data set.In this study, we analyze a disease-symptom relation network to understand the characteristics of patients' symptoms in terms of occurrence to improve a disease diagnosis and prediction task. We demonstrate the study by estimating the disease predictability and the relation between diseases and symptoms using machine (deep) learning techniques (SVM and CNN) based on word embedding. Understanding the associations between the diseases and symptoms in clinical notes can support physicians in making decisions, and provide researchers evidence about disease development and treatment as well as primary care applications.
## Methods and materials
The following 3-stage research was conducted using machine learning to understand the predictability of diseases given symptoms. We use the same dataset used in [8]. Those research studies obtained a 95.12% accuracy score in disease prediction tasks by employing Decision Tree, Random Forest and Naive Bayes classifiers. A total of 4,920 patient records were obtained in this research. The dataset of 41 types of disease consisting of 135 symptoms was used, and the degree of symptom severity was graded on three levels. Every disease in our dataset is associated with up to 18 symptoms.
### 1. Analyze common and unusual symptoms.
It is crucial to explore hidden links between diseases to understand their characteristic difference. Symptoms are commonly observed in diseases and are essential to diagnose disease primarily. We analyze common and unusual symptoms in the disease-symptom network and estimate the rate of the uniqueness of the symptoms by their occurrence.
### 2. Estimate the degree of predictability of disease based on symptoms.
Based on common and unusual symptoms, we attempt to diagnose disease in an early state based on Support Vector Machine and CNN algorithms. In the data preprocessing stage, we applied a bag of words of natural language processing methods, representing symptoms and disease types in free text.
Support Vector Machine (SVM). To calculate the inner product in a feature space of symptoms as a function of the main entry points, a nonlinear learning machine is built as a kernel function and can be expressed as K. A kernel function may be interpreted as a k function, and consequently, for all \(x\),\(z\)\(\in\)\(X\), we have:
\[K(x,z)=\langle\varphi(x)\cdot\varphi(z)\rangle \tag{1}\]
We use a radial basis function (RBF) as the least square SVM (LS-SVM) for SVM. The main advantage of LS-SVM is that it is more efficient than SVM in terms of computation, whereby LS-SVM training only solves a set of linear equations instead of the time-consuming and challenging calculation of second-order equations.
Convolutional neural network (CNN). In a neural network, neurons are fed inputs, which then neurons consider the weighted sum over them and pass it by an activation function and pass out the output to the next neuron. A CNN differs from that of a neural network because it operates over a volume of inputs. We configured the architecture of CNN as a multi-layer network that is designed to require minimal data processing. Sequentially five layers were designed with the following hyper-parameters. The first layer is a one-dimensional convolutional layer of 64 filters, two kernels and a Relu activation function. We add a dense (16 units), a max pooling layer and a flattened layer into the model. The output layer contains'softmax' activation and the number of output classes.
### Symptoms reduction
Understanding emerging symptoms is very important in disease prediction. However, symptoms are complex and could co-occur due to many diseases. Using PCA techniques, we reduce the number of symptoms to detect the degree of essential features as symptoms for each disease. The principal components are eigenvectors of the data's covariance matrix. Our data set is expressed by the matrix \(X\in\mathbb{R}^{n\times d}\), and the calculation for the covariance matrix can be expressed as:
\[C=\frac{1}{n-1}\sum\limits_{i=1}^{n}{(X_{i}-\bar{X})(X_{i}-\bar{X})^{T}} \tag{2}\]
We also determine similar diseases based on common symptoms based on a distance function to understand the ambiguity of the disease that is represented by symptoms. We use a cosine distance function as follows:
\[similarity(A,B)=\frac{A\cdot B}{\|A\|\times\|B\|}=\frac{\sum\limits_{i=1}^{n}{A _{i}\times B_{i}}}{\sqrt{\sum\limits_{i=1}^{n}{A_{i}^{2}}}\ \ \ \times\sqrt{\sum\limits_{i=1}^{n}{B_{i}^{2}}}} \tag{3}\]
where A and B are vectors or matrices of diseases with symptoms.
Based on the similarity metrics, K-means clustering algorithm identifies similar diseases. The objective of K-Means clustering is to minimize total intra-cluster variance or the squared error function:
\[J=\sum\limits_{j=1}^{K}{\sum\limits_{n\in\mathcal{S}_{j}}{\left|{x_{n}-\mu_{j} }\right|^{2}}}, \tag{4}\]
where k is a number of clusters, j is a number of instances, \(x_{n}-\mu_{j}\) is an euclidean distance between \(x\) instance and the j\({}^{\text{th}}\) cluster centroid.
The Silhouette score is used to measure the degree of separation between clusters. A score of 1 denotes the best clustering with excellent separation. The value of the silhouette coefficient is between [-1, 1].
\[Silhouette-score=\frac{b_{i}-a_{i}}{\max{(bi,a_{i})}} \tag{5}\]
where \(\mathfrak{a}_{i}\) - average distance between \(i\) and all of other points in its own cluster, \(\mathfrak{b}_{i}\)- distance between \(i\) and its next nearest cluster centroid.
## Results
We first build a network of diseases and symptoms to understand predictability. The network is visualized in Figure 1. The network is modeled to have a diameter of 10, a radius of 5, and an average shortest path length of 4.2. The average disease-symptom linkage degree of the disease-symptom correlation network is 1.882.
We identified common and unusual symptoms based on the symptoms occurring in diseases, as shown in Figure 2. Unusual symptoms were not observed in some diseases, such as Chickenpox, Chronic cholestasis, Heart attack, jaundice, Malaria, Hepatitis A, C, D, and Hyperthyroidism.
Figure 1: Network of disease and symptom relation
The occurrence of symptoms over diseases are estimated in Figure 3. A symptom occurring only in a single disease is 84, a symptom occurring in 2 diseases is 20, and so. Contrary to unusual symptoms, some symptoms occur commonly. For instance, a symptom occurring in 17 diseases is 2.
More than two occurrences of symptoms in the disease are almost 50% of the symptoms. That highlights that most symptoms commonly occur over disease, and ambiguity of diseases is due to the common symptoms. On average, the rate of unusual symptoms occurrence for each disease is around 39.2%, except for the diseases without any unusual symptoms. The diseases with more than 50% of the uniqueness rate of symptoms are predicted relatively well.
Figure 3: a) Occurrence of symptoms over diseases b) Occurrence of unusual symptoms by diseases
Figure 2: Common vs Unusual symptoms occurring in diseases
We trained the disease prediction models that employ CNN and SVM methods in our split data 80/20. The dataset is well-balanced. The performance of the models are evaluated using F1-score, Precision, and Recall. The performance result in macro averaged metrics presented in Table 1 explains the predictability of diseases. Given symptoms, predicting a particular disease is 100% of the F1-score. The evaluation results were relatively good, 98% - 100% considering common and unusual symptoms. These results indicate that machine learning can potentially diagnose diseases in the early stage, taking the characteristics of symptoms into account. Our model outperformed the other experiments [8] using the same dataset, with a 3-5% increase. We also highlight that unusual symptoms increase the accuracy of the disease prediction task. Such a result was also validated by estimating the prediction probabilities of the SVM model on the test data, as shown in Figure 4.
However, understanding common and unusual symptoms are essential in disease prediction tasks; we try to reduce the number of symptoms employing Principal Component Analysis (PCA). Figure 4b shows the
\begin{table}
\begin{tabular}{|c|c|c|c|} \hline Algorithms & F1-score & Precision & Recall \\ \hline SVM (common symptoms) & 98.2\% & 98.4\% & 98\% \\ \hline SVM (common + unusual symptoms) & 99.2\% & 99.2\% & 99.2\% \\ \hline CNN (common symptoms) & 99\% & 99\% & 99\% \\ \hline CNN (common + unusual symptoms) & 100\% & 100\% & 100\% \\ \hline \end{tabular}
\end{table}
Table 1: Evaluation result of machine learning models
Figure 4: a) Predictability rate of SVM b) K-fold cross validation using a reduced number of PCA features
reduced number of symptoms compared to the accuracy of the SVM model. At least four types of symptoms, regardless of common or unusual characteristics, should be defined for each disease to have a predictability rate of more than 91% by a k (k=5) fold cross-validation.
That means if patients can observe at least four types of symptoms, the likelihood of disease diagnosis increases to 91%. However, diseases based on symptoms characteristic were well classified, but we need to understand the ambiguity of common symptoms to refine the classification task. So, identifying similar diseases which show similar symptoms is crucial. By K-means, diseases were clustered based on common symptoms with the use of the cosine distance method for the similarity of diseases. Comparing 41 types of diseases pairwise, 50% of diseases, around 400 pairs, have entirely different symptoms.
Very similar 20 diseases were observed and contained common symptoms among those diseases. The symptoms co-occur, and similarities of diseases increase the risk of misdiagnosing this type of disease, considering only common symptoms. Therefore, it is necessary to conduct a detailed examination using other testing equipment like blood tests, X-rays, CTs, and so. We also validated the result using the K-means clustering algorithm. The K-means method encourages us to identify similar diseases based on common symptoms. We applied K-means clustering with a cosine distance. Figure 5 presents the Silhouette score of K-means on the data containing PCA-reduced symptoms and all symptoms. PCA reduction improved K-means performance as the Silhouette score is higher than 0.5 on the dataset containing PCA-reduced symptoms. The Silhouette score is 0.64 when the optimal cluster number is 6 for the dataset containing PCA-reduced symptoms; the Silhouette score is 0.28 when the optimal cluster number is 7 for the dataset containing all symptoms. From cluster 27, the silhouette score curve became flattened at a score of 0.74.
The result indicates that the dataset containing PCA-reduced symptoms was better classified, and similar diseases were identified. However, the dataset containing all symptoms got a silhouette score of 0.84 at cluster 40. The result explains that most diseases were well separated given the symptoms and why the machine learning method performed well. Table 2 summarizes the result of the K-means clustering.
Figure 5: Silhouette score of K-means clustering
## Conclusions
This study analyzed 41 types of diseases, including 135 common and uncommon symptoms of patients. We can use machine learning methods to diagnose a particular disease given symptoms with 98-100% accuracy. Our results indicate that unusual and uncommon symptoms increase disease prediction accuracy. However, most diseases have common symptoms and could co-occur; it is difficult to understand the crucial features of symptoms. Our results suggest that data reduction techniques allow import features of symptoms by reducing the number of symptoms. In our demonstration, at least four types of symptoms for each disease were sufficient to diagnose a particular disease with more than 91% of accuracy. To analyze the ambiguity of diseases, we need to identify similar diseases based on common symptoms. However, a large dataset is required for analyzing the relationship between diseases and symptoms in a wide range, such as the asynchronous onset of diseases. We will extend this study by using open databases of biomedical protein, molecular, gene, and phenotypic databases and extracting information from clinical article databases (PubMed). The relationship between the clinical manifestations of the disease and their underlying molecular interactions based on symptoms will be explored in detail.
**Acknowledgements: This research was supported by Mongolian Foundation for Science and Technology (MFST), project number "STPICD-2021/475". The study was supported in part by a grant from Irkutsk National Research Technical University. The authors would like to give special thanks to the Mongolian Ministry of Science and Technology, and the Irkutsk National Research Technical University for supporting this research.**
**Competing interests** The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.**
**Patient consent for publication** Not applicable.**
**Data availability statement** Data may be obtained from a third party and are not publicly available.**
**Conflicts of interest:** The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.
|
2310.04412 | FedConv: Enhancing Convolutional Neural Networks for Handling Data
Heterogeneity in Federated Learning | Federated learning (FL) is an emerging paradigm in machine learning, where a
shared model is collaboratively learned using data from multiple devices to
mitigate the risk of data leakage. While recent studies posit that Vision
Transformer (ViT) outperforms Convolutional Neural Networks (CNNs) in
addressing data heterogeneity in FL, the specific architectural components that
underpin this advantage have yet to be elucidated. In this paper, we
systematically investigate the impact of different architectural elements, such
as activation functions and normalization layers, on the performance within
heterogeneous FL. Through rigorous empirical analyses, we are able to offer the
first-of-its-kind general guidance on micro-architecture design principles for
heterogeneous FL.
Intriguingly, our findings indicate that with strategic architectural
modifications, pure CNNs can achieve a level of robustness that either matches
or even exceeds that of ViTs when handling heterogeneous data clients in FL.
Additionally, our approach is compatible with existing FL techniques and
delivers state-of-the-art solutions across a broad spectrum of FL benchmarks.
The code is publicly available at https://github.com/UCSC-VLAA/FedConv | Peiran Xu, Zeyu Wang, Jieru Mei, Liangqiong Qu, Alan Yuille, Cihang Xie, Yuyin Zhou | 2023-10-06T17:57:50Z | http://arxiv.org/abs/2310.04412v1 | FedConv: Enhancing Convolutional Neural Networks for Handling Data Heterogeneity in Federated Learning
###### Abstract
Federated learning (FL) is an emerging paradigm in machine learning, where a shared model is collaboratively learned using data from multiple devices to mitigate the risk of data leakage. While recent studies posit that Vision Transformer (ViT) outperforms Convolutional Neural Networks (CNNs) in addressing data heterogeneity in FL, the specific architectural components that underpin this advantage have yet to be elucidated. In this paper, we systematically investigate the impact of different architectural elements, such as activation functions and normalization layers, on the performance within heterogeneous FL. Through rigorous empirical analyses, we are able to offer the first-of-its-kind general guidance on micro-architecture design principles for heterogeneous FL.
Intriguingly, our findings indicate that with strategic architectural modifications, pure CNNs can achieve a level of robustness that either matches or even exceeds that of ViTs when handling heterogeneous data clients in FL. Additionally, our approach is compatible with existing FL techniques and delivers state-of-the-art solutions across a broad spectrum of FL benchmarks. The code is publicly available at [https://github.com/UCSC-VLAA/FedConv](https://github.com/UCSC-VLAA/FedConv).
## 1 Introduction
Federated Learning (FL) is an emerging paradigm that holds significant potential in safeguarding user data privacy in a variety of real-world applications, such as mobile edge computing (Li et al., 2020). Yet, one of the biggest challenges in FL is data heterogeneity, making it difficult to develop a single shared model that can generalize well across all local devices. While numerous solutions have been proposed to enhance heterogeneous FL from an optimization standpoint (Li et al., 2020; Hsu et al., 2019), the recent work by Qu et al. (2022) highlights that the selection of neural architectures also plays a crucial role in addressing this challenge. This study delves into the comparative strengths of Vision Transformers (ViTs) vis-a-vis Convolutional Neural Networks (CNNs) within the FL context and posits that the performance disparity between ViTs and CNNs amplifies with increasing data heterogeneity.
The analysis provided in Qu et al. (2022), while insightful, primarily operates at a macro level, leaving certain nuances of neural architectures unexplored. Specifically, the interplay between individual architectural elements in ViT and its robustness to heterogeneous data in FL remains unclear. While recent studies (Bai et al., 2021; Zhang et al., 2022) suggest that self-attention-block is the main building block that contributes significantly to ViT's robustness against out-of-distribution data, its applicability to other settings, particularly heterogeneous FL, is yet to be ascertained. This gap in understanding prompts us to consider the following questions: _which architectural elements in ViT underpin its superior performance in heterogeneous FL, and as a step further, can CNNs benefit from incorporating these architectural elements to improve their performance in this scenario?_
To this end, we take a closer analysis of the architectural elements of ViTs, and empirically uncover several key designs for improving model robustness against heterogeneous data in FL. First, we note the design of activation functions matters, concluding that smooth and near-zero-centered activation functions consistently yield substantial improvements. Second, simplifying the architecture by completely removing all normalization layers and retraining a single activation function in each
block emerges as a beneficial design. Third, we reveal two key properties -- feature extraction from overlapping patches and convolutions only for downsampling -- that define a robust stem layer for handling diverse input data. Lastly, we critically observe that a large enough kernel size (_i.e._, 9) is essential in securing model robustness against heterogeneous distributions.
Our experiments extensively verify the consistent improvements brought by these architectural designs in the context of heterogeneous FL. Specifically, by integrating these designs, we are able to build a self-attention-free CNN architecture, dubbed FedConv, that outperforms established models, including ViT (Dosovitskiy et al., 2020), Swin-Transformer (Liu et al., 2021), and ConvNeXt(Liu et al., 2022). Notably, our FedConv achieves 92.21% accuracy on COVID-FL and 54.19% on iNatural, outperforming the next-best solutions by 2.57% and 13.89%, respectively. Moreover, our FedConv can effectively generalize to other datasets with varying numbers of data clients, from as few as 5 to more than 2,000; when combined with existing FL methods, our FedConv consistently registers new performance records across a range of FL benchmarks.
In conclusion, our findings shed light on the pivotal role of architecture configuration in robustifying CNNs for heterogeneous FL. We hope that our insights will inspire the community to further probe the significance of architectural nuances in different FL settings.
## 2 Related Works
**Federated Learning.** FL is a decentralized approach that aims to learn a shared model by aggregating updates or parameters from locally distributed training data (McMahan et al., 2017). However, one of the key challenges in FL is the presence of data heterogeneity, or varying distribution of training data across clients, which has been shown to cause weight divergence (Zhao et al., 2018) and other optimization issues (Hsieh et al., 2020) in FL.
To address this challenge, FedProx (Li et al., 2020c) adds a proximal term in the loss function to achieve more stable and accurate convergence; FedAVG-Share (Zhao et al., 2018) keeps a small globally-shared subset amongst devices; SCAFFOLD (Karimireddy et al., 2020) introduces a variable to both estimate and correct update direction of each client. Beyond these, several other techniques have been explored in heterogeneous FL, including reinforcement learning (Wang et al., 2020a), hierarchical clustering (Briggs et al., 2020), knowledge distillation (Zhu et al., 2021; Li and Wang, 2019; Qu et al., 2022a), and self-supervised learning (Yan et al., 2023; Zhang et al., 2021).
Recently, a new perspective for improving heterogeneous FL is by designing novel neural architectures. Li et al. (2021) points out that updating only non-BatchNorm (BN) layers significantly enhances FedAVG performance, while Du et al. (2022) suggests that simply replacing BN with LayerNorm (LN) can mitigate external covariate shifts and accelerate convergence. Wang et al. (2020b) shows neuron permutation matters when averaging model weights from different clients. Our research draws inspiration from Qu et al. (2022b), which shows that Transformers are inherently stronger than CNNs in handling data heterogeneity (Qu et al., 2022b). Yet, we come to a completely different conclusion: with the right architecture designs, CNNs can be comparable to, or even more robust than, Transformers in the context of heterogeneous FL.
**Vision Transformer.** CNNs have been the dominant architecture in visual recognition for nearly a decade due to their superior performance (Simonyan and Zisserman, 2014; He et al., 2016; Szegedy et al., 2016; Howard et al., 2017; Tan and Le, 2019). However, the recently emerged ViTs challenge the leading position of CNNs (Dosovitskiy et al., 2020; Touvron et al., 2021a;b; Liu et al., 2021) -- by applying a stack of global self-attention blocks (Vaswani et al., 2017) on a sequence
Figure 1: Performance comparison on three heterogeneous FL datasets. While a vanilla ResNet significantly underperforms Transformers and ConvNeXt when facing data heterogeneity, our enhanced CNN model, named FedConv, consistently achieves superior performance.
of image patches, Transformers can even show stronger performance than CNNs in a range of visual benchmarks, especially when a huge amount of training data is available (Dosovitskiy et al., 2020; Touvron et al., 2021; Liu et al., 2021; He et al., 2022). Additionally, Transformers are shown to be inherently more robust than CNNs against occlusions, adversarial perturbation, and out-of-distribution corruptions (Bhojanapalli et al., 2021; Bai et al., 2021; Zhang et al., 2022; Paul and Chen, 2022).
**Modernized CNN.** Recent works also reignite the discussion on whether CNNs can still be the preferred architecture for visual recognition. Wightman et al. (2021) find that by simply changing to an advanced training recipe, the classic ResNet-50 achieves a remarkable 4% improvement on ImageNet, a performance that is comparable to its DeiT counterpart (Touvron et al., 2021). ConvMixer (Trockman and Kolter, 2022), on the other hand, integrates the patchify stem setup into CNNs, yielding competitive performance with Transformers. Furthermore, ConvNeXt (Liu et al., 2022) shows that, by aggressively incorporating every applicable architectural design from Transformer, even the pure CNN can attain excessively strong performance across a variety of visual tasks.
Our work is closely related to ConvNeXt (Liu et al., 2022). However, in contrast to their design philosophy which aims to build Transformer-like CNNs, our goal is to pinpoint a core set of architectural elements that can enhance CNNs, particularly in the context of heterogeneous FL.
## 3 FedConv
In this section, we conduct a comprehensive analysis of several architectural elements in heterogeneous FL. Our findings suggest that pure CNNs can achieve comparable or even superior performance in heterogeneous FL when incorporating specific architectural designs. Key designs including switching to smooth and near-zero-centered activation functions in Section 3.2, reducing activation and normalization layers in Section 3.3, adopting the stem layer setup in Section 3.4, and enlarging the kernel size in Section 3.5. By combining these designs, we develop a novel CNN architecture, **FedConv**. As demonstrated in Section 3.6, this architecture emerges as a simple yet effective alternative to handle heterogeneous data in FL.
### Experiment Setup
**Datasets.** Our main dataset is COVID-FL (Yan et al., 2023), a real-world medical FL dataset containing 20,055 medical images, sourced from 12 hospitals. Note that clients (_i.e._, hospital) in this dataset are characterized by the absence of one or more classes. This absence induces pronounced data heterogeneity in FL, driven both by the limited overlap in client partitions and the imbalanced distribution of labels. To provide a comprehensive assessment of our approach, we report performance in both the centralized training setting and the distributed FL setting.
**Federated learning methods.** We consider the classic Federated Averaging (FedAVG) (McMahan et al., 2017) as the default FL method, unless specified otherwise. FedAVG operates as follows: 1) the global server model is initially sent to local clients; 2) these clients next engage in multiple rounds of local updates with their local data; 3) once updated, these models are sent back to the server, where they are averaged to create an updated global model.
**Training recipe.** All models are first pre-trained on ImageNet using the recipe provided in (Liu et al., 2022), and then get finetuned on COVID-FL using FedAVG. Specifically, in fine-tuning, we set the base learning rate to 1.75e-4 with a cosine learning rate scheduler, weight decay to 0.05, batch size to 64, and warmp epoch to 5. Following (Qu et al., 2022; Yan et al., 2023), we apply AdamW optimizer (Loshchilov and Hutter, 2017) to each local client and maintain their momentum term locally. For FedAVG, we set the total communication round to 100, with a local training epoch of 1. Note that all 12 clients are included in every communication round.
**Computational cost.** We hereby use FLOPs as the metric to measure the model scale. To ensure a fair comparison, all models considered in this study are intentionally calibrated to align with the FLOPs scale of ViT-Small (Dosovitskiy et al., 2020), unless specified otherwise.
To improve the performance-to-cost ratio of our models, we pivot from the conventional convolution operation in ResNet, opting instead for depth-wise convolution. This method, as corroborated by prior research (Howard et al., 2017; Sandler et al., 2018; Howard et al., 2019; Tan and Le, 2019),
exhibits a better balance between performance and computational cost. Additionally, following the design philosophy of ResNeXt (Xie et al., 2017), we adjust the base channel configuration across stages, transitioning from (64, 128, 256, 512) to (96, 192, 384, 768); we further calibrate the block number to keep the total FLOPs closely align with the ViT-Small scale.
**An improved ResNet baseline.** Building upon the adoption of depth-wise convolutions, we demonstrate that further incorporating two simple architectural elements from ViT enables us to build a much stronger ResNet baseline. Firstly, we replace BN with LN. This shift is motivated by prior studies which reveal the adverse effects of maintaining the EMA of batch-averaged feature statistics in heterogeneous FL (Li et al., 2021; Du et al., 2022); instead, they advocate that batch-independent normalization techniques like LN can improve both the performance and convergence speed of the global model (Du et al., 2022). Secondly, we replace the traditional ReLU activation function with GELU (Hendrycks and Gimpel, 2016). As discussed in Section 3.2, this change can substantially increase the classification accuracy in COVID-FL by 4.52%, from 72.92% to 77.44%.
We refer to the model resulting from these changes as **ResNet-M**, which will serve as the default baseline for our subsequent experiments. However, a critical observation is that, despite its enhancements, the accuracy of ResNet-M still lags notably behind its Transformer counterpart in heterogeneous FL, which registers a much higher accuracy at 88.38%.
### Activation function
We hereby investigate the impact of activation function selection on model performance in the context of heterogeneous FL. Our exploration begins with GELU, the default activation function in Transformers (Dosovitskiy et al., 2020; Touvron et al., 2021; Liu et al., 2021). Previous studies show that GELU consistently outperforms ReLU in terms of both clean accuracy and adversarial robustness (Hendrycks and Gimpel, 2016; Elfwing et al., 2018; Clevert et al., 2016; Xie et al., 2020). In our assessment of GELU's efficacy for heterogeneous FL, we observe a similar conclusion: as shown in Table 1, replacing ReLU with GELU can lead to a significant accuracy improvement of 4.52% in COVID-FL, from 72.92% to 77.44%.
Building upon the insights from (Xie et al., 2020), we next explore the generalization of this improvement to smooth activation functions, which are defined as being \(\mathcal{C}^{1}\) smooth. Specifically, we assess five activation functions: two that are non-smooth (Parametric Rectified Linear Unit (PReLU) (He et al., 2015) and Leaky ReLU (LReLU)), and three that are smooth (SoftPlus (Dugas et al., 2000), Exponential Linear Unit (ELU) (Clevert et al., 2016), and Sigmoid Linear Unit (SiLU) (Elfwing et al., 2018)). The curves of these activation functions are shown in Figure 2, and their performance on COVID-FL is reported in Table 1. Our results show that smooth activation functions generally outperform their non-smooth counterparts in heterogeneous FL. Notably, both SiLU and ELU achieve an accuracy surpassing 78%, markedly superior to the accuracy of LReLU (73.41%) and PReLU (74.24%). Yet, there is an anomaly in our findings: SoftPlus, when replacing ReLU, fails to show a notable improvement. This suggests that _smoothness alone is not sufficient for achieving strong performance in heterogeneous FL._
With a closer look at these smooth activation functions, we note a key difference between SoftPlus and the others: while SoftPlus consistently yields positive outputs, the other three (GELU, SiLU, and ELU) can produce negative values for certain input ranges, potentially facilitating outputs that
\begin{table}
\begin{tabular}{c|c c|c} \hline Activation & Central & FL & Mean Act \\ \hline ReLU & 95.59 & 72.92 & 0.28 \\ \hline LReLU & 95.54 & 73.41 & 0.26 \\ PReLU & 95.41 & 74.24 & 0.20 \\ \hline SoftPlus & 95.28 & 73.86 & 0.70 \\ GELU - & 95.82 & 77.44 & 0.07 \\ SiLU & 95.81 & 79.52 & 0.04 \\ ELU & 95.59 & 78.25 & -0.07 \\ \hline \end{tabular}
\end{table}
Table 1: A study on the effect of various activation functions.
Figure 2: Plots of various activation function curves.
are more centered around zero. To quantitatively characterize this difference, we calculate the mean activation values of ResNet-M across all layers when presented with COVID-FL data. As noted in the "Mean" column of Table 1, GELU, SiLU, and ELU consistently hold mean activation values close to zero, while other activation functions exhibit a much larger deviations from zero. These empirical results lead us to conclude that utilizing a **smooth and near-zero-centered** activation function is advantageous in heterogeneous FL.
### Reducing activation and normalization layers
Transformer blocks, in contrast to traditional CNN blocks, generally incorporate fewer activation and normalization layers (Dosovitskiy et al., 2020; Touvron et al., 2021; Liu et al., 2021). Prior works show that CNNs can remain stable or even attain higher performance with fewer activation layers (Liu et al., 2022) or without normalization layers (Brock et al., 2021). In this section, we delve into this design choice in the context of heterogeneous FL.
Drawing inspiration from ConvNeXt, we evaluate three different block instantiations: 1) _Normal Block_, which serves as the basic building block of our ResNet-M baseline; 2) _Invert Block_, originally proposed in (Sandler et al., 2018), which has a hidden dimension that is four times the size of the input dimension; and 3) _InvertUp Block_, which modifies Invert Block by repositioning the depth-wise convolution to the top of the block. The detailed block configurations is illustrated in Figure 3. Notably, regardless of the specific block configuration employed, we always ensure similar FLOPs across models by adjusting the number of blocks.
**Reducing activation layers.** We begin our experiments by aggressively reducing the number of activation layers. Specifically, we retain only one activation layer in each block to sustain nonlinearity. As highlighted in Table 1(a), all three block designs showcase at least one configuration that delivers substantial performance gains in heterogeneous FL. For example, the best configurations yield an improvement of 6.89% for Normal Block (from 77.44% to 84.33%), 3.77% for Invert Block (from 80.35% to 84.12%), and 1.48% for InvertUp Block (from 80.96% to 82.44%). More intriguingly, a simple rule-of-thumb design principle emerges for these best configurations: the activation function is most effective when placed subsequent to the channel-expanding convolution layer, whose output channel dimension is larger than its input dimension.
**Reducing normalization layers.** Building upon our experiments above with only one best-positioned activation layer, we further investigate the impact of aggressively removing normalization layers. Similarly, we hereby are interested in keeping only one normalization layer in each block. As presented in Table 2, we observe that the effects of removing normalization layers are highly block-dependent in heterogeneous FL: it consistently hurts Normal Block, leads to improvements for the Invert Block (up to +2.07%), and consistently enhances InvertUP block (up to +3.26%).
**Normalization-free setup.** Another interesting direction to explore is by removing all normalization layers from our models. This is motivated by recent studies that demonstrate high-performance visual recognition with normalization-free CNNs (Brock et al., 2021; 20). To achieve this, we train normalization-free networks using the Adaptive Gradient Clipping (AGC) technique, following (Brock et al., 2021). The results are presented in Table 2. Surprisingly, we observe that these normalization-free variants are able to achieve competitive performance compared to their best counterparts with only one activation layer and one normalization layer, _e.g._, 82.50% _vs._ 82.33% for Normal Block, 84.63% _vs._ 86.19% for Invert Block, and 85.65% _vs._ 85.70% for InvertUP Block.
Figure 3: Block architecture details.
Additionally, a normalization-free setup offers practical advantages such as faster training speed (Singh and Shrivastava, 2019) and reduced GPU memory overhead (Bulo et al., 2018). In our context, compared to the vanilla block instantiations, removing normalization layers leads to a 28.5% acceleration in training, a 38.8% cut in GPU memory, and conveniently bypasses the need to determine the best strategy for reducing normalization layers.
Moreover, our proposed normalization-free approach is particularly noteworthy for its superior performance compared to FedBN (Li et al., 2021) (see supplementary material), a widely acknowledged normalization technique in FL. While FedBN decentralizes normalization across multiple clients, ours outperforms it by completely eliminating normalization layers. These findings invite a reevaluation of "already extensively discussed" normalization layers in heterogeneous FL.
### Stem layer
CNNs and Transformers adopt different pipelines to process input data, which is known as the _stem_. Typically, CNNs employ a stack of convolutions to downsample images into desired-sized feature maps, while Transformers use patchify layers to directly divide images into a set of tokens. To better understand the impact of the stem layer in heterogeneous FL, we comparatively study diverse stem designs, including the default ResNet-stem, Swin-stem, and ConvStem inspired by (Xiao et al., 2021). A visualization of these stem designs is provided in Figure 4, and the empirical results are reported in Table 3. We note that 1) both Swin-stem and ConvStem outperform the vanilla ResNet-stem baseline, and 2) ConvStem attains the best performance. Next, we probe potential enhancements to ResNet-stem and Swin-stem by leveraging the "advanced" designs in ConvStem.
**Overlapping convolution.** We first investigate the performance gap between Swin-stem and ConvStem. We posit that the crux of this gap might be attributed to the variation in patch overlapping. Specifically, Swin-stem employs a convolution layer with a stride of 4 and a kernel size of 4, thereby extracting features from non-overlapping patches; while ConvStem resorts to overlapping convolu
\begin{table}
\begin{tabular}{c|c|c|c} \hline Block & Act & Normal & Central & FL \\ \hline \multirow{4}{*}{Normal} & Act3 & All & 95.89 & 84.33 \\ & Act5 & Norm & 95.84 & 82.06 \\ & Act3 & Norm & 95.36 & 82.33 \\ & Act3 & Norm & 95.34 & 81.36 \\ & Act3 & No Norm & 95.29 & 82.50 \\ \hline \multirow{4}{*}{Invert} & Act1 & All & 96.19 & 84.12 \\ & Act1 & Norm & 96.19 & 84.12 \\ & Act1 & Norm & 96.04 & 83.02 \\ & Act1 & Norm & 95.59 & 86.19 \\ & Act1 & No Norm & 95.94 & 84.63 \\ \hline \multirow{4}{*}{InvertUp} & Act2 & All & 95.71 & 82.44 \\ & Act2 & Norm & 95.64 & 83.46 \\ & Act2 & Norm & 95.71 & 85.70 \\ \cline{1-1} & Act2 & No Norm & 95.74 & 85.65 \\ \hline \end{tabular}
\end{table}
Table 2: (a) Analysis of the effect of reducing activation functions. “ActX” refers to the block that only keeps the activation layer after the Xth convolution layer. “All” refers to keeping all activation layers within the block. (b) Analysis of the effect of reducing normalization functions. “NormY” refers to the block that only keeps the normalization layer after the Yth convolution layer. “No Norm” refers to removing all normalization layers within the block.
Figure 4: Illustration of different stem setups, including ResNet-stem, Swin-stem and ConvStem. ’s’ denotes the stride of convolution.
tions, which inherently bring in adjacent gradient consistency and spatial smoothness (Graham et al., 2021). To validate our hypothesis, we modify the Swin-stem by increasing the kernel size to 5 while retaining a stride of 4. This seemingly modest alteration yielded a marked performance enhancement of +3.32% (from 79.44% to 82.76%), confirming the pivotal role of overlapping convolutions within stem layers in heterogeneous FL.
**Convolutions-only downsampling.** ResNet-stem, despite its employment of a 7\(\times\)7 convolution layer with a stride of 2 -- thereby extracting features from overlapped patches -- remarkably lags behind Swin-stem in performance. A noteworthy distinction lies in the ResNet-stem's integration of an additional max-pooling layer to facilitate part of its downsampling; while both Swin-stem and ConvStem exclusively rely on convolution layers for this purpose. To understand the role of the max-pooling layer within ResNet-stem, we remove it and adjust the stride of the initial convolution layer from 2 to 4. As shown in Table 3, this modification, dubbed "ResNet-stem (No MaxPool)", registers an impressive 5.15% absolute accuracy improvement over the vanilla ResNet-stem. This observation suggests that employing convolutions alone (hence no pooling layers) for downsampling is important in heterogeneous FL.
In summary, our analysis highlights the significance of the stem layer's design in securing model performance in heterogeneous FL. Specifically, two key factors are identified, _i.e._, the stem layer needs to extract features from overlapping patches and employs convolutions only for downsampling.
### Kernel Size
Global self-attention is generally recognized as a critical factor that contributes to the robustness of ViT across diverse data distributions in FL (Qu et al., 2022b). Motivated by this, we explore whether augmenting the receptive field of a CNN- by increasing its kernel size -- can enhance this robustness. As depicted in Figure 5, increasing the kernel size directly corresponds to significant accuracy improvements in heterogeneous FL. The largest improvement is achieved with a kernel size of 9, elevating accuracy by 6.95% over the baseline model with a kernel size of 3 (_i.e._, 84.39% _vs._ 77.44%). It is worth noting, however, that pushing the kernel size beyond 9 ceases to yield further performance enhancements and might, in fact, detract from accuracy.
### Component combination
We now introduce FedConv, a novel CNN architecture designed to robustly handle heterogeneous clients in FL. Originating from our ResNet-M baseline model, FedConv incorporates five pivotal design elements, including _SiLU activation function_, _retraining only one activation function per block_, _normalization-free setup_, _ConvStem_, and _a large kernel size of 9_. By building upon three distinct instantiations of CNN blocks (as illustrated in Figure 3), we term the resulting models as FedConv-Normal, FedConv-Invert, and FedConv-InvertUp.
Our empirical results demonstrate that these seemingly simple architectural designs collectively lead to a significant performance improvement in heterogeneous FL. As shown in Table 4, FedConv models achieve the best performance, surpassing strong competitors such as ViT, Swin-Transformer, and ConvNeXt. The standout performer, FedConv-InvertUp, records the highest accuracy of 92.21%, outperforming the prior art, ConvNeXt, by 2.64%. These outcomes compellingly contest the assertions in (Qu et al., 2022b), highlighting that a pure CNN architecture can be a competitive alternative to ViT in heterogeneous FL scenarios.
\begin{table}
\begin{tabular}{c|c c} \hline \hline Stem & Central & FL \\ \hline ResNet-stem & 95.82 & 77.44 \\ \hline Swin-stem & 95.61 & 79.44 \\ ConvStem & 95.26 & **83.01** \\ \hline Swin-stem (Kernel Size 5) & 95.64 & 82.76 \\ ResNet-stem (No MaxPool) & 95.76 & 82.59 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Analysis of the effect of various stem layers. “(Kernel Size 5)” denotes using a kernel size of 5 in convolution. “(No MaxPool)” denotes removing the max-pooling layer and increasing the stride of the first convolution layer accordingly.
Figure 5: The study on the effect of different kernel sizes.
## 4 Generalization and Practical Implications
In this section, we assess the generalization ability and communication costs of FedConv, both of which are critical metrics for real-world deployments. To facilitate our analysis, we choose FedConv-InvertUp, our top-performing variant, to serve as the default model for our ablation study.
### Generalizing to other Datasets
To assess the generalizability of our model, we evaluate its performance on two additional heterogeneous FL datasets: CIFAR-10 (Krizhevsky et al., 2009) and iNaturalist (Van Horn et al., 2018).
**CIFAR-10.** Following (Qu et al., 2022b), we use the original test set as our validation set, and the training set is divided into five parts, with each part representing one client. Leveraging the mean Kolmogorov-Smirnov (KS) statistic to measure distribution variations between pairs of clients, we create three partitions, each representing different levels of label distribution skewness: split-1 (KS=0, representing an IID set), split-2 (KS=0.49), and split-3 (KS=0.57).
**iNaturalist.** iNaturalist is a large-scale fine-grained visual classification dataset, containing natural images taken by citizen scientists (Hsu et al., 2020). For our analysis, we use a federated version, iNature, sourced from FedScale (Lai et al., 2021). This version includes 193K images from 2295 clients, of which 1901 are in the training set and the remaining 394 are in the validation set.
Table 5 reports the performance on CIFAR-10 and iNaturalist datasets. As data heterogeneity increases from split1 to split3 on CIFAR-10, while FedConv only experiences a modest accuracy drop of 1.85%, other models drop the accuracy by at least 2.35%. On iNaturalist, FedConv impressively achieves an accuracy of 54.19%, surpassing the runner-up, ViT-Small, by more than 10%. These results confirm the strong generalization ability of FedConv in highly heterogeneous FL settings.
### Generalizing to other FL Methods
We next evaluate our model with different FL methods, namely FedProx (Li et al., 2020c), FedAVG-Share (Zhao et al., 2018), and FedYogi (Reddi et al., 2020). FedProx introduces a proximal term to estimate and restrict the impact of the local model on the global model; FedAVG-Share utilizes a
\begin{table}
\begin{tabular}{c c|c c} \hline \hline Model & FLOPs & Central & FL \\ \hline ResNet50 & 4.1G & 95.66 & 73.61 \\ ResNet-M & 4.6G & 95.82 & 77.44 \\ \hline Swin-Tiny & 4.5G & 95.74 & 88.38 \\ ViT-Small & 4.6G & 95.86 & 84.89 \\ ConvNeXt-Tiny & 4.5G & 96.01 & 89.57 \\ \hline FedConv-Normal & 4.6G & 95.84 & 90.61 \\ FedConv-Invert & 4.6G & 96.19 & 91.68 \\ FedConv-InvertUp & 4.6G & 96.04 & 92.21 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Performance comparison on COVID-FL. By incorporating architectural elements such as SiLU activation function, retaining only one activation function, the normalization-free setup, ConvStem, and a large kernel size of 9, our FedConv models consistently outperform other advanced solutions in heterogeneous FL.
\begin{table}
\begin{tabular}{c|c c c c|c} \hline \hline \multirow{2}{*}{Model} & \multicolumn{4}{c|}{CIFAR-10} & \multicolumn{2}{c}{iNaturalist} \\ \cline{2-5} & Central & Split-1 & Split-2 & Split-3 & FL \\ \hline ResNet50 & 97.47 & 96.69 & 95.56 & 87.43 & 12.61 \\ \hline Swin-Tiny & 98.31 & 98.36 & 97.83 & 95.22 & 24.57 \\ ViT-Small & 97.99 & 98.24 & 97.84 & 95.64 & 40.30 \\ ConvNeXt-Tiny & 98.31 & 98.20 & 97.67 & 95.85 & 22.53 \\ \hline FedConv-InvertUp & 98.42 & 98.11 & 97.74 & 96.26 & 54.19 \\ \hline \hline \end{tabular}
\end{table}
Table 5: Performance comparison on CIFAR-10 and iNaturalist. Our FedConv model consistently outperforms other models. Notably, as data heterogeneity increases, FedConv’s strong generalization becomes more evident.
globally shared dataset to collect data from each client for local model updating; FedYogi incorporates the adaptive optimization technique Yogi (Zaheer et al., 2018) into the FL context.
The results, as reported in Table 6, consistently highlight the superior performance of our FedConv model across these diverse FL methods. This observation underscores FedConv's potential to enhance a wide range of heterogeneous FL methods, enabling seamless integration and suggesting its promise for further performance improvements.
### Communication Cost
In FL, communication can be a major bottleneck due to the inherent complications of coordinating numerous devices. The process of client communication is often more time-consuming than local model updates, thereby emerging as a significant challenge in FL (Van Berkel, 2009). The total number of communication rounds and the size of the messages transmitted during each round are key factors in determining the communication efficiency (Li et al., 2020). To comprehensively evaluate these aspects, we follow the methodology proposed in (Qu et al., 2022). Specifically, we record the number of communication rounds required for different models to achieve a preset accuracy threshold. Additionally, we use Transmitted Message Size (TMS), which is calculated by multiplying the number of model parameters with the associated communication rounds, to quantify communication costs.
As shown in Figure 6, our FedConv-InvertUp achieves the fastest convergence speed among all models. In CIFAR-10 split3, where high data heterogeneity exists, FedConv-InvertUp only needs 4 communication rounds to achieve the target accuracy of 90%, while ConvNeXt necessitates 7 rounds. This efficiency also translates to a marked reduction in TMS in FL, as reported in Table 7. In contrast, ResNet struggles to converge to the 90% accuracy threshold in the CIFAR-10 split3 setting. These results demonstrate the effectiveness of our proposed FedConv architecture in reducing communication costs and improving the overall FL performance.
## 5 Conclusion
In this paper, we conduct a comprehensive investigation of several architectural elements in ViT, showing those elements that, when integrated into CNNs, substantially enhance their performance in heterogeneous FL. Moreover, by combining these architectural modifications, we succeed in building a pure CNN architecture that can consistently match or even outperform ViT in a range of heterogeneous FL settings. We hope that our proposed FedConv can serve as a strong baseline, catalyzing further innovations in FL research.
\begin{table}
\begin{tabular}{c|c c c} \hline Model & FedProx & Share & FedYogi \\ \hline ResNet50 & 72.92 & 92.43 & 66.01 \\ ViT-Small & 87.07 & 93.89 & 87.69 \\ Swin-Tiny & 87.74 & 94.02 & 91.86 \\ ConvNeXt-Tiny & 89.35 & 95.11 & 92.46 \\ \hline FedConv-InvertUp & 92.11 & 95.23 & 93.10 \\ \hline \end{tabular}
\end{table}
Table 6: Performance comparison with different FL methods on COVID-FL. ‘Share’ denotes ‘FedAVG-Share’. We note our FedConv consistently shows superior performance.
\begin{table}
\begin{tabular}{c|c c c c c} \hline Model & ResNet50 & Swin-Tiny & ViT-Small & ConvNext-Tiny & FedConv-InvertUp \\ \hline TMS & \(\infty\) & 27.5M\(\times\)10 & 21.7M\(\times\)11 & 27.8M\(\times\)8 & 25.6M\(\times\)5 \\ \hline \end{tabular}
\end{table}
Table 7: Comparison based on TMS. TMS is calculated by multiplying the number of model parameters with the communication rounds needed to attain the target accuracy. We note our FedConv requires the lowest TMS to reach the target accuracy.
## Acknowledgements
This work is supported by a gift from Open Philanthropy, TPU Research Cloud Program, and Google Cloud Research Credits program.
|
2303.13056 | Predicting the Initial Conditions of the Universe using a Deterministic
Neural Network | Finding the initial conditions that led to the current state of the universe
is challenging because it involves searching over an intractable input space of
initial conditions, along with modeling their evolution via tools such as
N-body simulations which are computationally expensive. Recently, deep learning
has emerged as a surrogate for N-body simulations by directly learning the
mapping between the linear input of an N-body simulation and the final
nonlinear output from the simulation, significantly accelerating the forward
modeling. However, this still does not reduce the search space for initial
conditions. In this work, we pioneer the use of a deterministic convolutional
neural network for learning the reverse mapping and show that it accurately
recovers the initial linear displacement field over a wide range of scales
($<1$-$2\%$ error up to nearly $k\simeq0.8$-$0.9 \text{ Mpc}^{-1}h$), despite
the one-to-many mapping of the inverse problem (due to the divergent backward
trajectories at smaller scales). Specifically, we train a V-Net architecture,
which outputs the linear displacement of an N-body simulation, given the
nonlinear displacement at redshift $z=0$ and the cosmological parameters. The
results of our method suggest that a simple deterministic neural network is
sufficient for accurately approximating the initial linear states, potentially
obviating the need for the more complex and computationally demanding backward
modeling methods that were recently proposed. | Vaibhav Jindal, Albert Liang, Aarti Singh, Shirley Ho, Drew Jamieson | 2023-03-23T06:04:36Z | http://arxiv.org/abs/2303.13056v2 | # Predicting the Initial Conditions of the Universe using Deep Learning
###### Abstract
Finding the initial conditions that led to the current state of the universe is challenging because it involves searching over a vast input space of initial conditions, along with modeling their evolution via tools such as N-body simulations which are computationally expensive. Deep learning has emerged as an alternate modeling tool that can learn the mapping between the linear input of an N-body simulation and the final nonlinear displacements at redshift zero, which can significantly accelerate the forward modeling. However, this does not help reduce the search space for initial conditions. In this paper, we demonstrate for the first time that a deep learning model can be trained for the reverse mapping. We train a V-Net based convolutional neural network, which outputs the linear displacement of an N-body system, given the current time nonlinear displacement and the cosmological parameters of the system. We demonstrate that this neural network accurately recovers the initial linear displacement field over a wide range of scales (\(<1\)-\(2\%\) error up to nearly \(k=1\ \mathrm{Mpc}^{-1}\,h\)), despite the ill-defined nature of the inverse problem at smaller scales. Specifically, smaller scales are dominated by nonlinear effects which makes the backward dynamics much more susceptible to numerical and computational errors leading to highly divergent backward trajectories and a one-to-many backward mapping. The results of our method motivate that neural network based models can act as good approximators of the initial linear states and their predictions can serve as good starting points for sampling-based methods to infer the initial states of the universe.
Machine Learning Department, Carnegie Mellon University, Pittsburgh, PA, USA \({}^{2}\)Max Plank Institute for Astrophysics, Garching, Germany \({}^{3}\)Center for Computational Astrophysics, Flatiron Institute, New York, NY, USA; \({}^{4}\)Department of Physics & Center for Data Science, New York University, New York, NY, USA; \({}^{5}\)Department of Astrophysical Sciences, Princeton University, Princeton, USA; Correspondence to: Aarti Singh \(<\)[email protected]\(>\), Shirley Ho \(<\)[email protected]\(>\).
## 1 Introduction
The evolution of our universe can be uniquely determined by its initial conditions and the laws of physics governing its dynamics. To understand this cosmic history, astrophysicists use a large number of surveys (Amendola et al., 2018; Eisenstein et al., 2011; Spergel et al., 2015) and simulations (Springel et al., 2001; Bagla, 2002; Villaescusa-Navarro et al., 2020). These simulations compute the gravitational evolution of a system of N-body particles given a set of nearly uniform and typically Gaussian initial conditions, representing the early universe. These forward simulations, however, are computationally expensive and require a large amount of time and computational resources.
In recent years, deep-learning techniques have been shown to be extremely helpful in accelerating the forward modeling process (He et al., 2019; Jamieson et al., 2022). These deep-learning models learn the mapping between pairs of inputs and outputs from numerical N-body simulations and act as fast and accurate approximators for these simulators. These deep-learning surrogates speed up the forward modeling process by several orders of magnitude. Since neural networks are theoretically proven to be universal function approximators (Hornik et al., 1989), the forward modeling of N-body simulations fits perfectly into the regime of neural networks.
The problem of inferring the initial state of the universe, or the input to an N-body simulation that generates a specific redshift zero (current time) nonlinear displacement field, is an inverse problem and poses a completely different challenge. Inverse problems are hard as they require a search over a large space of input configurations (the potential initial conditions of the universe), and typically involve one-to-many mapping if learned as a reverse mapping. Standard neural networks are one-to-one mappings, and not expected to work well in these problems. Sampling approaches such as Hamiltonian Monte Carlo (Radford, 2012) based on Bayesian priors are computationally very expensive. One could resort to more complex generative neural networks such as generative adversarial networks (GANs) (Goodfellow et al., 2014), normalizing flows (Rezende & Mohamed, 2015), diffusion models (Sohl-Dickstein et al., 2015; Ho et al., 2020), etc. but they often either fail to converge, are unstable, or require excessive computational
time (cf. Che et al., 2016; Chen et al., 2023; Salimans & Ho, 2022).
Importantly, simulations in scientific fields such as cosmology are often deterministic, and therefore they are reversible in principle. The one-to-many backward problem arises primarily due to numerical and computational errors which get exacerbated only at small scales which are dominated by nonlinear effects. This can cause the backward trajectories to be highly divergent. This motivates the approach we demonstrate here: training a standard deterministic neural network to learn the reverse map and output the initial states of cosmological N-body simulations using the final state of displacements as input. We show that despite the one-to-many nature of the reverse mapping at small scales, a simple neural network can do an excellent job of predicting the initial states not only at large scales but even down to relatively small scales (\(k>0.1\ \mathrm{Mpc}^{-1}\,h\)) where the nonlinear dynamics of gravitational clustering become important. Our model continues to have \(<1-2\%\) error down to \(k=0.8\)-\(0.9\ \mathrm{Mpc}^{-1}\,h\). The inverse model we train is only slightly less accurate than the forward model based on the same architecture (Jamieson et al., 2022). Our results empirically motivate the use of neural networks as approximate inverse-mapping black boxes that could generate reliable initial states for a given output state, which could then be used to speed up the more fine-grained sampling-based inverse modeling methods.
## 2 Background
Consider an N-body system with particles distributed on a uniform grid with positions \(\mathbf{q}\). Let \(\boldsymbol{\Psi}_{ZA}(\mathbf{q})\) be their linear ZA approximation at redshift \(z=0\). Thus, the final positions of the particles when they evolve linearly according to the Zel'dovich approximation is
\[\mathbf{x}_{lin}(\mathbf{q})=\mathbf{q}+\boldsymbol{\Psi}_{ZA}(\mathbf{q}). \tag{1}\]
Let the final nonlinear displacement of the particle initially at grid site \(\mathbf{q}\) be \(\boldsymbol{\Psi}_{NL}(\mathbf{q})\). Thus, the final positions of the
Figure 1: Qualitative comparison of the \(x,y,\) and \(z\) displacements for a \(128\times 128\) slice of particles from a linear field sampled using the training parameters and the corresponding linear field predicted by our inverse model.
particles at redshift \(z=0\) under nonlinear evolution is
\[\mathbf{x}_{nonlin}(\mathbf{q})=\mathbf{q}+\mathbf{\Psi}_{NL}(\mathbf{q}). \tag{2}\]
In this work, we investigate the problem of predicting the linear displacement field at redshift \(z=0\), given the nonlinear displacement field and the cosmological parameters defining the N-body evolution.
## 3 Methodology
We train a CNN-based neural network to predict the initial state of an N-body system of particles evolving under gravity on an expanding cosmological background, given the final state. Our CNN takes the nonlinear displacement field \(\mathbf{\Psi}_{NL}(\mathbf{q})\) at redshift \(z=0\) (current time) and the value of \(\Omega_{m}\) as the input, and predicts the linear displacement field \(\mathbf{\Psi}_{ZA}(\mathbf{q})\), i.e., the Zel'dovich approximation (ZA) at redshift \(z=0\). We directly use the CNN architecture used in (Jamieson et al., 2022) and train it using 100 pairs of nonlinear and linear displacement fields. In terms of the training procedure, our method is almost identical to (Jamieson et al., 2022), with the only difference being that we reversed the inputs and outputs of the neural network. We now input the nonlinear displacement field to our CNN and ask it to predict the linear displacement field. This is exactly opposite to what was being done by (Jamieson et al., 2022). The source code of our implementation and experiments is available at github.com/vaibhavjindal/map2map/tree/inverse_mapping.
For our experiments, we train our model using simulations of \(128^{3}\) particles in a square box with a side-length of \(250\ \mathrm{Mpc}/h\). The particles are distributed uniformly across this grid with a mean separation of \(1.95\ \mathrm{Mpc}/h\) between two adjacent particles of the grid. This mean separation corresponds to a Nyquist wavenumber of \(k=1.608\ \mathrm{Mpc}^{-1}\ h\), the theoretical limit beyond which we can't trust the predictions of any model for this setting. For the training data, we randomly generated 100 linear fields for a fixed set of cosmological parameters (\(\Omega_{m}=0.300,\Omega_{b}=0.050,h=0.700,n_{s}=0.965,\sigma_{8}=0.799\)). We then use the emulator by (Jamieson et al., 2022) to generate the nonlinear displacement fields for these linear fields. We use this small set of pairs of nonlinear and linear fields to train our model.
The neural network architecture involves four convolutional layers, which determine its field-of-view to be \(96^{3}\). That is, a focal particle's initial displacement is predicted based on its environment out to its \(48^{\mathrm{th}}\) neighbour on the initial particle grid, corresponding to a distance of \(93.75\ \mathrm{Mpc}/h\). This finite field-of-view has a benefit: the evolution of the system on large scales is accurately described by linear theory, so the V-net model preserves this linear evolution on scales larger than the field-of-view while allowing for nonlinear evolution at smaller (medium range of) scales.
On very small scales, the particles clustered tightly into dark matter halos where their orbits become complicated and difficult to predict. This small-scale clustering imposes a resolution limit on the inverse mapping, making it a one-to-many mapping as numerical errors and floating point precision make the neural network model unable to fully encode the detailed textures of this virialized motion. This limitation is also present in the forward model, which tends to make halos more diffuse on small scales than in the simulations, blurring the details of these sharp structures. For the inverse mapping, the initial linear displacements are blurred for particles that end up inside of halos, limiting the accuracy of the inverse model predominantly on these very small scales.
To evaluate the in-distribution performance of our model, i.e., the performance on fields corresponding to the training set cosmological parameters, we analyze the results of our model on unseen pairs of nonlinear and linear fields with the same set of cosmological parameters as the training data (Sections 4.1, 4.2 and 4.3). To evaluate how well our model performs on unseen cosmological parameters, we present the out-of-distribution (OOD) evaluation on the Quijote simulation suite (Villaescusa-Navarro et al., 2020) in Section 4.4.
## 4 Results and Analysis
In the following section, we showcase our method's outputs both qualitatively and quantitatively with a variety of method and summary statistics.
### Qualitative Analysis
Figure 1 shows the \(x,y,\mathrm{and}\ z\) direction displacements for a \(128\times 128\) slice of the linear displacement field and the corresponding linear field predicted by our inverse model. Qualitatively, the predictions of our model match very well with the original linear field that we wanted to predict.
To further evaluate the quality of the prediction, we used the forward-direction emulator again to generate the nonlinear field when fed the predicted linear field. We qualitatively compare this regenerated nonlinear field with the original nonlinear field in Figure 2. We find these displacement fields match very nicely qualitatively. The residuals are also not significant (especially one should take into account that the color bar at the residual plot is approximately 10 times smaller).
### One-Point Statistics
The initial conditions of the simulation are set up in Fourier space, with each mode of the displacement field drawn from a random Gaussian distribution with a variance determined by the linear power spectrum \(P(k)\), which is determined by the cosmological parameters. This construction yields
a coordinate-space displacement field that is also Gaussian, so its statistics are uniquely determined by the two-point correlation function, which is simply the Fourier transform of the power spectrum. To demonstrate that we have accurately recovered the initial conditions of the simulation we must show that the output of our model has both the correct power spectrum and that its statistical distribution is Gaussian.
Figure 3: Two-point correlation comparison between the original linear field (target) and the linear field predicted by our model (prediction). For an exact prediction, the variation of power with wavenumber should be exactly similar for both the fields, and the values of transfer function fractional error and stochasticity should be exactly zero.
Figure 2: Qualitative comparison of the \(x,y,\) and \(z\) displacements for a \(128\times 128\) slice of particles from the original nonlinear field and the nonlinear field generated from the linear field predicted by our inverse model. The nonlinear field is generated from the forward modeling emulator (Jamieson et al., 2022). The slice shown here is the same as the one shown in Figure 1 for a one-to-one comparison.
We plot the histogram of probability density of the displacements of the particles for the original linear field and the one predicted by our model (Figure 5). Each particle has three displacements corresponding to the \(x,y,\) and \(z\) directions. Since the linear fields are sampled from a Gaussian distribution determined by the cosmological parameters, we expect the distribution of displacements to match \(\mathcal{N}(0,5.275)\) for the simulation setting with \(128^{3}\) particles in a box size of 250 Mpc/\(h\). Specifically, the variance of displacements along the \(i^{\rm th}\) Cartesian direction is given by:
\[\sigma_{i}^{2}=\int\frac{\mathrm{d}k^{3}}{(2\pi)^{3}}\frac{(k^{i})^{2}}{k^{4}} P(k), \tag{3}\]
where the integral is over all wave vectors in Fourier space, \(k\equiv|\vec{k}|\) is the magnitude of the wave vector and \(k^{i}\) is its \(i^{\rm th}\) component. We numerically evaluate this integral on a Fourier space grid with the same dimensions as the initial simulation grid.
From Figure 5 we see that the statistics of our model output agree well with the expected Gaussian distribution. The bin counts also match the particular realization from this distribution of the target data out to displacements of \(\sim 10~{}{\rm Mpc}/h\), or 2\(\sigma_{i}\). Extremely large displacements indicate a particle either flowing outwards in a rare, extremely underdense environment or inwards towards a rare, high-density peak. Based on the residuals, we see that the tails of the distribution predicted by the model are somewhat smaller than the target data, indicating the model misplaces these particles. This is unsurprising due both to the rarity of these trajectories and to the fact that these particles are the most affected by extreme non-linearities in their environments, which exacerbates the one-to-many problem.
### Two-Point Correlation Comparison
The displacement power spectrum for a displacement field \(\mathbf{\Psi}\) for wavenumber \(k\) is defined as
\[P(k)=\sum_{i\in\{x,y,z\}}\langle\mathbf{\Psi}_{i}(k)\mathbf{\Psi}_{i}(k)\rangle. \tag{4}\]
Using this definition of power spectrum in the Fourier space, we can now define the transfer function as
\[T(k)=\sqrt{P(k)}, \tag{5}\]
and the correlation coefficient as
\[r(k)=\frac{P_{pred\times true}(k)}{\sqrt{P_{pred}(k)P_{true}(k)}}, \tag{6}\]
Figure 4: Two-point correlation comparison between the original nonlinear field (target) and the nonlinear field generated from the predicted linear field given by the inverse model. For an exact prediction, the variation of power with wavenumber should be exactly similar for both the fields, and the values of transfer function fractional error and stochasticity should be exactly zero.
Figure 5: Distribution of the displacements of particles for a given linear field and the corresponding linear field predicted by our model. The distribution has been calculated by considering the \(x,y,\) and \(z\) displacements of \(128^{3}\) particles. Relative error denotes the relative errors in probability density for different bins.
where \(P_{pred}(k)\) is the displacement power spectrum predicted by our neural network, \(P_{true}(k)\) is the ground truth power spectrum, and \(P_{pred\times true}(k)\) is the cross power spectrum between the predicted and the ground truth fields. Using these two quantities, we define the transfer function fractional error,
\[\frac{\Delta T(k)}{T(k)}=\sqrt{\frac{P_{pred}(k)}{P_{true}(k)}}-1, \tag{7}\]
to measure the discrepancy between amplitudes of the predicted and the true fields. We also define stochasticity,
\[1-r^{2}(k)=1-\frac{P_{pred\times true}^{2}(k)}{P_{pred}(k)P_{true}(k)}, \tag{8}\]
to capture the excess fraction of correlation in the prediction of our model that cannot be accounted for in the target data. For an ideal match between the target and the predicted field, the values of both these quantities should be exactly zero. Figure 3 shows the performance of our model in terms of these quantities for an original linear displacement field and its corresponding predicted linear field. We see that from large scales down to scales where \(k\simeq 0.5\ \mathrm{Mpc}^{-1}\ h\) the model achieves percent-level accuracy for both the transfer functions and stochasticities. Note that non-linearities become important at scales where \(k>0.1\ \mathrm{Mpc}^{-1}\ h\), so the model is able to accurately learn the inverse mapping even in the moderately nonlinear regime for in-distribution fields.
To further test the reliability of our model, we generated the nonlinear displacement field from our predicted linear field by using the forward direction emulator (Jamieson et al., 2022). Since the mapping from the nonlinear displacement field to the linear displacement field is one-to-many, it becomes critical to see that the nonlinear field which gets generated from our predicted linear field matches the actual nonlinear field. Figure 4 shows the power spectra comparison between these two nonlinear displacement fields. We see that there is an excellent match between the powers of the two fields. The transfer function fractional errors and the stochasticity plots show a good match for large to medium scales (\(k<0.5\ \mathrm{Mpc}^{-1}\ h\)).
### Out-Of-Distribution Evaluation
Given that our model has been trained on simulations generated by a neural network emulator (Jamieson et al., 2022) with fixed cosmological parameters (\(\Omega_{m}=0.300,\Omega_{b}=0.050,h=0.700,n_{s}=0.965,\sigma_{8}=0.799\)), there is a legitimate concern about its ability to generalize to actual N-body simulations with different sets of cosmological parameters. In order to assess this out-of-distribution (OOD) performance, we have conducted a series of experiments on simulations from the Quijote suite (Villaescusa-Navarro et al., 2020).
The Quijote suite comprises 2000 linear and nonlinear fields, each consisting of \(512^{3}\) particles that are uniformly distributed in a cube with a side length of \(1000\ \mathrm{Mpc}/h\). To quantify the dissimilarity between these simulations and our training data, we rank them based on the sum of their relative percentage differences in \(\Omega_{m}\) and \(\sigma_{8}\) from our training values, since these two parameters have the most significant impact on the simulated distributions. This dissimilarity metric is then used to evaluate the model's performance on different percentiles, with the 100th percentile simulation representing the one on which we expect our model to perform the worst. Notably, our model's performance is unaffected by changes in the box size, as long as the mean particle density remains constant.
In order to evaluate the model's performance on out-of-distribution (OOD) Quijote simulation data, we qualitatively compare the \(x,y,\) and \(z\) displacements of a \(512\times 512\) slice from the linear and nonlinear fields, similar to Section 4.1. The slices for the 0th percentile (\(\Omega_{m}=0.296,\Omega_{b}=0.067,h=0.523,n_{s}=1.091,\sigma_{8}=0.806\)) and the 20th percentile (\(\Omega_{m}=0.311,\Omega_{b}=0.067,h=0.673,n_{s}=0.993,\sigma_{8}=0.977\)) simulations are presented in Figures 8 and 11 respectively. Additionally, the one-point statistics for these simulations are provided in Figures 6 and 9. It is worth mentioning that the Quijote simulations consist of \(512^{3}\) particles in a box with a side length of \(1000\ \mathrm{Mpc}/h\). Hence, based on Equation 3, the theoretical distributions for these simulations are \(\mathcal{N}(0,6.193)\) and \(\mathcal{N}(0,7.159)\) respectively. Furthermore, we present the two-point correlation comparisons for these simulations in Figures 7 and 10.
For completeness, we present the results of our power spectra analysis of the actual linear field and our model's predictions for a range of percentiles of the dissimilarity metric in Figure 12. We are able to match the in-distribution performance for the 0th percentile simulation and we are able to do reasonably well for the 20th percentile simulation for medium scales. The performance gradually gets worse as we move towards the higher percentiles of the dissimilarity metric. Additionally, in Figure 13, we compare the actual nonlinear fields with the nonlinear fields generated by passing the output of our model through the forward direction emulator (Jamieson et al., 2022). Once again, we see a good match for lower percentiles of the dissimilarity metric which progressively gets worse with increasing percentiles.
we show that neural networks are able to do recover a linear field which matches the original linear field for a wide range of scales, including scales affected by the nonlinear physics of gravitational clustering. The final simulation state is also accurately recovered after first being inverse mapped by our model, and then being forward mapped back to the final state. We empirically demonstrate that the model generalizes reasonably well to OOD cosmological parameters. This indicates that despite the ill-defined nature of the inverse-mapping problem, neural networks can still be successfully trained to accurately predict the linear fields at large and medium scales.
## 6 Future Work
In this work, we showed that neural networks are successful in predicting the initial states of the N-body simulation at a wide range of scales, going down to small scales where nonlinear gravitational effects kick in. The inherent one-to-many mapping between the final states and the initial states at smaller scales makes it impossible for N-body simulators to make such predictions. However, inverse neural network models, such as the one presented in this work, can be trained to predict approximate initial states of N-body simulations which are correct for a wide range of scales. These approximate initial states could then be used as initializations by further downstream sampling-based methods (e.g. Hamiltonian Monte Carlo, Active Learning, etc.) to refine their search for better initial states which are correct at even smaller scales.
Other directions for future work involve training on larger set of cosmological parameters, improving OOD performance, and uncertainty quantification for the initial states.
## Acknowledgements
This work is supported by Simons Foundation grant on Learning the Universe.
|
2303.11127 | MT-SNN: Enhance Spiking Neural Network with Multiple Thresholds | Spiking neural networks (SNNs), as a biology-inspired method mimicking the
spiking nature of brain neurons, is a promising energy-efficient alternative to
the traditional artificial neural networks (ANNs). The energy saving of SNNs is
mainly from multiplication free property brought by binarized intermediate
activations. In this paper, we proposed a Multiple Threshold (MT) approach to
alleviate the precision loss brought by the binarized activations, such that
SNNs can reach higher accuracy at fewer steps. We evaluate the approach on
CIFAR10, CIFAR100 and DVS-CIFAR10, and demonstrate that MT can promote SNNs
extensively, especially at early steps. For example, With MT,
Parametric-Leaky-Integrate-Fire(PLIF) based VGG net can even outperform the ANN
counterpart with 1 step. | Xiaoting Wang, Yanxiang Zhang, Yongzhe Zhang | 2023-03-20T14:04:50Z | http://arxiv.org/abs/2303.11127v1 | # MT-SNN: Enhance Spiking Neural Network with Multiple Thresholds
###### Abstract
Spiking neural networks (SNNs), as a biology-inspired method mimicking the spiking nature of brain neurons, is a promising energy-efficient alternative to the traditional artificial neural networks (ANNs). The energy saving of SNNs is mainly from multiplication free property brought by binarized intermediate activations. In this paper, we proposed a Multiple Threshold (MT) approach to alleviate the precision loss brought by the binarized activations, such that SNNs can reach higher accuracy at fewer steps. We evaluate the approach on CIFAR10, CIFAR100 and DVS-CIFAR10, and demonstrate that MT can promote SNNs extensively, especially at early steps. For example, With MT, Parametric-Leaky-Integrate-Fire(PLIF) based VGG net can even outperform the ANN counterpart with 1 step.
## 1 Introduction
The development of artificial neural networks (ANNs) especially deep learning in recent years brought remarkable successes in lots of domains like computer vision [1][2], natural language processing [3][4][5], multi-modal[6][7] etc. However, computational costs of ANNs are too high for even one single application. For example, a standard convolution neural network to classify ImageNet-1k dataset will expend about 250 watts[8], while by contrast, only 20 watts are required by human brain to process various tasks simultaneously[9].
Spiking Neural Networks (SNNs) are considered as the next generation neural models for its closer mechanism to the biological neurons in the brain[10]. Recently SNNs attract increasing attention due to their abilities such as temporal information processing, energy efficiency [8] and high biological plausibility [11]. By leveraging binary spike signals, SNNs can achieve low-energy consumption by multiplication-free inference and avoiding computing zero values of inputs or activation [8]. Neuromorphic hadwares such as TrueNorth[12], Lohi[13] and Tianjic[14] demonstrated that SNNs is capable of saving energy by orders of magnitude.
However, even though with these promising inherent properties, SNNs are not widely adopted by the main-stream machine learning problems. We argue three obvious obstacles should account for this. Firstly, quality degradation caused by information loss is unavoidable by replacing the float activations with binary spikes. Previously the problem is severe due to lacking efficient learning algorithms, surrogate gradient[15] fills the gap to a large extend. But it still exists when limiting time steps. Secondly, many popular problems are not with temporal information, pre-processing is necessary to make them solvable by SNNs. However, it's inefficient if a problem is converted from single step to multiple steps. For example, in static image classification tasks, the static image is duplicated into multiple copies to adapt the SNNs, multiple steps indeed boost the quality while reducing the efficiency of training and inference. Thirdly, SNNs are constraint by both software and hardware, modern popular ML frameworks such as Pytorch [16],
Jax [17] and Tensorflow [18] don't provide efficient and general instructions or high-level functions to accelerate the convolution with 0/1 spike activations [19]. And current popular devices like TPU, GPU are not specifically optimized for multiplication free operations.
In this work, we propose a multiple threshold (MT) algorithm at Leak-Integrate-Fire(LIF) cell to partly recover the information loss brought by replacing floating-point activations with 0/1 spikes. The difference between one single threshold (ST) and MT can be seen in Fig 1 and Fig 2. And we find the algorithm is effective in enhancing the quality of SNNs by both achieving better accuracy at same time steps and reaching similar accuracy with fewer time steps. The latter one reduces the burden of training SNNs on current hardwares. Furthermore, the trained model can still be deployed on neuromorphic hardwares without violating the nature of spikes.
Our contributions can be summarized as follows:
* We propose the multiple threshold (MT) algorithm as an augmentation to partly reserve precision in spike activations. MT can be viewed as a widget used in the fire stage of LIF cells such that can be deployed in SNNs of various architectures. we demonstrate MT is a robust way to improve quality of SNNs.
* We evaluate the MT algorithm on Parametric Leak Integrate Fire (PLIF) based VGG and ResNet on CIFAR-10, CIFAR-100 and DVS-CIFAR10 datasets, Results show that MT is highly effective and versatile. Our implemented SNNs with MT can exceed state-of-the-art accuracy of similar architectures, using fewer steps.
## 2 Related Works
### Learning Algorithms
After the emergence of SNNs, how to train the models effectively stays as an active area. The earliest learning algorithms are based on biological plausible local learning rules, like Hebbian learning [20] and Spike-Timing-Dependent Plasticity
Figure 1: Spikes over Single Threshold (ST), \(\mu\) is membrane and \(o\) is output spike.
Figure 2: Spikes over Multiple Thresholds (MT), \(\mu\) is membrane and \(o\) is output spike.
[21]. However, such methods are only suitable for shallow SNNs, and the performance is far below methods mentioned below.
ANN-To-SNN methods are capable of obtaining high-quality SNNs by leveraging the knowledge from well-trained ANNs and converting the ReLU activations to spike activations based on rate coding[22][23]. However, achieving near lossless conversion requires a considerable amount of time steps (\(>200\)) to accumulate the spikes, which may significantly increase the latency.
Backpropagation with surrogate gradient is widely used in recent researches to achieve high-quality deep models [24][25][26]. The utilization of surrogate gradient function enables end-to-end backpropagation in SNN training, thus training knowledge of ANNs can be transferred to SNNs. [27][15] systematically studied the remarkable robustness of the surrogate gradient based algorithms and demonstrated that SNNs trained with surrogate gradient can achieve competitive performance with ANNs. Backpropagation with surrogate functions requires much fewer steps compared to ANN-To-SNN methods as it's not dependent of rate coding [28].
### Model architecture
Backpropagation with surrogate gradient unlocked the model architecture migration from ANNs to SNNs. [28] initially applied direct training of various sized deep convolutional neural networks on both static and neuromorphic datasets with normalization and rate coding. [29] explored ResNet with time-dependent batch normalization and validated the architecture on ImageNet for the first time. [30][31] proposed spike-element-wise ResNet and membrane based ResNet respectively which pushed the depth of the architecture to more than 100 layers. [32] introduced attention mechanisms into SNNs and achieved comparable and even better performance compared to the ANN counterpart on large-scale datasets. Furthermore, [33] proposed Spiking Transformer by combining self-attention with spiking neural network. There will be more works on such model migrations in the foreseeable future.
### Information Loss
Information loss in SNNs attracts increasing attentions recently. In [34], Soft Reset is leveraged to reserve the information in the residual potential, and Membrane Potential Rectifier is proposed to alleviate the precision loss in quantization. [35] leveraged a re-parameterization technique to decouple training and inference stage, and enhance the presentation capacity b learning real-valued spikes during training and transferring the capacity to model parameters by not sharing convolution kernels. The MT approach in this paper falls into the same domain with [34][35], which provides another option to reduce information loss in spike activations.
## 3 Preliminary
### Parametric Leaky Integrate and Fire Model
Parametric Leaky Integrate and Fire (PLIF) neuron model[36] is adopted as the basic unit in the model architectures in this paper. PLIF includes the following discrete time equations:
\[H[t]=f(V[t-1],X[t]), \tag{1}\] \[S[t]=\Theta(H[t]-V_{th}),\] (2) \[V[t]=H[t](1-S[t])+V_{reset}S[t] \tag{3}\]
Where X[t] is the input current at time-step t from the previous layer, H[t] and V[t] represent the membrane potential after neuronal dynamics and spike trigger respectively. \(V_{th}\) is the firing threshold. \(\Theta(x)\) is the Heaviside step function which is defined by
\[\Theta(x)=\left\{\begin{array}{cc}1&x\geq 0\\ 0&x<0\end{array}\right. \tag{4}\]
\(V_{reset}\) denotes the reset potential. The function in Eq 1 describes the neuronal dynamics, which can represent different model with different forms. Eq 5 and Eq 6 describe the Integrate-and-Fire(IF) and Leaky Integrate-and-Fire(LIF) respectively.
\[H[t]=V[t-1]+X[t] \tag{5}\]
\[H[t]=V[t-1]+\frac{1}{\tau}(X[t]-(V[t-1]-V_{reset})) \tag{6}\]
In Eq 6, the \(\tau\) is the membrane time constant, [36] made it learnable with Eq 7.
\[\tau=1+exp(-a)\in(1,+\infty) \tag{7}\]
Where \(a\) is a learnable variable.
Furthermore, when \(V_{reset}=0\), the PLIF neuron becomes
\[H[t]=(1-\frac{1}{\tau})V_{t-1}+\frac{1}{\tau}X_{t} \tag{8}\]
which is analogous to the input gate and forget gate in Long Short-Term Memory(LSTM) networks [37]. In this paper, We set \(V_{reset}=0\) and implement the PLIF model with formula in Eq 8.
### Surrogate Function
The surrogate function used in this paper is the popular rectangular function proposed by [28], given by Eq below.
\[\frac{\partial S[t]}{\partial H[t]}=\frac{1}{a}sign(|H[t]-V_{th}|\leq\frac{a }{2}) \tag{9}\]
Where a is a hyper-parameter and usually set to 1.
### Outputs
Based on whether to fire at the last layer, there are naturally two kinds of outputs:
1. Output the membrane of the last layer directly without firing such that the loss can be computed on float values as the ANNs, which is widely used by [19][29][38] etc.
2. Output the spikes across time steps. This method inherently loss some precision especially with fewer time steps. A voting layer is proposed by [36] to alleviate the problem.
The loss functions are computed on the mean output across time steps of the model, classic classification losses such as Softmax or Mean Squared Error(MSE) can all be applied to the training of SNNs.
In practices, we found that the two outputs perform quite different on various datasets with various number of classes, which is illustrated in the experiment section.
## 4 Multi-Thresholds SNN
It's commonly observed that the quality of SNNs can be boosted by increasing time steps. Fig 3 below demonstrated this phenomenon. In Fig 3, the yellow line is the corresponding ANN with the same architecture of SNNs, and the red line is the SNNs with ST. It's observed that SNNs with ST require at least 2 steps to recover the same accuracy of its ANN counterpart.
We argue that compared to the ANNs, the precision of middle outputs of SNNs is lost in replacing float values with spikes and compensated on multiple time steps.
To overcome the precision loss problem in the intermediate activations in SNNs, we propose a Multi-Threshold (MT) approach to partly preserve the precision, the idea is illustrated in Fig 1 and Fig 2. In Fig 1, one threshold in red line split the input membrane into two values 0 and 1, in this process, the information about how much the membrane is greater / smaller than the threshold is completely lost. In Fig 2, two auxiliary thresholds are added, one is smaller in blue line and the other one is larger in yellow line. Two more series of spikes are obtained based on the auxiliary thresholds, the result that adds up the three sequences of spikes is a more accurate representation of the original membrane.
To formulate the approach, a series of parameters are introduced in, namely \([\Delta_{1},\Delta_{2},...,\Delta_{n}]\), and we apply each \(\Delta\) to Eq 2:
\[S[t]_{\Delta_{i}}=\Theta(H[t]-V_{th}-\Delta_{i}),i\in[1,2,...,n] \tag{10}\]
And Eq 3 is still used to update the membrane.
After obtaining all spikes for each threshold, the final outputs are obtained by
\[S[t]_{sum}=S[t]+\Sigma S[t]_{\Delta_{i}} \tag{11}\]
However, after applying multiple thresholds, from Eq 11, the outputs have other possible values other than 0/1, which breaks the binary property of SNNs, making the network not multiplication-free anymore. To keep the multiplication-free property, convolution layer of next layer can be involved in to perform an equivalent operation in Eq 12, right side of which is still multiplication-free.
\[Conv(S[t]_{sum})=Conv(S[t])+\Sigma Conv(S[t]_{\Delta_{i}}) \tag{12}\]
Generally, we can deploy left side of Eq 12 on current popular hardwares like TPU, GPU etc and right side on neuromorphic hardwares with multiplication-free properties.
## 5 Experiments
In this section, experimental results for the proposed method are reported on static datasets CIFAR10, CIFAR100 and neuromorphic datasets CIFAR10-DVS. ResNet and VGG network architectures are implemented to demonstrated the versatility of the method. The code is implemented with Tensorflow and all experiments are conducted on TPU.
### Network Architectures
ResNet and VGG networks are implemented for experiments with various configurations, the configurations of VGG-like architectures are listed in Table 1. The convolutions between pooling layers are viewed as a stage, same number of filters are used for convolutions in the same stage. The models end with two fully connected layers, the former layer is a hidden layer, while the latter layer is for output.
The VGG-8 model is the model architecture[36] for CIFAR10 dataset, 92% parameters of the model are from the first dense layer because of the large size of output of the last pooling layer. So VGG-9 is proposed to deepen the network as well as reduce the model size.
Each convolution layer is followed by a batch normalization layer and a PLIF layer to fire spikes, the first Conv-BN-PLIF is viewed as the encoder to convert image pixels into spikes.
Similarly, the configuration of ResNet architectures is listed in Table 2. The residual connections happened at the membrane level following [31]. After convolution layers, a pooling layer with large size is applied to convert the output image into 1-D, after which a fully-connected layer is appended as the output.
### Static Datasets Classification
CIFAR10 and CIFAR100 are the static datasets evaluated in this paper. The datasets contains 50K training and 10K test images with 32x32 pixels. Random horizontal flip, random rotation by 15 degree and random height, width shift by 10% fraction are used as the data augmentation approaches.
\begin{table}
\begin{tabular}{c c c c c c c} \hline Model Name & Dataset & \(N_{stages}\) & \(N_{conv}\) & Conv Filters & \(N_{fc}\) & First FC & \(N_{params}\) \\ \hline
*VGG-8 & CIFAR10(100) & 2 & 3,3 & 256,256 & 2 & 2048 & 36.72M \\ VGG-9 & CIFAR10(100) & 3 & 2,2,3 & 256,512,512 & 2 & 1024 & 19.72M \\ VGG-12 & DVS-CIFAR10 & 4 & 2,2,3,3,3 & 128,128,128,128,128 & 2 & 512 & 2.88M \\ \hline \end{tabular}
\end{table}
Table 1: Configurations of VGG architectures.
\begin{table}
\begin{tabular}{c c c c c c} \hline Model Name & Dataset & \(N_{layers}\) & \(N_{stages}\) & \(N_{filters}\) & \(N_{params}\) \\ \hline ResNet20 & CIFAR10(100) & 20 & 3 & 64,128,256 & 4.66M \\ \hline \end{tabular}
\end{table}
Table 2: Configurations of ResNet architectures.
In training, SGD optimizer is adopted with 0.9 momentum, the learning rate is initially set to 0.1 and decay by 0.1 after 100 epochs, after 500 epochs, the peak accuracy is reported.
The accuracy comparison on CIFAR10, CIFAR100 between SNNs with ST, SNNs with MT and the ANN counterparts are illustrated in Fig 3. It's observed that on both CIFAR10 and CIFAR100 datasets, all of the VGG-8, VGG-9 adn ResNet-20 models, all the time steps from 1 to 5, the accuracy of SNNs with MT outperforms SNNs with ST. And for all combinations except the ResNet-20 on CIFAR100, SNNs with MT can achieve close or even better accuracy at \(time\_step=1\).
The comparison between our results and previous state-of-the-art results of similar model architectures is listed in Table 3. The best accuracy of our proposed VGG-9 network are 94.74% and 75.53% respectively, with a 0.49% and 1.29% absolute accuracy improvement compared to the existed state-of-the-art results of simialr model architectures. Furthermore, the VGG-9 model can reach 94.71% and 74.79% accuracy when step is 2, which are already better than the previous state of the art results. Our implemented ResNet-20 network is not as good as the VGG-9 network, but still, on CIFAR10, the accuracy of MT-ResNet-20 can achieve 94.71% accuracy at \(time\_step=4\) and exceed the previous state of the art at \(time\_step=3\).
All the results on CIFAR10/CIFAR100 are from models trained by taking membrane as the output (See (A) of Sec 3.3), as we found that SNNs taking membrane as output is superior to models taking spikes (See (B) of Sec 3.3) as output on CIFAR10. And specifically for CIFAR100, it's difficult for model to converge if taking spikes and voting layer as output makes the model.
### Neuromorphic datasets classification
VGG-12 in Table 1 is adopted on DVS-Cifar10 dataset to verify the effectiveness of MT. The DVS-CIFAR10 dataset is processed in the same way as [36], namely converting the events to frames by accumulating events into T slices evenly, thus different frame datasets are obtained for different step T. No data augmentation approaches are involved in the experiments.
From Fig 4, it's observed that the accuracy is improved significantly at early stage especially when step is less than 4. The comparison of our proposed model with previous similar models are listed in Table 3, in which our final model accuracy is 76.3%, which is superior to the previous models.
However, when the number of steps is large, the gap between ST and MT is small, also, in the experiments on DVS-CIFAR10, we found that the accuracy shakes significantly even with same configuration. We argue that this is mainly caused by the fewer examples in the dataset. As currently large-scale DVS dataset is difficult to be acquired, we leave more explorations on DVS datasets as future work.
Figure 3: Performance comparison of ST and MT on CIFAR10 / CIFAR100 with various steps.
### Ablation Study
Extensive ablation studies are conducted to evaluate different MT settings. Firstly we study which part of the model needs MT, in (a)(b) of Fig 5, we apply MT on convolution layers only and both convolution and fully-connected layers, and evaluate the results on different steps. From (a), it's observed that applying MT on fully-connected layers improves accuracy at early steps. However, from (b), applying MT on fully-connected layers doesn't make significant changes on accuracy. We argue the deeper reason is that the fully-connected layers occupies 92% parameters of VGG-8 while 42.7% of VGG-9.
Secondly different deltas are explored on VGG-9 with \(step=1\), from (c) of Fig 5, it's observed that using negative deltas only performs more significant effect over positive deltas only, while combination of both positive and negative delta performs the best. And the accuracy curve is smoother when absolute delta is larger than 0.3, indicating no more information will be recovered when delta is too large.
Figure 4: Performance comparison of ST and MT on DVS-CIFAR10 with various steps.
\begin{table}
\begin{tabular}{c c c c} \hline Dataset & Name & Model & Steps & Accuracy(\%) \\ \hline \multirow{8}{*}{CIFAR10 / CIFAR100} & \multirow{8}{*}{ResNet-19} & 2 & 92.34 / - \\ & & & 4 & 92.92 / - \\ & & & 6 & 93.16 / - \\ \cline{2-4} & \multirow{2}{*}{VGG-8} & 8 & 93.50 / - \\ \cline{2-4} & & & 5 & 93.01 / 71.19 \\ \cline{2-4} & \multirow{2}{*}{InfLoR-SNN[34]} & ResNet-20 & 5 & 93.01 / 71.19 \\ & & VGG-16 & 5 & 94.06 / 71.56 \\ \cline{2-4} & \multirow{2}{*}{Real Spike[35]} & ResNet-20 & 5 & 93.01 / 66.60 \\ & & VGG-16 & 5 & 92.90 / 70.62 \\ \cline{2-4} & \multirow{2}{*}{DSpike[19]} & \multirow{2}{*}{ResNet-18} & 2 & 93.13 / 71.68 \\ & & & 4 & 93.66 / 73.35 \\ & & & 6 & **94.25 / 74.24** \\ \cline{2-4} & \multirow{2}{*}{Ours} & \multirow{2}{*}{MT-VGG-9} & 1 & 93.47 / 73.67 \\ & & & 2 & 94.71 / 74.79 \\ & & & 3 & 94.54 / 75.13 \\ & & & 4 & 94.51 / **75.53** \\ & & & 5 & **94.74 / 75.29** \\ \cline{2-4} & \multirow{2}{*}{Ours} & \multirow{2}{*}{MT-ResNet-20} & 1 & 93.50 / 70.74 \\ & & & 2 & 93.84 / 72.05 \\ & & & 3 & 94.55 / 73.23 \\ & & & 4 & **94.71 / 73.75** \\ & & & 5 & 94.44 / 73.45 \\ \hline \multirow{8}{*}{DVS-CIFAR10} & \multirow{2}{*}{STDP-tdBN[29]} & ResNet-17/19 & 10 & 67.80 \\ & PLIF[36] & Conv+FC & 20 & 74.80 \\ \cline{1-1} \cline{2-4} & SEW-ResNet[30] & SEW-ResNet & 16 & 74.40 \\ \cline{1-1} \cline{2-4} & DSpike[19] & ResNet-18 & 10 & 75.40 \\ \cline{1-1} \cline{2-4} & MS-ResNet20[31] & ResNet-20 & - & 75.56 \\ \cline{1-1} \cline{2-4} & \multirow{2}{*}{Ours} & ST-VGG-12 & 5 & 75.90 \\ \cline{1-1} \cline{2-4} & & MT-VGG-12 & 5 & **76.30** \\ \hline \end{tabular}
\end{table}
Table 3: Performance comparison of MT with SoTA methods.
## 6 Conclusion
In this paper, multiple threshold approach is proposed to augment the output of spiking layers, thus relieving the precision loss of SNNs comparing to float-based neural networks. We show that SNNs with multiple thresholds outperform state-of-the-art models with similar architectures, and tend to reach higher accuracy at fewer steps, thus providing us an option to make easier trade off between the number of steps and the quality.
|
2306.01065 | Turbulence model augmented physics informed neural networks for mean
flow reconstruction | Experimental measurements and numerical simulations of turbulent flows are
characterised by a trade-off between accuracy and resolution. In this study, we
combine accurate sparse pointwise mean velocity measurements with the
Reynolds-Averaged Navier-Stokes (RANS) equations using data assimilation
methods. Importantly, we bridge the gap between data assimilation (DA) using
Physics-Informed Neural Networks (PINNs) and variational methods based on
classical spatial discretisation of the flow equations, by comparing both
approaches on the same turbulent flow case. Firstly, by constraining the PINN
with sparse data and the under-determined RANS equations without closure, we
show that the mean flow is reconstructed to a higher accuracy than a RANS
solver using the Spalart-Allmaras (SA) turbulence model. Secondly, we propose
the SA turbulence model augmented PINN (PINN-DA-SA), which outperforms the
former approach by up to 73% reduction in mean velocity reconstruction error
with coarse measurements. The additional SA physics constraints improve flow
reconstructions in regions with high velocity and pressure gradients and
separation. Thirdly, we compare the PINN-DA-SA approach to a variational data
assimilation using the same sparse velocity measurements and physics
constraints. The PINN-DA-SA achieves lower reconstruction error across a range
of data resolutions. This is attributed to discretisation errors in the
variational methodology that are avoided by PINNs. We demonstrate the method
using high fidelity measurements from direct numerical simulation of the
turbulent periodic hill at Re = 5600. | Yusuf Patel, Vincent Mons, Olivier Marquet, Georgios Rigas | 2023-06-01T18:15:48Z | http://arxiv.org/abs/2306.01065v2 | # Turbulence model augmented physics informed neural networks for mean flow reconstruction
###### Abstract
Experimental measurements and numerical simulations of turbulent flows are characterised by a trade-off between accuracy and resolution. In this study, we bridge this gap using Physics Informed Neural Networks (PINNs) constrained by the Reynolds-Averaged Navier-Stokes (RANS) equations and accurate sparse pointwise mean velocity measurements for data assimilation (DA). Firstly, by constraining the PINN with sparse data and the under-determined RANS equations without closure, we show that the mean flow is reconstructed to a higher accuracy than a RANS solver using the Spalart-Allmaras (SA) turbulence model. Secondly, we propose the SA turbulence model augmented PINN-DA-SA), which outperforms the former approach - up to 73% reduction in mean velocity reconstruction error with coarse measurements. The additional SA physics constraints improve flow reconstructions in regions with high velocity and pressure gradients and separation. Thirdly, we compare the PINN-DA-SA approach to a variational data assimilation using the same sparse velocity measurements and physics constraints. The PINN-DA-SA achieves lower reconstruction error across a range of data resolutions. This is attributed to discretisation errors in the variational methodology that are avoided by PINNs. We demonstrate the method using high fidelity measurements from direct numerical simulation of the turbulent periodic hill at \(Re=5600\).
## I Introduction
Whilst the Navier-Stokes equations describe accurately the evolution of fluid flow in space and time, their direct numerical simulation (DNS) is intractable in turbulent regimes. As a compromise, industrial simulation is dominated by Reynolds-Averaged Navier-Stokes simulations (RANS), which govern the time-averaged flow quantities instead of unsteady time-varying values. Whilst solutions of the RANS equations are computationally tractable, they are also less accurate due to their under-determined nature and the lack of exact turbulence closure models [1]. On the other hand, experimental methods are often more expensive, with extra costs such as test part manufacture, and require access to laboratory facilities (i.e. wind tunnels). Error from sources, such as imperfect test parts and sensor noise can also make measurements less reliable while measurement tools can also be limited. Particle Image Velocimetry (PIV) is often used to measure flow velocity but its resolution may be hardware restricted and limited to specific planes of interest (2D planes in a full 3D field), whilst pressure measurements are difficult to obtain in the bulk flow without being intrusive.
Data assimilation methods have enabled the augmentation of low-fidelity numerical simulations with high-fidelity experimental data for correcting turbulence RANS models, such as with the parameter correction [2], addition of corrective terms [3] and development of new models [4]. The goal of this work is to approach the inverse problem, where a set of flow observations (data) is used to discover the factors which caused them. This contrasts the forward problem, where factors (boundary conditions) are defined, and the resultant effects of the system are calculated. By leveraging sparse high-fidelity time-averaged measurements, which obey the governing RANS equations, we extract information not present in the original dataset: interpolate missing data by super-resolving the flow fields (such as coarse PIV fields); and infer missing fields (such as pressure and Reynolds stresses). |
2305.18070 | Forensic Video Steganalysis in Spatial Domain by Noise Residual
Convolutional Neural Network | This research evaluates a convolutional neural network (CNN) based approach
to forensic video steganalysis. A video steganography dataset is created to
train a CNN to conduct forensic steganalysis in the spatial domain. We use a
noise residual convolutional neural network to detect embedded secrets since a
steganographic embedding process will always result in the modification of
pixel values in video frames. Experimental results show that the CNN-based
approach can be an effective method for forensic video steganalysis and can
reach a detection rate of 99.96%. Keywords: Forensic, Steganalysis, Deep
Steganography, MSU StegoVideo, Convolutional Neural Networks | Mart Keizer, Zeno Geradts, Meike Kombrink | 2023-05-29T13:17:20Z | http://arxiv.org/abs/2305.18070v1 | # Forensic Video Steganalysis in Spatial Domain by Noise Residual Convolutional Neural Network
###### Abstract
This research evaluates a convolutional neural network (CNN) based approach to forensic video steganalysis. A video steganography dataset is created to train a CNN to conduct forensic steganalysis in the spatial domain. We use a noise residual convolutional neural network to detect embedded secrets since a steganographic embedding process will always result in the modification of pixel values in video frames. Experimental results show that the CNN-based approach can be an effective method for forensic video steganalysis and can reach a detection rate of 99.96%.
keywords: Forensic, Steganalysis, Deep Steganography, MSU StegoVideo, Convolutional Neural Network +
Footnote †: journal: Forensic Science International: Digital Investigation
## 1 Introduction
Steganography is the hiding of secret information inside innocent looking (digital) objects, whereas, steganalysis is the science of detecting steganography (Li et al., 2011). This research relates to forensic steganalysis, which refers to a level of steganalysis that attempts to obtain further in-depth knowledge about a hidden message (Chutani and goyal, 2019). Steganography and (forensic) steganalysis have become an important field of interest in forensic science,
due to the rising popularity of steganography among criminals and terrorists (Choudhary, [2012]) (European Commission, [202]). A reason for the rise in popularity is that "stand-alone" encryption methods have proved to be insecure. This is mainly a result of the successful and continuous effort of law enforcement agencies to compromise encrypted criminal communications, such as with the "EncroChat Hack" in [2020] (O'Rourke, [202]). Steganography can also be used along with encryption, which provides more security and robustness (Taha et al., [2019]), because one first needs to find the encrypted secret and extract it from the carrier before it can be decrypted.
An object in which a secret is hidden is called a cover. Many covers can be used for steganography (e.g., text files, images, audio files), but in this paper, we focus on video steganography, i.e., steganography with video files as cover. This is a popular research area within steganography due to the high secret hiding potential of video files compared to, for example, images and audio files (Lu et al., [2019]). Videos are in fact a moving stream of images and sounds and, therefore, any distortions in a video file might go by unobserved by humans. Additionally, video files are generally larger in size and, therefore, have more potential bytes to alter to embed a secret.
Criminals and terrorists can use video steganography to hide information and to communicate with each other (Garcia, [2018]). There exist numerous real-world examples where steganography has been used with bad intentions (Dalal and Juneja, [2021]). US officials claimed, for example, that Al-Qaeda used steganography to plan the 9/11 attack. Also in several cases, steganography was used to hide child pornography. Therefore, specialized tools need to be developed by law enforcement agencies to detect such criminal content on, for example, confiscated computers. Criminals can also communicate with video steganography by, for example, uploading an innocent looking video with an embedded message to a popular online video sharing platform. The intended receiver of the message only needs to know where to look to extract the video and its
hidden content. This is very difficult to detect because of the vast number of video files on such platforms. Unfortunately, the research on video steganalysis is lacking behind the research on video steganography. Therefore, forensic video steganalysis requires more interest from forensic researchers.
One possible approach for forensic steganalysis is to use a convolutional neural network (CNN). A CNN is a special type of artificial neural network that is most commonly applied to analyze images, therefore one can use a CNN to conduct forensic steganalysis from the perspective of the spatial domain, where the modification of pixel values are analyzed to detect a hidden secret.
This study evaluates a CNN and its video steganalysis capabilities (i.e., its ability to detect video steganography) in spatial domain. The Noise Residual Convolutional Neural Network (NR-CNN), proposed by (Liu and Li, 2020), is trained on a video steganography dataset to detect two steganography tools: Deep Video Steganography (Sathyan, 2019) and MSU StegoVideo (Moscow State University) 2006). The remainder of this paper is organized as follows. Section 2 describes the related research papers from this research. Section 3 describes how the steganography dataset is created and how the NR-CNN is trained and evaluated. The results are presented and discussed in section 4 and conclusions and future directions are in section 5.
## 2 Related work
### Deep Steganography
Deep Steganography refers to steganography implemented with a deep neural network, which is an artificial neural network with multiple layers between the input and output layers. A Deep Steganography method was proposed by (Baluja, 2017) to hide an image inside an other image of the same size. The proposed Deep Steganography network consists of three parts: a preparation network, a hiding network and a reveal network, which are trained together on
an image dataset. The input of the network is a cover image and a secret image and the output is the target cover image and the target secret image after the embedding and extracting process. During training the difference between the input and the output images are used as error terms. In this way, the network can learn how to hide images inside each other with the lowest number of noticeable differences. Once the network is trained, it is split into an encoding and decoding network, which can then be used as a image steganography tool. In addition, since videos basically consists of a number of combined images, this tool can also be transformed into a video steganography tool.
### MSU StegoVideo
MSU StegoVideo1 is a video steganographic tool developed by (Moscow State University, 2009). The tool can be used to hide any file inside a video, with small video distortions. It has two important settings which are the data redundancy, which determines the amount of data that is hidden in each frame, and a noise setting, which determines the amount of added noise. The tool also requires a password to embed and extract the hidden secret. The Moscow State University does not provide any source code for MSU StegoVideo.
Footnote 1: [https://www.compression.ru/video/stego](https://www.compression.ru/video/stego) yidco/index _gn.html
### Noise Residual Convolutional Neural Network
A universal steganalysis method was proposed by (Liu and Li, 2020) to detect both intraprediction mode and motion vector based steganography. Since, both steganography methods eventually lead to the modification of pixel values in decoded frames, they designed a Noise Residual Convolutional Neural Network (NR-CNN) from the perspective of the spatial domain. In a data-driven manner the network automatically learned features and implemented classification. The trained NR-CNN reached a detection accuracy from 59.82% up to 99.74% for different embedding rates.
3 Method
Avideo dataset is created with a mix of regular videos and two types of steganography videos. The videos from that dataset along with their corresponding class labels are used to train a convolutional neural network. Specifically, it is trained to classify frames from the videos into three categories: regular, deep-stego and MSU-stego. Thus, the trained network should be able to determine if a video is a regular video or a video that is embedded with one of the two steganographic embedding techniques.
### Data
The VLOG dataset (Fouhey et al., 2018) is used to obtain video material for the experiments. This dataset consists of 2.747 video files with a total duration of 314 hours and over 30 million frames, therefore, we do not require the whole dataset for our experiment. However, we need to generalize our dataset as much as possible, to make sure the trained network works well on unseen data. Therefore, the final dataset should contain video frames from as much different videos as possible. Hence, the VLOG dataset is transformed into a "10-sec" dataset by splitting the videos into videos of around 10 seconds each. Now, when we randomly pick a video from the 10-sec dataset we obtain a random section from a random video from the VLOG dataset. Next, we define a parameter \(k\), which represents the number of 10-second videos we want in the final steganography dataset (stego-dataset). This stego-dataset, therefore, will contain \(k/3\) Deep Steganography (DVS) videos, \(k/3\) MSU StegoVideo (MSU) videos, and \(k/3\) regular videos. The regular videos are created by simply copying \(k/3\) videos from the 10-sec dataset into the stego-dataset and removing them from the 10-sec dataset.
#### 3.1.1 Deep Video Steganography dataset
The deep neural network hiding technique, proposed by (Baluja, 2017) and discussed in section2.1, embeds an image into another image of the same size. In figure 1, an example is shown. This technique was implemented by (Sathyan,
2019) for usage with video frames and made publicly available in the Deep Video Steganography (DVS) repository3. This repository is used to create the DVS videos for the stego-dataset, which is done by picking two distinct random videos from the 10-sec dataset and hiding one of those videos inside the other using DVS. The resulting video is added to the stego-dataset and the two randomly picked videos are removed from the 10-sec dataset. We repeat this \(k/3\) times.
Footnote 3: [https://github.com/anilsathyan7/Deep-Video-Steganography-Hiding-Videos-in-Plain-Sight](https://github.com/anilsathyan7/Deep-Video-Steganography-Hiding-Videos-in-Plain-Sight)
Although the DVS technique is visually difficult to detect, the number of bits required to encode a secret frame inside a cover frame of the same size is between 1 and 4 bits per pixel (bpp). Given that previous studies (Xuan et al., 2005)(Zou et al., 2006) have demonstrated that bit rates of 0.1 bbp can already be discovered by statistical analysis, it is expected that the DVS videos can also be detected by a CNN-based approach.
Figure 1: Example of the deep neural network hiding technique, with a picture of a cat as secret image and a picture of a dog as cover image.
#### 3.1.2 MSU StegoVideo dataset
MSU StegoVideo1[Moscow State University, 2006], discussed in section 4.2 is a public video steganographic tool that can hide a secret file inside the frames of a video. Figure 2 shows an example of a secret text message embedded into a frame from a landscape video. We use MSU StegoVideo to create the MSU videos for the stego-dataset. This is done by randomly picking and concatenating \(k/3\) distinct videos from the 10-sec dataset into a large video file. Next, we hide a text file containing Lorem Ipsum text inside the concatenated video using MSU StegoVideo, with data redundancy set to 2 and noise set to 100. The video with the embedded secret is then split into 10-second videos again, now all containing a part of the secret.
Footnote 1: [https://www.compression.ru/video/stego](https://www.compression.ru/video/stego) _video/index _en.html
MSU StegoVideo is not open source and is, therefore, difficult to analyze. However, we approximated that the embedding rate of the secret text file is 0.1 bits per pixel (bpp), which is at least 10 times lower compared to the DVS technique. This might result in a lower detection rate compared to DVS.
Figure 2: Example of the MSU StegoVideo tool, with a frame from a landscape video as cover.
### Network Architecture
We chose to use the Noise Residual Convolutional Neural Network (NR-CNN), as proposed by (Liu and Li, 2020) and discussed in section 2.3. They showed that the NR-CNN can detect both intraprediction mode and motion vector-based steganography by detecting the modification of pixel values in decoded frames. The steganography methods we aim to detect are not based on intraprediction modes or motion vectors but do also modify pixel values, therefore, the prospect is that the NR-CNN will also be effective in detecting both the DVS and MSU embedding approach.
The network architecture of the NR-CNN is shown in figure 1. The first layer is the residual convolutional layer "ResConv" whose role is to compute the steganographic noise residual from the video frames. It consists of 34 custom-made filters showed in figure 2.30 high-pass filters and 4 global filters. These filters will be automatically optimized during training. The input of the "ResConv" layer is single channel 224x224 image data (gray-scaled video frames). The
\begin{table}
\begin{tabular}{|l|l|l|l|l|l|} \hline _tt_ & Layer & Input & Output & Kernel Size & Notes \\ \hline
**1** & Residual convolutional layer & 1channel & 34 channels & (\(\mathbb{S}^{*}\)5) & Stride = 1, Batch Normalization, PTLU \\ \hline
2 & Convolutional layer 1 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)3) & Stride = 1, Batch Normalization, ReLu \\ \hline
3 & Convolutional layer 2 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)3) & Stride = 1, Batch Normalization, ReLu \\ \hline
4 & Convolutional layer 3 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)3) & Stride = 1, Batch Normalization, ReLu \\ \hline
5 & Average pooling layer 1 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)2) & Stride = 2 \\ \hline
6 & Steganalysis residual block 1 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)3) & \\ \hline
7 & Average pooling layer 2 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)3) & Stride = 2 \\ \hline
8 & Steganalysis residual block 2 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)3) & \\ \hline
9 & Average pooling layer 3 & 34 channels & 34 channels & (\(\mathbb{M}^{*}\)3) & Stride = 2 \\ \hline
10 & Convolutional layer 4 & 34 channels & 32 channels & (\(\mathbb{M}^{*}\)3) & Stride = 1, Batch Normalization, ReLu \\ \hline
**11** & Average pooling layer 4 & 32 channels & 32 channels & (\(\mathbb{M}^{*}\)2) & Stride = 2 \\ \hline
12 & Convolutional layer 5 & 32 channels & 16 channels & (\(\mathbb{M}^{*}\)3) & Stride = 1, Batch Normalization, ReLu \\ \hline
13 & Convolutional layer 6 & 16 channels & 16 channels & (\(\mathbb{M}^{*}\)3) & Stride = 3, Batch Normalization, ReLu \\ \hline
14 & Fully connected layer & 16\({}^{3}\)3\({}^{*}\)3 features & 3 features & NA & \\ \hline
15 & Softmax layer & 3 features & 3 outcomes & NA & \(\alpha\): regular, 1: deep stego, 2: MSU stego \\ \hline \end{tabular}
\end{table}
Table 1: The architecture of the Noise Residual Convolutional Neural Network (Liu and Li, 2020). The first layer computes the residual, the twelve subsequent layers perform the feature extraction and the final two layers complete the classification.
feature extraction part of the architecture consists of 6 convolutional layers with batch normalization, 4 average pooling layers and 2 steganalysis residual blocks. The steganalysis residual blocks are based on ResNet (He et al., 2016), but are improved for steganalysis by changing the final mapping from \(F(x)+x\) to \(x-F(x)\) to retain the steganographic residual signal. The classification part of the network consists of a fully connected (linear) layer and a softmax layer with three outputs representing the three possible classes: regular, deep-stego and MSU-stego.
### Experimental setup
The final steganography dataset contains \(k=3555\) videos, which are split into a training set, a validation set and a test set with respectively 1700, 174, and 1681 videos. The training set is used to train the NR-CNN and the validation set is used to validate the network during training. The test set is used to validate the network after training.
Before training, the videos from the training set are split into 5 segments, i.e., 2-second videos. From each segment, a random frame is picked to train the network with. This avoids training the network on possibly nearly similar subsequent frames, which may result in a network that is only working on the training set, i.e. overfitting. The frames are resized to 224x224 pixels and transformed into single channel gray-scale images. During the final evaluation
Figure 3: The 34 custom-made filters from the residual convolution layer of which the first 30 are high-pass filters and the last 4 are global filters. The filters will be optimized during training.
of the network, we have a similar pre-processing step, but the videos from the test set are split into 20 segments instead of 5 to eventually evaluate the trained network on more frames.
The NR-CNN is implemented on the deep learning framework PyTorch, and is trained on 8,000 frames with a batch size of 20. The rest of the training setup is similar to the setup used by (Liu and Li) 2020) for the NR-CNN. Hence, the number of training iterations is 150 epochs, and the network optimizer is AdaDelta with learning rate \(lr=0.4\), decay rate \(\rho=0.95\), a weight decay of \(5\times 10^{-4}\), and epsilon parameter \(eps=1\times 10^{-8}\). During training we try minimizing the Cross-Entropy loss.
The complete source code is available on Github[]
## 4 Results & Discussion
In this section, we will evaluate the effectiveness of the trained NR-CNN on the detection of the Deep Video Steganography and MSU StegoVideo tools. The results are shown in table 2 and 3 which lists the predictions from the network on, respectively, the frames of the training set and the test set. The training set with 34,000 frames has an accuracy of 99.99% with 3 wrong predictions, and the test set with 33,620 frames has an accuracy of 99.96% with 13 wrong predictions. During inspection of the frames that where wrongly predicted we found a few possible causes for the faulty classifications. Out of the 16 frames there where 6 almost completely black frames, which may indicate that black frames are difficult to classify. Also 6 frames with content from a CCTV camera where wrongly classified, probably due to the visible horizontal lines that we typically find in CCTV camera footage. This conjecture is supported by two other wrongly predicted frames, which also had horizontal lines in the frames
content. The two remaining frames did not show any clear possible cause of misclassification.
These results show that the NR-CNN is able to detect both the DVS and MSU embedding approaches with a remarkably high accuracy. One of the reasons for these high detection rates could be the fact that both steganography techniques leave behind some sort of clearly distinguishable watermark on the video frames. Such watermarks might be relatively easy to detect for convolutional neural networks, since CNN's are designed to classify shapes that have a number of similar features, which is the case for watermarks. It is however expected that every video steganography method will leave behind some sort of watermark and that makes the CNN-based steganalysis approach very promising. Another reason for the high accuracy on both techniques could be the high embedding rate, which is between 1 and 4 bits per pixel for DVS and approximately 0.1 for the MSU technique. However, if the embedding rate would have a significant impact on the detection rate, we should have expected to obtain more faulty
\begin{table}
\begin{tabular}{|c|c|c|c|} \hline
\begin{tabular}{c} Train labelsPredictions \\ \end{tabular} & regular & deep-stego & MSU-stego \\ \hline regular & 11580 & 0 & 0 \\ \hline deep-stego & 1 & 10817 & 2 \\ \hline MSU-stego & 0 & 0 & 11600 \\ \hline \end{tabular}
\end{table}
Table 2: The predictions from the NR-CNN per label class of the training set. The values represent the number of frames.
\begin{table}
\begin{tabular}{|c|c|c|c|} \hline
\begin{tabular}{c} Test labelsPredictions \\ \end{tabular} & regular & deep-stego & MSU-stego \\ \hline regular & 11620 & 0 & 0 \\ \hline deep-stego & 2 & 10512 & 6 \\ \hline MSU-stego & 0 & 5 & 11475 \\ \hline \end{tabular}
\end{table}
Table 3: The predictions from the NR-CNN per label class of the test set. The values represent the number of frames.
predictions for the MSU-stego class than for the deep-stego class, which is not the case.
5. Conclusions & future directions
The high accuracy of 99.99% and 99.96% on the train and test set, respectively, show that the Noise Residual Convolutional Network (NR-CNN), from (Liu and Li, 2020), is not limited to detecting intraprediction mode and motion vector-based steganography, but can also be trained to accurately detect and classify the Deep Video Steganography (DVS) and MSU StegoVideo (MSU) methods. Given that the NR-CNN is also able to detect the DVS and MSU steganographic methods, which are completely different in their embedding techniques compared to the intraprediction mode and motion vector-based methods, we can start considering the NR-CNN as a promising general forensic video steganalysis network. However, it should be noted that, for now, the detection capabilities of the NR-CNN are only tested on steganography methods that where present in the training set. Future studies should, therefore, investigate whether the NR-CNN is also able to detect steganography methods that it has not seen before.
The resulting trained NR-CNN from this research can be used to accurately identify and classify steganography videos created with the Deep Video Steganography and the MSU StegoVideo tool. Furthermore, the created dataset could be expanded to train the network in detecting and classifying additional steganographic methods. However, in order to create the videos for the dataset, the corresponding tools for these steganographic methods have to be available. This is the case for publicly available steganography methods but it is, for example, also possible that a new steganographic tool is found on a confiscated computer from a person of interest. This tool could then be utilized to expand the created steganography dataset, by creating additional steganography videos with a video dataset and self fabricated hidden secrets. Subsequently, the network
has to be retrained on the expanded dataset to also detect and classify that new tool in the future.
Experimental results show that a convolutional neural network based approach to detect and classify video steganography can perform exceptionally well. Future research should investigate whether the NR-CNN can be trained to use as a general forensic steganalysis tool.
|
2304.08162 | Cardiac Arrhythmia Detection using Artificial Neural Network | The prime purpose of this project is to develop a portable cardiac
abnormality monitoring device which can drastically improvise the quality of
the monitoring and the overall safety of the device. While a generic, low cost,
wearable battery powered device for such applications may not yield sufficient
performance, such devices combined with the capabilities of Artificial Neural
Network algorithms can however, prove to be as competent as high end flexible
and wearable monitoring devices fabricated using advanced manufacturing
technologies. This paper evaluates the feasibility of the Levenberg-Marquardt
ANN algorithm for use in any generic low power wearable devices implemented
either as a pure real-time embedded system or as an IoT device capable of
uploading the monitored readings to the cloud. | Prof Sangeetha R G, Kishore Anand K, Sreevatsan B, Vishal Kumar A | 2023-04-17T11:20:11Z | http://arxiv.org/abs/2304.08162v1 | # Cardiac Arrhythmia Detection using Artificial Neural Network
###### Abstract
The prime purpose of this project is to develop a portable cardiac abnormality monitoring device which can drastically improvise the quality of the monitoring and the overall safety of the device. While a generic, low cost, wearable battery powered device for such applications may not yield sufficient performance, such devices combined with the capabilities of Artificial Neural Network algorithms can however, prove to be as competent as high end flexible and wearable monitoring devices fabricated using advanced manufacturing technologies. This paper evaluates the feasibility of the Levenberg-Marquardt ANN algorithm for use in any generic low power wearable devices implemented either as a pure real-time embedded system or as an IoT device capable of uploading the monitored readings to the cloud.
**Keywords:** Levenberg-Marquardt Algorithm, Wearable Electronics, Artificial Neural Network, Cardiac
Abnormality Monitoring, Prediction
*Corresponding author(s). E-mail(s): [email protected];
[email protected]; [email protected];
[email protected];
## 1 Introduction
The pattern of cardiac rhythms has the implying that whether the heart beats typically or not. A healthy heart can effectively circulate blood throughout the body with a normal heartbeat. Heart surrenders alludes to the shortcomings and downfalls in the heart and its vasculature. These imperfections incorporate coronary illnesses and myocardial areas of localized necrosis. Heart abandons are for the most part liable for the aggravations in the normal pulsates of the heart, which is called arrhythmias [1].
The World Health Organization approximates that about 12 million deaths occur worldwide every year subsequently of Coronary Heart Diseases (CHD). Several aspects such as diabetes, HDL & LDL cholesterol, smoking, obesity, family history makes a person more susceptible to CHDs. In these scenarios, timely prediction and diagnosis of cardiac abnormalities proves to be absolutely necessary for people who are prone to such conditions.
In the region of Nagpur, India[2], the study authors conducted a screening camp for atrial fibrillation (AF) and collected essential data including blood pressure, height, weight, diabetes check and the ECG of the residents. Although AF is a public health issue of utmost importance throughout the world[3], this study also notes that a single study[4] conducted in a remote Himalayan village residents is the only large-scale population-based study of atrial fibrillation in India prevailing until their paper.
Artificial Neural Network is a critical tool for evaluation and prediction. ANN based consumer solutions in the medical industry plays an essential role in improvising the performance and credibility of medical management of general population. ANNs have the potential to sense for various critical conditions, in this case, various CHDs and arrhythmias. The surplus availability of the corresponding conditions' monitored readings (data sets) in electronic form means that the necessary resources to train an ANN model can be deployed with a significant reduction in both development time and time to market.
Since the equated model is trained to record the patterns and rhythms of the ECG wave-forms, ECG wave-forms have been obtained and processed through ANNs for the diagnosis of cardiovascular diseases. Disease detection is based on the P Q R S intervals. Despite the fact that there were a number of other
obstacles in the way, the final accuracy was only 71%, which is why multi-layer perceptron (MLP) backtracking began to be used in disease detection shortly after its introduction. With the assistance of ANNs, fully automated procedures were compared to the clinical interpretation.
The overview of this paper is assembled as follows. Section 2 lists the essential literature surveys. Section 3 gives an insight into the implementation methodology. Section 4 describes the Levenberg-Marquardt ANN model. Section 5 evaluates the final results and the general efficacy of the said ANN model in terms of accuracy and feasibility. The final conclusion of this paper is mentioned in Section 6.
## 2 Literature Survey
In this study [5], 500 pregnant women's NI-FECG and echocardiography recordings were gathered by the authors. The fetal echocardiography reference diagnostic and the NI-FECG-based diagnosis were compared after the cardiologists examined the extracted NI-FECG. This study comes to the conclusion that while it may be possible to detect the fetal arrhythmias with the of this NI-FECG technique, it is crucial to emphasise the improvements in the models that are used to reconstruct the P-wave.
In another study [6], the authors have given an insight into the significance of using an Apple Watch to clinically monitor the heart beat rates.
Yet another study [7] discusses about the Intrapartum fetal cardiac arrhythmias. Using a direct fetal ECG, the authors of this paper gathered 15 incidences of fetal cardiac arrhythmia. According to the study, there are 12.4 arrhythmias for every 1000 observed newborns. The report also mentions that any arrhythmia was associated with the varied decelerations.
This particular study [8], the authors have evaluated the transpiring aspects of electronic wearable technologies in the detection of arrhythmia. This paper evaluates the performance of photoplethysmography (PPG) based wearable devices with and without the aid of machine-learning algorithms with the authors concluding that the latter proved to give a more reliable performance.
The above studies were essential for this paper.
## 3 Implementation Methodology
This paper describes our implementation of a real-time embedded battery powered working model. The all-inclusive block diagram is demonstrated in the following figure:
The working model comprises of an Arduino UNO development board (with ATmega328P as its 8-bit microcontroller), a generic heart sensor - for monitoring the heart beats in real-time and a power source. The monitored readings will be stored in a Microsoft Excel spreadsheet and this file is used as a database for the ANN.
In the context of this paper, the Jupyter Notebook Python tool has been used to implement the Levenberg-Marquardt algorithm to predict the prevalence of any underlying cardiac abnormalities along with the predicted 'death rates'.
## 4 Levenberg-Marquardt ANN Model
The Levenberg-Marquardt (LM), an advanced non-linear optimization algorithm [9] is one of the fastest algorithm available for MLPs. The principal application of Levenberg-Marquardt algorithm lies on solving the issue of fitting least squares curve which is also sketched for minimizing the sum of square error functions. The LM algorithm optimises the variables of the curve of the mentioned model \(f(x,\beta)\) in a known realistic data collection of variables, \((x_{i},y_{i})\), whereupon one can achieve infinitesimally the product of the squared values of the deviations \(S(\beta)\) becomes.
\[S(\beta)=\sum_{i=1}^{a}[y_{i}-f(x_{i},\beta)]^{2} \tag{1}\]
The parameter vector, \(\beta\), is changed in each weight change step by a fresh approximation, \((\delta+\beta)\). The linear equivalent of the functions \(f(x_{i},\delta+\beta)\) is used to determine \(\delta\)[10].
\[f(x_{i},\delta+\beta)\thickapprox J_{i}\delta+f(x_{i},\beta) \tag{2}\]
Wherein the variables: \(J_{i}=\frac{f(x_{i},\beta)\delta}{j\delta}\) is the descent of the function \(f\) with respect to the parameter vector \(\beta\).
Regarding, we select the derivative of \(S\). To obtain the smallest values of the squares added together, \(S(\beta)\), use this \(\delta\) value and set it to zero. The resulting equation is:
\[(\lambda I+J^{T}J)\delta=J^{T}[y-f(\beta)] \tag{3}\]
\[J=\begin{bmatrix}\frac{\delta y_{1}}{\delta x_{1}}&...&\frac{\delta y_{1}}{ \delta x_{b}}\\ &:&:\\ \frac{\delta y_{2}}{\delta x_{1}}&...&\frac{\delta y_{m}}{\delta x_{b}}\end{bmatrix} \tag{4}\]
Where \(J\) is the Matrix of Jacobean, \(I\) is the Matrix of Identity, \(\delta\) as the incrementing factor added to \(\beta\) and \(\lambda\) is the damping factor.
A smaller value can be used if the fluctuation of S is quick, putting the process closer to the Gauss-Newton technique. One single step nearer to the gradient descent approach can be achieved for modest changes in S by increasing \(\lambda\)[11]. The diagonal matrix made up of the \(J^{T}J\) diagonal elements replaces the identity matrix (\(I\)) in the Levenberg-Marquardt method.
With the use of the LM approach, gradient components can be scaled in accordance with curvature to allow for bigger swaying in the direction of minor gradients and prevent the slow convergence on these directions.
## 5 Algorithm Evaluation and Results
### Input Data Analysis
The database used to test the performance and working of the Levenberg-Marquardt ANN model contains hundreds of patient's clinical record. For the reason of simplicity and clarity, only 5 of it is mention in the following tabulation:
\begin{tabular}{||c c c c c c c c||} \hline Age & Anaemia & Diabetes & High BP & Platelets & Sex & Smoking & Time & Death Event \\ \hline \hline
75 & 0 & 0 & 1 & 265000 & 1 & 0 & 4 & 1 \\ \hline
55 & 0 & 0 & 0 & 263358.03 & 1 & 0 & 6 & 1 \\ \hline
65 & 0 & 0 & 0 & 162000 & 1 & 1 & 7 & 1 \\ \hline
50 & 1 & 0 & 0 & 210000 & 1 & 0 & 7 & 1 \\ \hline
65 & 1 & 1 & 0 & 327000 & 0 & 0 & 8 & 1 \\ \hline \end{tabular}
### Output Results
The complete database have been used to train and validate the Levenberg-Marquardt model. The following figure shows the data representation in Jupyter Notebook Python:
The following figures represent the accuracy of prediction of cardiac abnormality:
The following figures represent the accuracy of prediction of cardiac abnormality:
The figure for confusion matrix of the trained model is as follows:
## 6 Conclusion & Future Work
Taking everything into account, when the ANN was prepared, approved and tried in the wake of upgrading the information boundaries, the generally speaking prescient precision acquired was 93.034
The selected database has been used to confirm the accuracy of the system's generated results. As a result, the proposed ANN model can successfully identify individuals at risk for coronary heart disease and predicts future risks for patients.
|
2304.01620 | Image Blind Denoising Using Dual Convolutional Neural Network with Skip
Connection | In recent years, deep convolutional neural networks have shown fascinating
performance in the field of image denoising. However, deeper network
architectures are often accompanied with large numbers of model parameters,
leading to high training cost and long inference time, which limits their
application in practical denoising tasks. In this paper, we propose a novel
dual convolutional blind denoising network with skip connection (DCBDNet),
which is able to achieve a desirable balance between the denoising effect and
network complexity. The proposed DCBDNet consists of a noise estimation network
and a dual convolutional neural network (CNN). The noise estimation network is
used to estimate the noise level map, which improves the flexibility of the
proposed model. The dual CNN contains two branches: a u-shaped sub-network is
designed for the upper branch, and the lower branch is composed of the dilated
convolution layers. Skip connections between layers are utilized in both the
upper and lower branches. The proposed DCBDNet was evaluated on several
synthetic and real-world image denoising benchmark datasets. Experimental
results have demonstrated that the proposed DCBDNet can effectively remove
gaussian noise in a wide range of levels, spatially variant noise and real
noise. With a simple model structure, our proposed DCBDNet still can obtain
competitive denoising performance compared to the state-of-the-art image
denoising models containing complex architectures. Namely, a favorable
trade-off between denoising performance and model complexity is achieved. Codes
are available at https://github.com/WenCongWu/DCBDNet. | Wencong Wu, Shicheng Liao, Guannan Lv, Peng Liang, Yungang Zhang | 2023-04-04T08:21:46Z | http://arxiv.org/abs/2304.01620v1 | # Image Blind Denoising Using Dual Convolutional Neural Network with Skip Connection
###### Abstract
In recent years, deep convolutional neural networks have shown fascinating performance in the field of image denoising. However, deeper network architectures are often accompanied with large numbers of model parameters, leading to high training cost and long inference time, which limits their application in practical denoising tasks. In this paper, we propose a novel dual convolutional blind denoising network with skip connection (DCBDNet), which is able to achieve a desirable balance between the denoising effect and network complexity. The proposed DCBDNet consists of a noise estimation network and a dual convolutional neural network (CNN). The noise estimation network is used to estimate the noise level map, which improves the flexibility of the proposed model. The dual CNN contains two branches: a u-shaped sub-network is designed for the upper branch, and the lower branch is composed of the dilated convolution layers. Skip connections between layers are utilized in both the upper and lower branches. The proposed DCBDNet was evaluated on several synthetic and real-world image denoising benchmark datasets. Experimental results have demonstrated that the proposed DCBDNet can effectively remove gaussian noise in a wide range of levels, spatially variant noise and real noise. With a simple model structure, our proposed DCBDNet still can obtain competitive denoising performance compared to the state-of-the-art image denoising models containing complex architectures. Namely, a favorable trade-off between denoising performance and model complexity is achieved. Codes are available at [https://github.com/WenCongWu/DCBDNet](https://github.com/WenCongWu/DCBDNet).
keywords: Image Denoising, Dual CNN, Skip Connection, Dilated Convolution, Noise Estimation Network +
Footnote †: journal: arXiv
## 1 Introduction
In the process of image acquisition and transmission, noise is hardly to be avoided, which seriously affects the visual quality of images, therefore noise removal is an extremely important step for many image processing tasks [1]. All denoising methods aim to obtain the clean image \(x\) from its noisy observation \(y\) by eliminating the noise \(n\), namely \(x=y-n\). Over the decades, many denoising methods have been proposed. For instance, the non-local means (NLM) [2] uses the average of all pixels in an image to achieve noise filtering. In GNLM [3], the grey theory [4] is integrated into the NLM to further improve its denoising performance. Targeted image denoising (TID) [5] improves denoising performance by using a dataset that contains similar image patches. Block-matching and 3-dimensional filtering (BM3D) [6] enhances the sparse representation by collaborative alteration for image denoising. The learned simultaneous sparse coding (LSSC) [7] combines the non-local means and sparse coding approaches to realize noise removal. Other denoising methods based on non-local self-similarity (NSS) [8; 9], sparse learning [10; 11; 12], gradient learning [13; 14; 15; 16], Markov random field (MRF) [17; 18; 19; 20], total-variation (TV) [21; 22], and weighted nuclear norm minimization (WNNM) [23; 24] were also proposed.
Although the above-mentioned traditional denoising methods have achieved favorable denoising performance, most of these approaches have two shortcomings: (1) the complex optimization algorithms of these methods lead to massive running time consumption, and (2) many models require a considerable number of manual setting parameters,
which increases the uncertainty of denoising results. There are some denoising methods based on image priors such as the fields of experts [18], cascade of shrinkage fields (CSF) model [25], or the trainable nonlinear reaction diffusion (TNRD) [26], they do not need time-consuming optimization procedures, or less manually set parameters are required during model training, however the performances of these methods are limited by the specific forms of image priors. Inspired by the CSF and TNRD, Zhang et al. [27] proposed a successful denoising convolutional neural network (DnCNN). However, the DnCNN performs well only in a limited range of noise levels. Since the advent of DnCNN, deep neural networks (DNN) based models have become the most popular denoising methods [28; 29]. However, the early DNN based denoising models like DnCNN need to train a specific model for a specific noise level, the limited flexibility of these models makes them hard to be utilized in real denoising scenes.
To make the DNN based denoising models more flexible, many techniques have been developed. Some researchers try to use a tunable noise level map as the network input [30; 31], therefore it is capable of handling a wide range of noise levels including spatially variant and invariant noise. However, the noise level map has to be manually pre-defined. To realize blind denoising, many models try to incorporate a noise estimation sub-network to obtain noise distribution in an image, such as the convolutional blind denoising network (CBDNet) [32], the blind universal image fusion denoiser (BUIFD) [33], and the variational denoising network (VDN) [34], promising denoising performances have been obtained.
Although increasing the depth of the neural networks may improve their learning ability, the problem of huge network parameters and high computational costs will also be brought, and it has been verified that the accuracy of the network will decline when the network depth is increased constantly, therefore many researchers have proposed to expand the width of the networks instead of the depth. Especially, in [35; 36; 37], the dual CNNs are designed for image denoising, illustrating that the competitive denoising performance can also be obtained by increasing the width of the deep neural network models.
Recently, many research works have revealed that the skip connection [38; 39], dilated convolution [40], and the U-Net [41] can be helpful for deep image denoising models. The dilated convolution and the U-Net can enlarge the receptive fields of convolution layers, and skip connection has the ability to accelerate network training, also they can provide better feature preservation during feature transposing. Some recently proposed denoising models such as IRCNN [42], DSNet [43], BRDNet [36], DRUNet [31], RDUNet [44], and the DDUNet [45] have achieved remarkable denoising performances by using these techniques.
Inspired by the success of the above-mentioned techniques in image denoising, in this paper, we propose a novel dual convolutional blind denoising network with skip connection (DCBDNet) to achieve effective denoising performance. The proposed DCBDNet model contains a noise estimation network and a dual convolutional neural network (CNN) with two sub-networks. In the proposed dual convolutional network, one sub-network is a u-shaped convolutional network, where the downsampling and upsampling are used. Another sub-network contains dilated convolutional layers to enlarge the receptive field of the convolution layers. Skip connections are employed in both sub-networks to fuse the features from different convolution layers. The features from the two sub-networks are then concatenated to produce the denoised image. The proposed DCBDNet owns the following favorable characteristics:
(1) A noise estimation network with a large receptive field is designed, which can extract more useful information and estimate the noise level map accurately.
(2) The dual CNN of the proposed DCBDNet utilizes downsampling operations and dilated convolutions to enlarge the receptive field. Moreover, skip connections are utilized to preserve more image details for denoising.
(3) Experimental results verify that our proposed DCBDNet achieves more robust and efficient denoising performance than similar networks on both synthetic and real noisy images.
The remainder of this paper is organized as follows. Section 2 gives a brief introduction of the related image denoising techniques. Section 3 introduces our proposed model. Section 4 presents our experimental results. The paper is concluded by Section 5.
## 2 Related work
The dual sub-network structure is one of the methods that are used to expand the width of the network, where generally two different sub-networks are designed to achieve complementary feature learning. In [35], a DualCNN contains two sub-networks was proposed for low-level vision tasks, where the shallow branch is used for obtaining
the whole structure of an image, and another deeper branch is designed for capturing image details. Tian et al. [37] designed a dual denoising network (DudeNet), which can extract global and local features to enhance the network performance. A batch-renormalization denoising network (BRDNet) was proposed in [36], which includes an upper and a lower sub-networks to increase the network width.
It is worth noting that the BRDNet [36] has a large difference in the sizes of the receptive fields in its upper and lower sub-networks, which may degrade its learning ability and denoising performance. In addition, the dilated rate of the dilated convolutions in BRDNet is fixed, which may lead to the loss of image details, generating the gridding phenomenon. The BRDNet with two 17-layer sub-networks has a deeper network structure and more network parameters. Moreover, in BRDNet, one network is trained for only one specific noise level, which leads to its inflexibility and impracticality. In this paper, we also develop a dual CNN structure, however we aim to design a more flexible denoising network to realize blind denoising. Different from the BRDNet, our dual CNN contains fewer layers. The downsampling and upsampling are used in our upper sub-network, and the hybrid dilated convolutions are utilized in the lower sub-network, which can augment the receptive field, and the sizes of the receptive fields of the two branches can keep close. More importantly, in our model, a noise estimation network is developed for obtaining a noise level map, which makes our model fully blind.
To address the problem of model flexibility, Zhang et al. [30] proposed a fast and flexible denoising convolutional neural network (FFDNet), and a tunable or non-uniform noise level map helps FFDNet can handle a wide range of noise levels including spatially variant and invariant noise, the DRUNet [31] also takes this type of noise level map as its input. DRUNet achieves the state-of-the-art denoising performance, however it has a large number of network parameters and a complex network structure. Moreover, since the noise distributions in a real noisy image are unknown, the manually defined noise level map used in the FFDNet and the DRUNet makes them hard to be applied in real denoising scenes.
In order to make a denoising model fully blind, many different techniques have been developed. In DeamNet [46], a dual element-wise attention mechanism (DEAM) module, and a new adaptive consistency prior (ACP) are introduced for blind image denoising. The AirNet [47] adopts the concept of contrast learning [48] to recover images from multiple types of degradation. The VDIR [49] utilizes variational framework for image restoration tasks. One popular and effective way to realize blind denoising is to equip a denoising model with a noise estimation sub-network, which usually is a convolution neural network has a simple structure, aiming to obtain the noise distributions in an image automatically. The noise estimation network of the CBDNet [32] and VDN [34] adopts a 5-layer fully convolutional network, the convolution kernel sizes are \(3\times 3\times 32\) and \(3\times 3\times 64\), respectively. Neither the pooling nor batch normalization operations are used in their noise estimation network. The noise estimator of the BUIFD [33] consists of a 7-layer fully convolutional network with a convolution kernel of \(5\times 5\times 64\), where the pooling is also not used, while the batch normalization is applied.
U-Net [41] was originally designed for semantic segmentation of multi-scale features, and later was utilized in the field of image denoising. A residual dense U-Net neural network (RDUNet) was presented in [44], which employs densely connected convolutional layers to reuse the feature maps, the local and global residual learning is used to avoid the gradient vanishing and accelerate the network training. Jia et al. [45] proposed a multi-scale cascaded U-Nets architecture called the Dense U-Net (DDUNet) for image denoising. The multi-scale dense skip connections are used for feature superposing across the cascading U-Nets, which promotes feature recycling and avoids the gradient vanishing. The DRUNet [31] utilizes the combination of the U-Net [41] and ResNet [38] as its model structure, and the state-of-the-art denoising performance was reported. The success of these U-Net based denoising models has demonstrated that U-Net can be an effective tool for image denoising.
Dilated convolution was first employed for wavelet decomposition [50]. Later, Yu et. al. [40] proposed a multi-scale context aggregation network for image segmentation based on dilated convolutions, and promising results have been obtained. The dilated convolution has the ability to enlarge the receptive field, a bigger receptive field can let the model extract more context information, therefore to promote the learning ability. Many denoising models have incorporated dilated convolutions in their networks. For instance, Zhang et al. [42] designed an image restoration CNN (IRCNN) for image blind denoising, image deblurring, and single image super-resolution. The hybrid dilated filters [51; 52] are utilized in IRCNN to enlarge the receptive field and address the gridding phenomenon. Following IRCNN, a dilated residual network (DSNet) [43] uses symmetric skip connections to further improve the denoising performance. The lower branch of the BRDNet [36] also adopts dilated convolutions to capture more context information.
Skip connection [38; 39] is generally used for tackling the problem of gradient vanishing or exploding during back-propagating. DnCNN [27] only uses one skip connection to obtain the denoised image. Mao et al. [53] proposed a very deep residual encoder-decoder network called the RED-Net for image restoration, where the skip connections are used to facilitate network training. A lightweight dense dilated fusion network (DDFN) was presented in [54; 55] for real-world image denoising, which tackles the vanishing or exploding of gradients by skip connections during network training. A single-stage blind real image denoising network (RIDNet) was designed in [56], which contains the enhancement attention modules (EAM) with short and long skip connections to improve denoising performance. Anwar et al. [57] developed an identity enhanced residual denoising (IERD) network with short and long skip connections for image denoising. It can be seen that using skip connections can be helpful for model training. More importantly, the features from different layers can be fused through skip connections, therefore much more semantic and structural features in images can be preserved.
## 3 The proposed model
### Network architecture
Our proposed DCBDNet consists of a noise estimation network and a dual convolutional denoising network (CNN). The architecture of the proposed DCBDNet is shown in Fig. 1. The model contains two main sub-networks: a noise estimation network (the green dashed box in Fig. 1) and a dual CNN denoising network (the orange dashed box in Fig. 1). The noise level map in a noisy image is first obtained by the noise estimation network, and it will be fed into the dual CNN with the noisy image together to produce the denoised result. The proposed dual CNN contains a U-shaped upper branch, and a lower branch with dilated convolutions, skip connections are applied in both branches.
#### 3.1.1 Noise Estimation Network
To achieve image blind denoising, we use a noise estimation network to estimate the noise level map. In CBDNet [32] and VDN [34], an estimation network with 5 convolutional layers is used. In order to obtain a larger receptive
Figure 1: The network architecture of the proposed model for image denoising.
field, we design a noise estimation network with 7 convolutional layers, the convolutional kernel size is \(3\times 3\times 64\).
Our noise estimation network consists of Conv, max-pooling (Downsampling) [58], bilinear interpolation (Up-sampling) [59], batch normalization (BN) [60], rectified linear unit (ReLU) [61] and Tanh [62]. The downsampling and upsampling operations are utilized to enlarge its receptive field, which can extract more complex noise information and estimate the noise level map more accurately. As the downsampling operation may lead to a loss of image information, a skip connection is used in the network to reduce the loss.
It is apparent if the estimated noise level or noise distribution does not match the noise in the input image, the denoising performance will decline. In practice, people tend to estimate a high noise level to remove more noise, however if the estimated noise level is much higher than the real one, unwanted visual artifacts will be brought. As has been verified in [30; 31], the orthogonal initialization of the convolutional filters [63; 64; 65] is an effective way to solve this problem. Therefore the orthogonal initialization is also utilized in our network to obtain a balance between noise removal and image detail preservation.
#### 3.1.2 Dual Convolutional Neural Network
Much previous work has verified that expanding the width of the network is also an effective way for improving network performance [66]. Therefore, we propose a dual CNN contains two parallel sub-networks to expand the width of the model, which contains an upper and a lower sub-networks. The upper sub-network contains standard convolution (Conv), max-pooling (Downsampling) [58], bilinear interpolation (Upsampling) [59], skip connections [38; 39], batch normalization (BN) [60], and rectified linear unit (ReLU) [61]. The lower sub-network comprises dilated convolution (DConv) [40], skip connection, BN, and ReLU. Different types of convolution filters allow the two sub-networks can extract complementary image features [67] and therefore enhance the generalization ability of the proposed DCBDNet.
Aiming for a desirable balance between network complexity and denoising performance, we set 12 convolutional layers for the upper and lower sub-networks respectively, and one convolutional layer after their concatenation. The convolutional filter size is set to \(3\times 3\times 64\) for both grayscale and color images. Moreover, in order to obtain similar sizes of the receptive fields in the two sub-networks and reduce the computational cost of the upper sub-network, different from the standard U-Net, in our dual CNN only two downsampling and upsampling operations are used. Since the downsampling operations will lead to the loss of image information, two skip connections are applied for feature superposing in the upper sub-network. Furthermore, symmetric skip connections are employed in the lower sub-network to accelerate its training and improve its detail preservation. The skip connections can also avoid the gradient vanishing or exploding for back-propagating during the network training.
The downsampling in the upper sub-network and the dilated convolutions in the lower sub-network aim to widen the receptive field and keep the sizes of the receptive fields in both two sub-networks close, which can obtain more image context and detail features. Inspired by the hybrid dilated convolution (HDC) [51; 52], we employ different dilated rates for each dilated convolution layer, and the rate in each layer is set to 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 1, which can eliminate the gridding phenomenon and enhance the denoising performance [52]. The receptive fields of upper and lower sub-networks in different layers are listed in Table 1. It can be found that the two sub-networks own approximately the same size of receptive fields in the last layer. Specifically, if the receptive fields of two sub-networks have a large difference, it will lead to an increase in the computational cost of one sub-network, simultaneously the other sub-network may not extract enough image information due to the size limitation of its receptive fields, which may result in degradation of denoising performance.
### Loss function
In this subsection, we discuss the loss function of the proposed DCBDNet. To train the network parameters of the proposed DCBDNet for the AWGN removal, we select the average mean-square error (MSE) as the optimization
\begin{table}
\begin{tabular}{l l l l l l l l l l l l} \hline \hline Layer & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\ \hline Upper sub-network & 30 & 34 & 38 & 48 & 56 & 74 & 90 & 106 & 122 & 138 & 154 & 170 \\ \hline Lower sub-network & 30 & 38 & 50 & 66 & 86 & 110 & 130 & 146 & 158 & 166 & 170 & 174 \\ \hline \hline \end{tabular}
\end{table}
Table 1: The receptive fields of the upper and lower sub-networks in different layers.
target, which is the most widely used optimization function. The loss function is defined in Eqn. (1).
\[\begin{split}\mathcal{L}(\theta)&=\frac{1}{2K}\sum_{j=1 }^{K}\left\|\mathcal{F}(y_{j};\theta)-x_{j}\right\|^{2}\\ &=\frac{1}{2K}\sum_{j=1}^{K}\left\|\hat{x}-x_{j}\right\|^{2}, \end{split} \tag{1}\]
where \(x_{j}\), \(\hat{x}\), and \(y_{j}\) represent the clean, predicted, and noisy images, respectively. \(\theta\) is the trainable network parameters, and \(K\) is the number of clean-noisy image patches.
For the real noise with spatial variation, using MSE as a loss function will produce a blurry and over-smoothed visual effect, and the high-frequency textures may be lost due to the square penalty. Therefore, the Charbonnier loss [68] is chosen as the reconstruction loss to optimize our DCBDNet. Moreover, to further enhance the fidelity and authenticity of high-frequency details when removing noise, following [69], we employ an edge loss to constrain the high-frequency components between the ground-truth image \(x\) and the denoised image \(\hat{x}\). As our proposed DCBDNet includes a noise estimation network to estimate the noise level map \(\sigma(y)\) in the noisy image \(y\), referring to [32], we adopt a total variation (TV) regularizer to constrain the smoothness of the estimated noise level. In summary, the overall loss function of our DCBDNet is defined as:
\[\mathcal{L}=\mathcal{L}_{char}(\hat{x},x)+\lambda_{edge}\mathcal{L}_{edge}( \hat{x},x)+\lambda_{TV}\mathcal{L}_{TV}(\sigma(y)), \tag{2}\]
where \(\lambda_{edge}\) and \(\lambda_{TV}\) empirically are set to 0.1 and 0.05, respectively. \(\mathcal{L}_{char}\) stands for the Charbonnier loss, which is defined as:
\[\mathcal{L}_{char}=\sqrt{\left\|\hat{x}-x\right\|^{2}+\epsilon^{2}}, \tag{3}\]
where the constant \(\epsilon\) is set as \(10^{-3}\). The edge loss \(\mathcal{L}_{edge}\) is designed as:
\[\mathcal{L}_{edge}=\sqrt{\left\|\triangle(\hat{x})-\triangle(x)\right\|^{2}+ \epsilon^{2}}, \tag{4}\]
where \(\triangle\) denotes the Laplacian operator [70]. \(\mathcal{L}_{TV}\) is defined as:
\[\mathcal{L}_{TV}=\left\|\triangledown_{h}\sigma(y)\right\|_{2}^{2}+\left\| \triangledown_{v}\sigma(y)\right\|_{2}^{2}, \tag{5}\]
where \(\triangledown_{h}(\triangledown_{v})\) is the gradient operator along the horizontal (vertical) direction.
## 4 Experiments and results
### Datasets
For the AWGN removal, the DIV2K dataset [71] is used for our DCBDNet training, the dataset contains 800 high-resolution color images as training data, and 100 high-resolution color images for validation. The size of the training images in DIV2K was re-scaled to \(512\times 512\), and the images were grayscaled for training the grayscale image denoising model. The training images were randomly cropped into image patches. As the patch size is extremely important for the network training, based on the architecture of our proposed DCBDNet, the size of the image patches used in our experiments is set to \(180\times 180\). Since a noise estimation network and two sub-networks are contained in our proposed DCBDNet, the size of the receptive field of the upper sub-network is 170, and 174 for the lower sub-network.
In general, the size of image patches should be larger than the receptive fields of convolution layers, therefore the patch size of \(180\times 180\) is appropriate for our DCBDNet training, for both grayscale images and color images. The patch size used here is larger than the patch sizes used in many other denoising models, which are usually set as \(50\times 50\), however our experimental results illustrate that due to the larger patch size, the proposed DCBDNet can capture more image context features for improving denoising performance, especially for the images contain high
noise levels. The AWGN in the noise level range of \([0,75]\) was added to each clean image patch to obtain noisy image patches.
The Set12 and BSD68 datasets [72] were used for our grayscale image denoising evaluation. The CBSD68 [72], Kodak24 [73] and McMaster [74] datasets were selected for the evaluation of color image denoising. For real image denoising, the training data of the SIDD[75] and RENOIR [76] datasets are selected for our model training. The SIDD training data contains 320 pairs of noisy images and the near noise-free counterparts. The RENOIR dataset is composed of 240 pairs of noisy images and the near noise-free counterparts. In order to facilitate network training, the images in these two datasets were randomly cropped into image patches of size \(180\times 180\). Moreover, the rotation and flipping operations were used for data augmentation. The SIDD validation set, DND sRGB images [77], RN15 [78] and Nam [79] datasets were used for evaluation. We also validated the effectiveness of our model on the Set5 dataset [80] for spatially variant noise.
### Experimental settings
All our experiments were implemented on a computer with a sixteen-core Intel(R) Core(TM) i7-11700KF CPU @ 2.50GHz, 32 GB of RAM, and an NVIDIA GeForce RTX 3080Ti GPU. The proposed DCBDNet for grayscale and color images were trained respectively. It costs about 42 hours to complete DCBDNet training. For the DCBDNet model of real denoising, it takes about 50 hours to train our model.
The model parameters are optimized by the Adam optimizer [81]. For the AWGN removal, the DCBDNet was trained for 700,000 iterations, during which the initial learning rate is \(10^{-4}\) and then decreases by half every 100,000 iterations. For real image denoising, we applied 120 epochs to train the DCBDNet model, during which the initial learning rate is \(2\times 10^{-4}\) and is steadily reduced to \(10^{-6}\) using cosine annealing strategy [82]. The batch size was set to 16. For other hyper-parameters of the Adam algorithm, we used the default settings.
### Ablation study
In order to validate the effectiveness of our proposed network architecture, especially the effects of the skip connection, we trained four different networks for grayscale and color image denoising, respectively. The models under the combinations of with/without skip connection and with/without batch normalization (BN) were trained and tested. The four different models and their corresponding performances can be seen in Fig. 2. The Set12 [72] and Kodak24 [73] datasets were used for grayscale and color image denoising evaluation, respectively. The noise level was set to 25, and the averaged PSNR on each 10,000 iterations was recorded.
In Fig. 2, it can be seen that the denoising network with skip connection and BN achieves a better denoising performance than the other three networks on both grayscale images and color images. The results have verified that using skip connection and BN in the denoising network can enhance its performance.
### Denoising Evaluation
We evaluated the denoising performance of our DCBDNet model quantitatively and qualitatively. For quantitative analysis, we calculate the peak signal-to-noise ratio (PSNR), structural similarity index measure (SSIM) [83], feature similarity index measure (FSIM) [84], the learned perceptual image patch similarity (LPIPS) as well as the DeepFeatures [85] and Inception-Score [86]. For qualitative evaluation, we compared the visual effect of the denoised images from different methods.
### Evaluation of spatially invariant AWGN removal
We first present the results of the spatially invariant AWGN removal on grayscale images. Table 2 reports the PSNR values at different noise levels for the compared denoising methods on the Set12 dataset. It can be seen that the denoising performance of our proposed DCBDNet is slightly inferior to the DeamNet and DRUNet. However, the DeamNet and DRUNet are both equipped with complex network structures. The performance of the proposed DCBDNet is lower than the denoising results of the BRDNet on the noise levels of 15 and 25, but higher than BRDNet when the noise level is 50, which indicates that our DCBDNet is more robust for the images with high noise levels. More importantly, our proposed DCBDNet has a more compact network than BRDNet.
It should be noted that the WNNM obtained excellent denoising performances under different noise levels on the image "Barbara". There are rich repetitive structures exist in this image, and they can be effectively learned by the
methods like WNNM which is based on non-local self-similarity learning. One can also see that the performance of TID is unsatisfied under all tested noise levels, as TID works well only on the specific datasets which contain images have similar image patches, however the Set12 dataset does not meet the above condition.
Table 3 shows the averaged SSIM on the Set12 dataset for the compared denoising methods. It can be seen that our DCBDNet obtains competitive performance, the DeamNet and DRUNet obtain the leading results, however the DRUNet uses a manually pre-defined noise level map to obtain the results, and both the DeamNet and DRUNet have much deeper network structure than our model.
Table 4 and Table 5 list the averaged PSNR and SSIM results on the BSD68 dataset for the compared denoising methods, respectively. Table 6 lists the average FSIM on the Set12 and BSD68 datasets of the compared denoising methods. One can see that our DCBDNet model obtains competitive denoising performance.
Fig. 3 shows the denoised results on the "Castle" image from the BSD68 dataset at the noise level 50 of different methods. In Fig. 3, we zoom in a region (green box) for detail comparison (red box). It can be seen that though the DeamNet and DRUNet achieve high PSNRs, the 'over-smooth' effects are also brought. The DeamNet completely replaces the white small region (not noise) with the image context (Fig. 3 (h)), and the DRUNet changes the original irregular white region into a regular one (Fig. 3 (i)), while our proposed method can maintain a balance between noise removal and detail preservation (Fig. 3 (j)).
To evaluate the denoising performance of AWGN removal on color images, the CBSD68, Kodak24, and McMaster datasets were used. The PSNR values obtained by the compared methods are listed in Table 7. It can be seen that our proposed DCBDNet outperforms all the compared methods except the DRUNet on CBSD68, Kodak24, and McMaster datasets at noise levels 50 and 75. The proposed DCBDNet outperforms the BRDNet on the three datasets when the noise level is greater than 35. As the BRDNet also employs a dual CNN structure, we think the reason is a deeper network structure like the one used in the BRDNet may have more learning ability when the noise power is not strong.
Table 8 shows the averaged SSIM, FSIM, LPIPS, and the Inception-Score (IS) results of different methods on CBSD68, Kodak24, and McMaster datasets. Our DCBDNet model outperforms DnCNN, IRCNN, and FFDNet on the four evaluation metrics.
The visual results of color image AWGN removal at noise level 50 can be seen in Fig. 4, where the "kodim22" image from the Kodak24 dataset is used. It can be seen that the small white dot in the red box is overly smoothed by CBM3D and AirNet, while it is well preserved by our DCBDNet.
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|} \hline Methods & \(\sigma\)=15 & \(\sigma\)=25 & \(\sigma\)=35 & \(\sigma\)=50 & \(\sigma\)=75 \\ \hline BM3D [6] & 31.07 & 28.57 & 27.08 & 25.62 & 24.21 \\ \hline WNNM [23] & 31.37 & 28.83 & 27.30 & 25.87 & 24.40 \\ \hline TNRD [26] & 31.42 & 28.92 & - & 25.97 & - \\ \hline DnCNN-S [27] & 31.72 & 29.23 & 27.69 & 26.23 & 24.64 \\ \hline BUIFD [33] & 31.35 & 28.75 & 27.03 & 25.11 & 22.68 \\ \hline IRCNN [42] & 31.63 & 29.15 & 27.66 & 26.19 & - \\ \hline FFDNet [30] & 31.63 & 29.19 & 27.73 & 26.29 & 24.79 \\ \hline DSNetB [43] & 31.69 & 29.22 & - & 26.29 & - \\ \hline RIDNet [56] & 31.81 & 29.34 & - & 26.40 & - \\ \hline BRDNet [36] & 31.79 & 29.29 & - & 26.36 & - \\ \hline ADNet [87] & 31.74 & 29.25 & - & 26.29 & - \\ \hline DudeNet [37] & 31.78 & 29.29 & - & 26.31 & - \\ \hline CDNet [88] & 31.74 & 29.28 & 27.77 & 26.36 & 24.85 \\ \hline DeamNet [46] & 31.91 & 29.44 & - & 26.54 & - \\ \hline DRUNet [31] & 31.91 & 29.48 & 28.02 & 26.59 & 25.10 \\ \hline DCBDNet & 31.65 & 29.24 & 27.80 & 26.37 & 24.86 \\ \hline \end{tabular}
\end{table}
Table 4: The averaged PSNR (dB) results of the compared methods on BSD68 dataset with different noise levels. The best, second best and third best is highlighted in red, blue and green, respectively.
\begin{table}
\begin{tabular}{c c c c} \hline Noise level & \(\sigma\)=15 & \(\sigma\)=25 & \(\sigma\)=50 \\ \hline BM3D [6] & 0.896 & 0.851 & 0.766 \\ \hline WNNM [23] & 0.894 & 0.846 & 0.756 \\ \hline TNRD [26] & 0.896 & 0.851 & 0.768 \\ \hline DnCNN-S [27] & 0.903 & 0.862 & 0.783 \\ \hline BUIFD [33] & 0.899 & 0.855 & 0.755 \\ \hline IRCNN [42] & 0.901 & 0.860 & 0.780 \\ \hline FFDNet [30] & 0.903 & 0.864 & 0.791 \\ \hline BRDNet [36] & 0.906 & 0.866 & 0.794 \\ \hline ADNet [87] & 0.905 & 0.865 & 0.791 \\ \hline RIDNet [56] & 0.906 & 0.867 & 0.793 \\ \hline CDNet [88] & 0.903 & 0.865 & 0.792 \\ \hline DeamNet [46] & 0.910 & 0.872 & 0.806 \\ \hline DRUNet [31] & 0.910 & 0.873 & 0.810 \\ \hline DCBDNet & 0.902 & 0.865 & 0.794 \\ \hline \end{tabular}
\end{table}
Table 3: The averaged SSIM results of the compared methods on Set12 dataset with different noise levels. The best, second best and third best is highlighted in red, blue and green, respectively.
\begin{table}
\begin{tabular}{c c c c c} \hline Datasets & Methods & \(\sigma\)=15 & \(\sigma\)=25 & \(\sigma\)=50 \\ \hline \multirow{6}{*}{Set12} & DnCNN-S [27] & 0.761 & 0.719 & 0.655 \\ \cline{2-5} & DnCNN-B [27] & 0.759 & 0.720 & 0.656 \\ \cline{2-5} & IRCNN [42] & 0.759 & 0.718 & 0.656 \\ \cline{2-5} & FFDNet [30] & 0.760 & 0.719 & 0.656 \\ \cline{2-5} & DRUNet [31] & 0.768 & 0.727 & 0.666 \\ \cline{2-5} & DCBDNet & 0.760 & 0.722 & 0.662 \\ \hline \multirow{6}{*}{BSD68} & DnCNN-S [27] & 0.746 & 0.689 & 0.602 \\ \cline{2-5} & DnCNN-B [27] & 0.744 & 0.688 & 0.601 \\ \cline{2-5} & IRCNN [42] & 0.742 & 0.686 & 0.602 \\ \cline{2-5} & FFDNet [30] & 0.745 & 0.690 & 0.602 \\ \cline{2-5} & DRUNet [31] & 0.750 & 0.696 & 0.612 \\ \cline{2-5} & DCBDNet & 0.746 & 0.692 & 0.609 \\ \hline \end{tabular}
\end{table}
Table 6: The averaged FSIM results of the compared methods on Set12 and BSD68 dataset with different noise levels.
\begin{table}
\begin{tabular}{c c c c} \hline Noise level & \(\sigma\)=15 & \(\sigma\)=25 & \(\sigma\)=50 \\ \hline BM3D [6] & 0.872 & 0.802 & 0.687 \\ \hline WNNM [23] & 0.878 & 0.810 & 0.698 \\ \hline TNRD [26] & 0.883 & 0.816 & 0.703 \\ \hline DnCNN-S [27] & 0.891 & 0.828 & 0.719 \\ \hline BUIFD [33] & 0.886 & 0.819 & 0.682 \\ \hline IRCNN [42] & 0.888 & 0.825 & 0.717 \\ \hline FFDNet [30] & 0.890 & 0.830 & 0.726 \\ \hline BRDNet [36] & 0.893 & 0.831 & 0.727 \\ \hline ADNet [87] & 0.892 & 0.829 & 0.722 \\ \hline RIDNet [56] & 0.893 & 0.833 & 0.727 \\ \hline CDNet [88] & 0.892 & 0.831 & 0.727 \\ \hline DeamNet [46] & 0.896 & 0.837 & 0.737 \\ \hline DRUNet [31] & 0.895 & 0.837 & 0.738 \\ \hline DCBDNet & 0.889 & 0.829 & 0.727 \\ \hline \end{tabular}
\end{table}
Table 5: The averaged SSIM results of the compared methods on BSD68 dataset with different noise levels. The best, second best and third best is highlighted in red, blue and green respectively.
Figure 4: Visual results on the image “kodim22” from Kodak24 dataset.
Figure 3: Visual results on the image “Castle” of different denoising methods.
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|} \hline Datasets & Methods & \(\sigma\)=15 & \(\sigma\)=25 & \(\sigma\)=35 & \(\sigma\)=50 & \(\sigma\)=75 \\ \hline & CBM3D [6] & 33.52 & 30.71 & 28.89 & 27.38 & 25.74 \\ & MCWNNM [24] & 30.91 & 27.61 & 25.88 & 23.18 & 21.21 \\ & CDnCNN-S [27] & 33.89 & 31.23 & 29.58 & 27.92 & 24.47 \\ & BUIFD [33] & 33.65 & 30.76 & 28.82 & 26.61 & 23.64 \\ & IRCNN [42] & 33.86 & 31.16 & 29.50 & 27.86 & - \\ & FFDNet [30] & 33.87 & 31.21 & 29.58 & 27.96 & 26.24 \\ & DSNetB [43] & 33.91 & 31.28 & - & 28.05 & - \\ & RIDNet [56] & 34.01 & 31.37 & - & 28.14 & - \\ CBSD68 & VDN [34] & 33.90 & 31.35 & - & 28.19 & - \\ & BRDNet [36] & 34.10 & 31.43 & 29.77 & 28.16 & 26.43 \\ & ADNet [87] & 33.99 & 31.31 & 29.66 & 28.04 & 26.33 \\ & DudeNet [37] & 34.01 & 31.34 & 29.71 & 28.09 & 26.40 \\ & GradNet [89] & 34.07 & 31.39 & - & 28.12 & - \\ & CDNet [88] & - & 31.34 & 29.84 & 28.14 & - \\ & AirNet [47] & 33.92 & 31.26 & - & 28.01 & - \\ & DRUNet [31] & 34.30 & 31.69 & 30.09 & 28.51 & 26.84 \\ & DCBDNet & 34.01 & 31.41 & 29.81 & 28.22 & 26.54 \\ \hline & CBM3D [6] & 34.28 & 31.68 & 29.90 & 28.46 & 26.82 \\ & MCWNNM [24] & 32.00 & 28.76 & 27.02 & 21.18 & 18.06 \\ & CDnCNN-S [27] & 34.48 & 32.03 & 30.46 & 28.85 & 25.04 \\ & BUIFD [33] & 34.41 & 31.77 & 29.94 & 27.74 & 24.67 \\ & IRCNN [42] & 34.56 & 32.03 & 30.43 & 28.81 & - \\ & FFDNet [30] & 34.63 & 32.13 & 30.57 & 28.98 & 27.27 \\ Kodak24 & DSNetB [43] & 34.63 & 32.16 & - & 29.05 & - \\ & BRDNet [36] & 34.88 & 32.41 & 30.80 & 29.22 & 27.49 \\ & ADNet [87] & 34.76 & 32.26 & 30.68 & 29.10 & 27.40 \\ & DudeNet [37] & 34.81 & 32.26 & 30.69 & 29.10 & 27.39 \\ & GradNet [89] & 34.85 & 32.35 & - & 29.23 & - \\ & AirNet [47] & 34.68 & 32.21 & - & 29.06 & - \\ & DRUNet [31] & 35.31 & 32.89 & 31.26 & 29.86 & 28.06 \\ & DCBDNet & 34.80 & 32.38 & 30.84 & 29.29 & 27.60 \\ \hline & CBM3D [6] & 34.06 & 31.66 & 29.92 & 28.51 & 26.79 \\ & MCWNNM [24] & 32.75 & 29.39 & 27.44 & 21.37 & 18.16 \\ & CDnCNN-S [27] & 33.44 & 31.51 & 30.14 & 28.61 & 25.10 \\ & BUIFD [33] & 33.84 & 31.06 & 28.87 & 26.20 & 22.75 \\ & IRCNN [42] & 34.58 & 32.18 & 30.59 & 28.91 & - \\ & FFDNet [30] & 34.66 & 32.35 & 30.81 & 29.18 & 27.33 \\ McMaster & DSNetB [43] & 34.67 & 32.40 & - & 29.28 & - \\ & BRDNet [36] & 35.08 & 32.75 & 31.15 & 29.52 & 27.72 \\ & ADNet [87] & 34.93 & 32.56 & 31.00 & 29.36 & 27.53 \\ & GradNet [89] & 34.81 & 32.45 & - & 29.39 & - \\ & AirNet [47] & 34.70 & 32.44 & - & 29.26 & - \\ & DRUNet [31] & 35.40 & 33.14 & 31.66 & 30.08 & 28.29 \\ & DCBDNet & 34.76 & 32.56 & 31.10 & 29.54 & 27.75 \\ \hline \end{tabular}
\end{table}
Table 7: The averaged PSNR (dB) of the compared methods on the CBSD68, Kodak24 and McMaster datasets. The best, second best and third best is marked in red, blue and green respectively.
shown in Eqn. (6).
\[\begin{split} p&=3(1-m)^{2}e^{(-m^{2}-(n+1)^{2})}\\ &-10(\frac{m}{5}-m^{3}-n^{5})e^{(-m^{2}-n^{2})}\\ &-\frac{1}{3}e^{(-(m+1)^{2}-n^{2})}.\end{split} \tag{6}\]
For an estimated spatially variant noise distribution \(p\), the non-uniform noise level map \(M\) can be obtained by Eqn. (7).
\[M=\lambda\frac{p-min(p)}{max(p)-min(p)}, \tag{7}\]
where the \(\lambda\) is a coefficient used to control the intensity of the noise. \(\lambda\) and the normalized distribution \(p\) are multiplied to generate the spatial variant noise level map. The spatially variant AWGN can be obtained by Eqn. (8).
\[N=M\cdot D, \tag{8}\]
where \(D\) is the standard normal distribution \(\mathcal{N}(0,1)\). The clean image \(x\) and the noise level \(N\) were then added at the element level to gain spatially variant AWGN image \(y\), which is represented as \(y=x+N\).
To verify the effectiveness of the proposed DCBDNet for spatially variant AWGN removal, we choose the "butterfly" image from the Set5 dataset for visual evaluation, and the \(\lambda\) in Eqn. (7) was set as 50. Fig. 5 shows the visual comparison of the compared methods. It can be seen that the DCBDNet and VDN are effective to eliminate the spatially variant AWGN.
### Real noisy image denoising evaluation
For the evaluation of the real noisy image denoising, the SIDD validation set, DND sRGB images, RNI15, and Nam datasets were used. The SIDD validation set, DND sRGB images, and Nam dataset contain noisy images and the near noise-free counterparts, the quantitative evaluation can be implemented. Table 9 lists the averaged PSNR and SSIM values of different methods on the SIDD validation set and DND sRGB images. One can see that our proposed DCBDNet model achieves more effective denoising performance than MCWNNM, TWSC, DnCNN-B, CBDNet, and RIDNet, however the VDN and VDIR outperform our model, however both of them have much more complex model structures than ours.
Fig. 6 shows the visual comparison from the compared denoising methods. It can be found the VDN, VDIR, and the proposed DCBDNet achieve better visual quality.
The RNI15 dataset consists of 15 real noisy images without the corresponding ground truth images, therefore the quantitative comparison can not be implemented. The visual results of the compared denoising models on the image
\begin{table}
\begin{tabular}{c|c|c c c c|c c c|c c c} \hline \hline \multirow{2}{*}{Datasets} & \multirow{2}{*}{Methods} & \multicolumn{4}{c|}{\(\sigma\)=15} & \multicolumn{4}{c|}{\(\sigma\)=25} & \multicolumn{4}{c}{\(\sigma\)=50} \\ \cline{3-13} & & SSIM & FSIM & LPIPS & IS & SSIM & FSIM & LPIPS & IS & SSIM & FSIM & LPIPS & IS \\ \hline \multirow{8}{*}{CBSD68} & CDnCNN-B [27] & 0.929 & 0.784 & 0.0628 & 4.354 & 0.883 & 0.737 & 0.1090 & 4.250 & 0.790 & 0.658 & 0.2101 & 4.064 \\ \cline{2-13} & IRCNN [42] & 0.929 & 0.782 & 0.0626 & 4.330 & 0.882 & 0.736 & 0.1078 & 4.243 & 0.790 & 0.660 & 0.2039 & 4.189 \\ \cline{2-13} & FFDNet [30] & 0.929 & 0.782 & 0.0655 & 4.270 & 0.882 & 0.733 & 0.1210 & 4.166 & 0.789 & 0.648 & 0.2442 & 3.946 \\ \cline{2-13} & DRUNet [31] & 0.934 & 0.791 & 0.0556 & 4.314 & 0.893 & 0.748 & 0.0962 & 4.259 & 0.810 & 0.675 & 0.1815 & 4.097 \\ \cline{2-13} & DCBDNet & 0.931 & 0.785 & 0.0604 & 4.330 & 0.887 & 0.740 & 0.1036 & 4.273 & 0.780 & 0.665 & 0.1994 & 4.054 \\ \hline \multirow{8}{*}{Kodak24} & CDnCNN-B [27] & 0.920 & 0.765 & 0.0828 & 2.003 & 0.876 & 0.713 & 0.1292 & 1.965 & 0.791 & 0.632 & 0.2290 & 1.917 \\ \cline{2-13} & IRCNN [42] & 0.920 & 0.764 & 0.0810 & 1.989 & 0.877 & 0.712 & 0.1270 & 1.977 & 0.793 & 0.634 & 0.2202 & 1.931 \\ \cline{1-1} \cline{2-13} & FFDNet [30] & 0.922 & 0.764 & 0.0846 & 1.988 & 0.878 & 0.709 & 0.1395 & 1.947 & 0.794 & 0.621 & 0.2553 & 1.933 \\ \cline{1-1} \cline{2-13} & DRUNet [31] & 0.929 & 0.777 & 0.0688 & 2.021 & 0.891 & 0.730 & 0.1081 & 1.971 & 0.820 & 0.655 & 0.1862 & 1.874 \\ \cline{1-1} \cline{2-13} & DCBDNet & 0.924 & 0.770 & 0.0762 & 0.009 & 0.884 & 0.721 & 0.1182 & 1.961 & 0.806 & 0.644 & 0.2064 & 1.907 \\ \hline \multirow{8}{*}{McMaster} & CDnCNN-B [27] & 0.904 & 0.759 & 0.0684 & 1.488 & 0.869 & 0.723 & 0.1014 & 1.441 & 0.799 & 0.662 & 0.1725 & 1.457 \\ \cline{1-1} \cline{2-13} & IRCNN [42] & 0.920 & 0.770 & 0.0608 & 1.485 & 0.882 & 0.730 & 0.0935 & 1.450 & 0.807 & 0.668 & 0.1567 & 1.458 \\ \cline{1-1} \cline{2-13} & FFDNet [30] & 0.922 & 0.769 & 0.0648 & 1.505 & 0.886 & 0.731 & 0.1026 & 1.465 & 0.815 & 0.668 & 0.1832 & 1.458 \\ \cline{1-1} \cline{2-13} & DRUNet [31] & 0.932 & 0.781 & 0.0512 & 1.472 & 0.903 & 0.746 & 0.0812 & 1.458 & 0.846 & 0.689 & 0.1403 & 1.445 \\ \cline{1-1} \cline{2-13} & DCBDNet & 0.923 & 0.772 & 0.0599 & 1.487 & 0.891 & 0.737 & 0.0909 & 1.472 & 0.828 & 0.679 & 0.1558 & 1.435 \\ \hline \hline \end{tabular}
\end{table}
Table 8: The averaged SSIM, FSIM, LPIPS and Inception-Score (IS) results of the compared methods on CBSD68, Kodak24 and McMaster datasets with different noise levels.
\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline Dataset & Methods & MCWNNM [24] & TWSC [12] & DrCNN-B [27] & CBDNet [32] & RIDNet [56] & VDN [34] & VDIR [49] & DCBDNet \\ \hline SIDD & PSNR & 33.40 & 35.33 & 23.66 & 30.78 & 38.71 & 39.28 & 39.26 & 38.94 \\ \hline \multirow{2}{*}{DND} & SSIM & 0.879 & 0.933 & 0.583 & 0.951 & 0.954 & 0.957 & 0.955 & 0.953 \\ \cline{2-9} & PSNR & 37.38 & 37.94 & 37.90 & 38.06 & 39.26 & 39.38 & 39.63 & 39.37 \\ \hline \multirow{2}{*}{DND} & SSIM & 0.929 & 0.940 & 0.943 & 0.942 & 0.953 & 0.952 & 0.953 & 0.951 \\ \hline \end{tabular}
\end{table}
Table 9: The averaged PSNR(dB), SSIM and FSIM of different denoising methods on the SIDD validation set and DND sRGB images. The top three results on each noise level are marked in red, blue and green in order.
Figure 5: Visual results on the image “butterfly” from Set5 dataset with spatially variant AWGN. (a) Ground-truth image / (PSNR (dB) /SSIM), (b) Non-uniform noise level map, (c) Noisy image degraded by spatially variant AWGN / (20.74/0.552), (d) CDnCNN-B / (20.83/0.555), (e) ADNet / ((20.78/0.592), (f) BUIFD / (20.74/0.590), (g) AirNet / (20.64/0.586), (h) VDN / (24.72/0.743), (i) VDIR / (20.95/0.596), (j) DCBDNet / (23.85/0.847).
"Dog" can be seen in Fig. 7, where one can see that the TWSC, CDnCNN-B, VDN, and VDIR produced inferior visual results. Furthermore, the MCWNNM and the proposed DCBDNet obtained visual appealing results.
Fig. 8 displays the denoising results of the compared denoising methods on the image "Vinegar" from the Nam dataset, where one can see that the MCWNNM, TWSC, VDN, and the proposed DCBDNet obtained better visual quality and PSNR/SSIM values. It also should be noted that even nowadays the DNN based methods are much more popular in image denoising, however the traditional methods like the MCWNNM and TWSC still can obtain remarkable denoising performance in real denoising tasks.
### Network complexity analysis
In our experiments, the network complexity was evaluated from the perspectives of model running time, floating point operations per second (FLOPs), and numbers of network parameters. It should be noted that we used the original source codes of the compared denoising methods released by the authors, therefore the BM3D, WNNM, MCWNNM, and TWSC were implemented in Matlab (R2020a) environment, and the DnCNN-B, BUIFD, IRCNN, FFDNet, BRDNet, ADNet, DudeNet, CBDNet, RIDNet, VDN, VDIR, DeamNet, AirNet, DRUNet, and the proposed DCBDNet were evaluated in PyCharm (2021) environment.
We first evaluated the running time of different denoising methods, the results are listed in Table 10. Three randomly chosen grayscale and color images with different sizes were utilized for evaluating the running time at noise level 25, and the running time on each image of every evaluated model was obtained by averaging the running time of 20 implementations. Our experiments neglected the memory transfer time between CPU and GPU. It can be observed that the denoising speed of BM3D, WNNM, MCWNNM, and TWSC using CPU is much slower than the methods running on GPU. The models can achieve leading PSNR values such as the DeamNet and DRUNet require a longer denoising time, especially when the size of the image is bigger. More importantly, these models equipped with complex structures also require much longer training time.
Table 11 lists the number of parameters and FLOPs of the tested denoising methods on grayscale and color images, respectively. For the network parameters, it can be seen that DnCNN-B, IRCNN, FFDNet, and ADNet have smaller numbers of parameters than our DCBDNet, however the quantitative results of our DCBDNet are superior to
Figure 6: Visual results on the image “11.4” from SIDD the SIDD validation set. (a) Ground-truth image / (PSNR (dB) /SSIM), (b) Noisy image / (18.25/0.169), (c) MCWNNM / (28.63/0.702),(d) TWSC / (30.41/0.811), (e) CDnCNN-B / (20.76/0.235), (F) VDN / (36.39/0.907), (G) VDIR / (36.35/0.906), (h) DCBDNet / (35.61/0.906).
Figure 8: Denoising results on the image “Vinegar” from Nam dataset. (a) Ground-truth image / (PSNR(dB)/SSIM), (b) Noisy image / (34.93/0.841), (c) MCWNNM / (39.51/0.964), (d) TWSC / (41.05/0.983), (e) CDnCNN-B / (35.41/0.856), (f) BUIFD / (35.88/0.868), (g) ADNet / (35.07/0.844), (f) VDN / (37.53/0.967), (i) VDIR / (36.88/0.909), (j) DCBDNet / (38.59/0.954).
Figure 7: Visual results on the image “Dog” from RNI15 dataset.
these methods. It can be discovered that with a smaller number of parameters, our DCBDNet still can outperform some models with more network parameters in some noise levels, such as the BUIFD, DudeNet, RIDNet, CBDNet, BRDNet, and AirNet. In terms of FLOPs, we also tested the different models on two images of the same size with different channel numbers (grayscale and color). It can be found that the FLOPs of our DCBDNet are lower than most of the state-of-the-art methods, nevertheless our DCBDNet can still obtain competitive denoising performance. The experimental results also demonstrate that our DCBDNet can achieve a desirable balance between model complexity and denoising performance.
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline \multirow{2}{*}{Methods} & \multirow{2}{*}{Device} & \multicolumn{2}{c|}{\(256\times 256\)} & \multicolumn{2}{c|}{\(512\times 512\)} & \multicolumn{2}{c|}{\(1024\times 1024\)} \\ \cline{3-8} & & Gray & Color & Gray & Color & Gray & Color \\ \hline BM3D [6] & CPU & 0.458 & 0.593 & 2.354 & 3.771 & 9.782 & 12.818 \\ \hline WNNM [23] & CPU & 63.867 & - & 277.003 & - & 1150.842 & - \\ \hline MCWNNM [24] & CPU & - & 62.777 & - & 277.623 & - & 1120.112 \\ \hline TWSC [12] & CPU & 12.314 & 34.41 & 53.155 & 140.964 & 221.507 & 608.492 \\ \hline DnCNN-B [27] & GPU & 0.032 & 0.032 & 0.037 & 0.037 & 0.057 & 0.057 \\ \hline BUIFD [33] & GPU & 0.035 & 0.037 & 0.050 & 0.053 & 0.112 & 0.123 \\ \hline IRCNN [42] & GPU & 0.030 & 0.030 & 0.030 & 0.030 & 0.030 & 0.030 \\ \hline FFDNet [30] & GPU & 0.031 & 0.030 & 0.031 & 0.030 & 0.032 & 0.030 \\ \hline ADNet [87] & GPU & 0.031 & 0.033 & 0.035 & 0.045 & 0.051 & 0.093 \\ \hline VDN [34] & GPU & 0.144 & 0.162 & 0.607 & 0.597 & 2.367 & 2.376 \\ \hline VDIR [49] & GPU & - & 0.385 & - & 1.622 & - & 6.690 \\ \hline DeamNet [46] & GPU & 0.054 & - & 0.121 & - & 0.392 & - \\ \hline AirNet [47] & GPU & - & 0.143 & - & 0.498 & - & 2.501 \\ \hline DRUNet [31] & GPU & 0.068 & 0.068 & 0.106 & 0.107 & 0.276 & 0.280 \\ \hline DCBDNet & GPU & 0.050 & 0.051 & 0.078 & 0.081 & 0.183 & 0.187 \\ \hline \end{tabular}
\end{table}
Table 10: Running time (in seconds) of the evaluated denoising methods on three grayscale and color images with different sizes.
\begin{table}
\begin{tabular}{|c|c|c|c|c|} \hline \multirow{2}{*}{Methods} & \multicolumn{2}{c|}{Parameters} & \multicolumn{2}{c|}{FLOPs} \\ \cline{2-5} & Gray & Color & \(256\times 256\times 1\) & \(256\times 256\times 3\) \\ \hline DnCNN-B [27] & 666 & 668 & 21.93 & 22.12 \\ \hline BUIFD [33] & 1186 & 1196 & 35.31 & 35.65 \\ \hline IRCNN [42] & 186 & 188 & 6.08 & 6.15 \\ \hline FFDNet [30] & 485 & 852 & 3.97 & 3.14 \\ \hline CBDNet [32] & - & 4365 & - & 20.14 \\ \hline RIDNet [56] & 1497 & 1499 & 48.90 & 48.98 \\ \hline VDN [34] & 7810 & 7817 & 24.47 & 24.70 \\ \hline VDIR [49] & - & 2227 & - & - \\ \hline BRDNet [36] & 1113 & 1117 & 36.48 & 36.63 \\ \hline ADNet [87] & 519 & 521 & 17.08 & 17.15 \\ \hline DudeNet [37] & 1077 & 1079 & 35.35 & 35.43 \\ \hline DeamNet [46] & 2226 & - & 72.85 & - \\ \hline AirNet [47] & - & 8930 & - & 150.64 \\ \hline DRUNet [31] & 32639 & 33641 & 71.71 & 71.79 \\ \hline DCBDNet & 1004 & 1013 & 24.38 & 24.68 \\ \hline \end{tabular}
\end{table}
Table 11: The number of model parameters (in K) and the FLOPs (in G) for grayscale and color image denoising of different models.
## 5 Conclusion
In this paper, we propose a novel dual convolutional blind denoising network with skip connection (DCBDNet). The proposed DCBDNet contains a noise estimation network and a dual convolutional neural network (CNN) with two sub-networks. The proposed denoising model incorporates a noise estimation network to estimate the noise level map to enhance its flexibility, which makes the DCBDNet can achieve blind denoising. The dual CNN not only expands the network width to enhance the learning ability of the DCBDNet model, but also can capture the complementary image features for improving denoising performance. In addition, the u-shaped structure and dilated convolution are utilized in two sub-networks respectively to enlarge the receptive fields. Skip connections are adopted in both sub-networks for image feature superposing, and for avoiding the gradient vanishing or exploding. Experimental results illustrate that our proposed DCBDNet can achieve competitive denoising performance both quantitatively and qualitatively compared to state-of-the-art denoising methods. Moreover, the proposed DCBDNet has a shorter running time, fewer FLOPs, and fewer model parameters compared to many other denoising methods. Therefore our proposed DCBDNet can provide an option for practical image denoising. In the future, we aim to further investigate the feature learning ability of the model, especially for the images containing rich repetitive textures.
## 6 Acknowledgements
The work is funded by the Natural Science Foundation of China No. 61863037, No. 41971392, and the Applied Basic Research Foundation of Yunnan Province under grant No. 202001AT070077.
|
2308.11080 | Stress representations for tensor basis neural networks: alternative
formulations to Finger-Rivlin-Ericksen | Data-driven constitutive modeling frameworks based on neural networks and
classical representation theorems have recently gained considerable attention
due to their ability to easily incorporate constitutive constraints and their
excellent generalization performance. In these models, the stress prediction
follows from a linear combination of invariant-dependent coefficient functions
and known tensor basis generators. However, thus far the formulations have been
limited to stress representations based on the classical Rivlin and Ericksen
form, while the performance of alternative representations has yet to be
investigated. In this work, we survey a variety of tensor basis neural network
models for modeling hyperelastic materials in a finite deformation context,
including a number of so far unexplored formulations which use theoretically
equivalent invariants and generators to Finger-Rivlin-Ericksen. Furthermore, we
compare potential-based and coefficient-based approaches, as well as different
calibration techniques. Nine variants are tested against both noisy and
noiseless datasets for three different materials. Theoretical and practical
insights into the performance of each formulation are given. | Jan N. Fuhg, Nikolaos Bouklas, Reese E. Jones | 2023-08-21T23:28:26Z | http://arxiv.org/abs/2308.11080v1 | Stress representations for tensor basis neural networks: alternative formulations to Finger-Rivlin-Ericksen
###### Abstract
Data-driven constitutive modeling frameworks based on neural networks and classical representation theorems have recently gained considerable attention due to their ability to easily incorporate constitutive constraints and their excellent generalization performance. In these models, the stress prediction follows from a linear combination of invariant-dependent coefficient functions and known tensor basis generators. However, thus far the formulations have been limited to stress representations based on the classical Rivlin and Ericksen form, while the performance of alternative representations has yet to be investigated. In this work, we survey a variety of tensor basis neural network models for modeling hyperelastic materials in a finite deformation context, including a number of so far unexplored formulations which use theoretically equivalent invariants and generators to Finger-Rivlin-Ericksen. Furthermore, we compare potential-based and coefficient-based approaches, as well as different calibration techniques. Nine variants are tested against both noisy and noiseless datasets for three different materials. Theoretical and practical insights into the performance of each formulation are given.
## 1 Introduction
Recently, there has been dramatically increased interest in machine learning (ML) in the computational sciences. This rise in popularity is due to: the ability of machine learning models to directly utilize experimental data in simulation environments, the potential speed up of ML models in comparison to traditional numerical models and methods, as well as the general utility and open-access ecosystem of ML tools. Nevertheless, many scientific ML (SciML) applications suffer from two interconnected bottlenecks: a lack of generalization capabilities due to poor extrapolations and a lack of trustworthiness due to the opaqueness of the trained models. The main premise in SciML is that the underlying data often comply with physical laws (known or yet to be discovered) or otherwise connect to known mathematical structure, which can help surmount the aforementioned bottlenecks via a physics-informed paradigm. The promise of SciML can lead to myriad benefits
such as: more accurate predictions, reduction of unnecessary human involvement, speed-up of the processing-performance-product development cycle, and minimization of the computational costs of detailed simulations. Particular to the focus of this work, an automated data-driven approach for constitutive modeling can have significant payoffs in material discovery, industrial engineering simulations and research. Many developments have been made in this arena for fluid closure models [1; 2; 3]; in this work we focus on constitutive models for solids.
A number of distinct approaches to forming constitutive models with ML have been investigated. ML tools have been utilized in parameter estimation of known constitutive models [4]. This is a task that becomes more complex as model parameters increase and experimental observations are limited. This is especially true for traditional optimization approaches due to the non-convex nature of the optimization problem at hand. Mixing traditional and ML approaches to representation and calibration via symbolic regression [5; 6; 7; 8; 9; 10] has been widely explored. This approach selects from a library of known models that directly enforce physical and mechanistic constraints (depending on the specific model choices) to distill parsimonious data-driven constitutive models. Notable developments include the approach of Wang _et al_. [11] who used reinforcement learning to turn model building into a competitive game. Also Schmidt _et al_. [12] used symbolic regression to distill constitutive laws from unlabeled data. Later, De Lorentzis and co-workers [13; 14] utilized sparse regression to discover interpretable constitutive laws for a wide array of material classes. An interesting extension to this work was the development of an unsupervised Bayesian framework for discovering hyperelasticity models which accounts for uncertainty [15]. Neural networks and Gaussian process models have been widely employed as replacements for human-selected, traditional model forms. In fact, the use of ML black-box constitutive models has been extensively studied for over 30 years. Starting from the influential works of Ghaboussi and collaborators [16; 17; 18], these tools have been employed for different material models with increasing complexity over the years [19; 20; 21; 22].
A significant current challenge is generating trustworthy models from low-data (constrained by experimental/computational cost) and limited-data (constrained by experimental design and observation). To this end efforts have been made to train data-driven constitutive models that do not only train with raw stress-strain data but incorporate additional physics-based restrictions to the trained model [23; 24; 25; 26; 27; 28]. These models, referred to as _physics-informed_ or _physics-guided data-driven_ constitutive models try to enforce a variety of physical principles and mechanics-informed assumptions. From enforcing objectivity, to material symmetries [1], thermodynamic constraints [29; 30] and polyconvexity [31; 32] there are approaches that enforce these condition weakly through the loss function [33; 34; 35] or strictly in the construction of the ML representation [1; 36; 37; 38]. A large majority of the proposed works in the literature for physics-guided constitutive models are based on neural networks [23; 39; 36; 24; 25; 26; 33] due to the flexibility of this paradigm.
Material frame indifference is a primary concern in developing constitutive models [40]. Ling _et al_. [1] introduced the tensor basis neural network (TBNN) to embed objectivity through an equivariant NN formulation. An anisotropic hyperelastic model was formed from the scalar invariants and tensor basis of the strain using atomistic crystal data, in addition to fluids applications. Later Frankel _et al_. [36] adapted the tensor basis representations to a Gaussian process formalism to represent general tensor functions and hyperelastic data. This was extended by Fuhg and Bouklas [37] to anisotropic materials, strictly enforcing known symmetries up to transverse isotropy; this work showed that this simplified learning approach led to significant generalization capabilities when the physics do not radically change outside of the training region. This approach was also utilized in Kalina _et al_. [41] integrated in a multiscale framework with automated data-mining. In
Fuhg _et al._[32], tensor basis NNs were utilized to discover the character of the anisotropy of the material through labeled data. Even though several works have focused on utilizing tensor basis representation theorems in learning of hyperelastic responses from labeled data pairs, there has not been an extensive study aimed at discovering the most efficient tensor basis representations for the learning tasks at hand in the context of finite deformation and hyperelasticity.
In the context of hyperelasticity, strict enforcement of polyconvexity requirements [42] for the strain energy density has also proven extremely useful towards generalization, discovery, and robustness. Input convex neural networks have been utilized for the enforcement of polyconvexity towards learning hyperelastic responses [31, 32], and in some cases even interpretability can be achieved [43] due to the non-parametric nature of the specific implementation. Alternately, neural ordinary differential equations have also been utilized towards strict enforcement of polyconvexity [44]. More recently Linden _et al._[38] presents a thorough review of techniques to enforce physical constraints and mechanistic assumptions towards learning hyperelasticity with NNs. Such approaches are crucial for the efficient utilization of the data and the development of robust material models that can efficiently generalize.
This work provides a limited survey of the wide variety of tensor basis techniques and contrasts their performance on representative data in the low-data regime (100 training points). We focus on stress representations for hyperelastic materials since they are the fundamental basis for finite deformation mechanics. The contributions of this work are: novel formulations based on the variety that the tensor basis framework affords, exploration of different methods of calibrating the models to data, and demonstration of the effects of noise and incompatible representations on physics-constrained formulations. To this end, we utilize well-known hyperelastic models as data generators.
In Sec. 2 we develop a multitude of equivariant _tensor basis_ neural networks (TBNNs) [1] formulations from classical representation theory. Then in Sec. 3 we give details of the data generation and training methodology. Sec. 4 presents the results of testing the models in and out of distribution and without and with additive noise. Finally in Sec. 5 we summarize the findings and conclude with avenues for future work.
## 2 Stress representations
In this work, we develop and compare a variety of tensor basis neural network (TBNN) formulations for stress representations. In this section, we introduce the fundamental differences between the representations and the neural network formulations that follow directly from the representations.
### Tensor basis models
Hyperelasticity is the prevailing theory for the description of finite deformation solid mechanics for continua in the absence of inelastic phenomena. The theory posits a potential \(\Psi\) from which the second Piola-Kirchhoff stress \(\mathbf{S}\) can be derived:
\[\mathbf{S}=2\boldsymbol{\partial}_{\mathbf{C}}\Psi(\mathbf{C})\, \tag{1}\]
as a function of the right Cauchy-Green stretch tensor \(\mathbf{C}=\mathbf{F}^{T}\mathbf{F}\). Here \(\mathbf{F}=\partial_{\mathbf{X}}\boldsymbol{\chi}\) is the deformation gradient of the spatial position \(\mathbf{x}=\boldsymbol{\chi}(\mathbf{X},t)\) at time \(t\) with respect to the corresponding reference position \(\mathbf{X}\) of the material. This potential ensures deformations are reversible, and is also utilized in some incremental formulations of large strain plasticity [45, 46].
In this work, we limit the discussion to isotropic hyperelasticity. In this case material frame invariance of the potential leads to the reduction of the inputs of \(\Psi\) to three scalar invariants \(I_{a}\) of \(\mathbf{C}\) and an equivariant stress function:
\[\mathbf{S}=2\,\boldsymbol{\partial}_{\mathbf{C}}\Psi(I_{1}(\mathbf{C}),I_{2}( \mathbf{C}),I_{3}(\mathbf{C})) \tag{2}\]
The chain rule results in the summation of material-specific, scalar derivative functions and an _a priori_ known tensor basis:
\[\mathbf{S}=2\boldsymbol{\partial}_{\mathbf{C}}\Psi(\mathbf{C})=2\,\sum_{a=1}^{ 3}\boldsymbol{\partial}_{I_{a}}\Psi\,\boldsymbol{\partial}_{\mathbf{C}}I_{a} \tag{3}\]
Typically the principal invariants,
\[I_{1}=\mathrm{tr}(\mathbf{C}),\quad I_{2}=\mathrm{tr}\big{(}\mathbf{C}^{-1} \big{)}\det(\mathbf{C}),\quad I_{3}=\det(\mathbf{C})\, \tag{4}\]
from the Cayley-Hamilton theorem
\[\mathbf{C}^{3}-I_{1}\mathbf{C}^{2}+I_{2}\mathbf{C}-I_{3}\mathbf{I}=\mathbf{0} \tag{5}\]
are employed. Note the second invariant is equivalently \(I_{2}=\frac{1}{2}(\mathrm{tr}\big{(}\mathbf{C})^{2}-\mathrm{tr}\big{(} \mathbf{C}^{2}\big{)})\). A three-term formula for the stress
\[\mathbf{S}=2\,[\partial_{I_{1}}\Psi+I_{1}\partial_{I_{2}}\Psi]\,\mathbf{I}-2 \partial_{I_{2}}\Psi\,\mathbf{C}+2I_{3}\,\partial_{I_{3}}\Psi\,\mathbf{C}^{-1} \tag{6}\]
comes from collecting terms with like powers of \(\mathbf{C}\). This is a well-known and arguably the most widely used stress representation for isotropic materials. It was first introduced by Finger [47] but was further popularized by Rivlin and Ericksen [48].
A generalization of this representation can be compactly written as a tensor basis expansion
\[\mathbf{S}=\sum_{a=1}^{3}c_{a}(\mathcal{I})\,\mathbf{B}_{a}\, \tag{7}\]
where the 3 coefficients \(c_{a}\) are functions of a set of 3 independent invariants \(\mathcal{I}\) and the basis \(\mathbf{B}_{a}\) must span \(\{\mathbf{C}^{a},a=-1,0,1\}\). For instance, Eq. (6) can be expressed as
\[\mathcal{I} = \{I_{a},\,a=1,2,3\} \tag{8}\] \[\mathcal{B} = \{\mathbf{C}^{a},\,a=0,1,-1\} \tag{9}\]
and
\[\begin{array}{rcl}c_{0}&=&2\,[\partial_{I_{1}}\Psi+I_{1}\partial_{I_{2}} \Psi]\\ c_{1}&=&-2\,\partial_{I_{2}}\Psi\\ c_{-1}&=&2I_{3}\,\,\partial_{I_{3}}\Psi\end{array} \tag{10}\]
Note that the Cayley-Hamilton theorem Eq. (5) allows the power basis to be shifted to higher or lower powers
\[\mathbf{C}^{3+k}=I_{1}\mathbf{C}^{2+k}-I_{2}\mathbf{C}^{1+k}+I_{3}\mathbf{C}^ {k}\text{ for }k\in\{\ldots,-2,-1,0,1,2,\ldots\}\, \tag{11}\]
for example
\[\mathcal{B}=\{\mathbf{C}^{a},\,a=0,1,2\}\, \tag{12}\]
via
\[I_{3}\mathbf{C}^{-1}=\mathbf{C}^{2}-I_{1}\mathbf{C}+I_{2}\mathbf{I}\;. \tag{13}\]
This basis together with the principal invariants (4) is another form of the Rivlin-Ericksen representation [48]. Also, the basis that results from the chain rule:
\[c_{a} = \{\partial_{I_{a}}\Psi,\,a=1,2,3\} \tag{14}\] \[\mathcal{B} = \{\boldsymbol{\partial}_{\mathbf{C}}I_{a},\,a=1,2,3\} \tag{15}\]
is part of an equally valid representation.
To calibrate Eq. (7), the model output can be regressed directly to stress data, or the coefficients for a given basis, e.g. \(\mathcal{B}=\{\mathbf{I},\mathbf{C},\mathbf{C}^{-1}\}\), can be determined at each data point \((\mathbf{C}_{i},\mathbf{S}_{i})\) via:
\[\begin{bmatrix}c_{1}\\ c_{2}\\ c_{3}\end{bmatrix}=\begin{bmatrix}1&\epsilon_{1}&\epsilon_{1}^{-1}\\ 1&\epsilon_{2}&\epsilon_{2}^{-1}\\ 1&\epsilon_{3}&\epsilon_{3}^{-1}\end{bmatrix}^{-1}\begin{bmatrix}\sigma_{1}\\ \sigma_{2}\\ \sigma_{3}\end{bmatrix} \tag{16}\]
using the fact that any power basis, such as Eq. (9), is collinear with \(\mathbf{S}\). Here \(\sigma_{a}\) and \(\epsilon_{a}\) are the eigenvalues of the stress and stretch tensors, herein \(\mathbf{S}\) and \(\mathbf{C}\), respectively. If the eigenvalues are distinct, Eq. (16) provides a unique solution for the coefficient values; however, multiplicity of strain eigenvalues requires special treatment, see Refs. [49, 50, 30] and App. A, which also outlines alternate solution procedures. Alternatively, we can use the Gram-Schmidt procedure
\[\mathbf{B}_{a}=\tilde{\mathbf{B}}_{a}-\sum_{b=1}^{a-1}\frac{\tilde{\mathbf{B} }_{a}:\mathbf{B}_{b}}{\mathbf{B}_{b}:\mathbf{B}_{b}} \tag{17}\]
to orthogonalize the basis \(\tilde{\mathbf{B}}_{a}\in\{\mathbf{I},\mathbf{C},\mathbf{C}^{-1}\}\), which results in
\[\mathcal{B} = \left\{\mathbf{I},\,\mathrm{dev}(\mathbf{C}),\,\mathrm{dev}( \mathbf{C}^{-1})-\left[\mathbf{C}^{-1}:\frac{\mathrm{dev}(\mathbf{C})}{\| \,\mathrm{dev}(\mathbf{C})\|}\right]\frac{\mathrm{dev}(\mathbf{C})}{\|\, \mathrm{dev}(\mathbf{C})\|}\right\} \tag{18}\]
if we keep the same scalar invariants. Herein \(\mathrm{dev}(\mathbf{C})=\mathbf{C}-1/3\,\mathrm{tr}(\mathbf{C})\mathbf{I}\). The fact that the Gram-Schmidt procedure starting with \(\mathbf{B}_{1}=\mathbf{I}\) and \(\mathbf{B}_{2}=\mathbf{C}\) leads to a spherical-deviatoric split is noteworthy. Orthogonality of the basis allows for direct determination of the coefficients:
\[c_{a}=\mathbf{S}:\mathbf{B}_{a} \tag{19}\]
Likewise, Gram-Schmidt applied to \(\{\mathbf{C}^{a},a=0,1,2\}\) gives the unnormalized basis
\[\mathcal{B} = \left\{\mathbf{I},\,\mathrm{dev}(\mathbf{C}),\,\|\,\mathrm{dev} (\mathbf{C})\|^{2}\,\mathrm{dev}(\mathbf{C}^{2})-(\mathbf{C}^{2}:\mathrm{dev} (\mathbf{C}))\,\mathrm{dev}(\mathbf{C})\right\} \tag{20}\]
Similarly, we can use a formulation inspired by the work Criscione _et al._[51] which effects an orthogonal spherical-deviatoric split of the basis via invariants:
\[\mathcal{I} = \left\{K_{1}=\mathrm{tr}(\mathbf{C}),\,K_{2}=\|\,\mathrm{dev}( \mathbf{C})\|,\,K_{3}=\det\left(\frac{\mathrm{dev}(\mathbf{C})}{\|\,\mathrm{ dev}(\mathbf{C})\|}\right)\right\} \tag{21}\] \[\mathcal{B} = \left\{\mathbf{I},\mathbf{A},-\frac{1}{3}\mathbf{I}-\mathrm{tr} \big{(}\mathbf{A}^{3}\big{)}\mathbf{A}+\mathbf{A}^{2}\right\} \tag{22}\]
where \({\bf A}={\rm dev}({\bf C})/\|\,{\rm dev}({\bf C})\|\). The resulting stress representation is
\[{\bf S} = \partial_{K_{1}}\Psi\,{\bf I}+\partial_{K_{2}}\Psi\,{\bf A}+ \partial_{K_{3}}\Psi\,\frac{1}{K_{2}}\left[-\frac{1}{3}{\bf I}-{\rm tr}\big{(}{ \bf A}^{3}\big{)}{\bf A}+{\bf A}^{2}\right]\] \[= \underbrace{\left[\partial_{K_{1}}\Psi-\frac{1}{3K_{2}}\, \partial_{K_{3}}\Psi\!\right]}_{c_{0}}\,{\bf I}+\underbrace{\left[\partial_{K _{2}}\Psi-\frac{3K_{3}}{K_{2}}\,\partial_{K_{3}}\Psi\right]}_{c_{1}}\,{\bf A} +\underbrace{\frac{1}{K_{2}}\,\partial_{K_{3}}\Psi}_{c_{2}}\,{\bf A}^{2}\]
Note Criscione _et al._[51] formulate the representation in terms of the spatial Hencky stretch, and here we apply the invariants of the same form to \({\bf C}\). This formulation combines derivative connection of the potential, invariants and the basis in the sense that the basis is a result of the choice of invariants, as in Eq. (14), and orthogonality of the basis. A better behaved set of related invariants
\[{\cal I}=\big{\{}{\rm tr}({\bf C}),\,{\rm tr}\,{\rm dev}({\bf C})^{2},\,{\rm det }\,({\rm dev}({\bf C}))\big{\}} \tag{24}\]
which eliminate the normalization in Eq. (21), leads to the basis
\[{\cal B}=\{{\bf I},2\,{\rm dev}\,{\bf C},({\rm det}({\rm dev}\,{\bf C}))\,{\rm dev }(({\rm dev}({\bf C}))^{-1})\} \tag{25}\]
See App. B for further details on the construction of an orthogonal basis.
With any of these representations, a densely connected neural network (NN) can be employed as a representation of the potential \(\Psi({\cal I})\) itself or the coefficient functions \(c_{a}({\cal I})\) directly. Summation of the coefficients with the known basis \({\cal B}\), as in Eq. (7), completes the formulation of a _tensor basis neural network_ (TBNN) [1]. Sec. 3.3, App. C and App. D provide details of the implementation of the TBNNs.
### Additional physical constraints
Other fundamental considerations, in addition to equivariance of the stress \({\bf S}({\bf C})\), constrain the form of the coefficient functions \(c_{a}({\cal I})\). Of the various constraints (rank-1 convexity, strong ellipticity, Hadamard stability, _etc._[40, 52, 53]), polyconvexity was proved by Ball [42] to ensure the existence of solutions in the context of hyperelasticity. For isotropic materials, polyconvexity requires that \(\Psi\) is convex in the triplet \(({\bf F},{\rm cof}\,{\bf F},{\rm det}\,{\bf F})\) which can be fulfilled when
\[\Psi=\Psi(I_{1},I_{2},I_{3})\mbox{ is convex in each of its arguments \@@cite[cite]{[\@@bibref{}{Ball}{}{}]}.} \tag{26}\]
An input convex neural network (ICNN) [54] satisfies these conditions and has been utilized for modeling hyperelastic materials in various recent studies [31, 38, 27]. Alternatively, if we assume that \(\Psi\) is polyconvex, we know that the derivatives of \(\Psi\) have to be non-decreasing, _i.e._\(\partial_{I_{a}}\Psi\geq 0\) with regards to \(I_{a}\). Assuming a representation of the form of Eq. (3)
\[{\bf S}=2\,\sum_{a=1}^{3}\mathbf{\partial}_{I_{i}}\Psi\,\mathbf{\partial}_{{\bf C}}I_{a}=\underbrace{\mathbf{\partial}_{I _{1}}\Psi}_{c_{0}}\,{\bf I}+\underbrace{\mathbf{\partial}_{I_{2}} \Psi}_{c_{1}}\,(I_{1}{\bf I}-{\bf C})+\underbrace{I_{3}\mathbf{\partial }_{I_{3}}\Psi}_{c_{-1}}\,{\bf C}^{-1}\,\,, \tag{27}\]
this implies that \(c_{1}(I_{1},I_{2}^{0},I_{3}^{0})\) is monotonically increasing in \(I_{1}\) for fixed \(I_{2}^{0}\) and \(I_{3}^{0}\). Note that the basis element \(I_{1}{\bf I}-{\bf C}=-\,{\rm dev}\,{\bf C}\) naturally arises from the Cayley-Hamilton/principal invariants, c.f. Eq. (4) and Eq. (10). We enforce this condition via an input monotone (or in fact monotonically
non-decreasing) neural network [27] which guarantees that the outputs of a neural network are monotonically non-decreasing in each of its inputs. Since to the best of our knowledge, no currently proposed neural network architecture enforces that each output individually is monotonically non-decreasing to only a subset of its inputs, and proposing a network of this kind is out of the scope of this work, we remark that this is an overconstrained way of enforcing the convexity condition.
Additional constitutive constraints resulting from mechanistic assumptions, include that the stress in the reference configuration is zero,
\[\mathbf{S}(\mathbf{C}=\mathbf{I})=\mathbf{0}\ \text{implies}\ \sum_{a}c_{a}(I_{1}^{0},I_{2}^{0},I_{3}^{0})=0. \tag{28}\]
with \(I_{1}^{0}=3,I_{2}^{0}=3,I_{3}^{0}=1\). One possible solution to enforcing this is to refactor the basis to form a Saint-Venant-like expansion:
\[\mathbf{S}=\sum_{a=1}^{3}c_{a}\mathbf{E}^{a} \tag{29}\]
where \(\mathbf{E}=1/2(\mathbf{C}-\mathbf{I})\). A \(\mathbf{C}\) based version is likewise:
\[\mathbf{S}=\sum_{a=1}^{3}c_{a}\mathbf{C}^{a}. \tag{30}\]
Note the coefficient functions \(c_{a}\) for these two representations are distinct but related, as are all the other representations introduced in this section. The requirements at the reference state \(\mathbf{C}=\mathbf{I}\) can be seen as a special case of the more general condition of symmetric loading where 2 or 3 of the eigenvalues are equal, examples include equibiaxial and hydrostatic/volumetric loadings.
The set of points where the eigenvalues are unique is dense in the invariant input space [55, 56], whereas highly symmetric cases are often used in testing and experiments since they are more easily understood and yet are sparse in the invariant input space. Since the unique case is dense there are continuous extensions for the coefficient functions to the case of eigenvalue multiplicity; however, the formula for the solution of the coefficients Eq. (16) does not provide them since the determinant of the system goes to zero. Although not well-cited, the important body of theoretical work starting with Serrin [55, 56, 57, 58] relates the smoothness of \(\mathbf{S}(\mathbf{C})\) or \(\mathbf{S}(\mathbf{E})\) to the smoothness of the coefficient functions with respect to the scalar invariants. Since most classical work treated only polynomial functions of the invariants, these developments have not been fully utilized; however, in the present context, we are forming general coefficient functions with neural networks. Man [56] proved that \(\mathbf{S}\) needs to be two degrees more continuous than the desired degree of smoothness of the coefficient functions, in particular \(\mathbf{S}(\mathbf{C})\) needs to be twice differentiable for \(c_{a}(\mathcal{I})\) to be continuous. Note that smooth solutions to the balance of momentum already require \(\mathbf{S}\) to be \(C^{1}\) and \(\Phi\) to be \(C^{2}\). Also, Scheidler [57] provided coefficient values from derivatives of the stress with respect to particular deformations, unlike Eq. (14).
Smoothness and growth considerations affect the choice of NN activations. For example, the St. Venant-like basis (29) incurs certain growth and asymptotic behavior. Refactoring the coefficients as
\[\tilde{c}_{a}=\|\mathbf{E}\|^{n}c_{a} \tag{31}\]
can enforce asymptotic behavior near \(\mathbf{C}\rightarrow\mathbf{I}\) as in Ref. [29]. The orthonormal basis formulations also need special consideration due to the normalization which creates non-smoothness in the coefficients, as in Eq. (18). An unnormalized basis, such as Eq. (20), avoids these issues.
### Summary of selected stress representations
In Sec. 4 we compare a number of distinct formulations of TBNNs for hyperelastic response listed in Table 1. Three are based on representing the strain energy potential \(\Psi(\mathcal{I})\) directly: (a) using the principal invariants \(\mathcal{I}\) as inputs to a standard feed-forward dense neural network (_Rivlin-Pot_), (b) using the principal invariants with an input convex neural network (_Convex-Pot_), and (c) using spherical-deviatoric split invariants in a standard dense neural network (_Crisc-Pot_). For these models the derivative of the potential with respect to these invariants through automatic differentiation provides the stress response. Six other models are based on coefficient-basis product formulations: (a) the customary power basis and coefficient functions in terms of the principal invariants (_Rivlin-Coeff_), (b) an input monotone neural network formulation of the coefficient functions with the power basis (_Mono-Coeff_) (c) the orthogonal basis with the Criscione invariants (_Crisc-Coeff_), (d) the orthogonal basis with the principal invariants (_Orthnorm-Coeff_), (e) an unnormalized orthogonal basis with more regular invariants (_Orth-Coeff_), and (f) a St.Venant-like basis with the principal invariants (_StV-Coeff_). For these both the coefficient functions \(c_{a}(\mathcal{I})\) and the basis \(\mathbf{B}_{a}\) are chosen. Table 1 summarizes the differences in the TBNN variants. In addition to these variations, we also explored how the method for calibration to stress data, e.g. via the coefficients found through regression or projection, or implicitly through direct calibration to stress, affects the model accuracy.
## 3 Data and training
For this study, we train the various NN models enumerated in Table 1 to stress data generated with classical hyperelastic models. In this section, we briefly discuss the classical data-generating models and give a detailed description of the data-generation process.
### Data and training
We remark that the complexity of the coefficient and potential functions is intrinsically connected to the stress measure, the basis function, and the invariants. To emphasize this consider the second Piola-Kirchhoff stress given by
\[\mathbf{S}=c_{0}^{C}\mathbf{I}+c_{1}^{C}\mathbf{C}+c_{-1}^{C}\mathbf{C}^{-1}. \tag{32}\]
\begin{table}
\begin{tabular}{|c|c c c|c c c|} \hline & invariants & basis & coefficients & potential & convex & orthogonal basis \\ \hline Rivlin-Pot & Eq. (4) & Eq. (15) & Eq. (14) & \(\times\) & & \\ Convex-Pot & Eq. (4) & Eq. (15) & Eq. (14) & \(\times\) & \(\times\) & \\ Crisc-Pot & Eq. (21) & Eq. (22) & Eq. (23) & \(\times\) & & \(\times\) \\ Rivlin-Coeff & Eq. (4) & Eq. (12) & Eq. (7) & & & \\ Mono-Coeff & Eq. (4) & Eq. (27) & Eq. (27) & & \(\times\) & \\ Crisc-Coeff & Eq. (21) & Eq. (22) & Eq. (7) & & & \(\times\) \\ Orthnorm-Coeff & Eq. (21) & Eq. (18) & Eq. (7) & & & \(\times\) \\ Orth-Coeff & Eq. (24) & Eq. (20) & Eq. (7) & & & \(\times\) \\ StV-Coeff & Eq. (4) & Eq. (29) & Eq. (7) & & & \\ \hline \end{tabular}
\end{table}
Table 1: Tensor basis neural network variants.
Naively, one could presume that using the Kirchhoff stress tensor \(\mathbf{\tau}\) and the left Cauchy-Green tensor \(\mathbf{B}\) with an equivalent basis representation (\(\mathbf{I}\), \(\mathbf{B}\), \(\mathbf{B}^{-1}\)), i.e.
\[\mathbf{\tau}=c_{0}^{B}\mathbf{I}+c_{1}^{B}\mathbf{B}+c_{-1}^{B}\mathbf{B}^{-1} \tag{33}\]
the respective coefficients might be the same, e.g. \(c_{a}^{C}=c_{a}^{B}\) for \(a=0,1,-1\). However, recalling that the Kirchhoff stress can be expressed as \(\mathbf{\tau}=\mathbf{FSF}^{T}\), Eq. (32) can be rewritten as
\[\mathbf{\tau}=c_{0}^{C}\mathbf{B}+c_{1}^{C}\mathbf{B}^{2}+c_{-1}^{C}\mathbf{I}. \tag{34}\]
Hence, under the assumption that the eigenvalues are unique, we find that
\[c_{0}^{B}\mathbf{I}+c_{1}^{B}\mathbf{B}+c_{-1}^{B}\mathbf{B}^{-1}=c_{0}^{C} \mathbf{B}+c_{1}^{C}\mathbf{B}^{2}+c_{-1}^{C}\mathbf{I} \tag{35}\]
which yields
\[c_{0}^{B}=c_{-1}^{C}-c_{1}^{C}I_{2},\qquad c_{1}^{B}=c_{0}^{C}+c_{1}^{C}I_{1}, \qquad c_{-1}^{B}=c_{1}^{C}I_{3}. \tag{36}\]
via the Cayley-Hamilton theorem (5). The complexity of the two sets of coefficient functions \(\{c_{0}^{C},c_{1}^{C},c_{-1}^{C}\}\) and \(\{c_{0}^{B},c_{1}^{B},c_{-1}^{B}\}\) is therefore clearly different. Using the Cayley-Hamilton theorem (5) to transform the model representation would also alter the complexity of the coefficient functions. In order to make the following comparisons as fair as possible we have restricted ourselves to second Piola-Kirchhoff stress representations and data. Note that the Piola transform would also affect the orthogonality of the basis.
We furthermore remark that additively separable energies that are based on the Valanis-Landel hypothesis [59, 60, 61] lead to more trivial calibrations, i.e. if
\[\Psi(I_{1},I_{2},I_{3})=\Psi_{1}(I_{1})+\Psi_{2}(I_{2})+\Psi_{3}(I_{3}) \tag{37}\]
we can see from Eq. (10) that this would result in
\[\begin{split} c_{0}(I_{1},I_{2})&=2\left[\partial_{ I_{1}}\Psi_{1}(I_{1})+I_{1}\partial_{I_{2}}\Psi_{2}(I_{2})\right]\\ c_{1}(I_{2})&=-2\,\partial_{I_{2}}\Psi_{2}(I_{2}) \\ c_{-1}(I_{3})&=2I_{3}\partial_{I_{3}}\Psi_{3}(I_{3}).\end{split} \tag{38}\]
Hence, this leads to \(c_{1}\) and \(c_{-1}\) being functions of only one invariant and \(c_{0}\) reduced to a function of two invariants. In order to avoid these simplifications we use only hyperelastic models that are not additively decomposable with regards to their inputs.
Note the definition of the invariants can be engineered to reduce the complexity of the coefficient functions for a particular material dataset. In a limiting case, the coefficient functions are themselves invariants and hence present the simplest representation in some sense, albeit one that is hard to discover _a priori_ from the measured data. Representation complexity is particularly important in the low data regime which we explore.
### Data models
Three well-known compressible hyperelastic models were selected to generate training data: (a) Mooney-Rivlin [62, 63], (b) a modified version of Carroll's hyperelastic law [64, 65], and (c) a Gent-type model [66, 67]. Each is expressed in terms of the invariants \(I_{1}=\mathrm{tr}(\mathbf{C})\), \(I_{2}=\mathrm{tr}\big{(}\mathbf{C}^{-1}\big{)}\det(\mathbf{C})\), and \(J=\sqrt{\det\mathbf{C}}\)
The specific compressible Mooney-Rivlin model considered here has the strain energy function
\[\Psi=\theta_{1}\left(\frac{I_{1}}{J^{2/3}}-3\right)+\theta_{2}\left(\frac{I_{2}}{ J^{4/3}}-3\right)+\theta_{3}(J-1)^{2}\, \tag{39}\]
which yields a second Piola-Kirchhoff stress of the form:
\[\mathbf{S}=\underbrace{2\left(\frac{\theta_{1}}{J^{2/3}}+I_{1}\frac{\theta_{2 }}{J^{4/3}}\right)}_{c_{0}^{*}}\mathbf{I}\underbrace{-2\frac{\theta_{2}}{J^{4 /3}}}_{c_{1}^{*}}\mathbf{C}+\underbrace{J\left[-\frac{2}{3}\theta_{1}\frac{I_{ 1}}{J^{5/3}}-\frac{4}{3}\theta_{2}\frac{I_{2}}{J^{7/3}}+2\theta_{3}(J-1)\right] }_{c_{-1}^{*}}\mathbf{C}^{-1} \tag{40}\]
We use (scaled) material parameters ( \(\theta_{1}=0.92\) Pa, \(\theta_{2}=2.37\) Pa and \(\theta_{3}=10.001\) MPa) from fits to vulcanized rubber data, c.f. Ref. [68], for data generation.
Following Ref. [65], a modified Carroll model is defined by the strain energy function
\[\Psi=\theta_{1}\left(\frac{I_{1}}{J^{2/3}}-3\right)+\theta_{2}\left[\left( \frac{I_{1}}{J^{2/3}}\right)^{4}-81\right]+\theta_{3}\left(\sqrt{\frac{I_{2}} {J^{4/3}}}-\sqrt{3}\right)+\theta_{4}(J-1)^{2}. \tag{41}\]
This energy results in
\[\mathbf{S} =\underbrace{2\left[\frac{\theta_{1}}{J^{2/3}}+4\theta_{2}\left( \frac{I_{1}}{J^{2/3}}\right)^{3}+I_{1}\left(\theta_{2}\frac{1}{2J^{2/3}I_{2}} \right)\right]}_{c_{0}^{*}}\mathbf{I}\underbrace{-2\theta_{2}\frac{1}{2J^{2/3 }I_{2}}}_{c_{1}^{*}}\mathbf{C} \tag{42}\] \[+\underbrace{J\left(-\frac{2}{3}\theta_{1}\frac{I_{1}}{J^{4/3}}- \frac{8}{3}\theta_{2}\frac{I_{1}^{4}}{J^{11/3}}-\frac{2}{3}\theta_{3}\frac{ \sqrt{I_{2}}}{J^{5/3}}+\theta_{4}(J-1)\right)}_{c_{-1}^{*}}\mathbf{C}^{-1}\]
We use a scaled version of the material parameters reported in Ref. [65], in particular \(\theta_{1}=151.09387\) GPa, \(\theta_{2}=0.3028\) MPa, \(\theta_{3}=68.33070\) GPa, and \(\theta_{4}=500\) TPa.
Lastly, we also utilize the response of a compressible version of the Gent+Gent model, as named in Ref. [69], that is defined by the strain energy function
\[\Psi=-\frac{\theta_{1}}{2}J_{m}\log\left(1-\frac{I_{1}-3}{J_{m}}\right)-\theta _{2}\log\left(\frac{I_{2}}{J}\right)+\theta_{3}\left(\frac{1}{2}(J^{2}-1)-\log J \right)\, \tag{43}\]
where we choose \(\theta_{1}=2.4195\) MPa, \(\theta_{2}=1.8146\) MPa, \(\theta_{3}=1.2097\) MPa and \(J_{m}=77.931\). This strain energy yields a second Piola-Kirchhoff stress of the form:
\[\mathbf{S}=\underbrace{2\left[-\frac{\theta_{1}}{2}J_{m}\frac{1}{I_{1}-3-J_{m }}+\theta_{2}\frac{I_{1}}{I_{2}}\right]}_{c_{0}^{*}}\mathbf{I}\underbrace{-2 \theta_{2}\frac{1}{I_{2}}}_{c_{1}^{*}}\mathbf{C}+\underbrace{J\,\theta_{3}(J- \frac{1}{J})}_{c_{-1}^{*}}\mathbf{C}^{-1} \tag{44}\]
The Gent+Gent model is not polyconvex; however, it is convex over a limited range where \(I_{1}<J_{m}+3\). For simplicity, we refer to this model simply as Gent.
Note that hereafter \(c_{a}^{*}\) denote the true coefficients, which differ from the extracted coefficients \(c_{a}\) near ill-conditioned solves, and the fitted NN coefficients \(\hat{c}_{a}\).
### Training and validation
For sampling, we define a nine-dimensional space around the undeformed configuration of the deformation gradient as
\[\overline{F}_{ij}\in[F_{ij}^{L},F_{ij}^{U}]=\begin{cases}1-\delta\leq 1\leq 1+ \delta,&\text{when i=j},\\ -\delta\leq 0\leq\delta,&\text{otherwise}.\end{cases} \tag{45}\]
We then define a training region with \(\delta=0.2\) and a test region with \(\delta=0.3\) and use the space-filling sampling technique proposed in Ref. [37] to generate \(100\) training points and \(10,000\) test points that fill their respective spaces. Figure 1 shows the spread of these samples in invariant space \((I_{1},I_{2},J)\). Then given the triple \((I_{1},I_{2},I_{3}=J^{2})\) we can reconstruct the right Cauchy-Green tensor as
\[\mathbf{C}=\begin{bmatrix}\frac{1}{3}I_{1}-2\sqrt{H}\cos\left(\frac{\pi-\beta }{3}\right)&0&0\\ 0&\frac{1}{3}I_{1}-2\sqrt{H}\cos\left(\frac{\pi+\beta}{3}\right)&0\\ 0&0&\frac{1}{3}I_{1}-2\sqrt{H}\cos\left(\frac{\beta}{3}\right)\end{bmatrix} \tag{46}\]
where
\[H=\frac{1}{9}(I_{1}^{2}-3I_{2}),\qquad G=\frac{1}{3}I_{1}I_{2}-I_{3}-\frac{2}{ 27}I_{1}^{3},\qquad\beta=\arccos\left(-\frac{G}{2H^{3/2}}\right) \tag{47}\]
from which we can obtain the values of the invariants and the basis of all the investigated stress representations of Sec. 2. When training the model we use an \(80/20\) split to obtain \(20\) validation data points.
After obtaining a set of training and testing data we added noise to the resulting coefficient values to disrupt symmetries and analytic functional forms. In particular, we take the coefficient values \(c_{0},c_{1},c_{-1}\) corresponding to the representation
\[\mathbf{S}=c_{0}\mathbf{I}+c_{1}\mathbf{C}+c_{-1}\mathbf{C}^{-1} \tag{48}\]
for every data point, and define a noisy version \(\tilde{c}_{a}=c_{a}+\mathcal{N}(0,0.02\left|c_{a}\right|)\) for \(a=0,1,-1\) which then gives a noisy stress
\[\tilde{\mathbf{S}}=\tilde{c}_{0}\mathbf{I}+\tilde{c}_{1}\mathbf{C}+\tilde{c} _{-1}\mathbf{C}^{-1}. \tag{49}\]
This \(\tilde{\mathbf{S}}\) was then used as the target stress to obtain the coefficients for all other models, e.g. the Criscione model. Hence, we generate \(100\) noisy training samples that have the same invariants as the noiseless counterparts and use the same noiseless data for the test set. An example of a generated noisy test set is shown in Figure 2 for the Mooney-Rivlin model.
All the tensor basis neural network models [1] were implemented in _PyTorch_[70]. Potential models were formed from a multilayer, densely connected feedforward neural network (NN) with a single output
\[\Phi=N\!N(\mathcal{I}) \tag{50}\]
where the coefficients \(c_{a}=\partial_{I_{a}}\Phi\) are obtained through automatic differentiation. Summation with the known basis provides the stress
\[\mathbf{S}=\sum_{a}c_{a}\mathbf{B}_{a} \tag{51}\]
The coefficient-based models utilized a monolithic NN with 3 outputs
\[c_{a}=N\!\!N_{a}(\mathcal{I}) \tag{52}\]
and the same summation to form the stress. To be consistent all TBNN models consisted of 3 layers with 30 neurons per layer and a _Softplus_ activation function [71]. App. C and App. D provide additional details of the implementation of potential and coefficient-based TBNNs, respectively.
The training loss was formulated on the mean squared error of either the stress components or the coefficients
\[\text{MSE}=\lambda_{\mathbf{S}}\sum_{i=1}^{N_{\text{train}}}\|\mathbf{S}_{i}- \hat{\mathbf{S}}_{i}\|^{2}+\lambda_{c}\sum_{i=1}^{N_{\text{train}}}\sum_{a=1}^ {3}\|[c_{a}]_{i}-[\hat{c}_{a}]_{i}\|^{2}\, \tag{53}\]
since these are available from representative volume element (RVE)/experimental data, whereas the strain energy is less accessible. Although mixing both losses proved useful in preliminary studies, all reported data is from models trained with either \(\lambda_{\mathbf{S}}=1,\lambda_{c}=0\) or \(\lambda_{\mathbf{S}}=0,\lambda_{c}=1\). Note the coefficients scale as \(|c_{a}|\sim\|\mathbf{S}|\ \|\mathbf{B}_{a}\|^{-1}\) so the coefficient-based loss can suffer from numerical conditioning issues. All models were trained for \(50,000\) epochs using the _Adam_ optimizer [72] with a constant learning rate of \(0.001\).
We compared the performance of the models using the normalized mean squared error of the stress over the \(10,000\) testing data points
\[\text{RMSE}=\sqrt{\frac{\sum_{i=1}^{N_{\text{test}}}\|\mathbf{S}_{i}-\hat{ \mathbf{S}}(\mathbf{C}_{i})\|^{2}}{\sum_{i}\|\mathbf{S}_{i}\|^{2}}} \tag{54}\]
where \(\hat{\mathbf{S}}_{i}\) is the predicted stress and \(\mathbf{S}_{i}\) represents the ground truth at data point \(i\).
## 4 Results
First, we survey the test losses of the models enumerated in Table 1. Then we undertake detailed investigations of why the theoretically equivalent representations do or do not perform well by examining where the largest errors occur and how the predictions compare to held-out data.
Figure 1: Space-filling training/validation (colored by maximum stress component normalized by the mean for the Mooney-Rivlin data) and test samples in invariant space.
### Comparison of test losses
For each TBNN model described in Table 1 we assembled an ensemble of 30 parameterizations using random initialization of the NN parameters and shuffling the training/validation subsets of the 100 training points. Figure 3 shows the range of RMSE test errors for the six datasets from the 3 traditional models described in Sec.3, each with and without noise. Clearly, the various theoretically equivalent TBNN formulations perform differently and each of the datasets evoke different errors. Overall the polyconvex (Conv-Pot) and monotonic (Mono-Coeff) models appear to perform the best, although the standard potential-based (Rivlin-Pot) model has comparable performance to Mono-Coeff. The coefficient-based Rivlin-Coeff has considerably higher test errors than the potential-based Rivlin-Pot, despite Rivlin-Pot relying on automatic differentiation. The Criscione and other orthogonal models perform worse than the convex, monotonic and Rivlin models but they do better on the Gent data than on the other two datasets. We observe that the Gent model has a qualitatively different functional form than the selected Mooney-Rivlin and Carroll data-generating models, e.g. the presence of log terms in the energy Eq. (43). The Orth model with smoother invariants performs the best of the orthogonal basis models and is an anomaly in that it trains better indirectly to stress than to the extracted coefficients. This may be due to the conditioning issues with solving for coefficients of a power basis, mentioned in Sec. 3.3. The St. Venant model (both \(\mathbf{C}\) and \(\mathbf{E}\) based) is an outlier with large errors likely due to the mismatch in the growth of the tensor basis and the data, which necessitates more complex coefficient functions. Although small, the differences in calibration techniques can have an effect. Training to stress, instead of extracted coefficients, can regularize the trained coefficient functions, since stress is smoother than the coefficient functions as per the Man-Serrin theorem discussed in Sec. 2.2. Also training to stress can discourage a potential reinforcement of bias from individually trained coefficient functions that need to coordinate to form an accurate stress. Training to coefficients, on the other hand, removes the potentially ill-conditioned linear algebra implicit in training to stress. Projection of data onto expected bases may also remove discrepancies as with the noisy datasets.
The test errors seem to be largely dominated by testing the models in extrapolation, more insight will be given in the following sections.
Figure 2: Effective stress noise in percent of Frobenius norm error over the test data of a Mooney-Rivlin dataset.
### Locations of worst errors
The worst 1% errors of the 10,000 sample test set for each model are shown in Figure 4 for the Mooney-Rivlin data, in Figure 5 for the modified Carroll data, and in Figure 6 for the Gent data. For reference, the undeformed state is at \((I_{1}=3,I_{2}=3,I_{3}=1)\) which is inside the hull of sample points shown in these figures. Generally speaking, for most models, the worst errors are at the boundary of the test locus where they are forced into extrapolation. Note that \(I_{3}\) is associated with volumetric deformation, \(I_{1}\) can be interpreted at the linearization of \(I_{3}\), while \(I_{2}\) is sensitive to shear and deviatoric deformations.
Examining Figure 4, the Convex-Pot, Rivlin-Pot, and Orth-Coeff have the largest errors where the invariants (and eigenvalues of **C**) are large, while the Crisc-Coeff and the similar Orthnorm-Coeff have largest errors in the low region. The Crisc-Pot has relatively large errors at both extremes. Of the better-performing models, the Mono-Coeff formulation is an outlier since it has its worst errors in the midrange of the invariants, albeit still at the boundary. Likewise, the Orthnorm-Coeff has high error in the midrange, as well as the low range, while the St. Venant model performs particularly poorly in the low to midrange. The patterns are relatively unchanged with discrepancy
Figure 3: Comparison of TBNN variants summarized in Table 1 over test sets for the three different data models with and without noise. Note that coefficient-based variants with \({}^{*}\) were trained to stress data, and had to discover the coefficient values. Also the **E**-based variant of the St.Venant basis Eq. (29) had errors well above the displayed range so only the **C**-based variant Eq. (30) is shown.
added by noise, with the exception of the worst errors transitioning to the lower range for the most accurate model, Convex-Pot. The errors for the Carroll data shown in Figure 5 largely resemble those for the Mooney-Rivlin data, although for this data the Mono-Coeff and Orth-Coeff models seem more sensitive to noise. They, together with the Convex-Pot, shift their worst error locations with noise. The errors for the Gent data, shown in Figure 6, however, present different patterns. For this case, all models perform worst where the invariants are small, which can be ascribed to the Gent model being ill-defined where \(I_{1}\) becomes less than a value determined by the parameter \(J_{m}\). There are also scattered worst error locations in the midrange for the Rivlin-Coeff model.
Figure 7, Figure 8, and Figure 9 provide another view of the error patterns and corroborate the observations from the previous plots. These figures illustrate the correlation of the maximum errors with the difference in the largest and smallest (Rivlin-Ericksen) coefficient values for a particular data point in the test set. Large differences in the coefficient values are associated with less symmetric deformations. For each model, the figures show how the worst errors shift as a function of the difference in the coefficient values. For the Mooney-Rivlin data, only the worst-performing model, StV-C, has a single locus of maximal errors. Of the best-performing models, Convex-Pot, Rivlin-Pot, and Rivlin-Coeff have similar patterns that remain stable after the injection of noise. The Mono-Coeff model, on the other hand, changes the locations of where the worst errors occur relative to the difference in the coefficient values and also has the worst errors on par with Convex-Pot. Again the patterns for the Carroll data are similar to the Mooney-Rivlin data, while the Gent data present qualitatively different patterns. For the Gent data, all models, except the worst performing StV-C, have overlapping loci of worst errors that do not change appreciably with noise. This is perhaps due to discrepancies between the relatively simple TBNN models and the Gent data.
Next, we aim to test the performance of the TBNN variants to generalization. We conjecture that the differences in generalization performance can be attributed to how much of the complexity of the stress-strain mapping is intrinsically provided by the nonlinearity of the stress representation bases. Meaning, if the nonlinearity of the bases in the chosen representation is approaching the nonlinearity of the stress-strain mapping then the coefficient can be described by simpler lower-order functions. If the coefficients are lower-order functions, i.e. constant, linear, or quadratic, then accurately extrapolating this behavior with a TBNN is going to require less training data and a less complex NN to be accurate.
To check this hypothesis we offer the following approach. Consider the mapping \(\mathcal{M}_{IC}\) from the respective invariants to the respective coefficient values, e.g
\[\mathcal{M}_{IC}:\mathcal{I}\rightarrow[c_{1},c_{2},c_{3}]. \tag{55}\]
Let this mapping be approximated by a polynomial regressor of \(n\)-th order with interaction terms denoted by \(\hat{\mathcal{M}}^{n}_{IC}(\mathcal{I})\), e.g. for \(n=2\)
\[\hat{\mathcal{M}}^{2}_{IC}(\mathcal{I})=\hat{\mathbf{c}}^{2}_{IC}=\mathbf{\alpha}_{0} +\mathbf{\alpha}_{1}I_{1}+\mathbf{\alpha}_{2}I_{2}+\mathbf{\alpha}_{3}I_{3}+\mathbf{\alpha}_{4 }I_{1}^{2}+\mathbf{\alpha}_{5}I_{1}I_{2}+\mathbf{\alpha}_{6}I_{2}^{2}+\mathbf{\alpha}_{7}I _{2}I_{3}+\mathbf{\alpha}_{8}I_{3}^{2} \tag{56}\]
where \(\mathbf{\alpha}_{i}\in\mathbb{R}^{3}\). To check the potential complexity of this mapping we look at two scenarios. First, how polynomial regression fitted on the training data predicts the test data, and second, how well \(\hat{\mathcal{M}}^{n}_{IC}(\mathcal{I})\) predicts the test data coefficients if it was trained on the test data. The root-mean-squared error (RMSE) between the reference and predicted test data coefficients of the former is shown in Figure 10 for the three noiseless data cases. Surprisingly, polynomials of second order generalize the best for Rivlin-Coeff and Mono-Coeff. This leads us to the conjecture that the
complexity of the coefficient functions of Rivlin-Coeff and Mono-Coeff are generally lower than the other representation. This seems to correlate with the results of the TBNN generalization errors c.f. Figure 3. The coefficient error between the regressor of an increasing polynomial order, trained on the test data and evaluated on the test data is displayed in Figure 11. It can be seen that, compared to the previous case (Figure 3), Mono-Coeff and Rivlin-Coeff still have the lowest errors but more significantly that the complexity of the coefficient functions seems to have changed, i.e. while second order polynomials where best for models trained on the training data, now an increasing polynomial order seems to help to accurately fit the coefficient functions. Note that the upward trends after initial low discrepancy fits in some of the data in Figure 10 could possibly be attributed to overfitting of the polynomials to the 100-point training dataset.
Next, we aim to gauge what the contribution of the basis representation is on the accuracy. From the output of the polynomial regression of (56) an \(n\)-th order polynomial prediction of the stress can be obtained
\[\hat{\mathbf{S}}^{n}_{IC}=\sum_{a=1}^{3}\,\hat{c}^{n}_{a,IC}\mathbf{B}_{a}. \tag{57}\]
We furthermore assume an alternative mapping \(\mathcal{M}_{IS}\) from the invariants of the representation to
Figure 4: Mooney-Rivlin data, worst 1% errors for each model.
the symmetric components of the stress
\[\mathcal{M}_{IS}:\mathcal{I}\rightarrow[S_{11},S_{12},S_{13},S_{22},S_{23},S_{33}] \tag{58}\]
for which we build a similar \(n\)-th order polynomial referred to as \(\hat{\mathcal{M}}_{IS}^{n}\). Then, we can find the difference between the RMSEs of \(\hat{\mathbf{S}}_{IC}^{n}\) and \(\hat{\mathcal{M}}_{IS}^{n}\) evaluated on the test data, i.e.
\[\Delta\text{RMSE}^{n}(\mathcal{I}^{test})=\text{RMSE}(\hat{\mathcal{M}}_{IS}^ {n}(\mathcal{I}^{test}))-\text{RMSE}(\hat{\mathbf{S}}_{IC}^{n}(\mathcal{I}^{ test})).\]
Simplistically, this difference between the stress errors between these two regressors will help us judge the role and contribution of the basis generators, i.e. if \(\Delta\text{RMSE}^{n}>0\) then the bases have a positive contribution to the prediction which means that the RMSE of obtaining the stress from a linear combination of coefficients and bases \(\hat{\mathbf{S}}_{IC}^{n}=\sum_{a=1}^{3}\,\hat{c}_{a,IC}^{n}\mathbf{B}_{a}\) is lower than the mapping from invariants to stress directly. This would tell us that the basis components take complexity out of the system. On the other hand if \(\Delta\text{RMSE}^{n}<0\) the basis components make the mapping between invariants and stress more complex.
In Figure 12 we compare the RMSE-difference of models trained on the training data and evaluated on the test data while Figure 13 highlights the RMSE difference when the models were trained
Figure 5: Modified Carroll data, worst 1% errors for each model.
and tested on the test data. It can be seen that the basis components of the Mono-Coeff and Rivlin-Coeff representations generally help in reducing the complexity of the invariants-stress mapping, which is the reason why the invariants-stress mapping are not the same.
Figure 6: Gent data, worst 1% errors for each model.
Figure 7: Maximal errors for each model for the Mooney-Rivlin data. The horizontal lines indicate where the data has been clipped.
especially for lower polynomial order while the opposite is true for the remaining representations that were investigated.
Overall we believe that this investigation of the data through the lens of a polynomial regressor suggests that our hypothesis is valid. The TBNN has better generalization capabilities for some of the stress representations because the complexity of the mapping is reduced owing to nonlinearities introduced by the basis components.
Figure 8: Maximal errors for each model for the modified Carroll data. The horizontal lines indicate where the data has been clipped.
Figure 9: Maximal errors for each model for the Gent data. The horizontal lines indicate where the data has been clipped.
### Interpolation
The TBNN models have the ability to form smooth extensions to coefficient functions for high symmetry loading. Consider the parameterized invariants [73]
\[\begin{split} I_{1}(\gamma)&=3-2\,\gamma+\gamma^{2}\\ I_{2}(\gamma)&=3-4\gamma+2\,\gamma^{2}\\ I_{3}(\gamma)&=(1-\,\gamma)^{2}\end{split} \tag{59}\]
with \(\gamma\in[-0.2,0.2]\). A uniaxial extension can be observed for \(\gamma<0\) while \(\gamma>0\) yields an (equi)biaxial extension. This path is highlighted in Figure 14 in the projected invariant space and is inside the training region even though not explicitly part of the training data set. We specifically focus on this path due to the fact that it is characterized by two coalescent principal stretches \(\lambda_{2}=\lambda_{1}\) for \(\gamma<0\) and \(\lambda_{3}=\lambda_{2}\) for \(\gamma>0\) where \(\lambda_{1}\leq\lambda_{2}\leq\lambda_{3}\). Here \(\lambda_{a}=\sqrt{\epsilon}_{a}\) are the principal stretches. As described earlier and as seen in App. A, this means that the solution matrix for the coefficients of some of the presented stress representations is ill-conditioned and special schemes are
Figure 11: RMSE between predicted coefficient values and reference coefficient values using a polynomial of \(n\)-th order as the regressor which was trained on all available data (test data) and tested on the same data.
Figure 10: RMSE between predicted coefficient values and reference coefficient values using a polynomial of \(n\)-th order as the regressor which was trained on the training data and tested on the test data set.
needed to be able to solve for the coefficients. We remark that:
1. Depending on the loading path, these schemes lead to discontinuities near the reference state \(\mathbf{C}=\mathbf{I}\). In particular, this is the case for the Rivlin-Coff (\(\mathbf{S}=c_{1}\mathbf{I}+c_{2}\mathbf{C}+c_{3}\mathbf{C}^{-1}\)) and St.V-Coeff (\(\mathbf{S}=c_{1}\mathbf{C}+c_{2}\mathbf{C}^{2}+c_{3}\mathbf{C}^{3}\)) representations for the path described in Eq. (59).
2. Due to the space-filling way the training data was generated the principal strains of all training data points are unique, apart from the undeformed configuration. This means that the trained models have not been trained on coefficients that came as a result of the special schemes described in App. A. Hence, examining the predicted coefficients in this high-symmetry case provides an interesting and interpretable test case.
Figure 15 shows the trained coefficients and stress predictions for the Rivlin-Coeff and St.V-Coeff models over \(\gamma\). Clearly, the extracted coefficient functions near the reference state \(\mathbf{C}=\mathbf{I}\) become discontinuous; however, the built-in continuity of the NN enables an approximate continuous
Figure 12: The RMSE difference between the stress prediction of an n-th order polynomial trained from the invariants to coefficients \(\hat{\mathbf{S}}^{n}_{IC}\) and an n-th order polynomial trained from the invariants directly to the stress \(\hat{\mathcal{M}}^{n}_{IS}\), i.e. \(\Delta\text{RMSE}^{n}(\mathcal{I}^{test})=\text{RMSE}(\hat{\mathcal{M}}^{n}_ {IS}(\mathcal{I}^{test}))-\text{RMSE}(\hat{\mathbf{S}}^{n}_{IC}(\mathcal{I}^{ test}))\). Both models were trained on the **training** data and tested on the **test** data.
Figure 13: The RMSE difference between the stress prediction of an n-th order polynomial trained from the invariants to coefficients \(\hat{\mathbf{S}}^{n}_{IC}\) and an n-th order polynomial trained from the invariants directly to the stress \(\hat{\mathcal{M}}^{n}_{IS}\), i.e. \(\Delta\text{RMSE}^{n}(\mathcal{I}^{test})=\text{RMSE}(\hat{\mathcal{M}}^{n}_ {IS}(\mathcal{I}^{test}))-\text{RMSE}(\hat{\mathbf{S}}^{n}_{IC}(\mathcal{I}^ {test}))\). Both models were trained on all available **test** data and tested on the same data.
extension. This approximation \(\hat{c}_{a}\) is different than the coefficients \(c_{a}\) extracted from the equation system, altered to accommodate multiplicity, but still yields an accurate stress representation for Rivlin-Coeff and a sufficient one for StV-Coeff. It seems that the smooth extension avoids large errors that would be incurred if the extracted coefficients were approximated.
Remarkably, the resulting predicted coefficients for Rivlin-Coeff are practically equivalent to the derived coefficients from the potential prediction of Convex-Pot, Figure 16. This is interesting since Convex-Pot has not been trained on the coefficients. We furthermore remark that (for this loading case) not all of the representations show a discontinuous coefficient behavior as a result of the coalescent principal strains. For example for Mono-Coff, whose coefficient matrix was also ill-conditioned and had to be adapted, the coefficient behavior is smooth over \(\gamma\), see Figure 17. In this case, the NN coefficients are basically identical to the extracted coefficients obtained from the altered equation system.
### Extrapolation
To highlight the predictive quality of selected representations consider a loading path given by the homogenous deformation [73]
\[\begin{split} I_{1}&=3-1.6\,\gamma+\gamma^{2}\\ I_{2}&=3-3.2\gamma+1.64\,\gamma^{2}\\ I_{3}&=(1-0.8\,\gamma)^{2}\end{split} \tag{60}\]
where \(\gamma\in[0,1]\). The loading path projected into invariant space is shown in Figure 18. We can see that it starts at the undeformed configuration and goes beyond even the range of the test data. The deformation leaves the hull of the training data points at \(\gamma\approx 0.25\). We highlight that this path is not explicitly part of the training data set. For five of the representations, Figure 19 shows the expected coefficients and trained coefficients respectively. The range of the training regime is highlighted. Surprisingly, all the selected models fit the reference coefficients sufficiently well, even St.V-Coeff which was by far the worst-performing approach in terms of generalization error. Comparing the fits of the models to the conclusions drawn from Figure 3, it becomes evident that the magnitude-wise largest coefficient predictions of the poorly performing representations tend to stagnate earlier. Similar reasoning can be followed when examining Figure 20 which plots three components of the expected stress and their predicted counterparts from the neural network models,
Figure 14: Uniaxial and Biaxial extension parameterization in invariant space given by \(\gamma\)
where we observe that the representations which have only one significant coefficient on the path are also the best performing.
## 5 Conclusion
In this work, we investigated the a wide variety of tensor basis neural network models, including previously unexplored alternatives to the classical Finger-Rivlin-Ericksen stress representation, such as TBNNs with an orthogonal basis and others with a St. Venant basis. We compared coefficient-based TBNNs against potential-based models and discussed and summarized techniques to obtain reference coefficient values from stress-strain data pairs.
In our cases studies involving six test datasets for three materials and two noise levels, the representations derived from the classical Finger-Rivlin-Ericksen formulation yield the best generalization performance. This was surprising to us, because we had initially believed that in particular, the
Figure 15: Reference and predicted coefficients around the undeformed configuration for uniaxial (\(\gamma<0\)) and biaxial (\(\gamma>0\)) extension for the Rivlin-Coeff and St.V-Coeff representations obtained from the Mooney-Rivlin model.
potential advantages of orthogonal bases, e.g. continuity of the coefficients and linear independence, would also translate into better extrapolations. We found that the generalization capabilities of the stress representations is largely dependent on the simplicity and lower complexity of the coefficient functions in the sense that the coefficient functions are smooth and monotonic, like low-order polynomials. This is the case when the stress generators (bases) already describe a majority of the stress-strain data complexities and hence the invariant-coefficient mappings are simpler. The introduction of physics-constrained extensions to the TBNN in particular convexity (potential) or monotonicity (coefficients) appears to be the most beneficial for accurate extrapolation and generalization. We also observed that the assumption of the existence of a potential helps the performance,
Figure 16: Reference and predicted coefficients around the undeformed configuration for uniaxial (\(\gamma<0\)) and biaxial (\(\gamma>0\)) extension for the Rivlin-Coeff and Convex-Pot representations obtained from the Mooney-Rivlin model.
Figure 17: Reference and predicted coefficients around the undeformed configuration for uniaxial (\(\gamma<0\)) and biaxial (\(\gamma>0\)) extension for the Mono-Coeff representation obtained from the Mooney-Rivlin model.
i.e. potential-based models generalize better than coefficient-based models for the same stress representation.
In future work the study will be extended to include anisotropic representations. We also aim to introduce monotonically increasing neural network formulations that eliminate the restrictiveness of current implementations, where a subset of the outputs is monotonically increasing with only a subset of the inputs, to potentially improve the performance of the monotonic Rivlin representation.
## Acknowledgments
REJ would like to thank Professor J.B. Estrada (University of Michigan) and NB would like to thank Professor K.T. Ramesh (Johns-Hopkins University) for independently pointing out Criscione's work on stress representations with an orthogonal basis.
JF and NB gratefully acknowledge support by the Air Force Office of Scientific Research under award number FA9550-22-1-0075.
Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC., a wholly owned subsidiary of Honeywell International, Inc., for the U.S. Department of Energy's National Nuclear Security Administration under contract DE-NA-0003525. This paper describes objective technical results and analysis. Any subjective views or opinions that might be expressed in the paper do not necessarily represent the views of the U.S. Department of Energy or the United States Government.
Figure 18: Parameterization in invariant space given by \(\gamma\)
Figure 19: Selected Mooney-Rivlin coefficient curves over parameter \(\gamma\). Dashed lines: extracted coefficients, solid lines: trained NN coefficients.
Figure 20: Selected Mooney-Rivlin stress-strain curves over parameter \(\gamma\). Dashed lines: data, solid lines: trained NN. |
2301.04838 | LB-SimTSC: An Efficient Similarity-Aware Graph Neural Network for
Semi-Supervised Time Series Classification | Time series classification is an important data mining task that has received
a lot of interest in the past two decades. Due to the label scarcity in
practice, semi-supervised time series classification with only a few labeled
samples has become popular. Recently, Similarity-aware Time Series
Classification (SimTSC) is proposed to address this problem by using a graph
neural network classification model on the graph generated from pairwise
Dynamic Time Warping (DTW) distance of batch data. It shows excellent accuracy
and outperforms state-of-the-art deep learning models in several few-label
settings. However, since SimTSC relies on pairwise DTW distances, the quadratic
complexity of DTW limits its usability to only reasonably sized datasets. To
address this challenge, we propose a new efficient semi-supervised time series
classification technique, LB-SimTSC, with a new graph construction module.
Instead of using DTW, we propose to utilize a lower bound of DTW, LB_Keogh, to
approximate the dissimilarity between instances in linear time, while retaining
the relative proximity relationships one would have obtained via computing DTW.
We construct the pairwise distance matrix using LB_Keogh and build a graph for
the graph neural network. We apply this approach to the ten largest datasets
from the well-known UCR time series classification archive. The results
demonstrate that this approach can be up to 104x faster than SimTSC when
constructing the graph on large datasets without significantly decreasing
classification accuracy. | Wenjie Xi, Arnav Jain, Li Zhang, Jessica Lin | 2023-01-12T06:49:55Z | http://arxiv.org/abs/2301.04838v3 | LB-SimTSC: An Efficient Similarity-Aware Graph Neural Network for Semi-Supervised Time Series Classification
###### Abstract
Time series classification is an important data mining task that has received a lot of interest in the past two decades. Due to the label scarcity in practice, semi-supervised time series classification with only a few labeled samples has become popular. Recently, Similarity-aware Time Series Classification (SimTSC) is proposed to address this problem by using a graph neural network classification model on the graph generated from pairwise Dynamic Time Warping (DTW) distance of batch data. It shows excellent accuracy and outperforms state-of-the-art deep learning models in several few-label settings. However, since SimTSC relies on pairwise DTW distances, the quadratic complexity of DTW limits its usability to only reasonably sized datasets. To address this challenge, we propose a new efficient semi-supervised time series classification technique, LB-SimTSC, with a new graph construction module. Instead of using DTW, we propose to utilize a lower bound of DTW, LB_Keogh, to approximate the dissimilarity between instances in linear time, while retaining the relative proximity relationships one would have obtained via computing DTW. We construct the pairwise distance matrix using LB_Keogh and build a graph for the graph neural network. We apply this approach to the ten largest datasets from the well-known UCR time series classification archive. The results demonstrate that this approach can be up to 104x faster than SimTSC when constructing the graph on large datasets without significantly decreasing classification accuracy.
1
Footnote 1: These authors contributed equally.
Copyright © 2023, Association for the Advancement of Artificial Intelligence (www.aaai.org). All rights reserved.
## Introduction
Time series classification is an important research area and attracts a great amount of attention [22]. In practice, due to the difficulty and high cost of obtaining labeled data, there might only be a few labeled instances per class for training. This becomes one of the greatest challenges in time series classification, and motivates researchers to investigate semi-supervised solutions [23]. Recently, zha et al. [24] proposed SimTSC, which combines batch Graph Convolution Network (GCN) [10] with Dynamic Time Warping (DTW), a commonly used distance measure that allows non-linear alignments in time. DTW has been shown to be more robust than other distance measures like Euclidean Distance in tasks such as classification and similarity search [1]. Specifically, SimTSC builds a graph from the DTW distance matrix; each node corresponds to a time series instance to be classified, and the edge is generated through DTW distance. SimTSC is versatile for three reasons. First, it only requires a batch dynamic subgraph and does not need the complete graph for the entire data to be stored in the GPU for training. Second, compared with the classic graph generation process, which simply uses the k-nearest neighbors (k-NN) to generate a static graph, SimTSC uses a graph via local k-NN generated from batch data, which allows the information in labeled data to be efficiently passed to the unlabeled data. Third, SimTSC is able to learn a warping-aware representation by inheriting the advantages of using DTW [19].
Despite the advantages, SimTSC is not scalable for large data. To construct the graph, SimTSC requires the full pairwise computation of DTW distances, a process with a high computational cost of \(O(L^{2})\), where L is the time series instance length. For example, for the famous _StartLightCurves_ dataset, which contains 9,236 time series of length 1,024, DTW takes around two days to calculate the distances between all pairs. Furthermore, since DTW computation uses dynamic programming, it is not parallelizable with GPU computations. While several techniques have been proposed to speed up DTW computation, they cannot be applied in this case since they work by pruning unnecessary computations for the similarity search problem, whereas SimTSC requires the full pairwise distance matrix for training.
To address this problem, we propose a new efficient graph based time series classification technique, **L**ower **B**ound **S**imilarity-aware **T**ime Series (LB-SimTSC) with a new efficient graph construction approach. Instead of computing the pairwise distance matrix using DTW, we propose to use a lower-bounding distance for DTW, which is much cheaper to compute. In particular, we adapt LB_Keogh, a popular lower bound for DTW [11], with \(O(L)\) time complexity. For the _StartLightCurves_ dataset, it would only take about 30 minutes to compute all pairwise distances using LB_Keogh instead of 2 days. The idea of lower bound is originally proposed to speed up the 1-NN similarity search problem by providing a reasonable, efficient-to-compute approximation of the actual distance and allowing us to prune some candidates from con
sideration. It is not designed as a similarity measure by itself. However, we observe that LB_Keogh matrix can be used as a replacement for DTW to provide the guidance needed by GCN and help GCN learn a similar warping-aware representation. We demonstrate through empirical evaluation that using the approximation matrix can achieve similar performance as the original SimTSC, with reduced running time by two orders of magnitude.
In summary, our contribution is as follows:
* In this paper, we investigate an important and challenging problem of semi-supervised time series classification with only a few labeled samples.
* We propose a new efficient graph-based time series classification technique, LB-SimTSC, with a new graph construction module that takes only linear time.
* Our experimental results show that our proposed LB-SimTSC achieves similar performance with SimTSC, but with much faster graph construction for large data.
* Our work demonstrates that it is possible to leverage a much more efficient lower bound distance-based graph to guide GCN, while still maintaining the same ability as using the more expensive DTW distance.
## Related Work
**Graph-based Time Series Classification** Most existing graph-based time series classification methods either require actual graphs (e.g., transportation) as an input or do not consider semi-supervised settings with few labels in each class [1]. The most closely related work is SimTSC [13]. SimTSC constructs a graph from the DTW pairwise matrix, where each node represents a time series, and the connection between nodes represents their similarity. The computation of the matrix is very time-consuming for large data. Our proposed method LB-SimTSC takes an alternative approach to address the efficiency bottleneck by utilizing LB_Keogh, a lower bound of DTW, to construct the graph. LB-SimTSC significantly reduces the graph construction time from quadratic to linear in the length of instances. It is thus more scalable for large datasets while maintaining comparable performance as SimTSC.
**Lower Bound of DTW** Lower bound of DTW is introduced to speed up time series similarity search. Since lower bounding measures are often much cheaper to compute than DTW, they are often used to approximate the minimum distance between a pair of sequences. Such approximation allows the quick elimination of certain unqualified candidates without computing the actual distances in similarity search. Driven by the need for efficient DTW-based similarity search, many lower bounding distance measures such as LB_Yi, LB_Kim, and LB_Keogh [22, 1, 13] have been proposed. Among them, LB_Keogh [13] is simple to compute and remains one of the most competitive and tightest lower bounds for DTW-based query tasks.
To the best of our knowledge, we are the first to explore the direction of using a lower bounding measure for graph construction for graph-based semi-supervised time series classification models.
## Problem Formulation
In this paper, we study a time series semi-supervised classification problem with the transductive setting [13], where test data without labels can be seen during training time. Consider a training data \(\mathcal{X}^{train}\) consisting of an time series instances \(X_{i}\) of length \(L\), with only a small \(n^{\prime}\) instances \(\mathcal{X}^{labeled}=[X_{1},X_{2},\cdots,X_{n^{\prime}}]\) with known labels \(Y^{labeled}=[y_{1},y_{2},\cdots,y_{n^{\prime}}]\) where \(y_{i}\in\{1,\cdots,C\}\) classes, and \(\mathcal{X}^{unlabeled}\) data without labels. During training, our proposed model is trained on \(\mathcal{X}^{labeled}\) and \(Y^{labeled}\) with \(\mathcal{X}^{unlabeled}\). Our goal is to train a model that correctly predicts the labels of test data \(\mathcal{X}^{test}\).
## Methodology
Fig. 1 shows the overall framework of the proposed method. The framework consists of three steps: **1) Batch Sampling**. Given a dataset \((\mathcal{X},\mathbf{Y})\), we first form a batch consisting of an equal number of labeled and unlabeled data \(\mathcal{X}^{B}\). **2) LB_Keogh Lower Bound Graph Construction**. We compute a pairwise lower bound distance matrix with respect to \(\mathcal{X}^{B}\) to generate a batch LB-graph \(G^{B}\) that describes the approximate warping-aware (dis)similarity between pairs of instances within each batch. The feature vector is obtained from the backbone network. **3) Graph Convolution and Classification** The feature vector is passed through Graph
Figure 1: Overall framework of LB-SimTSC.
Convolution Network (GCN) [10] to aggregate the features across the generated \(G^{B}\). Then the obtained node embedding is passed through a fully connected neural network and performs the classification task.
There are two main advantages of the framework: We can pass the label information from labeled instances to unlabeled instances through batched data. In addition, the GCN aggregates the information of similar instances under warping captured by the generated batch LB-graph \(G^{B}\) and achieves the preservation of warping-aware similarity on the instance level in the latent space.
Batch SamplingTo form a batch \(\mathcal{X}^{B}\) of size \(m\), we sample \(m/2\) number of instances from labeled data \((\mathcal{X}^{labeled},Y^{labeled})\), and \(m/2\) number of instances from unlabeled data \(\mathcal{X}^{unlabeled}\). In this step, we ensure that each class has equal samples to avoid imbalance in the learning process. The batch data will be used to compute the embedding and the proposed batch LB-Graph.
Lb_Keogh Graph ConstructionWe introduce our proposed LB_Keogh Graph (LB-Graph) construction in this subsection.
LB_Keogh [1] is originally proposed as a lower bound to prune unnecessary computations of DTW when performing similarity search. It is much cheaper to compute than the actual DTW distance, but still maintains the ability to allow warping when comparing two time series.
Given two time series instances \(X_{i}\) and \(X_{j}\) from batch \(\mathcal{X}^{B}\), LB_Keogh creates an envelope consisting of one upper bound and one lower bound time series. As shown in Eq. 1, for each timestamp \(k\):
\[\begin{split} u_{i,k}&=\max([X_{i,k-r},X_{i,k-r+1}, \cdots,X_{i,k+r}])\\ l_{i,k}&=\min([X_{i,k-r},X_{i,k-r+1},\cdots,X_{i,k+r }])\end{split} \tag{1}\]
where \(r\) is the allowed range of warping. Then the LB_Keogh distance \(d^{LB}\) between instance \(X_{i}\) and \(X_{j}\) is calculated by Eq. 2:
\[d^{LB}(X_{i},X_{j})=\sqrt{\sum_{k=1}^{L}\left\{\begin{array}{ll}(X_{j,k}-u_{ i,k})^{2},&ifX_{j,k}>u_{i,k}\\ (X_{j,k}-l_{i,k})^{2},&ifX_{j,k}<l_{i,k}\\ 0,&otherwise\end{array}\right.} \tag{2}\]
The pairwise LB_Keogh matrix \(D_{LB}\) given a batch \(\mathcal{X}^{B}\) is hence defined as
\[D_{LB}(i,j)=d^{LB}(X_{i},X_{j}),\quad X_{i}\in\mathcal{X}^{B},X_{j}\in \mathcal{X}^{B}. \tag{3}\]
Graph Construction from \(D_{LB}\)We next generate the graph \(G^{B}(V,E)\) from \(D_{LB}\). We perform a two-step approach to compute the edges.
We first convert the LB_Keogh distance to similarity by:
\[A_{i,j}=\frac{1}{\exp{(\alpha D_{i,j})}}. \tag{4}\]
where \(\alpha\) is scaling parameter.
Then we generate a sparse graph based on \(A\). For each row \(A_{i}=[A_{i,1},\ldots,A_{i,m}]\) in \(A\), we select \(K\) candidates to form the sparse adjacency matrix. Specifically, to form a vector \(Q_{i}\), we select random \(K\) candidates with zero LB_Keogh distance, which indicates that the shapes of these instances fall within the enveloped area (i.e. they are likely to be similar to \(X_{i}\)). If there are fewer than \(K\) candidates with zero distance, then we pick \(K\) instances with the smallest LB_Keogh distances.
To incorporate this idea, we compute a sparse adjacency matrix \(\bar{A}_{i,j}\) by:
\[\bar{A}_{i,j}=\left\{\begin{array}{ll}1/K,&j\sim\mathcal{Q}_{i}\quad \&\quad|\mathcal{Q}_{i}|\geq K;\\ A_{i,j},&A_{i,j}\in\arg\text{TopK}(A_{i})\quad\&\quad|\mathcal{Q}_{i}|<K;\\ 0,&\text{otherwise}.\end{array}\right. \tag{5}\]
where \(\mathcal{Q}_{i}=\{k|D_{i,k}=0\}\), and we randomly pick \(K\) samples from \(\mathcal{Q}_{i}\).
Now we are ready to build the batch graph \(G^{B}(V,E)\) where \(|V|=m\), and the weights between node \(i\) and node \(j\) is defined as:
\[E_{i,j}=\frac{\bar{A}_{i,j}}{\sum_{b=1}^{m}\bar{A}_{i,b}}. \tag{6}\]
The overall LB graph construction algorithm is summarized in Algorithm 1.
```
1:Input:\(\mathcal{X}^{B}\): batch data, \(r\): warping range, \(\alpha\): scaling factor, \(K\): number of top neighbors
2:Output:\(G^{B}\): the graph of the current batch /* Compute \(D_{LB}\) via Eqn. 3 */
3:\(D\)=ComputePairwiseLB(\(X_{batch}\)) /* Compute \(A\) via Eqn. 4 */
4:for each \(D_{i,j}\) in \(D\)do
5:\(A_{i,j}=1/\exp(\alpha D_{i,j})\)
6:endfor
7: /* Compute \(G^{B}\) via Eqn. 5 and Eqn. 6. */
8:\(G^{B}=\text{GenerateGraph}(A,K)\)
9:return\(G^{B}\)
```
**Algorithm 1** LB-Graph Construction
Graph Convolution and ClassificationGiven a backbone network \(f(.)\), we compute the feature embedding network \(z=f(\mathcal{X}^{B})\). Then the embedding \(z\) is passed through a series of graph convolutional network (GCN) layers and used to perform classification. Particularly,
\[z^{l}=GCN(G^{B},z^{l-1})\]
\[o=Softmax(z^{l}).\]
where \(l\) is the number of layers in this case. In our work, we use the same backbone network as SimTSC [14], which is a ResNet [1] with three residual blocks.
Figure 2: A visual intuition of the lower envelope (blue dotted line) and upper envelope (green dotted line) of a sample time series (gray solid line) generated by LB_Keogh.
### Advantages of LB-SimTSC
Compared with SimTSC [13], our proposed method has two advantages. First, we construct batch LB_Keogh graph, which can be seen as an alternative but efficient solution to measure warping similarity. Compared to the original DTW distance computation, which is expensive via dynamic programming or recursion, LB_Keogh is simple and only requires \(O(L)\) time complexity. Second, from Eqn 2, we can see that \(D_{LB}\) is highly parallelizable, thus more suitable to implement in GPU.
Moreover, GCN does not require exact weights to perform aggregate information to propagate label information. Therefore, although LB_Keogh matrix \(D_{LB}\) containing zero values provides a less accurate warping measure than DTW, all of these instances fall into the envelop area and share some degree of warping similarity. Thus, a random subset of zero value in \(D_{LB}\) is sufficient to guide the training and propagate labels. In our experiments, we find that the empirical performance of LB-SimTSC is statistically comparable with the performance of SimTSC.
## Experimental Evaluation
In this section, we evaluate both efficiency and performance of our proposed LB-SimTSC.
DatasetsOur evaluation will focus on demonstrating the efficiency of LB-SimTSC, as well as the ability to achieve competitive performance even with few labels available. We choose all large datasets from the UCR classification archive [1]. Specifically, we choose datasets with sequence lengths greater than 500, and the number of instances greater than 2000. A total of ten datasets are included. We follow the same dataset generation protocol as SimTSC, whereas we first split every dataset into training set (80%) and test set dataset (20%). We randomly sample \(\beta\) instances for each class from the training data to form \(\mathcal{X}^{labeled}\) and \(Y^{labeled}\). The remaining training data is used as \(\mathcal{X}^{unlabeled}\). We test six different settings \(\beta=\{5,10,15,20,25,30\}\). We report the classification accuracy for each case.
HyperparametersWe keep all the settings of the baselines, consistent with the original paper. For our model, we fix the warping range \(r\) to be 5% of time series length, and empirically set the scaling factor \(\alpha\) to 11. All other settings are consistent with SimTSC.
Experiment 1: Comparing with 1NN-DTWWe compare with the 1-Nearest Neighbor classifier under Dynamic Time Warping Distance (1NN-DTW). 1NN-DTW is a well-known baseline in time series classification [1] and still performs well even with only few labeled data available [13].
Table 1 shows the classification accuracy of 1NN-DTW and our model on the 10 datasets. Our model wins 8 or 9 out of 10 in most cases, and ties with 1NN-DTW when \(\beta=5\). To further illustrate the superiority of the accuracy of our model, we perform the one-sided Wilcoxon signed-rank test. The p-values of the Wilcoxon test between two models on all \(\beta\) settings are 0.246, 0.042, 0.042, 0.043, 0.043, 0.024 and 0.042, respectively. Among them, except for \(\beta=5\), the rest of the p-values are all less than 0.05. Thus we conclude that our model is significantly better than 1NN-DTW across all settings except 5 labels, which is consistent with the observation in SimTSC. This is potential because the extreme small-sample situation is easier for the classical 1-NN method but more difficult for deep learning to get good performance.
Experiment 2: Comparing with SimTSCSimTSC [13] is the closest related work. We compare computational time for graph construction, which is the major bottleneck in overall computation cost. For both methods, to ensure a fair comparison, we follow the same implementation process described in [13] via pre-computing the similarity matrix for the entire dataset first, then performing sampling for each batch. For our model, LB-SimTSC, we use Python to implement the graph construction process. For SimTSC, since their graph construction code in C is not executable on our computer, we use an equivalent C++ implementation to estimate their running time. We report the actual running time for both methods.
\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline & \multicolumn{2}{c}{5 labels} & \multicolumn{2}{c}{10 labels} & \multicolumn{2}{c}{15 labels} \\ \hline Datasets & 1NN-DTW & LB\_SimTSC & 1NN-DTW & LB\_SimTSC & 1NN-DTW & LB\_SimTSC \\ \hline Perda & 0.540 & **0.793** & 0.531 & **0.826** & 0.545 & **0.816** \\ Perdb & 0.672 & **0.813** & 0.603 & **0.806** & 0.628 & **0.807** \\ NIFECTECT & **0.665** & 0.662 & 0.704 & **0.743** & 0.710 & **0.830** \\ NIFECTECT & **0.757** & 0.689 & 0.758 & **0.798** & 0.817 & **0.856** \\ UWGLAll & **0.779** & 0.447 & **0.824** & 0.549 & **0.856** & 0.622 \\ Phoneme & 0.185 & **0.255** & 0.204 & **0.330** & **0.209** & **0.346** \\ Mailfa & **0.944** & 0.508 & 0.900 & **0.635** & **0.571** & 0.960 \\ MSST & 0.784 & **0.871** & 0.796 & **0.853** & 0.834 & **0.908** \\ MSST & **0.790** & 0.775 & 0.519 & **0.891** & 0.834 & **0.916** \\ SLC & 0.559 & **0.970** & **0.653** & **0.939** & 0.763 & **0.546** \\ \hline wins & **5** & **5** & **1** & **9** & **2** & **8** \\ p-value & 0.246 & **-** & 0.042 & **-** & 0.042 & **-** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Accuracy scores LB-SimTSC (ours) and 1NN-DTW on ten large datasets. The p-value is calculated using the Wilcoxon signed-rank test (one-sided).
\begin{table}
\begin{tabular}{l c c c c c} \hline \hline Datasets & Length & Instance & SimTSC & LB-SimTSC & Faster \\ \hline Perda & 500 & 4921 & 3.826 & **0.127** & **30s** \\ FordB & 500 & 4446 & 3.310 & **0.099** & **33x** \\ NIFECTECT1 & 750 & 3765 & 4.622 & **0.082** & **56x** \\ NIFECTECT2 & 750 & 3765 & 4.678 & **0.081** & **58x** \\ UWGLAll & 945 & 4478 & 10.385 & **0.126** & **62x** \\ Phoneme & 1024 & 2110 & 2.841 & **0.029** & **96x** \\ Mallat & 1024 & 2400 & 3.716 & **0.036** & **104x** \\ MSST & 1024 & 2525 & 4.014 & **0.041** & **96x** \\ MSRT & 1024 & 2925 & 5.045 & **0.058** & **86x** \\ SLC & 1024 & 9236 & 46.240 & **0.566** & **82x** \\ \hline Total & & & & 88.676 & **1.247** & **71x** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparison of graph construction time
Table 2 shows the graph construction time in hours for SimTSC and LB-SimTSC on the ten datasets. We can observe that even when we use the slower implementation (Python) for the graph construction module of our model and the much faster implementation (MATLAB) for SimTSC, our model is still 71x faster than SimTSC in total time, and up to 104x faster on one dataset. For the time required to complete all graph construction, our approach reduces it from 3 days 16 hours to only 75 minutes. Note that an increase in time series length or number of instances makes the speed gap of our method more significant than that of SimTSC. The large time saving of our model makes our approach desirable for semi-supervised TSC on large data with few labels.
We also compare the accuracy to demonstrate that LB-SimTSC still achieves competitive performance. To eliminate randomness in deep learning training, we run both methods three times and report the average accuracy. Table 3 shows the classification accuracy of SimTSC and our model. The number of wins of SimTSC is slightly more than ours in all settings. To show the difference in accuracy between the two models, we perform the two-sided Wilcoxon signed-rank test. The p-values between SimTSC and LB-SimTSC are 0.492, 0.375, 0.375, 0.232, 0.695 and 0.492, respectively. All the p-values are less than 0.05, meaning our model does not have a significant difference in accuracy from SimTSC.
## Conclusion
In this paper, we study efficient semi-supervised time series classification with few labeled samples. We propose a new efficient graph-based time series classification, LB-SimTSC, with a new graph construction module that takes only linear time. Our proposed method resolves the scalability issue of constructing graphs from large datasets while maintaining the ability to allow time warping when comparing two time series. The experimental results on ten large datasets from the UCR archive show that our model achieves two orders of magnitude of speedup on graph construction without significant loss of classification accuracy compared to SimTSC. Furthermore, our work is the first to explore using a more efficient lower bounding-based graph to guide GCN while still maintaining the same ability as the more expensive DTW-based SimTSC.
|
2303.06856 | Dynamic Neural Network for Multi-Task Learning Searching across Diverse
Network Topologies | In this paper, we present a new MTL framework that searches for structures
optimized for multiple tasks with diverse graph topologies and shares features
among tasks. We design a restricted DAG-based central network with
read-in/read-out layers to build topologically diverse task-adaptive structures
while limiting search space and time. We search for a single optimized network
that serves as multiple task adaptive sub-networks using our three-stage
training process. To make the network compact and discretized, we propose a
flow-based reduction algorithm and a squeeze loss used in the training process.
We evaluate our optimized network on various public MTL datasets and show ours
achieves state-of-the-art performance. An extensive ablation study
experimentally validates the effectiveness of the sub-module and schemes in our
framework. | Wonhyeok Choi, Sunghoon Im | 2023-03-13T05:01:50Z | http://arxiv.org/abs/2303.06856v1 | # Dynamic Neural Network for Multi-Task Learning
###### Abstract
In this paper, we present a new MTL framework that searches for structures optimized for multiple tasks with diverse graph topologies and shares features among tasks. We design a restricted DAG-based central network with read-in/read-out layers to build topologically diverse task-adaptive structures while limiting search space and time. We search for a single optimized network that serves as multiple task adaptive sub-networks using our three-stage training process. To make the network compact and discretized, we propose a flow-based reduction algorithm and a squeeze loss used in the training process. We evaluate our optimized network on various public MTL datasets and show ours achieves state-of-the-art performance. An extensive ablation study experimentally validates the effectiveness of the sub-module and schemes in our framework.
## 1 Introduction
Multi-task learning (MTL), which learns multiple tasks simultaneously with a single model has gained increasing attention [3, 13, 14]. MTL improves the generalization performance of tasks while limiting the total number of network parameters to a lower level by sharing representations across tasks. However, as the number of tasks increases, it becomes more difficult for the model to learn the shared representations, and improper sharing between less related tasks causes negative transfers that sacrifice the performance of multiple tasks [15, 36]. To mitigate the negative transfer in MTL, some works [6, 25, 32] separate the shared and task-specific parameters on the network.
More recent works [21, 29, 38] have been proposed to dynamically control the ratio of shared parameters across tasks using a Dynamic Neural Network (DNN) to construct a task adaptive network. These works mainly apply the cell-based architecture search [19, 27, 41] for fast search times, so that the optimized sub-networks of each task consist of fixed or simple structures whose layers are simply branched, as shown in Fig. 0(a). They primarily focus on finding branching patterns in specific aspects of the architecture, and feature-sharing ratios across tasks. However, exploring optimized structures in restricted network topologies has the potential to cause performance degradation in heterogeneous MTL scenarios due to unbalanced task complexity.
We present a new MTL framework searching for sub-network structures, optimized for each task across diverse network topologies in a single network. To search the graph topologies from richer search space, we apply Directed Acyclic Graph (DAG) for the homo/heterogeneous MTL frameworks, inspired by the work in NAS [19, 27, 40]. The MTL in the DAG search space causes a scalability issue, where the number of parameters and search time increase quadratically as the number of hidden states increases.
To solve this problem, we design a restricted DAG-based central network with read-in/read-out layers that allow our MTL framework to search across diverse graph topologies while limiting the search space and search time. Our flow-restriction eliminates the low-importance long skip connection among network structures for each task, and creates the required number of parameters from \(O(N^{2})\) to \(O(N)\). The read-in layer is the layer that directly connects all the hidden states from the input state, and the read-out layer is the layer that connects all the hidden states to the last feature layer. These are key to having various network topological representations, such as polytree structures, with early-exiting and multi-embedding.
Then, we optimize the central network to have compact task-adaptive sub-networks using a three-stage training procedure. To accomplish this, we propose a squeeze loss and a flow-based reduction algorithm. The squeeze loss limits the upper bound on the number of parameters. The reduction algorithm prunes the network based on the weighted adjacency matrix measured by the amount of information flow in each layer. In the end, our MTL framework constructs a compact single network that serves as multiple task-specific networks with unique structures, such as chain, polytree, and parallel diverse topologies, as presented in Fig. 0(b). It also dynamically controls the amount of sharing representation among tasks.
The experiments demonstrate that our framework successfully searches the task-adaptive network topologies of each task and leverages the knowledge among tasks to make a generalized feature. The proposed method outperforms state-of-the-art methods on all common benchmark datasets for MTL. Our contributions can be summarized as follows:
* We present for the first time an MTL framework that searches both task-adaptive structures and sharing patterns among tasks. It achieves state-of-the-art performance on all public MTL datasets.
* We propose a new DAG-based central network composed of a flow restriction scheme and read-in/out layers, that has diverse graph topologies in a reasonably restricted search space.
* We introduce a new training procedure that optimizes the MTL framework for compactly constructing various task-specific sub-networks in a single network.
## 2 Related Works
**Neural Architecture Search (NAS)** Neural Architecture Search is a method that automates neural architecture engineering [8]. Early works [40, 2, 41] use reinforcement learning based on rewarding the model accuracy of the generated architecture. Alternative approaches [30, 24, 37] employ evolutionary algorithms to optimize both the neural architecture and its weights. These methods search for an adequate neural architecture in a large discrete space. Gradient-based NAS methods [4, 19, 39] of formulating operations in a differentiable search space are proposed to alleviate the scalability issues. They generally use the convex combination from a set of operations instead of determining a single operation. Most NAS approaches [19, 27, 40] adopt the complete DAG as a search space, to find the architecture in the various network topologies. However, DAG-based MTL frameworks have not been proposed, because of their considerably high computational demands.
**Multi-Task Learning (MTL)** Multi-task learning in deep neural networks can be categorized into hard and soft parameter sharing types [31]. Hard parameter sharing [13, 3, 14], also known as shared-bottom, is the most commonly used approach to MTL. This scheme improves generalization performance while reducing the computational cost of the network, by using shared hidden layers between all tasks. However, it typically struggles with the negative transfer problem [15, 36] which degrades performance due to improper sharing between less relevant tasks.
On the other hand, soft-parameter sharing [25, 32] alleviate the negative transfer problem by changing the shared parameter ratio. These approaches mitigate the negative transfer by flexibly modifying shared information, but they cannot maintain the computational advantage on the classic shared-bottom model. Recently, advanced approaches have been proposed to adjust shared parameters using a dynamic neural network [21, 22, 38, 29] and NAS [10].
**NAS-style MTL** MTL frameworks using a dynamic neural network (DNN) can be divided into two categories. One employs the Mixture-of-Experts (MoE) [33], which is designed for conditional computation of per-sample, to MTL by determining the experts of each task [21, 9, 22]. They have a fixed depth finalized task-specific sub-network, because they choose experts from a fixed number of modular layers. This causes a critical issue with task-balancing in the heterogeneous MTL. The other adopts the skip-or-select policy to select task-specific blocks from the set of residual blocks [38] or a shared block per layer [12, 29]. These methods only create a simple serial path in the finalized sub-network of each task, and a parallel link cannot be reproduced. Moreover, they heuristically address the unbalanced
Figure 1: **Graph representation of various neural networks. (a) Graph representation of existing dynamic neural network for multitask learning and ours. (b) Topologies of a completed Directed Acyclic Graph (DAG) and the output sub-graph of DAG structure.**
task-wise complexity issues in the heterogenous MTL (_e.g_. manually changing the balancing parameters based on the task complexity [29, 38]). Thus, none of the aforementioned works focus on finding the optimal task-specific structure in the MTL scenario.
## 3 Method
We describe our MTL framework, which searches for optimized network structures tailored to each task across diverse graph topologies, while limiting search time. Sec. 3.1 describes the composition of the searchable space of our central network and our flow-restriction method for efficiently balancing the topological diversity of task-specific sub-networks and searching space. Sec. 3.2 introduces our mechanism to determine the task-adaptive sub-network in the central network and describes the overall training process and loss function. The overall pipeline of our method is illustrated in Fig. 2.
### The Central Network with Diverse Topologies
Our central network composes a graph \(G=(V,E)\) with layers \(E\) in which the \(N\) hidden states \(V=\{v_{1},...,v_{N}\}\) are topologically sorted:
\[E=\{e_{ij}\}_{i,j\in\{1,...,N\}},\text{ where }i<j, \tag{1}\] \[e_{ij}(\,\cdot\,;\theta_{ij}):\mathbb{R}^{N^{v_{i}}}\to \mathbb{R}^{N^{v_{j}}}, \tag{2}\]
where \(e_{ij}\) is the operation that transfer the state \(v_{i}\) to \(v_{j}\) with the weight parameters \(\theta_{ij}\in\Theta\), and \(N^{v_{k}}\) is the number of the elements of hidden state \(v_{k}\), respectively. We adopt the DAG structure [19, 27, 40] for the network. However, the optimized structure from DAG is searched from \(2^{N(N-1)/2}\) network topologies, which are too large to be optimized in time. To address the issue while maintaining diversity, we propose a flow-restriction and read-in/read-out layers.
**Flow-restriction** The flow-restriction eliminates the low-importance long skip connection among network structures for each task by restricting \(j-i\leq M\) where \(M\) is the flow constant. Regulating the searchable edges in the graph reduces the required number of parameters and searching time from \(O(N^{2})\) to \(O(N)\), but it sacrifices the diversity and capacity of the network topologies.
To explain the topological diversity and task capacity of sub-networks, we define the three components of network topology, as follows:
1. \(\mathcal{D}(G)=\max(\{\text{Distance}(v_{i},v_{j})\}_{v_{i},v_{j}\in V}),\)
2. \(\mathcal{W}(G)=\max(\{\text{Out}_{v_{i}}\}_{v_{i}\in V}),\)
3. \(\mathcal{S}(G_{s},G)=|E_{s}|/|E|,\)
where \(\text{Out}_{v_{i}}\) is the out-degree of the vertex \(v_{i}\) and \(\text{Distance}(\cdot)\) is the operation that counts the number of layers (or edges) between two connected vertices. The network depth \(\mathcal{D}(G)\) is equal to the longest distance between two vertices in the graph \(G\). The network width \(\mathcal{W}(G)\) is equal to the maximum value of the out-degrees of hidden states in the graph \(G\). The sparsity \(\mathcal{S}(G_{s},G)\) of the sub-graph \(G_{s}\) is the ratio of finalized edges \(|E_{s}|\) over entire edges \(|E|\). The first two components are measurements of the topological diversity of the finalized sub-network, while the last one is for the sub-network capacity. While a complete DAG has the full range of depth and width components, the flow-restricted DAG has the properties of depth and width components as follows:
1. \(\min(\{\mathcal{D}(G_{s})\}_{G_{s}\subseteq G})=\lceil(|V|/M)\rceil,\)
2. \(\max(\{\mathcal{W}(G_{s})\}_{G_{s}\subseteq G})=M,\)
where \(\{G_{s}\}\) is the entire sub-graph of \(G\). The min-depth property (Prop. 1) can cause the over-parameterized problem when the capacity of the task is extremely low. The max-width property (Prop. 2) directly sacrifices the diversity of network topologies in the search space.
**Read-in/Read-out layers** We design read-in/read-out layers to mitigate these problems. The read-in layer embeds the input state \(v_{0}\) into all hidden states \(v_{i}\in V\) with task-specific weights \(\alpha_{i}^{k}\in\mathcal{A}\) for all \(K\) tasks \(\mathcal{T}=\{T_{k}\}_{k\in\{1,...,K\}}\) as follows:
\[v_{i}^{k}=\sigma(\alpha_{i}^{k})\cdot v_{0}, \tag{3}\]
where \(\sigma(\cdot)\) is the sigmoid function. Then, the central network sequentially updates the hidden state \(v_{1}^{k}\) to \(v_{N}^{k}\) with the task-specific weights \(\gamma_{ij}^{k}\in\Gamma\) that correspond to \(e_{ij}^{k}\):
\[v_{j}^{k}=\frac{1}{\text{In}_{v_{j}^{k}}}\sum_{e_{ij}\in E}(\sigma(\gamma_{ij} ^{k})\cdot e_{ij}(v_{i}^{k};\theta_{ij})), \tag{4}\]
where \(\text{In}_{v_{j}^{k}}\) is the in-degree of \(v_{j}^{k}\). Note that \(\Gamma\) is the adjacency matrix of graph \(G\). Finally, the read-out layer aggregates all hidden state features \(\{v_{i}^{k}\}_{i\in\{1,...,N\}}\) with the task-specific weights \(\beta_{i}^{k}\in\mathcal{B}\) and produces the last layer feature \(v_{L}^{k}\) for each task \(k\) as follows:
\[v_{L}^{k}=\sum_{i\in\{1,...,N\}}(\sigma(\beta_{i}^{k})\cdot v_{i}^{k}). \tag{5}\]
The final prediction \(\hat{\mathbf{y}}_{k}\) for each task \(T_{k}\) is computed by passing the aggregated features \(v_{L}^{k}\) through the task-specific head \(H^{k}(\cdot)\) as follows:
\[\hat{\mathbf{y}}^{k}=H^{k}(v_{L}^{k}). \tag{6}\]
All upper-level parameters \(\mathcal{A},\mathcal{B}\), and \(\Gamma\) are learnable parameters, and their learning process is described in Sec. 3.2. The read-in/read-out layers enable the optimized network to have a multi-input/output sub-network. The read-out layer
aggregates all hidden states of the central network during the search stage, allowing a specific task to use the early hidden states to output predictions while ignoring the last few layers. These early-exit structures help alleviate the over-parameterized problem in simple tasks.
### Network Optimization and Training Procedure
We describe the entire training process for our MTL framework, which consists of three stages, including warm-up, search, and fine-tuning stages.
**Warm-up stage** As with other gradient-based NAS, our framework has upper-level parameters that determine the network structure and parameters. This bilevel optimization with a complex objective function in an MTL setup makes the training process unstable. For better convergence, we initially train all network parameters across tasks for a few iterations. We train the weight parameters of the central network \(\Theta\) that shares all operations \(E\) across tasks. We fix all values of the upper-level parameters \(\mathcal{A},\mathcal{B}\), and \(\Gamma\) as \(0\), which becomes \(0.5\) after the sigmoid function \(\sigma(\cdot)\), and freeze them. We train the network parameters \(\Theta\) in Eq. 4 with a task loss as follows:
\[\mathcal{L}_{task}=\sum_{k=0}^{K}\mathcal{L}_{T_{k}}(\mathbf{\hat{y}}_{T_{k}},\mathbf{y}_{T_{k}}), \tag{7}\]
where \(\mathcal{L}_{T_{k}}\) is the task-specific loss, which is the unique loss function for each task.
**Search stage** After the warm-up stage, we unfreeze the upper-level parameters \(\mathcal{A},\mathcal{B}\), and \(\Gamma\) and search the network topologies appropriate to each task. We train all these parameters and network parameters \(\Theta\) simultaneously by minimizing the task loss and the proposed squeeze loss \(\mathcal{L}_{sq}\) as follows:
\[\mathcal{L}_{train}=\mathcal{L}_{task}+\lambda_{sq}\mathcal{L}_{sq}, \tag{8}\]
\[\mathcal{L}_{sq}=\sum_{k=0}^{K}(\max((\sum_{\gamma_{ij}\in\Gamma}(\sigma( \gamma_{ij}))-\kappa),0)), \tag{9}\]
where \(\lambda_{sq}\) is the balancing hyperparameter, and \(\kappa\) is a constant number called the budget, that directly reduces the sparsity of the central network. This auxiliary loss is designed to encourage the model to save computational resources.
**Fine-tuning stage** Lastly, we perform a fine-tuning stage to construct a compact and discretized network structure using the trained upper-level parameters \(\mathcal{A},\mathcal{B}\), and \(\Gamma\). To do so, we design a flow-based reduction algorithm that allows the network to obtain high computational speed by omitting low-importance operations, as described in Alg. 1. It measures the amount of information flow of each layer \(e_{ij}\) in the central network by calculating the ratio of edge weight with respect to other related edges weight. Then, it sequentially removes the edge which has the lowest information flow. Alg. 1 stops when the edge selected to be deleted is
Figure 2: **Overall pipeline. Our central network follows a DAG-based structure with read-in/out layers, and task-specific heads. The long skip connection is cut by our flow-restriction. Our framework with a 3-task MTL learning scenario consists of three stages including warm-up, search, and fine-tuning stages. The warm-up stage only learns the parameters of the main network \(\Theta\) and task-specific weights. The search stage learns the upper-level parameters \(\mathcal{A},\mathcal{B},\Gamma\), and task-specific weights. Then, flow-based reduction eliminates the low-importance edges from the network. The fine-tuning stage re-trains the network with the remaining important parameters.**
the only edge that can reach the graph. We use the simple Depth-first search algorithm to check the reachability of \(\hat{\Gamma}\) between hidden state \(v_{N_{\alpha}}\) to \(v_{N_{\beta}}\). All the output \(\hat{\mathcal{A}},\hat{\mathcal{B}},\hat{\Gamma}\) in Alg. 1, which is the discretized binary adjacency matrix, represent the truncated task-adaptive sub-network. After the reduction, we fix the upper-level parameters and only re-train the network parameters \(\Theta\), and we do not use the sigmoid function in Eq. 3-5
```
Input:\(\Gamma\in\mathbb{R}^{N\times N}\), \(\mathcal{A}\in\mathbb{R}^{N}\), \(\mathcal{B}\in\mathbb{R}^{N}\) Output:\(\hat{\Gamma},\hat{\mathcal{A}},\hat{\mathcal{B}}\)// Discretized params.
1 initialize zero matrix \(\Psi,\hat{\Psi}\in\mathbb{R}^{(N+2)\times(N+2)}\)
2\(N_{\alpha}=\operatorname*{argmax}(\mathcal{A})\)
3\(N_{\beta}=\max(N_{\alpha}+1,\operatorname*{argmax}(\mathcal{B}))\)
4\(\Gamma[:N_{\alpha},:]\gets 0\)//removeedges\(<\)\(N_{\alpha}\)
5\(\Gamma[:,N_{\beta}:]\gets 0\)//removeedges\(>\)\(N_{\beta}\)
6\(\Psi[1:N,1:N]\leftarrow\Gamma\)//merge\(\Gamma,\mathcal{A},\mathcal{B}\)into\(\Psi\)
7\(\Psi[0,N_{\alpha}+1:N_{\beta}+1]\leftarrow\mathcal{A}[N_{\alpha}:N_{\beta}]\)
8\(\Psi[N_{\alpha}+1:N_{\beta}+1,N+1]\leftarrow\mathcal{B}[N_{\alpha}:N_{\beta}]\)
9whileTruedo
10 initialize zero matrix \(S\in\mathbb{R}^{(N+2)\times(N+2)}\)
11for\(i\gets 0\)to\(\{N+1\}\)do
12for\(j\gets 0\)to\(\{N+1\}\)do
13\(S[i,j]\gets\psi_{ij}\big{(}\frac{1}{\operatorname*{ln}_{v_{i}}}\sum_{ \psi_{ki}\in\Psi}(\psi_{ki})/\sum_{\psi_{ki}\in\Psi}(\psi_{ik})+\frac{1}{ \operatorname*{Out}_{j_{j}}}\sum_{\psi_{jk}\in\Psi}(\psi_{jk})/\sum_{\psi_{kj} \in\Psi}(\psi_{kj})\big{)}\)
14\(\psi_{ij}\gets 0\), where \(S[i,j]\) is nonzero min value
15ifgraph builded from \(\Psi\) is reachablethen
16\(\hat{\Psi}\leftarrow\Psi\)
17
18else
19\(\hat{\Psi}[\hat{\Psi}>0]\gets 1\)//discretization
20\(\hat{\Gamma}\leftarrow\hat{\Psi}[1:N,1:N]\)//splitinto\(\Gamma,\mathcal{A},\mathcal{B}\)
21\(\hat{\mathcal{A}}\leftarrow\hat{\Psi}[0,1:N]\)
22\(\hat{\mathcal{B}}\leftarrow\hat{\Psi}[1:N,N+1]\)
23return\(\hat{\Gamma},\hat{\mathcal{A}},\hat{\mathcal{B}}\)
```
**Algorithm 1**Flow-based Reduction
## 4 Experiments
We first describe the experimental setup in Sec. 4.1. We compare our method to state-of-the-art MTL frameworks on various benchmark datasets for MTL in Sec. 4.2. We also conduct extensive experiments and ablation studies to validate our proposed method in Sec. 4.3-4.5.
### Experimental Settings
**Dataset** We use four public datasets for multi-task scenarios including Omniglot [17], NYU-v2 [34], Cityscapes [7], and PASCAL-Context [26]. We use these datasets, configured by previous MTL works [29, 38], not their original sources.
* **Omniglot** Omniglot is a classification dataset consisting of 50 different alphabets, and each of them consists of a number of characters with 20 handwritten images per character.
* **NYU-v2** NYU-v2 comprises images of indoor scenes, fully labeled for joint semantic segmentation, depth estimation, and surface normal estimation.
* **Cityscapes** Cityscapes dataset collected from urban driving scenes in European cities consists of two tasks: joint semantic segmentation and depth estimation.
* **PASCAL-Context** PASCAL-Context datasets contain PASCAL VOC 2010 [34] with semantic segmentation, human parts segmentation, and saliency maps, as well as additional annotations for surface normals and edge maps.
**Competitive methods** We compare the proposed framework with state-of-the-art methods [1, 11, 12, 18, 20, 22, 23, 25, 28, 29, 32, 38] and various baselines including a single task and a shared-bottom. The single-task baseline trains each task independently using a task-specific encoder and task-specific head for each task. The shared-bottom baseline trains multiple tasks simultaneously with a shared encoder and separated task-specific heads.
We compare our method with MoE-based approaches, including Soft Ordering [23], Routing [28], and Gumbel-Matrix [22], as well as a NAS approach [18] on Omniglot datasets. CMTR [18] can modify parameter count, similar to our method. We compare our method with other soft-parameter sharing methods including Cross-Stitch [25], Sluice network [32], and NDDR-CNN [11] and the dynamic neural network (DNN)-based methods including MTAN [20], DEN [1], and Adashare [38] for the other three datasets. We provide the evaluation results of two recent works, LTB [12] and PHN [29] for PASCAL-Context datasets because only the results are reported in their papers, but no source codes are provided.
**Multi-task scenarios** We set up multi-task scenarios with the combination of several tasks out of a total of seven tasks, including classification \(\mathcal{T}_{cls}\), semantic segmentation \(\mathcal{T}_{sem}\), depth estimation \(\mathcal{T}_{dep}\), surface normal prediction \(\mathcal{T}_{norm}\), human-part segmentation \(\mathcal{T}_{part}\), saliency detection \(\mathcal{T}_{sal}\), and edge detection \(\mathcal{T}_{edge}\). We follow the MTL setup in [38] for three datasets including Omniglot, NYU-v2, and cityscapes, and [29] for PASCAL-Context. We simulate a homogeneous MTL scenario of a 20-way classification task in a multi-task setup using Omniglot datasets by following [23]. Each task predicts a class of characters in a single alphabet set. We use the other three datasets for heterogeneous MTL. We set three tasks including segmentation, depth estimation, and normal estimation for NYU-v2 and two with segmentation, depth estimation for Cityscapes.
We set five tasks \(\mathcal{T}_{sem}\), \(\mathcal{T}_{part}\), \(\mathcal{T}_{norm}\), \(\mathcal{T}_{sal}\), and \(\mathcal{T}_{edge}\) as used in [29] for PASCAL-Context datasets.
**Evaluation metrics** We follow the common evaluation metrics utilized in the competitive methods. We use an accuracy metric for the classification task. The semantic segmentation task is measured by mean Intersection over Union (mIoU) and pixel accuracy. We use the mean absolute and mean relative errors, and relative difference as the percentage of \(\delta=\max(\hat{\mathbf{d}}/\mathbf{d},\mathbf{d}/\hat{\mathbf{d}})\) within thresholds \(1.25^{\{1,2,3\}}\) for the depth estimation task. For the evaluation of the PASCAL-Context datasets, we follow the same metrics used in [29] for all tasks. As reported in [38], we report a single relative performance \(\Delta_{\mathcal{T}_{i}}\) in Tab. 1-4 for each task \(\mathcal{T}_{i}\) with respect to the single-task baseline, which defined as:
\[\Delta_{\mathcal{T}_{i}}=\frac{100}{|\mathcal{M}|}\sum_{j=0}^{|\mathcal{M}|}( -1)^{l_{j}}\frac{(\mathcal{M}_{\mathcal{T}_{i},j}-\mathcal{M}_{\mathcal{T}_{i},j}^{single})}{\mathcal{M}_{\mathcal{T}_{i},j}^{single}}, \tag{10}\]
where \(\mathcal{M}_{\mathcal{T}_{i},j}\) and \(\mathcal{M}_{\mathcal{T}_{i},j}^{single}\) are the \(j\)-th metric of \(i\)-th task \(\mathcal{T}_{i}\) from each method and the single task baseline, respectively. The constant \(l_{j}\) is 1 if a lower value represents better for the metric \(\mathcal{M}_{\mathcal{T}_{i},j}\) and 0 otherwise. The averaged relative performance for all tasks \(\mathcal{T}\) is defined as:
\[\Delta_{\mathcal{T}}=\frac{1}{|\mathcal{T}|}\sum_{i=1}^{|\mathcal{T}|}\Delta_ {\mathcal{T}_{i}}. \tag{11}\]
The absolute task performance for all metrics is reported in the supplementary material.
**Network and training details** For our central network, we set 8 hidden states, the same as the existing MoE-based works [22, 28] and use the same classification head for Omniglot datasets. We set 12 hidden states, the same as the VGG-16 [35], except for the max-pooled state, and use the Deeplab-v2 [5] decoder structure as all task heads for all the other datasets, respectively. We use the Adam [16] optimizer to update both upper-level parameters and network parameters. We use cross-entropy loss for semantic segmentation and L2 loss for the other tasks. For a fair comparison, we train our central network from scratch without pre-training for all experiments. We describe more details on the network structure and hyperparameter settings in the supplementary material.
model outperforms AdaShare [38] for both the NYU-v2 and Cityscapes datasets, while keeping almost the same number of parameters (NYU-v2: 1.00 vs. 1.04 and Cityscapes 1.00 vs. 0.96). With the flow constant \(M=7,9\), our method outperforms all the baselines by a large margin. The results from the PASCAL-Context datasets in Tab. 4 show that all baselines suffer from negative transfer in several tasks, as the number of tasks increases. Only Adashare and Cross Stitch slightly outperform the single-task baseline (see the performance \(\Delta_{\mathcal{T}}\)). On the other hand, ours with \(M=9\) achieves the best performance without any negative transfers for all tasks.
Interestingly, the required parameters of the search space increase almost in proportion to the increase of the flow constant, but there is no significant difference in the number of parameters of the finalized networks. For example, the required number of parameters for the network with the flow constant \(M=3,5,7\) is 2.77, 4.23, and 5.38, respectively. This demonstrates that the proposed flow-based reduction algorithm is effective in removing low-relative parameters while maintaining performance. Specifically, we observe that the total performance of our framework with \(M=7\) is slightly better than the \(M=9\) setup in Tab. 2 despite its smaller architecture search space. To investigate this, we further analyze the tendency in performance and computational complexity with respect to the flow constant in Sec. 4.4.
### Analysis of Topologies and Task Correlation
To demonstrate the effectiveness of the proposed learning mechanism, we visualize our finalized sub-network topologies in Fig. 3-(a-c) and the adjacency matrix for NYU-v2 3-task learning in Fig. 3-(d). We also analyze the diversity and capacity of task-adaptive network topologies in Tab. 5 with network depth \(\mathcal{D}\), width \(\mathcal{W}\), and sparsity \(\mathcal{S}\) described in Sec. 3.1. These analyses provide three key observations on our task-adaptive network and the correlation among tasks.
First, _the tasks of segmentation and surface normal hardly share network parameters_. Various task-sharing patterns are configured at the edge, but there is only one sharing layer between the two tasks. This experiment shows a low relationship between tasks, as it is widely known that the proportion of shared parameters between tasks indicates task correlation [22, 29, 38].
Second, _long skip connections are mostly lost_. The length of the longest skip connection in the finalized network is 5, and the number of these connections is 2 out of 18 layers, even with the flow constant of 7. This phenomenon is observed not only in NYU-v2 datasets but also in the other MTL datasets. This can be evidence that the proposed flow-restriction reduces search time while maintaining high performance even by eliminating the long skip connection in the DAG-based central network.
Lastly, _Depth estimation task requires more network resources than segmentation and surface normal estimation tasks_. We analyze the network topologies of the finalized sub-network of each task in NYU-v2 datasets using three components defined in Sec. 3. The depth \(\mathcal{D}\) and width \(\mathcal{W}\) of the sub-network increase in the order of semantic segmentation, surface normal prediction, and depth estimation tasks. Likewise, the sparsity \(\mathcal{S}\) of the depth network is the highest. This experiment shows that the depth network is the task that requires the most network resources.
### Performance w.r.t. Flow-restriction
We analyze performance and computational complexity with respect to the flow constant \(M\) for the NYU-v2 and Cityscapes datasets. We report the rate of performance degradation with respect to the complete DAG search space in Fig. 4. We observe that the reduction rate of the final performance does not exceed 3% even with considerably lower flow constants. The performance is saturated at a flow constant of about 7 or more. This means that the proposed method optimizes the task adaptive sub-network regardless of the size of the network search space, if it satisfies the minimum required size.
Figure 3: **Graph Representation of Task-adaptive Sub-network** The finalized sub-network topologies (\(M=7\)) trained with NYU-v2 datasets is illustrated as graph. (a-c) The task-adaptive sub-network of semantic segmentation, depth estimation, and surface normal, respectively. (d) The adjacency matrix where color represents the discretized value for the activated edge of each task.
\begin{table}
\begin{tabular}{c|c c c} \hline \hline Task & \(\mathcal{D}\) & \(\mathcal{W}\) & \(\mathcal{S}\) \\ \hline Semantic Seg. & 5 & 3 & 0.103 \\ Depth & 7 & 3 & 0.192 \\ Surface normal & 7 & 2 & 0.128 \\ \hline \hline \end{tabular}
\end{table}
Table 5: Topologies analysis on **NYU-v2 datasets**.
To demonstrate the effectiveness of our flow-based reduction (FBR) algorithm, we compare it to two other reduction algorithms (random and threshold) for Cityscapes datasets in Fig. 5. The random reduction literally removes the edges randomly, and the thresholding method sequentially removes the edge which has the lowest value in the adjacency matrix \(\Gamma\). We measure the rate of performance degradation of the pruned network of each reduction algorithm with respect to the non-reduced network while changing the sparsity \(\mathcal{S}\). Note that our method automatically determines the sparsity, so for this experiment only, we add a termination condition that stops the network search when a certain sparsity is met. The results show that the proposed flow-reduction method retains performance even with a low sparsity rate. This means that our method efficiently prunes the low-related edge of the network compared to the other methods.
### Ablation Study on Proposed Modules
We conduct ablation studies on the four key components of our framework; the flow-restriction, read-in/out layers, flow-based reduction, and squeeze loss. We report the relative task performance and the number of parameters of the finalized network with/without the components in Tab. 6. The results show that our framework, including all components, achieves the lowest number of parameters and the second-best performance. Our method without flow-based reduction achieves the best performance. However, the finalized network from this setup has about a five-times larger number of parameters than ours because the network has never been pruned in a training process. This demonstrates that our restricted DAG-based central network is optimized to build compact task-adaptive sub-networks with performance close to the optimized sub-network from a complete DAG-based network.
## 5 Conclusions
In this paper, we present a new MTL framework to search for task-adaptive network structures across diverse network topologies in a single network. We propose flow restriction to solve the scalability issue in a complete DAG search space while maintaining the diverse network topological representation of the DAG search space by adopting read-in/out layers. We also introduce a flow-based reduction algorithm that prunes the network efficiently while maintaining overall task performance and squeeze loss, limiting the upper bound on the number of network parameters. The extensive experiments demonstrate that the sub-module and schemes of our framework efficiently improve both the performance and compactness of the network. Our method compactly constructs various task-specific sub-networks in a single network and achieves the best performance among all the competitive methods on four MTL benchmark datasets.
## Acknowledgement
This work was supported by the National Research Foundation of Korea (NRF) grant funded by the Korea government (MSIT) (No. RS-2023-00210908).
\begin{table}
\begin{tabular}{c|c c c|c|c} \hline \hline Method & \(\Delta\tau_{rms}\uparrow\) & \(\Delta\tau_{rms}\uparrow\) & \(\Delta\tau_{rms}\uparrow\) & \(\Delta\tau\) & \# of Param \(\downarrow\) \\ \hline Ours (M=7) & +13.4 & **+9.2** & +10.7 & +11.1 & **1.31** \\ \hline w/o flow-restriction & +13.2 & **+9.2** & +10.4 & +11.0 & 1.80 \\ w/o read-in/out & +11.7 & +8.3 & +10.4 & +10.1 & 1.43 \\ w/o flow-based reduction & **+14.2** & **+9.2** & **+11.1** & **+11.5** & 6.50 \\ w/o \(\mathcal{L}_{\text{avg}}\) & +13.2 & +8.8 & +10.7 & +10.9 & 1.38 \\ \hline \hline \end{tabular}
\end{table}
Table 6: **Ablation study on the proposed modules (NYU-v2).**
Figure 4: **Model performance with respect to the proposed flow-restriction.** We plot the degradation ratio of the performance (left y-axis) and parameter (right y-axis) by changing the flow constant \(M\). We measure the final averaged task performance with NYU-v2 and Cityscapes datasets marked by purple and pink circle markers, respectively. We also measure the number of parameters marked by gray square markers.
Figure 5: **Model Performance with respect to the network sparsity.** We plot the performance degradation rate by changing network sparsity. We compare our flow-based reduction algorithm to two other schemes; random selection and thresholding. |
2303.11480 | Inferring ocean transport statistics with probabilistic neural networks | Using a probabilistic neural network and Lagrangian observations from the
Global Drifter Program, we model the single particle transition probability
density function (pdf) of ocean surface drifters. The transition pdf is
represented by a Gaussian mixture whose parameters (weights, means and
covariances) are continuous functions of latitude and longitude determined to
maximise the likelihood of observed drifter trajectories. This provides a
comprehensive description of drifter dynamics allowing for the simulation of
drifter trajectories and the estimation of a wealth of dynamical statistics
without the need to revisit the raw data. As examples, we compute global
estimates of mean displacements over four days and lateral diffusivity. We use
a probabilistic scoring rule to compare our model to commonly used transition
matrix models. Our model outperforms others globally and in three specific
regions. A drifter release experiment simulated using our model shows the
emergence of concentrated clusters in the subtropical gyres, in agreement with
previous studies on the formation of garbage patches. An advantage of the
neural network model is that it provides a continuous-in-space representation
and avoids the need to discretise space, overcoming the challenges of dealing
with nonuniform data. Our approach, which embraces data-driven probabilistic
modelling, is applicable to many other problems in fluid dynamics and
oceanography. | Martin T. Brolly | 2023-03-20T22:20:15Z | http://arxiv.org/abs/2303.11480v2 | # Inferring ocean transport statistics with probabilistic neural networks
###### Abstract
Using a probabilistic neural network and Lagrangian observations from the Global Drifter Program, we model the single particle transition probability density function (pdf) of ocean surface drifters. The transition pdf is represented by a Gaussian mixture whose parameters (weights, means and covariances) are continuous functions of latitude and longitude determined to maximise the likelihood of observed drifter trajectories. This provides a comprehensive description of drifter dynamics allowing for the simulation of drifter trajectories and the estimation of a wealth of dynamical statistics without the need to revisit the raw data. As examples, we compute global estimates of mean displacements over four days and lateral diffusivity. We use a probabilistic scoring rule to compare our model to commonly used transition matrix models. Our model outperforms others globally and in three specific regions. A drifter release experiment simulated using our model shows the emergence of concentrated clusters in the subtropical gyres, in agreement with previous studies on the formation of garbage patches. An advantage of the neural network model is that it provides a continuous-in-space representation and avoids the need to discretise space, overcoming the challenges of dealing with nonuniform data. Our approach, which embraces data-driven probabilistic modelling, is applicable to many other problems in fluid dynamics and oceanography.
## 1 Introduction
The motion of turbulent fluids can be characterised usefully by dynamical statistics such as dispersion, energy spectra and velocity structure functions (e.g., Batchelor 1953, Monin & Yaglom 1971). In oceanography much effort has been directed towards inferring such statistics from observations (e.g., LaCasce 2008, van Sebille et al. 2018). In many cases, these inference tasks can be related to problems in conditional probability density estimation. For example, estimating single-particle dispersion is related to estimating the conditional density
\[p\left(\mathbf{X}(t+\tau)-\mathbf{X}(t)\mid\mathbf{X}(t),\,t,\,\tau\right), \tag{1}\]
where \(\mathbf{X}(t)\) is the position of a particle at time \(t\), in that the dispersion is the variance of this distribution. Similarly, the velocity structure functions are moments of the conditional
density
\[p\left(\mathbf{u}(\mathbf{x}_{1},\,t)-\mathbf{u}(\mathbf{x}_{2},\,t)\mid\mathbf{x}_{1},\, \mathbf{x}_{2},\,t\right), \tag{2}\]
where \(\mathbf{u}(\mathbf{x},\,t)\) is the fluid velocity at position \(\mathbf{x}\). By estimating full conditional densities like (1) and (2), it is possible to estimate simultaneously a number of related statistics. For instance, (1) describes entirely the single-particle displacement statistics, while (2) encodes velocity structure functions of all orders, providing two-point Eulerian velocity statistics. It is no surprise, then, that estimating these conditional densities accurately is a nontrivial task.
In this work we consider a particular tool for conditional density estimation, the mixture density network (MDN) (Bishop, 1994), and test its performance in learning fluid statistics from observations. MDNs are machine learning models, which combine artificial neural networks with probabilistic mixture models to represent conditional densities (Bishop, 2006). Their use has increased rapidly in recent years with applications in a variety of fields for a range of reduced order modelling and emulation tasks, including surrogate modelling of fluid flow (Maulik et al., 2020), parameterisation of subgrid momentum forcing in ocean models (Guillaumin and Zanna, 2021), emulation of complex stochastic models in epidemiology (Davis et al., 2020) and multi-scale models of chemical reaction networks (Bortolussi and Palmieri, 2018), and subgrid scale closures in large eddy simulations of turbulent combustion (Shin et al., 2021).
We focus on learning the single-particle transition density (1) in the ocean near-surface using Lagrangian trajectory data collected as part of the Global Drifter Program (Lumpkin and Centurioni, 2019). A model of the transition density provides, at every point in the ocean, a probabilistic forecast for drifter displacements from that location. We show that the MDN model outperforms existing stochastic models of drifter dynamics based on Ulam's method (Ulam, 1960; Froyland, 2001), as well as another simple benchmark model, and eliminates the difficulty of designing appropriate discretisations of space needed for such models.
From the transition density it is possible to derive estimates of a range of single-particle statistics. As examples, we provide maps of the mean displacement over four days as a function of initial position \(\mathbf{X}_{0}\), as well as the lateral diffusivity. The transition density produces highly non-Gaussian statistics in some regions. By calculating the Kullback-Leibler divergence between our full model and a simplified Gaussian model, we quantify and map non-Gaussianity in drifter displacements.
The MDN model also provides the basis for a discrete-time Markov process model of drifter dynamics, offering a continuous space alternative to Markov chain models which have been used in numerous studies (Maximenko et al., 2012; van Sebille et al., 2012; Miron et al., 2017, 2021). We perform a global simulation of drifters for a period of ten years with initial positions given on a uniform grid, and reproduce the 'garbage patches' in subtropical gyres seen in previous studies.
The article is structured as follows. In SS2 we discuss conditional density estimation and the estimation of conditional statistics. In SS3 we introduce MDNs. In SS4 we describe the MDN model of the single-particle transition density from drifter observations. We compare its performance with alternative models, present derived single-particle statistics and simulate the clustering of drifters in subtropical gyres. In SS5 we conclude and suggest further problems where MDNs may be a useful tool.
Conditional modelling
While the aim of regression is to model \(\mathbb{E}[\mathbf{Y}\mid\mathbf{X}]\), where \(\mathbf{X}\) and \(\mathbf{Y}\) are random variables, conditional modelling (or conditional density estimation, CDE) is the task of inferring the full conditional probability density \(p(\mathbf{Y}\mid\mathbf{X})\)1. By modelling conditional densities, rather than just conditional means, we incorporate information about the variability of \(\mathbf{Y}\mid\mathbf{X}\); more than this, conditional models can capture skewness, excess kurtosis and multimodality. This comprehensive description of conditional statistics is valuable in applications where single point-estimates are insufficient due to inherent variability, and where there is interest in non-Gaussian statistics, including those associated with rare events. Conditional models can be used in two ways: (i) as stochastic surrogate models (or emulators), and (ii) as a tool for estimating conditional statistics.
Footnote 1: We restrict attention to the case of continuous random variables.
Parametric conditional models (such as MDNs) assume that, for each possible value of \(\mathbf{X}\), the distribution of \(\mathbf{Y}\mid\mathbf{X}\) belongs to a certain family of parametric distributions, i.e.
\[p(\mathbf{Y}\mid\mathbf{X})=\rho(\mathbf{Y}\,;\,\mathbf{\theta}(\mathbf{X})), \tag{3}\]
where \(\rho(\,\cdot\,;\,\mathbf{\theta})\) is the probability density corresponding to a family of distributions parameterised by \(\mathbf{\theta}\). In this case, not only must the form of \(\rho\) be chosen, but the dependence on the conditioned variable must also be modelled by some representation of \(\mathbf{\theta}(\mathbf{X})\).
### Estimating conditional statistics
Given data \(\{\mathbf{X}_{i},\mathbf{Y}_{i}\}\), a standard approach to estimating conditional statistics \(\mathbb{E}[\mathbf{f}(\mathbf{Y})\mid\mathbf{X}]\) is to first discretise (or 'bin') in \(\mathbf{X}\) and produce local estimates \(\mathbb{E}[\overline{\mathbf{f}(\mathbf{Y})}](\tilde{\mathbf{X}})\) for each value of the discretised variable \(\tilde{\mathbf{X}}\), typically by Monte Carlo estimation, such that
\[\mathbb{E}[\overline{\mathbf{f}(\mathbf{Y})}](\tilde{\mathbf{X}}):=\frac{\sum_{i}\mathbf{f}( \mathbf{Y}_{i})\,\,\mathbb{I}_{B}(\mathbf{X}_{i})}{\sum_{i}\,\mathbb{I}_{B}(\mathbf{X}_{i })}, \tag{4}\]
where \(\mathbb{I}_{B}\) is the indicator function of \(B\), the set of values of \(\mathbf{X}\) whose discretised value is \(\tilde{\mathbf{X}}\). For estimates (4) to be useful, one must design a suitable discretisation of the domain of \(\mathbf{X}\), which balances the need to choose a fine enough discretisation to resolve details in \(\mathbf{X}\) with the need to take sufficiently large bins to have enough data for these estimates to have reasonably small variance. This can be especially challenging when data is sparse, or when the density of data is highly inhomogeneous.
Conditional modelling offers an alternative approach wherein one first constructs a model of the conditional density, as in (3), that is continuous in both \(\mathbf{X}\) and \(\mathbf{Y}\), then computes estimates
\[\mathbb{E}_{\mathcal{M}}[\mathbf{f}(\mathbf{Y})\mid\mathbf{X}]:=\int\mathbf{f}(\mathbf{Y})\,\, \rho(\mathbf{Y}\,;\,\mathbf{\theta}(\mathbf{X}))\,\mathrm{d}\mathbf{Y} \tag{5}\]
for as many statistics as desired at any value of \(\mathbf{X}\) in the domain, without the need to revisit the raw data. In some cases the expectations \(\mathbb{E}_{\mathcal{M}}\) can be calculated using a closed-form expression. Where no such expression is known, the expectation can be computed by numerical integration or a Monte Carlo method. Since these calculations rely only on evaluating the modelled conditional density, or sampling from it, they are not limited by sparsity of data. Also, for a given \(\mathbf{X}^{*}\), estimates of the form (4) are informed only by observations in the same
bin as \(\mathbf{X}^{*}\), whereas in a conditional model, all observations are used to fit \(\rho(\mathbf{Y}\,;\,\mathbf{\theta}(\mathbf{X}^{*}))\). The schematic in figure 1 contrasts the standard approach and the conditional modelling approaches.
## 3 Mixture density networks
A mixture density network (Bishop 1994, 2006) is a conditional model where an artificial neural network is employed to represent the function \(\mathbf{\theta}(\mathbf{X})\) in (3) and the parametric form \(\rho(\,\cdot\,;\,\mathbf{\theta})\) corresponds to a mixture distribution. The density of a general mixture distribution is
\[\rho(\,\cdot\,;\,\,\mathbf{\theta})=\sum_{i=1}^{N_{\mathrm{c}}}\alpha_{i}\ \rho_{i}(\,\cdot\,;\,\,\mathbf{\theta}_{i}), \tag{6}\]
where \(N_{\mathrm{c}}\) is the number of components in the mixture, the \(i^{\mathrm{th}}\) component has density \(\rho_{i}(\,\cdot\,;\,\,\mathbf{\theta}_{i})\) with parameters \(\mathbf{\theta}_{i}\), \(\mathbf{\theta}=[(\alpha_{1},\ \mathbf{\theta}_{1}),\ \cdots,\ (\alpha_{N_{\mathrm{c}}},\ \mathbf{\theta}_{N_{\mathrm{c}}})]\) and the \(\alpha_{i}\) are component weights subject to the constraint
\[\sum_{i=1}^{N_{\mathrm{c}}}\alpha_{i}=1. \tag{7}\]
Commonly, the component densities \(\rho_{i}\) are chosen from the same family and, in particular, Gaussian, but components can be chosen differently. In the Gaussian case, the \(\mathbf{\theta}_{i}\) are conditional means and covariances.
The neural network representation of \(\mathbf{\theta}(\,\cdot\,)\) is itself parametric with parameters \(\mathbf{w}\); hence, MDNs model \(p(\mathbf{Y}\,\mid\,\mathbf{X})\) with \(\rho(\mathbf{Y}\,;\,\mathbf{\theta}(\mathbf{X}\,;\,\mathbf{w}))\). The network can have any architecture,
Figure 1: Estimating conditional statistics by a standard approach versus by first constructing a model for the conditional density.
but that of a multilayer perceptron (Rumelhart et al., 1985) (also known as a fully connected multilayer feedforward neural network) with nonlinear activation functions is common -- in this case \(\mathbf{w}\) consists of the weights and biases.
A natural loss function for conditional models, which quantifies how well they fit data, is the negative (conditional) log likelihood of observations \(\mathcal{D}=\{\mathbf{X}_{i},\mathbf{Y}_{i}\}\) under the model. In MDNs this is
\[\mathcal{L}(\mathbf{w}\,;\,\mathcal{D})=\sum_{i}-\log\rho\left(\mathbf{Y}_{i}\,;\,\bm {\theta}(\mathbf{X}_{i}\,;\,\mathbf{w})\right). \tag{8}\]
Training an MDN then amounts to finding optimal values for the neural network's parameters
\[\mathbf{w}^{*}=\operatorname*{arg\,min}_{\mathbf{w}}\;\mathcal{L}(\mathbf{w}\,;\,\mathcal{ D}). \tag{9}\]
Minimising the negative log likelihood is equivalent to maximising the log likelihood of training data, also referred to as the log score in probabilistic forecasting (Bernardo, 1979; Gneiting and Raftery, 2007; Brocker and Smith, 2007). Maximum likelihood estimation in this context differs from the more familiar setting of fitting an unconditional model for \(p(\mathbf{Y})\) given observed data \(\{\mathbf{Y}_{i}\}\) -- here, there is generically only one observed value of \(\mathbf{Y}\mid\mathbf{X}\) corresponding to each observed value of \(\mathbf{X}\), and for most values of \(\mathbf{X}\) there are no observations at all. It is clear, then, that, for each value of \(\mathbf{X}\), we are certainly not in the large-data regime that would allow one to invoke asymptotic properties of maximum likelihood estimates. The quality of parametric conditional models (3) depends critically on how well \(\mathbf{\theta}(\mathbf{X}\,;\,\mathbf{w}^{*})\) represents how the distribution of \(\mathbf{Y}\mid\mathbf{X}\) varies with \(\mathbf{X}\). In particular, since MDNs employ a neural network to model \(\mathbf{\theta}(\mathbf{X})\), and neural networks are highly flexible models, it is common for MDNs to exhibit poor generalisation unless regularisation techniques are used. In the following section we employ a widely used regularisation technique known as early stopping (see e.g. Prechelt (2012)), wherein a small proportion of training data (referred to as the test set) are not used to inform steps in the optimisation scheme, but are instead used to track the evolution of an estimate of the model's generalisation error (the value of the loss function evaluated on data outside the training set). The guiding heuristic is that it is typical for the generalisation error of neural networks to reach a minimum as training progresses before increasing due to overfitting -- early stopping is a strategy where one terminates model training when the generalisation error is believed to have reached this minimum. Details of our implementation are given in the following section.
## 4 Application to single-particle statistics of the ocean near-surface
In this section we present an MDN model of the single-particle transition density (1) of ocean surface drifting buoys (drifters). The model's parameters are inferred from trajectory data collected as part of the Global Drifter Program (Lumpkin and Centurioni, 2019).
### Data
We use the Global Drifter Program quality-controlled 6-hour interpolated dataset, which includes positions (latitude and longitude) and sea-surface temperatures. Drifter velocity estimates are also provided, though these are obtained by simple finite-differencing of position
in time and subject to error. The raw measurements are treated according to the procedure of Hansen & Poulain (1996), which involves the removal of suspected spurious values and interpolation to regular 6-hour intervals. The interpolation method, which is a form of kriging (Hansen & Herman 1989), assumes contamination by an uncorrelated zero-mean noise and makes assumptions about the structure functions of the discretised position process. We leave as a caveat to our results that this preprocessing of the data could be questioned and proceed taking the interpolated data as our ground-truth. Only position observations are used in our modelling. Figure 2 shows how many observed displacements are recorded per squared kilometre in each \(1^{\circ}\) latitude \(\times 1^{\circ}\) longitude square. These data were recorded between 1989 and 2021 and include a total of 23893 drriter trajectories. We split the data in two parts, by selecting approximately half (11946) of the drriter trajectories at random to use for creating the model and set the remaining data aside for validation. The overall dataset contains over 18 million observations of 6-hour displacements.
In section 4.3 we perform a model comparison. Skill scores are computed for the full training and validation datasets with global coverage, as well as for three restricted regions, labelled \(A\), \(B\), and \(C\), shown in figure 3, having extents \(20-50^{\circ}\) W, \(30-50^{\circ}\) N; \(145-175^{\circ}\) E, \(20-40^{\circ}\) N; and \(110-130^{\circ}\) W, \(10^{\circ}\) S-\(10^{\circ}\) N.
### Model
The transition density is not modelled in the most general form. Instead, we (i) consider, at first, a fixed value of the time-lag \(\tau\), so that the transition density may be written
\[p(\mathbf{X}_{n+1}\mid\mathbf{X}_{n}), \tag{10}\]
where \(\mathbf{X}_{n}=\mathbf{X}(t_{0}+n\tau)\), and (ii) assume the process \(\mathbf{X}(t)\) is time-homogeneous, such that (1) is independent of the initial time \(t\), (10) is independent of \(n\) and
\[p(\Delta\mathbf{X}\mid\mathbf{X}_{0}) \tag{11}\]
Figure 2: Count of drriter observations per squared kilometre.
\(\Delta\mathbf{X}\) is the displacement of a drifter from its position at the previous timestep, denoted \(\mathbf{X}_{0}\). By assuming time-homogeneity we neglect the effects of seasonality and low-frequency variability in ocean dynamics. If, additionally, an assumption of Markovianity is made, then (10) is enough to construct a discrete-time Markov process model (\(\mathbf{X}_{n}\)) for drifter position (Pavliotis, 2014). For a Markov assumption to be accurate, the discretisation timescale \(\tau\) must be chosen appropriately. We choose a timescale of 4 days on the basis that the Lagrangian velocity decorrelation time (or integral timescale) at the surface was previously estimated from drifters to be approximately 2-3 days in all four ocean basins (Rupolo, 2007).
We model (11) using an MDN \(-\) see the schematic in figure 4. The model takes as input \(\mathbf{X}_{0}\), given in longitude-latitude coordinates, and its output is a Gaussian mixture distribution with \(N_{c}=32\) mixture components modelling \(\Delta\mathbf{X}\mid\mathbf{X}_{0}\), also in degrees of longitude and latitude from \(\mathbf{X}_{0}\). The neural network part of the model thus encodes
\[\mathbf{\theta}(\cdot)=\left\{\alpha_{i}(\cdot),\ \mathbf{\mu}_{i}(\cdot),\ \mathbf{C}_{i}( \cdot)\right\}_{i=1}^{N_{c}} \tag{12}\]
such that
\[\begin{split}\dot{p}(\Delta\mathbf{X}\mid\mathbf{X}_{0})=\sum_{i=1}^{N_{ c}}\alpha_{i}(\mathbf{X}_{0})\det\left(2\pi\mathbf{C}_{i}\left(\mathbf{X}_{0}\right) \right)^{-\frac{1}{2}}\\ \times\exp\left[-\frac{1}{2}\left(\Delta\mathbf{X}-\mathbf{\mu}_{i} \left(\mathbf{X}_{0}\right)\right)^{\mathrm{T}}\mathbf{C}_{i}^{-1}\left(\mathbf{X}_{0} \right)\ \left(\Delta\mathbf{X}-\mathbf{\mu}_{i}\left(\mathbf{X}_{0}\right)\right)\right],\end{split} \tag{13}\]
where \(\mathbf{\mu}_{i}\) and \(\mathbf{C}_{i}\) are the mean vector and covariance matrix of mixture component \(i\). The number of mixture components is a hyperparameter which could be optimised. We chose \(N_{c}=32\) on the basis that 32 component mixtures were found to be sufficiently expressive in trial experiments with MDNs.
The architecture chosen for the neural network is the standard multilayer perceptron, with six hidden (i.e. interior) layers. The first four hidden layers have 256 neurons and the remaining two have 512. The activation function \(\tanh(x)\) is applied to each of the hidden
Figure 3: Regions considered for model comparison in section 4.3.
layers. Thus, the activity of hidden layer \(i\), is
\[\mathbf{h}_{i}=\tanh\left(W_{i}\mathbf{h}_{i-1}+\mathbf{b}_{i}\right) \tag{14}\]
for \(i>1\), and
\[\mathbf{h}_{1}=\tanh\left(W_{1}\mathbf{X}_{0}+\mathbf{b}_{1}\right). \tag{15}\]
Here, \(\mathbf{W}_{i}\in\mathbb{R}^{d_{i}\times d_{i-1}}\) and \(\mathbf{b}_{i}\in\mathbb{R}^{d_{i}}\) are the weight and bias parameters corresponding to the \(i^{\text{th}}\) layer, having \(d_{i}\) neurons. Note that \(\mathbf{w}=\{\mathbf{W}_{i},\mathbf{b}_{i}\}\). The final layer has custom activation functions designed to enforce the natural constraints on the components of \(\mathbf{\theta}\). In particular, the softmax activation function \(a_{\text{sm}}(\mathbf{x})=\exp(\mathbf{x})\,/\,\sum_{i}\exp(x_{i})\) is applied to the neural network outputs which correspond to the mixture component weights, \(\mathbf{\alpha}\), to ensure that these are positive and satisfy the constraint (7). Each covariance matrix \(\mathbf{C}_{i}\) is represented by the components of a lower triangular Cholesky factor \(-\) positivity of the diagonal elements is enforced by taking an exponential. When \(N_{c}=32\) we have \(\dim(\mathbf{\theta})=192\), and the total number of neural network parameters, i.e. weights and biases, is \(\dim(\mathbf{w})=690,880\). We train the model by minimising the negative log likelihood loss function (8) using the Adam algorithm (Kingma & Ba, 2015). We note that the number of widths of hidden layers are further hyperparameters which we have chosen after experimentation with test problems. We do not attempt to find optimal values for these in this work.
As is common in machine learning, we standardise the data before training (LeCun et al., 2012), that is we transform both the input data, \(\{\mathbf{X}_{0i}\}\), and output data, \(\{\Delta\mathbf{X}_{i}\}\), separately, by subtracting the mean of the training data and dividing each component by its standard deviation in the training data, so that each component of the transformed data has zero mean and unit variance. While theoretical justifications for this practice are lacking or unsatisfactory, we found that it did improve noticeably the numerical stability of the optimisation procedure. In any case, the transformation that we apply is invertible, although care must be taken to correctly invert the rescaling of the transition density. For example, if we denote the standardised variables by \(\widehat{\mathbf{X}_{0}}\) and \(\widehat{\Delta\mathbf{X}}\), then the model approximates \(p(\widehat{\Delta\mathbf{X}}\mid\widehat{\mathbf{X}_{0}})\), and we can recover the transition density with the correct units as
\[p(\Delta\mathbf{X}\mid\mathbf{X}_{0})=\frac{p\left(\widehat{\Delta\mathbf{X}}\mid\widehat {\mathbf{X}_{0}}\right)}{\widehat{\text{std}}(\Delta X)\,\widehat{\text{std}}( \Delta Y)}, \tag{16}\]
where \(\widehat{\text{std}}(\,\cdot\,)\) denotes the sample standard deviation among the training data.
Figure 4: Schematic of the MDN model of the single-particle transition density of drifters.
One aspect of neural networks that is particularly relevant to the problem at hand, is that they struggle to represent periodic functions (Liu et al., 2020). Given that we operate in longitude-latitude coordinates, a model of the transition density ought to be periodic in longitude. However, since the neural network model receives the initial position \(\mathbf{X}_{0}\) as simply a vector in \(\mathbb{R}^{2}\), the concept of a spherical domain is not built in to the representation. Indeed, the MDN model produces discontinuities in \(p(\Delta\mathbf{X}\mid\mathbf{X}_{0})\) at the dateline due to model error on either side. To improve continuity at the dateline we employ a crude technique, wherein we replicate the data twice, once shifted by \(360^{\circ}\) longitude west, and once shifted by \(360^{\circ}\) east.
The model is implemented in Python using TensorFlow (TensorFlow Developers, 2021) and TensorFlow Probability (TensorFlow Probability Developers, 2021) and trained using four NVIDIA Tesla V100 16GB GPUs in parallel. Of the 50% of data used to construct the model, 90%, again chosen randomly, was used to inform iterations of the optimisation procedure, and 10% was used for early stopping -- we refer to these portions of the data as the training and test sets, respectively. Training took approximately 90 minutes. The evolution during training of the loss function on training and test sets is shown in figure 5 as a function of epoch. An epoch is the number of iterations taken for all data to be used once in the Adam algorithm. The stopping criterion used for the optimisation, an example of early stopping, was that the test loss had not decreased since 50 epochs previous.
### Model evaluation and comparison
Since the MDN model is probabilistic, its performance should be assessed using skill scores for probabilistic forecasts, as opposed to performance metrics commonly used for deterministic models, such as the mean squared error. As discussed above, minimising the negative log likelihood is equivalent to maximising the log score, since this is exactly the log likelihood. The log score has attractive properties, namely strict propriety (Brocker and Smith, 2007) and locality (Du, 2021). Indeed it is the only smooth local strictly proper scoring rule for continuous variables up to affine transformation (Bernardo, 1979). A scoring rule is strictly proper
Figure 5: Evolution of the training and test loss in the MDN model during optimisation. The loss shown is the mean negative log likelihood per datapoint (i.e. a normalised form of (8)) in terms of the standardised variables \(\mathbf{\widetilde{X}}_{0}\) and \(\widehat{\Delta\mathbf{X}}\).
if its expectation (with respect to data) is maximised uniquely by the correct/perfect model (assuming it exists). A scoring rule is local if it is a function only of the value of the forecast probability distribution evaluated at the observed data, and does not depend for example on other features of the forecast distribution, such as its shape. For validation purposes we can compute the log score on our validation data set. However, while the value of the log score can be easily interpreted in the case of forecasts of discrete/categorical variables, its value in the case of continuous variables is not immediately meaningful, since it refers to probability density, which has dimensions inverse to the area of its support, meaning that the scale of the log score is problem-dependent. On the other hand, the log score can be more easily interpreted when used as a relative score between models -- in particular, the mean difference of log scores between models reflects the average additional probability the first model places on observed outcomes compared to the other model, measured in units of information, nats (or shannons when \(\log_{2}\) is used in the definition of the score). The difference of log scores is invariant under smooth transformations of the forecast variable (Du, 2021); this means, in particular, that differences in log scores are unaffected by a change of units. Thus, in order to evaluate the MDN model we compare it with alternative models. We describe two alternative models, one used extensively in the literature, and one proposed here as a simple but reasonable alternative. We also compare with a simplified version of the MDN model, which features only one mixture component, i.e. for which \(N_{c}=1\). The log score of all models is computed on both training and validation data to assess relative performance.
#### 4.3.1 Transition matrix model
Previous work (Maximenko et al., 2012; van Sebille et al., 2012; Miron et al., 2017, 2021), modelled drifter dynamics with a discrete-time Markov chain using Ulam's method (Ulam, 1960; Froyland, 2001). This requires to discretise space into bins \(\{B_{i}\}\) and estimate the transition matrix
\[P_{ij}=\mathbb{P}(\mathbf{X}_{n+1}\in B_{j}\mid\mathbf{X}_{n}\in B_{i}), \tag{17}\]
which is the discrete analogue of the transition density (10). Indeed the primary difference between a Markov chain model and our Markov process model is that ours is continuous in space. The elements of the transition matrix are usually estimated by the standard approach sketched in figure 1, where we have \(\mathbf{Y}=\mathbf{X}_{n+1}\) and \(f(\mathbf{Y})=1_{B_{j}}(\mathbf{X}_{n+1})\) -- this corresponds to the maximum-likelihood estimate for each \(P_{ij}\) and, hence, maximises the log score on the training dataset. Note that the transition matrix can be used to construct a corresponding transition density which is piecewise constant on gridcells in \(\mathbf{X}_{n}\) and \(\mathbf{X}_{n+1}\) via
\[p(\Delta\mathbf{X}\mid\mathbf{X}_{0})=\frac{P_{ij}}{A(B_{j})},\quad\text{ when }\mathbf{X}_{0}\in B_{i},\ \mathbf{X}_{0}+\Delta\mathbf{X}\in B_{j}, \tag{18}\]
where \(A(B_{j})\) is the area2 of \(B_{j}\). This is important for allowing comparison with models which are continuous in space.
Footnote 2: For consistency with the transition density as given by the MDN model, these areas must be calculated in terms of the same variables, i.e. degrees longitude by degrees latitude.
An advantage of Markov chain models is that analysis of their long time behaviour is straightforward -- the left and right eigenvectors of the transition matrix can be studied to identify almost-invariant sets, as in Miron et al. (2017). This has been called the eigenvector method (Froyland et al., 2014). The extension of this analysis to the continuous-space setting
using our model, which we leave for future work, requires the calculation of eigenfunctions of the relevant Perron-Frobenius operator \(\mathcal{P}\), which acts on probability density functions to evolve them forward in time, such that
\[p(\mathbf{X}_{n+1}) =\mathcal{P}(p(\mathbf{X}_{n})) \tag{19}\] \[:=\int_{\Omega}p(\mathbf{X}_{n})\,p(\mathbf{X}_{n+1}\mid\mathbf{X}_{n})\, \mathrm{d}\mathbf{X}_{n}. \tag{20}\]
Alternatively, it is worth noting that the MDN model can be used to construct a transition matrix, by numerical integration of the transition density, that is by computing numerically
\[P_{ij}=\int_{B_{i}}\int_{B_{j}}p(\mathbf{X}_{n+1}\mid\mathbf{X}_{n})\,\mathrm{d}\mathbf{X}_{ n+1}\,\mathrm{d}\mathbf{X}_{n}. \tag{21}\]
In figure 6 we show the log transition density \(\log p(\Delta\mathbf{X}\mid\mathbf{X}_{0})\) derived from the transition matrix model via (18) for two different initial positions \(\mathbf{X}_{0}\). The first is located within the core of the Gulf Stream at \(34.85^{\circ}\) N, \(74.50^{\circ}\) W, and the second is just outside the Gulf stream at \(33.67^{\circ}\) N, \(72.55^{\circ}\) W. Notice that in each case the support of the density is the set of grid cells to which transitions were observed in the training data. In other words, transitions to other grid cells have probability zero under the model. We return to this point in section 4.3.3.
#### 4.3.2 Gaussian transitions with gridded parameters (GTGP)
A simple model for the transition density (11) is that, given initial positions \(\mathbf{X}_{0}\), transitions are conditionally Gaussian with conditional mean and covariance given by functions of \(\mathbf{X}_{0}\) which are piecewise constant on grid cells, i.e.
\[\Delta\mathbf{X}\mid\mathbf{X}_{0}\sim\mathcal{N}\left(\mathbf{\mu}\left(\mathbf{X}_{0}\right),\,\mathbf{C}\left(\mathbf{X}_{0}\right)\right), \tag{22}\]
with \(\mathbf{\mu}\left(\mathbf{X}_{0}\right)\) and \(\mathbf{C}\left(\mathbf{X}_{0}\right)\) piecewise constant in \(\mathbf{X}_{0}\). The parameters \(\mathbf{\mu}\) and \(\mathbf{C}\) are estimated by sorting the observations into bins and computing the sample mean and sample covariance for each bin. The sample mean is the maximum likelihood estimate of \(\mathbf{\mu}\), while the sample
Figure 6: Maps of the log transition probability density function, \(\log p(\Delta\mathbf{X}\mid\mathbf{X}_{0})\), for initial positions, \(\mathbf{X}_{0}\), (a) in the Gulf Stream (\(34.85^{\circ}\) N, \(74.50^{\circ}\) W), and (b) adjacent to the Gulf Stream (\(33.67^{\circ}\) N, \(72.55^{\circ}\) W), derived from the transition matrix model with \(\tau=4\) days via (18). Yellow dots indicate \(\mathbf{X}_{0}\).
covariance differs from the maximum likelihood estimate of \(\mathbf{C}\) only by a factor of \(\frac{N-1}{N}\approx 1\), where \(N\) is the number of training data in the given bin. Hence, the parameter estimates used are very close to those which maximise the log score on training data.
Figure 7 shows the mean of displacements from a GTGP model with a regular \(1^{\circ}\times 1^{\circ}\) longitude-latitude grid and \(\tau=4\) days, as a function of initial position.
#### 4.3.3 Model scores
We compute skill scores for the full training and validation datasets with global coverage, and for regions \(A\), \(B\), and \(C\). For both the transition matrix and GTGP models it is necessary to choose a spatial discretisation; herein we consider only square latitude-longitude grids,
Figure 7: Mean of displacements from the GTGP model, with \(\tau=4\) days, as a function of initial position.
so that the only parameter to be chosen is the grid cell side length. This choice affects their performance. If a relatively high resolution discretisation is used, the models attain relatively high scores in training, but generalise poorly, as reflected in poor scores on validation data. In the case of the GTGP model, an issue arises when validation data falls in grid cells not visited by drifters in the training set, since sample means and covariances cannot be estimated in bins where data is absent. As a simple solution, we set the value of \(\mathbf{\mu}\) and \(\mathbf{C}\) on unvisited grid cells equal to a global (or regional) estimate. A flaw of the transition matrix model, with the transition matrix estimated as discussed above, is that validation data can have zero probability under the model, and hence achieve a log score of minus infinity. This situation is avoided by taking sufficiently large grid cells, but this leads to exceptionally low scores. On the other hand, a validation score can be computed with smaller grid cells if one is prepared to simply discard validation data which have zero probability under the model. This seems overly generous, as the transition matrix model will be scored increasingly highly as the grid cell size is reduced to zero and an increasing number of the validation data are neglected. As a compromise, we fix the grid cell size for the transition matrix model to \(1^{\circ}\times 1^{\circ}\), the resolution used in some previous studies (van Sebille et al., 2012) where the transition matrix model was used, and discard validation data with zero probability -- the proportion of validation data discarded was 7% globally, and 2%, 9% and 4% in regions \(A\), \(B\) and \(C\), respectively. For the GTGP model the grid cell size was optimised to maximise validation scores using grid search cross validation: a common procedure which amounts to trying a range of values of a model hyperparameter (in this case the grid cell size) and choosing the value which optimises the validation score. The optimal grid cell size found ranged from \(1.1^{\circ}\) in region A to \(5^{\circ}\) globally. The scores are presented in table 1. In all regions the MDN models outperform the alternatives, with the 32-component model achieving slightly higher scores than the single-component model. Note that the scores reported happen to be negative -- this is not by convention, but instead reflects that log probability densities are often negative. A higher score is a better score.
### Results
Once trained, the model can be used in at least two ways: (i) to derive estimates of single-particle displacement statistics, and (ii) to simulate drifter trajectories. However, we first ex
\begin{table}
\begin{tabular}{l l|c c c c} & & TM & GTGP & MDN1 & MDN32 \\ \hline Global: & Training & \(-1.61\) & \(-1.20\) & \(-1.07\) & \(-1.02\) \\ & Validation & \(-1.74\) & \(-1.30\) & \(-1.14\) & \(-1.11\) \\ \(A\): & Training & \(-1.78\) & \(-1.25\) & \(-1.35\) & \(-1.30\) \\ & Validation & \(-1.89\) & \(-1.42\) & \(-1.40\) & \(-1.35\) \\ \(B\): & Training & \(-1.95\) & \(-1.90\) & \(-1.91\) & \(-1.85\) \\ & Validation & \(-2.16\) & \(-2.01\) & \(-2.01\) & \(-1.96\) \\ \(C\): & Training & \(-1.93\) & \(-1.59\) & \(-1.63\) & \(-1.56\) \\ & Validation & \(-2.00\) & \(-1.66\) & \(-1.61\) & \(-1.57\) \\ \end{tabular}
\end{table}
Table 1: Training and validation scores for the transition matrix and GTGP models, as well as the single-component MDN and full 32-component MDN models, in each of the regions considered (see the map in figure 3). The scores are the mean log score (i.e. mean log likelihood) per datapoint calculated in terms of the variables \(\mathbf{X}_{0}\) and \(\Delta\mathbf{X}\) in their original degrees longitude/latitude units.
amine the transition density directly. In figure 8 we show the log transition density \(\log p(\Delta\mathbf{X}\mid\mathbf{X}_{0})\) for two different initial positions \(\mathbf{X}_{0}\). In the first case, where \(\mathbf{X}_{0}\) is located within the core of the Gulf Stream at \(34.85^{\circ}\) N, \(74.50^{\circ}\) W, the transition density is strongly non-Gaussian, with contours extending roughly to the south and northeast, showing the influence of the Gulf Stream on drifters. In the second case, where \(\mathbf{X}_{0}\) is just outside the Gulf stream at \(33.67^{\circ}\) N, \(72.55^{\circ}\) W, the transition density is closer to Gaussian.
In order to quantify the extent to which the transition density deviates from being Gaussian, and how this varies from one region of the ocean to another, we computed the Kullback-Leibler (KL) divergence3 of the single-component MDN model, which is Gaussian, from the full 32-component model as a function of initial position. The result is shown in figure 9. Note that, since a closed-form expression for the KL divergence between two Gaussian mixtures is not known (Cui & Datcu, 2015), we provide simple Monte Carlo estimates based on 5000 samples at each of the vertices of a \(1^{\circ}\times 1^{\circ}\) grid. Where the KL divergence is zero, the two models agree exactly, indicating that displacements are Gaussian. The larger the KL divergence is, the greater the disagreement between the models, and the further from Gaussian the full model is. As a point of reference for interpreting the magnitude of the KL divergence, note that the if \(Z_{0}\sim\mathcal{N}(m_{0},\,1)\) and \(Z_{1}\sim\mathcal{N}(m_{1},\,1)\), then, writing their pdfs as \(p_{0}\) and \(p_{1}\), \(D_{\text{KL}}(p_{1}\parallel p_{0})=(m_{1}-m_{0})^{2}\). Non-Gaussianity of displacements is likely due primarily to inhomogeneity of ocean velocities -- drifters can explore a range of flow statistics as they move, and the convolved effects of these are reflected in observed displacements. An alternative explanation is that the underlying velocity field is non-Gaussian -- evidence of non-Gaussian velocities in the North Atlantic has been presented by Bracco et al. (2000) and LaCasce (2005) on the basis of observations from both subsurface current meters and subsurface floats.
Footnote 3: The KL divergence of \(p\) from \(q\), also known as the relative entropy, defined \(D_{\text{KL}}(q\parallel p)=\int q(x)\,\log\frac{q(x)}{p(x)}\,\text{dx}\), is a measure of the divergence of a probability density \(p\) from a reference probability density \(q\) – often interpreted as the amount of information lost when \(p\) is used to approximate \(q\).
As can be seen in figure 8, the model assigns nonzero probability to drifter displacements intersecting land. This is unavoidable given that the support of the assumed parametric form, that of a Gaussian mixture, extends to infinity; moreover, this may not be entirely spurious, given that some drifters do run aground. In 2012 Lumpkin et al. (2012) reevaluated drifter data to study the causes of drifter deaths. They concluded that approximately 27% of drifter
Figure 8: Maps of the log transition density, \(\log p(\Delta\mathbf{X}\mid\mathbf{X}_{0})\), for initial positions, \(\mathbf{X}_{0}\), (a) in the Gulf Stream (\(34.85^{\circ}\) N, \(74.50^{\circ}\) W), and (b) adjacent to the Gulf Stream (\(33.67^{\circ}\) N, \(72.55^{\circ}\) W), derived from the MDN model with \(\tau=4\) days. Yellow dots indicate \(\mathbf{X}_{0}\).
deaths were due to running aground, with a further 10% being picked up by humans, and the remainder failing due to internal faults. Outside of coastal regions this issue is unlikely to have a strong effect on the estimates of displacement statistics considered in section 4.4.1. The implications for dritter simulations are discussed further in section 4.4.2.
#### 4.4.1 Displacement statistics
In this section we present maps of single-particle statistics derived from the model. As a first example, we show the mean of displacements over the 4-day time increment of our model. We further provide global estimates of lateral diffusivity.
Figure 10 shows the mean of dritter displacements as a function of initial position. While the output of the model is in longitude-latitude coordinates \((\lambda,\phi)\), we apply a simple conversion to kilometres based on a local tangent-plane approximation
\[\Delta X =R\,\Delta\phi \tag{23a}\] \[\Delta Y =R\,\Delta\lambda\,\cos\phi_{0}, \tag{23b}\]
where \(R\) is the radius of the Earth at the equator. The imprint of several features of the surface dynamics, such as the western boundary currents and equatorial (counter) currents, is clear.
For the sake of comparison with previous work, we consider the estimation of lateral diffusivity from our model, though we emphasise that by modelling the full transition density, we provide a more accurate description of Lagrangian statistics than can be captured by the familiar advective-diffusive model of dispersion put forward by Davis (1987, 1991). The estimation of ocean diffusivity by various methods has been the subject of numerous papers (Oh et al. 2000, Zhurbas & Oh 2003, 2004, Klocker et al. 2012, Abernathey & Marshall 2013, Klocker & Abernathey 2014, Ying et al. 2019). The estimation of diffusivity from dritter displacements is straightforward only when there exists a suitable sampling time, which is larger than the time for dritter velocities to decorrelate, i.e. for dritter motion to become diffusive, and such
Figure 9: Kullback–Leibler divergence of the single-component MDN model from the full 32-component MDN model, as a function of initial position. Larger values indicate stronger deviations from Gaussianity in displacements.
Figure 10: Mean of displacements from the MDN model, with \(\tau=4\) days, as a function of initial position.
that the scale of drifter displacements over that time scale is small relative to spatial variations in the diffusivity. In this case a simple estimate of the lateral diffusivity tensor \(\mathbf{K}(\mathbf{x})\) is
\[\mathbf{K}(\mathbf{x})=\frac{1}{2\,\tau}\,\text{Cov}(\Delta\mathbf{X}\mid\mathbf{X}_{0}=\bm {x}), \tag{24}\]
where \(\tau\) is the suitably chosen time scale, and the conditional covariance is estimated by either one of the approaches sketched in figure 1. Unfortunately, such a time scale may not exist in the ocean, and, if it does exist, it likely varies in space, making its determination difficult. This challenge has been borne out in previous studies (LaCasce et al. 2014, Zhurbas et al. 2014). Oh et al. (2000) proposed a method to circumvent the issues created by inhomogeneity. They proposed to isolate the cross-flow component of the displacement covariance, identified by the minor principal component (the smaller eigenvalue of displacement covariance), and use this to provide a scalar estimate of diffusivity, since the cross-flow component is less affected by shear in the mean flow. In figure 11(a) we provide a similar estimate, derived from the MDN model with \(\tau=4\) days,
\[K(\mathbf{x})=\frac{1}{2\,\tau}\,\lambda_{2}(\mathbf{x}), \tag{25}\]
where \(\lambda_{2}(\mathbf{x})\) is the smallest eigenvalue of
\[\text{Cov}(\Delta\mathbf{X}\mid\mathbf{X}_{0}=\mathbf{x})=\sum_{i}\alpha_{i}\mathbf{C}_{i }+\sum_{i}\left[\alpha_{i}\left(\mathbf{\mu}_{i}-\sum_{i}\alpha_{i}\mathbf{\mu}_{i} \right)\left(\mathbf{\mu}_{i}-\sum_{i}\alpha_{i}\mathbf{\mu}_{i}\right)^{T}\right]. \tag{26}\]
The result agrees very well with estimates provided by Zhurbas & Oh (2004) for the Atlantic and Pacific oceans. Figure 11(b) shows the difference of estimates of the form (25) with \(\tau=14\) days and \(\tau=4\) days, respectively. In many areas, the diffusivity estimates are slightly amplified by taking a larger time lag \(\tau\), with greater differences visible in some particularly energetic regions; however, the effect is indeed much weaker than that observed with analogous along-flow diffusivity estimates derived from the largest eigenvalue of the displacement covariance matrix.
Leaving aside the challenges of estimating diffusivity from displacements, which are common to all methods, we highlight as this point some advantages to our approach. Using the MDN model, trained with maximum likelihood and effectively regularised by the use of early-stopping, removes the difficulty of tuning the resolution of bins. Instead, the effective resolution of our mean displacement and diffusivity estimates is set automatically by the resolution of the data, and is free to vary optimally in space. This allows us to produce at once global estimates, which resolve well-sampled flow features very well and are forgiving in regions where data is relatively sparse, with the exception of very high-latitude regions, where there is simply no data to constrain the model.
#### 4.4.2 Drifter simulations
In this section we demonstrate the simulation of drifter trajectories using the MDN model as the basis for a discrete time Markov process model. In a discrete-time setting, assuming Markovianity means assuming that \(p(\mathbf{X}_{n+1}\mid\mathbf{X}_{n},\,\mathbf{X}_{n-1},\,\cdots)=p(\mathbf{X}_{n+1}\mid\mathbf{X} _{n})\). In this case, sampling trajectories amounts to repeatedly sampling displacements in sequence according to the transition density, since, given the current position, displacements are statistically independent of previous positions.
Figure 11: Global estimate of lateral diffusivity derived from the MDN model of the transition density.
A complication of simulating drifters in this way is that, for reasons discussed above, drifters can hit land. In this work we do not attempt to model the beaching of drifters, since it is not clear that the Global Drifter Program dataset contains sufficient reliable information \(-\) in particular, it remains a challenge to determine whether drifters have run aground or not (Lumpkin et al., 2012). To exclude the possibility of running aground in our drifter simulations we implement a simple rejection sampling scheme, wherein displacements sampled from the transition density which would bring a drifter on land are rejected, and a new displacement is sampled until a displacement which keeps the drifter in the ocean is drawn. This amounts to sampling according to the conditional density \(p(\Delta\mathbf{X}\mid\mathbf{X}_{0},\mathbf{X}_{0}+\Delta\mathbf{X}\not\in\text{land})\), and is equivalent to the standard practice when using transition matrix models of restricting the domain considered to the ocean and normalising probability estimates correspondingly. To determine whether a proposed new position is on land, we check intersection with a 110m-resolution land mask.
We simulated the evolution of a set of drifters initialised on the vertices of a \(2^{\circ}\times 2^{\circ}\) grid for a period of 10 years. Note that the evolution of each drifter is simulated independently. This means that multi-particle statistics that would characterise the joint evolution of drifters released simultaneously in the ocean are not represented and, in particular, that the current model is not appropriate for simulating the release of a cloud of tracer particles on short time scales; however, it can be expected to represent the behaviour of drifters or buoyant tracers over large spatial and temporal scales. Similar experiments, carried out by Maximenko et al. (2012) and van Sebille et al. (2012) using transition matrix models trained on Global Drifter Program data, studied the clustering of simulated drifters due to near-surface convergence and the formation of so-called garbage patches, including the North Pacific Garbage Patch (Moore et al., 2001) and others corresponding to the other subtropical ocean gyres. The simulations of van Sebille et al. (2012) showed a further cluster in the Barents Sea which formed only after several decades.
The results of our model simulation are largely in agreement with these previous studies. The distribution of the simulated drifters is shown in figure 12 at the beginning of the simulation and after one, three, and ten years of evolution under the MDN model. After one year the drifters have become relatively sparse in equatorial regions. After three years clusters in the subtropical gyres have begun to appear, and after ten years, these are very well defined. Smaller clusters are also seen to appear, notably in the North Sea and in the seas south of Papua, as well as in some high latitude regions including along the west coast of Greenland and off Antarctica around \(100-130^{\circ}\) E.. Validating these clusters, that is, assessing whether marine debris is likely to accumulate in these areas, is difficult, because in situ observations remain sparse (Ryan et al., 2009). It may be that the dynamics in these regions, which are poorly sampled by GDP drifters, are simply underresolved by the MDN model, leading to spurious convergence zones. We note, for example, in figure 10 that mean displacements do not appear to represent the detail of known currents in the southern portion of the North Sea, which is not visited by drifters in the GDP data (see figure 2). In general, as is true for any data-driven model, caution should be exercised when interpreting model outputs in regions where data is lacking.
## 5 Conclusions
This work demonstrates the use of conditional density estimation, and, in particular, stochastic neural networks, in a fluid dynamical problem, namely that of diagnosing single-particle
statistics from trajectory data. We show how such probabilistic models are useful both as emulators, and as an indirect means of estimating conditional statistics. By operating in the framework of probabilistic modelling we are able to appeal to the extensive literature on statistical inference, probabilistic forecasting, model comparison and validation, and thereby avoid ad hoc choices of loss functions and performance metrics. Our model is compared, using a probabilistic scoring rule, to alternative models, including a Markov chain model used extensively in the literature, and is shown to outperform these, both globally and in three specific regions.
By modelling the single-particle transition density of surface drifters, we gain estimates of a range of conditional statistics simultaneously, which capture the occurrence of strongly non-Gaussian statistics in some areas of the ocean. We provide global maps of mean displacement and lateral diffusivity, but emphasise that these examples provide only a limited summary of the information contained in the transition density; further statistics, including higher moments of displacements can readily be computed from our model. Interpreted as the basis for a discrete-time Markov process, our model is also used to simulate the evolution of a set of drifters seeded globally on a uniform grid, and shows the emergence of clusters of drifters in the subtropical gyres, in agreement with previous work on the formation of garbage patches.
The approach espoused in this work is equally applicable to other problems in fluid dynamics and oceanography. One example is the estimation of structure functions from either Eulerian or Lagrangian velocity data. Another is the estimation of multi-particle statistics, such as relative dispersion, via modelling of multi-particle transition densities. Yet another is the learning of stochastic parameterisations in climate/atmosphere/ocean models. Guillau
Figure 12: Histograms of simulated drifters initially and after one, three, and ten years of evolution under the MDN model, respectively.
min & Zanna (2021) made progress on the parameterisation of subgrid momentum forcing in an ocean model with a single-component MDN model, but the approach is applicable more broadly, e.g. to the parameterisation of subgrid transport.
In this work we have largely neglected the need to quantify uncertainty in model parameters and to incorporate prior knowledge in our modelling. These needs would be met by a Bayesian approach, where, instead of estimating parameters by maximum likelihood, we apply Bayesian inference to obtain posterior distributions on parameters, which account for prior knowledge. Indeed, all of the results presented herein would benefit from uncertainty quantification. In the case of conditional statistics, a Bayesian approach would, e.g., allow to identify where there is not enough data to inform reliable estimates of lateral diffusivity; and in general, incorporating prior knowledge may help to regularise our model of the transition density, so that, in the case of drifter simulations, spurious convergence zones can be avoided. The application of Bayesian inference to MDNs remains challenging, but we consider this an important future direction.
**Acknowledgements.** I am grateful to Jacques Vanneste, James Maddison and Aretha Teckentrup for their advice, input and overall support of this work. I also thank Dhruv Balwada for helpful discussions. Thanks are also due to the reviewers for their suggestions which have improved the manuscript.
**Funding**. The author was supported by the MAC-MIGS Centre for Doctoral Training under EPSRC grant EP/S023291/1. This work used the Cirrus UK National Tier-2 HPC Service at EPCC (www.cirrus.ac.uk) funded by the University of Edinburgh and EPSRC (EP/P020267/1).
**Declaration of interests.** The author reports no conflict of interest.
**Data availability statement.** The code required to reproduce the results herein is available at doi.org/10.5281/zenodo.7737161, along with the trained MDN model and a Jupyter Notebook which demonstrates its use. The processed GDP data used and drifter simulation data are available at doi.org/10.7488/ds/3821.
|
2303.00566 | Structured Pruning for Deep Convolutional Neural Networks: A survey | The remarkable performance of deep Convolutional neural networks (CNNs) is
generally attributed to their deeper and wider architectures, which can come
with significant computational costs. Pruning neural networks has thus gained
interest since it effectively lowers storage and computational costs. In
contrast to weight pruning, which results in unstructured models, structured
pruning provides the benefit of realistic acceleration by producing models that
are friendly to hardware implementation. The special requirements of structured
pruning have led to the discovery of numerous new challenges and the
development of innovative solutions. This article surveys the recent progress
towards structured pruning of deep CNNs. We summarize and compare the
state-of-the-art structured pruning techniques with respect to filter ranking
methods, regularization methods, dynamic execution, neural architecture search,
the lottery ticket hypothesis, and the applications of pruning. While
discussing structured pruning algorithms, we briefly introduce the unstructured
pruning counterpart to emphasize their differences. Furthermore, we provide
insights into potential research opportunities in the field of structured
pruning. A curated list of neural network pruning papers can be found at
https://github.com/he-y/Awesome-Pruning . A dedicated website offering a more
interactive comparison of structured pruning methods can be found at:
https://huggingface.co/spaces/he-yang/Structured-Pruning-Survey . | Yang He, Lingao Xiao | 2023-03-01T15:12:55Z | http://arxiv.org/abs/2303.00566v2 | # Structured Pruning for Deep Convolutional Neural Networks: A survey
###### Abstract
The remarkable performance of deep Convolutional neural networks (CNNs) is generally attributed to their deeper and wider architectures, which can come with significant computational costs. Pruning neural networks has thus gained interest since it effectively lowers storage and computational costs. In contrast to weight pruning, which results in unstructured models, structured pruning provides the benefit of realistic acceleration by producing models that are friendly to hardware implementation. The special requirements of structured pruning have led to the discovery of numerous new challenges and the development of innovative solutions. This article surveys the recent progress towards structured pruning of deep CNNs. We summarize and compare the state-of-the-art structured pruning techniques with respect to filter ranking methods, regularization methods, dynamic execution, neural architecture search, the lottery ticket hypothesis, and the applications of pruning. While discussing structured pruning algorithms, we briefly introduce the unstructured pruning counterpart to emphasize their differences. Furthermore, we provide insights into potential research opportunities in the field of structured pruning. A curated list of neural network pruning papers can be found at
[https://github.com/he-y/Awesome-Pruning](https://github.com/he-y/Awesome-Pruning).
Computer Vision, Deep Learning, Neural Network Compression, Structured Pruning, Unstructured Pruning.
## 1 Introduction
Deep convolutional neural networks (CNNs) have shown exceptional performance in a wide variety of applications, including image classification [1], object detection [2], and image segmentation [3], amongst others. Numerous CNN structures including AlexNet [4], VGGNet [5], Inceptions [6], ResNet [7] and DenseNet [8] have been proposed. These architectures contain millions of parameters and require large computing power, making deployments on resource-limited hardware challenging. Model compression is a solution for this problem, aiming to reduce the number of parameters, computational cost, and memory consumption. As such, its study has gained importance.
To generate more efficient models, model compression techniques including pruning [9], quantization [10], decomposition [11], and knowledge distillation [12] have been proposed. The term "pruning" refers to removing components of a network to produce sparse models for acceleration and compression. The objective of pruning is to minimize the number of parameters without significantly affecting the performance of the models. Most research on pruning has been conducted on CNNs for the image classification task, which is the foundation for other computer vision tasks.
Pruning can be categorized into unstructured [9] and structured pruning [13]. **Unstructured pruning** removes connections (weights) of neural networks, resulting in unstructured sparsity. Unstructured pruning often leads to a high compression rate, but requires specific hardware or library support for realistic acceleration. **Structured pruning** removes entire filters of neural networks, and can achieve realistic acceleration and compression with standard hardware by taking advantage of a highly efficient library such as the Basic Linear Algebra Subprograms (BLAS) library.
Revisiting the property of CNNs from the perspective of structured pruning is meaningful in the era of Transformers [14]. Recently, there has been an increasing trend of incorporating the architectural design of CNNs into Transformer models [15, 16, 17, 18, 19]. Although the self-attention [20] in Transformers is effective in computing a representation of the sequence, an enormous amount of training data is still needed since Transformers lack induction biases [17, 21, 22]. In contrast, the structure of CNNs enforces two key inductive biases on the weights: locality and weight sharing, to improve the generalization of learning algorithms and are independent of data [17]. This survey provides a better understanding of CNNs and provides hints to efficiently design architecture for the future.
In this survey, we focus on structured pruning. Existing surveys on related compression studies are shown in Table I. Some surveys covers orthogonal fields including quantization [23], knowledge distillation [24], and neural architecture search [25]. Some surveys [26] provide a broader overview. Although some surveys focus on pruning, they pay more attention to unstructured pruning and cover a small number of studies on structured pruning. The numbers of structured pruning papers cited by [27, 28, 29, 30, 31, 32, 33] are 1, 11, 15, 55, 38, 10, and 20, respectively. We provide a more comprehensive survey with more than 200 structured pruning papers. For example, [30] can be covered by Section 2.1 2.2 2.3 2.4.1 2.7.1 3.1.
The survey is arranged as follows. In the taxonomy (Fig. 1), we group the structured pruning methods into different categories. Every subsection of Section 2 corresponds
to a category of structured pruning methods. Most methods are first developed in an unstructured manner and then extended to meet structural constraints. Although some studies cover multiple categories, we place them in the most appropriate categories that serve this survey. Section 3 then introduces some potential and promising future directions. Due to the length constraints, only the most representative studies are discussed in detail.
## 2 Methods
**Preliminaries:** A deep convolutional neural network \(\mathcal{N}\) can be parameterized by \(\{\mathbf{W}^{l}\in\mathbb{R}^{N_{l+1}\times N_{l}\times K_{l}\times K_{l}},\,1 \leq l\leq L\}\). At \(l\)-th layer, the input tensor \(I^{l}\) has shape \(N_{l}\times H_{l}\times W_{l}\), and the output tensor \(O^{l}\) has shape \(N_{l+1}\times H_{l+1}\times W_{l+1}\). \(N_{l}\) and \(N_{l+1}\) denote the channel number of input and output tensors in the \(l\)-th layer, respectively. \(\mathbf{W}^{l}\) represents the connections (weights) between the input tensor \(\mathbf{I}^{l}\) and the output tensor (feature map) \(\mathbf{Q}^{l}\). The weight matrix \(\mathbf{W}^{l}\) is made of \(N_{l+1}\) 3-D filters \(\mathbf{F}^{l}\). Specifically, the \(i\)-th filter in \(l\)-th layer can be denoted as \(\{\mathbf{F}^{l}_{i}\in\mathbb{R}^{N_{l}\times H_{l}\times W_{l}},1\leq i\leq N _{l+1}\}\). In this paper, we call \(\mathbf{K}^{l}\in\mathbb{R}^{K_{l}\times K_{l}}\) 2-D kernels, so a filter has \(N_{l}\) kernels of kernel size \(K_{l}\). To express a single weight, we use \(\left\{w=\mathbf{F}^{l}_{i}(n,k_{1},k_{2}),1\leq n\leq N_{l},1\leq k_{1},k_{2 }\leq K_{l}\right\}\). A typical convolution operation of \(l\)-th layer can be expressed as:
\[\mathbf{O}^{l}_{i}=\mathbf{I}^{l}*\mathbf{F}^{l}_{i}\ \text{\bf for}\ 1\leq i\leq N_{l+1} \tag{1}\]
where \(*\) denotes the convolution operator.
Structured pruning, such as filter pruning, aims to:
\[\begin{split}\min_{\mathbf{F}}\mathcal{L}(\mathbf{F};\mathcal{ D})=\min_{\mathbf{F}}\frac{1}{N}\sum_{i=1}^{N}\mathcal{L}\left(\mathbf{F};( \mathbf{x}_{i},\mathbf{y}_{i})\right),\\ \text{s.t.}\ \ \mathrm{Card}(\mathbf{F})\leq\kappa,\end{split} \tag{2}\]
where \(\mathcal{L}(\cdot)\) is the loss function (e.g., cross-entropy loss) and \(\mathcal{D}=\left\{(\mathbf{x}_{i},\mathbf{y}_{i})\right\}_{i=1}^{N}\) is a dataset. \(\mathrm{Card}(\cdot)\) is the cardinality of the filter set, and \(\kappa\) is the target sparsity level such as the number of remaining nonzero filters.
### _Weight-Dependent_
Weight-dependent criteria evaluate the importance of filters based on the weights of filters. Compared to activation-based methods, weight-dependent methods do not involve input data. As such, weight-dependent methods are considered straightforward and require lower computational costs. There are two subcategories of weight-dependent criteria: **filter norm** and **filter correlation**. Calculating the norm of a filter is done independently of the norm of other filters, while calculating filter correlation involves multiple filters.
#### 2.1.1 Filter Norm
In contrast to unstructured pruning which uses the magnitude of the weights as the metric, structured pruning computes the filter norm values to be the metric. The \(\ell_{p}\)-norm of a filter can be written as:
\[\left\|\mathbf{F}^{l}_{i}\right\|_{p}=\sqrt[]{\sum_{n=1}^{N_{l}}\sum_{k_{1}=1 }^{K_{l}}\sum_{k_{2}=1}^{K_{l}}\left|\mathbf{F}^{l}_{i}\left(n,k_{1},k_{2} \right)\right|^{p}}, \tag{3}\]
where \(i\in N_{l+1}\) represents the \(i\)-th filter in \(l\)-th layer, \(N_{l}\) is the input channel size, and \(K_{l}\) is the kernel size. \(p\) is the order of the norm, and the most common norms are \(\ell_{1}\)-norm (Manhattan norm) and \(\ell_{2}\)-norm (Euclidean norm).
Pruning Filter for Efficient ConvNets (PFEC) [13] first computes the importance of filters based on \(\ell_{1}\)-norm. Li _et al._ consider filters with smaller norms to have a weak activation and contribute less to the final classification decision [13].
Soft Filter Pruning (SFP) [115] empirically finds that \(\ell_{2}\)-norm works slightly better than \(\ell_{1}\)-norm. This is discussed further in Section 2.5.1.
#### 2.1.2 Filter Correlation
Filter Pruning via Geometric Median (FPGM) [51] reveals the "smaller-norm-less-important" assumption to not always be true, based on the real distribution of the neural networks. Instead of pruning away unimportant filters, it finds redundant filters by exploiting relationships among filters of the same layer. He _et al._ consider the filters close to the geometric median to be redundant because they represent common information shared by all filters in the same layer [51]. These redundant filters can be removed without significantly influencing the performance.
RED [52] uses a data-free structured compression method. It consists of three steps. First, scalar hashing is conducted on weights in each layer. Second, redundant filters are merged based on the relative similarity of the filters. Third, a novel uneven depthwise separation technique is used to prune layers. In RED++ [53], the third step is replaced with an _input-wise splitting_ technique to remove redundant operations such as multiplication and addition. The reason behind this is that mathematical operations are more of a bottleneck compared to memory allocation.
Unlike FPGM [51], which measures filter importance within layers, Correlation-based Pruning (COP) [54] compares the importance of the cross-layer filters. To determine the redundancy among filters within a layer, COP [54] first conducts a Pearson correlation test. Next, a layer-wise max-normalization is used to address the scaling effect of the correlation-based importance metric in order to rank the filters across layers. Lastly, a cost-aware regularization term is added to the global filter-importance calculation to allow users to have finer control over the budget.
Structural Redundancy Reduction (SRR) [55] exploits the structural redundancy by looking for the most redundant
\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline Papers & P. & Q. & D. & KD & NAS \\ \hline
[23, 34, 35] & & ✓ & & & \\ \hline
[24, 36] & & & & ✓ & & \\ \hline
[25, 37, 38, 39] & & & & & ✓ & \\ \hline
[27, 28, 29, 30, 31, 32, 33] & ✓ & & & & \\ \hline
[40, 41] & ✓ & ✓ & & & & \\ \hline
[42, 43, 44, 45] & ✓ & ✓ & ✓ & ✓ & \\ \hline
[26, 46, 47, 48, 49, 50] & ✓ & ✓ & ✓ & ✓ & ✓ \\ \hline \hline \end{tabular}
\end{table} TABLE I: Categorize existing surveys into Pruning (P), Quantization (Q.), Decomposition (D.), Knowledge Distillation (KD), and Neural Architecture Search (NAS).
layer, instead of the least ranked filters among all layers. First, filters in each layer are established as a graph. The redundancy of a graph can be evaluated by its two associated properties, i.e., quotient space size and \(\ell\)-covering number. The two properties with large values indicate a complex, and hence less redundant, graph. Within the most redundant layer, a filter norm can be applied to prune the least important filters. Finally, the graph of the layer is is re-established, and the layers' redundancy is re-evaluated.
Fig. 1: Taxonomy for structured pruning.
### _Activation-Based_
Activation maps are the convolutional results of input data and filters (Eq. 1). Apart from using the weights of filters, activation maps can be used for filter pruning. Activation channel pruning is another name for filter pruning since removing the channels of activation maps is equivalent to removing the filters. In addition to the effect of the current layer, filter pruning also influences the next layer's filter through feature maps.
To evaluate filters in layer \(l\), we can exploit the information on activation maps of:
1. **the current layer** - the channel importance can be evaluated by using the reconstruction error [58], the decomposition of the activation map [59], utilization of channel-independence [61], and post-activations [62, 63];
2. **the adjacent layers** - redundant channels can be effectively identified by exploiting the dependency between the current layer and the next layer [66, 67]. In addition, activation maps of the previous layer can also be utilized to guide the pruning decision [123, 124];
3. **all layers** - the holistic effect of removing a filter can be evaluated by minimizing the construction error of the Final Response Layer [69] and considering the discriminative power of all layers [70].
#### 2.2.1 Current Layer
Channel Pruning (CP) [58] uses layer \(l\)'s (current) activation maps to guide the pruning of layer \(l\)'s filters. It models layer-wise channel pruning as an optimization problem that minimizes the reconstruction error of sparse activation maps. Solving the optimization problems involve two alternating steps. (1) To find which channels to prune, CP explicitly solves the LASSO regression by fixing the weights rather than imposing a sparsity regularization to training loss. (2) To minimize the reconstruction error of layer \(l\)'s feature map, weights are fine-tuned with the fixed pruning decision.
HRank [59] uses the average rank of the current layer's activation maps from a small set of input data as the filter importance. An important finding is that regardless of the data received, a single filter generates activation maps with the same average rank. To find the average rank, the Singular Value Decomposition (SVD) is adopted. The decomposition conducted here is to find the rank rather than to reduce computational cost. After determining the average rank, a layer-wise pruning algorithm is then proposed to retain top-\(k\) filters.
Coreset-Based Compression (CBC) [60] adopts filter pruning to pre-process filters for coreset-based compression [225]. The scoring of the filters is based on the mean of activation norms over the entire training set. A binary search is then used to find the smallest number of filters that satisfy the accuracy constraint. After pruning, three coreset-based compression techniques are discussed, including \(k\)_-Means, Structured Sparse PCA, and Activation-Weighted coresets_. By using Deep Compression [1], _Activation-Weighted coresets_ outperforms the rest.
CHannel Independence (CHIP) has been used by Sui _et al._ to evaluate channel importance [61]. Channel independence is determined by the cross-channel correlation, indicating whether a channel is linearly dependent on other channels. The greater the independence of the channel, the higher its importance. Channel importance is determined by measuring the activation maps' nuclear norm change.
Average Percentage of Zero (APoZ) [62] utilizes the current layer's **post-activation** maps, which are the activation maps after activation functions such as ReLU. The _average percentages of zeros (APoZ)_ in the post-activation maps are used to measure the importance of channels. A small _APoZ_ value means that most parts of the activation maps are being activated, so these activation maps contribute more to the final results and are more important.
DropNet [63] utilizes the post-activation maps' **average magnitude** as the metric. Under this metric, a small non-zero activation value, which is considered important by APoZ [62], is no longer important in DropNet [63]. There are two reasons for the use of this metric. First, a small **average magnitude** indicates the presence of many inactive nodes. Second, the small magnitude also means these nodes are less adaptive to learning.
#### 2.2.2 Adjacent Layer
ThiNet [66] uses layer \(l+1\)'s (the next layer) activation maps to guide the pruning of the layer \(l\) (the current layer). The main idea is to approximate layer \(l+1\)'s activation maps with **subsets** of layer \(l\)'s activation maps. Channels outside these subsets are pruned. To find these subsets, a greedy algorithm is proposed. Specifically, the algorithm greedily adds channels to an initially empty set and measures the reconstruction error. Subsets that have the least reconstruction error and meet the sparsity constraint will be selected.
Approximated Oracle Filter Pruning (AOFP) [67] uses layer \(l+1\)'s activations and targets at pruning without heuristic knowledge which is often required by _Oracle Pruning_ methods [13, 62, 95]. **Firstly**, the concept of _damage isolation_ is introduced to avoid using heuristic importance metrics. _Damage isolation_ refers to the isolation of the damage caused by pruning layer \(l\) by layer \(l+1\), rendering it invisible to \(l+2\). **Secondly**, a multi-path framework is used to benefit from parallel scoring and fine-tuning. **Thirdly**, the _binary filter search_ method is used to solve problems of the multi-path framework.
In addition to using the next layer's activation maps, runtime neural pruning (RNP) [123] and feature boosting and suppression (FBS) [124] utilize the layer \(l-1\)'s (previous layer) activation maps to guide the pruning of the current layer. Both methods use the global average pooling result of the previous layer as the filter importance. This is further discussed in Section 2.5.2, since both methods conduct dynamic inference pruning.
#### 2.2.3 All Layer
Despite the success of existing methods, proponents of Neuron Importance Score Propagation (NISP) [69] argue that most methods did not consider the reconstruction error propagation. NISP proposes to use the _Final Response Layer (FRL)_ to determine the neuron importance because reconstruction errors from all previous layers will eventually be propagated to the _FRL_. Initially, the importance score of _FRL_ can be determined by any feature ranking technique, i.e., Inf-FS [226]. The neuron importance is then propagated
backward from \(\mathit{FRL}\) to the previous layers. Lastly, neurons with low importance scores in the layer are pruned. Pruned neurons will no longer back-propagate scores to the previous layers.
Discrimination-aware Channel Pruning (DCP) [70] aims to keep discriminative channels that substantially change the final loss in their absence. However, pruning shallow layers often triggers a smaller decrease in final loss due to the long propagation path. To resolve the problem, Zhuang _et al._ introduce discrimination-aware losses to every last layer of the intermediate layers. A greedy algorithm is then used to select channels based on the discrimination-aware loss and reconstruction loss between the baseline and pruned networks.
### _Regularization_
Regularization can be used for learning structured sparse networks by adding different sparsity regularizers \(R_{s}(\cdot)\). The sparsity regularizer can be applied to **BN parameters** if the networks contain batch normalization layers. To achieve structured sparsity, BN parameters are used to indicate the pruning decision of structures such as channels or filters. **Extra parameters** working as learnable gates have been introduced to guide pruning. With these extra parameters, networks no longer require batch normalization layers. Sparsity regularizers can also be directly applied to **filters**. Group Lasso regularization is commonly used to sparsify filters in a structured manner.
The general Group Lasso is defined as the solution to the following convex optimization problem [31],
\[\min_{\beta\in\mathbb{R}^{p}}\left(\left\|\mathbf{y}-\sum_{g=1}^{G}\mathbf{X }_{\mathbf{g}}\beta_{g}\right\|_{2}^{2}+\lambda\sum_{g=1}^{G}\sqrt{n_{g}} \left\|\beta_{g}\right\|_{2}\right) \tag{4}\]
where the feature matrix is divided into \(G\) groups, forming the matrix \(\mathbf{X}_{g}\) that contains only examples of group \(g\) as well as the corresponding coefficient vector \(\beta_{g}\). \(n_{g}\) indicates the size of group \(g\), and \(\lambda\geq 0\) is a tuning parameter. In the context of filter pruning, the first term can be viewed as the reconstruction error of the feature map, and the second term can be rewritten as:
\[\lambda\left\|\mathbf{F}^{l}\right\|_{2,1}=\lambda\sum_{i=1}^{N_{l+1}}\left\| \mathbf{F}_{i}^{l}\right\|_{2} \tag{5}\]
where groups \(G\) are replaced by output channels \(N_{l+1}\), and coefficients vectors \(\beta_{g}\) are replaced by filters. In addition, differences exist among the use of \(\ell_{1}\)-norm, \(\ell_{2}\)-norm and \(\ell_{2,1}\)-norm as the penalty function (Fig. 2).
#### 2.3.1 Regularization on BN Parameters
BN layers have been widely used in many modern CNNs to improve model generalization. By normalizing each training mini-batch, the internal covariate shift is addressed. The following describes the operations of a BN layer (NS [73]),
\[\hat{\mathbf{z}}=\frac{\mathbf{z}_{\mathrm{in}}-\mu_{\mathcal{B}}}{\sqrt{ \sigma_{\mathcal{B}}^{2}+\epsilon}};\quad\mathbf{z}_{\mathrm{out}}=\gamma \hat{\mathbf{z}}+\beta \tag{6}\]
where \(N_{l+1}\)-dimension \(\mathbf{z}_{\mathrm{in}}\) and \(\mathbf{z}_{\mathrm{out}}\) are the inputs and outputs of a BN layer, \(\mu_{\mathcal{B}}\) and \(\sigma_{\mathcal{B}}\) are the mean and standard deviation over the current mini-batch \(\mathcal{B}\). \(\epsilon\) is a small number to prevent zero-division. \(\gamma\in\mathbb{R}^{N_{l+1}}\) and \(\beta\in\mathbb{R}^{N_{l+1}}\) are the learnable parameters, indicating scale and shift, respectively. BN parameters are used as gates for filter pruning because the number of learnable parameters is equal to the number of feature maps and filters.
Network Slimming (NS) [73] directly uses the scaling parameter \(\gamma\) in BN to control output channels. The channel-level sparsity-induced \(\ell_{1}\) regularization is then introduced to jointly train the weights together with the \(\gamma\). After training, the corresponding channels that have close-to-zero \(\gamma\) are pruned. To optimize the non-smooth \(\ell_{1}\) penalty term, a subgradient descent [228] is used.
Similar to the situation in NS [73], Gated Batch Normalization (GBN) [74] uses \(\gamma\) as the channel-wise gate and \(\ell_{1}\)-norm of \(\gamma\) as the regularization term. A _Tick-Tock_ pruning framework is proposed to boost accuracy by iterative pruning. The _Tick_ phase trains the network with little data, and only the gates and final linear layer are allowed to be updated during training for one epoch. Meanwhile, channel importance is computed by the first-order Taylor Expansion for a global filter ranking. The _Tock_ phase then fine-tunes the sparse network with sparsity constraints.
Polarization Regularization (PR) [75] provides a variant \(\ell_{1}\)-based regularizer to polarize the scaling factors \(\gamma\). It contends that in the majority of the sparsity regularization methods, such as NS [73], a naive \(\ell_{1}\) regularizer converges all scaling factors to zero indiscriminately. A more reasonable approach is to push the scaling factors of unimportant neurons to zero and those of important neurons to a large value. To achieve the polarization effect, another penalty term is added to the naive \(\ell_{1}\) term, separating \(\gamma\) from their mean as far as possible. Similar to NS [73], subgradients [228] are used on non-differentiable points to solve the non-smooth regularizer.
Rethinking Smaller-Norm-Less-Informative (RSNLI) [76] is developed from the basis of previous methods tending to suffer from the Model Reparameterization problem and the Transform Invariance problem. As there are doubts whether smaller-norm parameters are less informative; Ye _et al._ propose to train with ISTA [229] to enforce sparsity on \(\gamma\). The channel whose \(\gamma\) is equal to zero is pruned. Then the \(\gamma-W\) rescaling trick is used on \(\gamma\) and weights to quickly start the sparsification process.
Operation-aware Soft Channel Pruning (SCP) [77] considers both BN and ReLU operations. In contrast to NS [73] making decision merely on the channel scaling \(\gamma\), Kang _et al._
Fig. 2: The left image shows the \(\ell_{1}\) penalty used in Lasso. The middle image shows the \(\ell_{2,1}\) penalty function used in Group Lasso, and the right image shows the \(\ell_{2}\) penalty function used in Ridge. \(\beta_{11}\) and \(\beta_{12}\) are grouped together for Group Lasso. (The image is taken from [227].)
also consider shifting parameters \(\beta\). Specifically, channels with large negative \(\beta\) and large \(\gamma\) are considered unimportant since these channels will become zero after ReLU. To account for BN's large negative mean values, the cumulative distribution function (CDF) of a Gaussian distribution parameterized by \(\beta\) and \(\gamma\) is used as the indicator function. To optimize \(\beta\) and \(\gamma\), a sparsity-loss-inducing large CDF value is designed to encourage the network to be more sparse.
EagleEye [78] proposes a three-stage pipeline. **First**, pruning strategies (i.e., layer-wise pruning ratio) are generated by simple random sampling. **Second**, sub-networks are generated according to the pruning strategies and \(\ell_{1}\)-norm of filters. **Third**, an _adaptive-BN-based candidate evaluation module_ is used to evaluate the performance of the sub-networks. Li _et al._ contend that outdated BN statistics are unfair to sub-network evaluations, and that BN statistics for every candidate should be re-calculated on a small part of the training dataset [78]. After sub-networks are evaluated with the _adaptive BN statistics_, the best-performing one is selected as the final pruned model.
#### 2.3.2 Regularization on Extra Parameter
Although some studies [74, 76] make special adjustments for networks without BN layers, introducing extra parameters is a more general solution. The extra parameters \(\theta\) are trainable and parameterize the gates \(g(\theta)\) in determining the pruning results.
To find a sparse structure, Sparse Structure Selection (SSS) [79] attempts to force the output of structures to zero. A scaling factor \(\theta\) is introduced after each structure, i.e., neuron, group or residual block. When \(\theta\) is lower than a threshold, the corresponding structure is removed. The gate \(g(\theta)\) function is:
\[g(\theta)=\begin{cases}0,&\theta<\text{Threshold}\\ 1,&\text{otherwise}\end{cases}. \tag{7}\]
It adopts a convex relaxation \(\ell_{1}\)-norm as the sparsity regularization on the extra parameter \(\theta\). To update \(\theta\), a modified Accelerated Proximal Gradient [230] is used.
Generative Adversarial Learning (GAL) [80] jointly prunes structures and adopts a Generative Adversarial Network (GAN) to achieve label-free learning. Extra scaling factors are introduced after each structure in the generator, forming soft masks. During training, a special regularization term that contains three regularizers is proposed: 1) a \(\ell_{2}\) weight decay regularizer on generators, 2) a \(\ell_{1}\) sparsity regularizer on the mask, and 3) an _adversarial regularization_ on discriminator. Furthermore, FISTA [229] is used to iteratively update the generator and discriminator, and the mask is updated together with the generator.
Discrete Model Compression (DMC) [81] explicitly introduces discrete (binary) gates after the feature map to precisely reflect the pruned channels' impact on the loss function. First, it samples subnetworks with stochastic discrete gates:
\[g(\theta)=\begin{cases}1,&\text{w.p. }\theta\\ 0,&\text{w.p. }1-\theta\end{cases} \tag{8}\]
where w.p. stands for "with probability". The stochastic nature of the gate ensures that every channel has the chance to be sampled if \(\theta\neq 0\), so different subnetworks can be produced. To update the non-differentiable binary gates, a Straight-Through Estimator [231] is adopted.
Similar to PR [75], Gates with Differentiable Polarization (GDP-Guo) [82] aims to polarize gates. Designing a gate with a polarization effect yields the property of smoothed \(\ell_{0}\) formulation [232]:
\[g(\theta)=\frac{\theta^{2}}{\theta^{2}+\epsilon}\xrightarrow{\text{has property}}\quad g(\theta)=\begin{cases}\approx 1,&\theta\neq 0\\ =0,&\theta=0\end{cases} \tag{9}\]
where \(\epsilon\) is a small positive value to prevent zero division. This property polarizes \(\theta\) to either exactly \(0\) or values close to \(1\). The gate itself is differentiable. However, the sparsity regularization on \(\theta\) involves \(\ell_{0}\)-norm and renders the objective function non-differentiable. Thus, proximal-SGD [233] is used to update \(\theta\).
Convolutional **Re-**parameterization and Gradient **Res**etting (ResRep) [83] re-parameterizes a CNN into two parts. The first "remembering part" learns to maintain the model's performance and will not be pruned. The second "forgetting part" inserts \(1\times 1\) CONV layers, or the _compactors_, after the BN layers. During training, a modified SGD update rule is applied to update the _compactors_ only. Thus, only _compactors_ are allowed to forget (forgetting) while other CONV layers are kept untouched (remembering).
Scientific Control Pruning (SCOP) [84] believes that the importance of a filter may be disturbed by _potential factors_ such as input data. For example, the filter importance ranking may vary if input data is slightly changed for data-dependent methods. To minimize the effect of _potential factors_, it prunes under scientific control by creating knockoff counterparts [234]. Knockoff features are identical to the real features except for not knowing the true label. Two introduced scaling factors \(\theta\) and \(\tilde{\theta}\) are then introduced to control the participation of real and knockoff features, respectively. The two parameters are complementary that \(\theta+\tilde{\theta}=\mathbf{1}\). If \(\theta\) cannot suppress \(\tilde{\theta}\), the real features are deemed to have little or no association with the true output. Thus, the filter importance score is defined as \(\mathcal{I}=\theta-\tilde{\theta}\), and filters with small importance scores are deemed redundant.
To directly control the model budget, Budget-Aware Regularization (BAR) [85] uses a prior loss and introduces a learnable dropout parameter \(\theta\)[235]. The prior loss is the product of two functions. The first function is an approximation of budgets, that is differentiable w.r.t. \(\theta\). The second function is a variant log-barrier function [236] that employs a sigmoidal schedule. The novel objective function consists of the prior loss, enabling simultaneous training and pruning according to the budget. Knowledge distillation is then used to improve accuracy.
#### 2.3.3 Regularization on Filters
Structured Sparsity Learning (SSL) [91] uses Group Lasso to prune channels. Removing layer \(l^{\prime}\)s channel will cause the removal of layer \(l^{\prime}\)s filters and layer \(l+1\)'s input channels. Hence, it adds two separate regularization terms for filter-wise and channel-wise pruning:
\[\sum_{n_{l}=1}^{N_{l+1}}\left\|\mathbf{W}_{n_{l},...,..}^{(l)}\right\|_{2}, \qquad\sum_{c_{l}=1}^{N_{l}}\left\|\mathbf{W}_{:c_{l},..,..}^{(l)}\right\|_{2}, \tag{10}\]
where \(\mathbf{W}^{(l)}\in\mathbb{R}^{N_{l+1}\times N_{l}\times K_{l}\times K_{l}}\).
Out-In-Channel Criterion Regularization (OICSR) [92] uses Group Lasso to **jointly** regularize filters that work cooperatively. The regularization term is:
\[\sum_{i=1}^{N}\left\|\mathbf{W}^{(l)}_{i,:}\oplus\mathbf{W}^{(l+1)}_{,:}\right\| _{2} \tag{11}\]
where \(\oplus\) denotes concatenation of the out-channel filters \(\mathbf{W}^{(l)}_{i,:}\in\mathbb{R}^{N_{l+1}\times(N_{l}K_{l})}_{i,:}\) and the in-channel filters \(\mathbf{W}^{(l+1)}_{:,i}\in\mathbb{R}^{(N_{l+2}K_{l+1}K_{l+1})\times N_{l+1}}\). It uses the premise that out-channel filters of layer \(l\) are interdependent of in-channel filters of layer \(l+1\), so these filters should be regularized together.
Only Train Once (OTO) [93] contends that even if all filters weights are zeros, the activations will be non-zero because of three parameters: 1) convolution bias, 2) BN mean, and 3) BN variance. Instead of grouping only filters, this method groups all parameters that cause a non-zero activation into a group named the zero-invariant group. Structured sparsity is then introduced to this group by applying the mixed \(\ell_{1}/\ell_{2}\)-norm. To solve the non-smooth mixed-norm regularization, a stochastic optimization algorithm named _Half-Space Stochastic Projected Gradient_ is used.
Growing Regularization (GREG) [94] exploits regularization under a growing penalty and uses two algorithms. The **first algorithm** focuses on the pruning schedule and adopts \(\ell_{1}\)-norm [13] to obtain a mask for pruning. Instead of immediately removing unimportant filters, a growing \(\ell_{2}\) penalty is used to gradually drive them to zero. The **second algorithm** uses a growing regularization to exploit the underlying Hessian information. The authors observe weight discrepancy increases as the regularization parameter increases, then weights will naturally separate. If the discrepancy is large enough, even a simple \(\ell_{1}\)-norm can be an accurate criterion.
### _Optimization Tools_
#### 2.4.1 Taylor Expansion
Taylor Expansion [237] expands a function into the Taylor Series which is an infinite sum of terms. The Taylor Expansion of a function \(f(x)\) expands at some point \(a\):
\[f(x)=\overbrace{f(a)+\frac{f^{\prime}(a)}{1!}(x-a)}^{\text{second-order approximation}}+\frac{f^{\prime\prime}(a)}{2!}(x-a)^{2}+\underbrace{R_{2}(x)}_{\text{reminders}}, \tag{12}\]
where \(f^{\prime}(\cdot)\) and \(f^{\prime\prime}(\cdot)\) is the first-order derivative and second-order derivative with respect to \(x\), respectively.
In structured pruning, Taylor Expansion is used to approximate the change in the loss \(\Delta\mathcal{L}\) of pruning structures such as filters or channels. Since pruned weights are set to 0, the loss function \(\mathcal{L}(w)\) of weights \(w\) can be evaluated at \(a=0\) using Taylor Expansion. By manipulating Eq. 12, we can get
\[\mathcal{L}(w)-\mathcal{L}(0)=\frac{\mathcal{L}^{\prime}(0)}{1!}(w-0)+\frac{ \mathcal{L}^{\prime\prime}(0)}{2!}(w-0)^{2}+R_{2}(w). \tag{13}\]
Let \(\mathcal{L}(w)-\mathcal{L}(0)=\Delta\mathcal{L}\) be the change in the loss of removing some weights, and \(w-0=\Delta w\) be the change in the weights. We can get the following equation based on [98],
\[\Delta\mathcal{L}=\frac{\partial\mathcal{L}^{\top}}{\partial w}\Delta w+\frac{ 1}{2}\Delta w^{\top}\mathbf{H}\Delta w+R_{2}(w) \tag{14}\]
where \(\frac{\partial\mathcal{L}}{\partial w}\) is the first-order gradient of loss function w.r.t. weights, and \(\mathbf{H}\) is the Hessian matrix containing second-order derivatives. Compared to regularization-based methods, pruning with Taylor Expansion does not need to wait until the activations are trained sufficiently small [96].
First-order and second-order Taylor expansions have their own characteristics. The second-order expansion contains more information, but it requires calculating the second-degree derivatives that are computationally prohibitive. On the contrary, the first-order expansion can be obtained from backpropagation without requiring additional memory, but this provides less information.
**First-order-Taylor:** Mol-16 [95] uses the first-order information to estimate the change in the loss of pruning activation maps. The higher-order remainders, including the second-order term, are discarded since they are computationally intractable and are encouraged to be small by the widely-used ReLU activation function. Thus, the absolute change in loss approximated by the first-order term is used as the metric for feature map importance:
\[\left|\frac{1}{M}\sum_{m}\frac{\partial\mathcal{L}}{\partial z_{m}}z_{m}\right|, \tag{15}\]
where \(M\) is the length of a flattened feature map and \(z\) is an activation in a feature map. After determining the feature map importance, the lowest ranked maps will be pruned.
Compared to Mol-16 [95] which fails with skip connections, Mol-19 [96] proposes a more general method that uses Taylor expansion to approximate the squared change in the final loss. Unlike Mol-16's [95] use of activations that increase memory consumption, Mol-19 [96] computes the importance \(\mathcal{I}\) based on weights:
\[\mathcal{I}_{\mathcal{S}}(\mathbf{W})\triangleq\sum_{s\in\mathcal{S}}\left( \frac{\partial\mathcal{L}}{\partial w_{s}}w_{s}\right)^{2}, \tag{16}\]
where \(\mathcal{S}\) is a structural set of parameters such as a convolutional filter, \(w_{s}\) is the individual weight of the filter, and \(\frac{\partial\mathcal{L}}{\partial w_{s}}\) represents the gradient. The first-order expansion performs significantly faster than the second-order expansion with a slightly higher accuracy drop.
Due to the simplicity and efficiency of computing, the first-order expansion is widely adopted by many methods such as GBN [74] and GDP-Lin [116] which are discussed in other sections.
**Second-order-Taylor:** In this sub-section, the Hessian matrix \(\mathbf{H}\) that contains second-order information from Eq. 14 is exploited. First, pioneering unstructured studies are briefly introduced. Second, the structured pruning methods are addressed.
**Pioneering unstructured studies:** Most current structured pruning methods that use second-order Taylor expansion are based on two pioneering studies on unstructured pruning: Optimal Brain Damage (OBD) [238] and Optimal Brain Surgeon (OBS) [239]. OBD [238] assumes that \(\mathbf{H}\) is
diagonal to ease computation. The diagonal \(\mathbf{H}\) is then used to compute the parameter importance. However, OBS [239] finds that most of the Hessian matrices \(\mathbf{H}\) are strongly non-diagonal. Thus, the full \(\mathbf{H}\) is used and the parameter importance is calculated by \(\mathbf{H}^{-1}\).
**Structured pruning methods**: With the success of OBD [238] and OBS [239] in unstructured pruning, the second-order expansion is applied to structured pruning. As deep CNNs have millions of parameters, computing and storing the Hessian \(\mathbf{H}\) become challenging [97]. Recent methods aim to approximate the Hessian matrix for structured pruning.
Collaborative Channel Pruning (CCP) [97] approximates the Hessian matrix by only using the first-order derivative of a pre-trained model. The first-order information can be retrieved from backpropagation, and no additional storage is needed. In addition, Peng _et al._ exploit the effect of removing multiple channels instead of a single channel. The non-diagonal element in \(\mathbf{H}\) reflects the interaction between two channels and hence exploits the inter-channel dependency. CCP models the channel selection problem as a constrained 0-1 quadratic optimization problem to evaluate the joint impact of pruned and unpruned channels.
Eigen Damage (ED) [98] introduces a baseline method that is the naive structured extension of OBD [238] and OBS [239]. Two algorithms are then applied to improve the baseline method. The **baseline method** sums up the individual change in parameters over a filter, raising the granularity to the filter level. However, computing and storing the Hessian \(\mathbf{H}\) is intractable. Wang _et al._ propose the use of the **first algorithm**[98] that applies K-FAC [240] approximation to decompose filters. As the naive extensions and the first algorithm both fail at capturing the correlation between filters, a **second algorithm** which decorrelates the weights before pruning is applied. This second algorithm adopts K-FAC [240] and projects weight space to a Kronecker-Factored eigenspace (KFE) [241] where there is little correlation.
Group Fisher Pruning (GFP) [99] addresses the difficulties other pruning methods face when channels from multiple layers are coupled and need to be pruned simultaneously. First, a layer grouping algorithm is used to automatically identify coupled channels. Second, the Hessian information is used as a unified importance criterion of a single channel and coupled channels. With the help from the Fisher information, the Hessian matrix is transformed into the square of first-order derivatives.
Hessian-Aware Pruning (HAP) [100] uses the Hessian information to measure the sensitivity of channels, and the average Hessian trace to approximate the Hessian. This approximation costs the same as backpropagating gradients [242]. The moderately sensitive channels are replaced with efficient low-rank decomposition, rather than removed. The premise behind this is when insensitive channels are pruned, moderately sensitive channels will be critical to the final accuracy.
Second-Order Structured Pruning (SOSP) [101] proposes two methods, SOSP-I and SOSP-H, to approximate the \(\mathbf{H}\). SOSP-I is based on the Gauss-Newton approximation [243] which uses first-order information. SOSP-H uses a fast Hessian-vector product approximation to enable saliency evaluation. SOSP-H considers the full Hessian matrix and has the complexity of first-order methods. Both SOSP-I and SOSP-H perform similarly while the latter scales better on large-scale vision tasks.
#### 2.4.2 Variational Bayesian
Bayesian inference [244] is a method to infer the posterior probability distribution \(p(\theta|x)\) with the known prior probability distribution \(p(\theta)\) of parameters \(\theta\) and the observed data \(x\). The formula to compute the posterior distribution over \(\theta\) is given:
\[\widehat{p(\theta|x)}=\underbrace{\overbrace{p(x|\theta)}^{\text{Likelihood}} \cdot\overbrace{p(\theta)}^{\text{Prior}}}_{\text{Evidence}},\text{where }p(x)=\int p(x|\theta)p(\theta)d\theta. \tag{17}\]
However, computing the evidence often requires computationally intractable integrals when large amounts of data are involved. Variational Bayesian (VB) methods [245] are used to approximate the posterior distribution \(p(\theta|x)\) by a variational distribution \(q(\theta)\). Specifically, \(q(\theta)\) is optimized by minimizing the Kullback-Leibler (KL) divergence which measures the "similarity" between \(q(\theta)\) and \(p(\theta|x)\). Since the computation of KL-divergence involves the intractable posterior distributed \(p(\theta|x)\), the optimization problem is solved by equivalent conversion to maximize the Evidence Lower BOund (ELBO).
Variational Pruning (VP) [102] is based on channel importance being indicated by random variables, as pruning by deterministic channel importance is inherently improper and unstable. Thus, BN's parameter \(\gamma\) is used to indicate the channel saliency and model \(\gamma\) by Gaussian distribution \(\mathcal{N}\left(\mu,\sigma\right)\). To introduce sparsity, VP utilizes the centrality property of the Gaussian distribution \(\mathcal{N}\) and samples \(\gamma\) from \(\mathcal{N}\left(\mu=0,\sigma\right)\) as the sparse prior distribution. After optimizing ELBO, distributions of \(\gamma\) with close-to-zero mean and small variance are considered safe for pruning, since such distributions are less likely to have salient parameters.
To find redundant channels, Recursive Bayesian Pruning (RBP) [103] targets the posterior of redundancy which assumes an inter-layer dependency among channels. First, each input channel is scaled by a dropout noise \(\theta\)[235, 246] with a dropout rate \(r\). Second, the dropout noises are then modeled across layers as a Markov chain to exploit the inter-layer dependency among channels. To get the posterior of redundancy, a sparsity-inducing Dirac-like prior is chosen. In addition, RBP [103] adopts the reparameterization trick [235] to scale the noise \(\theta\) on the corresponding channels to consider data fitness. As a result, the dropout rate \(r\) can be updated along with weights in a gradient-based manner. Pruning is conducted by setting the corresponding channels to zero when \(r\) is greater than a threshold.
A few other studies also use the Bayesian point of view. VIBNet [104] uses a _variational information bottleneck_, which is the informational theoretical measure of redundancy between adjacent layers. Louizos _et al._[105] utilize the horseshoe prior to efficiently approximate channel redundancy. Neklyudov _et al._[106] use a log-normal prior, resulting in a tractable and interpretable log-normal posterior.
#### 2.4.3 Others
**SGD-based:** Instead of zeroing out filters, Centripetal SGD (C-SGD) [107] makes redundant filters identical and merges identical filters into one filter. Regularized Modernized Dual Averaging (RMDA) [108] adds momentum to the RDA algorithm [247] and ensures that the trained model has the same structure as the original model. To prune the model, RMDA adopts Group Lasso to promote structured sparsity.
**ADMM-based:** Alternating Direction Method of Multipliers (ADMM) [248] is an optimization algorithm used to decompose initial problem into two smaller, more tractable subproblems. StructADMM [111] studies the solution of different types of structured sparsity such as filter-wise and shape-wise. Zhang _et al._ use a progressive and multi-step ADMM framework: at each step, it uses ADMM to prune and masks out zero weights, leaving the remaining weights as the optimization space for the next step.
**Bayesian Optimization:** Bayesian optimization (BO) [249] is a sequential design strategy for global optimization of black-box functions that does not assume any functional forms. When pruning a model which involves an extremely large design space, the curse of dimensionality problem occurs [250]. Rollback [113] adopts the RL-style automatic channel pruning [130] and uses BO to determine the optimal pruning policy.
**Soft Threshold:** Soft threshold [251] is a de-noising operator in the area of digital signal processing. Soft Threshold Reparameterization (STR) [114] adopts this operator to learn non-uniform sparsity budget across layers that is optimized per-layer.
### _Dynamic Pruning_
Dynamic pruning can be conducted during training and inference. **Dynamic during training** aims to preserve the models' representative capacity by maintaining a dynamic pruning mask during training. It is also called soft pruning to ensure that improper pruning decisions can be recovered later. On the other hand, hard pruning permanently removes weights with a fixed mask. **Dynamic during inference** indicates networks are pruned dynamically according to different input samples. For instance, a simple image that contains clear targets requires less model capacity compared to a complex image [108]. Hence, dynamic inference provides better resource-accuracy trade-offs.
#### 2.5.1 Dynamic during Training
**Weight-level dynamic:** The concept of training-time dynamic pruning was first introduced in Dynamic Network Surgery (DNS) [252], an unstructured pruning approach. To clarify the difference between other approaches, its formulation is:
\[\mathbf{W}_{i,j}^{l}\leftarrow\mathbf{W}_{i,j}^{l}-\eta\frac{\partial\mathcal{ L}(\mathbf{W}^{l}\odot\mathbf{T}^{l})}{\partial(\mathbf{W}_{i,j}^{l}\mathbf{T}_{ i,j}^{l})}, \tag{18}\]
where \(\eta\) is the learning rate and \(\odot\) denotes the Hadamard Product operator. \(\mathbf{W}^{l}\) is the weight matrix in the \(l\)-th layer with all weights of kernels unfolded and concatenated together. \(\mathbf{T}^{l}\) is the binary mask that has the same shape as the weight matrix, indicating the importance of the weights. \(\mathcal{L}(\cdot)\) is the loss function. \(\mathbf{W}_{i,j}^{l}\) and \(\mathbf{T}_{i,j}^{l}\) indicate a single element in \(\mathbf{W}^{l}\) and \(\mathbf{T}^{l}\). \(\mathbf{W}\) and \(\mathbf{T}\) are updated alternatively. All the weights are updated, so wrongly pruned parameters have a chance to regrow.
**Filter-level dynamic:** Soft filter Pruning (SFP) [115] adopts the idea of dynamic pruning in a structured way. Its use is based on the premise that hard pruning that uses a fixed mask throughout the training will reduce the optimization space. Therefore, it dynamically generates the masks based on the \(\ell_{2}\)-norm of filters at every epoch. Soft pruning means setting the values of filters to zero instead of removing filters. Previously soft-pruned filters are allowed to be updated at the next epoch, during which masks will be reformed based on new weights. The update rule is:
\[\mathbf{W}^{l}\leftarrow\mathbf{W}^{l}-\eta\frac{\partial\mathcal{L}\left( \mathbf{W}^{l}\odot\mathbf{m}^{l}\right)}{\partial\left(\mathbf{W}^{l}\odot \mathbf{m}^{l}\right)}, \tag{19}\]
where \(\mathbf{W}^{l}\in\mathbb{R}^{N_{l+1}\times N_{l}KK}\) and \(\mathbf{m}^{l}\in\mathbb{R}^{N_{l+1}}\).
Globally Dynamic Pruning (GDP-Lin) [116] also maintains a binary dynamic mask during training based on the filter importance. GDP-Lin adopts the first-order Taylor expansion to approximate the global discriminative power of each filter. In addition, the authors argue that frequently changing masks cannot effectively guide the pruning. Hence, masks are updated every \(e\) iteration, where \(e\) is set as a decreasing value to accelerate the convergence.
In addition to maintaining a sparse dynamic mask, Dynamic Pruning with Feedback (DPF) [117] simultaneously maintains a dense model. The premise behind its use is that a sparse model can be considered a dense model with compression error. The error can be used as feedback to ensure correct direction in the gradient updates. For this goal, gradients computed from the sparse model are used to update the dense model. The advantage of applying gradients on a dense model is that it helps weights to recover from errors.
CHannel EXploration (CHEX) [118] uses two processes to dynamically adjust filter importance. The first process is the channel pruning process with _Column Subset Selection criterion_[253]. The second process is the regrowing process, which is based on _orthogonal projection_[254] to avoid regrowing redundant channels and to explore channel diversity. Regrowing channels are restored to the _most recently used (MRIU)_ parameters rather than zeros. To better preserve model accuracy, the remaining channels are re-distributed dynamically among all the layers.
Dynamic Sparse Graph (DSG) [119] activates a small number of critical neurons with the constructed sparse graph at every iteration dynamically. DSG is developed from the argument that direct computation according to output activations is very costly for finding critical neurons. The _dimension reduction search_ is formulated to forecast the activation output by computing input and filters in a lower dimension. Furthermore, to prevent BN layers from damaging sparsity, Liu _et al._ introduce the _double-mask selection_ that uses the same selection mask before and after BN layers [119].
Other methods such as SCP [77] and DMC [81] also maintain the mask dynamically. These are discussed in Section 2.3.
#### 2.5.2 Dynamic during Inference
Runtime Neural Pruning (RNP) [123] is based on the premise that the static model fails to exploit the different properties of input images by using the same weights for both easier-recognized and complex pattern images. It uses a framework with CNN as the backbone and RNN as a decision network. The network pruning is modeled as a Markov decision process, and models are trained by reinforcement learning (RL). The RL agent evaluates filter importance and performs channel-wise pruning according to the relative difficulty of samples for a task. Thus, when the image is easier for the task, a sparser network is generated.
Feature Boosting and Suppression (FBS) [124] predicts output channel importance based on inputs by introducing a tiny and differentiable auxiliary network. In the auxiliary network, a 2D global average pooling is used to subsample the activation channels in the previous layer to scalars. The advantage of this is that it to reduce the computational overhead in the auxiliary network. A salient predictor then uses the subsampled scalars to generate the predicted saliency scores through a fully connected layer followed by an activation function. The top-\(k\) salient channels are finally involved in the inference-time calculation.
Deep Reinforcement Learning pruning (DRLP) [126] learns both the runtime (dynamic) and the static importance of channels. The runtime importance measures the importance of channels specific to an input. In contrast, the static importance measures the channel importance for the whole dataset. Like RNP [123], DRLP uses reinforcement learning (RL). The RL framework contains two parts: one static and one runtime. Each part contains an importance predictor and an agent, providing static/runtime importance and layer-wise pruning ratio respectively. In addition, a _trade-off pruner_ generates a unified pruning decision based on the outputs from the two parts.
Dynamic Dual Gating (DDG) [127] uses two separate gating modules (spatial and channel gating) to determine inference-time importance according to inputs. The spatial module consists of an adaptive average pooling followed by a 3x3 CONV layer to extract informative spatial features. By having a spatial mask, only informative features are allowed to pass to the next layer. The channel gating module works in a manner similar to existing methods such as FBS [124] by using global average pooling followed by the application of FC layers. To enable gradient flow, the Gumbel-Softmax reparameterization [255] is used for both spatial and channel gating modules.
Fire Together Wire Together (FTWT) [128] models the dynamic pruning task as a self-supervised binary classification problem. The proposed framework use 1) a prediction head to generate learnable binary masks and 2) a ground truth mask to guide the learning after each convolutional layer. The prediction head consists of a global max pooling layer, a 1x1 CONV layer, and a softmax layer. Then the outputs from the prediction head are rounded to generate a binary mask. To achieve self-supervised learning, ground truth binary masks are needed; by ranking the norm of input activations, ground truth pruning decisions are made to guide the learning.
At the same time, Contrastive Dual Gating (CDG) [129] implements another self-supervised dynamic pruning framework by using contrastive learning [256]. Contrastive learning uses transformed images such as flipped images as inputs and uses two contrastive branches to exploit the high-level features. Then a similarity-based contrastive loss [257] is used for gradient-based learning without the labeled data. Empirical studies show that pruning decisions cannot be transferred between contrastive branches. Thus, dual gating is introduced, and the two branches have distinct pruning masks. CDG [129] uses a framework similar to that of CGNet [258] for each contrastive branch. Like DDG [127], a 3x3 CONV layer is used to extract spatial features for unpruned features.
### _Neural Architecture Search_
As it is cumbersome to manually determine pruning-related hyperparameters such as the layer-wise pruning ratio, the Neural Architecture Search (NAS) [25] has been proposed to automatically find pruned structures.
Based on the survey of NAS [25], we categorize NAS for pruning into three methods. NAS can be modeled as:
1. [leftmargin=*]
2. **reinforcement learning (RL) problems**, in which RL agents find sparse subnetworks by searching over the action space such as pruning ratios.
3. **gradient-based methods** that modify the gradient update rule to make optimization problems with sparsity constraints differentiable to weights.
4. **evolutionary methods** that adopt evolutionary algorithms to explore and search the sparse subnetworks.
#### 2.6.1 Reinforcement Learning-Based
AutoML for Model Compression (AMC) [130] uses RL to automatically select the appropriate layer-wise pruning ratio without the manual sensitivity analysis. To search over a continuous action space, the deep deterministic policy gradient (DDPG) algorithm [259] is adopted. The actor receives 11 layer-dependent states such as FLOPS and outputs a continuous action about the pruning ratio. For accuracy-guaranteed pruning, the reward for the DDPG agent is modified from Eq. 20 to Eq. 21:
\[R_{\mathrm{err}}=-Error \tag{20}\] \[R_{\mathrm{FLOPs}}=-Error\cdot\log(\mathrm{FLOPs})\] (21) \[R_{\mathrm{Param}}=-Error\cdot\log(\#\mathrm{Param})\]
Automatic Graph encoder-decoder Model Compression (AGMC) [131] adopts the premise that AMC [130] still requires manual selection of the fixed 11 states fed into the RL agent. In addition, the fixed environment states ignore the rich information within the computational graphs. Hence, the DNNs are modeled as computational graphs and fed into a GCN-based graph encoder-decoder [260] to automatically learn the RL agent's input states. In contrast to AMC [130], AGMC rescales the pruning ratios to compensate for any unmet sparsity constraint rather than applying the FLOPs into the reward function (Eq. 21).
DECORE [132] adopts multi-agent learning. The presence of multiple agents comes from assigning dedicated agents to all channels in a layer, with each agent only learning one parameter representing a binary decision. In contrast to AMC [130] and AGMC [131], DECORE models
the state of the channel itself. To learn the action parameters, a higher reward is given when the accuracy retention task and compression task are both well-completed as shown in Eq. 22.
\[R_{\mathrm{comp.}}^{l}=\sum_{j=1}^{N_{l+1}}1-a_{j}^{l},\quad R_{ \mathrm{acc}}=\left\{\begin{array}{cc}1&\text{if }\hat{y}=y\\ -\lambda&\text{else}\end{array}\right. \tag{22}\] \[R^{l}=R_{\mathrm{comp.}}^{l}*R_{\mathrm{acc}}\]
where \(N_{l+1}\) represents the output channel size of layer \(l\), \(a^{l}\) is the action vector of layer \(l\), \(y\) and \(\hat{y}\) are the true label and predicted label, and \(-\lambda\) is a large penalty for a wrong prediction. The reward function does not consider the FLOPs; instead, the reward for the compression task simply takes into account the number of channels remaining.
GNN-RL [133] first models the DNN into a multi-stage graph neural network (GNN) to learn the global topology. The the generated hierarchical computational graph is then used as the environmental state of the agent. In contrast to AMC [130] and AGMC [131] that both use DDPG, this method uses the Proximal Policy Optimization (PPO) algorithm [261] as the policy since PPO gives a much better experiment result. In addition, due to the specially designed graph environment, the reward for the RL system does not need to contain sparsity constraints. Accuracy is the only metric for the reward described by Eq. 20.
#### 2.6.2 Gradient-Based
To search for the layer-wise sparsity, Differentiable Markov Channel Pruning (DMCP) [136] models channel pruning as a Markov process. Here, the state means retaining the channel during pruning, and transitions between states represent the pruning process. DMCP parameterizes both the transition and budget loss by learnable architecture parameters. The final loss is thus differentiable w.r.t. architecture parameters. To stages are used to finish pruning in a gradient-based manner. The first stage updates weights of unpruned networks with a variant sandwich rule [262]. The second stage updates the architecture parameters.
Differentiable Sparsity Allocation (DSA) [137] optimizes the sparsity allocation in continuous space using a gradient-based method that is more effective than a discrete search. The validation loss is adopted as a differentiable surrogate to render the evaluation of validation accuracy differentiable. Next, a probabilistic differentiable pruning process is used as a replacement for the non-differentiable hard pruning process. Finally, sparsity allocation is obtained under a budget constraint. An ADMM-inspired optimization method [248] is used to solve the constrained non-convex optimization problem.
Differentiable Hyper Pruning (DHP) [138] uses hypernetworks that generate weights for backbone networks. The designed hypernetwork consists of three layers. The **1) the latent layer** first takes two learnable latent vectors \(\{\mathbf{z}^{l}\text{ and }\mathbf{z}^{l-1},\mathbf{z}^{l}\in\mathbb{R}^{N_{l+1}}\}\) and forms the latent matrix. Then **2) the embedding layer** projects the latent matrix to embedding space, forming embedding vectors. Finally, **3) the explicit layer** takes embedding vectors and outputs weights that can be explicitly used as weights for CONV layers. Pruning is done by regularizing the latent vectors with \(\ell_{1}\) sparsity regularization, and proximal gradient algorithms [236] are used to update the latent vectors. This method is approximately differentiable since the proximal operation step has a closed-form solution.
To search for compact subnetworks, Pruning as Search (PaS) [139] adds a depth-wise binary convolution (DBC) layer after each convolutional layer. The DBC works as a pruning indicator, and Straight-Through Estimator [231] is used to allow gradient flow. Furthermore, a zero pruning indicator will zero out the gradient of weights, preserving the weights of pruned layers for ease of re-evaluation. Lastly, a structural reparameterization allows any width for the network. As an example, weights in the identity path are merged into CONV weights in a mathematically equivalent way to deal with residual connections.
Learning Filter Pruning Criteria (LFPC) [140] searches for layer-wise pruning criteria instead of pruning ratios. The basis for its use is that filters have differeing distributions for extracting coarse and fine-level features. This makes using the same pruning criterion for all layers in-appropriate. To explore the criteria space, criteria parameters are introduced to guide the choice of criteria. To enable gradient flow, this method uses the Gumbel-Softmax reparameterization [255] to make the loss differentiable to criteria parameters.
Transformable Architecture Search (TAS) [141] searches the width and depth of a network. Two learnable parameters \(\alpha\) and \(\beta\) are introduced to indicate the distribution of the possible number of channels and layer, respectively. Subnetworks can be sampled based on \(\alpha\) and \(\beta\). Applying the Gumbel-Softmax reparameterization [255] makes the sampling process differentiable. The search objectives are minimizing the validation loss while encouraging smaller computational costs and penalizing the unmet resources budget. Knowledge Distillation is further used to boost the performance of the pruned networks.
Exploration and Estimation (EE) [142] achieves channel pruning in a two-step gradient-based manner. The first step is **exploration** of subnetworks to allow larger search space with a fast sampling technique (_Stochastic Gradient Hamiltonian Monte Carlo_[263]). To bring sparsity, this method applies a FLOPs-aware prior distribution to the exploration process. The second step, **estimation**, is used to guide the generation of high-quality subnetworks.
#### 2.6.3 Evolutionary-Based
MetaPruning [148] aims to find the optimal layer-wise channel number with a two-stage framework. The first stage trains a meta network named _PruningNet_ to generate various structures. _PruningNet_ takes randomly sampled encoding vectors representing structures and learns in an end-to-end manner. In the second stage, an evolutionary search algorithm is deployed to search for the optimal structures under constraints. No fine-tuning is needed at search time since _PruningNet_ predicts the weights for all the pruned nets.
In contrast to MetaPruning [148], ABCPruner [149] looks for the optimal layer-wise channel number with a one-stage approach and requires no extra supporting network. In addition, it drastically reduces the combinations of pruned structures by limiting the preserved channels to a given
space. To search for the optimal pruned structures, an evolutionary algorithm based on the _Artificial Bee Colony algorithm (ABC)_[264] is applied.
Instead of using evolutionary algorithms (EA) on the entire network, Cooperative CoEvolution algorithm for Pruning (CCEP) [150] uses _cooperative coevolution_[265] that groups the network by layer and applies EA on each layer. By decomposing the networks into multiple groups, the search space is drastically decreased. The overall framework uses an iterative prune-and-fine-tune strategy. In each iteration, multiple individual candidates (parents) are generated by randomly pruning filters. Offsprings are generated by conducting parents with bit-wise mutations, where each bit represents the presence of a filter. Individuals are then evaluated with accuracy and FLOPs, and only top-\(k\) are retained for the next iteration.
### _Extensions_
#### 2.7.1 Lottery Ticket Hypothesis
The Lottery Ticket Hypothesis (LTH) [266] claims that "dense, randomly-initialized, feed-forward networks contain subnetworks (winning tickets) that -- when trained in isolation -- reach test accuracy comparable to the original network in a similar number of iterations." _Weight rewinding_ is always used in LTH-based papers. In the study by Frankle & Carbin [266], weights and the learning rate schedule are rewound to the values at epoch \(k=0\), in order to find the sparse subnetworks at initialization. Frankle _et al._[267] propose to rewind the weights and learning rate schedule to \(k>0\) epoch to deal with SGD randomness (noise). Different means of achieving unstructured LTH have been proposed: SNIP [268] by preserving the training loss; GraSP [269] by preserving the _gradient flow_; Neural Tangent Kernel (NTK) [270] by capturing the _training dynamics_; GF [271] by pruning weights that cause the least change to the _gradient flow_.
Renda _et al._[272] propose to rewind the learning rate schedule but not the weight value (_learning rate rewinding_). Experiments show that rewinding techniques consistently outperform fine-tuning, in which _learning rate rewinding_ outperforms or matches _weight rewinding_ in all scenarios.
Rethinking the Value of Network Pruning (RVNP) [152] re-evaluates the value of network pruning. The argument is that traditional fine-tuning techniques work no better than pruning from scratch. Extending LTH in a structured pruning setting for large-scale datasets fails to yield the lottery ticket.
Early Bird (EB) [153] proposes to find the winning ticket in the early stages of training, rather than fully training the dense network. To find the EB ticket, the mask for filters is computed based on the Hamming distance between two subnetworks pruned from the same model.
Prospect Pruning (ProsPr) [154] argues that the _trainability_ of the pruned networks should be considered. _Trainability_ exists as the model is going to be trained after pruning. Thus, _meta-gradients_ (gradient-of-gradients) have been proposed as a measure of _trainability_. Instead of estimating the changes in the loss at initialization, the effect of pruning on the loss over several steps of gradient descent at the beginning of training is estimated in ProsPr.
Early Compression via Gradient Flow Preservation (EarlyCroP) [155] achieves early pruning by solving three key problems. The problem **1) why to prune** is solved by extending a GF-based pruning criterion [271] to structured pruning. **2) How to prune** is solved by preserving the training dynamics leveraging using a connection between the _gradient flow_ and NTK [270]. Lastly, **3) when to prune** is solved by finding the _lazy kernel regime_, which is the phase where pruning has little effect on the _training dynamics_.
Pruning-aware Training (PaT) [156] tries to resolve the problem of _when early pruning should begin_? PaT is based on the premise that sub-networks having the same number of remaining neurons can have very different architectures. To determine when the architectures are stable, a novel metric called the _early pruning indicator (EPI)_ that computes the structure similarity of two subnetworks has been proposed.
#### 2.7.2 Joint Compression
Some prevailing techniques, i.e., architecture search, decomposition and quantization, are orthogonal to pruning methods for neural network compression. Applying these techniques in sequence may seem like a natural extension but can lead to sub-optimal solutions due to different optimization objectives [165]. Therefore, researchers have proposed to apply these techniques jointly.
**Pruning and NAS**: NPAS [161] develops a framework of joint network pruning and architecture search. This method is compiler-aware and replaces computational activation functions such as the sigmoid function with compiler-friendly ones.
**Pruning and Quantization:** DJPQ [162] jointly performs structured pruning and mixed-bit precision quantization in a gradient-based manner. This structured pruning is based on the variational information bottleneck [104], and mixed-bit precision quantization is extended to power-of-two bit-restricted quantization. Bayesian Bits (BB) [163] unifies the view of mixed precision quantization and pruning, and introduces mixed precision gates on filters for structured pruning. IODF [164] utilizes integer-only arithmetic based on 8-bit quantization and has learnable binary gates to eliminate redundant filters during inference.
**Pruning, NAS, and Quantization:** APQ [165] performs these tasks jointly. A once-for-all network [273] supporting a large search space for channel number is trained. Next, a quantization-aware accuracy predictor is designed to evaluate the accuracy of the selected structure with mixed-precision quantization [274]. This is followed by the use of an evolutionary-based architecture search [275] to find the best-accuracy model under latency or energy constraints.
**Pruning and Decomposition:** Some studies have exploited structured pruning and low-rank decomposition within a unified framework. The authors of Hinge [166] contend that pruning techniques cannot deal with the last CONV layer in a residual block that low-rank decomposition is able to. The two techniques are hinged by introducing _sparsity-inducing matrices_ after filters. Imposing group sparsity on the columns and rows of _sparsity-inducing matrices_ achieves filter pruning and decomposition respectively. Collaborative Compression (CC) [167] simultaneously learns the model sparsity and low-rankness to achieve channel pruning and tensor decomposition jointly.
#### 2.7.3 Special Granularity
Apart from unstructured pruning at the weight level and structured pruning at the filter level, there are also pruning methods at other granularities. To categorize these methods, we define three basic dimensions: output dimension \(N_{l+1}\), input dimension \(N_{l}\), and kernel dimension \(K^{2}\). Filter pruning can be viewed as pruning along dimension \(N_{l}\times K^{2}\), and channel pruning is along dimension \(N_{l+1}\times K^{2}\). They are similar since pruning filters in the \(l\)-th layer will remove the corresponding channels in the \(l+1\)-th layer. More different pruning granularities are shown in Fig. 3.
**Group along basic dimensions:** GBD [90] and SSL [91] introduce _group-wise pruning_ (Fig. 3c) which prunes weights located at the same position among all filters in a layer, that is, along the output dimension \(N_{l+1}\). SWP [170] prunes filters in a _stripe-wise_ (Fig. 3d) manner along input dimension \(N_{l}\). Compared to _group-wise pruning_, _stripe-wise pruning_ maintains filter independence, for there is no pattern across filters. PCONV [171] uses _kernel-wise pruning_ (Fig. 3e) to prune weights along kernel dimension \(K^{2}\).
**Diverse in basic dimensions:** Some researchers find making the same pruning decision along basic dimensions may not be optimal, and they propose to look into the basic dimensions. GKP-TMI [172] uses _grouped kernel pruning_ (Fig. 3f). On top of _kernel-wise pruning_, this method groups different filters and makes diverse pruning decisions in the output dimension \(N_{l+1}\). The remaining kernels are re-permuted to output a densely structured pruned network that benefits from parallel computing. 1xN [173] (Fig. 3f) uses a _1xN pruning pattern_ which treats \(N\) output kernels sharing the same input channel index as the basic pruning granularity. PCONV [171] uses _pattern-based pruning_ (Fig. 3g) by looking into the kernels and making different pruning decisions in the kernel dimension \(K^{2}\). _Block-wise pruning_[161] (Fig. 3h) generalizes _pattern-based pruning_[171] to share a same pattern for a kernel group, where kernels are grouped in both the output dimension \(N_{l+1}\) and the input dimension \(N_{l}\). **Other possible granularities.** There are some more possible structured granularities such as grouped stripe (extension of Fig. 3d) and grouped pattern (extension of Fig. 3g). Multi-granularity [178] also deserves investigation in structure pruning.
**Layer-level:** Besides breaking down filters into smaller granularies, Shallowing Deep Networks (SDN) [174] uses _layer-wise pruning_ to prune entire layers. Specifically, SDN places _a linear classifier probe_[276] after each layer to evaluate the effectiveness of the layer. The network is retrained with the knowledge distillation technique after pruning unimportant layers.
## 3 Future Directions
### _Pruning Topics_
Every subsection in Section 2 has the potential for further development in the future. Besides, structured pruning will continue to borrow ideas from unstructured pruning. In this section, we will discuss some promising topics directly related to pruning.
**Pruning theory:** Apart from utilizing optimization tools for pruning in Section 2.4, some works view pruning from the perspective of synaptic flow [179], signal propagation [180], and graph theory [181]. Besides, the pruning process can be guided by leveraging the interpretations of a model [182], the loss landscape [110], generalization-stability trade-off [183] and entropy of a model [184]. Moreover, the theory behind LTH is investigated with Logarithmic Pruning [185]. In addition, different training methods [186, 187, 188] can be considered together with pruning. The above directions have the potential in structure pruning.
**Pruning mechanism:** Researchers have new views on the prevailing three-stage training-pruning-retraining mechanism. First, the Lottery Ticket Hypothesis, which is proposed on unstructured pruning, is expected to extend on structured pruning. Second, single-shot pruning [189, 190] prunes only once to get the pruned models. Structured pruning can potentially benefit from this mechanism. Third, AC/DC training [191] is able to co-training the dense and
Fig. 3: Explain different pruning granularities in three basic dimensions: the output dimension \(N_{l+1}\), the input dimension \(N_{l}\), and the kernel dimension \(K^{2}\). “Along” means the same pruning decision made to all weights at the same position in this dimension. In contrast, “diverse” indicates pruning results are different in this dimension. _(a) Filter-wise_ and _(b) Channel-wise_ are the well-known structured pruning. Remaining _(c) - (h)_ are special granularities. _(c) Group-wise pruning_ groups weights along the output dimension \(N_{l+1}\). _(d) Stripe-wise pruning_ groups weights along the input dimension \(N_{l}\). _(e) Kernel-wise pruning_ groups weights along the kernel dimension \(K^{2}\). _(f) Grouped kernel pruning_ groups kernels across several different filters in \(N_{l+1}\) dimension. _(g) Pattern-based pruning_ utilizes pre-defined patterns to group weights in \(N_{l}\) dimension. _(h) Block-wise pruning_ groups kernels with the same pattern in both \(N_{l+1}\) and \(N_{l}\) dimensions.
sparse models. Therefore, handling multiple models during pruning and training is another promising direction for structured pruning.
**Pruning Rate:** Structured pruning can also extend the current weight pruning strategies on researching the layer-wise pruning ratios [192, 193].
**Pruning Domain:** Utilizing representation in the frequency domain [194, 64] to guide pruning is another interesting direction.
### _Pruning for Specific Tasks_
Pruning techniques can be applied to other tasks to achieve high computational efficiency. Here are some straightforward examples: super-resolution [202], personal re-id [203], medical imaging diagnostic [204], face attribute classification [205] and ensemble learning [206, 207]. Apart from tasks mentioned above, there are some emerging directions that are still in the early stages but are promising in the future.
**Pruning for Federated Learning:** Federated learning [277] aims to solve the problem of training a model without transferring data to a central location. Pruning [195, 196] helps alleviate communication costs required between devices and servers. Zhang _et al._[195] contend that the non-Independent and Identically Distributed (non-IID) degree for each device and server is different, so it proposes to compute the different pruning ratio from each device and an aggregated expected pruning ratio for the server.
**Pruning for Continual Learning:** Continual Learning tackles the problem of catastrophic forgetting [197]. Some pioneering works [198, 199, 200] use the pruned filters of the sparsified network to train a new task, so the training process do not cause deterioration to the performance of previous tasks.
**Limited Dataset:** Dataset compression and pruning [278] are emerging. The idea is to utilize part of the images from the training dataset to train the network. Structured pruning [201] has lots of topics to investigate along with this new trend.
### _Pruning Specific Networks_
Besides the prevailing CNNs, pruning is beneficial to other type of neural networks such as MLPs [216], rectifier neural networks [217], spiking neural networks [218, 219].
**Pruning GAN:** Generative adversarial network (GAN) [208] consists of a generative network and a discriminative network, and it requires large storage and FLOPs. Different pruning methods [209, 210, 201] are proposed achieve efficient GAN.
**Pruning Transformers:** Vision transformers [279] have achieved state-of-the-art (SOTA) performance in the area of computer vision. There has been a growing trend to incorporate the architectural design of CNNs into Transformer models [15, 16, 17, 18, 19]. Therefore, adopting these structured pruning techniques to compress these novel architecture designs is meaningful [14, 212].
**Pruning for AGI:** In recent years, foundation models and generalist agent [213] are the possible way to Artificial general intelligence (AGI). Foundation models such as GPT-3 [214] are trained on a huge amount of data and can be adapted to many downstream tasks. The generalist agent Gato [215] works as a multi-modal, multi-task, multi-embodiment generalist policy. These huge models can benefit from the research of structured pruning to achieve higher efficiency.
### _Pruning Targets_
During past years, the target of pruning has shifted from reducing the number of parameters in unstructured pruning to minimizing the FLOPs in structured pruning. Recently, the target of pruning has been evolving to meet the practical demands of real-world scenarios.
**Hardware:** Incorporate pruning to the hardware process is an emerging trend. Different types of hardware require different pruning techniques. Hardware compiler-aware pruning [220] conducts pruning based on the structural information of subgraphs constructed during compiler tuning.
**Energy:** As the deployment of AI models expands, the rising energy consumption of AI models needs greater attention. Considering energy during pruning needs to be investigated. Energy-aware pruning [221] greedily prunes the layer that consumes the most energy, for minimizing the MACs may not necessarily reduces the most energy consumption.
**Robustness:** The robustness of a network describes how easily a network is fooled to make a wrong prediction under attacks [222]. Consider the robustness and computational cost of models together during the model design process is a new trend. Researchers find sparsity brought by pruning can improve the adversarial robustness [280]. Linearity Grafting (Grafting) [223] uses the premise that network robustness favors linear functions and proposes the _linearity grafting_ method. ANP-VS [224] identifies the latent features with high vulnerability and proposes a Bayesian framework to prune these features by minimizing adversarial loss and feature-level vulnerability.
## 4 Related Works
**Unstructured Pruning (Weight Pruning):** The idea of pruning is first introduced by LeCun _et al._[238] who propose _saliency_ to measure the importance of each weight. The _saliency_ is computed by the diagonal elements of the Hessian matrix. Han _et al._[9] propose to iteratively prune weights with \(\ell_{1}\) regularization and retrain. Guo _et al._[252] propose _connection splicing_ which restores the wrongly pruned weights. In addition, Guo _et al._ incorporate the _connection splicing_ into the training process to dynamically learn the weights [252]. Han _et al._[1] adopt a 3-stage pipeline to prune weights and achieve a 49\(\times\) compression ratio with merely accuracy loss on VGG-16 [5], bringing back the research focus on network pruning.
**Quantization:** Quantization in model compression describes the process of approximating full precision weights (_32-bit floating point_) with lower precision weights (e.g., _8-bit integer_) to reduce computation and storage cost. The low-bit quantization includes binarization [281, 10] and ternarization [282, 283]. These methods can be roughly divided into two categories. First, heuristic quantization methods quantize weights by using mapping functions [281],
[282]. Second, non-heuristic methods formulate quantization as an optimization problem [283, 10]. In addition, the quantization process also includes clustering and parameter sharing [40], and quantization can be combined with pruning [284, 285, 1].
**Decomposition:** Decomposition is referring to matrix decomposition and tensor decomposition, where a matrix is just a 2-D tensor. Specifically, a tensor is decomposed or factorized into products of several low-rank tensors that approximate the original tensor. To decompose 2-D tensors (matrices), _full-rank decomposition_[286], _singular value decomposition (SVD)_[287], and _QR_[288] are arguably the most popular low-rank matrix decomposition techniques. To deal with 4-D tensors, methods or concepts such as _Tucker_[289], _classical prolongation (CP)_[290], and _tensor networks_[291] are applied. Furthermore, decomposition is orthogonal to pruning, and these two techniques are applied together [292, 293, 294].
**Knowledge Distillation:** The idea of transferring knowledge from a usually large network to a small network is first introduced by Bucilua _et al._[295], and the idea is later well-known as Knowledge Distillation [12]. The distillation process includes _(1) offline distillation_[12] which takes a pre-trained teacher model. Distillation can be _(2) online distillation_[296] which simultaneously updates the teacher model and the student model in an end-to-end manner. Furthermore, _(3) self-distillation_[297] requires only one model and distills the knowledge from deeper sections to shallow sections. In addition, knowledge distillation can work with pruning to achieve few-shot compression which requires few data [298, 299, 300].
**Neural Architecture Search:** The objective of neural architecture search [25] is to minimize human intervention in the search for neural network designs. In this regard, three factors play a significant role. (1) The search space defines potential candidates. Selecting candidates with prior knowledge reduces the frequently vast search space, but human bias may hinder performance. (2) Search strategies are the search space exploration algorithms. Simple taxonomy involves Bayesian optimization [301], evolutionary methods [39], gradient-based methods [302], and reinforcement learning [303]. (3) The evaluation strategy is used to assess the predictive ability of the model on unseen data. To address the prohibitive computational cost of the model's evaluation, efficient methods are developed.
## 5 Experiments
Table II provides straightforward comparisons among different structured pruning methods of ResNet-50 [7] on ImageNet [304]. This first trend is the target network changes from VGGNet [5] before 2017 to ResNet [7] after 2017. From 2017 to 2020, some studies on MobileNets [305] were proposed. Another obvious trend is to achieve a larger FLOPs reduction with a lower accuracy loss. For example, in 2018, SFP [115] reduced 41.8% FLOPs with 1.54% top-1 accuracy drop. In 2022, ResRep [83] achieved 51.2% FLOPs reduction without any accuracy drop.
|
2305.07187 | Point convolutional neural network algorithm for Ising model ground
state research based on spring vibration | The ground state search of the Ising model can be used to solve many
combinatorial optimization problems. Under the current computer architecture,
an Ising ground state search algorithm suitable for hardware computing is
necessary for solving practical problems. Inspired by the potential energy
conversion of springs, we propose a point convolutional neural network
algorithm for ground state search based on spring vibration model, called
Spring-Ising Algorithm. Spring-Ising Algorithm regards the spin as a moving
mass point connected to a spring and establish the equation of motion for all
spins. Spring-Ising Algorithm can be mapped on the GPU or AI chips through the
basic structure of the neural network for fast and efficient parallel
computing. The algorithm has very productive results for solving the Ising
model and has been test in the recognized test benchmark K2000. The algorithm
introduces the concept of dynamic equilibrium to achieve a more detailed local
search by dynamically adjusting the weight of the Ising model in the spring
oscillation model. Finally, there is the simple hardware test speed evaluation.
Spring-Ising Algorithm can provide the possibility to calculate the Ising model
on a chip which focuses on accelerating neural network calculations. | Zhelong Jiang, Gang Chen, Ruixiu Qiao, Pengcheng Feng, Yihao Chen, Junjia Su, Zhiyuan Zhao, Min Jin, Xu Chen, Zhigang Li, Huaxiang Lu | 2023-05-12T01:01:01Z | http://arxiv.org/abs/2305.07187v1 | **Point convolutional neural network algorithm for Ising model ground state research based on spring vibration**
## Abstract
The ground state search of the Ising model can be used to solve many combinatorial optimization problems. Under the current computer architecture, an Ising ground state search algorithm suitable for hardware computing is necessary for solving practical problems. Inspired by the potential energy conversion of springs, we propose a point convolutional neural network algorithm for ground state search based on spring vibration model, called Spring-Ising Algorithm. Spring-Ising Algorithm regards the spin as a moving mass point connected to a spring and establish the equation of motion for all spins. Spring-Ising Algorithm can be mapped on the GPU or AI chips through the basic structure of the neural network for fast and efficient parallel computing. The algorithm has very productive results for solving the Ising model and has been test in the recognized test benchmark K\({}_{\text{code}}\). The algorithm introduces the concept of dynamic equilibrium to achieve a more detailed local search by dynamically adjusting the weight of the Ising model in the spring oscillation model. Finally, there is the simple hardware test speed evaluation. Spring-Ising Algorithm can provide the possibility to calculate the Ising model on a chip which focuses on accelerating neural network calculations.
## Introduction
Combinatorial optimization problems, a subfield of optimization with discrete variables, are ubiquitous in many fields of research. In many cases, we can find a mapping to the decision form of the Ising model with a polynomial number of steps for the NPC (Non-deterministic Polynomial Complete) problem [1, 2, 3, 4]. Therefore, many optimization problems can be formulated as Ising models to find the ground state, or the lowest energy
configuration. So that, solving the Ising model becomes a general method for solving many NP problems, like partitioning problems [2], linear programming [1, 3, 5], inequality problems [6], coloring problems [2, 7] and so on. However, the Ising model is known to be NP-hard (Non-deterministic Polynomial Hard) problem [8]. So, it is difficult but important to find the ground state of the Ising model quickly and accurately.
The Ising model is mainly used in statistical physics and scientific computing. In statistical physics, the Ising model is widely used to study the phase transition phenomenon [9, 10, 11]. In scientific computing, the actual combinatorial optimization problem is mapped to the Ising model for finding the ground state in the N spins state space [12, 13, 14]. With N spins, there are \(2^{N}\) spin state to search the global minimum of the energy state, which is a great challenge for using conventional computing [15]. Special-purpose hardware devices for the ground state search, known as Ising machines, have recently attracted attention because of their potential to substantially speed up the solution of optimization problems [16]. Various schemes have been proposed and demonstrated for the Ising model, including quantum annealers [17, 18, 19, 20, 21], coherent Ising machine [22, 23, 24, 25, 26, 27, 28, 29, 30, 31] and so on. Limited by current technology, the above methods have difficulties such as large-scale expansion and complicated parameter configuration. Quantum computer is expected to solve exponential combinatorial optimization problems, but related work is still in its infancy [32].
The CMOS implementations [16, 33, 34, 35, 36, 37] are easy to integrate and expand, which means that it is a more suitable strategy for mapping and solving large-scale practical Ising model problem. In application, CMOS Ising machine has advantages such as tiny size, flexible expansion, high integration, low system power consumption and so on [36]. Most CMOS chips are based on non-fully connected structures, like lattice graph [15, 33, 35, 36], king graph[34, 38, 39, 40], and Hexagonally graph [41]. All-to-all connected Ising models are more practical value than sparse ones, but communication and synchronization between the spins degrade the speed performance in CMOS [16]. As the result of that, the spin scale of a CMOS chip based on an all-to-all connected topology design is very limited. The non-uniform design limits the popularization of CMOS chips and increases the design cost of ASIC for Ising model.
Al (Artificial Intelligence) chips have numerous computing resources, which are used for training and Inference of various Al algorithms. and are important available resources for computing large-scale problems. At present, Al chips have solved many problems such as classification, detection, and tracking by virtue of their powerful computing power[42, 43]. Commercial Al chips have the characteristics of high energy efficiency, high parallelism, and high scalability. These chips, which are optimized for communication and synchronization, have been used in a large number of large models. The computing architecture of the Al chip sets the computing engine for the multiply accumulate operation and realizes the parallel computing through efficient scheduling, thereby reducing computing time and off-chip storage access [44]. Using these computing hardware resources to solve the Ising model with numerous parameters is an extremely effective method since we have not yet achieved quantum computers.
The paper is organized as follows. In this paper, we propose a new algorithm, Spring-Ising Algorithm, that can solve the all-to-all connected Ising model directly on the Al chip.
First, we introduce how Spring-Ising Algorithm inspired by spring vibrations can be used to find the ground state of the Ising model. Then, we design the algorithm as a network structure based on point convolution and residual modules, which implements the solution iteration of the Ising model through point convolution and residual modules. Through our method, the optimization problem is transformed into the general formula of Al chips calculation by constructing the Ising model paradigm and Al chips accelerate Spring-Ising Algorithm for the ground state finding. Finally, the network structure is demonstrated on Al chip architecture from Ref. [45] to solve the Max-cut problem and both numerical and analytical investigation are conducted.
## Result
In this chapter, we propose the physical prototype of Spring-Ising Algorithm and how to apply Lagrange's equations to iterate spin states by symplectic method. Spring-Ising Algorithm is inspired by physical phenomena, spring vibrations. The detail of physical prototype is introduced as follow.
### Spring vibration model
The Ising model is defined as follow:
\[H=-\sum_{\textbf{i}\in\textbf{i}\in\textbf{i}\in\textbf{s}N}J_{ij}\sigma_{i} \sigma_{j}-\sum_{\textbf{i}\in\textbf{i}\in\textbf{s}N}h_{i}\sigma_{i} \tag{1}\]
The discrete variable \(\sigma_{i}\) is the \(i\)th Ising spin state such that \(\sigma_{i}\in\{-1,+1\}\). In Pauli matrices, the variable \(\sigma_{i}\) assigns values \(\{-1,+1\}\) to spin values \(\{1,\dagger\}\)[17]. \(J_{ij}\) denotes a coupling coefficient between the \(i\)th and \(j\)th spins and \(h_{i}\) is an external magnetic coefficient for the \(i\)th spin. \(H\) is the total energy of the Ising model and it tends to the lowest energy.
Inspired by the steady-state analysis of multiple mass-spring system in analytical mechanics, the ground state research method of the Ising model in this paper is designed. In Ising model, the state of the \(i\)th spin \(\uparrow\) (1) is encoded as a discrete variable corresponding to a value of \(+1(-1)\). We regard the discrete variable as the continuous change of the mass point in the macroscopic position, which is defined as the generalized coordinate \(q_{i}\in[-1,1]\). On this basis, the spring model is designed by considering a mass point connected at an ideal spring with no initial length and the spring force on the mass point is always pointing to one point, called the origin point. As shown in Fig. 1(a), the spring is fixed at the origin point, and the other end is the mass point representing the state of spin. Since the initial length of the spring is zero, when the mass point moves away from the origin, it is pulled by the spring. In this model, the mass point is above(below) the origin to represent the spin \(\uparrow\) (1), and the distance is represented as a degree of confidence. According to the coupling coefficient and spin state, the Ising model produces a number of forces along a line along the \(q_{i}\) axis. Therefore, the direction of the resultant force is also on the \(q_{i}\) axis, as shown in Fig. 1(b).
In the model, while a spin considered as a mass point is called the target spin, the other spins are called the source spins providing external force to the target spins. The magnitude and direction of \(F_{i}\) depend on the combined effect of multiple source spins but have nothing to do with the state of the target spin. Fig. 2(a) gives a specific example, when the state of source spin is \(\mathbf{+1}\), if the coupling coefficient is positive, an upward force will be generated. The greater the coupling coefficient, the greater the force generated. In the same way, if the coupling coefficient is negative, a downward force will be generated. When the coupling coefficient is zero, the source spin provides no force. The superposition of all the forces provided by the source spin is the force of the Ising model coupling relationship for the mass point \(i\). When the state of origin spin is \(\mathbf{-1}\), the direction of the force is opposite, as shown in Fig. 2(b).
Figure 1: Spring vibration model based on Ising model. The red sphere represents the spin, and the arrow in it indicates the spin state. The four bright red spheres on the upper left represent the four spins mapped by the Ising model. The green connection line between the red spheres represents the coupling relationship. The fuzzy sphere in the gray dashed box represents the opposite spin state of the blue dashed box. The two dashed boxes are used to represent the same spin in two spin states, expressing the two particle positions of the spring model. Correspondingly, the gray part in the spring model is another spin state. (a) The spin of Ising model is mapping to the position of the mass point on the spring vibration model. Take the part in the blue dashed box as an example, the spin state is up, the mass point is above the origin. The blue dashed box vice versa. (b) The distance between the mass point and the origin point is effected by the coupling relationship and the spring.
Figure 2: The specific example shows that the coupling relationship between spins affects the external force received on the mass point. \(\alpha_{i}\) is the \(i\)th spin which is regarded as the target spin and \(\alpha_{j}\) is the \(j\)th spin which is regarded as the source spin. The blue line between the spins means that the coupling relationship of the two spins is positive, the green line is negative. The force on the mass point is the resultant force produced by the sum of all coupling relations. (a) When the source spin \(\alpha_{i}\) is \(\mathbf{+1}\), the coupling relationship produces multiple forces on the mass point \(i\). (b) When the spin state \(\alpha_{i}\) is \(\mathbf{-1}\), the direction of the force is opposite.
The generalized coordinate introduced by the model is a continuous variable, which means that the magnitude of the force is also affected by the absolute value of the generalized coordinate from the source spin. So, the source spin is changed to the source spin generalized coordinate: \(\sigma_{i}\in\{-1,1\}\to q_{i}\in[-1,1]\). When the absolute value of the generalized coordinates is greater, the spring potential energy contained in the spring vibration model is greater. For the Ising model, the greater source spin has a greater overall influence on the system to the target spin and vice versa. Therefore, the discrete Ising model energy in Eq. (1) is set to the continuous Ising model energy in the spring vibration model.
2. Ground state search method
After establishing the spring vibration model, the following is how to use the model to find the ground state of Ising model. This method regards the potential energy of the Ising model as the ordinary potential energy and converts the potential energy of the Ising model into the potential energy of the spring and the kinetic energy of the system. The Ising model energy gradually decreases and transforms into the potential energy of the spring. Then, due to the constraints of generalized coordinates and generalized velocity, the energy originally converted into spring potential energy, continuous Ising model energy and kinetic energy is absorbed by the inelastic wall. The energy of the whole system gradually decreases and thus converges to the spring potential energy and the energy of the Ising model near the ground state.
According to the various constraints of this system, the Lagrangian equation is constructed as follows:
\[L(q_{i},\dot{q_{i}},t)=\sum_{i}m\dot{q_{i}}^{2}-\sum_{i}\frac{1}{2}k(q_{i}-q_ {0})^{2}-\zeta H_{Ising}(\mathbf{q}) \tag{2}\]
Where \(\mathbf{m}\) is the mass coefficient, \(k\) is the elastic coefficient, and \(\zeta\) is the scaling coefficient of the Ising model energy. The three terms of the mass point in Eq. (2) are the kinetic energy term, the spring potential energy term and the continuous Ising model energy term. In the spring vibration model, the generalized coordinates are independent of \(t\). It can be seen from the formula that the movement of the mass points is affected by the potential energy of the spring and the energy of the Ising model. The movement of the mass points is manifested as a continuous vibration on the ideal springs. From another perspective, it can be considered that when the spring is doing simple harmonic motion, a set of external forces are applied from the outside. Affected by the coupling coefficient of the Ising model, the oscillations of the mass points are biased towards the lower Ising model energy.
3. Symplectic method
Since the size of the Ising model depends on the number of spins, the solution scale is quite large. Therefore, it is very difficult to solve the Lagrangian equation directly and accurately. In this paper, referring to the Hamiltonian and symplectic method [46], the numerical iterative calculation of the spring vibration model is carried out. The Hamiltonian describes the total energy of the system and can be used to describe the system's dynamic behavior. Symplectic method is numerical method used to solve Hamilton's equations and it preserves energy conservation of the system.
According to the definition, the generalized momentum \(p_{i}\) is obtained as \(\partial L/\partial\dot{q}=m\dot{q}_{i}\). The Hamiltonian of the system is obtained by performing the Legendre transformation on the Lagrangian quantity:
\[H(q,p,t)=\sum_{i}q_{i}p_{i}-L(q_{i},q_{i},t)=\sum_{i}\frac{1}{2}q_{i}p_{i}+\sum_ {i}\frac{1}{2}k(q_{i}-q_{0})^{2}+\zeta H_{tsng}(\mathbf{q}) \tag{3}\]
Get Hamilton's equation:
\[\dot{q}_{i}= \frac{\partial H}{\partial p_{i}} \tag{4}\] \[\dot{p}_{i}= -\frac{\partial H}{\partial q_{i}}=-k(q_{i}-q_{0})+\zeta\sum_{j}w _{ij}q_{j}\]
Use the symplectic algorithm to solve the Hamiltonian system, and set the system origin to \(q_{0}\):
\[q_{i}(t_{n+1})=q_{i}(t_{n})+\Delta\dot{q}_{i}(t_{n})=q_{i}(t_{n})+\frac{ \Delta}{m}p_{i}(t_{n}) \tag{5}\] \[p_{i}(t_{n+1})=p_{i}(t_{n})+\Delta\dot{p}_{i}(t_{n})=p_{i}(t_{n} )-\Delta kq_{i}(t_{n})+\zeta\Delta\sum_{j}J_{ij}q_{j}(t_{n})\]
Where \(\mathbf{t_{n}}\) is the \(n\)th iteration. It can be seen from the above formula that \(\mathbf{q}_{i}(\mathbf{t_{n}})\) and \(\mathbf{p_{i}}(\mathbf{t_{n}})\) depend on the value of the previous state. With the iteration of the value, the energy is continuously converted. As the energy of the Ising model decreases, the solution is gradually approaching the ground state of the Ising model. Dimensional issues are not considered in numerical calculations, so parameters can be combined. The Eq. (5) is called the iterative formula of Spring-lsing Algorithm.
### 4. Point convolutional neural network
In the iterative calculation of the algorithm, the most important calculation is multiplication of \(J_{ij}\) and \(\mathbf{q}_{i}(\mathbf{t_{n}})\). A method of iterative calculation using point convolution to replace the product of vector and matrix is proposed, so that the algorithm can be used in high-bandwidth computing chips, like GPU and Al chip. Moreover, the point convolution is optimized in the hardware design to reuse the convolution kernel and reduce data access to accelerate the computation in parallel. Fig. 3 shows an alternative way of turning the iterative equation into the neural network architecture computation. \(\mathbf{q}_{i}(\mathbf{t_{n}})\) of a single test is assigned at fixed coordinate of the feature map, so the number of generalized coordinates and feature maps are the same. The size of the point convolution kernel also depends on the coupling relationship matrix of the Ising model so that the number of convolution kernel is \(\mathbf{n}\), and the number of convolution kernel channels is \(\mathbf{n}\). The rest of the architecture is the addition module, which can be completed through the residual structure in the neural network and is supported in mainstream Al chips.
## Discussion
In this chapter, we show the experimental results based on the spring vibration model. Then we introduce how to implement the above algorithm through point convolution and residual network and implement it on the CASSANN-v2 architecture.
To demonstrate the effect of Eq. (1), the algorithm is tested on the K\({}_{2000}\) benchmark instance, which is a random undirected graph with 2000 vertices and 1999000 edges [23]. The K\({}_{2000}\) has been used many times to solve maximum-cut problems (MAX-CUT) for Ising model comparison of performance [47, 23, 48].
### Qualitative result
When the kinetic energy is large enough, it can cross the local minimum value by the local oscillation; but at the same time, if the kinetic energy is too large, it cannot stay in any minimum value. So that, the following constraints are added each time \(q_{i}\) is updated:
\[q_{i}\gets f(q_{i})=\begin{cases}-\sqrt{2},&q_{i}<-\sqrt{2}\\ q_{i},&-\sqrt{2}\leq q_{i}\leq\sqrt{2}\\ \sqrt{2},&q_{i}>\sqrt{2}\end{cases} \tag{6}\]
Where \(f(*)\) describes the boundaries of \(q_{i}\). For the spring to vibrate, the boundary is slightly than the original setting [**-1,1**] so that set \(q_{i}\in[-\sqrt{2},\sqrt{2}]\). After combining the boundary conditions, the equation describes the motion law of the spin.
The mass point vibration result of running the spring vibration model algorithm in 10000 iterations is shown in Fig. 4. The benchmark has 2000 spins, of which the first twenty are selected in the figure for visualization. In the early stage of the algorithm, because the mass points are initialized at origin and only given a small disturbance, the energy of the Ising model has a long-term decline process. It can be clearly seen in the figure that, the polylines are very dense, which means that the mass points are oscillating violently. In this time, the energy of Ising model is also rapidly oscillating and declining. In the middle, there are many
Figure 3: The parallel calculation of the spring vibration model algorithm through the form of point convolution. The size of the feature map affects the number of parallel tests for the algorithm. Using a 2x2 feature map is four independent iterative calculations. The value of the feature map is the generalized coordinate value, and the point convolution kernel is the weight data of the Ising model. The \(q^{\prime}_{n}\) is the temporary variable. On the right is the entire point convolution network architecture.
mass points attached to the boundary gradually which have been at the lower energy point. Finally, only some mass points are still oscillating to search for the optimal and the energy of the Ising model has tended to the ground state and the detail of the energy change is shown in the inset of Fig. 4(a). Also, it can be seen that a few spin flips bring fluctuations of Ising energy.
2. Quantitative result
It can be easily predicted that the potential energy of the spring is lost within the limitation of the boundary conditions as time progresses. Therefore, in the later stages of evolution, it is necessary to compensate for the lost energy. In order to further search the ground state of Ising model accurately, Spring-Ising Algorithm introduces the concept of energy dynamic balance to increase the energy proportion of Ising model and improve the
Figure 4: The spring vibration model algorithm on the K\({}_{\rm{zz}}\) in 10000 iterations. The parameter configuration is as follows: k = 0.5, \(\zeta\) = 0.8\(\zeta\) - \(>\) 10\(\zeta\), \(\Delta\) = 0.2, \(m\) = 1. (a) The energy change curve of the Ising model. The mass point positions in Spring-Ising Algorithm are initialized near the origin, so the energy starts from 0 and decreases rapidly. Before N\({}_{\rm{zz}}\)=2000, the energy is descending in a violent shock. After that, vibrate slightly to search for the energy minimum. (b) The mass point (the first twenty) vibration. The very dense parts of the graph are the effect of multiple mass points oscillations. When the system completes the basic search, it tends to be stable. Most of the mass points tend to be stable and only some of them perform local search (like after N\({}_{\rm{zz}}\)=5000).
search efficiency. To compensate for the energy loss, Spring-Ising Algorithm sets the \(\zeta\) as a linear variable \(\zeta(\mathbf{t})\). In order to reduce the complexity of the algorithm, this variable is regarded as a constant in the calculation of the Lagrangian equation, which means that the time-varying effect in the Lagrange equation is not considered. Through further analysis and solution of this equation, the ground state finding of the Ising model system is obtained.
This test is based on the same small disturbance for initializing with different strategies of \(\zeta\). As shown in Fig. 5, no matter what the value of \(\zeta\) is fixed, the ground state search of the Ising model is easy to fall into a local optimum. Although the larger \(\zeta\) quickly leads to better local results (the blue line), it is difficult to search further to get better results. By gradually changing the value of \(\zeta\), further searches can be performed after the spring model has entered local stability. The red line and the orange line can be clearly seen each time steady state is established and further searches. This result is very similar to sufficiently slow cooling in simulated annealing. When the step length is short enough, better search results can be obtained.
The probability density function (CDF) is an important way to judge the performance of algorithms for solving Ising models. Fig 6. shows the cumulative distributions of the cut value of the K\({}_{2000}\). The algorithm is compared with the HdSB and HhSB algorithm [47], and there are partial similarities under different modeling methods. It shows that the spring vibration model algorithm within the specified number of steps can search for better cut value. The inset shows that the algorithm can find the optimal value more effectively and the number of optimal solutions accounts for 2.9% of all solutions, which is only about 1.2% solved by HhSB and HdSB.
Figure 5: The effect of different \(\zeta\) on the average results of K\({}_{\text{norm}}\), \(\zeta_{0}\) is the base value. \(\zeta_{0}\) = 0.05. The first and second sets of data (green curve and blue curve) indicate that the current \(\zeta\) is fixed at 0.8\(\zeta_{0}\) or 10\(\zeta_{0}\), respectively. The third and fourth set of data (orange curve and red curve) indicates that the \(\zeta\) is set from 0.8\(\zeta_{0}\) to 10\(\zeta_{0}\) with different step lengths. (N\({}_{\text{norm}}\) = 200 or 1000)
3. Hardware implementation
The test platform of this algorithm is a personal computer (Intel 8700K and NVIDIA GTX 2080ti) and the AI architecture (CNN accelerator) developed by Institute of Semiconductors, CAS [45]. By GTX 2080ti testing in the PyTorch framework, when the size of Ising model is 2000 and the number of tests is 1000, the calculation time is 9.95s/10000 steps, which means that a sample time of 10,000-step tests is 9.95ms. But when the number of tests is 100, the time is 2.30ms/10000 steps. The GPU has a shorter average single-sample test time at more massive tests. The average power consumption of the 2080Ti is 60.6W. By the AI architecture, the size of Ising model is 2000 and the number of tests is 49 (7\(\times\)7 feature map), the calculation time is 381.15ms/10000 steps, which means that a sample time of 10,000-step tests is 7.78ms. The average power consumption of the CASSANN-v2 is lower than 10W.
## Methods
### Numerical iteration
First, regard the spin of the Ising model as \(q\) and the coupling coefficient weight as \(J\). The ground state search process of the Ising model is solved under the mass points oscillation process. Based on the spring vibration model, the vibration equation combined with the Ising model is constructed and transformed into the following Hamiltonian.
\[H(q,p,t)=\sum_{i}\frac{1}{2}q_{i}p_{i}+\sum_{i}\frac{1}{2}k(q_{i}-q_{0})^{2}+ \zeta H_{\mathit{Ising}}(\mathbf{q}) \tag{7}\]
According to the equations of motion, all mass points are initialized near the origin, and then all mass points are made to start moving under the joint action of the spring and the Ising model. According to the symplectic method, the positions of the mass points at each
Figure 6: The spring vibration model algorithm cumulative distribution of cut values C of the K\({}_{\mathrm{tot}}\) compared to HQSB and HQSB. The red curve is the result of the Spring-Ising Algorithm. The inset is the magnification around the best-known cut value. The red curve illustrate that the Spring-Ising Algorithm has better suboptimal distribution results and more optimal values than HQSB and HQSB for the overall search results.
time step are found. The final spin state of the Ising model is obtained by tracking the mass points (numerical iteration).
\[\begin{split}& q_{i}(\mathbf{t}_{n+1})=q_{i}(\mathbf{t}_{n})+\Delta p_{i}( \mathbf{t}_{n})\\ & p_{i}(\mathbf{t}_{n+1})=p_{i}(\mathbf{t}_{n})-\Delta kq_{i}(\mathbf{t}_{n})+ \zeta(\mathbf{t}_{step})\Delta\sum_{j}J_{ij}\mathbf{q}_{j}(\mathbf{t}_{n})\end{split} \tag{8}\]
\(\Delta\), \(\mathbf{k}\) and \(\mathbf{\zeta}\) are independent adjustable variables. Then, Eq. (8) has the following constraints, like the perfectly inelastic walls work [47]. \(\mathbf{q}_{i}\in\mathbf{[-\sqrt{2},\sqrt{2}]}\). \(\mathbf{p}_{i}\in\mathbf{[-2,2]}\). \(\zeta(\mathbf{t}_{step})\) is a function linearly related to the number of iterations. For simple calculation, \(\zeta(\mathbf{t}_{step})\) is set as a piecewise constant function. Eq. (8) iterates the specified number of times to get the result of the Ising model ground state.
### 2. Hardware implementation
For an Ising model with \(\mathbf{n}\) spins, generalized coordinates \(\mathbf{q}\) are mapped to feature maps. The number of feature map pixels is the number of simultaneous iterations. The coupling coefficient matrix of the Ising model is mapped to the point convolution kernel. Divide the \(J\) into \(\mathbf{n}\) 1x1 convolution kernels with \(\mathbf{n}\) channels by row. Through the residual structure, the addition operation required in the algorithm is completed. By continuously calling this network structure (Fig. 3), the numerical calculation of \(\mathbf{q}\) and \(\mathbf{p}\) in the eq. (8) is updated. After an artificially set time step or calculation time, the \(\mathbf{q}\) is sampled, which is the current low energy state of the Ising model.
## 3 Data availability
The data that support the findings of this study are available from the corresponding author upon reasonable request.
## 4 Code availability
The code used in this work is available from the corresponding author upon reasonable request.
|
2304.08837 | Sensor Fault Detection and Isolation in Autonomous Nonlinear Systems
Using Neural Network-Based Observers | This paper presents a novel observer-based approach to detect and isolate
faulty sensors in nonlinear systems. The proposed sensor fault detection and
isolation (s-FDI) method applies to a general class of nonlinear systems. Our
focus is on s-FDI for two types of faults: complete failure and sensor
degradation. The key aspect of this approach lies in the utilization of a
neural network-based Kazantzis-Kravaris/Luenberger (KKL) observer. The neural
network is trained to learn the dynamics of the observer, enabling accurate
output predictions of the system. Sensor faults are detected by comparing the
actual output measurements with the predicted values. If the difference
surpasses a theoretical threshold, a sensor fault is detected. To identify and
isolate which sensor is faulty, we compare the numerical difference of each
sensor meassurement with an empirically derived threshold. We derive both
theoretical and empirical thresholds for detection and isolation, respectively.
Notably, the proposed approach is robust to measurement noise and system
uncertainties. Its effectiveness is demonstrated through numerical simulations
of sensor faults in a network of Kuramoto oscillators. | John Cao, Muhammad Umar B. Niazi, Matthieu Barreau, Karl Henrik Johansson | 2023-04-18T09:05:07Z | http://arxiv.org/abs/2304.08837v2 | Sensor Fault Detection and Isolation in Autonomous Nonlinear Systems Using Neural Network-Based Observers
###### Abstract
This paper presents a new observer-based approach to detect and isolate faulty sensors in industrial systems. Two types of sensor faults are considered: complete failure and sensor deterioration. The proposed method is applicable to general autonomous nonlinear systems without making any assumptions about its triangular and/or normal form, which is usually considered in the observer design literature. The key aspect of our approach is a learning-based design of the Luenberger observer, which involves using a neural network to approximate the injective map that transforms the nonlinear system into a stable linear system with output injection. This learning-based Luenberger observer accurately estimates the system's state, allowing for the detection of sensor faults through residual generation. The residual is computed as the norm of the difference between the system's measured output and the observer's predicted output vectors. Fault isolation is achieved by comparing each sensor's measurement with its corresponding predicted value. We demonstrate the effectiveness of our approach in capturing and isolating sensor faults while remaining robust in the presence of measurement noise and system uncertainty. We validate our method through numerical simulations of sensor faults in a network of Kuramoto oscillators.
## I Introduction
Fault detection and isolation (FDI) are essential for the safe and efficient operation of many industrial processes. A fault is an undesirable disruption or disturbance to the system, which could lead to catastrophic consequences if not addressed properly. Some examples of fault types include mechanical breakdown or failure of sensors. By using effective FDI methods, operators can identify faults early (detection), localize the fault source (isolation), and take corrective action before they cause costly damage or downtime.
FDI methods generally fall into two main categories: hardware and analytical redundancy [1]. Hardware redundancy methods rely on the use of multiple sensors to obtain and compare information about processes. This approach has the drawback of adding monetary cost for the purchase and maintenance of extra hardware. Methods using analytical redundancy overcome this by using the principle of residual generation. This generated residual is the difference between a predicted system output and its real measurement. Under fault-free operating conditions, the residual is approximately zero, while its value grows distinctly over a pre-defined threshold when faults occur.
Historically, methods for FDI based on analytical redundancy have been model-based, requiring an explicit mathematical model of the system being considered [2]. This approach was originally pioneered for linear systems during the 1970s in [3], where it was shown that it is always possible to design a filter capable of detecting and localizing faults in observable system dynamics. It was further refined and improved upon in [4], which together with [3] resulted in the famous _Beard-Jones Fault Detection filter_. Further extensions and application examples are addressed in [5, 6, 7, 8, 9].
The framework of observer-based fault detection schemes, developed in parallel with the above mentioned works, were first introduced for linear systems in [10]. Since then, it has become widely regarded as one of the most successful approaches for FDI and has resulted in several research directions. For example, the application of sliding-mode observers for FDI has been demonstrated in [11, 12, 13], where the problem is addressed by explicitly reconstructing the fault via manipulation of the output injection error. Nonlinear unknown input observers (NUIO) have also been widely used for FDI [2]. In [14], a bank of NUIOs with adjustable observer dynamics are used to detect and isolate thruster faults of an autonomous spacecraft. In recent years, an interval-based unknown input observer has gained a lot attention [15]. These observers are shown to be advantageous by relaxing the information requirements about the inputs and the non-linearity of the system. Substantial results on interval observers for FDI have been reported in [15, 16, 17, 18].
Another principal approach to analytical redundancy-based FDI are data-driven methods, which rose in popularity in the past decade driven by significant advancements in deep learning algorithms. These methods do not require an explicit system model, instead they rely on sensor data to approximate the underlying dynamics of the source that generates them in order to form a residual [19]. In [20], FDI with long short-term memory neural networks (LSTM) was demonstrated by generating residuals from comparing network predictions based on past time-series data with actual measurement. Other examples of neural network-based approaches are
proposed for industrial manufacturing processes [19], power plants [21] and unmanned aerial vehicles [22].
Despite the diversity of existing FDI schemes, most approaches still share certain limitations. The application domains of observer-based techniques are bound by their assumptions about specific system structures, which makes them impractical when such assumptions do not hold. Data-driven methods are relaxed in their assumptions, but this usually comes with the drawback of requiring substantial sensor data, which may be difficult or expensive to obtain.
In this paper, we address these issues by considering FDI using a learning-based approach to nonlinear Luenberger observers, also known as Kazantzis-Kravaris/Luenberger (KKL) observers [23, 24]. KKL observers rely on transforming the original system into a new system of higher dimension, where the transformation is governed by a certain partial differential equation. The observer is then described by the transformed system which is required to be stable up to output injection. An estimate of the system state is obtained by applying the inverse of the transformation to the new system, which takes it back to the original state space. KKL observers are not bound by considerations of specific system forms, instead they rely on certain observability conditions which have been shown to be very mild, making them applicable to a wide range of systems.
The main contribution of this paper includes a full description of a novel fault detection and isolation method that combines model and learning-based techniques using KKL observers. We present a neural network-based approach for approximating the observer transformations, leveraging the fact that any amount of training data can be generated from knowing the system model. We demonstrate the FDI capabilities of our method using numerical simulations, showing that it is able to effectively detect and isolate sensor faults under a variety of circumstances, while remaining robust and functional under the influence of system and measurement noise.
The outline of this paper is as follows: We begin by formulating the sensor FDI problem in Section II. In Section III, we describe the design of KKL observers and provide a detailed step-by-step description of our FDI method. Numerical results are provided in Section IV where we test our method by simulating a variety of fault cases. Lastly, Section V concludes the paper.
## II Problem Formulation
We consider an autonomous nonlinear system
\[\dot{x}(t) =f(x(t))+w(t) \tag{1a}\] \[y(t) =h(x(t))+v(t) \tag{1b}\]
where \(x(t)\in\mathcal{X}\subset\mathbb{R}^{n_{x}}\) is the state, \(y(t)\in\mathbb{R}^{n_{y}}\) is the output, and \(w(t),v(t)\) are bounded process and measurement noises, respectively. The output of the system (1) might be affected by sensor faults, which are modeled by modifying (1b) as
\[y(t)=\phi(t)\left[h(x(t))+v(t)+\zeta(t)\right]. \tag{2}\]
In (2), the measurements are corrupted by two types of faults:
\[\phi(t)=\begin{bmatrix}\phi_{1}(t)&\dots&\phi_{n_{y}}(t)\end{bmatrix}^{ \mathsf{T}}\in[0,1]^{n_{y}}\]
that models complete sensor failure and
\[\zeta(t)=\begin{bmatrix}\zeta_{1}(t)&\dots&\zeta_{n_{y}}(t)\end{bmatrix}^{ \mathsf{T}}\in\mathbb{R}^{n_{y}}\]
that models any type of sensor deterioration affecting the correctness of the output. If \(\phi(t)=1_{n_{y}}\) and \(\zeta(t)=0_{n_{y}}\), then the system is fault-free. Other cases represent multiple type of faults; for example, biasing or precision degradation of sensor \(i\) when \(\zeta_{i}(t)\neq 0\) or failure of sensor \(i\) when \(\phi_{i}(t)=0\).
Our objective is to detect and isolate sensor faults in (1) by designing a nonlinear observer of the form
\[\dot{\hat{z}}(t) =\psi(\hat{z}(t),y(t)) \tag{3a}\] \[\hat{x}(t) =\mathcal{T}^{*}(\hat{z}(t))\] (3b) \[\hat{y}(t) =h(\hat{x}(t)) \tag{3c}\]
which takes measurements \(y(t)\) as input and gives the state estimate \(\hat{x}(t)\) as output. The state \(\hat{z}(t)\in\mathbb{R}^{n_{z}}\) of the observer follows a nonlinear transformation \(\hat{z}=\mathcal{T}(\hat{x})\), where \(\mathcal{T}:\mathcal{X}\rightarrow\mathbb{R}^{n_{z}}\), and \(\mathcal{T}^{*}:\mathbb{R}^{n_{z}}\rightarrow\mathcal{X}\) is the left inverse of \(\mathcal{T}\). More details on these transformations are given in the next section.
The FDI problem can be split into two components:
1. Design (3) so that \(\lim_{t\rightarrow\infty}\|x(t)-\hat{x}(t)\|=0\) when there are no faults.
2. Detect and isolate faults by filtering the output signals of (2) using (3). Then, take the difference between the measured and estimated outputs to form residuals \[r_{i}(t)=|y_{i}(t)-\hat{y}_{i}(t)|,\quad i=1,\dots,n_{y}.\] FDI is then performed by discovering and analyzing anomalies occurring in the residuals.
## III FDI using learning-based KKL-Observer
In this section, we describe the proposed FDI approach using neural network-based observers. First, we briefly recall the theory of KKL observer design. Then, we present a machine learning-based observer design procedure. Finally, we propose our FDI methodology.
### _KKL-Observers_
Consider a nonlinear system
\[\dot{x}(t) =f(x(t)) \tag{4a}\] \[y(t) =h(x(t)) \tag{4b}\]
where \(x(t)\in\mathcal{X}\subset\mathbb{R}^{n_{x}}\) is the system state, \(y(t)\in\mathbb{R}^{n_{y}}\) the measured output, and \(f\) and \(h\) are smooth maps. The KKL observer is designed according to the following steps:
1. Transform (4) to new coordinates by an injective transformation \(\mathcal{T}:\mathcal{X}\rightarrow\mathbb{R}^{n_{z}}\) with \(z=\mathcal{T}(x)\) and \(n_{z}=n_{y}(2n_{x}+1)\) satisfying \[\dot{z}(t)=Az(t)+Bh(x(t));\;\;z(0)=\mathcal{T}(x_{0}),\] (5)
where \(A\in\mathbb{R}^{n_{z}\times n_{z}}\) is a Hurwitz matrix and \(B\in\mathbb{R}^{n_{z}\times n_{y}}\) is such that the pair \((A,B)\) is controllable. From (5), we see that \(\mathcal{T}\) must be governed by the partial differential equation (PDE) \[\frac{\partial\mathcal{T}(x)}{\partial x}f(x)=A\mathcal{T}(x)+Bh(x).\] (6)
2. Find the left inverse \(\mathcal{T}^{*}:\mathbb{R}^{n_{z}}\rightarrow\mathcal{X}\) of \(\mathcal{T}\), i.e, \(\mathcal{T}^{*}(\mathcal{T}(x))=x\), which exists due to the injectivity of \(\mathcal{T}\). Then, the KKL observer is given by \[\dot{z}(t) =Az(t)+By(t);\;\;\;z(0)=z_{0}\] (7a) \[\dot{x}(t) =\mathcal{T}^{*}(z(t))\] (7b) where \(\dot{x}(t)\) is the state estimate obtained from the observer.
The existence of (7) is guaranteed if (4) is _forward complete within \(\mathcal{X}\)_ and _backward \(\mathcal{O}\)-distinguishable_. We omit the details in this paper and refer to [24] for further details.
### _Machine Learning Approach for KKL Observer Design_
The design principle described in Section III-A relies on an injective transformation \(\mathcal{T}\) satisfying (6) and its inverse \(\mathcal{T}^{*}\). However, finding exact \(\mathcal{T}\) and \(\mathcal{T}^{*}\) are generally difficult. Even if \(\mathcal{T}\) is known, finding \(\mathcal{T}^{*}\) is very challenging [25]. We overcome these challenges by approximating the transformations using a _supervised physics-informed learning_ approach [26]. More specifically, we generate synthetic training data by simulating (4) and (5) to accurately capture the maps between their state spaces. We then perform nonlinear regression under the constraint of (6) to learn the approximate transformations. Relying on the theoretical results of [26], the convergence of the observer is guaranteed if the approximation error is sufficiently small. Assuming a well-trained model, the learning-based observer is capable of generalizing to previously unseen initial conditions and trajectories [26].
#### Iii-B1 Generation of Training Data
An arbitrary amount of training data may be generated by knowing the structure of (4) and (5). We begin by choosing \(p\) pairs of initial conditions \((x_{0}^{i},z_{0}^{i}),i=1,\ldots,p\) from the defined sets \(\mathcal{X}^{\text{train}}\subset\mathcal{X}\) and \(\mathcal{Z}^{\text{train}}\subset\mathbb{R}^{n_{z}}\). It is imperative that the points \(x_{0}^{i}\) are well distributed within \(\mathcal{X}^{\text{train}}\) in order to fully capture the transformations. This can be accomplished by using statistical methods such as Latin hypercube sampling suggested in [27]. Since we do not know \(\mathcal{T}\) in advance, it is impossible to sample from \(\mathcal{Z}^{\text{train}}\) so that \(z_{0}^{i}=\mathcal{T}(x_{0}^{i})\). Instead, we utilize a truncation method proposed in [26, 28].
The procedure of generating training data is as follows:
1. Choose \(p\) number of pairs of initial conditions \((x_{0}^{1},z_{0}^{1}),\ldots,(x_{0}^{p},z_{0}^{p})\).
2. Simulate (4) and (5) for a finite time \(t_{s}>0\) to obtain trajectories \[(x(t_{k};x_{0}^{1}),z(t_{k};z_{0}^{1})),\ldots,(x(t_{k};x_{0}^{p}),z(t_{k};z_{ 0}^{p}))\] with \(k=0,1,2,..,s\) and \(s\) being the number of samples.
3. Divide1 the dataset into _physics data points_\(\mathsf{P}_{p}\) and _regression data points_\(\mathsf{P}_{r}\). One way to accomplish this is to choose \(\mathsf{P}_{r}\) as all samples with an even index, and \(\mathsf{P}_{p}\) as all with an odd index. Footnote 1: This is motivated by the use of physics-informed neural networks [29].
#### Iii-B2 Learning the Transformations
We learn the transformation and its inverse by considering two neural networks \(\hat{\mathcal{T}}_{\theta}\) and \(\hat{\mathcal{T}}_{\eta}^{*}\), where \(\theta\) and \(\eta\) are the trainable parameters of the network. Both neural networks are trained jointly in an encoder-decoder architecture by minimizing a loss function consisting of a _regression loss_ and a _physics loss_. We define the regression loss as the mean squared error
\[\mathcal{L}_{\text{reg}}(\theta,\eta)\doteq\frac{1}{p}\sum_{i=1}^ {p}\frac{1}{|\mathsf{P}_{r}|}\sum_{k\in\mathsf{P}_{r}}\left\|z^{i}(t_{k})-\hat{ \mathcal{T}}_{\theta}(x^{i}(t_{k}))\right\|^{2}\\ +\chi\big{\|}x^{i}(t_{k})-\hat{\mathcal{T}}_{\eta}^{*}(\hat{ \mathcal{T}}_{\theta}(x^{i}(t_{k})))\big{\|}^{2} \tag{8}\]
where \(\chi\) is a discount factor balancing the two loss terms. The function (8) uses the available information about \(x^{i}(t_{k})\) and \(z^{i}(t_{k})\) to minimize the deviations in both the latent space and the final output. Furthermore, we leverage knowledge of the fact that a good approximation \(\hat{\mathcal{T}}_{\theta}\) should satisfy the PDE (6) by defining a physics loss as the PDE residual
\[\mathcal{L}_{\text{phy}}(\theta)\doteq\frac{1}{p}\sum_{i=1}^{p} \frac{1}{|\mathsf{P}_{p}|}\sum_{k\in\mathsf{P}_{p}}\big{\|}\frac{\partial \hat{\mathcal{T}}_{\theta}}{\partial x}(x^{i}(t_{k}))f(x^{i}(t_{k}))\\ -A\hat{\mathcal{T}}_{\theta}(x^{i}(t_{k}))-Bh(x^{i}(t_{k}))\big{\|} ^{2}. \tag{9}\]
This has the effect of reducing the risk of overfitting while also improving the generalization capabilities of the neural networks. Combining (8) and (9), we define the loss function to be
\[\mathcal{L}(\theta,\eta)\doteq\mathcal{L}_{\text{reg}}(\theta,\eta)+\lambda \mathcal{L}_{\text{phy}}(\theta) \tag{10}\]
where \(\lambda>0\) is a hyperparameter acting as a balancing factor for the two loss terms.
### _Performing Fault Detection and Isolation_
Our method detects and isolates faults by discovering rapid changes in the residual signals \(r_{i}(t)\) caused by fault induced observer transients. This is accomplished by defining a threshold \(r_{\Delta}\). Due to the inevitability of approximation errors in \(\hat{\mathcal{T}}_{\theta}\) and \(\hat{\mathcal{T}}_{\eta}^{*}\), and the presence of noise in (1), the residuals \(r_{i}\) will never converge to zero. Therefore, to avoid false positive alarms, it is important to distinguish between the non-zero residuals due to noise and approximation error and the increase in residual magnitude due to sensor faults. However, the introduction of a fault in a sensor will not only induce a transient in the corresponding output estimate, but in all other estimated outputs as well. Therefore, fault in one sensor could induce large residuals for the output estimates of other sensors, which may cause problem in fault isolation. Moreover, because of these inter-dependencies, the transients after the occurrence of fault may persist above the threshold, leading to an inability to even detect other subsequent faults.
Therefore, instead of using residuals \(r_{i}(t)\), we propose to use the finite difference approximation of its derivative to perform FDI, i.e.,
\[\tilde{r}_{i}(t_{k})=\left|\frac{r_{i}(t_{k})-r_{i}(t_{k-1})}{h}\right|,\quad i=1,\ldots,n_{y} \tag{11}\]
where \(\tilde{r}_{i}(t_{k})\) is the numerical approximation of \(\frac{dr_{i}(t_{k})}{dt}\) with \(h\) being the step size between samples. This remedies the unwanted influence of other transients and allows for efficient and reliable FDI, which is illustrated in the simulations.
The method for computing the threshold \(r_{\Delta}\) is described below:
1. Draw \(N\) initial conditions to form a set \(\mathcal{X}^{r_{\Delta}}\in\mathcal{X}\), with \(\mathcal{X}^{r_{\Delta}}\) satisfying \(\mathcal{X}^{r_{\Delta}}\cap\mathcal{X}^{\text{train}}=\emptyset\) to simulate realistic operating conditions with previously unseen data.
2. From each initial condition, generate measured and estimated output trajectories \((y^{1}(t),\ldots,y^{N}(t))\) and \((\hat{y}^{1}(t),\ldots,\hat{y}^{N}(t))\), by simulating (1) and (7), replacing \(\mathcal{T}^{*}\) with \(\tilde{\mathcal{T}}^{*}_{\eta}\).
3. For each measured and estimated output pair, compute (11).
4. The threshold \(r_{\Delta}\) is then taken as the maximum of all finite difference approximations.
To eliminate the influence of initial transients, which may cause \(r_{\Delta}\) to become unnecessarily large, we truncate the measured and estimated output trajectories at some time \(t_{\text{run}}>0\). A simple way to empirically choose \(t_{\text{run}}\) is to simulate the observer dynamics and select a time at which the transients have vanished. A fault is considered to be detected whenever any \(\tilde{r}_{i}(t_{k})>r_{\Delta}\).
## IV Simulation Results
Our approach is demonstrated in this section using numerical simulations. We show that FDI of a highly nonlinear system can be achieved using neural network-based KKL-observers, even in the presence of additive process and measurement noises. Both types of faults, sensor deterioration represented by the fault signal \(\zeta_{i}(t)\neq 0\) and sensor failure represented by \(\phi_{i}(t)=0\) in (2), are demonstrated.
### _Kuramoto Model_
We consider the Kuramoto model for demonstrating our FDI method. The Kuramoto model describes the phenomena of synchronization in a multitude of systems, including electric power networks, multi-agent coordination, and distributed software networks [30]. The dynamics of a network with \(n\) nodes are given as
\[\dot{\theta_{i}}(t)=\omega_{i}+\sum_{j=1}^{n}a_{ij}\sin(\theta_{i}(t)-\theta_ {j}(t)) \tag{12}\]
where \(\theta_{i}(t)\in\mathbb{S}^{1}\) is the phase angle of node \(i=1,..,n\), \(\omega_{i}\in\mathbb{R}\) is the natural frequency of node \(i\), and \(a_{ij}\geq 0\) denotes the coupling between node \(i\) and \(j\). In the literature, the state trajectories of (12) are often represented graphically as \(\sin(\theta_{i})\) in order to better illustrate their synchronization. We follow the same convention in our simulations.
### _Experimental Setup_
For (12), we consider a network of 10 nodes with randomly generated natural frequencies \(\omega_{i}\) and couplings \(a_{ij}\). The measurements are chosen as \(y=\begin{bmatrix}\theta_{1}&\theta_{2}&\theta_{3}&\theta_{4}&\theta_{5}\end{bmatrix}^ {\mathsf{T}}\). A set of 50 initial conditions are generated using Latin hypercube sampling, with \(\chi^{\text{train}}\in[-2,2]^{10}\). We choose Runge-Kutta-4 as our numerical ODE solver to simulate (12) and (5) over a time interval of \([0,30]\), partitioned into 4000 sample points for each trajectory. The neural networks \(\tilde{\mathcal{T}}_{\theta}\) and \(\tilde{\mathcal{T}}^{*}_{\eta}\) are chosen to be fully connected feed-forward networks, each consisting of 3 hidden layers of 250 neurons with ReLU activation function. Model training is facilitated by data standardization and learning rate scheduling. Following [31], the matrices of (5) are chosen as
\[A=\Lambda\otimes I_{n_{y}},\qquad B=\Gamma\otimes I_{n_{y}}\]
where \(\Lambda\in\mathbb{R}^{(2n_{x}+1)\times(2n_{x}+1)}\) is a diagonal matrix with diagonal elements linearly distributed in \([-15,-21]\), \(\Gamma\in\mathbb{R}^{2n_{x}+1}\) is a column vector of ones, and \(I_{n_{y}}\) is the identity matrix of size \(n_{y}\times n_{y}\). Here, \(n_{x}\) and \(n_{y}\) are 10 and 5, respectively, and \(n_{z}=n_{y}(2n_{x}+1)=105\).
The estimation capabilities of the observer under fault-free conditions are demonstrated in Fig. 1, which shows the estimated and true trajectories of two (randomly chosen) unmeasured states \(\theta_{7}\) and \(\theta_{8}\) over a time interval of \([0,20]\), with noise terms \(w(t),v(t)\sim\mathcal{N}(0,0.02)\). The figure demonstrates that the estimation error is stable under noise and neural network approximation error.
### _Numerical Results_
We now apply the learned neural network-based KKL observer to perform FDI. The fault threshold \(r_{\Delta}=7.1\) is computed according to the method described in Section III-C. We choose \(N=100\) initial conditions to create \(\mathcal{X}^{r_{\Delta}}\in[-2,2]^{10}\), again using Latin hypercube sampling. Fig. 1(a)-1(e) demonstrate the detection and isolation capabilities of our method under a variety of faults. In the figure, the first, second, and third rows correspond to the finite difference approximation (11), measured and estimated state trajectories, and the residuals \(r_{i}=|y_{i}-\hat{y}_{i}|\), respectively.
In Fig. 1(a), sensor \(2\) is disturbed by a constant fault term \(\zeta_{2}(t)=1\) introduced at \(t=5\) and ending at \(t=15\). The observer is able to follow the measured state trajectories
Fig. 1: Estimated and true trajectories of states \(\theta_{7}\) and \(\theta_{8}\) under the influence of process and sensor noise.
despite the presence of process and measurement noise, thus generating a small residual when no faults are present. The introduction of a fault induces a transient in the observer, causing a large residual to be generated for the disturbed state. Due to the stability of the observer, it will attempt to track the faulty trajectories after the occurrence of fault, leading to a decrease in the residual magnitudes. A new transient is induced upon the end of the fault term, creating the sharp "spikes" shown in the figure. The differences between using (11) and the generated residuals can be seen by comparing the top and bottom figures. It is clear that by approximating \(\frac{dr_{i}(t_{b})}{dt}\), the anomaly caused by \(\zeta(t)\) can be isolated from other simultaneously occurring transients.
Fig. 1(b) illustrates the situation when more than one fault is present. Sensors \(1\) and \(5\) are disturbed by \(\zeta_{1}(t)=\zeta_{5}(t)=1\), during \(t=5\) to \(t=10\), and \(t=7\) to \(t=15\) respectively. Each fault is distinctly detectable at the moment of occurrence. Again, using the finite difference approximations allows for isolation of the affected states by dampening the undesired transients.
In Fig. 1(c), we show that our method is also capable of detecting complete sensor shutdowns, which we demonstrate by modeling the fault in sensor \(4\) with \(\phi_{4}(t)=0\).
Fig. 1(d) and 1(e) illustrates the case when the fault signal on sensor \(3\) is a sin-wave
\[\zeta_{3}(t)=A\sin(\omega t) \tag{13}\]
where \(A\) is the amplitude and \(\omega\) the angular frequency. In Fig. 1(d), we simulate a fault in sensor \(y_{3}\) with \(A=5\) and \(\omega=2\pi\) rad\(/s\). In Fig. 1(e), the amplitude remains unchanged, but the angular frequency is increased to \(\omega=20\pi\) rad\(/s\). Unsurprisingly, an increase in frequency results in more prominent responses.
Note that the large spikes in the residuals and finite differences seen at the beginning of each figure is also a result of the observer transients, due to the full system state being unknown upon initialization. This should therefore be treated as an expected behavior and ignored in practice.
## V Conclusion and Future Work
We have presented a novel method for sensor fault detection and isolation using neural network-based observers. Our approach is effective in both fault detection and isolation, and it has the potential to be applied to a wide range of systems because it is not restricted to nonlinear systems with specific form or structure. Instead, it relies only on a certain observability condition of the system. We described a method to systematically design an observer, using neural networks to learn an injective transformation and its inverse. A state
Fig. 2: (a) Sensor deterioration in \(y_{2}\) with constant fault term. (b) Sensor deterioration in \(y_{1}\) and \(y_{5}\) at different time points with constant fault terms. (c) Shutdown of sensor \(y_{4}\). (d), (e) Sensor deterioration in \(y_{3}\) with a sinusoidal fault term.
estimate is obtained by transforming the original nonlinear system into a new one that is a stable linear system with output injection, and then applying the inverse transform back to its original state space. Sensor faults are detected by generating a residual, defined as the absolute difference between measured and estimated state values. We propose to monitor the time derivative of the residual signal by using the finite difference approximation. An empirical threshold is computed which if crossed, signifies the occurrence of a fault. We tested our method on a network of Kuramoto oscillators by simulating a variety of fault cases, including precision degradation due to sensor deterioration (injection of constant and sinusoidal fault signals) and sensor shutdown due to complete failure. The simulations demonstrated the effectiveness of our method in both fault detection and isolation.
The theory of KKL observers extends to non-autonomous systems, and adapting our method to those systems remains an open research topic. It is also of interest to study the performance of the method in the real world, especially in systems where conventional solutions are known to fail. Developing analytic methods to compute the threshold for residuals will also be considered in the future.
|
2302.05045 | Exploiting Sparsity in Pruned Neural Networks to Optimize Large Model
Training | Parallel training of neural networks at scale is challenging due to
significant overheads arising from communication. Recently, deep learning
researchers have developed a variety of pruning algorithms that are capable of
pruning (i.e. setting to zero) 80-90% of the parameters in a neural network to
yield sparse subnetworks that equal the accuracy of the unpruned parent
network. In this work, we propose a novel approach that exploits these sparse
subnetworks to optimize the memory utilization and communication in two popular
algorithms for parallel deep learning namely -- data and inter-layer
parallelism. We integrate our approach into AxoNN, a highly scalable framework
for parallel deep learning that relies on data and inter-layer parallelism, and
demonstrate the reduction in communication time and memory utilization. On 512
NVIDIA V100 GPUs, our optimizations reduce the memory consumption of a 2.7
billion parameter model by 74%, and the total communication time by 40%, thus
providing an overall speedup of 34% over AxoNN, 32% over DeepSpeed-3D and 46%
over Sputnik, a sparse matrix computation baseline. | Siddharth Singh, Abhinav Bhatele | 2023-02-10T04:22:25Z | http://arxiv.org/abs/2302.05045v3 | # Exploiting Sparsity in Pruned Neural Networks to Optimize Large Model Training
###### Abstract
Parallel training of neural networks at scale is challenging due to significant overheads arising from communication. Recently, deep learning researchers have developed a variety of pruning algorithms that are capable of pruning (i.e. setting to zero) 80-90% of the parameters in a neural network to yield sparse subnetworks that equal the accuracy of the unpruned parent network. In this work, we propose a novel approach that exploits these sparse subnetworks to optimize the memory utilization and communication in two popular algorithms for parallel deep learning namely - data and inter-layer parallelism. We integrate our approach into AxoNN, a highly scalable framework for parallel deep learning that relies on data and inter-layer parallelism, and demonstrate the reduction in communication time and memory utilization. On 512 NVIDIA V100 GPUs, our optimizations reduce the memory consumption of a 2.7 billion parameter model by 74%, and the total communication time by 40%, thus providing an overall speedup of 34% over AxoNN, 32% over DeepSpeed-3D and 46% over Sputnik, a sparse matrix computation baseline.
lottery ticket hypothesis, sparse computations, GPUs, parallel deep learning, memory optimizations
## I Introduction
Deep learning researchers have observed that increasing the size of a neural network almost always leads to better generalization i.e., accuracies on test data [1]. This has led to the development of neural architectures with billions of parameters [2], which are naturally trained in parallel on large GPU clusters due to their extreme compute and memory requirements. The progressive increase in neural network sizes has necessitated a corresponding increase in the number of GPUs to train them. However, with increasing GPU counts, communication becomes a significant bottleneck in the training procedure. Thus, designing algorithms that can improve the efficiency of training at scale is extremely critical. This will ensure that we can harness the proven benefits of growing network sizes while being able to train them in a reasonable amount of time.
The number of parameters in contemporary deep learning models is often in the tens to hundreds of billions. In their work on the _lottery ticket hypothesis_ (LTH), Frankle et al. observe empirically that a large fraction of the parameter set (80-90%) can be pruned (set to zero) at initialization without affecting the generalization performance on test data [3]. Subsequently, this phenomenon has witnessed great interest from the deep learning community and several follow up studies have tried to further refine the hypothesis, propose efficient pruning algorithms and/or prove it for a broader class of neural network architectures [4, 5, 6, 7, 8, 9].
Pruning algorithms output extremely sparse subnetworks, which in theory require significantly fewer number of floating point operations as compared to the unpruned networks. Several sparse matrix multiplication kernels for GPUs have been proposed that are specifically optimized for the patterns of sparsities in these subnetworks [10, 11, 12]. However, in spite of the advancements, these approaches are significantly slower than cuBLAS, a popular library for dense matrix multiplications on NVIDIA GPUs (used by deep learning frameworks such as PyTorch and Tensorflow). In Figure 1, we demonstrate that computing a fully connected layer with 90% sparsity using cuBLAS (we fill out zeros explicitly in the dense matrix) is 6-22\(\times\) faster than using Sputnik [11], a state-of-the-art sparse matrix multiplication library for deep learning workloads. This suggests that utilizing sparse matrix libraries to improve training performance is currently infeasible.
Instead of trying to optimize comp
Fig. 1: Comparison of the execution times of a fully-connected (FC) layer with a randomly generated, 90% sparse, square weight matrix in mixed precision. FC layers compute a linear transform of their input and are a vital component of various neural network architectures such as transformers [2]. For dense GPU kernels, we use NVIDIA’s cuBLAS, whereas for sparse GPU kernels, we use NVIDIA’s cuSPARSE and Sputnik [11]. We fix the input batch size to 576 and vary the size of the weight matrix from \(128^{2}\) to \(4096^{2}\).
work, we focus on exploiting sparsity to optimize memory utilization, and then exploit the saved memory to optimize communication. We demonstrate how our optimizations can greatly reduce the communication times of two widely used parallel algorithms for deep learning - namely inter-layer parallelism (point-to-point communication) and data parallelism (collective communication). First, we propose a novel approach, which we call Sparsity-aware Memory Optimization (SAMO), that provides memory savings of around 66-78%, while still being compute efficient. Through analytical communication models as well as experiments, we demonstrate that these memory savings can be utilized to reduce both the message transmission time as well as the pipeline latency (often called "bubble" time) of inter-layer parallelism. Finally, for data parallelism we only communicate the gradients corresponding to the non-zero (or unpruned) parameters, decreasing the message sizes, and thus alleviating the bottleneck of expensive all-reduce communication.
To demonstrate the efficacy of our optimizations, we integrate our method in AxoNN [13], a highly scalable framework for parallel deep learning that implements an efficient hybrid of data and inter-layer parallelism. On GPT-3 2.7B [2], a 2.7 billion parameter model, we demonstrate that SAMO reduces the memory consumption by 74% (from 80.16 GB to 20.28 GB)! Then, for a strong scaling run of the same model on 128-512 V100 GPUs of Summit, we successfully exploit the freed up memory to reduce the portion of batch spent in communication. We show that the absolute reduction in the communication time accounts for 40% of AxoNN's batch time on 512 GPUs. This makes our method a significant 34% faster than AxoNN, 32% faster than DeepSpeed-3D [14], and 46% faster that Sputnik [11]. Since Sputnik is designed for single GPU executions, we integrate it in AxoNN to run it in parallel. We summarize the important contributions of this work below:
* We present Sparsity-aware Memory Optimization (SAMO), a novel method that exploits recently proposed accuracy-preserving parameter pruning algorithms in deep learning, to significantly reduce the memory consumption of neural network training while not sacrificing performance.
* Through analytical communication models and experiments, we demonstrate how these memory savings can be utilized to significantly improve the communication performance of two popular algorithms for parallel deep learning, data and inter-layer parallelism.
* We conduct strong scaling experiments using popular convolution neural network architectures and transformer-based language models with 1.3 to 13 billion parameters on 16 to 2048 GPUs, and demonstrate significant improvements in communication times when compared with two highly scalable parallel deep learning frameworks AxoNN and DeepSpeed-3D.
## II Background and Related Work
Below, we provide background on neural network pruning, sparse matrix multiplications, and parallel deep learning.
### _Over-parameterization in neural networks_
We call a neural network over-parameterized, when its size is extremely large as compared to the training dataset. It has been empirically observed that the more over-parameterized a neural network gets, the better it seems to generalize on a held out test dataset [1]. Indeed, the largest neural networks in deep learning (like the GPT-3 [2]) are massively over-parameterized. This perplexing phenomenon, that cannot be explained by classical machine learning, has been an active area of research in deep learning [15, 16, 17, 18, 19, 1].
### _Lottery ticket hypothesis_
Proposed by Frankle et al. [3]., the lottery ticket hypothesis (LTH) asserts that in a randomly-initialized, over-parameterized neural network, there exists a subnetwork with one- to two-tenths of the parameters, which when trained in isolation can match and even improve the test-set performance of the original neural network. They theorize that in an over-parameterized network, it is this subnetwork that effectively ends up being trained, thus preventing over-fitting. They also present a simple algorithm to identify this subnetwork. Several follow up studies have tried to further refine the hypothesis, propose efficient pruning algorithms and/or prove it for a broader class of neural network architectures [4, 5, 6, 7, 8, 9]. In this work, we use You et al.'s algorithm for pruning [4].
### _Accelerated sparse kernels_
NVIDIA's cuSPARSE is designed for sparse matrices seen in scientific applications which have extremely high sparsities (\(>\)99%). Therefore, it is not a suitable candidate for the kinds of sparsities observed in neural network pruning (\(<\)90%). A number of approaches have been proposed that can operate in these levels of sparsities. Yang et al. augment merge-based algorithms with a novel row-based splitting technique to hide memory access latency [12]. Hong et al. design spMM and sDDMM (used for backward pass of a fully connected layer) that exploit an adaptive tiling strategy to reduce global memory access [10]. Gale et al. conduct an extensive survey of the sparsity patterns found in matrices across a variety of deep learning workloads [20]. Using the insights drawn from this study, they design state-of-the-art sparse kernels for spMM and sDDMM for deep learning workloads [11]. A number of approaches have been proposed that enforce a certain sparsity structure. Gray et al. design GPU kernels for block sparse matrices [21]. Chen et al. propose a novel column-vector-sparse-encoding for block sparse matrices that provides speedup over cuBLAS at sparsities as low as 70% at mixed precision [22]. Dao et al. propose a technique to reduce linear maps to a product of diagonal block sparse matrices and design kernels for computing their products efficiently [23, 24].
### _Types of parallelism in deep learning_
Three kinds of parallelism, namely intra-layer, inter-layer and data parallelism have been proposed in parallel deep learning. Intra-layer parallelism divides the execution of each layer across GPUs [25]. Inter-layer parallelism assigns a
contiguous subset of neural network layers to each GPU [26, 27, 28]. Data parallelism creates a replica of the entire network on each GPU [29, 30]. Usually, frameworks for parallel deep learning implement a hybrid of data parallelism with one or both of intra- and inter-layer parallelism [28, 14, 29]. For more details, we refer the reader to Ben-Nun et al. [31].
### _The AxoNN deep learning framework_
In this paper, we implement our ideas in a state-of-the-art framework, AxoNN, for parallel deep learning [13]. AxoNN implements a hybrid of inter-layer and data parallelism. It divides the set of GPUs into \(G_{data}\) groups. Each of these groups operates on an equal sized shard of the input batch, thus implementing data parallelism. Within each group, there are \(G_{inter}\) GPUs implementing inter-layer parallelism. To achieve concurrency within this inter-layer parallel groups, AxoNN breaks up the input batch shard into several "microbatches" and processes them in a pipelined fashion. Activations and gradients for a microbatch are exchanged among neighboring GPUs using point-to-point communication. As compared to other frameworks, AxoNN optimizes this communication by employing i. asynchronous messaging ii. message driven scheduling of microbatch operations. The former allows it to overlap communication with computation, whereas the latter allows it to reduce pipeline stalls. AxoNN supports mixed precision training [32] and activation checkpointing [33].
## III Sparsity-aware Memory Optimization
In this section, we discuss our approach to exploit sparse networks generated by pruning methods to significantly reduce the memory consumption of large model training. We refer to our approach as Sparsity-aware Memory Optimization (SAMO). We discuss SAMO in the context of mixed-precision training [32], which is the predominant mode used for the training of large multi billion-parameter models [29, 34, 35]. However, the optimizations discussed below are general and can also be applied to single-precision training.
Mixed-precision training involves storing the model parameters and gradients in both 16-bit (half-precision) and 32-bit (single-precision), and the optimizer states in 32-bit. The expensive forward and the backward pass are computed in 16-bit for efficiency, whereas the relatively cheaper optimizer step is done in 32-bit for accuracy. For more details, we refer the reader to Micikevicius et al. [32].
Model parameters, gradients and optimizer states are collectively referred to as the model state [29]. While mixed-precision is compute efficient, storing parameters and gradients in two precisions results in significantly high memory consumption [29] (25% more than single-precision training). For example, in the case of the widely used GPT-3 [2], this adds up to a significant 3.5 TB. For comparison, the DRAM capacity of a single V100 GPU on Summit is a mere 16GB.
Before discussing the details of our approach, we define certain variables as follows:
* Network parameters in 16
- and 32-bit representation respectively
* Network gradients in 16
- and 32-bit representation respectively
* 32-bit optimizer states for the network
* output of a parameter pruning algorithm, where \(\mathrm{ind}_{i}\) stores the indices of the unpruned (non-zero) parameters for the \(i\)th layer.
Now, we present how SAMO can help us in significantly reducing the model state memory requirements. Note that SAMO can be applied only after a neural network has been sparsified using a pruning algorithm.
### _Performance-preserving model state compression_
We have already seen in Figure 1 that computing the forward and backward passes with compressed sparse parameter tensors on GPUs is not a feasible approach. Thus, a memory optimization that tries to compress model states will be efficient only if it is able to utilize dense computation kernels on the GPU. Two important observations about the training process drive the design of our memory optimizations. First, most of the compute in neural network training happens in the forward and the backward pass. Second, out of the various model state tensors discussed previously, the forward and backward passes exclusively use \(\theta^{16}\) for computation. Thus, we do not compress \(\theta^{16}\). This allows us to directly invoke dense computation kernels on GPUs. For saving memory, we compress the other model states i.e., \(\theta^{32}\), \(\nabla\theta^{16}\), \(\nabla\theta^{32}\), and \(os\), which together still comprise 90% of the model state memory, even without \(\theta^{16}\)! By keeping \(\theta^{16}\) in an uncompressed format, we thus tradeoff a small proportion of the maximum possible memory savings to gain efficiency in compute.
### _Implementation of compressed storage_
To compress a model state, we convert it to a sparse coordinate (COO) format using the indices of the unpruned parameters (i.e. \(\mathrm{ind}\)) output by the pruning algorithm. However, being 32-bit (32-bit is sufficient for storing the indices of even the largest models in existence) integers, \(\mathrm{ind}\) occupies a non-trivial amount of GPU memory. We tackle this issue in two ways. First, we note that all of the model state tensors have zeros at the same indices. Therefore, in our storage scheme, the various COO tensors (i.e. \(\theta^{32}\), \(\nabla\theta^{16}\), \(\nabla\theta^{32}\), and \(os\)) share a common index tensor of non-zero values. Secondly, we convert the index tensors of any layer to those of a hypothetical one-dimensional view. As an example, say the non-zero indices for a \(2\times 2\) state tensor are \([(0,0),(1,1)]\). In a one dimensional view of the same state tensor (i.e. \(4\times 1\)), the non-zero values are at indices 0 and 3. Thus, we can save memory by storing only 2 integers (i.e. \([0,3]\)), without any loss of information. In general, for an N-dimensional state tensor, this saves us N\(\times\) memory. Having discussed how the various model states are stored by SAMO to optimize for memory, let us now look at how we compute a batch of data with this storage schema.
### _Training with SAMO_
The computation of a batch in neural network training can be divided into three phases - the forward pass, the backward
pass and the optimizer step. The forward pass computes the batch loss, the backward pass computes the gradients of the parameters w.r.t. the batch loss, and the optimizer step updates the parameters. Let us now look at how these phases are computed efficiently using SAMO.
**Forward Pass:** The forward pass of a neural network is done using the half-precision parameters, \(\theta^{16}\). As discussed in Section III-A, we store \(\theta^{16}\) in an uncompressed format with zeros explicitly filled in for pruned parameters. This allows us to exploit efficient dense computation kernels for GPUs, like those available in cuBLAS and cuDNN. Thus, the forward pass with SAMO is exactly the same as that in normal mixed precision training without SAMO.
**Backward Pass:** The backward pass also uses \(\theta^{16}\) to compute the batch gradients. Therefore, just like the forward pass, we are able to directly invoke efficient dense computation kernels. However, in Section III-A, we discussed that we store the half-precision gradients in a compressed state i.e. only for the unpruned parameters. Thus, we modify the backward pass to compress the gradients as soon as they are produced for any layer. We do this at the granularity of a layer, and not the entire model, so that we never have to store the uncompressed gradients for the entire model on the GPU memory.
**Optimizer Step:** In mixed precision training, the optimizer step consists of three element wise operations. The first step involves upscaling \(\nabla\theta^{16}\) to \(\nabla\theta^{32}\). The second step is running the optimizer using the upscaled gradients \(\nabla\theta^{32}\) and the optimizer states, \(os\) to update the 32-bit parameters, \(\theta^{32}\). The final step is to downscale \(\theta^{32}\) to \(\theta^{16}\). Let us now see how these three steps are done with SAMO.
We do the first step of upscaling \(\nabla\theta^{16}\) to \(\nabla\theta^{32}\) directly on the compressed tensors itself (as the values for the pruned parameters are always zero) using dense computation kernels. Again due to the same reason, the second step of running the optimizer can be directly computed on the compressed state tensors using dense kernels. This yields the updated parameters in 32-bit i.e., \(\theta^{32}\). The final step of downcasting \(\theta^{32}\) to \(\theta^{16}\) is not straightforward because these tensors are in a compressed and uncompressed state respectively. To solve this, we first define a new operation,"expansion", as the inverse operation of compression. Essentially, it takes a compressed tensor and the indices of the non-zero parameters to output the uncompressed version. Now, we do the parameter down-casting in three steps. First, we delete the now old uncompressed \(\theta^{16}\) from the GPU memory. Then we make a copy of \(\theta^{32}\) in 16-bit. Note that this is essentially the compressed version of our 16-bit parameters. Finally, we "expand" this copy using \(\mathrm{ind}\) to obtain the updated \(\theta^{16}\). Thus, the only modification to the optimizer step is an "expand" operation in the down-casting step.
### _Analytical model of memory savings_
In this section, we derive the memory savings as a result of storing model states with SAMO. We assume that the optimizer of choice is Adam [36], which is the go-to optimizer in deep learning for large model training. Adam stores two optimizer states per parameter. However, SAMO can be easily extended to work with other optimizers as well.
First let us derive the model state memory consumption without pruning. Let \(\phi\) be the total number of parameters in the neural network before pruning. Now, \(\theta^{16}\) and \(\nabla\theta^{16}\) take up \(2\phi\) bytes each, whereas \(\theta^{32}\) and \(\nabla\theta^{32}\) take up \(4\phi\) bytes each. Finally, \(\mathrm{os}\), which are stored in single precision take up \(8\phi\) bytes. This adds up to a total of \(20\phi\) bytes (2+2+4+4+8). Let us call this quantity \(M^{default}\).
Now, let us assume that we are uniformly pruning \(p\) fraction of the parameters before applying SAMO. This leaves us with \((1-p)\phi\) unpruned parameters. Let \(f=1-p\). We first calculate the memory required to store the compressed model states i.e. all model states except \(\theta^{16}\). For each of these tensors, we only need to maintain data for \(f\phi\) parameters. This adds upto \(18f\phi\) bytes ( \(2f\phi\) bytes for \(\nabla\theta^{16}\), \(4f\phi\) each for \(\theta^{32}\) and \(\nabla\theta^{32}\), and another \(8f\phi\) for \(\mathrm{os}\) ). We also maintain a non-zero index per unpruned parameter. In our storage scheme, each non-zero index is a 32-bit integer. This requires another \(4f\phi\) bytes. Storing the uncompressed \(\theta^{16}\) state tensor adds a further \(2\phi\) bytes. Note that our optimizer step creates a temporary compressed copy of the half precision parameters at the end of the optimizer step (See Section III-C). This adds another \(2f\phi\) bytes. Adding everything together, the total memory consumption of model state storage in bytes is :
\[M^{SAMO} =18f\phi+4f\phi+2\phi+2f\phi \tag{1}\] \[=24f\phi+2\phi\] (2) \[=24(1-p)\phi+2\phi\] (3) \[=20\phi-(24p-6)\phi\] (4) \[=M^{default}-(24p-6)\phi \tag{5}\]
In other words, the absolute amount of memory savings that SAMO provides is \((24p-6)\phi\) bytes, where p is the fraction of parameters that have been pruned and \(\phi\) is the total number of parameters before pruning. In Figure 2, we plot the percentage memory saved by SAMO as compared to default mixed-precision training. We observe that, SAMO requires a minimum sparsity of 0.25 to break even in terms of memory consumption. However, given that most DL pruning algorithms can comfortably prune 80-90% of the parameters, this is not an issue. In this range of sparsities, we observe that our method saves a significant 66-78% of memory required to store model states!
## IV Exploiting SAMO for Improving Parallel Training Performance
When computing on a single GPU, SAMO simply reduces memory consumption with some overheads in the backward pass (compression of gradients) and the optimizer step (expansion of parameters). Hence, when training on a single GPU, SAMO does not lead to any performance improvements. This is because the total number of floating point operations in the forward and backward pass is unchanged (since we still compute in dense). In this section, we discuss how parameter
pruning and SAMO can be used to optimize the performance of multi-GPU training.
The main performance bottleneck in parallel neural network training is communication. GPUs perform computation on data at a much faster rate than that of data communication between them on modern HPC interconnects. This problem is only exacerbated when training larger models, which require a correspondingly larger number of GPUs on a cluster. Thus, designing algorithms that can decrease the amount of communication can greatly benefit parallel deep learning. We now discuss how the application of SAMO on a pruned neural network can reduce communication in parallel training. As discussed in Section II, we use AxoNN, which implements a hybrid of inter-layer parallelism (point-to-point communication) and data parallelism (collective communication), to demonstrate the efficacy of our optimizations.
### _Optimizing collective communication in data parallelism_
First, let us see how our optimizations can decrease the overhead of collective communication in the data parallel phase. After the end of the forward and backward pass, AxoNN synchronizes the local gradients of each GPU via an all-reduce. In Section III-A, we showed how SAMO stores the 16-bit gradients in a compressed format i.e. only for the unpruned parameters. This allows us to reduce the size of collective communication messages by directly invoking AxoNN's all-reduce calls on the compressed tensor. This leads to a significant reduction in the collective communication time.
### _Optimizing point-to-point communication in inter-layer parallelism_
As described in Section II, AxoNN implements a hybrid of inter-layer and data parallelism by dividing the work among \(G_{\mathrm{inter}}\times G_{\mathrm{data}}\) GPUs. When SAMO is used to reduce the memory required for training a neural network, we can reduce the number of GPUs required to deploy a single instance of the neural network i.e. decrease \(G_{\mathrm{inter}}\). This can allow us to use more GPUs for data parallelism, and increase \(G_{\mathrm{data}}\). A reduced \(G_{\mathrm{inter}}\) has the effect of decreasing the time spent in point-to-point communication thereby increasing the efficiency of inter-layer parallelism. We now provide a proof for this claim. We use the following notations:
* Batch size
* The size of each microbatch
* Number of GPUs
* Time spent in computation on a microbatch of size \(\mathrm{mbs}\) during the forward pass through the entire model
* Time spent in computation on a microbatch of size \(\mathrm{mbs}\) during the backward pass through the entire model
Note that \(t_{f}\) and \(t_{b}\) do not take the point-to-point communication cost into account. They just denote the compute time for the forward and backward pass across all the layers.
The time spent in point-to-point communication can be divided into two parts: the bubble time and the transmission time. A GPU experiences a pipeline bubble when there aren't enough microbatches in the pipeline to keep all of the GPUs busy. As shown in Figure 3, different GPUs experience pipeline bubbles at different points in time. But a common theme is that pipeline bubbles occur towards the beginning and end of the computation of a batch. We define the transmission time as the total time spent in sending messages in the pipeline.
Let \(t_{\mathrm{bubble}}\) and \(t_{\mathrm{send}}\) denote the bubble time and transmission time respectively. Narayanan et al. [28] show that \(t_{\mathrm{bubble}}\) equals the time it takes to complete forward and backward passes for \(G_{\mathrm{inter}}-1\) microbatches on any GPU. We can also see this in Figure 3, wherein we observe that the bubble time for a pipeline with \(G_{\mathrm{inter}}=3\) equals the time to do two forward and two backward passes. Assuming uniform distribution of compute, the time to complete the forward and backward pass of a microbatch on a single GPU is \(\frac{t_{f}+t_{b}}{G_{\mathrm{inter}}}\).
Thus, the bubble time can be calculated as,
\[t_{\mathrm{bubble}} =(G_{\mathrm{inter}}-1)\times(\frac{t_{f}+t_{b}}{G_{\mathrm{inter }}}) \tag{6}\] \[=(t_{f}+t_{b})\times(1-\frac{1}{G_{\mathrm{inter}}}) \tag{7}\]
Fig. 3: Illustration of how a batch is computed in inter-layer parallelism on three GPUs (\(G_{\mathrm{inter}}=3\)). In this example, we have divided the input batch into 5 microbatches (numbered 0 to 4). The red and blue colors denote forward and backward passes of microbatches respectively. We assume that the forward pass takes one unit of time and the backward pass takes two units of time. We observe that on each GPU, the pipeline bubble time accounts for 6 units, which equals the time to do \(G_{\mathrm{inter}}-1=2\) forward passes and \(G_{\mathrm{inter}}-1=2\) backward passes.
Fig. 2: Percentage memory saved by SAMO as compared to default mixed-precision training. Sparsity here refers to the proportion of parameters that have been pruned. SAMO can save around 66-78% memory in a range of 0.8-0.9 sparsity, which is typical for most pruning algorithms in deep learning.
Now, taking the derivative of \(t_{\rm bubble}\) with \(G_{\rm inter}\), we can show that the pipeline bubble time is a monotonically increasing function of \(G_{\rm inter}\):
\[\frac{\partial t_{\rm bubble}}{\partial G_{\rm inter}}=\frac{t_{f}+t_{b}}{G_{ \rm inter}^{2}}>0 \tag{8}\]
Since SAMO can help in decreasing \(G_{\rm inter}\) via its memory savings, we can conclude that it can be used to optimize the pipeline bubble time. Note that in Equation 8, we observe that the gradient w.r.t. \(G_{\rm inter}\) is inversely proportional to its square. Thus, with a progressive increase in model size (which entails a corresponding increase in \(G_{\rm inter}\)), we expect diminishing returns in the bubble time improvement.
The transmission time \(t_{\rm send}\) is proportional to the number of messages sent and received by each GPU. Each GPU sends and receives four messages per microbatch, two each in the forward and backward passes. Let us now derive the total number of microbatches each GPU computes on. First, AxoNN divides the input batch into \(G_{\rm data}\) shards, one for each inter-layer parallel group. Next, each inter-layer parallel group breaks this batch shard into microbatches of size \(\rm mbs\). These microbatches are processed by every GPU in the inter-layer parallel group. Thus the total number of microbatches computed upon by every GPU is \(\frac{B}{G_{\rm data}\times\rm mbs}\). Thus, we can express \(t_{\rm send}\) as,
\[t_{\rm send} \propto 4\times\frac{B}{\rm mbs\times G_{\rm data}} \tag{9}\] \[\propto 4\times\frac{B}{\rm mbs}\times\frac{G_{\rm inter}}{G}( \because G_{\rm inter}\times G_{\rm data}=G) \tag{10}\]
Taking the derivative of Equation 10 w.r.t. \(G_{\rm inter}\) shows that \(t_{\rm send}\) is a monotonically increasing function of \(G_{\rm inter}\):
\[\frac{\partial t_{\rm send}}{\partial G_{\rm inter}}\propto\frac{B}{\rm mbs \times G}>0 \tag{11}\]
Hence, we can see that using SAMO to decrease \(G_{\rm inter}\) can also help us decrease the transmission time for point-to-point communication in inter-layer parallelism. Thus, we have shown how the memory optimizations in SAMO can be exploited to reduce the collective communication pertaining to data parallelism and point-to-point communication pertaining to inter-layer parallelism respectively. Later, in Section VI, we provide performance profiles that demonstrate reduction in communication times as empirical evidence for the claims we have made in this section.
## V Experimental Setup
In this section, we provide details of the empirical experiments that we conducted to demonstrate the benefits of our optimizations. As discussed in Section II, we used AxoNN [13] for parallelizing the training process. We first validate the statistical efficiency of our implementation by training two neural networks to completion at a sparsity of 0.9. For pruning, we use You et al.'s "Early-Bird Tickets" pruning algorithm [4]. Then, we study the performance of two convolution neural networks (VGG-19 [39] and WideResnet-101 [40]) and four GPT-style transformer models from Brown et al. [2] under a strong scaling setup to demonstrate the hardware efficiency of our approach. We use the Oak Ridge National Laboratory's Summit supercomputer to run our experiments. Summit has two POWER9 CPUs and six 16 GB NVIDIA V100 GPUs per node. Each CPU is connected to 3 GPUs via NVlink. The intra-node bandwidth, inter-node bandwidth, and the peak half-precision throughput are 50 GB/s, 12.5 GB/s and 125 Tflop/s per GPU respectively.
### _Description of neural networks and hyperparameters_
Table I lists the set of neural networks and the corresponding hyperparameters used in this study. VGG-19 [39] and WideResnet-101 [40] are two convolutional neural network (CNN) architectures widely used in computer vision. GPT-3 [2], a variant of the transformer architecture [41], is extremely popular in natural language processing for causal language modeling. For each model, we use the same hyperparameters (batch size, sequence length, learning rate schedules, gradient clipping, l2 regularization and optimizer hyperparameters) as used by the authors. We use SGD (with momentum [42]) and the AdamW [43] optimizer for training the CNN and GPT-3 models respectively. We use MegatronLM's highly optimized kernels to implement the GPT-3 models [25]. For the convolution neural networks, we use implementations provided by the torchvision library1.
Footnote 1: [https://pytorch.org/vision/stable/index.html](https://pytorch.org/vision/stable/index.html)
We profile the neural networks listed in Table I under a strong scaling setup to demonstrate the efficacy of our optimizations. For every model, we choose the minimum and maximum GPU counts such that the ratio of batch size to number of GPUs is 4 and 1 respectively. For a given model, we fix the batch size irrespective of the GPU count. This is because while increasing the batch size leads to better performance, it also degrades the quality of convergence [44]. Under a strict definition of strong scaling, the final answer should be the same irrespective of the number of GPUs. Therefore, it is important to keep the global batch size fixed. For our approach, we prune the networks to a sparsity of 90% using You et al.'s "Early Bird Ticket" algorithm [4].
To ensure the correctness of our optimizations, we train GPT-3 XL and GPT-3 2.7B to completion on the Wikitext-103 dataset [37] and the BookCorpus dataset [38] respectively. We
present the validation perplexity curves for AxoNN and AxoNN+SAMO. Again, we use a sparsity of 90% and the same pruning algorithm as the strong scaling runs. The purpose of this experiment to ensure that our proposed optimizations work correctly in an end-to-end fashion in combination with a pruning algorithm. Since this is a sanity check, the datasets we have used are much smaller than what are typically used to train large GPT-3 style language models. We highlight prior work by Samar et al. [45], who have successfully pruned GPT-3 style language models upto 90% on a much larger and challenging dataset (Pile [46].)
### _Choice of frameworks_
We integrate our optimizations in AxoNN [13] and refer to it as "AxoNN+SAMO". We use AxoNN and DeepSpeed-3D [29, 14] as baselines for dense computations. DeepSpeed-3D implements a hybrid of data, inter-layer and intra-layer parallelism for parallel model training. Their data parallel implementation uses the ZeRO optimizer to shard optimizer state memory across data parallel ranks [29]. They use MegatronLM's implementation of intra-layer parallelism of transformers [25]. DeepSpeed-3D has been used to train some of the largest neural networks till date such as Bloom-176B [34] and Megatron-Turing NLG 530B [35]. Finally, we integrate Sputnik [11] in AxoNN to create a sparse matrix multiplication baseline. Note that Sputnik does not support sparse convolutions, so we do not implement the convolution architectures in Table I using Sputnik. We build our baselines using CUDA 11.0, PyTorch 1.12.0, NCCL 2.8.4, GCC 9.1.0 and Spectrum-MPI 10.4.0.3.
### _Evaluation metrics_
For the statistical efficiency experiments, we report perplexity on the validation split of the training dataset. Perplexity is defined as the exponential of the cross entropy loss. For our strong scaling runs, we report the average iteration time i.e. time to train on a single batch of input data. We do this by training for 100 batches and averaging the time of the last 90.
For the transformer models, we also calculate the percentage of peak half-precision flop/s. To do this, we use Narayanan et al.'s formula to derive the total number of floating point operations in a batch [28] of a transformer model and divide it by the average batch time over 100 training batches to derive the flop/s. Finally, we divide this quantity by 125 fltop/s (the peak half-precision flops per GPU on Summit) and the number of GPUs to obtain the percentage of peak half-precision throughput.
Since Sputnik is a sparse matrix multiplication library, it only computes a fraction of the flops that the other dense computation frameworks compute. For instance at a sparsity of 90%, it would only compute 10% of the flops. For a fair comparison, we assume the same number of flops for Sputnik as the dense computation frameworks while using the time spent computing the sparse kernels.
## VI Results
We now present the results of the empirical experiments outlined in Section V.
### _Statistical efficiency_
We verify the statistical efficiency of AxoNN+SAMO by training GPT-3 XL [2] and GPT-3 2.7B [2] to completion at a sparsity of 90%. We use You et al.'s algorithm [4] to prune a neural network for AxoNN+SAMO. Figure 4 illustrates the results of this experiment. We observe that (1) the final validation perplexities for the pruned networks trained with AxoNN+SAMO match those of the unpruned network trained with AxoNN and (2) both AxoNN and AxoNN+SAMO reach the final validation perplexities in similar number of iterations. This verifies the correctness of our implementation.
### _Strong scaling performance_
Next, we illustrate the results of our strong scaling experiments on WideResnet-101 and VGG-19 in Figure 5, GPT
Fig. 4: Validation perplexities for GPT-3 XL (left) and GPT-3 2.7B (right) on 64 and 128 GPUs of Summit respectively. For AxoNN+SAMO, we prune both models to a sparsity of 90% using [4]. We use the same hyperparameters as Brown et al. [2] and train on the Wikitext-103 [37] and BookCorpus datasets [38].
3 XL and GPT-3 2.7B in Figure 6, and on GPT-3 6.7B and GPT-3 13B in Figure 7. The CNNs used in this study are nearly 10-100\(\times\) smaller than the GPT-3 based models (see Table I). Hence, all of AxoNN, DeepSpeed-3D and AxoNN+SAMO are able to run these architectures in a pure data parallel configuration, with a full copy of the network on each GPU. Thus the only communication here is the all-reduce on the network gradients. We illustrate these results in Figure 5. We observe similar batch times for both AxoNN and DeepSpeed-3D. This is explained by the fact that both these frameworks have very similar NCCL-based implementations of data parallelism. Our approach yields speedups of 7-12% over WideResnet-101 and 18-44% over VGG-19. While both these speedups are significant, SAMO seems to benefit the latter architecture more than the former. This is because the WideResnet-101 architecture spends nearly 1.5\(\times\) more time in the computation phase as compared to VGG-19. Also, both these models have similar number of parameters and thus similar communication costs in the data-parallel all-reduce. Thus the proportion of the batch time spent by the WideResnet-101 architecture in communication is significantly smaller than VGG-19. Since our approach optimizes communication, the benefits for WideResnet-101 are smaller than that of VGG-19. Note that we do not run Sputnik for the CNNs as the library does not support sparse convolutions.
Let us now discuss the much larger GPT-3 based neural networks. These networks are too large to fit on a single GPU and are thus trained using hybrid parallelism. First, we observe that the performance of the sparse matrix computation library, Sputnik is significantly worse than both of our dense baselines - AxoNN and DeepSpeed-3D, as well as AxoNN+SAMO (Figures 6 and 7). This is in spite of the fact that the number of floating point operations computed by Sputnik is 10% of the other methods. This is in agreement with our observations in Figure 1 for fully connected layers on a single GPU. Thus, AxoNN+SAMO ends up being nearly twice as fast as
Fig. 5: Time per iteration (batch time) for a strong scaling study of WideResnet-101 (left) and VGG-19 (right) on Summit. We prune the models to a sparsity of 90% for AxoNN+SAMO (see Table I for batch sizes). We annotate AxoNN+SAMO’s line with its percentage speedup over AxoNN.
Fig. 6: Time per iteration (batch time) for a strong scaling study of GPT-3 XL (left) and GPT-3 2.7B (right) on Summit. We prune the models to a sparsity of 90% for AxoNN+SAMO and Sputnik (see Table I for batch sizes). We annotate AxoNN+SAMO’s line with its percentage speedup over AxoNN.
Sputnik across all the GPT-3 style neural networks. It is evident from Figures 6 and 7 that augmenting AxoNN with our optimizations significantly improves its performance at scale. Our method speeds up the training of GPT-3 XL by 10-47%, GPT-3 2.7B by 10-24%, GPT-3 6.7B by 11-23% and GPT-3 13B by 19-26%. The speedups over DeepSpeed-3D are larger - 19-51%, 17-33%, 12-38% and 16.4-34% respectively for the four models.
We also present the percentage of peak half precision throughputs obtained for GPT-3 13B in Table II. We observe a significant reduction in the GPU utilization with increasing GPU counts for DeepSpeed-3D and AxoNN. This is a consequence of increasing communication to computation ratios. For both frameworks, the peak half precision throughput drops to around 20% at the largest profiled GPU counts. However, with AxoNN+SAMO, we observe a smaller reduction in hardware utilization, with a peak throughput of around 30% for the largest GPU count. This serves as empirical evidence of the fact that our optimizations indeed decrease the amount of communication in parallel training.
Since our optimizations are geared toward reducing the communication costs of training, we expect larger improvements over AxoNN as the number of GPUs increase. Again, this is because a larger proportion of time is spent in communication as we increase the scale of training. We find our observations in Figures 6 and 7 to be in agreement with this hypothesis. We indeed observe the largest speedups for the largest GPU counts, which are 47% and 34% for GPT-3 XL and GPT-3 2.7B on 512 GPUs, 23% for GPT-3 6.7B on 1024 GPUs, and 26% for GPT-3 13B on 2048 GPUs.
### _Performance Breakdowns_
To verify that the speedups over AxoNN are indeed due to reduction in communication times, we profile the GPT-3 2.7B model on 128, 256 and 512 GPUs and provide breakdowns of the batch times in Figure 8. We divide the batch time into its non-overlapping phases, namely the compute (forward and backward pass), point-to-point communication, pipeline bubble (due to inter-layer parallelism), and collective communication (due to data parallelism). We use the CUDA Event API to profile the time spent in each of these phases.
At 128 GPUs, we observe that training is dominated by the point-to-point communication time. However as the number of GPUs increase, the proportion of time spent in the point-to-point communication also decreases. Note that this is in line with Equation 10, wherein we showed that the messaging time is inversely proportional to the number of GPUs.
We observe that the primary reason for AxoNN+SAMO's improvement over AxoNN on 128 GPUs is due to a speedup in the point-to-point communication times. The absolute reduction in this time is 18% of AxoNN's batch time. The improvements in the collective and pipeline bubble times account for 6% and 9% of AxoNN's batch time. Thus for smaller GPU counts, we conclude that AxoNN+SAMO provides speedups primarily because of the improvements in the point-to-point communication times. The difference in the compute times is the overhead of compressing the parameter gradients at every backward pass (See Section III-C). The overhead accounts for 12% of AxoNN's batch time and is significantly overcome by the 33% (18+6+9) improvement in the total communication time. We think that these overheads can be reduced by kernel level optimizations such as fusing the compression operation
Fig. 7: Time per iteration (batch time) for a strong scaling study of GPT-3 6.7B (left) and GPT-3 13B (right) on Summit. We prune the models to a sparsity of 90% for AxoNN+SAMO and Sputnik (see Table I for batch sizes). We annotate AxoNN+SAMO’s line with its percentage speedup over AxoNN.
with the backward pass kernels. However, this is out of the scope of our current work.
At 256 GPUs, the point-to-point communication time is still dominant but not as much as 128 GPUs. In this case, the improvement in the point-to-point communication time accounts for a 16.17% of AxoNN's batch time. As compared to 128 GPUs, the improvements in the bubble and collective communication times account for a significantly larger proportion of AxoNN's batch time - 13.17% and 11.08%. The overhead in this case is 10.18% of the total batch time.
At 512 GPUs, we notice a very minor reduction in the point-to-point communication time. The reduction in the bubble and collective communication time account for 15% and 21% of AxoNN's batch time respectively. The reduction in the point-to-point communication only improves the batch times by 4%. In this case, the overhead of compressing gradients is 8% of AxoNN's batch time, which is again overcome by 40% (15+21+4) improvement in the total communication times.
## VII Conclusion
It is well known that recent magnitude-based pruning approaches can lead to significant pruning of neural networks without reducing statistical efficiency [3, 4]. However, to the best of our knowledge, no prior work has attempted to exploit neural network pruning for improving the hardware efficiency of parallel neural network training. The primary deterrent to doing this is the sparse nature of the pruned subnetworks, which results in inefficient hardware performance.
In this work, we presented Sparsity-aware Memory Optimization (SAMO), a novel method that exploits the aforementioned parameter pruning algorithms to significantly reduce the memory consumption of neural network training while not sacrificing performance. We then demonstrated how these memory savings can be utilized to significantly improve the communication performance of two popular algorithms for parallel deep learning, data and inter-layer parallelism. We conducted strong scaling experiments on two convolution neural networks, and large GPT-style language models with 1.3 billion to 13 billion parameters proposed by Brown et al. [2] in their seminal work on the GPT-3 architecture. In our experiments, we consistently observed significant improvements over two highly scalable parallel deep learning frameworks - AxoNN and DeepSpeed-3D and a state-of-the-art sparse matrix computation library called Sputnik.
## Acknowledgment
This work was supported by funding provided by the University of Maryland College Park Foundation. The authors thank Shu-Huai Lin for his help in conducting initial experiments that led to this research. This research used resources of the Oak Ridge Leadership Computing Facility at the Oak Ridge National Laboratory, which is supported by the Office of Science of the U.S. Department of Energy under Contract No. DE-AC05-00OR22725.
|
2303.10761 | Calibration of Neural Networks | Neural networks solving real-world problems are often required not only to
make accurate predictions but also to provide a confidence level in the
forecast. The calibration of a model indicates how close the estimated
confidence is to the true probability. This paper presents a survey of
confidence calibration problems in the context of neural networks and provides
an empirical comparison of calibration methods. We analyze problem statement,
calibration definitions, and different approaches to evaluation: visualizations
and scalar measures that estimate whether the model is well-calibrated. We
review modern calibration techniques: based on post-processing or requiring
changes in training. Empirical experiments cover various datasets and models,
comparing calibration methods according to different criteria. | Ruslan Vasilev, Alexander D'yakonov | 2023-03-19T20:27:51Z | http://arxiv.org/abs/2303.10761v1 | # Calibration of Neural Networks
###### Abstract
Neural networks solving real-world problems are often required not only to make accurate predictions but also to provide a confidence level in the forecast. The calibration of a model indicates how close the estimated confidence is to the true probability. This paper presents a survey of confidence calibration problems in the context of neural networks and provides an empirical comparison of calibration methods. We analyze problem statement, calibration definitions, and different approaches to evaluation: visualizations and scalar measures that estimate whether the model is well-calibrated. We review modern calibration techniques: based on post-processing or requiring changes in training. Empirical experiments cover various datasets and models, comparing calibration methods according to different criteria.
###### Contents
* 1 Introduction
* 2 Problem Statement
* 3 Calibration Evaluation
* 3.1 Visualization
* 3.2 Calibration Metrics
* 4 Calibration Methods
* 4.1 Post-processing
* 4.1.1 Histogram Binning
* 4.1.2 Isotonic Regression
* 4.1.3 Generalizations of Platt Calibration
* 4.2 Calibration During Training
* 4.2.1 Label Smoothing
* 4.2.2 Focal Loss
* 5 Empirical Experiments
* 5.1 Experimental Design
* 5.2 Experiment Results
* 6 Conclusion
* Appendices
* A Classification Accuracy
* B Binning-based Metrics
* C Proper Scoring Rules
Introduction
Deep learning is finding more and more applications in various fields. Neural networks are actively used in clinical practice [1], self-driving cars [2], machine translation [3], and other diverse applications.
Oftentimes, real-world problems require models that produce not only correct prediction but also a reliable measure of confidence in it. _Confidence_ refers to probability estimate that the forecast is correct. For example, if an algorithm predicts a given sample of patients are healthy with confidence \(0.9\), we expect that \(90\%\) of them are really healthy. A model with reliable confidence estimation is called _calibrated_. Along with the interpretation of neural network predictions, confidence calibration is important when probability estimates are fed into subsequent algorithm steps (for example, language models decoding strategies [4]).
Modern neural networks often turn out to be poorly calibrated [5]. However, many other machine learning algorithms also produce biased confidence estimates [6, 7]. Various calibration techniques have been proposed for "classical" machine learning, some of which have been developed in deep learning.
## 2 Problem Statement
Consider a classification problem for objects from set \(\mathcal{X}\) with classes \(\mathcal{Y}=\{1,\ldots,K\}\). Suppose we have trained a _model_ -- an algorithm which produces vector of scores _(confidences)_\(\mathbf{a}(x)=(a_{1}(x),\ldots,a_{K}(x))\), \(\sum_{j=1}^{K}a_{j}(x)=1\), for each \(x\in\mathcal{X}\). Next, the class corresponding to the highest confidence is assigned to the object:
\[\hat{y}(x)\coloneqq\operatorname*{argmax}_{j\in\mathcal{Y}}a_{j},\quad\hat{p} (x)\coloneqq a_{\hat{y}}.\]
We would like to interpret estimator \(\hat{p}\) as the probability that the true label coincides with the predicted one. If the estimate is accurate enough, then the model is called _calibrated_. Formally, the definition of calibration (_perfect calibration_ in [5]) can be written as follows:
\[\mathbb{P}\left(y=\hat{y}\mid\hat{p}=p\right)=p\quad\forall p\in[0,1]\;. \tag{1}\]
There are stronger definitions of model calibration1 than (1). For example, according to [8], the classifier is called calibrated (originally, _well-calibrated_) if
Footnote 1: It should be noted that the term _calibration_ also often refers to _methods_ which make model confidences accurate.
\[\mathbb{P}(y=j\mid a_{j}=p)=p\quad\forall j\in\mathcal{Y},\quad\forall p\in[0,1] \tag{2}\]
that means the assurances given for each class (not just the predicted one) are calibrated.
In the case of real-world data and models, we cannot directly check (1) and (2), so various calibration metrics come in handy as well as visualizations that are reviewed in section 3.
Section 4 describes calibration methods -- techniques that make confidences more reliable. First, one can calibrate confidences afterwards, i.e. find a transformation that maps biased estimates to calibrated. There are different algorithms that find optimal transformations. Second, it is possible to apply special techniques during training, for example, loss function modifications.
Section 5 provides empirical comparison of calibration methods for modern neural network architectures and shows how the choice of loss function affects the calibration.
## 3 Calibration Evaluation
### Visualization
Before defining calibration measures, we simplify the problem to binary classification: \(\mathcal{Y}=\{0,1\}\) -- consider the model generates confidences \(\hat{p}\) that the object belongs to the positive class (\(y=1\)). Binary classification is common in various applications and "classical" machine learning models: logistic regression, support vector machines, gradient boosted trees and others -- the problem of their calibration were studied in [6, 7].
Consider a set of objects (_usually, another validation set_), for each of which the true class is known and the confidence score is produced by the model. Divide the segment of all possible confidence values \([0,1]\) into \(M\) equal-width intervals \(I_{m}\):
\[I_{1}=\left[0,\frac{1}{M}\right),\ I_{2}=\left[\frac{1}{M},\frac{2}{M}\right), \ \ldots,\ I_{M-1}=\left[\frac{M-2}{M},\frac{M-1}{M}\right),\ I_{M}=\left[\frac{M- 1}{M},1\right]\,. \tag{3}\]
Thus, each confidence estimate falls into one of these intervals -- let \(B_{m}\) denote the set of indices of those objects which confidences are in \(I_{m}\). Both \(B_{m}\) and \(I_{m}\) are called _bins_.
For each bin \(B_{m}\), we calculate positive frequency \(A_{m}^{1}\) and average confidence \(C_{m}^{1}\):
Figure 1: Options for visualizing confidence calibration. For clarity, synthetic data was generated. Support vector machine is used as a model (the distances to the separating hyperplane are scaled into \([0,1]\)).
\[A_{m}^{1}=\frac{1}{|B_{m}|}\sum_{i\in B_{m}}1(y_{i}=1),\quad C_{m}^{1}=\frac{1}{|B _{m}|}\sum_{i\in B_{m}}\hat{p}_{i}. \tag{4}\]
Finally, we can draw a plot \((C_{m}^{1},A_{m}^{1})_{m=1}^{M}\) which is called _reliability plot_ Figure 1 (a). Also, the resulting curve is sometimes called calibration curve. The model is considered well-calibrated if its calibration curve is close to the diagonal (_in subsection 3.2 we describe scalar metrics of such closeness_).
Likewise, \((C_{m}^{1},A_{m}^{1})_{m=1}^{M}\) can be depicted using a histogram, which is called _reliability diagram_. In Figure 1 (b) the average confidence is shown in red, and the positive frequency is shown in blue. If the red bar is higher than the blue one, then the algorithm underestimates confidences -- _underconfidence_. The opposite case is called _overconfidence_. For better interpretation, the fraction of objects (bin _weight_) that fell into the bin can also be shown in the graph.
When the number of classes \(n>2\), reliability diagrams are built differently. The most popular approach corresponds to the definition (1). For each bin \(B_{m}\), we estimate "accuracy" \(A_{m}\) and average confidence \(C_{m}\):
\[A_{m}=\frac{1}{|B_{m}|}\sum_{i\in B_{m}}1(y_{i}=\hat{y}_{i}),\quad C_{m}=\frac {1}{|B_{m}|}\sum_{i\in B_{m}}\hat{p}_{i}. \tag{5}\]
The difference between (4) and (5) is that in multiclass case \(\hat{y}_{i}\) and \(\hat{p}_{i}\) correspond to the estimated class and its confidence, while in binary case statistics are calculated only for a positive class.
Note that \(A_{m}\) and \(C_{m}\) estimate the left and the right of (1), respectively. They can be depicted on reliability diagram. For two classes, this approach is illustrated in Figure 1 (c). Bins to the left of 0.5 turn out to be empty because a binary classification algorithm assigns an object to a class that has confidence \(>0.5\).
One can also consider classwise reliability diagrams [9]. To make it, each class should be separately assigned to the positive, while all the others should be treated like the negative, so \(n\) reliability diagrams for the binary case can be built. Although the classwise approach is more informative (2), when the number of classes is large (for example, 1'000 or 22'000 in ImageNet [10]), it is usually impractical due to the interpretation difficulty. Therefore, reliability diagrams considering only the prediction confidence (5) are more common.
### Calibration Metrics
In addition to visualizations, various metrics2 can be used to evaluate the calibration of the model. One of the most common is Expected Calibration Error (ECE) [11]. It estimates the expectation of the absolute difference between confidence and associated accuracy:
Footnote 2: Here, _metric_ refers to measure for the evaluation of algorithms
\[\mathbb{E}_{\hat{p}}\left|\mathbb{P}\left(y=\hat{y}\mid\hat{p}\right)-\hat{p} \right|. \tag{6}\]
(6) can be approximated using the partition of the confidences into bins (\(l\) is the total number of objects in the considered set):
ECE \[=\sum_{m=1}^{M}\frac{|B_{m}|}{n}\left|A_{m}-C_{m}\right|\] (7) \[=\sum_{m=1}^{M}\frac{|B_{m}|}{n}\left|\frac{1}{|B_{m}|}\sum_{i\in B _{m}}\mathbb{1}(\gamma_{i}=\hat{y}_{i})-\frac{1}{|B_{m}|}\sum_{i\in B_{m}}\hat {p}_{i}\right|\] \[=\frac{1}{n}\sum_{m=1}^{M}\left|\sum_{i\in B_{m}}\mathbb{1}(y_{i} =\hat{y}_{i})-\sum_{i\in B_{m}}\hat{p}_{i}\right|\,.\]
Comparing (7) and reliability diagrams for a multiclass problem, we notice that ECE is exactly equal to the weighted average of the gaps between red and blue bars Figure 1.
There are other metrics based on a partition of confidences into bins, although used less often. For example, one can calculate the maximum gap between confidence and accuracy [11]:
\[\text{MCE}=\max_{m}|A_{m}-C_{m}|\,, \tag{8}\]
or take into account the confidence not only for the predicted class but also for all the others (classwise ECE) [9]:
\[\text{cwECE}=\frac{1}{K}\sum_{j=1}^{K}\sum_{m=1}^{M}\frac{|B_{m}^{j}|}{n}|A_{ m}^{j}-C_{m}^{j}|, \tag{9}\]
where \(B_{m}^{j}\), \(A_{m}^{j}\), \(C_{m}^{j}\) are, respectively, \(m\)-th bin, accuracy and confidence, if we consider \(j\)-th class positive, and collect all the others into negative. This metric corresponds to classwise reliability diagrams.
Instead of equal-width bins (3), bins with an equal number of samples can be used -- sometimes confidence diagrams are built in this way. In [12], it was proposed to use equal-frequency bins to count the metrics described above. Further, an equal-width scheme will be considered. Also, in addition to \(l_{1}\)-norm (i.e. averaging modules), we can use \(l_{2}\)[13].
The problem with binning metrics is the dependence on the number of bins. An alternative approach is to use proper scoring rules. We consider Negative Log-Likelihood (NLL):
\[\text{NLL}=-\frac{1}{l}\sum_{i=1}^{n}\log a_{i,y_{i}} \tag{10}\]
where \(y_{i}\) is the true class label, \(a_{i,y_{i}}\) is a confidence of the algorithm in it, \(n\) is a total number of objects.
Another proper scoring rule, which can be used to evaluate model calibration, is Brier Score:
\[\text{BS}=\frac{1}{n}\sum_{i=1}^{n}\sum_{j=1}^{K}\left(a_{ij}-\mathbb{1}(y_{i} =j)\right)^{2}, \tag{11}\]
where \(K\) is a number of classes.
Calibration Methods
There are two main types of calibration techniques. First, model outputs can be post-processed. Special transformation, _calibration map_, maps biased probability estimates to the calibrated ones. Second, calibration can be incorporated into the model training itself.
### Post-processing
The transformation is usually found on a hold-out set _(calibration set)_\((x_{i},y_{i})_{i=1}^{n}\). It can be the same dataset used for hyperparameter tuning, but not the training set because model outputs distribution on training data is not the same as on unseen data.
#### 4.1.1 Histogram Binning
The method was originally introduced in [14] to calibrate decision trees and naive Bayes classifiers. A calibration map in histogram binning is piecewise constant. Consider the binary case: the set of output confidence values is divided into bins \(B_{1},\ldots,B_{M}\) (_usually equal-width_ (3) _or equal-frequency_), and scores that fall into \(B_{m}\) are replaced with the common \(\theta_{m}\). To find \(\theta_{1},\ldots,\theta_{M}\), the following optimization problem is solved:
\[\sum_{m=1}^{M}\sum_{i\in B_{m}}(\theta_{m}-y_{i})^{2}\ \rightarrow\ \min_{\theta_{1},\ldots,\theta_{M}}. \tag{12}\]
In such a statement the optimal \(\theta_{m}\) equals the fraction of positive objects that fall into \(B_{m}\). The calibration map is illustrated in Figure 2 (a).
The method is generalized to the multiclass case using the strategy _one-vs-rest_: each class is separately declared positive and \(K\) piecewise constant functions are constructed. In the inference stage, a calibrated vector is additionally normalized.
Figure 2: Different calibration maps for binary classification (the same data and model as in Figure 1).
#### 4.1.2 Isotonic Regression
The method was proposed in [8]. For the binary case, the map is piecewise constant again, but both the number of the intervals \(M\) and their boundaries are optimized. The constraint is that the map should be non-decreasing. Thus, the following problem is solved:
\[\sum_{m=1}^{M}\sum_{i\in\tilde{B}_{m}}\left(\theta_{m}-y_{i}\right)^{2}\ \rightarrow\ \min_{ \begin{subarray}{c}M,\\ 0=\alpha_{0}\leqslant\alpha_{1}\leqslant\cdots\leqslant\alpha_{M-1}\leqslant \alpha_{M}=1\end{subarray}} \tag{13}\]
where \(\tilde{B}_{1}=\{i:\alpha_{0}\leqslant\hat{p}_{i}<\alpha_{1}\},\ldots,\tilde{ B}_{m}=\{i:\alpha_{m-1}\leqslant\hat{p}_{i}\leqslant\alpha_{m}\}\). The shape of the function is illustrated in Figure 2.
Isotonic regression is generalized to the multiclass case in the same way as histogram binning.
#### 4.1.3 Generalizations of Platt Calibration
Originally, the method was proposed in [15] for calibration of the support vector machines. As can be seen in the illustrations Figure 1, Figure 2, if we rescale the distances \(r(x)\) from the objects to the separating hyperplane into \([0,1]\) and treat them as confidences in positive class, then the reliability plot will have the form of a sigmoid:
\[\hat{p}(x)=\frac{1}{1+e^{-\left(\alpha\cdot r(x)+\beta\right)}}. \tag{14}\]
Scale parameter \(\alpha\) and location parameter \(\beta\) are optimized on a calibration set using maximum likelihood estimation. In this method, the transformation is continuous and allows different generalizations to the multiclass case.
The last linear layer of a neural network for the object \(x\) outputs the logit vector: \(\mathbf{z}=(z_{1},\ldots,z_{K})\). To estimate class probabilities, the vector is transformed with softmax \(\sigma(\cdot)\):
\[\sigma\left(\mathbf{z}\right)=\frac{1}{\sum_{j=1}^{K}\exp\left(z_{j}\right)} \left(\exp\left(z_{1}\right),\ldots,\exp\left(z_{K}\right)\right),\]
so it is possible to generalize Platt Calibration by introducing scale and location parameters for logits:
\[a(x)=\sigma(\mathbf{W}\cdot\mathbf{z}+\mathbf{b}). \tag{15}\]
Parameters \(\mathbf{W}\) and \(\mathbf{b}\) are also optimized with maximum likelihood estimation on a calibration set, which is equivalent to minimizing NLL (10). Depending on \(\mathbf{W}\) and \(\mathbf{b}\) shapes, different generalization may be defined:
1. Temperature scaling: \[\mathbf{W}=\frac{1}{T}\in\mathbb{R},\ T>0,\ \mathbf{b}=\mathbf{0}.\] Generalization of Platt Calibration with a single scalar parameter. The method is one of the most frequently used. An increase in temperature \(T\) leads to an increase in uncertainty -- an increase in the entropy of the output distribution. Decreasing \(T\), on the contrary,
increases confidence in the predicted class. At the same time, the predicted class remains unchanged.
2. Vector scaling: \[\mathbf{W}=\text{diag}(\mathbf{v})\in\mathbb{R}^{K\times K}\text{ --- diagonal matrix},\mathbf{v}\in\mathbb{R}^{K}.\] In this approach, a different scale factor is optimized for each class (and the bias, if \(\mathbf{b}\neq\mathbf{0}\) is optimized too).
3. Matrix scaling: \[\mathbf{W}\in\mathbb{R}^{K\times K},\mathbf{b}\in\mathbb{R}^{K}.\] Matrix scaling is the most general parametrization in this group of methods and is equivalent to logistic regression in the logit space. However, with a large number of classes, the method has too many parameters, which can lead to overfitting, because a calibration set is usually not large.
Note that to implement any of these methods, it is enough to add a linear layer (of the required dimension) to the frozen neural network.
### Calibration During Training
The performance of neural networks strongly depends on the loss function. Usually, NLL (10) is used. Given an object \(x\), it is equal to the cross-entropy between the true classification one-hot distribution \(\mathbf{y}\) and the predicted distribution:
\[\text{CE}(\mathbf{y},\mathbf{a})=-\sum_{j=1}^{K}y_{j}\log a_{j}. \tag{16}\]
To improve the calibration of the model, one can modify the loss function itself.
#### 4.2.1 Label Smoothing
In this method, the degenerate distribution of the target is replaced by a smoothed one. The smoothing degree can be tuned using the parameter \(\alpha\in[0,1]\):
\[\mathbf{y}=(y_{1},\ldots,y_{K})\mapsto\left((1-\alpha)y_{1}+\frac{\alpha}{K},\ldots,(1-\alpha)y_{K}+\frac{\alpha}{K}\right)=\mathbf{y}^{\prime}. \tag{17}\]
As parameter \(\alpha\) increases, the distribution of \(\mathbf{y}^{\prime}\) becomes more uniform. After this transformation, \(\text{CE}(\mathbf{y}^{\prime},\mathbf{a})\) the cross-entropy between the smoothed classification vector and the predicted distribution is minimized.
Although using of smoothed labels to train a classifier is not a new idea, this approach was proposed for calibration in [16].
#### 4.2.2 Focal Loss
The focal loss was originally introduced to tackle the problem of class imbalance [17]. In terms of confidence calibration, the idea was first used in [18]. For an object belonging to the \(j\)-th class, the focal loss has the following definition:
\[\mathrm{FL}=-(1-a_{j})^{\nu}\cdot\log a_{j},\quad\nu\geqslant 0. \tag{18}\]
Note that the loss function becomes the cross-entropy when \(\nu=0\). Increasing parameter \(\nu\), as we see in Figure 3, decreases the penalty for those objects with already high confidence in the true class. While the cross-entropy is the upper bound of the Kullback-Leibler divergence between the true \(\mathbf{y}\) and the predicted \(\mathbf{a}\) distribution, the focal error has the entropy of the predicted distribution \(H(\mathbf{a})\)[18] subtracted from the estimate:
\[\mathrm{CE}(\mathbf{y},\mathbf{a})\geqslant\mathrm{KL}(\mathbf{y}||\mathbf{ a}),\qquad\mathrm{FL}(\mathbf{y},\mathbf{a})\geqslant\mathrm{KL}(\mathbf{y}|| \mathbf{a})-\nu\cdot\mathrm{H}(\mathbf{a}).\]
Thus, optimizing the focal error additionally increases the entropy of the predicted distribution and helps to tackle overconfidence.
## 5 Empirical Experiments
### Experimental Design
The following datasets are used in the experiments:
* **CIFAR-10**[19]: The dataset consists of 60 000 color images \(32\times 32\). _Training / validation / test_ splits are respectively \(50\,000\) / \(5\,000\) / \(5\,000\).
* **CIFAR-100**[19]: \(60\,000\) color images \(32\times 32\), \(100\) classes. _Training / validation / test_: \(50\,000\) / \(5\,000\) / \(5\,000\).
Figure 3: Focal loss on a single object. \(\hat{p}\) — probability estimation for a true class
* **ImageNet 2012**[10]: Large dataset with color images organized into 1000 classes. _Training / validation / test_: 1.2 m / 25 000 / 25 000.
* **Tiny ImageNet**[10]: 110 000 color images \(64\times 64\), organized into 200 classes, subset of the previous dataset. _Training / validation / test_: 100 000 / 5 000 / 5 000.
Pre-trained neural networks with various architectures from open repositories were used for calculations. In experiments, models and datasets are divided into two main groups:
1. The first group includes neural networks trained on CIFAR-10, CIFAR-100, and ImageNet. The weights for the models are obtained respectively from the repositories [20, 21, 22]. Models from this group are used to compare calibration methods based on post-processing.
2. The second group includes pre-trained neural networks from the repository [23]. The datasets used here are CIFAR-10, CIFAR-100, and Tiny ImageNet. These neural networks were trained in [18] -- focal error and label smoothing were used for the considered models.
The models were trained on the _training_ data (_or its subset_), calibrated on the _validation_ set -- all diagrams and metrics correspond to the _test_ set.
Code used in all experiments is published in [24]: temperature, vector, and matrix scaling are implemented using PyTorch, and other methods and evaluation are implemented with SciPY and scikit-learn. Histogram binning use 20 bins; ECE, cwECE, and MCE are calculated on 15 bins partition; reliability diagrams use 10 bins.
### Experiment Results
Complete tables with measurements are given in appendix, additional reliability diagrams for all the models considered in this work can be found in the accompanying repository [24].
Consider the reliability diagrams for ShuffleNetV2 (CIFAR-100, Figure 4): we see a "typical" state of modern neural networks calibration -- overconfidence. Calibration methods help to correct the situation: in this case, temperature scaling works best for all the metrics. However, histogram binning changes probabilities too aggressively when the number of classes is large, as can be seen from the weights change.
For a small number of classes, on the contrary, histogram binning works best in terms of confidence in prediction (Table 5, Table 6 -- for almost all models on CIFAR-10). Note that here neural networks already solve the classification problem with very high accuracy. Almost all probabilities of the predicted class are close to 1, as, for example, on Figure 5. In terms of MCE (Table 9, Table 10) -- metric, that doesn't consider weights of bins -- histogram binning leads to low calibration.
For matrix scaling, we do not provide reliability diagrams: the method overfits too much when the number of classes is large. As a result, matrix scaling significantly degrades the classification quality (Table 3, Table 4) for all datasets, except, again, the low-class CIFAR-10.
One of the most common methods of neural network calibration is temperature scaling. The method doesn't affect classification predictions, while other calibration options almost always reduce accuracy (Table 3, Table 4).
In terms of NLL, temperature and vector scaling are the best as expected, because this loss was minimized during calibration: Table 11, Table 12. As for Brier Score, the best calibration method in many cases was isotonic regression: Table 13, Table 14.
Focal loss and label smoothing result in better calibrated models than the ones optimizing the cross-entropy -- both in terms of calibration in the predicted class (Table 1) and classwise
\begin{table}
\begin{tabular}{l l c c c c c} \hline \hline Dataset & Model & CE & F1.1 & H.2 & F1.3 & 15.05 \\ \hline CIFAR-10 & DenseNet121 & 4.53 & 3.47 & 2.02 & 1.68 & **1.65** \\ CIFAR-10 & ResNet110 & 4.73 & 3.70 & 2.78 & **1.61** & 2.20 \\ CIFAR-10 & ResNet50 & 4.26 & 3.88 & 2.55 & 1.58 & 3.07 \\ CIFAR-10 & Wide-ResNet26-10 & 3.25 & 2.66 & **1.57** & 1.98 & 4.33 \\ CIFAR-100 & DenseNet121 & 20.90 & 14.54 & 8.40 & 4.49 & 13.27 \\ CIFAR-100 & ResNet110 & 19.76 & 15.35 & 12.10 & **9.22** & 11.44 \\ CIFAR-100 & ResNet50 & 18.14 & 13.36 & 8.60 & **4.99** & 8.15 \\ CIFAR-100 & Wide-ResNet26-10 & 16.28 & 9.12 & 4.22 & **2.20** & 5.27 \\ TinyImageNet & ResNet50 & 15.98 & 7.87 & 3.32 & **1.93** & 15.73 \\ \hline \hline \end{tabular}
\end{table}
Table 1: ECE, % – Expected Calibration Error (lower is better), 15 bins without post-processing, columns correspond to different loss functions
Figure 4: CIFAR-100, ShuffleNetV2_x0_5
estimates (Table 2). At the same time, such models can be further calibrated with post-processing. In the original paper [18], temperature scaling was used to calibrate models trained with focal loss. Although this approach does show good results with respect to ECE (Table 6), vector scaling works better for classwise cwECE (Table 8). As for models of the first group (Table 7), vector scaling also basically minimizes cwECE. These results are quite expected since vector scaling finds separate coefficients for each class.
Consider also reliability diagrams for EfficientNet (Figure 6). Among all the models used, the underconfidence is most clearly visible in this neural network: most of the predictions fall not into \([0.9,1]\), but into \([0.8,0.9)\). The reason for this behavior may be training setup: the model was trained with label smoothing (\(\alpha=0.1\)) [22]. All calibration methods resulted in a noticeable increase in the confidence of the answers.
## 6 Conclusion
In this work, the main methods of confidence calibration were compared on different neural network architectures, datasets, and critera.
The applicability of a particular method depends significantly on the amount of data and the selected evaluation criterion. Algorithms, in which separate calibration maps are found for each class, work well only if there is a sufficient amount of data in the calibration set (this can usually be provided when the number of classes is small). Strategies based on linear
Figure 5: CIFAR-10, DenseNet121 (CE)
transformation of logits (for example, temperature scaling) show high quality in problems with a large number of classes but are subject to overfitting when parameterization is excessive (matrix scaling).
Confidence calibration is still open to further research in machine learning: as shown in this work, not only calibration methods but also criteria choice can lead to different results.
Figure 6: ImageNet, EfficientNet_b8 |
2302.04373 | Measuring the Privacy Leakage via Graph Reconstruction Attacks on
Simplicial Neural Networks (Student Abstract) | In this paper, we measure the privacy leakage via studying whether graph
representations can be inverted to recover the graph used to generate them via
graph reconstruction attack (GRA). We propose a GRA that recovers a graph's
adjacency matrix from the representations via a graph decoder that minimizes
the reconstruction loss between the partial graph and the reconstructed graph.
We study three types of representations that are trained on the graph, i.e.,
representations output from graph convolutional network (GCN), graph attention
network (GAT), and our proposed simplicial neural network (SNN) via a
higher-order combinatorial Laplacian. Unlike the first two types of
representations that only encode pairwise relationships, the third type of
representation, i.e., SNN outputs, encodes higher-order interactions (e.g.,
homological features) between nodes. We find that the SNN outputs reveal the
lowest privacy-preserving ability to defend the GRA, followed by those of GATs
and GCNs, which indicates the importance of building more private
representations with higher-order node information that could defend the
potential threats, such as GRAs. | Huixin Zhan, Kun Zhang, Keyi Lu, Victor S. Sheng | 2023-02-08T23:40:24Z | http://arxiv.org/abs/2302.04373v1 | Measuring the Privacy Leakage via Graph Reconstruction Attacks on Simplicial Neural Networks (Student Abstract)
###### Abstract
In this paper, we measure the privacy leakage via studying whether graph representations can be inverted to recover the graph used to generate them via graph reconstruction attack (GRA). We propose a GRA that recovers a graph's adjacency matrix from the representations via a graph decoder that minimizes the reconstruction loss between the partial graph and the reconstructed graph. We study three types of representations that are trained on the graph, i.e., representations output from graph convolutional network (GCN), graph attention network (GAT), and our proposed simplicial neural network (SNN) via a higher-order combinatorial Laplacian. Unlike the first two types of representations that only encode pairwise relationships, the third type of representation, i.e., SNN outputs, encodes higher-order interactions (e.g., homological features) between nodes. We find that the SNN outputs reveal the lowest privacy-preserving ability to defend the GRA, followed by those of GATs and GCNs, which indicates the importance of building more private representations with higher-order node information that could defend the potential threats, such as GRAs.
1 Department of Computer Science, Texas Tech University, Box 43104, Lubbock, TX 79409-3104, USA
2 Department of Computer Science, Xavier University of Louisiana, New Orleans, LA 70125, USA
3 Department of Computer Science and Engineering, The Ohio State University, Columbus, OH 43210, USA
{\({}^{\dagger}\)Huixin.Zhan, "Victor.Sheng)@ttu.edu, \({}^{\ddagger}\)[email protected], \({}^{\dagger}\)[email protected],
## 1 Introduction
Most real-world graphs associated with people or human-related activities are often sensitive and might contain confidential information. In this paper, we focus on the threat of edge privacy, e.g., in an online social network, a user's friend list could potentially be private to the user. The server could aggregate node representations with their neighbors to learn better user representations to improve its services. Thus, if there is an edge between two nodes, their output representations obtained from the graph neural network (GNN) should be closer. Therefore, a potential adversary could possibly recover the sensitive edge information (e.g., friend lists) via a machine learning classifier that computes distance differences in graph representations.
In this paper, we study three representation methods (two low-order and one higher-order) that perform different aggregations to capture important graph structure properties, i.e., representations output from GCN, GAT, and our proposed SNN. Unlike the first two types of representations that only encode pairwise relationships, the proposed SNN utilize a higher-order combinatorial Laplacian to learn a graph convolution that encodes the homological features of simplicial complexes, which are higher-dimensional analogs of graphs [1]. We will then measure if SNN outputs are more vulnerable to potential attacks compared to regular GCN or GAT outputs.
We use GRAs as the potential attacks to measure privacy leakage. GRAs study whether representations can be inverted to recover the graph used to generate them. We propose a novel GRA for accurate representation inversion, i.e., from the representation outputs of a graph \(\mathcal{G}\), we can find a graph \(\mathcal{\hat{G}}\) with a very similar adjacency matrix. When a user's device computes a representation via GNN and sends it to a server for node classification, we assume the adversary could access the representation outputs with non-confidential edges during the data uploading process. We propose a graph decoder that reconstructs the graph by minimizing the reconstruction loss between the partial graph (with non-confidential edges) and the reconstructed graph. In our experiments, we will show that the SNN outputs reveal the lowest privacy-preserving ability to defend the GRAs. This calls for future research towards building more private representations with higher-order node information that could defend the potential attacks, such as GRAs.
## 2 Our Proposed Methods
SNN OutputsIn this paper, we will refer abstract simplicial complex to simplicial complexes. An abstract simplicial complex is a collection \(K\) of subsets of a finite set \(S\) that satisfies two axioms: (1) The singleton set \(\{v\}\) lies in \(K\) for each \(v\) in \(S\). (2) Whenever some \(\sigma\subset S\) lies in \(K\), every subset of \(\sigma\) must also lie in \(K\). The constituent subsets \(\sigma\subset S\) which lie in \(K\) are called simplices. Next, we will introduce the computation of \(d\)-dimensional incidence matrices. Fixing a collection \(K\) and letting \(K_{d}\) indicate the set of all \(d\)-simplices in \(K\), the \(d\)-dimensional incidence matrices operators can be represented as \(\partial_{d}:\mathbb{R}^{K_{d}}\rightarrow\mathbb{R}^{K_{d-1}}\). To build these incidence matrices operators, one first orders the nodes in \(K_{0}\) so that each \(d\)-simplex \(\sigma\subset K\) can be uniquely expressed as a list \(\sigma=[v_{0},...,v_{d}]\) of nodes in increasing order. The desired matrix \(\partial_{d}\) is completely prescribed by the following action on each \(\sigma\): \(\partial_{d}(\sigma)=\sum_{i=0}^{d}(-1)^{i}\cdot\sigma_{-i}\), where \(\sigma_{-i}:=[v_{0},...,\hat{v}_{i},...,v_{d}]\) and \(\hat{v}_{i}\) indicates that \(v_{i}\) is omitted. These operators form a sequence of vector spaces
and linear maps:
\[\cdots\overset{\partial_{d+1}}{\rightarrow}\mathbb{R}^{K_{d}}\overset{\partial_{ d}}{\rightarrow}\mathbb{R}^{K_{d-1}}\overset{\partial_{d-1}}{\rightarrow}\cdots. \tag{1}\]
In order to model the higher-order interactions between nodes, the graph Laplacian was generalized to simplicial complexes by Horak and Jost (2013). The higher-order combinatorial Laplacian can be formulated as: \(\mathcal{L}_{d}:=\partial_{d+1}\partial_{d+1}^{T}\partial_{d}\). Therefore, leveraging this \(\mathcal{L}_{d},\) we could obtain the final SNN outputs via the graph convolution as follows: \(H^{(2)}=\sigma(\tilde{Q}^{-\frac{1}{2}}\tilde{\mathcal{L}}_{d}\tilde{Q}^{- \frac{1}{2}}\sigma(\tilde{Q}^{-\frac{1}{2}}\tilde{\mathcal{L}}_{d}\tilde{Q}^{- \frac{1}{2}}H^{(0)}W^{(0)})W^{(1)}),\) where \(\tilde{\mathcal{L}}_{d}=\mathcal{L}_{d}+\mathbb{I},\mathbb{I}\) is the identity matrix, \(\tilde{Q}_{ii}=\sum_{j}\tilde{\mathcal{I}}_{d_{ij}}\) and \(W^{(k)}\) is a layer-specific trainable weight matrix. \(\sigma(\cdot)\) denotes an activation function. \(H^{(k)}\) is the matrix of activations in the \(k\)-th layer and the initial node representations are \(H^{(0)}\).
Graph Reconstruction AttackA graph \(\mathcal{G}=(V,E)\) is represented by the set of nodes \(V=\{v_{i}\}_{i=1}^{|V|}\) and edges \(E=\{e_{ij}\}_{i,j=1}^{|E|}\). To measure the privacy leakage via GRA, we will then propose a decoder only approach. Specifically, we utilize the outputs \(H^{(k)}\) and a partial adjacency matrix \(\mathcal{A}^{*}\) as the prior knowledge, the decoder \(f_{dec}\) reconstructs the adjacency matrix \(A_{rec}=\sigma((\tilde{\mathcal{A}}^{*}H^{(k)}W_{a})(\tilde{\mathcal{A}}^{*} H^{(k)}W_{a})^{\mathbf{T}}),\) where \(W_{a}\) is trained using back-propagation to minimize reconstruction loss between the adjacency matrix of the perial graph \(\mathcal{A}^{*}\) and the reconstructed partial graph \(\mathcal{A}^{*}_{rec}\) using \(\mathcal{L}^{(att)}=||\mathcal{A}^{*}-\mathcal{A}^{*}_{rec}||_{2}^{2}\).
## Experiments
DatasetsIn our experiments, we used five well-known real-world datasets: CiteSeer and CORA from Sen et al. (2008), PubMed Namata et al. (2012), as well as Amazon Computers and Amazon Photo from Shchur et al. (2018).
Experimental Set-UpIn order to generate GCN and GAT outputs, we follow the original graph convolution in GCNs Welling and Kipf (2016) and concatenation in GATs Velickovic et al. (2017). We only consider \(1\)-simplices, i.e., \(d=1\).
Performance for Three Types of RepresentationsTable 1 shows the GRA performance in terms of AUC of three types of representations for recovering the adjacency matrix \(\mathcal{A}\) of \(\mathcal{G}\). We compare our results with Attack-6 He et al. (2021) because it also requires node representations and the partial adjacency matrix \(\mathcal{A}^{*}\) as prior knowledge. Our proposed GRA with GCN outputs (GRA_GCN outputs) obtains inferior performances compared to Attack-6 (with \(\downarrow\)). However, GRA_GAT outputs achieve higher performances compared to Attack-6 in most of the cases and GRA_SNN outputs achieve the highest performances for all datasets (in bold), e.g., it achieves \(98.33\%\) AUC on the Citeseer dataset. This indicates the SNN outputs reveal the lowest privacy-preserving ability to defend the GRAs, followed by GAT and GCN outputs.
## Conclusion
In this paper, we measure the privacy leakage via studying whether representations can be inverted to recover the graph used to generate them using GRA. Our proposed GRA recovers a graph's adjacency matrix from the representations via a graph decoder that minimizes the reconstruction loss. We studied three types of representations that are trained on the graph, i.e., GCN outputs, GAT outputs, and SNN outputs using a higher-order combinatorial Laplacian. We found SNN outputs reveal the lowest privacy preserving ability. This indicates the importance of building more private representations with higher-order node information that could defend the potential threats.
|
2302.12505 | Spatial Bias for Attention-free Non-local Neural Networks | In this paper, we introduce the spatial bias to learn global knowledge
without self-attention in convolutional neural networks. Owing to the limited
receptive field, conventional convolutional neural networks suffer from
learning long-range dependencies. Non-local neural networks have struggled to
learn global knowledge, but unavoidably have too heavy a network design due to
the self-attention operation. Therefore, we propose a fast and lightweight
spatial bias that efficiently encodes global knowledge without self-attention
on convolutional neural networks. Spatial bias is stacked on the feature map
and convolved together to adjust the spatial structure of the convolutional
features. Therefore, we learn the global knowledge on the convolution layer
directly with very few additional resources. Our method is very fast and
lightweight due to the attention-free non-local method while improving the
performance of neural networks considerably. Compared to non-local neural
networks, the spatial bias use about 10 times fewer parameters while achieving
comparable performance with 1.6 ~ 3.3 times more throughput on a very little
budget. Furthermore, the spatial bias can be used with conventional non-local
neural networks to further improve the performance of the backbone model. We
show that the spatial bias achieves competitive performance that improves the
classification accuracy by +0.79% and +1.5% on ImageNet-1K and cifar100
datasets. Additionally, we validate our method on the MS-COCO and ADE20K
datasets for downstream tasks involving object detection and semantic
segmentation. | Junhyung Go, Jongbin Ryu | 2023-02-24T08:16:16Z | http://arxiv.org/abs/2302.12505v1 | # Spatial Bias for Attention-free Non-local Neural Networks
###### Abstract
In this paper, we introduce the spatial bias to learn global knowledge without self-attention in convolutional neural networks. Owing to the limited receptive field, conventional convolutional neural networks suffer from learning long-range dependencies. Non-local neural networks have struggled to learn global knowledge, but unavoidably have too heavy a network design due to the self-attention operation. Therefore, we propose a fast and lightweight spatial bias that efficiently encodes global knowledge without self-attention on convolutional neural networks. Spatial bias is stacked on the feature map and convolved together to adjust the spatial structure of the convolutional features. Therefore, we learn the global knowledge on the convolution layer directly with very few additional resources. Our method is very fast and lightweight due to the attention-free non-local method while improving the performance of neural networks considerably. Compared to non-local neural networks, the spatial bias use about \(\times 10\) times fewer parameters while achieving comparable performance with \(1.6\sim 3.3\) times more throughput on a very little budget. Furthermore, the spatial bias can be used with conventional non-local neural networks to further improve the performance of the backbone model. We show that the spatial bias achieves competitive performance that improves the classification accuracy by \(+0.79\%\) and \(+1.5\%\) on ImageNet-1K and cifar100 datasets. Additionally, we validate our method on the MS-COCO and ADE20K datasets for downstream tasks involving object detection and semantic segmentation.
keywords: Non-local operation, Long-range dependency, Spatial bias, Global context, Image classification, Convolutional neural networks +
Footnote †: journal: Expert Systems with Applications
## 1 Introduction
Convolutional neural networks (CNNs) excel in extracting nuanced local information. Thanks to this advantage, CNNs are utilized for a variety of visual recognition tasks. However, their inability to effectively capture the global context has been mentioned numerous repeatedly. Due to the limited receptive field size, the convolution focuses on a small region that learns only local information; to overcome this, several approaches to increase the receptive field size have been extensively studied, such as building deeper layers He et al. (2016), employing different kernel sizes Szegedy et al. (2015); Li et al. (2019); Li and Zhang (2022), and learning non-local pixel-level pairwise relationships Wang et al. (2018); Cao et al. (2019); Fang et al. (2021); You et al. (2022); Ding et al. (2023); Cho et al. (2022); Chi et al. (2020); Xie et al. (2022). Among these methods, self-attention based non-local neural networks Wang et al. (2018) have been a major approach to capture long-range information. However, they exploit an excessive amount of resources because of the self-attention operation. Therefore, this paper presents a novel lightweight method that directly learns the long-range dependency during the convolution operation. The proposed method acquires global knowledge by
Figure 1: Performance comparison for the proposed method and conventional non-local neural networks on ImageNet-1K dataset. \(\bullet\) denotes the naive ResNet backbone and conventional non-local neural networks and \(\star\) present performance improvement of the conventional networks with our spatial bias. In all cases, the proposed spatial bias enhance networks with minimal computational complexity.
incorporating a spatial bias term into the convolution operation. A spatial bias with long-range correlation is added to the position in which convolution is performed.
The proposed method allows for the simultaneous learning of local information from the convolution term and global knowledge from the spatial bias term. In addition, a minimal amount of resources are used for the proposed spatial bias term, and thus our method is very fast and lightweight compared to the conventional self-attention based non-local neural networks. We extensively carry out experiments on the number of parameters, FLOPs, throughput, and accuracy to show the efficacy of the proposed spatial bias method. As shown in Fig. 1, the inference time overhead of our spatial bias is **1.6** to **3.3** times less than that of non-local neural network while achieving competitive performance compared to the non-local networks Wang et al. (2018); Cao et al. (2019); Chi et al. (2020). The proposed spatial bias further improves the performance of backbone networks in conjunction with existing self-attention operations. The following is a summary of the contributions regarding our spatial bias.
* We introduce a spatial bias that takes into account both local and global knowledge in a convolution operation. Thanks to the proposed lightweight architecture, the spatial bias term is computed very quickly and with a small amount of overhead.
* We show that the proposed spatial bias term significantly improves the performance while incurring very modest overheads: in the case of ResNet-50 backbone, the parameter overhead of spatial bias has only 6.4% and \(\times 3.3\) faster compared to the non-local neural network (NLNet) Wang et al. (2018).
* We verify the generalizability of the proposed spatial bias by combining it with other non-local methods and backbones. We also confirm that spatial bias improves performance in downstream tasks.
## 2 Related Work
Non-local Neural Network with Self-attentionThe non-local neural networks Wang et al. (2018); Cao et al. (2019); Chi et al. (2020) using self-attention operation that learns long-range dependency has been most widely studied. Unlike
convolution operation, self-attention learns global knowledge in a single layer, which alleviates the narrow receptive field problem of CNNs. This approach performs well when applied to a variety of visual tasks. In particular, NLNet Wang et al. (2018) is the first study to exploit the self-attention operation for learning the pairwise relationship at the global pixel-level. However, since NLNet is calculated after obtaining an attention map independent of each query, the computation complexity is very high. For different query locations, GCNet Cao et al. (2019) generates similar attention maps, thereby modeling an efficient non-local block. In order to create lighter non-local networks, CCNet Huang et al. (2019), A2Net Chen et al. (2018), and BAT Chi et al. (2020) have been introduced by using an iterative cross-attention module Huang et al. (2019), dual-attention method Chen et al. (2018), and data-adaptive bilinear attentional transformation Chi et al. (2020). Fang et al. (2021) proposes an location-based attention method that distills positive information in a global context. Recently, the non-local neural networks are
Figure 2: Grad-Cam Selvaraju et al. (2017) visualization for spatial bias and convolution feature map. Notably, the grad-cam on the spatial bias exposes wider regions, which aids in learning global knowledge.
used to various tasks such as histopathological image classification Ding et al. (2023) and hand detection Xie et al. (2022). These methods have contributed to the design paradigm of non-local neural networks with the reduced overhead of self-attention operation. However, we argue that they still suffer from a fatal flaw in that their computational cost is quadratic \(O(n^{2})\)1 which causes a slowdown of inference time.
Footnote 1: \(n\) indicates the number of all positions in the feature map
Due to the heavy design of self-attention, conventional non-local methods are inserted only at specific layers in a convolutional neural network by consideration of the throughput and network size. Additionally, since traditional non-local operations only consider spatial correlation by merging channels, they are blind to any channel correlation. Therefore, to overcome these limitations, we propose spatial bias, an attention-free non-local neural network with a fast and lightweight architecture. In comparison to self-attention based non-local neural networks, the proposed spatial bias achieves comparable performance with \(1.6\sim 3.3\) times more throughput on a very little budget. Additionally, lightweight spatial bias can be employed across all network levels, complementing the existing heavy self-attention that can be given to particular layers. Thus, our spatial bias enables a network to learn more about global knowledge due to its fast and lightweight properties.
_Architecture Modeling._ Recently, effective neural networks have shown advances across a range of many visual recognition tasks. The modern CNN architecture conceived by LeNet LeCun et al. (1998) was realized a decade ago by AlexNet Krizhevsky et al. (2012), and various studies have been conducted to improve its performance and usefulness. Since then, CNN Simonyan and Zisserman (2014) with small filter sizes has been developed to encode more precise regional data. Consequently, skip connections have made it possible to build deeper networks He et al. (2016) and several studies have been done to increase expressiveness by varying the width, multi-path block design, or grouped feature flow of neural networks Zagoruyko and Komodakis (2016); Szegedy et al. (2015); Xie et al. (2017); Gao and Zhou (2023); Schwarz Schuler et al. (2022). Through a multi-branch design, recent CNN architectures Szegedy et al. (2015); Li et al. (2019); Zhang et al. (2020); Gao et al. (2019); Guo et al. (2021) communicate information between branches. Additionally, several methods Wang et al. (2018); Chi et al. (2020); Cao et al. (2019) capture long-range dependencies by taking advan
tage of the self-attention operation that guarantees a better understanding of global knowledge for the visual recognition task.
## 3 Proposed Method
The convolution utilizes a shared weight within a limited local window, allowing CNN to have the property of translational equivalence Zhang (2019). Recently, this property has been identified as the inductive bias Baxter (2000), and it has been stated repeatedly that convolution is not particularly effective at learning the relationship between long-range objects Wang et al. (2018). To address this problem, we propose a spatial bias term to compensate for these shortcomings in the convolution. Different from the existing method Wang et al. (2018); Cao et al. (2019); Chi et al. (2020) using the heavy self-attention module, the proposed method learns the global knowledge by adding a few spatial bias channels to the convolution feature map. Inspired by parallel network designs Szegedy et al. (2015); Li et al. (2019); Zhang et al. (2020); Gao et al. (2019), we devise the parallel branches that could complement long-range dependencies of a network as shown in Fig. 3. To generate the spatial bias, we encode long-range dependencies by compressing feature maps in channel and spatial directions. Then, we extend it to concatenate the spatial bias map and the convolutional feature map in the channel direction. Global knowledge from spatial bias is aggregated with the local features of the convolutional feature map, so the network learns both
Figure 3: Design of Spatial Bias term. The figure on the left shows the overall workflow and the right one shows its detail. In the right figure, to capture the global dependency, the channel and spatial size of the feature map are reduced through the \(1\times 1\) convolution and average pooling operations. We aggregate spatial bias on a reduced feature map using a simple 1D convolution operation.
local and global information. As shown in the Fig. 2, the spatial bias learns a wider region while convolution focuses on the local features in an image. Therefore, the CNN with the spatial bias learns richer information through our concatenated feature map. The following section introduces the specific process of aggregating convolutional feature map and spatial bias.
Generating Spatial Bias Map.Let the input feature map \(X\) of a convolution layer be \(X\in\mathbb{R}^{H\times W\times C}\). On this feature map, we compress it in the channel and spatial direction. Specifically, we use \(1\times 1\) convolution for channel reduction, where the feature map has a \(C^{\prime}\) channel. Then, we adopt an average pooling layer for the spatial compression that yields \(P\in\mathbb{R}^{H^{\prime}\times W^{\prime}\times C^{\prime}}\). We get a transformed feature map by flattening each channel of the feature map P into a 1D vector, \(Q\in\mathbb{R}^{1\times C^{\prime}\times H^{\prime}W^{\prime}}\).
To aggregate global knowledge on this transformed feature map, we exploit a \(1\times N\) convolution in the channel dimension where the \(N\) is larger than 1 so that we encode the inter-channel relationship global knowledge. The spatial bias map is then upsampled to the same size as the convolutional feature map using bilinear interpolation. The upsampled spatial bias map is concatenated with the convolutional feature maps as Eq. 1.
\[Output=ReLU(BN[Conv(X),SB]), \tag{1}\]
where \(X\) denotes an input feature map, \(Conv()\) and \(SB\) denote a standard convolution and a spatial bias, and [,] is the concatenate operation. After concatenation, the resultant feature map is sent through batch normalization and nonlinear activation layers.
Convolution with Spatial Bias.In general, naive convolution employs modest kernel sizes (_e.g._, \(3\times 3\)). To compensate the limited kernel size, the self-attention module is added after specific convolution layer to learn the global knowledge. In other words, the heavy self-attention operation is independently applied which increase parameters and computational budget extensively. The proposed spatial bias and convolutional features are complementary to each other. Spatial bias extracts the information of long range-dependency, which complement the existing short range-dependency of convolutional operation. The proposed spatially biased convolution need only minimal overhead of convolution operation due to our self-attention free approach. We aim to learn both of the local and global knowledge in convolution layer directly without additional module.
Complexity of Spatial BiasIn this paragraph, we discuss about the complexity of the proposed spatial bias in comparison with the self-attention operation. Suppose input size is defined as \(X\in\mathbb{R}^{H\times W\times C}\), the self-attention mechanism has a computational complexity of \(O((HW)^{2}C)\approx O((HW)^{2})\), because self-attention operation applies three projections to obtain query, keys and values and computes dot products between query and keys. On the other hand, the proposed spatial bias reduces the feature map size \(X\) by a fixed constant. Therefore, the complexity of spatial bias is \(O(H^{\prime}W^{\prime}sf)\approx O(H^{\prime}W^{\prime}f)\), where \(s\) and \(f\) denote the kernel size, number of filters. Since the number of filters is the same as \(H^{\prime}W^{\prime}\), the spatial bias has the complexity of \(O((H^{\prime}W^{\prime})^{2})\). The reduced height \(H^{\prime}\) and width \(W^{\prime}\) are fixed constant value, so the computational complexity is ideally \(O(1)\).
Therefore, we get very fast and lightweight operation that can be inserted into any convolutional layers. In the experiment section, we show its effectiveness with regard to the throughput, parameters, and computational overhead as well as performance improvement of CNNs.
On the Comparison with Squeeze and ExcitationThe general channel attention method (_i.e._, SENet, SKNet) Hu et al. (2018); Li et al. (2019) captures the channel-wise summarized information of the feature map and then learns the relationship between the channels to adjust the feature map, so the spatial correlation is not learned. On the other hand, the proposed spatial bias extracts the spatial-wise compressed information and then expands it toward the channel. That is, dependence on the spatial-channel direction can be aggregated at once with only a general convolution operation. In addition, while SE-like method refine the channel importance of the output feature map of the convolution layer, the proposed method learn different information in that it learns the channel and spatial information together in the convolution process directly by adding a bias to the feature map. Therefore, as shown in Table 8, the proposed spatial bias is more efficient than SE-like methods and additionally improve the performance of backbone when combining them with our spatial bias.
## 4 Experiments
In this section, we first perform ablation studies on the proposed spatial bias, then compare it with the conventional non-local neural networks with self-attention operation. We, then, provide the experimental analysis
of OOD and shape bias to support the effectiveness of the spatial bias. Finally, we show the experimental result on the object detection and semantic segmentation tasks.
### Experimental result on CIFAR-100
Setup.We report mean accuracy of three experiments using the CIFAR-100 dataset on the proposed method with different random seed for reliable comparison. We set the training recipe with reference to Yun et al. (2019). We use \(32\times 32\) image size 64 samples per mini-batch with 300 epochs. We initially set the learning rate as 0.25 and decayed it by a factor of 0.1 after each 75 epochs.
\begin{table}
\begin{tabular}{|c|c|c c c c|} \hline \hline Network & Stage & Param. & MFLOPs & Top-1 Error (\%) & Top-5 Error (\%) \\ \hline \multirow{4}{*}{ResNet-38} & - & 0.43M & 62.2 & 23.98 \(\pm\)0.23 & 5.73 \(\pm\)0.20 \\ & \(s_{1}\) & 0.45M & 63.6 & 23.86 \(\pm\)0.08 & 5.60 \(\pm\)0.13 \\ \cline{2-6} & \(s_{1},s_{2}\) & 0.46M & 64.2 & 22.44 \(\pm\)0.10 & 4.99 \(\pm\)0.05 \\ & \(s_{1},s_{2},s_{3}\) & 0.48M & 64.6 & 22.46 \(\pm\)0.25 & 5.21 \(\pm\)0.30 \\ \hline \multirow{4}{*}{ResNet-65} & - & 0.71M & 103.3 & 21.87 \(\pm\)0.35 & 5.33 \(\pm\)0.18 \\ & \(s_{1}\) & 0.74M & 105.8 & 20.81 \(\pm\)0.41 & 4.73 \(\pm\)0.09 \\ \cline{2-6} & \(s_{1},s_{2}\) & 0.77M & 106.9 & 20.77 \(\pm\)0.14 & 4.67 \(\pm\)0.29 \\ \cline{2-6} & \(s_{1},s_{2},s_{3}\) & 0.80M & 107.5 & 20.37 \(\pm\)0.20 & 4.61 \(\pm\)0.09 \\ \hline \multirow{4}{*}{ResNet-110} & - & 1.17M & 171.9 & 20.59 \(\pm\)0.38 & 4.96 \(\pm\)0.10 \\ & \(s_{1}\) & 1.22M & 176.1 & 19.97 \(\pm\)0.08 & 4.55 \(\pm\)0.06 \\ \cline{1-1} \cline{2-6} & \(s_{1}\),\(s_{2}\) & 1.28M & 178.0 & 19.42 \(\pm\)0.20 & 4.38 \(\pm\)0.06 \\ \cline{1-1} \cline{2-6} & \(s_{1},s_{2},s_{3}\) & 1.34M & 179.1 & 19.65 \(\pm\)0.68 & 4.80 \(\pm\)0.21 \\ \hline \end{tabular}
\end{table}
Table 1: Experimental result on CIFAR-100 through the proposed Spatial Bias(**3-bias channels**). Here, \(s_{\#}\) denotes the stage index of the ResNet architecture after the stem cell.
\begin{table}
\begin{tabular}{c c c c} \hline \hline Position & Stage & Top-1 Error (\%) & Param. \\ \hline \multirow{2}{*}{**Conv1**} & \(s_{1},s_{2}\) & 20.57 & 0.78M \\ & \(s_{1},s_{2},s_{3}\) & 20.56 & 0.83M \\ \hline \multirow{2}{*}{**Conv2**} & \(s_{1},s_{2}\) & 20.77 & 0.77M \\ & \(s_{1},s_{2},s_{3}\) & 20.37 & 0.80M \\ \hline \end{tabular}
\end{table}
Table 2: Experimental result on the comparison of insertion position in a bottleneck. We add spatial bias in parallel after **Conv1** or **Conv2**. The out channels of **Conv2** is reduced so that the spatial bias after **Conv2** has less parameters.
Position of Spatial Bias.Table 1 summarizes the performance comparison of spatial bias positions in ResNet stages. Since the spatial bias compresses the spatial resolution to the fixed size (_i.e._, 6 for CIFAR-100, 10 for ImageNet, Table 3), the overhead of parameters and computational budget is very small regardless of the stages. When we apply the spatial bias to stage1 (\(s1\)) and stage2 (\(s2\)), the performance of ResNet backbone is improved considerably. However, in the last stage (\(s3\)), there is no performance improvement with the spatial bias. We assume that the spatial size of the last stage is too small so that the global knowledge is disappeared.
Further, we validate the position of the spatial bias in a residual bottleneck. Table 2 shows the performance comparison in the insertion position of spatial bias after **Conv1** or **Conv2** in a bottleneck. We confirm that the spatial bias after **Conv2** reduce the parameters while achieving similar performance compared to that of **Conv1**.
Number of Spatial Bias Channels.We compare the performance on the number of spatial bias channels. The channel of the spatial bias represents its importance in the concatenated output, and thus the more channels are used, the more global knowledge will be learned from the spatial bias. As shown in Table 4, we confirm that the performance and overhead are the optimal when three channels were used (**Bias-3** and **Bias-4**), but the performance is degraded beyond that (_i.e._, **Bias-5** and **Bias-6**). It is inferred that if too much spatial bias is used, the convolution features are damaged which cause the performance deteriorates of entire networks.
Component analysis.We perform an ablation study on spatial bias component analysis. **Add** in Table 5 represent that the spatial bias is added to the feature map. In addition, the average pooling layer is replaced by the maximum pooling layer (**Maxpool**). Lastly, the global context is aggregated
\begin{table}
\begin{tabular}{l c c c} \hline \hline \multirow{2}{*}{Network} & \multirow{2}{*}{Param.} & \multirow{2}{*}{Top-1 Error (\%)} & Throughput (sample/sec) \\ \hline ResNet-65 & 0.71M & 21.87 & 12,816 \\ \(SB_{6}\) & 0.77M & 20.77 & 10,276 \\ \(SB_{10}\) & 1.13M & 20.48 & 10,221 \\ \(SB_{14}\) & 2.33M & 20.84 & 10,267 \\ \(SB_{16}\) & 3.47M & 20.75 & 10,467 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Various size for Spatial bias on CIFAR-100 (_i.e._, \(SB_{6}\) denotes compression size of 6).
with only the average layer(**Pool only**) for performance verification on the key operations.
### Experimental results on ImageNet
SetupIn this section, we present experimental result on ImageNet-1k, which includes more than 1.2 million images with 1,000 class labels. We validate our performance on ImageNet dataset using two training recipes. First, we use the training recipe of Wightman et al. (2021) to demonstrates the effectiveness of the proposed spatial bias. In this recipe, the training mini-batch size is set to 512 with 100 epochs using \(160\times 160\) input size. We initialize the learning rate to 8e-3 with the cosine learning rate scheduler. For optimization, we use a lamb You et al. (2019) that is suitable for training of large batch size. Second, we follow NLNet Chi et al. (2020)'s training recipe for fair comparison with state-of-the-art non-local neural networks. Specifically, we exploit the cropped input image as \(224\times 224\) size. The initial learning rate of 0.1 is reduced by 0.1 after 30, 60, and 80 epochs. We use 256 batch size
\begin{table}
\begin{tabular}{c|c c} \hline \hline Method & Param. & Top-1 Error (\%) \\ \hline Bias-0 & 0.71M & 21.87 \\ \hline Bias-1 & 0.76M & 20.91 \\ \hline Bias-2 & 0.77M & 20.99 \\ \hline Bias-3 & 0.77M & **20.77** \\ \hline Bias-4 & 0.77M & **20.60** \\ \hline Bias-5 & 0.77M & 21.06 \\ \hline Bias-6 & 0.77M & 20.82 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Experimental results on the number of spatial bias channels in CIFAR-100. Bias-# indicates the number of channels. We use ResNet-65 as the backbone networks. We add the spatial bias to the stage 1 and 2.
\begin{table}
\begin{tabular}{c c c} \hline \hline Network & Param. & Top-1 Error (\%) \\ \hline Add & 0.76M & 20.93 \\ Maxpool & 0.77M & 21.03 \\ Pool only & 0.71M & 22.34 \\ \hline \(SB_{6}\) & 0.77M & 20.77 \\ \hline \hline \end{tabular}
\end{table}
Table 5: Component analysis for Spatial bias on CIFAR-100.
and stochastic gradient descent(SGD) optimizer.
Result.We perform experiments with the position of the spatial bias and its channel size. We compare the performance of spatial bias on which stage of ResNet backbone. As shown in Table 6, the spatial bias has the best performance when adding it from stage 1 to 3 \(s1,s2,s3\). This result is the same as that of CIFAR-100 result where the spatial bias does not work on the small spatial size of the last stage. In addition, when the spatial bias is not used at the first stage \(s1\), the performance increase is insignificant. This result means that, as in previous studies Wang et al. (2018); Chi et al. (2020), global knowledge exists a lot in the earlier layer with high resolution, and thus the effect of spatial bias is greater.
Table 7 shows the performance comparison in the number of spatial bias channels in ImageNet dataset. When 3\(\sim\)4 channels of the spatial bias are added, the performance is improved by +0.58% compared to the baseline, and wider channels 5\(\sim\)6 degrade the performance. This result also confirm that the optimal channels should be used to avoid the damage of convolution feature map.
In Table 9, we compare the performance of spatial bias and conventional non-local neural networks Wang et al. (2018); Cao et al. (2019); Chi et al. (2020). Our spatial bias need a minimal parameter overhead compared to
\begin{table}
\begin{tabular}{c|c c c c} \hline \hline Method & Stage & Param. & Top-1 (\%) & Top-5 (\%) \\ \hline \hline Bias-0 & - & 25.56M & 76.42 & 92.87 \\ \hline \multirow{4}{*}{Bias-3} & \(s_{1},s_{3}\) & 25.86M & 76.68 & 93.13 \\ & \(s_{2},s_{3}\) & 25.89M & 77.00 & 93.00 \\ \cline{1-1} & \(s_{1},s_{2},s_{3}\) & 25.99M & **77.11** & 93.19 \\ \cline{1-1} & \(s_{1},s_{2},s_{3},s_{4}\) & 26.02M & 76.70 & 93.08 \\ \hline \hline \end{tabular}
\end{table}
Table 6: Experimental results on the position of spatial bias in ImageNet-1K.
\begin{table}
\begin{tabular}{c|c c c c c} \hline \hline Bias-\# & 1 & 2 & 3 & 4 & 5 \\ \hline \hline Top-1 (\%) & 76.70 & 76.84 & **77.00** & **77.00** & 76.66 \\ \hline Param. & 25.87M & 25.88M & **25.89M** & **25.90M** & 25.91M \\ \hline \hline \end{tabular}
\end{table}
Table 7: Experimental result on the number of spatial bias channels in ImageNet-1K.
NLNet Wang et al. (2018) so that ours is faster than them by 3.3 times. Compared with improved version of non-local neural networks (_i.e._, GCNet and BAT) Cao et al. (2019); Chi et al. (2020), the computational budget of the spatial bias is much cheaper while achieving comparative performance. In particular, existing non-local methods (NLNet, GCNet, and BAT) apply the self-attention module in only specific layers due to the heavy design, but the proposed spatial bias can be used to all layers with minimal overhead. Therefore, our spatial bias is combined with the existing non-local methods in a network to further improve its performance. We also proceed with the comparison by visualizing the attention map of spatial bias and other non-local neural networks. As shown in Fig. 4, the proposed spatial bias is simple yet straightforward, but the visualization results of our method are comparable to complex self-attention-based non-local neural networks.
### Compare with Compressed Self-attention
We conduct further experiments on compressed non-local neural networks. We applied NLNet-50 by compressing the features to \(10\times 10\) with the same average pooling used in our spatial bias. As shown in Table 10, we confirms that the compressed NLNet-50 has little gain in parameters and latency, but its performance deteriorate.
### OOD distortion Robustness and Shape bias
In this section, we verify the performance of the proposed spatial bias on the out-of-distribution data set for measuring a statistically different dis
\begin{table}
\begin{tabular}{l l c c c} \hline \hline Network & Param. & GFLOPs & Top-1 (\%) & Top-5 (\%) & Throughput (sample/sec) \\ \hline ResNet-50 & 25.56M & 4.11 & 76.05 & 92.80 & 2042 \\ SRM-ResNet-50\({}^{4}\) & 25.62M & 4.15(\(\Delta\)0.04) & 77.10 & - & 1243(\(\Delta\)799) \\ GE-ResNet-50\({}^{4}\) & 31.12M & 4.14(\(\Delta\)0.03) & 76.80 & - & 1365(\(\Delta\)677) \\ SE-ResNet-50 & 28.09M & 4.14(\(\Delta\)0.03) & 76.84 & 93.45 & 1787(\(\Delta\)255) \\ SK-ResNet-50 & 27.49M & 4.47(\(\Delta\)0.36) & 77.56 & 93.62 & 1557(\(\Delta\)485) \\ SB-ResNet-50 & 25.99M & 4.13(\(\Delta\)0.02) & 76.86 & 93.33 & 1836(\(\Delta\)206) \\ \hline SB-SE-ResNet-50 & 28.52M & 4.16(\(\Delta\)0.05) & 77.10 & 93.59 & 1626(\(\Delta\)416) \\ SB-SK-ResNet-50 & 27.94M & 4.49(\(\Delta\)0.38) & 77.93 & 93.54 & 1440(\(\Delta\)602) \\ \hline \hline \end{tabular}
\end{table}
Table 8: Experimental results on the standard attention operation. Unlike channel attention operation, spatial bias learns channel and spatial-wise dependencies to readjust the feature map. In addition, our spatial bias is lighter than channel attention operation, and has faster inference speed. Therefore, the channel attention network to which spatial bias is added improves performance with only a very small additional budget.
tribution from the training data. We conduct an OOD distortion robustness experiment on a total of 17 test datasets which have statistically different distributions. It includes five datasets(sketches Wang et al. (2019), edge-filtered images, silhouettes, texture-shape cue conflict, and stylized images Geirhos et al. (2018a)) and 12 test datasets Geirhos et al. (2018b). We compare the OOD robustness of the spatial bias and non-local neural networks using two different metrics (accuracy difference2, observed consistency3. In Table 11, the proposed spatial bias is more robust to OOD datasets compared to the conventional non-local neural networks. This result prove that the proposed spatial bias works well regardless of the data domain.
\begin{table}
\begin{tabular}{l c c c} \hline \hline Network & Param. & Top-1 (\%) & Latency (step/sec) \\ \hline \hline NLNet-50 & 32.9M & 77.2 & \(\mathbf{\Delta}\)**689** \\ Reduced NLN & 32.9M & 77.0 & \(\mathbf{\Delta}\)**630** \\ SB (Ours) & 26.0M & 76.9 & \(\mathbf{\Delta}\)**206** \\ \hline \hline \end{tabular}
\end{table}
Table 10: Comparison between non-local neural networks and spatial bias on ImageNet-1K.
\begin{table}
\begin{tabular}{l c c c c c} \hline \hline Network & Param. & GFLOPs & Top-1 (\%) & Top-5 (\%) & Throughput (sample/sec) \\ \hline ResNet-50 & 25.56M & 4.11 & 76.05 & 92.80 & 2042 \\ NLNet-50 & 32.92M & 7.66(\(\Delta\)3.55) & 77.25 & 93.66 & 1353(\(\Delta\)689) \\ GCet-50\({}_{+all}\) & 28.08M & 4.12(\(\Delta\)0.01) & 76.93 & 93.25 & 1719(\(\Delta\)323) \\ BAT-50 & 30.23M & 5.41(\(\Delta\)1.30) & 77.78 & 94.01 & 1232(\(\Delta\)810) \\ \hline SB-ResNet-50 & 25.99M & 4.13(\(\Delta\)0.02) & 76.86 & 93.33 & 1836(\(\Delta\)206) \\ \hline SB-NLNet-50 & 33.35M & 7.68(\(\Delta\)3.57) & 77.59 & 93.74 & 1276(\(\Delta\)766) \\ SB-GCNet-50\({}_{+all}\) & 28.51M & 4.14(\(\Delta\)0.03) & 77.00 & 93.27 & 1613(\(\Delta\)429) \\ SB-BAT-50 & 30.66M & 5.43(\(\Delta\)1.32) & 78.06 & 93.97 & 1153(\(\Delta\)889) \\ \hline \hline \end{tabular}
\end{table}
Table 9: Experimental result on the comparison with state-of-the-art (SoTA) non-local neural networks. We compare the proposed attention-free spatial bias method with the self-attention based non-local neural networks. Our spatial bias (SB) improve the performance with very few additional resources compared to the SoTA methods. Additionally, due to our lightweight architecture, SB further improve the networks when combining with self-attention based non-local methods.
### Object Detection
In this subsection, we validate the performance of spatial bias on object detection task. In this experiment, we use Faster R-CNN Ren et al. (2015) and Cascade R-CNN Cai and Vasconcelos (2018) with FPN Lin et al. (2017) using 118k training and 5k verification images from the MS COCO-2017 dataset Lin et al. (2014). We use ResNet-50 as a backbone models previously trained on ImageNet dataset. By following the standard protocol Chen et al. (2019), we use a \(1\times\) learning rate schedule with 12 epochs. We exploit the SGD optimizer with 1e-4 weight decay value and 0.9 momentum, initial learning rate as 0.02. Networks are trained on two A5000 GPUs with 8 samples per GPU. We reduce the width of the image to 800 and keep the height below 1,333 pixels. As shown in Table 12, the networks with our spatial bias improve the performance of detection model for all metrics.
Figure 4: Grad-CAM Selvaraju et al. (2017) visualization of our spatial bias (SB) and non-local methods. Our spatial bias focuses more on the discriminant parts of an object.
### Semantic Segmentation
We perform the evaluation of semantic segmentation task using the ADE20k dataset Zhou et al. (2019). FPN Lin et al. (2017) architecture is utilized for the baseline model to which the spatial bias is applied5. Segmentation networks are trained on two GPUs with 14 samples per GPU for 40K iterations. Same as the detection networks, we use ResNet-50 backbone model trained on ImageNet with input \(512\times 512\) input image size. We employ the AdamW Loshchilov and Hutter (2017) as the optimization algorithm and set the initial learning rate as \(2\times 10^{-4}\) and a weight decay as \(10^{-4}\) with polynomial learning rate decay. As shown in Table 13, networks with our spatial bias outperform baseline networks by \(+1.27aAcc\), \(+2.16mIoU\), \(+3.31mAcc\).
Footnote 5: We adopt the implementation of FPN model from Contributors (2020).
## 5 Conclusion
In this paper, we propose the spatial bias that learn global knowledge with fast and lightweight architecture. The proposed method adds only a
\begin{table}
\begin{tabular}{c|c c} \hline \hline Network & Acc diff. \(\downarrow\) & Obs.consistency \(\uparrow\) \\ \hline BAT-50 & 0.069 & 0.677 \\ \hline SBRNet-50 & 0.078 & 0.668 \\ \hline GCNet-50 & 0.081 & 0.668 \\ \hline NLNet-50 & 0.086 & 0.661 \\ \hline ResNet-50 & 0.087 & 0.657 \\ \hline \end{tabular}
\end{table}
Table 11: Experimental results on OOD datasets. We compare the OOD robustness using three metrics. Spatial bias shows better OOD robustness compared to non-local neural networks.
\begin{table}
\begin{tabular}{c|c|c|c|c|c|c|c} \hline \hline Method & Backbone & \(\mathcal{AP}\) & \(\mathcal{AP}_{50}\) & \(\mathcal{AP}_{75}\) & \(\mathcal{AP}_{S}\) & \(\mathcal{AP}_{M}\) & \(\mathcal{AP}_{L}\) \\ \hline \multirow{2}{*}{Faster-RCNN} & ResNet-50 & 39.0 & 60.3 & 42.4 & 23.0 & 43.2 & 50.0 \\ & ResNet-50 + ours & **40.0** & **61.5** & **43.7** & **24.0** & **44.1** & **51.6** \\ \hline \multirow{2}{*}{Cascade-RCNN} & ResNet-50 & 41.9 & 60.5 & 45.7 & 24.2 & 45.8 & 54.8 \\ & ResNet-50 + ours & **42.8** & **61.9** & **46.8** & **25.2** & **46.2** & **55.5** \\ \hline \hline \end{tabular}
\end{table}
Table 12: Experimental results on object detection using MS-COCO dataset.
few additional spatial bias channels to a convolutional feature map so that the convolution layer itself learns global knowledge with the self-attention operation. That is, the spatial bias is be a kind of non-local method that allows convolution to learn long-range dependency. Spatial bias generates much less parameter, FLOPs, and the throughput overhead than existing non-local methods Wang et al. (2018); Chi et al. (2020); Huang et al. (2019); Chen et al. (2018). Our design choice is simple yet straightforward. We assume this is the advantage of being applicable to various network architectures. We argue that the computational cost of the existing non-local neural networks with self-attention operation has increased considerably by using rather complex design choice. Also, the proposed spatial bias can be used together with existing self-attention based non-local methods. We believe that our new approach without self-attention based non local neural networks will inspire future studies.
|
2307.07649 | DistTGL: Distributed Memory-Based Temporal Graph Neural Network Training | Memory-based Temporal Graph Neural Networks are powerful tools in dynamic
graph representation learning and have demonstrated superior performance in
many real-world applications. However, their node memory favors smaller batch
sizes to capture more dependencies in graph events and needs to be maintained
synchronously across all trainers. As a result, existing frameworks suffer from
accuracy loss when scaling to multiple GPUs. Evenworse, the tremendous overhead
to synchronize the node memory make it impractical to be deployed to
distributed GPU clusters. In this work, we propose DistTGL -- an efficient and
scalable solution to train memory-based TGNNs on distributed GPU clusters.
DistTGL has three improvements over existing solutions: an enhanced TGNN model,
a novel training algorithm, and an optimized system. In experiments, DistTGL
achieves near-linear convergence speedup, outperforming state-of-the-art
single-machine method by 14.5% in accuracy and 10.17x in training throughput. | Hongkuan Zhou, Da Zheng, Xiang Song, George Karypis, Viktor Prasanna | 2023-07-14T22:52:27Z | http://arxiv.org/abs/2307.07649v1 | # DistTGL: Distributed Memory-Based Temporal Graph Neural Network Training
###### Abstract.
Memory-based Temporal Graph Neural Networks are powerful tools in dynamic graph representation learning and have demonstrated superior performance in many real-world applications. However, their node memory favors smaller batch sizes to capture more dependencies in graph events and needs to be maintained synchronously across all trainers. As a result, existing frameworks suffer from accuracy loss when scaling to multiple GPUs. Even worse, the tremendous overhead to synchronize the node memory make it impractical to be deployed to distributed GPU clusters. In this work, we propose DistTGL -- an efficient and scalable solution to train memory-based TGNNs on distributed GPU clusters. DistTGL has three improvements over existing solutions: an enhanced TGNN model, a novel training algorithm, and an optimized system. In experiments, DistTGL achieves near-linear convergence speedup, outperforming state-of-the-art single-machine method by 14.5% in accuracy and 10.17\(\times\) in training throughput.
2018 acmcopycopyright(c)2018-1-4509-XXXX-X/18/06... $15.00
2018
[MISSING_PAGE_POST]
requires a single GNN layer with some recent neighbors as supporting nodes. In the benchmark in TGL (Tang et al., 2018), M-TGNNs fill out the top ranks both in accuracy and training time.
Despite the success of M-TGNNs, it is hard to deploy them to large-scale production applications due to their poor scalability. The auxiliary node memory creates temporal dependencies and requires the training mini-batches to be small and scheduled in chronological order. Specifically, there are two major challenges to exploiting data parallelism in M-TGNN training. First, simply increasing the batch size reduces the number of graph events captured in the dynamic node embeddings and leads to information loss (please refer to Section 2.1.1 for more details). Figure 2(a) shows that the accuracy decreases as the batch size increases on the GDELT dataset. On smaller datasets, this decrease in accuracy is usually observed for much smaller batch sizes around \(10^{3}\)-\(10^{4}\)(Krizhevsky et al., 2014), where multiple-GPU data parallelism would not provide any throughput improvement over a single GPU. Second, all the trainers need to access and maintain a unified version of node memory, making it hard to be deployed to distributed systems. Unlike static GNN training, these memory operations to the node memory (typically hundreds of megabytes per mini-batch) have strict temporal dependencies. Due to these excess remote memory operations, distributed systems achieve worse performance than single machines. Figure 2(b) shows the case when the node memory is distributed to all machines where each machine owns a unique equally-sized portion. Furthermore, the remedy to cross-machine traffics in static GNN training (Goyal et al., 2017; Goyal et al., 2017; Goyal et al., 2017) -- graph partitioning technique METIS (Goyal et al., 2017), is not applicable to dynamic graphs. As a result, on both small- and large-scale datasets, the training time of the state-of-the-art M-TGNN framework (Tang et al., 2018) using 8 GPUs on a single node is \(10-100\times\) slower than state-of-the-art distributed static GNNs (Goyal et al., 2017; Goyal et al., 2017), with an unsatisfactory 2-3x speedup over a single GPU.
In this work, we propose DistTGL -- an efficient and scalable solution to train M-TGNNs on distributed GPU clusters. DistTGL improves the existing M-TGNN training solutions from three perspectives:
* **Model**: We enhance the node memory in M-TGNNs by adding additional static node memory, which improves both the accuracy and convergence rate.
* **Algorithm**: We design a novel training algorithm to overcome the challenges of accuracy loss and communication overhead in distributed scenarios.
* **System**: We build an optimized system adopting prefetching and pipelining techniques to minimize the mini-batch generation overhead.
Compared with existing methods, DistTGL has significant improvement in convergence and training throughput. To the best of our knowledge, DistTGL is the first work that scales M-TGNN training to distributed GPU clusters. DistTGL is publicly available at Github1. Our main contributions are
Footnote 1: [https://github.com/amazon-science/disttgl](https://github.com/amazon-science/disttgl)
* Based on the unique characteristics of M-TGNN training, we propose two novel parallel training strategies -- epoch parallelism and memory parallelism, which allow M-TGNNs to capture the same number of dependent graph events on multiple GPUs as on a single GPU.
* We provide heuristic guidelines to determine the optimal training configurations based on the dataset and hardware characteristics.
* To overlap mini-batch generation and GPU training, we serialize the memory operations on the node memory and efficiently execute them by an independent daemon process, avoiding complex and expensive synchronizations.
* In experiments, DistTGL achieves near-linear speedup when scaling to multiple GPUs in convergence rate, outperforming state-of-the-art single machine method (Tang et al., 2018) by more than 10\(\times\) (see Figure 1).
## 2. Background
Given a dynamic graph, TGNNs aim at embedding the contextual, structural, and temporal information of a given node at a given timestamp into a low-dimensional vector. M-TGNNs rely on the node memory and temporal graph attention to generate these vectors. We first explain the basic propagation rules in M-TGNNs. For the rest of this paper, unless stated otherwise, we denote scalar as lower case letter \(x\), vector as bold lower case letter \(x\), and matrix as bold upper case letter \(X\). We denote row-wise concatenation of vectors (or matrices) using double vertical bar within curly brackets \(\{x||y\}\).
### Memory-Based Temporal Graph Neural Networks
M-TGNNs (Goyal et al., 2017; Goyal et al., 2017; Goyal et al., 2017; Goyal et al., 2017) maintain dynamic node-level vectors to track the node history. TGN (Krizhevsky et al., 2014) proposes a general framework for different M-TGNN variants and supports different types of graph events. Here, we introduce TGN on the most common dynamic graphs with graph events of edges appearing. For a dynamic graph \(\mathcal{G}(\mathcal{V},\mathcal{E})\), its graph events could be represented by a time-ordered series \(\{(u,v,\mathbf{e}_{uv},t)\}\) where each quadruple represents an edge with edge feature \(\mathbf{e}_{uv}\) occurring between node \(u\) and node \(v\) at time \(t\). For each node \(v\in\mathcal{V}\), we maintain a node memory vector \(\mathbf{s}_{v}\), which is initialized to be a zero vector. When an edge \(\mathbf{e}_{uv}\) connecting node \(u\) and node \(v\) appears at timestamp \(t\), two mains are generated at node \(u\) and node \(v\)
\[\mathbf{m}_{u}=\left\{\mathbf{s}_{u}||\mathbf{s}_{v}||\Phi(t-t_{u}^{-})||\mathbf{e }_{uv}\right\} \tag{2}\] \[\mathbf{m}_{v}=\left\{\mathbf{s}_{u}||\mathbf{s}_{u}||\Phi(t-t_{v}^{-})||\mathbf{ e}_{uv}\right\}, \tag{1}\]
Figure 2. (a) Test accuracy of the GDELT dataset under different batch sizes. (b) Time per epoch spend in reading and writing of the node memory on different numbers of machines.
where \(\Phi(\cdot)\) is the time encoding (Kang et al., 2017), \(t_{u}^{-}\) is the timestamp when \(\mathbf{s_{u}}\) is last updated, and \(\mathbf{e_{uo}}\) is the edge feature. Then, we use an update function UPDT to update the node memory of node \(u\) and node \(v\),
\[\mathbf{s_{u}}=\text{UPDT}\left(\mathbf{s_{u}},\mathbf{m_{u}}\right)\qquad\mathbf{s_{v}}= \text{UPDT}\left(\mathbf{s_{v}},\mathbf{m_{v}}\right) \tag{3}\]
The update function can be implemented using any sequence model. In TGN-attn (Kang et al., 2017), UPDT(\(\cdot\)) is implemented as GRU cells. Since the UPDT function is only called when a related graph event occurs, the lengths of the hidden status of different nodes in the graph are different. In backward propagation, the learnable parameters \(\mathbf{W}\) and \(\mathbf{b}\) are trained within each GRU cell (the gradients do not flow back to previous GRU cells, like in the Back-Propagation-Through-Time algorithm).
After updating the node memory, a one-layer temporal attention layer (Kang et al., 2017) gathers and aggregates information from the node memory of the most recent neighbors \(\mathbf{S_{w}},w\in\mathcal{N}_{o}\) to compute the dynamic node embedding \(\mathbf{h_{o}}\) for node \(v\). If dynamic or static node features are available, they can be combined with the node memory.
\[\mathbf{q} =\mathbf{W_{q}}(\mathbf{s_{u}}||\Phi(0))+\mathbf{b_{s}} \tag{5}\] \[\mathbf{K} =\mathbf{W_{k}}(\mathbf{S_{w}}||\mathbf{E_{w}}||\Phi(\Delta t))+\mathbf{b_{k}}\] (6) \[\mathbf{V} =\mathbf{W_{v}}(\mathbf{S_{w}}||\mathbf{E_{w}}||\Phi(\Delta t))+\mathbf{b_{v}}\] (7) \[\mathbf{h_{o}} =\text{Softmax}\left(\frac{\mathbf{q}\mathbf{K}^{\text{T}}}{\sqrt{|\mathbf{N _{o}}|}}\right)\mathbf{V}, \tag{4}\]
where \(\Delta t\) is the time differences of the current timestamp with the last updated time of the node memory of \(\mathbf{w}\in\mathcal{N}_{o}\), and \(\mathbf{E_{w}}\) is the matrix of edge features connecting nodes \(v\) and \(w\in\mathcal{N}_{o}\).
Most TGNNs are self-supervised using the temporal edges as ground truth information, where the updates to node memory are delayed by one iteration due to the information leak problem (Kang et al., 2017). Specifically, the mails are cached for the supporting nodes, and the output embeddings are computed using Equation 4-7 before their node memory is updated using Equation 3. This reversed computation order needs to be implemented both in training and at inference to avoid the information leak problem.
#### 2.1.1. Batched M-TGNN Training
Since the training of M-TGNNs needs to be synchronized with the node memory, the training samples need to be scheduled chronologically. Theoretically, the node memory of a node needs to be immediately updated after a relevant graph event occurs on that node so that later dependent nodes can use this up-to-date node memory in the message passing process. Without changing the algorithm, we can process consecutive graph events that do not have overlapping nodes in batches by updating their node memory in parallel. However, this limits the batch size to no more than a few graph events on most dynamic graphs. In practice, the tiny batch size is computationally infeasible on modern hardware intended for highly paralleled programs. To solve this problem, M-TGNNs process the incoming graph events in larger fixed-size batches and update the node memory for the nodes that have new mails once per batch to reduce the computation time. Let \(\{\mathbf{m_{u}}\}\) be the set of mails generated at node \(u\) in a batch of graph events, \(\mathbf{s_{u}}\) is then updated using a COMB(\(\cdot\)) function
\[\mathbf{s_{u}}=\text{UPDT}(\mathbf{s_{u}},\text{COMB}(\{\mathbf{m_{u}}\})). \tag{8}\]
Note that the mails \(\{\mathbf{m_{u}}\}\) is not using the up-to-date node memory (since it is not computed yet) but using the outdated node memory at the last batch of graph events. In TGN-attn, the COMB(\(\cdot\)) function simply outputs the most recent mail. This batching approach both updates the node memory in batch and computes the attention-based message passing in batch. The batched update to node memory causes two types of inaccuracy in the node memory -- staleness and information loss (Figure 3). The staleness in the node memory refers to the problem where the node memory is not up-to-date due to the reversed computation order to avoid the information leak problem. The information loss in the node memory refers to the node memory not being updated by the mails that are filtered out by the COMB(\(\cdot\)) function as well as the inaccuracy of the mails due to using outdated node memory. When the batch size is increased, both the staleness and information loss in the node memory increase, resulting in lower accuracy (Kang et al., 2017). Besides these two types of inaccuracy, another common inaccuracy in sequence models is the inaccuracy due to not re-computing the hidden embeddings when the weights are updated, which generally does not affect the performance.
### Related Works
Dynamic graph representation learning plays an important role in many real-world problems. Many discrete TGNNs (Kang et al., 2017; Goyal et al., 2017; Krizhevsky et al., 2014; Krizhevsky et al., 2014), continuous TGNNs (Krizhevsky et al., 2014; Krizhevsky et al., 2014; Krizhevsky et al., 2014), and non-GNN methods (Krizhevsky et al., 2014; Krizhevsky et al., 2014) are proposed to learn node embeddings on dynamic graphs. There are many existing works that accelerate the message passing scheme in GNNs on a single node (Goyal et al., 2017; Krizhevsky et al., 2014) and on distributed GPU clusters (Goyal et al., 2017; Krizhevsky et al., 2014; Krizhevsky et al., 2014; Krizhevsky et al., 2014). In discrete TGNNs, the propagation within a graph snapshot is the same as static GNNs where these existing methods can be directly applied to. There are also some existing works that specialize in discrete TGNNs on a single GPU (Krizhevsky et al., 2014; Krizhevsky et al., 2014) and distributed systems (Goyal et al., 2017). However, these methods do not apply to continuous M-TGNNs due to the unique propagation rule of M-TGNNs. Accelerating continuous M-TGNNs is challenging due to the aforementioned antithesis between training speed and accuracy. Distributed M-TGNN training is even more challenging due to the high volume of data synchronization. There are a few works that accelerate M-TGNNs training. TGL (Krizhevsky et al., 2014) proposes a general framework for single-node multiple-GPU continuous TGNNs. However, TGL does not support distributed GPU clusters. The speedup of TGL on multiple GPUs in a single machine is also unsatisfactory, only achieving \(2-3\times\) speedup on 8 GPUs. EDGE (Chen et al., 2017) proposes to speedup the training by replacing the dynamic node memory of active nodes with static learnable node memory, gambling on the chance that active nodes have stable embeddings. To the best of our knowledge, there is no existing work for M-TGNN training that achieves near-linear scalability on
Figure 3. Overview of the inaccuracy in node memory caused by batched training.
single-node multiple-GPU, or operates on distributed GPU clusters. For the inference task, TGOpt (Wang et al., 2017) proposes to accelerate TGNN inference by de-duplication, memorization, and pre-computation. Another work (Wang et al., 2017) proposes a system-architecture co-design that accelerates M-TGNN inference on FPGAs. Unfortunately, these techniques do not apply to M-TGNN training.
## 3. DistTGL
We propose DistTGL -- an efficient and scalable solution to train M-TGNNs on distributed GPU clusters. DistTGL achieves scalability through improvements from three perspectives: model, algorithm, and system. From the model perspective, we introduce the static node memory that explicitly separates the time irrelevant node information. From the algorithm perspective, we propose two novel parallel training strategies and a method to determine the best combination of these strategies on any given dataset and hardware configuration. From the system perspective, we design an efficient system to reduce and overlap mini-batch generation overhead with GPU training. We introduce these improvements in the three following subsections.
### M-TGNN Model with Static Node Memory
M-TGNNs rely on node memory to summarize the node history. Previous work (Chen et al., 2017) argues that the node memory of nodes with active interactions is static. While this may be true on some evolving graphs like citation graphs, it fails on the dynamic graphs where high-frequency information is important, such as in fraud detection (Liu et al., 2018). Figure 5 shows the comparison of the accuracy in the temporal link prediction task that predicts destination nodes from source nodes using static and dynamic node memory. We do not observe any noticeable inclination on higher degree nodes favors static node memory or vice versa. We also observe similar results on the other datasets used in this work.
We believe that a general TGNN model should be able to capture both the dynamic and static node information of all nodes. In DistTGL, we separate the static and dynamic node memory and capture them explicitly. DistTGL keeps the original GRU node memory on all nodes to capture the dynamic node information and implements an additional mechanism to capture the static node information. There are two major benefits brought by this additional static node history. First, it enhances the capability of M-TGNNs to capture node history with burst interactions. Due to the batching of updating the node memory, if a node interacts with others many times in a short time period, it is inevitable that the COMB(\(\cdot\)) function used in the dynamic node memory would filter out most of these interactions, resulting in a loss of high-frequency information. The static node memory, combined with the time encoding (Zhou et al., 2017) in
Figure 4. Overview of DistTGL training with \(2\times 2\times 2\) (mini-batch\(\times\)epoch\(\times\)memory) parallelism on two four-GPU machines. For simplicity and easier understanding, we draw the reads and writes to the node memory at the beginning and end of each training iteration. In our optimized system, they have performed asynchronously with the training iterations and are fully overlapped with the GPU computation. Please refer to Figure 7 for more details on the three parallel training strategies.
Figure 5. Accuracy differences of each node with static and dynamic node memory on the Wikipedia dataset, sorted by node degrees. Positive bars (in dynamic\(>\)static region) indicate that dynamic node memory has better accuracy than static node memory for those nodes, and vice versa.
Figure 6. Validation accuracy on the Flights and MOOC datasets with and without pre-trained static node memory.
the temporal attention aggregator, could boost the performance in such cases. Second, the static node memory explicitly separates the information irrelevant to batch sizes, which improves the performance of data parallelized training. Since the static node memory is irrelevant with time, all graph events can be used to supervise the training process, allowing it to capture all static information regardless of batching. In this work, since most dynamic graphs do not have node features, we use learnable node embeddings pre-trained with the same task as the static node memory due to its simplicity. The pre-training of these embeddings can be easily done in any well-optimized distributed static GNN frameworks (Beng et al., 2015; Wang et al., 2016; Wang et al., 2017; Wang et al., 2018; Wang et al., 2019). Note that the static node memory is similar to learnable weights in the M-TGNN models and does not include any information in the test set. On the other hand, the dynamic node memory contains information in the test set and would cause information leaks if not handled properly. DistTGL also supports other kinds of learnable or non-learnable static node memory, such as co-trained embedding tables or even node embeddings generated by static GNNs.
Figure 6 shows the two datasets which have the most significant improvement with pre-trained static node memory. On a single GPU, our improved model achieves remarkably better accuracy on both datasets and a smoother convergence curve on the Flights dataset (we do not show the curves for multi-GPU for a clearer visualization). On the MOOC dataset, our model with static node memory also improves the scalability in convergence on multiple-GPU using epoch parallelism (which will be introduced later in Section 3.2).
### Parallel Training Algorithm
A straightforward approach to train M-TGNNs in parallel is to process the graph events in large global batches and distribute them to multiple trainers, which is used by TGL (Wang et al., 2016) in the setting of multiple GPUs on a single node. We refer to this approach as the mini-batch parallelism, which relaxes the inter-batch dependencies in node memory. However, the key to achieving good accuracy in multi-GPU M-TGNN training is to maintain the temporal dependency when the graph events are processed in large batches. To solve this problem, we propose two novel parallel training strategies - epoch parallelism and memory parallelism. Epoch parallelism relaxes the dependencies in the node memory due to weight updates and trains different epochs simultaneously on different trainers. Memory parallelism trades space for accuracy by maintaining multiple copies of the node memory at different timestamps. In the rest of this section, we first introduce the three types of parallelism and their advantages and disadvantages. Then, we discuss how to design an optimal training algorithm given any task specifications and hardware configurations.
#### 3.2.1. Mini-Batch Parallelism
Mini-batch parallelism simply trains a large global batch on multiple trainers in parallel. On \(n\) GPUs, a global batch of graph events is evenly divided into \(n\) local batches where each GPU is responsible for computing the output embeddings of one local batch. Figure 7(a) shows the case when a global batch is divided into three local batches on three trainers. Since the global mini-batches are generated in chronological order, we also split them into local mini-batches chronologically and ignore the intra-dependency within each global mini-batch. Specifically, these \(n\) trainers first fetch the node memory and cached mails of the assigned root nodes and their supporting nodes. Then, they compute the forward and backward propagation and update the model weights. Before they use the computed node memory to update the node memory and cached mails, they need to make sure all trainers have finished the fetch operations to avoid WriteAfter-Read (WAR) hazard. Note that ideally, the node memory and cached mails should be updated for both the root and supporting nodes so that we do not need to re-compute Equation 3 when these supporting nodes are referenced again in later batches. However, to ensure the model weights can receive enough feedback in the backward propagation, we do not update the node memory and cached mails of the supporting nodes and re-compute them when they are referenced later. Because the fetch and update of the node memory are done simultaneously in all trainers, the node embeddings generated for later graph events in the global batch cannot perceive the earlier graph events, incurring both staleness and information loss in the node memory. In addition, mini-batch parallelism requires all trainers to maintain the same copy of node memory, which leads to enormous communication overhead on distributed systems.
#### 3.2.2. Epoch Parallelism
Epoch parallelism leverages data parallelism by training different epochs simultaneously using only one copy of the node memory. In the vanilla M-TGNN training, self-supervised by temporal edges on a single GPU, we first sample some negative destination nodes for the root nodes in mini-batch \(i\). We then collect the supporting nodes for all positive and negative root nodes and fetch their node memory and cached mails. In the later epochs, for the same root nodes in mini-batch \(i\), we sample different sets of negative destination nodes and follow the same procedure to get their node memory and cached mails. To train on the same mini-batches in different epochs in parallel on \(n\) trainers,
Figure 7. Overview of mini-batch parallelism, epoch parallelism, and memory parallelism on three trainer processes. The “R” and “W” denote read and write operations to the shared node memory. In epoch parallelism, the arrows denote cross-process communication to send mini-batch data. In memory parallelism, the arrows denote cross-process communication to send the updated node memory.
we ignore the difference in node memory due to weight updates in the last \(n-1\) epochs. Thus, we can prepare one set of inputs of the positive nodes and \(n\) sets of inputs of the negative nodes and train them in parallel. Note that these mini-batches need to be scheduled in different iterations so that the gradients of positive nodes are not simply multiplied by \(n\). This scheduling increases the variance of the gradients of the sampled mini-batches, as the same set of positive nodes is learned for \(n\) consecutive iterations. The left part of Figure 7(b) shows the case when applying epoch parallelism to three trainers. In each iteration, trainer P0 fetches the node memory and cached mails for one positive mini-batch and three negative mini-batches. After P0 finishes one iteration, it writes to the node memory and sends the prepared mini-batches (one positive mini-batch and the two unused negative mini-batches) to P1. P1 receives the mini-batches from P0 and sends them (one positive mini-batch and the unused one negative mini-batch) to P2 after the computation. Note that only P0 needs to write back the updated node memory to the global copy of node memory in the main memory. Although the node memory of this mini-batch in P1 and P2 is updated using a more recent version of the weights, writing them to the global copy would lead to Read-After-Write (RAW) hazards with later training iterations. We also tried a finer-grained updating policy which updates nodes that do not have this RAW hazard in P1 and P2. However, it does not outperform the original policy. To reduce the cross-trainer communication, we further optimize the algorithm by reordering the mini-batches so that each trainer works on the same positive samples (with different negative samples) for \(n\) consecutive iterations (see the right part in Figure 7(b)). However, epoch parallelism still requires all trainers to access the same node memory, which is impractical on distributed systems.
#### 3.2.3. Memory Parallelism
Memory parallelism trades space for time by training different time segments of the dynamic graph simultaneously using separate copies of node memory. The left part in Figure 7(c) shows the case when applying memory parallelism on a dynamic graph with 6 mini-batches with three trainers and three copies of node memory. Each trainer is only responsible for one-third of the whole dynamic graph, i.e., a time segment of two consecutive mini-batches. In every iteration, each trainer needs to fetch its own node memory and cached mails. The design on the left requires the intermediate node memory to be transferred across the processes after the trainers finish their time segments. For example, P0 needs to send the node memory of all the nodes in the graph to P1 after iteration 1, which is expensive in distributed systems. To solve this problem, we reorder the mini-batches across the trainer (see the right part in Figure 7(c)) so that each trainer trains sequentially on all the segments using its own node memory. Since each trainer owns its individual node memory, there is no synchronization of the node memory across the trainers, making it the only suitable strategy for distributed systems.
#### 3.2.4. Optimal Training Algorithm
The aforementioned three parallelization strategies all have their own unique characteristics. We summarize their advantages and disadvantages in Table 1. To achieve optimal training performance, we provide heuristic guidelines for DistTGL users to combine these strategies to pick their advantages and offset their disadvantages. Consider a distributed system with \(p\) machines and \(q\) GPUs per machine. Let \(i\times j\times k=p\times q\) be a training configuration where \(i\) represents how many GPUs to compute each mini-batch, \(k\) represents how many copies of node memory to maintain, and \(j\) represents how many epochs to train in parallel for each copy of node memory. We determine the optimal choice of \((i,j,k)\) from task requirements and hardware configurations. There are two constraints from the hardware side. First, we need to have \(k\geq p\) as memory parallelism is the only strategy that does not synchronize node memory across the trainers. Then, the main memory of each machine should be able to hold \(k/p\) copies of node memory and cached mails, or at least hold sufficient cache if using the disk-based memory caching storage option.
Under these constraints, we first determine \(i\) according to the largest batch size. Figure 8 shows that when the batch size increases, fewer graph events would be captured in the node memory, especially for high-degree nodes. DistTGL users can set a threshold for the amount of missing information so that DistTGL would reversely find out the largest batch size. For applications where high-frequency information is crucial, we can set a stricter threshold for high-degree nodes. Based on this batch size, \(i\) can be determined according to the GPU specifications. For \(j\) and \(k\), we always prefer to apply memory parallelism since it leads to better convergence, which we have also verified from experiments (see Figure 9(b)).
\begin{table}
\begin{tabular}{c||c|c|c} & Mini-batch & Epoch & Memory \\ & Parallelism & Parallelism & Parallelism \\ \hline \hline Captured & less than & **same as** & **same as** \\ dependency & single-GPU & **single-GPU** & **single-GPU** \\ \hline Training & **same as** & \(n\) times & **same as** \\ overhead & **single-GPU** & single-GPU & **single-GPU** \\ \hline Main memory & **same as** & **same as** & \(n\) times \\ requirement & **single-GPU** & **single-GPU** & single-GPU \\ \hline Synchronization & weights and & weights and & **weights** \\ across trainers & node memory & node memory & **only** \\ \hline Gradient descent & **same as** & more than & **same as** \\ variance & **single-GPU** & single-GPU & **single-GPU** \\ \end{tabular}
\end{table}
Table 1. Summary of the three parallel training strategies on \(n\) trainers. The comparison with single-GPU training is made based on the same local batch size. The “Training overhead” row refers to the overheads in mini-batch generation at the beginning of each training iteration. The advantages are marked in bold.
Figure 8. Number of captured events in the node memory with different batch sizes, sorted by node degree from high to low on the Wikipedia dataset.
summary, we first determine \(i\) based on task requirements, then \(k\) based on hardware specification, and lastly \(j\) is fixed by \(p\times q/i\times k\).
For example, on a distributed system with 4 machines and 8 GPUs each machine, we determine the largest batch size is 3200 edges. The GPU saturates when batch size is larger than 1600 edges. So we first set local batch size to be 1600 edges and \(i=2\). The main memory of each machine can hold two copies of the node memory. Then we set \(k=32/2/2=8\). Finally, \(j\) is fixed to be \(32/2/8=2\).
### Distributed Training System
Designing a scalable distributed training system for M-TGNNs is not trivial. Even for the most straightforward mini-batch parallelism, previous work (Srivastava et al., 2017) only achieves 2-3\(\times\) speedup using 8 GPUs on a single node due to excessive overheads in mini-batch generation. We solve this issue by prefetching the mini-batches in a separate process and pipelining the sub-tasks (loading from disk, slicing features, slicing node memory, writing back to node memory) within one mini-batch generation. Figure 4 shows an overview of DistTGL serializing the memory operations and executing them asynchronously on separate processes. Here we focus on describing the most important design that handles the reads and writes to the node memory. As memory parallelism works on separate copies of node memory which has no dependency and can be easily parallelized, we consider the case for each \(i\times j\) trainer group that shares the same copy of the node memory. Since \(k\geq p\), each trainer group must have all the processes on the same physical machine. Within each \(i\times j\) group, the memory operations can be serialized as a spin lock acting on each \(i\) sub-group. For example, for \(i\times j=2\times 2\), we have the memory access sequence
\[(\text{R}_{0}\text{R}_{1})(\text{W}_{0}\text{W}_{1})(\text{R}_{2}\text{R}_{ 3})(\text{W}_{2}\text{W}_{3})(\text{R}_{0}\text{R}_{1})(\text{W}_{0}\text{W}_ {1})\cdots,\]
where \(\text{R}_{i}\) and \(\text{W}_{i}\) denote read and write requests from trainer \(i\), and there is no ordering for the requests within each bracket.
In DistTGL, instead of implementing an expensive cross-process lock mechanism, we launch an additional memory daemon process for each group of \(i\times j\) trainer processes to handle the read and write requests for all the trainers in that group. Let \(bs\) be the local batch size, \(d\) be the number of sampled supporting nodes for each root node, and \(d_{\text{mem}}\) be the dimension of the node memory. The memory process allocates the following buffers, which are shared with the trainers:
* mem_read_buf of size \([i\times j,j,bs\times d,d_{\text{mem}}]\) that holds the results of the memory read requests.
* mail_read_buf of size \([i\times j,j,bs\times d,2d_{\text{mem}}]\) that holds the results of the mail read requests.
* read_lidx_buf of size \([i\times j,j,bs\times d+1]\) that holds the indexes of the read requests and its length.
* mem_write_buf of size \([i\times j,bs,d_{\text{mem}}]\) that holds the input of the memory write request.
* mail_write_buf of size \([i\times j,bs,2d_{\text{mem}}]\) that holds the input of the mail write request.
* write_lidx_buf of size \([i\times j,bs+1]\) that holds the indexes of the read requests and its length.
* read_status of size \([i\times j]\) that indicates the status of the read request.
* write_status of size \([i\times j]\) that indicates the status of the write request.
Algorithm 1 shows the pseudo-code of the memory daemon process. Each trainer process issues the read and write requests by copying the inputs to the shared buffers and setting the elements of its rank in read_status and write_status to be 1. The memory daemon process executes these requests in serialized order, puts the read results to the buffers, and resets the status. Note that the first read request of each epoch is not issued, as the results are always all zero matrices right after the initialization.
```
Input:read_lidx_buf,mem_write_buf,mail_write_buf,write_lidx_buf Modify:read_status,write_stats Output:mem_read_buf,mail_read_buf repeat reset memory and mail rank = 0 repeat for\(r\) in \([\text{rank},\text{rank}+j)\)doin parallel wait until write_status\([r]==1\) write to memory from mem_write_buf\([r]\) write to mail from mail_write_buf\([r]\) write_status\([r]=0\) endfor rank += i rank = 0 if rank == \(i\times j\) for\(r\) in \([\text{rank},\text{rank}+j)\)doin parallel wait until read_status\([r]==1\) for\(jj\) in \([0,j)\)doin parallel slice memory to mem_read_buf\([r][jj]\) slice mail to mail_read_buf\([r][jj]\) endfor read_status\([r]=0\) endfor until epoch end until training end
```
**Algorithm 1** Memory Daemon Process
## 4. Experiments
We perform detailed experiments to evaluate the performance of DistTGL. We implement DistTGL using PyTorch (Pasz and Keras, 2018) 1.11.0 and DGL (Pasz and Keras, 2018) 0.8.2. The code and datasets will be open-sourced upon acceptance of this work.
\begin{table}
\begin{tabular}{c|c c c c c} & \(|V|\) & \(|E|\) & \(\max(t)\) & \(|d_{0}|\) & \(|d_{e}|\) \\ \hline Wikipedia & 9,227 & 157,474 & 2.7e6 & 100\({}^{*}\) & 172 \\ Reddit & 10,984 & 672,447 & 2.7e6 & 100\({}^{*}\) & 172 \\ MOOC & 7,144 & 411,749 & 2.6e7 & 100\({}^{*}\) & - \\ Flights & 13,169 & 1,927,145 & 1.0e7 & 100\({}^{*}\) & - \\ GDELT & 16,682 & 191,290,882 & 1.6e8 & 413 & 130 \\ \end{tabular}
\end{table}
Table 2. Dataset Statistic. The \(\max(t)\) column shows the maximum edge timestamp (minimum edge timestamp is 0 in all datasets). \(|d_{0}|\) and \(|d_{e}|\) show the dimensions of node features and edge features, respectively. The \({}^{*}\) mark denotes pre-trained features.
**Datasets.** Table 2 shows the statistics of the five datasets for the evaluation. The task on each dataset is
* **Wikipedia**(Hu et al., 2017) is a bipartite user-internet page graph where one graph event represents one user modifies the one Wikipedia page. The edge features are extracted from the text that the users update the pages with. The task on this dataset is temporal link prediction.
* **Reddit**(Hu et al., 2017) is a bipartite user-reddit graph where one graph event represents one user posts to one sub-reddit. The edge features are extracted from the text of the post. The task on this dataset is temporal link prediction.
* **MOOC**(Hu et al., 2017) is a bipartite user-course action graph where one graph event represents one user interacting with one class item (i.e., watching a video, answering a question). The task on this dataset is temporal link prediction.
* **Flights**(Hu et al., 2017) is a traffic graph where each node represents one airport, and each edge represents one flight between the two airports. The task on this dataset is temporal link prediction.
* **GDELT**(Wang et al., 2018) is a knowledge graph tracking events happening all over the world where each node represents one actor, and each edge represents one event. Since the temporal link prediction task used in TGL (Wang et al., 2018) is too simple, we use the 130-dimensional CAMEO code as edge features and set the task to be a 56-class 6-label dynamic edge classification problem that predicts the rest of the 56-dimensional edge features.
For the temporal link prediction task, to reduce the variance in the validation and test accuracy, we randomly sample 49 negative destination nodes (for bipartite graphs, we only sample from the other graph partition) and report the Mean Reciprocal Rank (MRR) of the true destination nodes. For the dynamic edge classification task, we report the F1-Micro score.
#### 4.0.1. Model
We use the most efficient one-layer TGN-attn (Han et al., 2017) model enhanced with the static node memory introduced in Section 3.1. We follow the original work to set the dimension of node memory to 100 and the number of most recent neighbors to 10 for each node. We pre-train the static node history with the same GNN architecture but only with static information using DGL (Hu et al., 2017). On the Wikipedia, Reddit, MOOC, and Flights datasets, we pre-train 10 epochs with stochastically selected mini-batches. On the GDELT dataset, we only pre-train 1 epoch. The pre-training of all datasets takes less than 30 seconds on a single machine. For the Wikipedia, Reddit, MOOC, and Flights datasets, we set the local batch size to be the largest available batch size 600 (Wang et al., 2018). For the GDELT dataset, the local batch size is set to 3200, limited by the GPU capacity. We set the learning rate to be linear with the global batch size. To ensure fairness, we keep the total number of traversed edges to be the same in multi-GPU training. The number of training iterations for \(x\) GPUs will be \(1/x\) compared to a single GPU. On the Wikipedia, Reddit, MOOC, and Flights datasets, we traverse the training events 100 times (100 epochs on a single GPU). On the larger GDELT dataset, we traverse the training events 10 times (10 epochs on a single GPU). On the Wikipedia, Reddit, MOOC, and Flights datasets, we perform evaluation after every training epoch using the node memory in the first memory process. On the GDELT dataset, due to the slow evaluation process (as DistTGL only accelerates training), we perform validation and testing every 2000 training iterations on a randomly selected chunk of 1000 consecutive mini-batches in the validation and the test set, starting with all-zero node memory and mains.
#### 4.0.2. Hardware
All experiments are performed on AWS EC2 cloud using g4dn.metal instances with dual Intel Platinum 8259CL CPU paired with 384GB EC-DDR4 memory, 8 Nvidia T4 GPUs with 16GB GDDR6 memory for each GPU, two 900GB NVMe SSDs,
Figure 9. (a) Convergence curve of DistTGL with different epoch parallelism \(j\) using 1-8 GPUs on one node. (b) Convergence curve of DistTGL with combination of different epoch and memory parallelism \(j\times k\) using 8 GPUs on one node. The test MRR is shown between parentheses in the legend. Compared with the single-GPU baseline, DistTGL with memory parallelism \(1\times 1\times 8\) achieves near-linear converge speedup with negligible accuracy loss on 8 GPUs.
and 100Gbps Ethernet connection. We create the instances in the same group of rack to make sure the cross-machine latency is minimized. Due to the lack of CPU cores, we sample the mini-batch in advance and store them on the two NVMe SSDs in RAID0 mode to maximize the throughput, which could also be generated on the fly during training if the CPU power is enough. Note that the positive edges in the mini-batches are reused in every epoch. For the negative edges, we observe that in the temporal link prediction task, a small number of groups of negative edges are enough. So we prepare 10 groups of negative edges and randomly use them in the total 100 epochs. We assign 6 CPU threads for each trainer and memory process so that the total 96 physical threads can serve the needs for maximum memory parallelism of \(k=8\) on a single machine. To further overlap the mini-batch generation with the GPU computation, we pre-fetch the pre-sampled static information from disks \(j\) iterations in advance. We directly pre-fetch the static information to GPU using a separate CUDA stream than the training CUDA stream. Note that the dynamic node memory still needs to be obtained following the serialized order in the memory process. For all methods, the node memory and cached mails are stored in the main memory and transferred between CPU and GPU in every training iteration.
### Convergence
We first evaluate the convergence of DistTGL by comparing the validation accuracy after different numbers of training iterations and the testing accuracy for the final model.
We start with the performance of epoch parallelism on the Wikipedia, Reddit, Flights, and MOOC datasets, as the largest batch sizes on these datasets do not allow mini-batch parallelism. Figure 9(a) shows the convergence curves of applying 1 (as the baseline), 2, 4, and 8 epoch parallelism. When \(j=2\), we observe more than 2x speedup for the number of training iterations before reaching 70%, 80%, and 90% of the best validation accuracy on all four datasets, especially on the Flights datasets where the final test accuracy is even higher than the baseline. We believe that the super-linear scalability is due to the larger global negative batch size, where we observe similar convergence speed improvement when we increase the number of negative samples during training for the baseline. Unfortunately, increasing the number of negative samples cannot be used to speedup the convergence as the computation complexity is linear with the number of root nodes. When \(j=4\), epoch parallelism still manages to achieve linear speedup except on the Flights dataset with the most number of unique edges (Kumar et al., 2017). When \(j=8\), epoch parallelism leads to significant test accuracy drop and non-linear speedup. The sub-linear scalability for epoch parallelism when \(j\) is large is expected as it trains on the same positive nodes consecutively in multiple iterations, leading to increased variance in the mini-batch gradients.
Then, on the same four datasets, we fix \(j\times k=8\) and evaluate the convergence with different memory parallelism. Figure 9(b) shows the convergence curves of different epoch and memory parallelism. Compared with epoch parallelism (\(1\times 8\times 1\)), memory parallelism achieves both better validation accuracy and notably better test accuracy due to better gradient estimation in each mini-batch. In general, the larger the memory parallelism \(k\) is, the better the test MRR. The training configuration with the largest \(k=8\) achieves linear speedup in convergence compared with the single GPU baseline with only an average of 0.004 drop in test MRR. Figure 10 shows the test MRR and the number of training iterations to reach the best validation MRR of different training configurations when \(i=1\) and \(j\times k\leq 32\). The experiment results agree with our strategy for optimal training configuration, where we prioritize memory parallelism over epoch parallelism within the hardware limit.
For the GDELT dataset, we verify that the largest batch size without accuracy loss is larger than the capacity of one machine (see Figure 2(a)), which also agrees with previous work (Zhu et al., 2017). Hence we follow our optimal training configuration choosing policy and prioritize mini-batch parallelism. Figure 11 shows the convergence of DistTGL on the GDELT datasets. The single GPU baseline \(1\times 1\times 1\) converges very slowly. Increasing the learning rate can speedup the convergence to some extent but will also lower the accuracy. By contrast, mini-batch parallelism \(8\times 1\times 1\) enjoys the benefit of larger batch size and achieves super-linear speedup. To further speedup on more trainers, we need to use memory parallelism to solve the massive communication overhead across machines. On multiple machines, the combination of memory parallelism and mini-batch parallelism achieves satisfying convergence speedup with the highest test accuracy.
Figure 11. Convergence of DistTGL on the GDELT datasets. The test F1-Micro is shown between parentheses in the legend.
Figure 10. (a) Test MRR and (b) number of iterations before convergence with different epoch parallelism \(j\) and memory parallelism \(k\) on the Wikipedia dataset.
### Training Throughput
We evaluate the training throughput of DistTGL on up to four 8-GPU machines. We do not test on more machines as the training time on the largest GDELT dataset is already less than 30 minutes on four machines while it only takes a few minutes to train on the smaller datasets. Figure 12(a) shows the training throughput and the speedup compared with the single GPU baseline of the optimal training configuration on 2, 4, and 8 GPUs on a single machine, 16 GPUs on two machines, and 32 GPUs on four machines. On 8/32 GPUs on 1/4 machines, DistTGL achieves close to linear speedup averaging 7.27/25.08\(\times\), respectively. In terms of absolute throughput, the training throughput on the Reddit and Flights datasets is around 10% slower than the other datasets due to the larger amount of writes to the node memory and cached mails. Since DistTGL only applies memory parallelism across machines, the memory operations are evenly distributed to each machine. There is no cross-machine traffic besides the synchronization of model weights, leading to a balanced workloads in each trainer. Due to the small TGNN models with only a few megabytes of weights, DistTGL also achieves near-linear speedup scaling on distributed systems.
We also compare the performance of DistTGL with the vanilla single GPU implementation TGN (Krizhevsky et al., 2014) and its optimized version TGL-TGN (Krizhevsky et al., 2014) that supports single-machine multiple-GPU. Figure 12(b) shows the training throughput per GPU of the two baseline methods and DistTGL in different training configurations on the Wikipedia and GDELT datasets. On the GDELT dataset, TGN does not finish training in 10 hours. DistTGL with the optimal training configurations (memory parallelism on the Wikipedia dataset and a combination of mini-batch and memory parallelism on the GDELT dataset) significantly outperform TGN and TGL. On 2, 4, and 8 GPUs, DistTGL achieves an average of 1.24\(\times\), 1.91\(\times\), and 2.93\(\times\) improvement, respectively, compared with TGL. The 1\(\times\)1\(\times\)1 single GPU implementation of DistTGL is also faster than TGL due to our system optimization that overlaps the read and write operations from and to node memory. On the GDELT dataset, memory parallelism does not scale linearly on 8 GPUs due to the limitation of the bandwidth between CPU and RAM, whereas the scalability is notably better on multiple machines.
## 5. Conclusion
In this work, we propose DistTGL, an M-TGNN training framework for large-scale distributed M-TGNN training. DistTGL addressed the accuracy loss issue and communication overhead challenges by adopting three improvements of an enhanced model, a novel training algorithm, and an optimized system. Compared with state-of-the-art TGNN framework TGL (Krizhevsky et al., 2014), DistTGL not only outperforms TGL both in convergence rate and training throughput on a single machine but also extends M-TGNN training to distributed systems. We will open-source DistTGL and all datasets used in this work upon acceptance of this work.
Figure 12. (a) Training throughput of DistTGL. We show the parallel training strategies with the best accuracy (memory parallelism on the four small datasets and mini-batch parallelism on the two large datasets on each node) for each dataset. The bars with red frame denote the optimal training configuration on different number of GPUs. (b) Training throughput per GPU of DistTGL compared with TGN and TGL-TGN on the Wikipedia and GDELT datasets. |
2306.13515 | Binary domain generalization for sparsifying binary neural networks | Binary neural networks (BNNs) are an attractive solution for developing and
deploying deep neural network (DNN)-based applications in resource constrained
devices. Despite their success, BNNs still suffer from a fixed and limited
compression factor that may be explained by the fact that existing pruning
methods for full-precision DNNs cannot be directly applied to BNNs. In fact,
weight pruning of BNNs leads to performance degradation, which suggests that
the standard binarization domain of BNNs is not well adapted for the task. This
work proposes a novel more general binary domain that extends the standard
binary one that is more robust to pruning techniques, thus guaranteeing
improved compression and avoiding severe performance losses. We demonstrate a
closed-form solution for quantizing the weights of a full-precision network
into the proposed binary domain. Finally, we show the flexibility of our
method, which can be combined with other pruning strategies. Experiments over
CIFAR-10 and CIFAR-100 demonstrate that the novel approach is able to generate
efficient sparse networks with reduced memory usage and run-time latency, while
maintaining performance. | Riccardo Schiavone, Francesco Galati, Maria A. Zuluaga | 2023-06-23T14:32:16Z | http://arxiv.org/abs/2306.13515v1 | # Binary domain generalization for sparsifying binary neural networks+
###### Abstract
Binary neural networks (BNNs) are an attractive solution for developing and deploying deep neural network (DNN)-based applications in resource constrained devices. Despite their success, BNNs still suffer from a fixed and limited compression factor that may be explained by the fact that existing pruning methods for full-precision DNNs cannot be directly applied to BNNs. In fact, weight pruning of BNNs leads to performance degradation, which suggests that the standard binarization domain of BNNs is not well adapted for the task. This work proposes a novel more general binary domain that extends the standard binary one that is more robust to pruning techniques, thus guaranteeing improved compression and avoiding severe performance losses. We demonstrate a closed-form solution for quantizing the weights of a full-precision network into the proposed binary domain. Finally, we show the flexibility of our method, which can be combined with other pruning strategies. Experiments over CIFAR-10 and CIFAR-100 demonstrate that the novel approach is able to generate efficient sparse networks with reduced memory usage and run-time latency, while maintaining performance.
Keywords:Binary neural networks Deep neural networks Pruning Sparse representation.
## 1 Introduction
The increasing number of connected Internet-of-Things (IoT) devices, now surpassing the number of humans connected to the internet [6], has led to a sensors-rich world, capable of addressing real-time applications in multiple domains, where both accuracy and computational time are crucial [1]. Deep neural networks (DNNs) have the potential of enabling a myriad of new IoT applications, thanks to their ability to process large complex heterogeneous data and to extract patterns needed to take autonomous decisions with high reliability [20].
However, DNNs are known for being resource-greedy, in terms of required computational power, memory, and energy consumption [4], whereas most IoT devices are characterized by limited resources. They usually have limited processing power, small storage capabilities, they are not GPU-enabled and they are powered with batteries of limited capacity, which are expected to last over 10 years without being replaced or recharged. These constraints represent an important bottleneck towards the deployment of DNNs in IoT applications [40].
A recent and notable example to enable the usage of DNNs in limited resource devices are binary neural networks (BNNs) [15]. BNNs use binary weights and activation functions that allow them to replace computationally expensive multiplication operations with low-cost bitwise operations during forward propagation. This results in faster inference and better compression rates, while maintaining an acceptable accuracy for complex learning tasks [10, 25]. For instance, BNNs have achieved over 80% classification accuracy on ImageNet [10, 31]. Despite the good results, BNNs have a fixed and limited compression factor compared to full-precision DNNs, which may be insufficient for certain size and power constraints of devices [22].
A way to further improve BNNs' compression capacity is through network pruning, which seeks to control a network's sparsity by removing parameters and shared connections [12]. Pruning BNNs, however, is a more challenging task than pruning full-precision neural networks and it is still a challenge with many open questions [38]. Current attempts [9, 19, 28, 32, 37, 36, 38] often rely on training procedures that require more training stages than standard BNNs, making learning more complex. Moreover, these methods fail in highly pruned scenarios, showing severe accuracy degradation over simple classification problems.
In this work, we introduce sparse binary neural network (SBNN), a more robust pruning strategy to achieve sparsity and improve the performance of BNNs. Our strategy relies on entropy to optimize the network to be largely skewed to one of the two possible weight values, i.e. having a very low entropy. Unlike BNNs that use symmetric values to represent the network's weights, we propose a more general binary domain that allows the weight values to adapt to the asymmetry present in the weights distribution. This enables the network to capture valuable information, achieve better representation, and, thus better generalization. The main contributions of our work can be summarized as follows: 1) We introduce a more general binary domain w.r.t. the one used by BNNs to quantize real-valued weights; 2) we derive a closed-form solution for binary values that minimizes quantization error when real-valued weights are mapped to the proposed domain; 3) we enable the regularization of the BNNs weights distribution by using entropy constraints; 4) we present efficient implementations of the proposed algorithm, which reduce the number of bitwise operations in the network proportionally to the entropy of the weight distribution; and 5) we demonstrate SBNN's competitiveness and flexibility through benchmark evaluations.
The remaining of this work is organized as follows. Section 2 discusses previous related works. The core of our contributions are described in Section 3. In Section 4, we study the properties of the proposed method and assess its perfor
mance, in terms of accuracy and operation reduction at inference, through a set of experiments using, CIFAR-10, CIFAR-100 [18] and ImageNet [31] datasets. Finally, a discussion on the results and main conclusions are drawn in Section 5.
## 2 Related Work
We first provide an overview of BNNs. Next, we review sparsification through pruning [2, 12, 27, 34] and quantization [11, 16, 39, 41], the two network compression strategies this work relies on. A broad review covering further network compression and speed-up techniques can be found in [21].
**Binary Neural Networks.** BNNs [15] have gained attention in recent years due to their computational efficiency and improved compression. Subsequent works have extended [15] to improve its accuracy. For instance, [30] introduced a channel-wise scaling coefficient to decrease the quantization error. ABC-Net adopts multiple binary bases [23], and Bi-Real [26] recommends short residual connection to reduce the information loss and a smoother gradient for the signum function. Recently, ReActNet [25] generalized the traditional sign(\(\cdot\)) and PReLU activation functions to extend binary network capabilities, achieving an accuracy close to full-precision ResNet-18 [13] and MobileNet V1 [14] on ImageNet [31]. By adopting the RSign, the RPReLU along with an attention formulation Guo et al. [10] surpassed the 80% accuracy mark on ImageNet. Although these works have been successful at increasing the performance of BNNs, few of them consider the compression aspect of BNNs.
**Network Sparsification.** The concept of sparsity has been well studied beyond quantized neural networks as it reduces a network's computational and storage requirements and it prevents overfitting. Methods to achieve sparsity either explicitly induce it during learning through regularization (e.g. \(L_{0}\)[27] or \(L_{1}\)[12] regularization), or do it incrementally by gradually augmenting small networks [2]; or by post hoc pruning [8, 33, 34].
BNNs pruning is particularly challenging because weights in the \(\{\pm 1\}\) domain cannot be pruned based only on their magnitude. Existing methods include removing unimportant channels and filters from the network [9, 28, 37, 38], but optimum metrics are still unclear; quantizing binary kernels to a smaller bit size than the kernel size [36]; or using the \(\{0,\pm 1\}\) domains [19, 32]. Although these works suggest that the standard \(\{\pm 1\}\) binary domain has severe limitations regarding compression, BNNs using the \(\{0,\pm 1\}\) domain have reported limited generalization capabilities [19, 32]. In our work, we extend the traditional binary domain to a more general one, that can be efficiently implemented via sparse operations. Moreover, we address sparsity explicitly with entropy constraints, which can be formulated as magnitude pruning of the generic binary weight values mapping them in the \(\{0,1\}\) domain. In our proposed domain, BNNs are more robust to pruning strategies and show better generalization properties than other pruning techniques for the same sparsity levels.
**Quantization.** Network quantization allows the use of fixed-point arithmetic and a smaller bit-width to represent network parameters w.r.t the full-precision
counterpart. Representing the values using only a finite set requires a quantization function that maps the original elements to the finite set. The quantization can be done after training the model, using parameter sharing techniques [11], or during training by quantizing the weights in the forward pass, as ternary neural networks (TNNs) [17], BNNs [5] and other quantized networks do [16, 39]. Our work builds upon the strategy of BNNs by introducing a novel quantization function that maps weights to a binary domain that is more general than the \(\{\pm 1\}\) domain used in most state-of-the-art BNNs. This broader domain significantly reduces the distortion-rate curves of BNNs across various sparsity levels, enabling us to achieve greater compression.
## 3 Method
The proposed SBNN achieves network pruning via sparsification by introducing a novel quantization function that extends standard BNNs weight domain \(\{\pm 1\}\) to a more generic binary domain \(\{\alpha,\beta\}\) and a new penalization term in the objective loss controlling the entropy of the weight distribution and the sparsity of the network (Section 3.2). We derive in Section 3.3 the optimum SBNN's \(\{\alpha,\beta\}\) values, i.e. the values that minimize the quantization loss when real-valued weights are quantized in the proposed domain. In Section 3.4, we use BNN's state-of-the-art training algorithms for SBNN training by adding the sparsity regularization term to the original BNN's objective loss. Section 3.5 describes the implementation details of the proposed SBNN to illustrate their speed-up gains w.r.t BNNs.
### Preliminaries
The training of a full-precision DNN can be seen as a loss minimization problem:
\[\operatorname*{arg\,min}_{\widetilde{\mathbf{W}}}\mathcal{L}(y,\hat{y}) \tag{1}\]
where \(\mathcal{L}(\cdot)\) is a loss function between the true labels \(y\) and the predicted values \(\hat{y}=f(\mathbf{x};\widetilde{\mathbf{W}})\), which are a function of the data input \(\mathbf{x}\) and the network's full precision weights \(\widetilde{\mathbf{W}}=\{\widetilde{\mathbf{w}}^{\ell}\}\), with \(\widetilde{\mathbf{w}}^{\ell}\in\mathbb{R}^{N^{\ell}}\) the weights of the \(\ell^{th}\) layer, and \(N=\sum_{\ell}N^{\ell}\) the total number of weights in the DNN. We denote the \(i^{th}\) weight element of \(\widetilde{\mathbf{w}}^{\ell}\) as \(\widetilde{w}_{i}^{\ell}\).
A BNN [15] uses a modified signum function as quantization function that maps full precision weights \(\widetilde{\mathbf{W}}\) and activations \(\widetilde{\mathbf{a}}\) to the \(\{\pm 1\}\) binary domain, enabling the use of low-cost bitwise operations in the forward propagation, i.e.
\[\overline{\mathbf{W}}=\operatorname*{sign}(\widetilde{\mathbf{W}})\,,\qquad \frac{\partial g(\widetilde{w}_{i})}{\partial\widetilde{w}_{i}}=\left\{ \begin{array}{ll}\frac{\partial g(\widetilde{w}_{i})}{\partial\widetilde{w} _{i}}&\text{, if }-1\leq\widetilde{w}_{i}\leq 1\\ 0&\text{, otherwise,}\end{array}\right.\]
where \(\text{sign}(\cdot)\) denotes the modified sign function over a vector, \(g(\cdot)\) is a differentiable function, \(\overline{\mathbf{W}}\) the network's weights in the \(\{\pm 1\}\) binary domain, \(\overline{w}_{i}\) a given weight in the binary domain, and \(\widetilde{w_{i}}\) the associated full-precision weight.
### Sparse Binary Neural Network (SBNN) Formulation
Given \(\Omega^{\ell}=\{\alpha^{\ell},\beta^{\ell}\}\) a general binary domain, with \(\alpha^{\ell},\beta^{\ell}\in\mathbb{R}\), and \(\alpha^{\ell}<\beta^{\ell}\), let us define a SBNN, such that, for any given layer \(\ell\),
\[w_{i}^{\ell}\in\Omega^{\ell}\qquad\forall\ i, \tag{2}\]
with \(w_{i}^{\ell}\) the \(i^{th}\) weight element of the weight vector, \(\mathbf{w}^{\ell}\), and \(\mathbf{w}=\left\{\mathbf{w}^{\ell}\right\}\) the set of weights for all the SBNN.
We denote \(S_{\alpha^{\ell}}\) and \(S_{\beta^{\ell}}\) the indices of the weights with value \(\alpha^{\ell}\), \(\beta^{\ell}\) in \(\mathbf{w}^{\ell}\)
\[S_{\alpha^{\ell}}=\{i\,|\,1\leq i\leq N^{\ell},w_{i}^{\ell}=\alpha^{\ell}\}, \qquad S_{\beta^{\ell}}=\{i\,|\,1\leq i\leq N^{\ell},w_{i}^{\ell}=\beta^{\ell}\}.\]
Since \(\alpha^{\ell}<\beta^{\ell}\;\forall\;\ell\), it is possible to estimate the number of weights taking the lower and upper values of the general binary domain over all the network:
\[L^{\ell}=|S_{\alpha^{\ell}}|,\qquad U^{\ell}=|S_{\beta^{\ell}}|,\qquad L=\sum_{ \ell}L^{\ell},\qquad U=\sum_{\ell}U^{\ell}, \tag{3}\]
with \(L+U=N\), the total number of SBNN network weights. In the remaining of the manuscript, for simplicity and without loss of generality, please note that we drop the layer index \(\ell\) from the weights notation.
To express the SBNN weights \(\mathbf{w}\) in terms of binary \(\{0,1\}\) weights, we now define a a mapping function \(r:\{0,1\}\longrightarrow\{\alpha,\beta\}\) that allows to express \(\mathbf{w}\):
\[w_{i}=r\left(w_{\{0,1\},i}\right)=\left(w_{\{0,1\},i}+\xi\right)\cdot\eta \tag{4}\]
with
\[\alpha=\xi\cdot\eta,\qquad\beta=(1+\xi)\cdot\eta, \tag{5}\]
and \(w_{\{0,1\},i}\in\{0,1\}\), the \(i^{th}\) weight of a SBNN, when restricted to the binary set \(\{0,1\}\). Through these mapping, 0-valued weights are pruned from the network, the making SBNN sparse.
The bit-width of a SBNN is measured with the binary entropy \(h()\) of the distribution of \(\alpha\)-valued and \(\beta\)-valued weights,
\[h(p)=-p\log_{2}(p)-(1-p)\log_{2}(1-p)\qquad\left[\text{bits/weight}\right], \tag{6}\]
with \(p=U/N\). Achieving network compression using a smaller bit-width than that of standard BNN's weights (1 bit/weight) is equivalent to setting a constraint in the SBNN's entropy to be less or equal than a desired value \(h^{*}\), i.e.
\[h(U/N)\leq h^{*}. \tag{7}\]
Given \(h^{-1}()\) the inverse binary entropy function for \(0\leq p\leq 1/2\), it is straightforward to derive such constraint, \(U\leq M\) where
\[M\triangleq N\cdot h^{-1}(h^{*}). \tag{8}\]
From Eq. (7) and (8), this implies that the constraint corresponds to restricting the maximum number of \(1s\) in the network, and thus the sparsity of the network. Thus, the original full-precision DNN loss minimization problem (Eq. (1)) can be reformulated as:
\[\begin{array}{ll}\operatorname*{arg\,min}&\mathcal{L}(y,\hat{y})\\ \text{s.t.}&\mathbf{w}_{\{0,1\}}\in\{0,1\}^{N},\\ &U\leq M<N.\end{array} \tag{9}\]
The mixed optimization problem in Eq. (9) can be simplified by relaxing the sparsity constraint on \(U\) through the introduction of a non-negative function \(g(\cdot)\), which penalizes the weights when \(U>M\):
\[\begin{array}{ll}\operatorname*{arg\,min}&\mathcal{L}(y,\hat{y})+\lambda g (\mathbf{W}_{\{0,1\}})\\ \text{s.t.}&\mathbf{W}_{\{0,1\}}\in\{0,1\}^{N}\end{array} \tag{10}\]
and \(\lambda\) controls the influence of \(g(\cdot)\). A simple, yet effective function \(g(\mathbf{W}_{\{0,1\}})\) is the following one:
\[g\left(\mathbf{W}_{\{0,1\}}\right)=\text{ReLU}\left(U/N-\text{EC}\right), \tag{11}\]
where \(\text{EC}=M/N\) represents the fraction of expected connections, which is the fraction of 1-valued weights in \(\mathbf{W}_{\{0,1\}}\) over the total number of weights of \(\mathbf{W}_{\{0,1\}}\).
Eq. (9) allows to compare the proposed SBNN with the standard BNN formulation. By setting \(\xi=-1/2\) and \(\eta=2\), for which \(\alpha=-1\) and \(\beta=+1\) (Eq. (4)), and removing the constraint on \(U\) leads to the standard formulation of a BNN. This implies that any BNN can be represented using the \(\{0,1\}\) domain and perform sparse operations. However, in practice when \(U\) is not contained to be \(\leq M\), then \(U\approx N/2\) and \(h(1/2)=1\) bit/weight, which means that standard BNNs cannot be compressed more.
### Weight Optimization
In this section, we derive the value of \(\Omega=\{\alpha,\beta\}\) which minimizes the quantization error when real-valued weights are quantized using it.
The minimization of the quantization error accounts to minimizing the binarization loss, \(\mathcal{L}_{B}\), which is the optimal estimator when \(\widetilde{\mathbf{W}}\) is mapped to \(\mathbf{W}\)[30]. This minimization is equivalent to finding the values of \(\alpha\) and \(\beta\) which minimize \(\mathcal{L}_{B}\). To simplify the derivation of the optimum \(\alpha\) and \(\beta\) values, we minimize
over two variables in one-to-one correspondence with \(\alpha\) and \(\beta\). To achieve this, as in Eq. 4-5, we map \(w_{i}\in\Omega\) to \(\overline{w}_{i}\in\{-1,+1\}\), i.e.
\[w_{i}=\tau\overline{w}_{i}+\phi,\]
where \(\tau\) and \(\phi\) are two real-valued variables, and \(\alpha=-\tau+\phi\) and \(\beta=\tau+\phi\). As a result, \(\alpha\) and \(\beta\) are in one-to-one correspondence with \(\tau\) and \(\phi\), and the minimization of \(\mathcal{L}_{B}\) can be formulated as
\[\tau^{*},\phi^{*}=\arg\min_{\tau,\phi}\mathcal{L}_{B}=\arg\min_{\tau,\phi}\left\| \widetilde{\mathbf{w}}-(\tau\overline{\mathbf{w}}+\phi\mathbf{1})\right\|_{2} \tag{12}\]
where \(\|\cdot\|_{2}\) is the \(\ell_{2}\)-norm and \(\mathbf{1}\) is the all-one entries matrix.
By first expanding the \(\ell_{2}\)-norm term and using the fact that \(\text{sum}(\overline{\mathbf{w}})=N^{\ell}(2p-1)\), it is straightforward to reformulate Eq. 12 as a a function of the sum of real-valued weights, their \(\ell_{1}\)-norm, the fraction of \(+1\)-valued binarized weights and the two optimization parameters. In such case, the \(\nabla\mathcal{L}_{B}\) is
\[\nabla\mathcal{L}_{B}=\begin{pmatrix}\frac{\partial\mathcal{L}_{B}}{\partial \mathcal{L}_{B}}\\ \frac{\partial\mathcal{L}_{B}}{\partial\phi}\end{pmatrix}=2\begin{pmatrix}- \|\widetilde{\mathbf{w}}\|_{1}+N^{\ell}\big{(}\tau+\phi(2p-1)\big{)}\\ -\text{ sum}(\widetilde{\mathbf{w}})+N^{\ell}\big{(}\phi+\tau(2p-1)\big{)} \end{pmatrix}. \tag{13}\]
Solving to find the optimal values \(\tau\) and \(\phi\) we obtain
\[\tau^{*}=\frac{\|\widetilde{\mathbf{w}}\|_{1}}{N^{\ell}}-\phi^{*}(2p-1)\,,\ \ \ \phi^{*}=\frac{\text{sum}(\widetilde{\mathbf{w}})}{N^{\ell}}-\tau^{*}(2p-1). \tag{14}\]
When \(p=0.5\), like in standard BNNs, it gives the classical value of \(\tau^{*}=\|\widetilde{\mathbf{w}}\|_{1}/N^{\ell}\) as in [30]. By substituting \(\phi^{*}\) in Eq. (12), we obtain the closed-form solution
\[\tau^{*}=\frac{\|\widetilde{\mathbf{w}}\|_{1}-(2p-1)\text{sum}(\widetilde{ \mathbf{w}})}{N^{\ell}(1-(2p-1)^{2})}\,,\ \ \ \phi^{*}=\frac{\text{sum}(\widetilde{\mathbf{w}})-(2p-1)\|\widetilde{\mathbf{w}} \|_{1}}{N^{\ell}(1-(2p-1)^{2})}. \tag{15}\]
As the gradient (Eq. 13) is linear in \(\phi\) and \(\tau\), this implies that there is a unique critical point. Moreover, an analysis of the Hessian matrix confirms that \(\mathcal{L}_{B}\) is convex and that local minimum is a global minimum. The derivation is here omitted as it is straightforward.
### Network Training
The SBNN training algorithm builds upon state-of-the-art BNN training algorithms [3, 15, 25], while introducing network sparsification. To profit from BNNs training scheme, we replace \(\mathbf{W}_{\{0,1\}},\xi\) and \(\eta\) (Eq. (10)) with \(\overline{W},\tau\) and \(\phi\). Doing so, \(\mathcal{L}(y,\hat{y})\) corresponds to the loss of BNN algorithms \(\mathcal{L}_{\text{\tiny{BNN}}}\). SBNN training also requires to add the penalization term from Eq. (11) to account for sparsity. To account for \(\overline{\mathbf{W}}\), the regularization function \(g(\mathbf{W}_{\{0,1\}})\) (Eq. (11)) is redefined according to
\[j(\overline{\mathbf{W}})=\text{ReLU}\left(\left(\sum_{i}\frac{\overline{w}_{i }+1}{2N}\right)-\text{EC}\right), \tag{16}\]
and the SBNN objective loss can be expressed as
\[\mathcal{L}_{\text{\tiny SBNN}}=\mathcal{L}_{\text{\tiny BBNN}}+\lambda\,j( \overline{\mathbf{W}}). \tag{17}\]
During training, we modulate the contribution of the regularization term \(j(\overline{\mathbf{W}})\) by imposing, at every training iteration, to be equal to a fraction of \(\mathcal{L}_{\text{\tiny SBNN}}\), i.e.
\[\gamma=\frac{\lambda\,j(\overline{\mathbf{W}})}{\mathcal{L}_{\text{\tiny SBNN }}}. \tag{18}\]
The hyperparameter \(\gamma\) is set to a fixed value over all the training process. Since \(\mathcal{L}_{\text{\tiny SBNN}}\) changes at every iteration, this forces \(\lambda\) to adapt, thus modulating the influence of \(j(\overline{\mathbf{W}})\) proportionally to the changes in the loss. The lower \(\gamma\) is set, the less influence \(j(\overline{\mathbf{W}})\) has on the total loss. This means that network sparsification will be slower, but convergence will be achieved faster. On the opposite case (high \(\gamma\)), the training will favor sparsification.
### Implementation Gains
We discuss the speed-up gains of the proposed SBNN through its efficient implementation using linear layers in the backbone architecture. Its extension to convolutional layers (Fig. 1) is straightforward, thus we omit it for the sake of brevity.
We describe the use of sparse operations, as it can be done on an FPGA device [7, 36]. Instead, when implemented on CPUs, SBNNs can take advantage of pruned layers, kernels and filters for acceleration [9, 28, 37, 38]. Moreover, for kernels with only a single binary weight equal to 1 there is no need to perform a convolution, since the kernels remove some elements from the corner of their input.
Figure 1: BNNs vs. SBNNs operations in a convolutional layer using \(c_{out}\) filters and input of \(c_{in}\) dimensions. BNNs’ (\(c_{out}\cdot c_{in}\)) convolutional kernels are dense and require all computations. SBNNs’ kernels are sparse, allowing to skip certain convolutions and sum operations. The removed filters are indicated by a dashed contour and no fill. Both BNNs and SBNNs perform convolutions using XNOR and popcount operations, while the sum is replaced by popcount operations.
The connections in a SBNN are the mapped one-valued weights, i.e. the set \(S_{1}\). Therefore, SBNNs do not require any XNOR operation on FPGA, being popcount the only bitwise operation needed during the forward pass. The latter, however, is performed only in a layer's input bits connected through the one-valued weights rather than the full input.
For any given layer \(\ell\), the number of binary operations of a BNN is \(\mathcal{O}_{\textsc{BNN}}=2N^{\ell}\)[3], \(N^{\ell}\) XNOR operations and \(N^{\ell}\) popcounts. A rough estimate of the implementation gain in terms of the number of binary operations of SBNNs w.r.t. BNNs can be expressed in terms of the EC as
\[\frac{\mathcal{O}_{\textsc{SBNN}}}{\mathcal{O}_{\textsc{BNN}}}\approx\frac{2N ^{\ell}}{\text{EC}\cdot N^{\ell}}\approx\frac{2}{\text{EC}}, \tag{19}\]
which indicates that the lower the EC fraction, the higher the gain w.r.t. BNNs.
Binary operations are not the only ones involved in the inference of SBNN layers. After the sparse \(\{0,1\}\) computations, the mapping operations to the \(\{\alpha,\beta\}\) domain take place, also benefiting from implementation gains. To analyze these, let us now denote \(\mathbf{x}\) the input vector to any layer and \(\mathbf{z}=\mathbf{w}\,\mathbf{x}\) its output. Using E. (4), \(\mathbf{z}\) can be computed as
\[\mathbf{z}=\xi\,\mathbf{z}^{\prime}+\xi\,\eta\,\mathbf{q}, \tag{20}\]
where \(\mathbf{z}^{\prime}=\mathbf{w}_{\{\mathbf{0},\mathbf{1}\}}\,\mathbf{x}\) is the result of sparse operations (Fig. 1), \(\mathbf{q}=\mathbf{1}\,\mathbf{x}\), and \(\mathbf{1}\) the all-ones matrix.
All the elements in \(\mathbf{q}\) take the value \(2\cdot\text{popcount}(\mathbf{x})-|\mathbf{x}|\), with \(|\mathbf{x}|\) the size of \(\mathbf{x}\). Therefore, they are computed only once, for each row of \(\mathbf{1}\). Being \(\xi\) and \(\eta\) known at inference time, they can be used to precompute the threshold in the threshold comparison stage of the implementation of the batchnorm and sign operations following the estimation of \(\mathbf{z}\)[35]. Thus, SBNNs require \(|\mathbf{x}|\) binary operations, one real product and \(|\mathbf{x}|\) real sums to obtain \(\mathbf{z}\) from \(\mathbf{z}^{\prime}\).
## 4 Experiments and Results
We first run a set of ablation studies to analyze the properties of the proposed method (Section 4.1). Namely, we analyze the generalization of SBNNs in a standard binary domain and the proposed generic binary domain; we study the role of the quantization error in the network's performance; and the effects of sparsifying binary kernels. Next, we compare our proposed method to other state-of-the-art techniques using the well established CIFAR-10 and CIFAR-100 [18] datasets. Preliminary results on ImageNet [31] are also discussed. All our code has been made publicly available3.
Footnote 3: github.com/robustml-eurecom/SBNN
### Ablation Studies
**Experimental setup.** We use a ResNet-18 binarized model trained on CIFAR-10 as backbone architecture. We train the networks for 300 epochs, with batch
size of \(512\), learning rate of \(1e-3\), and standard data augmentation techniques (random crops, rotations, horizontal flips and normalization). We use an Adam optimizer and the cosine annealer for updating the learning rate as suggested in [24] and we follow the binarization strategy of IR-Net [29].
#### 4.1.3 Generalization properties.
We compare the performance of the proposed generic binary domain to other binary domains used by BNNs by assessing the networks' generalization capabilities when the sparsity ratio is \(95\%\). For this experiment, we use the \(\{-\beta,+\beta\}\) domain from [30] with no sparsity constraints as the baseline. Additionally, we consider the same domain with a \(95\%\) sparsity constraint and the \(\{\alpha,\beta\}\) domain obtained optimizing \(\tau\) and \(\phi\) according to Eq. (15) with the \(95\%\) sparsity constraint. Table 1 reports the obtained results in terms of top-1 accuracy and accuracy loss w.r.t. the BNN baseline model (\(\Delta\)). When we impose the \(95\%\) sparsity constraint with the \(\{-\beta,+\beta\}\) domain, the accuracy drop w.r.t. to the baseline is \(2.98\%\). Using the \(\{\alpha,\beta\}\) domain, the loss goes down to \(2.47\%\), nearly \(0.5\%\) better than the \(\{-\beta,+\beta\}\) domain. The results suggest that a more general domain leads to improved generalization capabilities.
#### 4.1.4 Impact of the quantization error
We investigate the impact of the quantization error in the SBNN generalization. To this end, we compare the proposed quantization technique (Sec. 3.3) with the strategy of learning \(\Omega\) via back-propagation. We denote this approach Learned \(\{\alpha,\beta\}\) (Table 1). The obtained results show that with the learning of the parameters the accuracy loss w.r.t. the BNN baseline decreases down to \(-0.09\%\), thus \(2.38\%\) better than when \(\tau\) and \(\phi\) are analytically obtained with Eq. (15). This result implies that the quantization error is one of the sources of accuracy degradation when mapping real-valued weights to any binary domain, but it is not the only source. Indeed, activations are also quantized. Moreover, errors are propagated throughout the network. Learning \(\Omega\) can partially compensate for these other error sources.
#### 4.1.5 Effects of network sparsification
We investigate the effects of network sparsification and how they can be leveraged to reduce the binary operations (BOPs) required in SBNNs. In Section 4.1.4, we showed that our binary domain is more adept at learning sparse network representations compared to the standard binary domain. This allows us to increase the sparsity of SBNNs while maintaining a desired level of accuracy. When the sparsity is sufficii
\begin{table}
\begin{tabular}{c|c c c} \hline \hline Domain & Sparsity constraint Top-1 Accuracy & \(\Delta\) \\ \hline \hline Baseline & & 88.93\% & / \\ \(\{-\beta,+\beta\}\)[30] & 95\% & 85.95\% & -2.98\% \\ \(\{\alpha,\beta\}\) & 95\% & 86.46\% & -2.47\% \\ Learned \(\{\alpha,\beta\}\) & 95\% & 88.84\% & -0.09\% \\ \hline \end{tabular}
\end{table}
Table 1: Role of the binary domain and the quantization error when sparsifying BNNs. Experiments performed on CIFAR-10 with a binarized ResNet-18 model.
tional kernels can be entirely removed from the network, which further reduces the BOPs required for SBNNs. Additionally, convolutional kernels with only a single binary weight equal to 1 do not require a convolution to be performed, as these kernels simply remove certain elements from the input.
To illustrate this effect, we plotted the distribution of binary kernels for the 5th, 10th, and 15th layers of a binarized ResNet-18 model (Fig. 2). The first column shows the distribution when no sparsity constraints are imposed, while the second and third columns show the distribution for sparsity levels of 95% and 99%, respectively. The kernels are grouped based on their Hamming weights, which is the number of non-zero elements in each \(\{0,1\}^{3\times 3}\) kernel. The plots suggest that increasing the sparsity of SBNNs results in a higher number of kernels with Hamming weights of 0 and 1.
### Benchmark
**CIFAR-10.** We compare our method against state-of-the-art methods over a binarized ResNet-18 model using CIFAR-10. Namely, we consider: STQ [28], Slimming [37], Dual-P [7], Subbit [36], IR-Net [29] and our method with learned \(\tau\) and \(\phi\), for different sparsity constraints. We use the IR-Net as BNN baseline to be compressed. We use the experimental setup described in Sec. 4.1 with some modifications. We extend the epochs to 500 as in [36], and we use a MixUp strategy [42]. In the original IR-Net formulation [29], the training setup is missing. We use our setup to train it, achieving the same accuracy as in [29].
Table 2 reports the obtained results in terms of accuracy (Acc.), accuracy loss w.r.t. the IR-Net model (\(\Delta\)), and BOPs reduction (BOPs PR). For our SBNN, we estimate BOPs PR by counting the number of operations which are not computed from the convolutional kernels with Hamming weight 0 and 1. For
Figure 2: Percentage of binary kernels for various Hamming weights of a binarized Resnet-18 model over CIFAR-10 for different sparsity constraints. The 5-th, 10-th and 15-th layers are shown in the top, middle and bottom rows, respectively.
other methods, we refer the reader to the original publications. We assess our method at different levels of sparsity, in the range 50 to 99%. For SBNNs we also report the percentage of SBNN's convolutional kernels with Hamming weight 0 (\(K_{0}\)) and with Hamming weight 1 (\(K_{1}\)).
The results suggest that our method is competitive with other more complex pruning strategies. Moreover, our method reports similar accuracy drops w.r.t. state-of-the-art Subbit and Dual-P for similar BOPs PR. However, we need to point out that Subbit and Dual-P results refer to BOPs PR on FPGA, where SBNN can take advantage of sparse operations (Section 3.5) also for the kernels with larger Hamming weights than 0 and 1, because on FPGA all operations involving 0-valued weights can be skipped. For instance, the use of sparse operations on the SBNN 95% allows to remove \(\approx\) 84.9% BOPs.
**CIFAR-100.** We compare our method in the more challenging setup of CIFAR-100, with 100 classes and 500 images per class, against two state-of-the-art methods: STQ [28], and Subbit [36]. We use ReActNet-18 [25] as the backbone architecture, using a single training step and no teacher. We train for 300 epochs with the same setup used for CIFAR-10 with Mixup augmentation. As no previous results for this setup have been reported for ReActNet-18 and Subbit, for a fair comparison, we trained them from scratch using our setup. We report the same metrics used for CIFAR-10, plus the the reduction of binary parameters (BParams PR). For our SBNN, we estimate BParams PR as follows. For each kernel we use 2 bits to differentiate among zero Hamming weight kernels, one Hamming weight kernels and all the other kernels. Then, we add 4 bits to the kernels with Hamming weight 1 to represent the index position of their 1-valued bit, whereas we add 9 bits for all the other kernels with Hamming weight larger
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Method** & **Acc.** & \(\mathbf{\Delta}\) & **BOPs PR** & \(\mathbf{K_{0}}\) & \(\mathbf{K_{1}}\) \\ \hline IR-Net & 91.50\% & / & / & / & / \\ STQ & 86.56\% & -5.50\% & -40.0\% & / & / \\ Slimming & 89.30\% & -2.20\% & -50.0\% & / & / \\ Dual-P (2\(\rightarrow\)1) & 91.02\% & -0.48\% & -70.0\% & / & / \\ Dual-P (3\(\rightarrow\)1) & 89.81\% & -1.69\% & -80.6\% & / & / \\ Dual-P (4\(\rightarrow\)1) & 89.43\% & -2.07\% & -85.4\% & / & / \\ Subbit 0.67-bits & 91.00\% & -0.50\% & -47.2\% & / & / \\ Subbit 0.56-bits & 90.60\% & -0.90\% & -70.0\% & / & / \\ Subbit 0.44-bits & 90.10\% & -1.40\% & -82.3\% & / & / \\ SBNN 50\% **[our]** & 91.70\% & +0.20\% & -11.1\% & 5.6\% & 6.8\% \\ SBNN 75\% **[our]** & 91.71\% & +0.21\% & -24.5\% & 30.7\% & 15.9\% \\ SBNN 90\% **[our]** & 91.16\% & -0.24\% & -46.5\% & 61.8\% & 15.5\% \\ SBNN 95\% **[our]** & 90.94\% & -0.56\% & -63.2\% & 77.1\% & 11.8\% \\ SBNN 96\% **[our]** & 90.59\% & -0.91\% & -69.7\% & 81.0\% & 10.1\% \\ SBNN 97\% **[our]** & 90.71\% & -0.79\% & -75.7\% & 84.8\% & 8.7\% \\ SBNN 98\% **[our]** & 89.68\% & -1.82\% & -82.5\% & 89.3\% & 6.5\% \\ SBNN 99\% **[our]** & 88.87\% & -2.63\% & -88.7\% & 94.6\% & 3.3\% \\ \hline \hline \end{tabular}
\end{table}
Table 2: Evaluation of kernel removal for different pruning targets using a binarized Resnet-18 model on CIFAR-10.
than 1, which are their original bits. For the other methods, please refer to their work for their estimate of BParams PR.
Table 3 reports the obtained results for the different methods and our SBNN for various sparsity targets. We can see that our pruning method is more effective in reducing both the BOPs and the parameters than Subbit. It allows to remove 79.2% of kernels, while increasing the original accuracy by 0.79% w.r.t. the ReActNet-18 baseline. Instead, we observe nearly 1% accuracy drop for a Subbit network for a similar BOPs reduction. Moreover, our method allows to remove nearly 15% more binary parameters.
**ImageNet.** We assess our proposed SBNN trained with target sparsity of 75% and 90% on ImageNet. We compare them with state-of-the-art BNNs, namely: XNOR-Net [30], Bi-RealNet-18 [26] and ReActNet-18, ReActNet-A [25] and Subbit [36]. Moreover, we also report the accuracy of the full-precision ResNet-18 [13] and MobileNetV1 [14] models, as a reference. We use a ReActNet-A [25] as SBNN's backbone with its MobileNetV1 [14] inspired topology and with the distillation procedure used in [25], whereas in Subbit [36] they used ReActNet-18 as backbone. One of the limitations of Subbit [36] is that their method cannot be applied to the pointwise convolutions of MobileNetV1 [14]. Due to GPUs limitations, during our training, we decreased the batch size to 64. For a fair comparison, we retrained the original ReActNet-A model with our settings.
Table 4 reports the results in terms of accuracy (Acc). We also include the number of operations (OPs) to be consistent with other BNNs assessment on ImageNet. For BNNs, OPs are estimated by the sum of floating-point operations (FLOPs) plus BOPs rescaled by a factor 1/64 [30, 26, 25]. We assume sparse operations on FPGA to estimate BOPs for SBNN.
We observe that BOPs are the main contributors to ReActNet-A's OPs (Table 4), thus decreasing them largely reduces the OPs. This, instead, does not
\begin{table}
\begin{tabular}{c c c c c c} \hline
**Method** & **Acc.** & \(\mathbf{\Delta}\) & **BOPs PR BParams PR** & \(\mathbf{K_{0}}\) & \(\mathbf{K_{1}}\) \\ \hline ReActNet-18\({}^{*}\) & 62.79\% & / & / & / & / \\ STQ & 57.72\% & -5.05\% & -36.1\% & -36.1\% & - \\ Subbit 0.67-bits\({}^{*}\) & 62.60\% & -0.19\% & -47.2\% & -33.3\% & / / \\ Subbit 0.56-bits\({}^{*}\) & 62.07\% & -0.72\% & -70.0\% & -44.4\% & / / \\ Subbit 0.44-bits\({}^{*}\) & 61.80\% & -0.99\% & -82.3\% & -55.6\% & / / \\ SBNN 50\% **[our]** & 63.03\% & +0.24\% & -11.1\% & / & 5.6\% & 6.8\% \\ SBNN 95\% **[our]** & 63.33\% & +0.54\% & -66.2\% & -59.9\% & 72.9\% & 16.6\% \\ SBNN 96\% **[our]** & 63.04\% & +0.25\% & -67.3\% & -63.7\% & 78.9\% & 12.6\% \\ SBNN 97\% **[our]** & 62.41\% & -0.38\% & -73.4\% & -66.8\% & 82.9\% & 11.1\% \\ SBNN 98\% **[our]** & 63.58\% & +0.79\% & -79.2\% & -70.3\% & 88.1\% & 8.0\% \\ SBNN 99\% **[our]** & 62.23\% & -0.57\% & -87.8\% & -74.0\% & 93.6\% & 4.7\% \\ \hline \multicolumn{6}{l}{\({}^{*}\) our implementation.} \\ \end{tabular}
\end{table}
Table 3: Evaluation of kernel removal for different pruning targets using a ReActNet-18 model on CIFAR-100.
hold for ReActNet-18, which may explain why Subbit is not effective in reducing OPs of its baseline. Our method instead is effective even for less severe pruning targets and it requires less than \(3.4\times\) OPs w.r.t. state-of-the-art ReActNet-A model, while incurring in an acceptable generalization loss between \(1.9-3.4\%\).
## 5 Conclusions
We have presented sparse binary neural network (SBNN), a novel method for sparsifying BNNs that is robust to simple pruning techniques by using a more general binary domain. Our approach involves quantizing weights into a general \(\Omega=\{\alpha,\beta\}\) binary domain that is then expressed as 0s and 1s at the implementation stage. We have formulated the SBNN method as a mixed optimization problem, which can be solved using any state-of-the-art BNN training algorithm with the addition of two parameters and a regularization term to control sparsity.
Our experiments demonstrate that SBNN outperforms other state-of-the-art pruning methods for BNNs by reducing the number of operations, while also improving the baseline BNN accuracy for severe sparsity constraints. Future research can investigate the potential of SBNN as a complementary pruning technique in combination with other pruning approaches. In summary, our proposed SBNN method provides a simple yet effective solution to improve the efficiency of BNNs, and we anticipate that it will be a valuable addition to the field of binary neural network pruning.
|
Subsets and Splits