校园网页 · 学校官网
Efficient and stable SAV-based methods for gradient flows arising from deep learning
Journal of Computational Physics 505 (2024) 112911 Available online 7 March 2024 0021-9991/© 2024 Elsevier Inc. All rights reserved. Contentslistsavailableat ScienceDirect Journal of Computational Physics journal homepage: www.elsevier.com/locate/jcp Efficient and stable SAV-based methods for gradient flows arising from deep learning ZiqiMa a, ZhipingMao a,∗, JieShen b,∗ a School of Mathematical Sciences, Fujian Provincial Key Laboratory of Mathematical Modeling and High-Performance Scientific Computing, Xiamen University, Xiamen, 361005, China b School of Mathematical Science, Eastern Institute of Technology, Ningbo, Zhejiang, 315200, China A R T I C L E I N F O A B S T R A C T Keywords: Deep learning Gradient flow SAV method Energy stable Adam method Adaptive learning rate The optimization algorithm plays an important role in deep learning and significantly affects the stability and efficiency of the training process, and consequently the accuracy of the neural network approximation. A suitable (initial) learning rate is crucial for the optimization algorithm in deep learning. However, a small learning rate is usually needed to guarantee the convergence of the optimization algorithm, resulting in a slow training process. We develop in this work efficient and energy stable optimization methods for function approximation problems as well as solving partial differential equations using deep learning. In particular, we consider the gradient flows arising from deep learning from the continuous point of view, and employ the particle method (PM) and the smoothed particle method (SPM) for the space discretization while we adopt SAV-based schemes, combined with the adaptive strategy used in Adam algorithm, for the time discretization. To illustrate the effectiveness of the proposed methods, we present a number of numerical tests to demonstrate that the SAV-based schemes significantly improve the efficiency and stability of the training as well as the accuracy of the neural network approximation. We also show that the SPM approach gives a slightly better accuracy than the PM approach. We further demonstrate the advantage of using adaptive learning rate in dealing with more complex problems. 1. Introduction Neural network-based machine learning, which is also called deep learning, has been widely used in classical artificial intelligence, for instance, object detection and face recognition using convolutional neural networks [1,2], handwriting learning and natural language processing using recurrent neural networks [3], generating examples for the image dataset and unknown photographs of human faces using generative adversarial networks[4]. In the last decade, it has also been shown that deep learning is a powerful tool in scientific computing. For examples, a PINN framework that can easy handle inverse problems and complex geometries is proposed in [5], DeepONet, which uses neural network to approximate differential operators, is proposed in [6]f o r solving a class of similar problems, a mesh-free computational framework for solving elliptic PDEs on unknown manifolds based on deep learning theory is proposed in [7], and deep learning has also been used to solve many complex high-dimensional nonlinear PDEs [8,9]. We refer to [10–12]and references therein for more efforts in these directions. * Corresponding authors. E-mail addresses:maziqi@stu.xmu.edu.cn(Z.Ma), zpmao@xmu.edu.cn(Z.Mao), jshen@eitech.edu.cn(J.Shen). https://doi.org/10.1016/j.jcp.2024.112911 Received 2 May 2023; Received in revised form 1 March 2024; Accepted 2 March 2024 Journal of Computational Physics 505 (2024) 112911 2 Z.Ma,Z.MaoandJ.Shen A 𝐾-hidden layer neural network is defined as 𝑓(𝐱,𝜃)= 𝑓𝐾(...𝑓2(𝑓1(𝐱))), where 𝜃denotes all parameters to be trained, and for the 𝑘-th hidden layer 𝑓𝑘(𝐱)= 1 𝑚𝑘 𝑚𝑘∑ 𝑖=1 𝑎𝑖,𝑘𝜎(𝝎𝑇 𝑖,𝑘𝐱+𝑏𝑖,𝑘),𝑘=1,2,… ,𝐾. Here 𝑚𝑘is the number of neurons in the 𝑘-th hidden layer, 𝜎(⋅) is a nonlinear activation function, 𝜃𝑖,𝑘=(𝑎𝑖,𝑘, 𝑏𝑖,𝑘, 𝝎𝑖,𝑘), where 𝑎𝑖,𝑘, 𝑏𝑖,𝑘∈ℝ, 𝝎𝑖,𝑘∈ℝ𝐷are the parameters to be trained. We shall drop the subscript 𝑘if no confusion arises. The idea of deep learning is to find the best approximation of a target functional using a neural network as the surrogate function. To this end, we need to define the so-called loss function (energy functional) to formulate an optimization problem. For example, in the supervised learning with a given target function 𝑓∗, the loss function, also called the population risk, in the 𝐿2 sense is given by (𝜃)= ∫ 𝐷 (𝑓(𝐱,𝜃)−𝑓∗(𝐱))2𝜇(𝑑𝐱), (1) where 𝜇is a probability distribution; or with a given set of data (𝐱𝑖, 𝑦𝑖) ∈ℝ𝐷× ℝ, 𝑖 =1, 2, … , 𝑛, the loss function, also called the empirical risk, is given by (𝜃)= 1 𝑛 𝑛∑ 𝑖=1 (𝑓(𝐱𝑖,𝜃)−𝑦𝑖)2. (2) A major task in deep learning is to develop efficient optimization algorithms for the training of neural networks. This is also a bottleneck that significantly affects the efficiency and accuracy of the neural network approximation. Popular optimization algorithms used in deep learning are mostly gradient descent-based methods. The gradient descent (GD) method, proposed in [13], takes the form: 𝜃𝑡+1 =𝜃𝑡−Δ𝑡∇𝜃(𝜃𝑡), and was first described as an optimization algorithm for deep learning in [14], where Δ𝑡denote the learning rate 𝑙𝑟, ∇𝜃(𝜃𝑡) is the gradient of the loss function w.r.t. 𝜃at the time step 𝑡. However, due to the fact that the optimization problems arising from deep learning are usually nonconvex and high-dimensional, the original GD method often fails as it is more likely trapped in a local minimum. Moreover, it is computationally expensive due to the fact that the GD method uses the gradient calculated from all samples at each epoch. Therefore, the Stochastic Gradient Descent (SGD) method, which randomly chooses one or a batch of training samples from the training set, is proposed to resolve this issue[15]. In particular, the SGD [15]integrates the idea of mini-batch, and updates the parameters using a mini-batch of 𝑙training examples at each time step 𝑡by the following formula: 𝜃𝑡+1 =𝜃𝑡−Δ𝑡∇𝜃(𝜃𝑡; 𝐱𝑖∶𝑖+𝑙,𝑦𝑖∶𝑖+𝑙), where the gradient is computed by using 𝑙data (𝐱𝑖∶𝑖+𝑙, 𝑦𝑖∶𝑖+𝑙) in the 𝑖th mini-batch.1 However, the learning rate Δ𝑡for the SGD method is usually set to be a constant, so it does not converge if the learning rate is too large while it converges very slowly if the learning rate is too small. Therefore, several adaptive optimization algorithms are proposed. For instance, Adagrad (Adaptive Gradient) adapts the learning rate by assigning higher learning rates to infrequent features, which ensures that the parameter updates rely less on frequency and more on relevance [16]. An extension of Adagrad is RMSprop, which avoids the learning rate going to zero[17]. It accumulates past squared gradients over window of a fixed size rather than all of them to improve the efficiency. One of the most popular adaptive optimization algorithms in deep learning is the so called Adam algorithm [18], which first computes the estimates of the first moment (the mean) and second moment (the uncentered variance) of the gradient: 𝑚𝑡=𝛽1𝑚𝑡−1+(1−𝛽1)∇𝜃(𝜃𝑡),𝑣 𝑡=𝛽2𝑣𝑡−1+(1−𝛽2)‖∇𝜃(𝜃𝑡)‖2, (3) where 𝛽1 =0.9, 𝛽2 =0.999, and 𝑚0, 𝑣0 is initialized to 0, then updates parameters with the bias-corrected first and second moment estimates ̂𝑚𝑡, ̂𝑣𝑡: ̂𝑚𝑡= 𝑚𝑡 1−(𝛽1)𝑡,̂𝑣𝑡= 𝑣𝑡 1−(𝛽2)𝑡,𝜃 𝑡+1 =𝜃𝑡− Δ𝑡√ ̂𝑣𝑡+𝜖 ̂𝑚𝑡. (4) More detail can be found in [19]and references therein. However, the performance, especially the stability and the efficiency, of the aforementioned optimization algorithms strongly depends on the choice of the (initial) learning rate, even for these adaptive-based methods. For instance, in practice, one needs to manually and carefully adjust the learning rate to obtain a more or less “good” learning process. On the one hand, the training may 1 For the sake of simplicity, we ignore the dependence on (𝐱𝑖∶𝑖+𝑙, 𝑦𝑖∶𝑖+𝑙)in this paper. Journal of Computational Physics 505 (2024) 112911 3 Z.Ma,Z.MaoandJ.Shen fail if the learning rate is too big, and on the other hand, the training process is very slow if the learning rate is too small. Therefore, it is important to develop efficient and stable optimization algorithms for the training process in deep learning. Recently, Liu et al. considered the optimization problem as finding the steady state solutions of a gradient flow from the continu- ous point of view and then proposed efficient and energy stable SAV-based algorithms[20]. We note that from the continuous point of view, the training process in deep learning can be viewed as a dynamic system, see [21–27]and references therein. For examples, it has been shown that the 2LNN model [28,29]a n d the ResNet [30,31] correspond to continuous dynamic systems under certain conditions. In addition, it is shown in [32]that the SGD dynamics for one hidden layer neural networks can be captured by a certain gradient flow governed by a nonlinear partial differential equation. Motivated by this, we aim to adopt the efficient and stable optimization algorithms proposed in [20]for the training process in deep learning from the continuous point of view, namely, we would like to develop efficient and stable algorithms for the continuous nonlinear PDEs arising from deep learning. In particular, we shall consider the function approximation problem using the 𝐿2 loss function with one hidden layer neural networks approach, and develop efficient SAV-based algorithms for the corresponding gradient flow. Specifically, we consider the empirical risk (2)with the following one hidden layer neural network 𝑓(𝐱)= 1 𝑚 𝑚∑ 𝑖=1 𝑎𝑖𝜎(𝝎𝑇 𝑖𝐱). Here we use 𝐱 ⇒[𝐱; 1], 𝝎𝑖⇒[𝝎𝑖; 𝑏𝑖]to simplify the notations, 𝑚is the number of neurons. By using the mean field analysis[32,33], it follows that as 𝑚 →∞, the one hidden layer neural network can be represented by the function in the expectation form from the continuous point of view: 𝑓(𝐱)= ∫ 𝑎𝜎(𝝎𝑇𝐱)𝜋(𝑑𝑎,𝑑𝝎)= 𝔼(𝑎,𝝎)∼𝜋[𝑎𝜎(𝝎𝑇𝐱)], (5) where 𝜋is the probability distribution of 𝜃=(𝑎, 𝝎), and the gradient flow corresponding to the training process is given by 𝜕𝜋 𝜕𝑡=−∇⋅(𝜋∇𝑣),𝑣 =−𝛿 𝛿𝜋, (6) where is the loss functional given by (1). Therefore, the training process, i.e., the optimization in deep learning, becomes finding the steadysolution of the above gradient flow. The main purpose of this work is to develop stable and efficient numerical schemes to solve (6). In particular, we numerically solve the problem (6)u s i n g the particle method (PM) and the smoothed particle method (SPM) for the space discretization while using SAV-based schemes for the time discretization. We point out here that in the present work we test the SPM approach for the space discretization for (6)t o see if SPM would give a better accuracy compared with the PM approach since SPM is a nonlocal approach. Our numerical results show that the SPM approach delivers a little better accuracy compared with the PM approach. We would like to develop better space discretizations such as spectral methods for (6)in future. Our main contributions are as follows: •W e formulate and implement the PM and SPM approaches, and show that SPM achieves approach higher accuracy than the PM approach. •W e adopt several efficient and energy stable SAV-based schemes, including the vanilla SAV, the restart SAV and the relaxed SAV schemes to improve the robustness and efficiency of the training processes. Note that the vanilla SAV and the relaxed SAV schemes are all unconditionally energy stable with a modified energy. •B y combining the SAV-based schemes with the Adam adaptive technique, we develop a SAV based adaptive algorithm which is more efficient and results in more reliable training processes, and also improves accuracy. The rest of the paper is organized as follows. The numerical schemes for both space and time discretization of (6)a r e pre- sented in Section2. Then several numerical examples including regression and classification problems are shown to demonstrate the effectiveness of the present algorithms in Section3. A summary with some discussions is givenin Section4. 2. Numerical methods We first introduce PM and SPM approximations for the spactial discretization, and then present several efficient and energy stable SAV-based schemes for the time discretization. 2.1. Space discretization for the gradient flow We introduce the PM and SPM methods for the high-dimensional nonlinear system (6). These two methods have been proposed in [26], but as fas as we know the SPM has not yet been implemented in the framework of deep learning. 2.1.1. Particle method We approximate the continuous distribution 𝜋by ̂𝜋(𝜃)= 1 𝑚 𝑚∑ 𝑘=1 𝛿(𝜃−𝜃𝑘), (7) Journal of Computational Physics 505 (2024) 112911 4 Z.Ma,Z.MaoandJ.Shen where 𝛿(⋅)is the Dirac delta function, 𝑚is the number of particles, and {𝜃𝑘}𝑚 𝑘=1 are the 𝑚particles. Then (5)is approximated by 𝑓(𝑥; ̂𝜋)= 1 𝑚 𝑚∑ 𝑘=1 𝑎𝑘𝜎(𝝎𝑇 𝑘𝐱). By testing (6)with a function 𝑔(𝜃), we obtain a weak formulation of (6): 𝑑 𝑑𝑡∫ 𝑔(𝜃)𝑑𝜋(𝜃)=− ∫ ∇⋅(𝜋𝑣(𝜋,𝜃))𝑔(𝜃)𝑑𝜃= ∫ ⟨𝑣(𝜋,𝜃),∇𝑔(𝜃)⟩𝑑𝜋(𝜃). Then applying the approximation (7)on both sides of the above equation and using the chain rule yields 𝑑 𝑑𝑡 1 𝑚 𝑚∑ 𝑘=1 𝑔(𝜃𝑘)= 1 𝑚 𝑚∑ 𝑘=1 ⟨ ∇𝑔(𝜃𝑘),𝑑𝜃𝑘 𝑑𝑡 ⟩ = 1 𝑚 𝑚∑ 𝑘=1 ⟨∇𝑔(𝜃𝑘),𝑣(̂𝜋,𝜃𝑘)⟩, which implies 𝑑𝜃𝑘 𝑑𝑡=𝑣(̂𝜋,𝜃𝑘)=−𝛿(𝜃1,...,𝜃𝑚) 𝛿𝜃𝑘 , (8) where 𝜃=(𝑎, 𝝎), and (𝜃1, ..., 𝜃𝑚)is the approximation of the energy functional (1)by using (7). Consequently, we obtain 𝑑𝑎𝑘 𝑑𝑡=−𝛿 𝛿𝑎𝑘 =−𝔼𝐱[(𝑓(𝐱; ̂𝜋)−𝑓∗(𝐱))𝜎(𝝎𝑇 𝑘𝐱)], 𝑑𝝎𝑘 𝑑𝑡=− 𝛿 𝛿𝝎𝑘 =−𝔼𝐱[(𝑓(𝐱; ̂𝜋)−𝑓∗(𝐱))𝑎𝑘𝜎′(𝝎𝑇 𝑘𝐱)𝐱]. (9) The expectation with respect to 𝐱here corresponds exactly to the mini-batch in the SGD method. Therefore, for the implementation of PM, we can directly employ the GD (or SGD for the stochastic version) method. 2.1.2. Smoothed particle method Unlike the PM approach, here we use the following smooth function to approximate the distribution 𝜋 ̃𝜋(𝜃)= 1 𝑚 𝑚∑ 𝑘=1 𝜙ℎ(𝜃−𝜃𝑘), (10) where 𝜙ℎis a probability density function of (0, ℎ2𝐼), ℎ ∈(0, 1)is a constant with a default value 0.0001. In this case, (5)can be approximated by 𝑓(𝐱; ̃𝜋)= ∫ 𝑎𝜎(𝝎𝑇𝐱)̃𝜋(𝑑𝑎,𝑑𝝎)= 𝔼(𝑎,𝝎)∼̃𝜋[𝑎𝜎(𝝎𝑇𝐱)]. Next we introduce a random variable 𝜉∼ (0, 𝐼𝐷+1), which is equivalent to ℎ𝜉∼ (0, ℎ2𝐼𝐷+1). Then the above expectation can be calculated by computing the expectation with respect to the variable 𝜉. Let us write 𝜉as 𝜉=(𝜉1, 𝝃2), where 𝜉1 ∈ℝ is for the parameter 𝑎while 𝝃2 ∈ℝ𝐷is for the parameter 𝝎. Therefore, the above expectation can be written as 𝑓(𝐱; ̃𝜋)= 1 𝑚 𝑚∑ 𝑘=1 𝔼(𝜉1,𝝃2)[(𝑎𝑘+ℎ𝜉1)𝜎((𝝎𝑘+ℎ𝝃2)𝑇𝐱)]. By using a similar argument as that for the PM approach, we obtain the following system 𝑑𝜃𝑘 𝑑𝑡=𝑣(̃𝜋,𝜃𝑘)=−𝛿(𝜃1,...,𝜃𝑚;𝜉) 𝛿𝜃𝑘 , (11) where (𝜃1, ..., 𝜃𝑚; 𝜉)is the approximation of the energy functional (1)by using (10). This gives 𝑑𝑎𝑘 𝑑𝑡=−𝔼𝝃2[𝛿(𝝃2) 𝛿𝑎𝑘 ]=− 𝔼𝝃2[𝔼𝐱[(𝑓(𝐱; ̃𝜋)−𝑓∗(𝐱))𝜎(𝝎𝑇 𝑘𝐱+ℎ𝝃𝑇 2 𝐱)]], 𝑑𝝎𝑘 𝑑𝑡=−𝔼(𝜉1,𝝃2)[𝛿(𝜉1, 𝝃2) 𝛿𝝎𝑘 ] =−𝔼(𝜉1,𝝃2)[𝔼𝐱[(𝑓(𝐱; ̃𝜋)−𝑓∗(𝐱))(𝑎𝑘+ℎ𝜉1)𝜎′(𝝎𝑇 𝑘𝐱+ℎ𝝃𝑇 2 𝐱)𝐱]]. (12) For the implementation, we employ the Monte Carlo method for the numerical integration to approximate the expectation with respect to 𝜉in the above equation. By generating a series of random variables {𝜉𝑖}𝐽 𝑖=1 ∼ (0, 𝐼𝐷+1), and using them to calculate the expectation 𝐽times (in this work, we take 𝐽=10), we use the obtained average to compute gradients and then update parameters. In summary, the SPM algorithm can be implemented as follows: Journal of Computational Physics 505 (2024) 112911 5 Z.Ma,Z.MaoandJ.Shen Algorithm 1 Smoothed Particle Method. Input: 𝜃0 Output: 𝜃𝑁 1: for 𝑛 =0, 1, ..., 𝑁−1 do 2: Generate {𝜉𝑗}𝐽 𝑗=1 ∼ (0, 𝐼𝐷+1) 3: for 𝑗=1, 2, ..., 𝐽do 4: Calculate 𝐿𝑗= (𝐱, 𝜃𝑛, 𝜉𝑗) 5: end for 6: 𝐿𝑜𝑠𝑠 = 1 𝐽 ∑𝐽 𝑗=1𝐿𝑗 7: Use the Loss to renew 𝜃𝑛+1 8: end for 9: return 𝜃𝑁 2.2. Time discretization for the gradient flow We now consider the time discretization for the ODE systems (8)a n d (11). We write systems (8)a n d (11) into the following unified form 𝑑𝜃 𝑑𝑡=−𝛿(𝜃) 𝛿𝜃∶=− (𝜃), (13) where 𝜃=[𝜃1, … , 𝜃𝑚]𝑇. Due to the nonlinear activate functions in the neural network approximation, the resulting system is usually a complex nonlinear system. Taking the inner product of (13)with 𝜃𝑡, we obtain the energy dissipation law 𝑑 𝑑𝑡(𝜃)= (𝛿(𝜃) 𝛿𝜃,𝜃𝑡 ) =−‖𝜃𝑡‖2 ≤0, where (⋅, ⋅)and ‖ ⋅ ‖denote the standard discrete 𝐿2 inner product and the corresponding norm, respectively. However, the commonly used GD method and its variants usually do not ensure energy diminishing, and may not converge if the time step (i.e., the learning rate) is too large. Thus, inspired by the SAV method for the gradient flow [34], and encouraged by its success for optimization problems [20], we shall employ several SAV-based algorithms which enjoy an energy dissipation law at the discrete level. 2.2.1. SAV-based algorithms We first recall the vanilla SAV method. The SAV method is a popular numerical method in dealing with complex gradient flow systems proposed in [34]s i n c e it is easy to design efficient and energy stable schemes for gradient flows. In order to improve the performance (e.g., the efficiency and the stability) of the SAV method, we introduce a linear semi positive-definite operator to the system (13): 𝑑𝜃 𝑑𝑡+ (𝜃)+ (𝜃)−(𝜃)=0 . (14) For example, we can take (𝜃) =𝜆(−Δ)𝑘𝜃, where 𝜆, 𝑘 ≥0are given constants. We then introduce a scalar auxiliary variable (SAV) 𝑟(𝑡)= √ (𝜃)+ 𝐶, (15) where 𝐶is a constant to ensure that (𝜃) +𝐶≥0, and expand the system (14)into the following system: 𝑑𝜃 𝑑𝑡+ (𝜃)+ 𝑟√ (𝜃)+ 𝐶 (𝜃)−(𝜃)=0 , (16a) 𝑑𝑟 𝑑𝑡= 1 2 √ (𝜃)+ 𝐶 ( (𝜃),𝑑𝜃 𝑑𝑡 ) . (16b) With 𝑟(0) = √ (𝜃|𝑡=0)+ 𝐶, it is obvious that the solution of (14)is also a solution of the above system. We then discretize the above system with the following first order scheme: 𝜃𝑛+1 −𝜃𝑛 Δ𝑡 + (𝜃𝑛+1)+ (𝜃𝑛)√ (𝜃𝑛)+ 𝐶 𝑟𝑛+1 −(𝜃𝑛)=0 , (17a) 𝑟𝑛+1 −𝑟𝑛 Δ𝑡 = 1 2 √ (𝜃𝑛)+ 𝐶 ( (𝜃𝑛),𝜃𝑛+1 −𝜃𝑛 Δ𝑡 ) . (17b) Taking the 𝐿2 inner product for (17a)with 𝜃𝑛+1 −𝜃𝑛and multiplying 2Δ𝑡𝑟𝑛+1 on both sides of (17b), summing up the results, we can easily prove the following: Theorem 1. The scheme (17)is unconditionally energy stable in the following sense with a modified energy: ∀ Δ𝑡 >0, we have (𝑟𝑛+1) 2 −(𝑟𝑛)2 =−((𝜃𝑛+1 −𝜃𝑛),𝜃𝑛+1 −𝜃𝑛)−(𝑟𝑛+1 −𝑟𝑛) 2 −‖𝜃𝑛+1 −𝜃𝑛‖2 Δ𝑡 ≤0. (18) Journal of Computational Physics 505 (2024) 112911 6 Z.Ma,Z.MaoandJ.Shen The scheme (17)can be easily and efficiently implemented as follows: Letting 𝜃𝑛+1 =𝜃𝑛+1,1 +𝑟𝑛+1𝜃𝑛+1,2, (19) we have that (17a)is equivalent to the following two decoupled equations: 𝜃𝑛+1,1 Δ𝑡+ (𝜃𝑛+1,1)= 𝜃𝑛 Δ𝑡+ (𝜃𝑛), 𝜃𝑛+1,2 Δ𝑡+ (𝜃𝑛+1,2)=− (𝜃𝑛)√ (𝜃𝑛)+ 𝐶 , from which we derive 𝜃𝑛+1,1 =𝜃𝑛,𝜃𝑛+1,2 =− Δ𝑡√ (𝜃𝑛)+ 𝐶 (𝐼+Δ𝑡)−1 (𝜃𝑛). Then we substitute the above equations into (17b)to get 𝑟𝑛+1 = 𝑟𝑛 1+Δ𝑡( (𝜃𝑛),(𝐼+Δ𝑡)−1 (𝜃𝑛)) 2((𝜃𝑛)+𝐶) . (20) Now we obtain 𝜃𝑛+1 in view of (19). We summarize the SAV method in Algorithm2. Algorithm 2 SAV scheme. Input: 𝜃0, Δ𝑡, 𝑟0 = √ (𝜃0)+ 𝐶 Output: 𝜃𝑁 1: for 𝑛 =0, 1, ..., 𝑁−1 do 2: 𝜃𝑛+1,1 =𝜃𝑛 3: 𝜃𝑛+1,2 =− Δ𝑡√ (𝜃𝑛)+𝐶(𝐼+Δ𝑡)−1 (𝜃𝑛) 4: 𝑟𝑛+1 = 𝑟𝑛 1+Δ𝑡( (𝜃𝑛),(𝐼+Δ𝑡)−1 (𝜃𝑛)) 2((𝜃𝑛)+𝐶) 5: 𝜃𝑛+1 =𝜃𝑛+1,1 +𝑟𝑛+1𝜃𝑛+1,2 6: end for 7: return 𝜃𝑁 2.2.2. Restart SAV method Theorem 1 states that the modified energy (𝑟𝑛)2 is unconditionally stable. However, for the vanilla SAV, the computed 𝑟𝑛may not be a good approximation of 𝑟(𝑡𝑛). For instance, 𝑟𝑛may go to 0 rapidly if Δ𝑡or ( (𝜃𝑛),(𝐼+Δ𝑡)−1 (𝜃𝑛)) 2((𝜃𝑛)+𝐶) is too big. Therefore, we may lose accuracy and even obtain a wrong steady state solution. The main reason for this is that 𝑟𝑛is not directly linked to 𝑟(𝑡𝑛). To resolve this issue, a simple idea is to introduce ̂𝑟𝑛∶=𝑟(𝜃𝑛)= √ (𝜃𝑛)+ 𝐶 directly according to the definition, and renew 𝑟𝑛+1 using 𝑟𝑛+1 = ̂𝑟𝑛 1+Δ𝑡( (𝜃𝑛),(𝐼+Δ𝑡𝑛)−1 (𝜃𝑛)) 2((𝜃𝑛)+𝐶) instead of using (20). We call this algorithm as Restart SAV (ResSAV) and state it in Algorithm3. Algorithm 3 Restart SAV scheme. Input: 𝜃0, Δ𝑡 Output: 𝜃𝑁 1: for 𝑛 =0, 1, ..., 𝑁−1 do 2: ̂𝑟𝑛= √ (𝜃𝑛)+ 𝐶 3: 𝜃𝑛+1,1 =𝜃𝑛 4: 𝜃𝑛+1,2 =− Δ𝑡√ (𝜃𝑛)+𝐶(𝐼+Δ𝑡)−1 (𝜃𝑛) 5: 𝑟𝑛+1 = ̂𝑟𝑛 1+Δ𝑡( (𝜃𝑛),(𝐼+Δ𝑡)−1 (𝜃𝑛)) 2((𝜃𝑛)+𝐶) 6: 𝜃𝑛+1 =𝜃𝑛+1,1 +𝑟𝑛+1𝜃𝑛+1,2 7: end for 8: return 𝜃𝑁 Journal of Computational Physics 505 (2024) 112911 7 Z.Ma,Z.MaoandJ.Shen 2.2.3. Relaxed SAV method The restart SAV usually performs better than the vanilla SAV, however, it no longer guarantees an energy dissipation law. Therefore, we adopt the idea of relaxed SAV proposed in [35]that enjoys the energy dissipation law and, at the same time, links 𝑟𝑛 directly to 𝑟(𝑡𝑛). Specifically, we employ the relaxation technique to update 𝑟𝑛+1 by using a linear combination of the value computed by using (20)(here we denote it by ̃𝑟𝑛+1) and the value of ̂𝑟𝑛+1 given by ̂𝑟𝑛+1 ∶= √ (𝜃𝑛+1)+ 𝐶, (21) leading to the following relaxed SAV method 𝜃𝑛+1 −𝜃𝑛 Δ𝑡 + (𝜃𝑛+1)+ (𝜃𝑛)√ (𝜃𝑛)+ 𝐶 ̃𝑟𝑛+1 −(𝜃𝑛)=0 , (22a) ̃𝑟𝑛+1 −𝑟𝑛 Δ𝑡 = 1 2 √ (𝜃𝑛)+ 𝐶 ( (𝜃𝑛),𝜃𝑛+1 −𝜃𝑛 Δ𝑡 ) , (22b) 𝑟𝑛+1 =𝜉0̃𝑟𝑛+1 +(1−𝜉0)̂𝑟𝑛+1, (22c) where 𝜉0 is determined by solving the following optimization problem 𝜉0 =m i n 𝜉∈[0,1] 𝜉, 𝑠.𝑡.(𝑟𝑛+1)2 −(̃𝑟𝑛+1)2 ≤𝜂‖𝜃𝑛+1 −𝜃𝑛‖2 Δ𝑡 . (23) Here 𝜂∈[0, 1]is an artificial parameter with a default value of 0.99. It has been shown in [35]t h a t the relaxation parameter 𝜉0 is given by 𝜉0 =max { 0, −𝑏− √ 𝑏2 −4𝑎𝑐 2𝑎 } , (24) where the coefficients are given by 𝑎=(̃𝑟𝑛+1 −̂𝑟𝑛+1) 2 ,𝑏 =2 ̂𝑟𝑛+1(̃𝑟𝑛+1 −̂𝑟𝑛+1), 𝑐=( ̂𝑟𝑛+1) 2 −(̃𝑟𝑛+1) 2 −𝜂‖𝜃𝑛+1 −𝜃𝑛‖2 Δ𝑡 . By using (18)with 𝑟𝑛+1 replaced by ̃𝑟𝑛+1 and (23), we have immediately the following: Theorem 2. The relaxed SAV scheme (22)is unconditionally energy stablein the sense that (𝑟𝑛+1)2 −(𝑟𝑛)2 =−((𝜃𝑛+1 −𝜃𝑛),𝜃𝑛+1 −𝜃𝑛)−(̃𝑟𝑛+1 −𝑟𝑛) 2 −(1−𝜂) ‖𝜃𝑛+1 −𝜃𝑛‖2 Δ𝑡 ≤0. The relaxed SAV scheme can be implemented as follows: Algorithm 4 Relaxed SAV scheme. Input: 𝜃0 𝑘, Δ𝑡, 𝑟0 = √ (𝜃0)+ 𝐶 Output: 𝜃𝑁 1: for 𝑛 =0, 1, ..., 𝑁−1 do 2: Obtain 𝜃𝑛+1 and ̃𝑟𝑛+1 by using Algorithm2 3: ̂𝑟𝑛+1 = √ (𝜃𝑛+1)+ 𝐶 4: 𝑎 =( ̃𝑟𝑛+1 −̂𝑟𝑛+1) 2 5: 𝑏 =2 ̂𝑟𝑛+1(̃𝑟𝑛+1 −̂𝑟𝑛+1) 6: 𝑐=( ̂𝑟𝑛+1) 2 −(̃𝑟𝑛+1) 2 −𝜂‖𝜃𝑛+1−𝜃𝑛‖2 Δ𝑡 7: 𝜉0 =𝑚𝑎𝑥{0, −𝑏− √ 𝑏2−4𝑎𝑐 2𝑎 } 8: 𝑟𝑛+1 =𝜉0̃𝑟𝑛+1 +(1 −𝜉0)̂𝑟𝑛+1 9: end for 10: return 𝜃𝑁 2.2.4. Adaptive SAV methods When solving complex nonlinear PDEs, the adaptive time step is usually used to improve the efficiency and accuracy. In particular for optimizing algorithms in deep learning, one of the most commonly used methods is the Adam method [18], which can be seen as a GD-based algorithm that uses a modified learning rate and gradient to update parameters. We now propose an adaptive version Journal of Computational Physics 505 (2024) 112911 8 Z.Ma,Z.MaoandJ.Shen Table 1 Notations of parameters. #ofneurons 𝑚 #ofdata 𝑀 Dimensionoftheproblem 𝐷 batchsize 𝑙 SAVconstant 𝐶 Coefficientforthelinearoperator 𝜆 for the SAV schemes based on the Adam algorithm. More precisely, we use the Adam algorithm (3)-(4)to update the time step and the nonlinear term, and then substitute them into the corresponding SAV methods to update the parameters, i.e.: •S t e p 1: Compute ̂ (𝜃𝑛)and ̂Δ𝑡using the adaptive strategy of the Adam method; •S t e p 2: Use the adaptive corrective terms to update 𝜃𝑛+1 using SAV-based schemes. We denote these adaptive SAV schemes as A-SAV, A-ResSAV and A-RelSAV corresponding to the vanilla SAV, the restart SAV and the relaxed SAV, respectively. The details for the adaptive implementation are given as follows: Algorithm 5 The adaptive SAV scheme. Input: 𝜃0, Δ𝑡, 𝑟0, 𝜖=1𝑒 −8, 𝛽1 =0.9, 𝛽2 =0.999, 𝑚0 =0, 𝑣0 =0 Output: 𝜃𝑁 1: for 𝑛 =0, 1, ..., 𝑁−1 do 2: 𝑚𝑛+1 =𝛽1𝑚𝑛+(1 −𝛽1) (𝜃𝑛) 3: 𝑣𝑛+1 =𝛽2𝑣𝑛+(1 −𝛽2)‖ (𝜃𝑛)‖2 4: ̂𝑚𝑛+1 = 𝑚𝑛+1 1−(𝛽1)𝑛+1 5: ̂𝑣𝑛+1 = 𝑣𝑛+1 1−(𝛽2)𝑛+1 6: ̂ (𝜃𝑛) = ̂𝑚𝑛+1 7: ̂Δ𝑡= Δ𝑡√ ̂𝑣𝑛+1+𝜖 8: update 𝜃𝑛+1 by using Algorithm2, 3and 4, respectively 9: end for 10: return 𝜃𝑁 3. Numerical results In this section, we present several numerical examples, including three regression problems as well as a classification problem to illustrate the effectiveness of the present methods. In all numerical examples, we use “ReLU” as the activate function if not mentioned. We use PM-Euler to denote the PM with the forward Euler scheme, and PM-SAV to denote the PM with the SAV scheme, likewise for PM-ResSAV, PM-RelSAV, SPM-Euler, SPM-SAV, SPM-ResSAV, SPM-RelSAV. We also use SPM-A-SAV to denote the adaptive version of SPM-SAV, and similar notations are used for other methods. We point out here that the PM-Euler is actually the GD method or the SGD method if the mini-batch technique is used. Namely, the PM-Euler method is equivalent to the GD method, or the SGD method if the mini-batch technique is used. Numerical results show that the results obtained by using the SPM-Euler method are almost the same as or a little better than the ones obtained by using the PM-Euler method, see the result in Fig.2. Similarly, the results obtained by using the SPM-A-Euler method are almostsame as or a little better than the ones obtained by using the PM-A-Euler method, which is actually the Adam method, one of the most popularly used optimization method in deep learning. For the learning rate, we use either the time step Δ𝑡or the notation 𝑙𝑟. In all numerical tests, we take the linear semi positive-definite operator to be (𝜃) =𝜆𝜃 with a suitable 𝜆 ≥0. For the sake of convenience, we also list some other frequently used parameters in Table1. 3.1. Regression problem We first consider the regression problem. Note that before calculation, we process data with the Z-score normalization 𝐱 ⇒ 𝐱−𝜇 𝜎 , where 𝜇, 𝜎are the mean and standard deviation of the data, respectively, and then take the relative error as the loss function. For each case, we use 80%of the data for training while use the other 20%of the data for testing. 3.1.1. Example1 Example 1. Consider the following target function: 𝑓∗(𝑥1,...,𝑥𝐷)=sin ( 𝐷∑ 𝑖=1 𝑝𝑖𝑥𝑖 ) +cos ( 𝐷∑ 𝑖=1 𝑞𝑖𝑥𝑖 ) , (25) Journal of Computational Physics 505 (2024) 112911 9 Z.Ma,Z.MaoandJ.Shen Fig. 1.Example1: Train loss (left) and test loss (right) using the full batch of data. Upper: PM method, lower: SPM method. Other parameters are set as 𝑚 =1000, 𝑀= 10000, 𝑙=8000, 𝑙𝑟 =0.6, 𝐶=1, 𝜆 =10. where {𝑝𝑖,𝑞𝑖}1≤𝑖≤𝐷are given coefficients, 𝐷is the dimension. We generate a random data set {𝐱𝑗,𝑓∗ 𝑗}1≤𝑗≤𝑀, where 𝐱𝑗∈(0, 1)𝐷. We begin by verifying the theoretical results given in Theorems1and 2, i.e., the discrete energy dissipation law, with full batch of training data. To this end, we employ both PM and SPM methods with or without SAV/Relaxed SAV schemes for a 20D problem using 𝑀=10000 data. The learning rate, i.e., the time step, is set to be 0.6, and other parameters for the SAV scheme are 𝐶=1, 𝜆 =10. If not otherwise specified, the parameters for the smoothed particle method are set to be ℎ =0.0001, 𝐽=10. The results are shown in Fig.1. We observe that the train and test losses obtained by using the SAV method or the relaxed SAV method decay asymptotically. This is in agreement with Theorem 1 and 2. However, we observe oscillations for the result obtained without using SAV-based methods. As mentioned before, it is usually computationally expansive to use full data. Therefore, we shall employ the stochastic version of SAV-based methods, i.e., utilize the mini-batch technique as in SGD. Hereafter, if not otherwise specified, we use the stochastic SAV-based methods in all following numerical tests. To demonstrate the effectiveness of the SPM method, we show numerical results in Fig. 2 for Example 1 with 𝐷=4 0, 𝑀= 10000, 𝑚 = 1000by comparing the accuracy between the results obtained by using PM-based methods and the ones obtained by using SPM-based methods. The batch size used here is 𝑙=64, and the other parameters are set as follows: 𝐶=1, 𝜆 =4. Observe that we obtain higher (but not significantly improved) accuracy with SPM-based methods compared with PM-based methods. We also test different sets of data with different numbers and different dimensions showing a similar result. One of our future works is to develop a highly accurate space discretization method. Next, we show how the SAV-based schemes improve the efficiency and stability of the training process. Consider Example1with 𝐷=40, 𝑚 =1000, 𝑀=100000. We implement both PM and SPM methods, and the behaviors for both methods are almost the same. Thus, we only show the result with the SPM method. The train and test losses using different types of SAV-based methods with different (fixed) learning rates are shown in Fig.3. The result obtained by using SGD with a default learning rate 0.01 is presented as the baseline. We observe that all results obtained with the three SAV-based schemes (i.e., the vanilla SAV, the restart SAV and the relaxed SAV) are almost the same. For the case of 𝑙𝑟 =0.5, it shows that the test loss using SAV-based methods is about 2 orders of magnitude higher than that using the Euler scheme. For the case of 𝑙𝑟 =1, the test loss using SAV-based schemes is almost the same as the case of 𝑙𝑟 =0.5while the solution obtained by using the SPM-Euler method even does not converge. This also indicates that Journal of Computational Physics 505 (2024) 112911 10 Z.Ma,Z.MaoandJ.Shen Fig. 2. Example1:Trainloss(left)andthetestloss(right)for 40𝐷.Otherparametersaresetas: 𝑚=1000,𝑀 =10000,𝑙=64,𝑙𝑟=0.2,𝐶=1,𝜆=0.c. Fig. 3.Example1: Train loss (left) and the test loss (right) with different fixed learning rate. Upper: 𝑙𝑟 =0.5, lower: 𝑙𝑟 =1. Other parameters are set as: 𝑚 =1000, 𝑀= 100000, 𝑙=256, 𝐶=100, 𝜆 =4. the training process is stable by using the SAV-based methods with respect to the learning rate. Furthermore, we observe that all obtained results are much better than those obtained by using SPM-Euler with the default learning rate (𝑙𝑟 =0.01). The fixed learning rate for each case is used in the above tests. Next we consider the case of using the adaptive learning rate. More precisely, we solve the above problem by combining the SAV-based schemes and the adaptive strategy used in Adam algorithm, see Algorithm5for more details. We show in Fig.4the comparison of the results between the SAV-based methods and non-SAV-based method for different initial learning rates (𝑙𝑟 =0.01and 𝑙𝑟 =1). We also present the result obtained by using the Adam method with the default initial learning rate 𝑙𝑟 =0.001 as the baseline. Again, the accuracy using SAV-based methods is much better than that using a non-SAV-based scheme with the same (big) initial learning rate, and even slightly better than that using Adam with a small Journal of Computational Physics 505 (2024) 112911 11 Z.Ma,Z.MaoandJ.Shen Fig. 4. Example1: Train loss (left) and the test loss (right) with different initial learning rate for adaptive method. Upper: 𝑙𝑟 =0.01, lower: 𝑙𝑟 =1. Other parameters are set as:: 𝑚 =1000, 𝑀=100000, 𝑙=256, 𝐶=100, 𝜆 =4. initial learning rate (i.e., the default case). It also converges much faster than the default case, i.e., the case of using Adam method with the initial learning rate 𝑙𝑟 =0.001. Moreover, even with an adaptive learning rate, we cannot obtain a convergent solution with a relatively big initial learning rate (e.g., 𝑙𝑟 =1) with the non-SAV based schemes. On the other hand, we observe that the accuracy by using SAV-based schemes with an adaptive learning rate is more or less the same as that by using a fixed learning rate, i.e., the advantage of adaptive learning rate is not significant for this example. However, as we will see in the next example that the adaptive learning rate is necessary to improve the efficiency for more complex problems. We also investigate the influence of the coefficient 𝜆of the linear operator for the SAV-based schemes. As we mentioned pre- viously, the vanilla SAV scheme may give a wrong solution. We first employ the SPM method and SAV scheme with 𝑙𝑟 =0.5 and different values of 𝜆 =0, 1, 4, 10. The train and test losses are shown in Fig. 5 showing that 𝜆 =4 gives the best result for the SAV scheme. We also employ the SPM method with restart and relaxed SAV methods with different values of 𝜆. Numerical results show that the parameter 𝜆just weakly affects the restart and relaxed SAV methods. We further demonstrate this by plotting the value of 1 −𝑞𝑛, where 𝑞𝑛= 𝑟𝑛 ̂𝑟𝑛, for 𝜆 =0, 4and the three SAV-based schemes in Fig.6. The ratio 𝑞𝑛(or 1 −𝑞𝑛) should be an approximation of 1 (or 0). We observe that 1 −𝑞𝑛≈0.6for the case of SAV with 𝜆 =0 while 1 −𝑞𝑛≈0for the other cases. 3.1.2. Example2 For Example 1, we obtained similar accuracy when using fixed and adaptive learning rates. Particularly, we obtained high accuracy solutions as well as efficient and stable training processes in both cases. Now we show in the next example the advantage of using the adaptive learning rate. Example 2. Let us consider the following quadratic function: 𝑓∗(𝑥1,...,𝑥𝐷)= 𝐷∑ 𝑖=1 𝑐𝑖𝑥2 𝑖, (26) Journal of Computational Physics 505 (2024) 112911 12 Z.Ma,Z.MaoandJ.Shen Fig. 5.Example1: Train loss (left) and test loss (right) with different values of the coefficient 𝜆. Other parameters are 𝑚 =1000, 𝑀=100000, 𝑙=256, 𝑙𝑟 =0.5, 𝐶=100. Fig. 6. Example1: The values of 1 −𝑞for SAV, ResSAV and RelSAV methods with different values of the parameter 𝜆. Left: 𝜆 =0, right: 𝜆 =4. Other parameters are: 𝑚 =1000, 𝑀=100000, 𝑙=256, 𝑙𝑟 =0.5, 𝐶=10. Fig. 7. Example2:Trainloss(left)andthetestloss(right)forthe40D.Otherparametersaresetas: 𝑚=100,𝑀 =10000,𝑙=64,𝑙𝑟=0.01,𝐶=1,𝜆=0. where 𝑥 ∈[0, 5]𝐷, {𝑐𝑖}1≤𝑖≤𝐷is a set of preset coefficients. We first compare the accuracy of the solutions between the PM method and the SPM method by considering Example 2 with 𝐷=4 0, 𝑚 =100, 𝑀= 10000, 𝑙=6 4, 𝑙𝑟 =0.01, 𝐶=1, 𝜆 =0. Again, the result obtained by using the SPM method is slightly better than the one obtained by using the PM method(see Fig.7). Journal of Computational Physics 505 (2024) 112911 13 Z.Ma,Z.MaoandJ.Shen Fig. 8. Example 2: Train loss (left) and the test loss (right) with different fixed learning rate: 𝑙𝑟 =0.4 (upper), 1 (lower). Other parameters are set as: 𝑚 =100, 𝑀= 10000, 𝑙=64, 𝐶=1, 𝜆 =4. We then employ the present SPM method with different time stepping schemes using the fixed learning rate for Example2with 𝐷=40, 𝑚 =100 𝑀=1000, 𝐶=1, 𝜆 =4. The result of train and test losses for different learning rates (𝑙𝑟 =0.4, 1) is shown in Fig.8. The result using the SPM method with the forward Euler scheme with a default learning rate 𝑙𝑟 =0.01is used as a benchmark. For the SPM method with the forward Euler scheme using a large learning rate, the solutions do not converge. However, we always obtain convergent solution by using the SAV-based schemes. Nevertheless, unlike in the case of Example 1, we observe in the current case that we lose about one order of magnitude on accuracy for the solution using the SAV-based schemes with a large fixed learning rate, compared with the solution using 𝑙𝑟 =0.01. This prevents us to use a large learning rate to obtain high accurate solutions. To resolve the aforementioned issue, we need to use the adaptive learning rate. We next employ the adaptive algorithms using the Adam strategy and SAV-based schemes, similarly as in the previous example. The results with different initial learning rates (𝑙𝑟 =0.1, 1) are presented in Fig. 9. The result using the adaptive SPM-Euler with a default initial learning rate 𝑙𝑟 =0.001 is also presented as the benchmark. Again, we observe that the accuracy of the solution using SAV-based schemes is better than that using the non-SAV schemes. Moreover, unlike the case with fixed learning rates, here the accuracy of the solution using adaptive SAV-based schemes is almost the same as that in the benchmark (i.e., the case using the Adam method with initial learning rate 𝑙𝑟 =0.001). Moreover, if we take a look at the left bottom of the plots, we observe that the SAV-based schemes with a big initial learning rate converge fasterwhen compared with the benchmark. 3.1.3. Example3 We now consider a more difficult regression problem. Example 3. Consider the following target function, 𝑓∗(𝐱)= 𝑒−10‖𝐱‖2, 𝐱=(𝑥1,...,𝑥𝐷), (27) which is a high dimensional Gaussian function with steep gradients near the origin. Journal of Computational Physics 505 (2024) 112911 14 Z.Ma,Z.MaoandJ.Shen Fig. 9. Example2: Train loss (left) and the test loss (right) with different initial learning rates for adaptive method: 𝑙𝑟 =0.1 (upper), 0.1 (lower). Other parameters are set as: 𝑚 =100, 𝑀=10000, 𝑙=64, 𝐶=1, 𝜆 =4. Since the target function is very sharp near the origin, we use a nonuniform distributed data set, namely, we randomly generate 100000 data with {𝐱}∼ (0, 0.2). Other parameters are given as follows: 𝑚 = 10000, ℎ =0.000001. The batch size is 𝑙= 256. We show in Fig. 10 the result using SPM method with the relaxed SAV scheme and the non-SAV scheme, and employ both fixed and adaptive learning rates by setting the (initial) learning rate to be 𝑙𝑟 =1. Again, the result using adaptive SPM-Euler method, Adagrad, RMSprop with the default learning rate 𝑙𝑟 =0.001 are presented for comparison. It shows that the relaxed SAV scheme is more efficient and stable than the Euler method with either the fixed learning rate or the adaptive learning rate. In addition, the solution using relaxed SAV with the adaptive learning rate has better accuracy and a much faster convergence than adaptive SPM-Euler with the default initial learning rate. This means that the adaptive relaxed SAV approach is more efficient that the Adam approach. 3.2. Classification problem Example 4. We consider in this subsection the classification problem, i.e., the MNIST (Mixed National Institute of Standards and Technology) problem [36], whose dataset is a large-scale handwritten digit database collected by the National Institute of Standards and Technology, containing a training set of 60000 samples and a test set of 10000 samples. The results on the accuracy, train loss and test loss using different methods are shown in Fig. 11. We observe that there is no obvious difference between the four algorithms. This is because classification problems do not require as high precision as regression problems, We only need to approximate the label with about 10% of accuracy to get the correct classification. Nevertheless, the accuracy of the SPM method is still slightly better than the PM method. Also, the train loss using relaxed SAV method is slightly better than the one using a non-SAV method. 3.3. Solving partial differential equations Besides the function approximation problems, we also consider in this subsection solving PDEs using the neural network-based method with the present SAV-based optimization methods. Journal of Computational Physics 505 (2024) 112911 15 Z.Ma,Z.MaoandJ.Shen Fig. 10.Example3: Train loss (left) and the test loss (right) between the results obtained by using Euler, RelSAV, A-Euler and A-RelSAV, as well as two other popularly used adaptive methods (i.e., Adagrad and RMSprop with default learning rate 0.001). Other parameters are set as: 𝑚 =10000, 𝑀=100000, 𝑙=256, 𝐶=100, 𝜆 =4. Fig. 11. Example4(classificationproblem):(a)SampleimagesfromMNISTtestdataset.(b)Accuracy.(c)Trainloss.(d)Testloss. Example 5. Consider the following burgers equation: ⎧ ⎪ ⎨ ⎪⎩ 𝑢𝑡+𝑢𝑢𝑥=𝜈𝑢𝑥𝑥,𝑥∈(−1,1),𝑡∈(0,𝑇], 𝑢(𝑥,0)=−sin 𝜋𝑥,𝑥∈(−1,1), 𝑢(−1,𝑡)= 𝑢(1,𝑡)=0 ,𝑡∈[0,𝑇], (28) where 𝜈=0.01∕𝜋and 𝑇=1. Here we adopt PINNs to solve the above equation and use 𝑡𝑎𝑛ℎas the activate function. We use 200 ×60 equally distributed residual points for 𝑥 ×𝑡domain. Since the expressive ability of the single hidden layer neural network is too weak Journal of Computational Physics 505 (2024) 112911 16 Z.Ma,Z.MaoandJ.Shen Fig. 12. Example5Testlossesobtainedbydifferentoptimizers.(a) 𝑙𝑟=0.01.(b) 𝑙𝑟=0.001.Otherparametersaresetas 𝐶=10000, 𝜆=4. to solve the above Burgers equation, thus we use a neural network with 5 hidden layers and 32 neurons for each layer. Furthermore, we use PM approach in the case since we do not have a continuous PDE form like (6). We compare the test errors between the ones obtained by using the present adaptive SAV-based methods and the ones obtained by using several popularly used adaptive optimization methods (i.e., Adagrad, RMSprop and Adam) in Fig. 12 for 𝑙𝑟 =0.01 and 𝑙𝑟 =0.001, respectively. Observe that the present adaptive SAV-based methods enjoy superior efficiency and accuracy. Furthermore, for a big learning rate (𝑙𝑟 =0.01), the results of Adagrad and RMSprop even do not converge. 4. Conclusion and discussion We considered in this paper efficient and stable numerical methods for solving gradient flows arising from deep learning. For the space discretization, we implemented both particle method (PM) and smoothed particle method (SPM), and showed that the SPM is slightly better than the PM in terms of accuracy. For the time discretization, we adopted several efficient SAV-based time stepping schemes, and developed their adaptive version by applying the adaptive strategy used in Adam. Numerical results show that the SAV-based schemes significantly improve the efficiency and robustness of the training process and the accuracy of the solution when using large learning rates by comparing with the SGD method or the Adam method. When compared with the Adam method with a small learning rate, we obtain in most cases much more accurate solutions with much higher efficiency by the proposed methods. In the present work, we mainly considered the function approximation problem by only one-hidden layer neural network. How- ever, the proposed methods can be extended to the multi-layer neural network and different architectures of neural networks, see Example5. We shall consider extending the proposed methods to different problems, for instance, solving more complex PDEs, with different neural network architectures in a future work. CRediT authorship contribution statement Ziqi Ma: Data curation, Investigation, Methodology, Visualization, Writing – original draft, Writing – review & editing. Zhip- ing Mao: Conceptualization, Data curation, Funding acquisition, Investigation, Methodology, Project administration, Supervision, Writing – original draft, Writing – review & editing. Jie Shen:Conceptualization, Funding acquisition, Investigation, Methodology, Project administration, Supervision, Writing – original draft, Writing – review & editing. Declaration of competing interest The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper. Data availability Data will be made available on request. Acknowledgement This work is supported by the National Key R&D Program of China under Grant No. 2022YFA1004500 and the National Natural Science Foundation of China under Grant No. 12171404 and No. 12371409. Journal of Computational Physics 505 (2024) 112911 17 Z.Ma,Z.MaoandJ.Shen References [1] A. Krizhevsky, I. Sutskever, G.E. Hinton, Imagenet classification with deep convolutional neural networks, Commun. ACM 60 (2017) 84–90. [2] J. Long, E. Shelhamer, T. Darrell, Fully convolutional networks for semantic segmentation, in: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2015, pp.3431–3440. [3] T. Mikolov, M. Karafiát, L. Burget, J. Cernock`y, S. Khudanpur, Recurrent neural network based language model, in: Interspeech, Volume 2, Makuhari, 2010, pp.1045–1048. [4] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, Y. Bengio, Generative adversarial networks, Commun. ACM 63 (2020) 139–144. [5] M. Raissi, P. Perdikaris, G.E. Karniadakis, Physics-informed neural networks: a deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations, J. Comput. Phys. 378 (2019) 686–707. [6] L. Lu, P. Jin, G. Pang, Z. Zhang, G.E. Karniadakis, Learning nonlinear operators via deeponet based on the universal approximation theorem of operators, Nat. Mach. Intell. 3 (2021) 218–229. [7] S. Liang, S.W. Jiang, J. Harlim, H. Yang, Solving PDEs on unknown manifolds with machine learning, arXiv :2106 .06682[abs], 2021. [8] J. Han, A. Jentzen, W. E, Solving high-dimensional partial differential equations using deep learning, Proc. Natl. Acad. Sci. 115 (2018) 8505–8510. [9] C. Huré, H. Pham, X. Warin, Deep backward schemes for high-dimensional nonlinear PDEs, Math. Comput. 89 (2020) 1547–1579. [10] L. Lu, X. Meng, Z. Mao, G.E. Karniadakis, DeepXDE: a deep learning library for solving differential equations, SIAM Rev. 63 (2021) 208–228. [11] T. Muther, A.K. Dahaghi, F.I. Syed, V. Van Pham, Physical laws meet machine intelligence: current developments and future directions, Artif. Intell. Rev. (2022) 1–67. [12] J. Sirignano, K. Spiliopoulos, DGM: a deep learning algorithm for solving partial differential equations, J. Comput. Phys. 375 (2018) 1339–1364. [13] A. Cauchy, et al., Méthode générale pour la résolution des systemes d’équations simultanées, C. R. Sci. Paris 25 (1847) 536–538. [14] D.E. Rumelhart, G.E. Hinton, R.J. Williams, Learning representations by back-propagating errors, Nature 323 (1986) 533–536. [15] H. Robbins, S. Monro, A stochastic approximation method, Ann. Math. Stat. (1951) 400–407. [16] J. Duchi, E. Hazan, Y. Singer, Adaptive subgradient methods for online learning and stochastic optimization, J. Mach. Learn. Res. 12 (2011). [17] G. Hinton, N. Srivastava, K. Swersky, Neural networks for machine learning lecture 6a overview of mini-batch gradient descent, Cited on 14 (2012) 2. [18] D.P. Kingma, J. Ba Adam, A method for stochastic optimization, arXiv preprint arXiv :1412 .6980, 2014. [19] S. Ruder, An overview of gradient descent optimization algorithms, arXiv preprint arXiv :1609 .04747, 2016. [20] X. Liu, J. Shen, X. Zhang, An efficient and robust SAV based algorithm for discrete gradient systems arising from optimizations, arXiv preprint arXiv :2301 .02942, 2023. [21] R.T. Chen, Y. Rubanova, J. Bettencourt, D.K. Duvenaud, Neural ordinary differential equations, Adv. Neural Inf. Process. Syst. 31 (2018). [22] E. Haber, L. Ruthotto, Stable architectures for deep neural networks, Inverse Probl. 34 (2017) 014004. [23] J. Han, Q. Li, et al., A mean-field optimal control formulation of deep learning, Res. Math. Sci. 6 (2019) 1–41. [24] Q. Li, L. Chen, C. Tai, et al., Maximum principle based algorithms for deep learning, J. Mach. Learn. Res. 18 (2018) 1–29. [25] Y. Lu, A. Zhong, Q. Li, B. Dong, Beyond finite layer neural networks: bridging deep architectures and numerical differential equations, in: International Conference on Machine Learning, PMLR, 2018, pp.3276–3285. [26] C. Ma, L. Wu, et al., Machine learning from a continuous viewpoint, I, Sci. China Math. 63 (2020) 2233–2266. [27] E. Weinan, A proposal on machine learning via dynamical systems, Commun. Math. Stat. 1 (2017) 1–11. [28] A. Barron, Universal approximation bounds for superpositions of a sigmoidal function, IEEE Trans. Inf. Theory 39 (1993) 930–945. [29] G. Cybenko, Approximation by superpositions of a sigmoidal function, Math. Control Signals Syst. 2 (1989) 303–314. [30] K. He, X. Zhang, S. Ren, J. Sun, Deep residual learning for image recognition, in: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2016, pp.770–778. [31] C. Ma, L. Wu, et al., The Barron space and the flow-induced function spaces for neural network models, Constr. Approx. 55 (2022) 369–406. [32] S. Mei, A. Montanari, P.-M. Nguyen, A mean field view of the landscape of two-layer neural networks, Proc. Natl. Acad. Sci. 115 (2018) E7665–E7671. [33] J. Sirignano, K. Spiliopoulos, Mean field analysis of neural networks: a central limit theorem, Stoch. Process. Appl. 130 (2020) 1820–1852. [34] J. Shen, J. Xu, J. Yang, The scalar auxiliary variable (SAV) approach for gradient flows, J. Comput. Phys. 353 (2018) 407–416. [35] M. Jiang, Z. Zhang, J. Zhao, Improving the accuracy and consistency of the scalar auxiliary variable (SAV) method with relaxation, J. Comput. Phys. 456 (2022) 110954. [36] Y. LeCun, L. Bottou, Y. Bengio, P. Haffner, Gradient-based learning applied to document recognition, Proc. IEEE 86 (1998) 2278–2324.
采集于
查看校方原文 ↗