Skip to main content
Proceedings. Mathematical, Physical, and Engineering Sciences logoLink to Proceedings. Mathematical, Physical, and Engineering Sciences
. 2020 Jul 15;476(2239):20200334. doi: 10.1098/rspa.2020.0334

Locally adaptive activation functions with slope recovery for deep and physics-informed neural networks

Ameya D Jagtap 1,†,, Kenji Kawaguchi 2,†,, George Em Karniadakis 1,3,
PMCID: PMC7426042  PMID: 32831616

Abstract

We propose two approaches of locally adaptive activation functions namely, layer-wise and neuron-wise locally adaptive activation functions, which improve the performance of deep and physics-informed neural networks. The local adaptation of activation function is achieved by introducing a scalable parameter in each layer (layer-wise) and for every neuron (neuron-wise) separately, and then optimizing it using a variant of stochastic gradient descent algorithm. In order to further increase the training speed, an activation slope-based slope recovery term is added in the loss function, which further accelerates convergence, thereby reducing the training cost. On the theoretical side, we prove that in the proposed method, the gradient descent algorithms are not attracted to sub-optimal critical points or local minima under practical conditions on the initialization and learning rate, and that the gradient dynamics of the proposed method is not achievable by base methods with any (adaptive) learning rates. We further show that the adaptive activation methods accelerate the convergence by implicitly multiplying conditioning matrices to the gradient of the base method without any explicit computation of the conditioning matrix and the matrix–vector product. The different adaptive activation functions are shown to induce different implicit conditioning matrices. Furthermore, the proposed methods with the slope recovery are shown to accelerate the training process.

Keywords: physics-informed neural networks, machine learning, bad minima, stochastic gradients, accelerated training, deep learning benchmarks

1. Introduction

In the recent years, research on neural networks (NNs) has intensified around the world due to their successful applications in many diverse fields such as speech recognition [1], computer vision [2] and natural language translation [3]. NNs have also been used in the area of scientific computing where they solve partial differential equations (PDEs) due to their ability to effectively approximate complex functions arising in diverse scientific disciplines (cf. Physics-informed Neural Networks (PINNs) by Raissi et al. [4] and references therein). PINNs can accurately solve both direct problems, where the approximate solutions of governing equations are obtained, as well as highly ill-posed inverse problems, where parameters involved in the governing equation are inferred from the training data.

A major drawback of such NN-based models is the slow training/convergence speed, which can adversely affect their performance, especially for solving real-life applications, which require an NN model to run in real-time. Therefore, it is crucial to accelerate the convergence of such models without sacrificing the performance. Highly efficient and adaptable algorithms are important to design the most effective NN, which not only increase the accuracy of the solution but also reduce the training cost. Various architectures of NN like Dropout NN [5] have been proposed in the literature, which can improve the efficiency of the algorithm for specific applications. One of the important features of NN is the activation function, which decides the activation of particular neuron during training process. There is no rule of thumb for the choice of activation function, and in fact it solely depends on the problem at hand. Therefore, in this work, we are particularly focusing on adaptive activation functions, which adapt automatically such that the network can be trained faster. Various methods have been proposed in the literature for adaptive activation function, like the adaptive sigmoidal activation function proposed by Yu et al. [6] for multilayer feedforward NNs. Qian et al. [7] focused on learning activation functions in convolutional NNs by combining basic activation functions in a data-driven way. Multiple activation functions per neuron were proposed by Dushkoff & Ptucha [8], where individual neurons select between a multitude of activation functions. Li et al. [9] proposed a tunable activation function, where only a single hidden layer is used and the activation function is tuned. Shen et al. [10] used a similar idea of tunable activation function but with multiple outputs. Recently, Kunc & Kléma proposed a transformative adaptive activation functions for gene expression inference, see [11]. One such adaptive activation function was proposed by Jagtap et al. [12] by introducing a scalable parameter in the activation function, which can be optimized by using any optimization method. Mathematically, it changes the slope of activation function thereby increasing the learning process by altering the loss landscape of NN, especially during the initial training period. Due to single scalar parameter, we call such adaptive activation functions globally adaptive activations, meaning that it gives an optimized slope for the entire network. One can think of doing such optimization at the local level, where the scalable parameters are introduced hidden layer-wise or even for each neuron in the network. Due to different learning capacity of each hidden-layer, such locally defined activation slopes can further improve the performance of the network. In order to further increase the training speed, an activation slope-based slope recovery term is added in the loss function, which further accelerates convergence.

The rest of the paper is organized as follows. Section 2 presents the methodology of the proposed layer-wise and neuron-wise locally adaptive activations in detail. This also includes a discussion on the slope recovery term, expansion of parametric space due to layer-wise and neuron-wise introduction of additional parameters, and its effect on the overall training cost. In this section, the PINN method is also introduced briefly for completeness. Section 3 gives theoretical results for gradient decent algorithms, where we analyse both the convergent points and gradient dynamics per iteration. In §4, we perform some computational experiments with the proposed method solving function approximation problem using deep NN and inverse PDE-based problems using PINNs. We also solved some standard deep learning benchmarks problems using the proposed activation functions. Several comparisons are made between the existing and the proposed methods. Finally, in §5, we summarize the findings of our work.

2. Methodology

We use an NN of depth D corresponding to a network with an input layer, D − 1 hidden-layers and an output layer. In the kth hidden-layer, Nk number of neurons are present. Each hidden-layer of the network receives an output zk1RNk1 from the previous layer, where an affine transformation of the form

Lk(zk1)wkzk1+bk 2.1

is performed. The network weights wkRNk×Nk1 and bias term bkRNk associated with the kth layer are chosen from independent and identically distributed sampling. The nonlinear-activation function σ( · ) is applied to each component of the transformed vector before sending it as an input to the next layer. The activation function is an identity function after an output layer. Thus, the final NN representation is given by the composition

uΘ(z)=(LDσLD1σL1)(z),

where the operator ° is the composition operator, Θ={wk,bk}k=1DV represents the trainable parameters in the network, and V is the parameter space; u and z0 = z are the output and input of the network, respectively.

Jagtap et al. [12] proposed an adaptive activation function where an additional scalable parameter na, where n ≥ 1 is pre-defined scaling factor, is introduced. The parameter aR acts as a slope of activation function. Since, the parameter a is defined for the complete network, we are calling it a global adaptive activation function (GAAF). Optimization of such parameter dynamically alters the loss landscape thereby increases the NN convergence, especially during the early training period. It is also possible to extend this strategy by locally defining the activation slope. In this regard, we propose the following two approaches to locally optimize the activation function.

  • Layer-wise locally adaptive activation functions (L-LAAF) Instead of globally defining the parameter a for the adaptive activation function, let us define this parameter for each hidden layer as
    σ(nakLk(zk1)),k=1,2,,D1.
    This gives additional D − 1 parameters to be optimized along with weights and biases. Here, every hidden-layer has its own slope for the activation function.
  • Neuron-wise locally adaptive activation functions (N-LAAF) One can also define such activation function at the neuron level as
    σ(naik(Lk(zk1))i),k=1,2,,D1,i=1,2,,Nk.
    This gives additional k=1D1Nk parameters to be optimized. Neuron-wise activation function acts as a vector activation function in each hidden-layer, where every neuron has its own slope for the activation function, as opposed to scalar activation function given by L-LAAF and GAAF approaches.

In both cases, n ≥ 1 is a scaling factor. For every problem, there exists a critical scaling factor ncrit above which the optimization algorithm becomes very sensitive. The resulting optimization problem leads to finding the minimum of a loss function by optimizing activation slopes along with weights and biases. Then, the final layer-wise adaptive activation function-based NN representation of the solution is given by

uΘ^(z)=(LDσnaD1LD1σnaD2LD2σna1L1)(z).

Similarly, we can write the neuron-wise adaptive activation function-based NN representation of the solution. In this case, the set of trainable parameters Θ^V^ consists of {wk,bk}k=1D and {aik}k=1D1,i=1,2,,Nk. In the proposed methods, the initialization of scalable parameters is done such that naik=1,n.

The advantage of locally introducing the parameters for the activation slope over its global counterpart is that, it gives additional degrees of freedom to every hidden layer as well as to every neuron in all the hidden layers, which in turn increases the learning capacity of the network. Another advantage of LAAF is that different scaling factors can be assigned for every layer as well as for every neuron as opposed to the global scaling factor in GAAF.

Compared to single additional parameter of GAAF, the locally adaptive activation function-based PINN has several additional scalable parameters to train. Thus, it is important to consider the additional computational cost required. The increase of the parametric space leads to a high-dimensional optimization problem whose solution can be difficult to obtain. Between the previously discussed two approaches, i.e. L-LAAF and N-LAAF, N-LAAF introduces the highest number of additional parameters for optimization. Next, we discuss the qualitative picture of the increase in the number of parameters. Let ω and β be the total number of weights and biases in the NN. Then, the ratio P, which is the size of parametric space of N-LAAF to that of fixed activation-based NN is, P(1+2ϱ)/(1+ϱ), where ϱ = β/ω. As an example, consider a fully connected NN with single input and output involving three hidden-layers with 20 neurons in each layer, which gives the values of ω = 840 and β = 61. Thus, P=1.0677, i.e.6.77% increase in the number of parameters. This increment can be further reduced with an increase in the number of layers as well as neurons in each layer, which eventually results in negligible increase in the number of parameters. In such cases, the computational cost for fixed activation function and that of neuron-wise locally adaptive activations is comparable.

(a). Physics-informed neural networks

In this section, we shall briefly introduce the PINN algorithm [4]. PINN is a very efficient method for solving forward and inverse differential and integro-differential equations involving noisy, sparse and multi-fidelity data. The main feature of the PINN is that it can easily incorporate all the given information like governing equation, experimental data, initial/boundary conditions, etc., into the loss function thereby recast the original problem into an optimization problem. One of the main limitation of PINN algorithm is its high computational cost for high-dimensional optimization problem, which is addressed in [13] by employing the domain decomposition approach. The PINN algorithm aims to learn a surrogate u=uΘ^ for predicting the solution u of the governing PDE. In PINN algorithm the loss function is defined as

J(Θ^)=WFMSEF+WuMSEu, 2.2

where the mean squared error (MSE) is given as

MSEF=1Nfi=1Nf|FΘ^(xfi)|2,MSEu=1Nui=1Nu|uiuΘ^(xui)|2.

{xfi}i=1Nf represents the set of residual points, while {xui}i=1Nu represents the training data points. WF and Wu are the weights for residual and training data points, respectively, which can be chosen dynamically [14]. The NN solution must satisfy the governing equation given by the residual FΘ^=F(uΘ^) evaluated at randomly chosen residual points in the domain. As an example, for the general differential equation of the form L u = f, the residual term is given by FΘ^LuΘ^f, where L represent the linear/nonlinear differential terms. To construct the residuals in the loss function, derivatives of the solution with respect to the independent variables are required, which can be computed using the automatic differentiation (AD) [15]. AD is an accurate way to calculate derivatives in a computational graph compared to numerical differentiation since they do not suffer from the errors such as truncation and round-off errors. Thus, the PINN method is a grid-free method, which does not require mesh for solving equations. This constitutes the physics-informed part of NN as given by the first term in equation (2.2). The second term in equation (2.2) includes the known boundary/initial conditions, experimental data, which must be satisfied by the NN solution.

The resulting optimization problem leads to finding the minimum of a loss function by optimizing the trainable parameters Θ^. The solution to this minimization problem can be approximated iteratively by one of the forms of gradient descent algorithm. The stochastic gradient descent (SGD) algorithm is widely used in machine learning community see [16] for a complete survey. In this work, the ADAM optimizer [17], which is a variant of the SGD method is used.

(b). Loss function with slope recovery term

The main motivation of adaptive activation function is to increase the slope of activation function, resulting in non-vanishing gradients and fast training of the network. It is clear that one should quickly increase the slope of activation in order to improve the performance of NN. Thus, instead of only depending on the optimization methods, another way to achieve this is to include the slope recovery term S(a) defined as

S(a){11/(D1)k=1D1exp(ak)for L-LAAF,11/(D1)k=1D1exp(i=1NkaikNk)for N-LAAF.

The main reason behind this is that such term contributes to the gradient of the loss function without vanishing. The overall effect of including this term is that it forces the network to increase the value of activation slope quickly thereby increasing the training speed.

Figure 1 shows a sketch of a neuron-wise locally adaptive activation function-based physics-informed neural network (LAAF-PINN), where both the NN part along with the physics-informed part can be seen. The activation slopes from every neuron are also contributing to the loss function in the form of slope recovery term. The following algorithm summarizes the LAAF-PINN algorithm with slope recovery term.

Figure 1.

Figure 1.

Schematic of LAAF-PINN for the Burgers equation. The left NN is the uninformed network while the right one induced by the governing differential equation is the informed network. The input are the coordinates (x,t) while the output is the solution u(x,t) which has to satisfy the governing equation. The two NNs share parameters and they both contribute to the loss function. (Online version in colour.)

Algorithm 1: LAAF-PINN algorithm with slope recovery term. —

  • Step 1 : Specification of training set in computational domain

    Training data : uΘ^ network {xui}i=1Nu, Residual training points : {FΘ^ network {xfi}i=1Nf}

  • Step 2 : Construct neural network uΘ^ with random initialization of parameters Θ^.

  • Step 3 : Construct the residual neural network {FΘ^} by substituting surrogate uΘ^ into the governing equations using automatic differentiation and other arithmetic operations.

  • Step 4 : Specification of the loss function that includes the slope recovery term:
    J~(Θ^)=WFNfi=1Nf|FΘ^(xfi)|2+WuNui=1Nu|uiuΘ^(xui)|2+WaS(a), 2.3

    where Wa is the weight for slope recovery term.

  • Step 5 : Find the best parameters Θ^ using a suitable optimization method for minimizing the loss function J~(Θ^) as
    Θ^=argminΘ^V^J~(Θ^).

3. Gradient dynamics with adaptive activation: convergent points and acceleration of convergence

When compared with the standard method, the adaptive activation method induces a new gradient dynamics, which results in different convergent points and the acceleration of the convergence. The following theorem states that a gradient descent algorithm minimizing our objective function J~(Θ^) in (??) does not converge to a sub-optimal critical point or a sub-optimal local minimum, for neither L-LAAF nor N-LAAF, given appropriate initialization and learning rates. For simplicity, WF,Wu and Wa are assumed to be unity. In the following theorem, we treat Θ^ as a real-valued vector. Let J~c(0)=MSEF+MSEu with the constant network uΘ(z)=uΘ(z)=cRND for all z, z′ where c is a constant.

Theorem 3.1. —

Let (Θ^m)mN be a sequence generated by a gradient descent algorithm as Θ^m+1=Θ^mηmJ~(Θ^). Assume that J~(Θ^0)<J~c(0)+S(0) for any cRND, J~ is differentiable, and that for each i ∈ {1, …, Nf}, there exist differentiable function φi and input ρi such that |FΘ^(xfi)|2=φi(uΘ^(ρi)). Assume that at least one of the following three conditions holds.

  • (i)

    (constant learning rate) J~ is Lipschitz continuous with Lipschitz constant C (i.e. ||J~(Θ^)J~(Θ^)||2C||Θ^Θ^||2 for all Θ^,Θ^ in its domain), and ϵ ≤ ηm ≤ (2 − ϵ)/C, where ϵ is a fixed positive number.

  • (ii)

    (diminishing learning rate) J~ is Lipschitz continuous, ηm → 0 and m=0ηm=.

  • (iii)

    (adaptive learning rate) the learning rate ηm is chosen by the minimization rule, the limited minimization rule, the Armjio rule, or the Goldstein rule [18].

Then, for both L-LAAF and N-LAAF, no limit point of (Θ^m)mN is a sub-optimal critical point or a sub-optimal local minimum.

The initial condition J~(Θ^0)<J~c(0)+S(0) means that the initial value J~(Θ^0) needs to be less than that of a constant network plus the highest value of the slope recovery term. Here, note that S(1)<S(0). The proof of theorem 3.1 is included in appendix A.

We now study how the proposed method approaches the convergent points and why it can accelerate the convergence. To illustrate the principal mechanism behind the acceleration, we compare the gradient dynamics of the proposed method against that of the standard method in the domain of J. The gradient dynamics of the standard method in the domain of J is

Θm+1=ΘmηmJ(Θm), 3.1

and generates the sequence (J(Θm))mN of the standard objective values. The gradient dynamics of the adaptive activation method in the domain of J~ is Θ^m+1=Θ^mηmJ~(Θ^m), and generates the sequence (J~(Θ^m))mN of the modified objective values. Those dynamics are in the two different spaces, the domains of J and J~. To compare them, we translate the dynamics (Θ^m)mN in the domain of J~ to the dynamics (Θ~m)mN in the domain of J.

More concretely, we show that the gradient dynamics (Θ^m)mN of the global adaptive activation method generates the sequence (J(Θ~m))mN of the standard objective values where

Θ~m+1=Θ~mηmG^(Θ^m+1)J(Θ~m)+ηm2H^J(Θ~m)Θ~m, 3.2

where Θ~m+1dom(J) is Θ^m+1dom(J~) being translated in the space of Θm+1, which is dom(J) (dom(J) is the domain of J),

G^(Θ^m+1)=(am)2I+Wm(Wm)

and

H^J(Θ~m)=J(Θ~m)J(Θ~m).

Comparing equations (3.1) and (3.2), we can see that the gradient dynamics of the adaptive activation modifies the standard dynamics, by multiplying a conditioning matrix G^(Θ~m) to the gradient and by adding the approximate second-order term ηm2H(Θ~m)Θ~m. This provides the mathematical intuition of why the global adaptive activation method can accelerate the convergence and it is not equivalent to changing or adapting learning rates.

To understand the approximate second-order term ηm2H(Θ~m)Θ~m, note that the gradient dynamics of the standard method (3.1) can be viewed as the simplest discretization (Euler’s Method) of the differential equation of the gradient flow,

Θ˙=J(Θ), 3.3

where we approximate Θt0+t1=Θt0t[t0,t1]J(Θt)dt by setting J(Θt)J(Θt0) for t ∈ [t0, t1]. In this view, we can consider other discretization procedures of (3.3). For example, instead of setting J(Θt)J(Θt0), we can approximate

J(Θt)J(Θt0)+HJ(Θt0)(ΘtΘt0),

where HJ is the Hessian of J. The term ηm2H(Θ~m)Θ~m in (3.2) can be obtained by further approximating the second term by setting HJ(Θt0)H^J(Θ~t0) and ΘtΘt0ηmΘ~t0.

More generally, we show that the gradient dynamics (Θ^m)mN of any adaptive activation method generates the sequence (J(Θ~m))mN of the standard objective values, where

Θ~m+1=Θ~mηmG(Θ^m+1)J(Θ~m), 3.4

with

G(Θ^m+1)=diag((Aam)2)+diag(Wm)AAdiag(Wm)ηmdiag(V(Θ^m+1))

and

V(Θ^m+1)=diag(Aam)AAdiag(Wm)J(Θ~m).

Here, given a vector vRd, diag(v)Rd×d represents a diagonal matrix with diag(v)ii = vi and v2 represents v° v where v° u is the element-wise product of the two vectors v and u. The matrix A differs for different methods of adaptive activation functions with different types of locality, and is a fixed matrix given a method of GAAF, L-LAAF or N-LAAF. For example, in the case of GAAF, d′ = 1 and A=(1,1,,1)Rd. By plugging this A into (3.4) and noticing that diag(Wm)AAdiag(Wm)=WW with this A, we can obtain (3.2) from (3.4); i.e. (3.4) is a strictly more general version of (3.2). In the general case for any adaptive activation method with different types of locality, we can write Θ~m+1=Aam+1Wm+1, where Wm+1Rd and am+1Rd with some matrix ARd×d. In the case of L-LAAF, d′ is the number of layers and ARd×d is the matrix that satisfies Θ~m+1=Aam+1Wm+1 for L-LAAF. In the case of N-LAAF, d′ is the number of all neurons and ARd×d is the matrix that satisfies Θ~m+1=Aam+1Wm+1 for N-LAAF.

Comparing equations (3.1) and (3.4), we can see that the gradient dynamics of different adaptive activation methods modify the standard dynamics, by multiplying different conditioning matrices G(Θ^m) to the gradient, with different matrices A. This provides the mathematical intuition of why various adaptive activation methods can accelerate the convergence in different ways with different matrices A, and they are not equivalent to changing or adapting learning rates. Also, our analysis with (3.4) is applicable to any adaptive activation methods beyond GAAF, L-LAAF and N-LAAF, and provides insights for designing new adaptive activation methods that correspond to the new matrices A in (3.4) in order to further accelerate the convergence.

The conditioning matrix G(Θ^m) is positive definite with sufficiently small learning rate ηm since diag((Aam)2) is positive definite and diag(Wm)AAdiag(Wm) is positive semi-definite (when every entry of am is non-zero). Therefore, with sufficiently small learning rate ηm, the parameter update in equation (3.4) decreases the value of J as J(Θm+1) < J(Θm) at differentiable points whenever ||J(Θ~m)||0. This is because J(Θm+1)=J(Θm)ηmJ(Θ~m)G(Θ^m+1)J(Θ~m)+ηmφ(ηm) at differentiable points with some function φ such that limηm0φ(ηm)=0.

We now derive equations (3.2) and (3.4), and explain the definition of each symbol in more detail. Let us first focus on the GAAF method without the recovery term. Let J^ be J~ without the recovery term. Let Θ~=aW, where W consists of all standard weight and bias parameters {wk,bk}k=1D. Then, we have that J^(Θ^)=J(Θ~). While the standard method generates the sequence of standard objective values (J(Θm+1))mN, the GAAF method generates the sequence of standard objective values (J(Θ~m))mN. To compare the two methods in terms of the same standard objective values, we are thus interested in the following gradient dynamics of the proposed method:

Θ~m+1=am+1Wm+1=(amηmaJ(Θ~m))(WmηmWJ(Θ~m))=Θ~mηmamWJ(Θ~m)ηmaJ(Θ~m)Wm+ηm2aJ(Θ~m)WJ(Θ~m) 3.5

Here, we have that WJ(Θ~)=((J(Θ~)/Θ~)Θ~/W) and aJ(Θ~)=((J(Θ~)/Θ~)Θ~/a) by the chain rule, where J(Θ~)/Θ~=J(Θ~), Θ~/W=aI (I is the identity matrix) and Θ~/a=W. By plugging these into each term in the last line of (3.5),

amWJ(Θ~m)=(am)2J(Θ~m)

and

aJ(Θ~m)Wm=Wm(Wm)J(Θ~m),

and

aJ(Θ~m)WJ(Θ~m)=J(Θ~m)J(Θ~m)Θ~m,

which obtains (3.2) as desired. Similar to the case of GAAF, in the general case, we have

Θ~m+1=Aam+1Wm+1=(A(amηmaJ(Θ~m)))(WmηmWJ(Θ~m))=Θ~mηm(AamWJ(Θ~m))ηm(AaJ(Θ~m)Wm)+ηm2(AaJ(Θ~m)WJ(Θ~m)). 3.6

By using WJ(Θ~)=((J(Θ~)/Θ~)Θ~/W) and aJ(Θ~)=((J(Θ~)/Θ~)Θ~/a),

AamWJ(Θ~m)=diag(AamAam)J(Θ~m), 3.7
AaJ(Θ~m)Wm=diag(Wm)AAdiag(Wm)J(Θ~m) 3.8
andAaJ(Θ~m)WJ(Θ~m)=diag(diag(Aam)AAdiag(Wm)J(Θ~m))J(Θ~m). 3.9

By plugging these into (3.6), we obtain (3.4).

Figure 2 illustrates the effect of adaptive activation methods on the objective value and the normalized condition number. It shows that the adaptive activation methods accelerated the convergence of the objective value while decreasing the condition number. The improvement of the condition number roughly coincided with the improvement of the objective value. The condition number of interest is (the largest singular value of M)/(the smallest singular value of M) where M=G(Θ^)1/22J(Θ~)G(Θ^)1/2 for adaptive activation function methods and M=2J(Θ~) for the standard method without adaptive activations. As this condition number gets smaller, the convergence rate of the objective value can improve when the matrix M is normal [18]. The normalized condition numbers in each subfigure are the minimum condition numbers over the previous epochs, and were normalized by dividing the condition numbers by the initial condition numbers of the standard method. For this experiment, we set n = 1, and we used a fixed dataset generated by sklearn.datasets.make_circleswithn_samples= 1000, noise = 0.01, random_state=0, and factor = 0.7. This dataset is not linearly separable. We adopted the fully-connected NN with a single hidden layer. The standard cross entropy loss was used for training and plots.

Figure 2.

Figure 2.

Experiment under consideration: Effect of adaptive activations on objective value and normalized condition number (i.e. the condition number divided by the initial condition number of the standard method). In each subfigure, width = the number of units in the hidden layer. (a) Sigmoid, width = 10, (b) Sigmoid, width = 20, (c) ReLU, width = 20, (d) ReLU, width = 100, (e) Softplus, width = 100. (Online version in colour.)

4. Computational results

In this section, we shall solve the function approximation problem using deep NN and inverse PDE problems involving the two-dimensional Poisson’s and inviscid Burgers equations using PINN algorithm with the proposed methods. Some standard deep learning benchmarks problems are also solved. The performance of the proposed methods is evaluated in terms of the convergence speed and the accuracy.

(a). Neural network approximation of nonlinear discontinuous function

In this test case, a deep NN (without physics-informed part) is used to approximate a discontinuous function. Here, the loss function consists of the data mismatch and the slope recovery term. The following discontinuous function with discontinuity at x = 0 location is approximated by a deep NN.

u(x)={0.2sin(6x)ifx0,1+0.1xcos(18x)otherwise.

This function contains both high and low frequency components along with the discontinuity. The domain is [ − 3, 3] and the number of training points used is 300, which are chosen randomly. The activation function is tanh, learning rate is 2.0 × 10−4 and the number of hidden layers is four with 50 neurons in each layer. The scaling factor is 10 and both Wu, Wa are unity. Figure 3 shows the solution (first column) and point-wise absolute error in log scale (second column). The solution by the standard fixed activation function is given in the first row, the GAAF solution is given in second row, whereas the third and fourth row shows the solution given by L-LAAF and N-LAAF, respectively. We see that both L-LAAF and N-LAAF with slope recovery term accelerate training speed compared to other methods. We also note that, GAAF solution with the slope recovery term (not shown) is also comparable with the proposed methods in terms of training speed, and it can be considered as a new contribution due to involvement of the slope recovery term.

Figure 3.

Figure 3.

Discontinuous function: NN approximation of function at 2000, 8000 and 15 000 iterations using standard fixed activation (first row), GAAF (second row), L-LAAF (third row), and N-LAAF (fourth row) using the tanh activation. The first column shows the solution. The second column gives the point-wise absolute error in the log scale for all the cases. (Online version in colour.)

(b). Inverse problem: 2D Poisson’s equation

In this example, we shall identify the unknown parameter in the diffusion coefficient. This example is taken from Pakravan et al. [19], where a variable diffusion coefficient parametrized as D(x;α)=1+αx needs to be evaluated, with randomly chosen values of α ∈ [0.05, 0.95]. The computational domain is Ω[1/2,1/2]2 and the governing Poisson’s equation is given by

([1+αx]u)+x+y=0,(x,y)Ω,

with boundary condition ub = cos (πx)cos (πy,) (x, y) ∈ ∂Ω.

The feed-forward NN using three hidden layers with 30 neurons in each layer is trained over 500 generated solutions by randomly choosing the parameter α from the given range. The hyperbolic tangent activation function is used with 0.0008 learning rate. The value of scaling factor is unity in all the cases and WF=1, Wu = 10, Wa = 10. Later we tested its performance on 50 independent solutions fields to identify the parameter α using the fixed activation, GAAF, L-LAAF and the N-LAAF without and with 2.5% Gaussian noise. To show the convergence in the early training period, the results are plotted after 4000 iterations with the clean data and the data with noise. Figure 4 shows the results of the standard activation, GAAF, L-LAAF and the N-LAAF (top to bottom row) without noise (first column) and with Gaussian noise (second column). Both L-LAAF and N-LAAF perform better than GAAF where the learned parameters are in good agreement with the true values. Table 1 shows the relative L2 error in all the cases without noise, and among all methods, L-LAAF gives least error.

Figure 4.

Figure 4.

Inverse problem 2D Poisson equation: The standard activation, GAAF, L-LAAF and the N-LAAF (top to bottom row) without noise (first column) and with Gaussian noise (second column). (Online version in colour.)

Table 1.

The relative L2 error in all the cases without noise.

standard Acti. GAAF L-LAAF N-LAAF
Rel. L2 error 1.012 × 10−1 1.654 × 10−2 7.328 × 10−3 1.482 × 10−2

(c). Inverse problem: 2D inviscid Burgers equation

Our next example is the inverse problem of identification of viscosity coefficient in the Burgers equation. The solution of inviscid Burgers equation can be discontinuous even with sufficiently smooth initial condition. The two-dimensional inviscid Burgers equation is given as

ut+uux+uy=0,x[0.1,1],y[0,1],andt>0,

subject to boundary conditions

u(x,0)={aifx<0,botherwise,

u( − 0.2, y) = a and u(1,y)=b,y. The exact solution for the case of a = 2 and b = 0 is given in [20], which has a steady oblique discontinuity.

In this work, we used the recently proposed conservative PINN (cPINN) method [13], which is basically a domain decomposition approach in PINN for conservation laws. The computational domain is divided into 12 sub-domains and a separate PINN is employed in each sub-domain which are working in tandem. The solutions in each sub-domains are stitched using the interface conditions, which include the enforcement of conservative flux and the average solution along the common interface. The division of computational domain into 12 sub-domains is shown in figure 5. The interface locations on x- and y-axes are [0.2, 0.6] and [0.25, 0.5, 0.75], respectively.

Figure 5.

Figure 5.

Numbering of 12 sub-domains.

In cPINN algorithm, instead of supplying the original equation, the following parametrized viscous Burgers equation is supplied

ut+uux+uy=ν(uxx+uyy),

and we aim to identify the value of the viscosity coefficient ν, which is zero for the inviscid Burgers equation. For this test case we used the hyperbolic tangent activation function, 0.0006 learning rate, scaling factor is 5 in all cases and table 2 gives the number of neurons, number of hidden layers and the number of residual points in each sub-domain. In this case, WF=1, Wu = 10, Wa = 20 are used. The initial values of ν is chosen arbitrarily in all 12 sub-domains, which is [1, 2, 3, 4, −5, 6, −7, 8, 9, 10, 11, 12]/2, respectively. We note that cPINN is a robust method even in the case of negative values of viscosity that no standard solver would tolerate.

Table 2.

NN architecture in each sub-domains for the two-dimensional inviscid Burgers equation.

domain no. 1 2 3 4 5 6 7 8 9 10 11 12
# layers 6 6 3 6 6 3 6 3 3 3 3 3
# neurons 20 20 20 20 20 20 20 20 20 20 20 20
# residual pts. 2200 2200 400 600 2200 800 400 2200 2200 400 800 2200

All the simulations are performed up to 40 k iterations. The number and locations of training data points (300 pts.) and residual points (8000 pts.) are fixed in all cases. Figure 6 shows the variation of ν (first column) and point-wise error (second column) for fixed activation, GAAF, L-LAAF and N-LAAF (top to bottom row) cases. In all cases, ν converges to its actual value, which is zero. The cPINN algorithm using fixed activation function takes 14 750 iterations for convergence whereas the GAAF, L-LAAF and the N-LAAF takes 13 600, 11 090 and 11 170 iterations, respectively. Among all the cases, L-LAAF gives the smallest absolute point-wise error as shown in the figure. In this test case, both N-LAAF and L-LAAF with slope recovery term perform better than GAAF in terms of convergence speed and accuracy of the solution.

Figure 6.

Figure 6.

Inverse problem 2D Burgers equation: Variation of ν (first column) and point-wise error (second column) for standard (fixed activation), GAAF, L-LAAF and N-LAAF (top to bottom row). (Online version in colour.)

(d). Standard deep learning benchmark problems

The previous sub-section demonstrates the advantages of adaptive activation functions with PINN for physics-related problems. One of the remaining questions is whether or not the advantage of adaptive activations remains with standard deep NNs for other types of deep learning applications. To explore the question, this section presents numerical results with various standard benchmark problems in deep learning.

MNIST [21], Fashion-MNIST [22] and KMNIST [23] are the datasets with handwritten digits, images of clothing and accessories, and Japanese letters. Apart from MNIST, Semeion [24] is a handwritten digit data set that contains 1593 digits collected from 80 persons. SVHN [25] is another data set for street view house numbers obtained from house numbers in Google Street View images. CIFAR [26] is a popular data set containing colour images. In particular, the CIFAR-10 data set contains 50 000 training and 10 000 testing images in 10 classes with image resolution of 32 × 32. CIFAR-100 is similar to the CIFAR-10, except it has 100 classes with 600 images in each class.

Figures 7 and 8 show the mean values and the uncertainty intervals of the training losses for fixed activation function (standard), GAAF, L-LAAF and N-LAAF, by using the standard deep learning benchmarks. The solid and dashed lines are the mean values over three random trials with random seeds. The shaded regions represent the intervals of 2 ×(the sample standard deviations) for each method. Figures 7 and 8 consistently show that adaptive activation accelerates the minimization process of the training loss values. Here, all of GAAF, L-LAAF and N-LAAF use the slope recovery term, which improved the methods without the recovery term.

Figure 7.

Figure 7.

Training loss in log scale versus epoch without data augmentation. (a) Semeion, (b) MNIST, (c) KMNIST, (d) Fashion-MNIST, (e) CIFAR-10, (f ) CIFAR-100, (g) SVHN. (Online version in colour.)

Figure 8.

Figure 8.

Training loss in log scale versus epoch with data augmentation. (a) Semeion, (b) MNIST, (c) KMNIST, (d) Fashion-MNIST, (e) CIFAR-10, (f ) CIFAR-100, (g) SVHN. (Online version in colour.)

The standard cross entropy loss was used for training and plots. We used pre-activation ResNet with 18 layers [27] for CIFAR-10, CIFAR-100 and SVHN datasets, whereas we used a standard variant of LeNet [21] with ReLU for other datasets; i.e. the architecture of the variant of LeNet consists of the following five layers (with the three hidden layers): (1) input layer, (2) convolutional layer with 64 5 × 5 filters, followed by max pooling of size of 2 by 2 and ReLU, (3) convolutional layer with 64 5 × 5 filters, followed by max pooling of size of 2 by 2 and ReLU, (4) fully connected layer with 1014 output units, followed by ReLU, and (5) Fully connected layer with the number of output units being equal to the number of target classes. All hyper-parameters were fixed a priori across all different datasets and models. We fixed the mini-batch size s to be 64, the initial learning rate to be 0.01, and the momentum coefficient to be 0.9. The learning rate was divided by 10 at the beginning of 10th epoch for all experiments (with and without data augmentation), and of 100th epoch for those with data augmentation. For the convolutional layers, L-LAAF shares the same single parameter across all pixels and channels within each layer, whereas N-LAAF has as many extra parameters as the number of pixels in every channel. In this section, we used scaling factor n = 1 and 2 because the NN with ReLU activation represents a homogeneous function and hence the behaviours with other values of n can be achieved by changing learning rates in this case. Note that this is not true in previous sections for PINN.

5. Conclusion

In summary, we present two versions of locally adaptive activation functions namely, layer-wise and neuron-wise locally adaptive activation functions. Such local activation functions further improve the training speed of the NN compared to its global predecessor. To further accelerate the training process, an activation slope-based slope recovery term is added in the loss function for both layer-wise and neuron-wise activation functions, which is shown to enhance the performance of the NN. To verify our claim, a function approximation problem is solved using deep NN and two inverse PDE problems are solved using PINNs, demonstrating that the locally adaptive activations outperform fixed as well as global adaptive activations in terms of training speed and accuracy. Moreover, while the proposed formulations increase the number of additional parameters compared to the fixed activation function, the overall computational cost is comparable. The proposed adaptive activation function with the slope recovery term is also shown to accelerate the training process in standard deep learning benchmark problems. We theoretically prove that no sub-optimal critical point or local minimum attracts gradient descent algorithms in the proposed methods (L-LAAF and N-LAAF) with the slope recovery term under only mild assumptions. We also show that the gradient dynamics of the proposed method is not equivalent to the dynamics of base method with any (adaptive) learning rates. Instead, the proposed methods are equivalent to modifying the gradient dynamics of the base method by implicitly multiplying conditioning matrices to the gradients of the base method. The explicit computations of such matrix–vector products are too expensive for NNs, whereas our adaptive activation functions efficiently avoid the explicit computations.

Appendix A. Proof of theorem 3.1

We first prove the statement by contradiction for L-LAAF. Suppose that the parameter vector Θ^ consisting of {wk,bk}k=1D and {ak}k=1D1 is a limit point of (Θ^m)mN and a sub-optimal critical point or a sub-optimal local minimum.

Let fi:=φi(uΘ^(ρi)) and ui:=|uiuΘ^(xui)|2. Let zfi,k and zui,k be the outputs of the kth layer for ρi and (xui), respectively. Define

hfi,k,j:=nak(wk,jzfi,k1+bk,j)R

and

hui,k,j:=nak(wk,jzui,k1+bk,j)R,

for all j ∈ {1, …, Nk}, where wk,jR1×Nk1 and bk,jR.

Following the proofs in [18, Propositions 1.2.1–1.2.4], we have that J~(Θ^)=0 and J~(Θ^)<J~c(0)+S(0), for all three cases of the conditions corresponding the different rules of the learning rate. Therefore, we have that for all k ∈ {1, …, D − 1},

J~(Θ^)ak=S(a)ak+nNfi=1Nfj=1Nkfihfi,k,j(wk,jzfi,k1+bk,j)+nNui=1Nuj=1Nkuihui,k,j(wk,jzui,k1+bk,j)=S(a)ak+j=1Nk(nNfi=1Nffihfi,k,j(wk,jzfi,k1+bk,j)+nNui=1Nuuihui,k,j(wk,jzui,k1+bk,j))=0. A 1

Furthermore, we have that for all k ∈ {1, …, D − 1} and all j ∈ {1, …, Nk},

J~(Θ^)wk,j=nakNfi=1Nffihfi,k,j(zfi,k1)+nakNui=1Nuuihui,k,j(zui,k1),=0 A 2

and

J~(Θ^)bk,j=nakNfi=1Nffihfi,k,j+nakNfi=1Nfuihui,k,j=0. A 3

By combining (A 1)–(A 3), for all k ∈ {1, …, D − 1},

0=akJ~(Θ^)ak=akS(a)ak+j=1Nk(nakNfi=1Nffihfi,k,j(wk,jzfi,k1+bk,j)+nakNui=1Nuuihui,k,j(wk,jzui,k1+bk,j))=akS(a)ak+j=1Nk(wk,j(J~(Θ^)wk,j)+bk,j(J~(Θ^)bk,j))=akS(a)ak.

Therefore,

0=akS(a)ak=ak(D1)(k=1D1exp(ak))2exp(ak),

which implies that for all ak = 0 since (D1)(k=1D1exp(ak))2exp(ak)0. This implies that J~(Θ^)=J~c(0)+S(0), which contradicts with J~(Θ^)<J~c(0)+S(0). This proves the desired statement for L-LAAF.

For N-LAAF, we prove the statement by contradiction. Suppose that the parameter vector Θ^ consisting of {wk,bk}k=1D and {ajk}k=1D1j=1,2,,Nk is a limit point of (Θ^m)mN and a sub-optimal critical point or a sub-optimal local minimum. Redefine

hfi,k,j:=najk(wk,jzfi,k1+bk,j)R

and

hui,k,j:=najk(wk,jzui,k1+bk,j)R,

for all j ∈ {1, …, Nk}, where wk,jR1×Nk1 and bk,jR. Then, by the same proof steps, we have that J~(Θ^)=0 and J~(Θ^)<J~c(0)+S(0), for all three cases of the conditions corresponding the different rules of the learning rate. Therefore, we have that for all k ∈ {1, …, D − 1} and all j ∈ {1, …, Nk},

J~(Θ^)ajk=nNfi=1Nffihfi,k,j(wk,jzfi,k1+bk,j)+nNui=1Nuuihui,k,j(wk,jzui,k1+bk,j)+S(a)ajk=0. A 4

By combining (A 2)–(A 4), for all k ∈ {1, …, D − 1} and all j ∈ {1, …, Nk},

0=ajkJ~(Θ^)ajk=najkNfi=1Nffihfi,k,j(wk,jzfi,k1+bk,j)+najkNui=1Nuuihui,k,j(wk,jzui,k1+bk,j)+ajkS(a)ajk=wk,j(J~(Θ^)wk,j)+bk,j(J~(Θ^)bk,j)+ajkS(a)ajk=ajkS(a)ajk.

Therefore,

0=ajkS(a)ak=2ajk(D1)(k=1D1exp(i=1NkaikNk))2exp(i=1NkaikNk)/Nk,

which implies that for all ajk=0 since (D1)(k=1D1exp(i=1Nkaik/Nk))2exp(i=1Nkaik/Nk)0. This implies that J~(Θ^)=J~c(0)+S(0), which contradicts with J~(Θ^)<J~c(0)+S(0). This proves the desired statement for N-LAAF.

Data accessibility

https://github.com/AmeyaJagtap/Locally-Adaptive-Activation-Functions-Neural-Networks-.

Authors' contributions

A.D.J.: conception and design, acquisition and interpretation of data, drafting and revising the article, corrections. K.K.: theoretical analysis, acquisition and interpretation of data, revising the article, corrections. G.E.K.: drafting and revising the article, supervision, corrections. All authors agree to be accountable for all aspects of the work.

Competing interests

We declare we have no competing interest.

Funding

This work was supported by the Department of Energy PhILMs grant DE-SC0019453, and by the DARPA-AIRA grant HR00111990025.

Reference

  • 1.Hinton G. et al. 2012. Deep neural networks for acoustic modeling in speech recognition. IEEE Signal Process Mag. 29, 82–97. ( 10.1109/MSP.2012.2205597) [DOI] [Google Scholar]
  • 2.Krizhevsky A, Sutskever I, Hinton G. 2012. Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems 25, 26th Annual Conf. in Neural Information Processing Systems 2012, Lake Tahoe, NV, 1–6 December, vol. 1, pp. 1097–1105. Neural Information Processing Systems Foundation Inc.
  • 3.Wu Y. et al. 2016. Google’s neural machine translation system: bridging the gap between human and machine translation. (http://arxiv.org/abs/1609.08144).
  • 4.Raissi M, Perdikaris P, Karniadakis GE. 2019. Physics-informed neural network: a deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. J. Comput. Phys. 378, 686–707. ( 10.1016/j.jcp.2018.10.045) [DOI] [Google Scholar]
  • 5.Srivastava N, Hinton G, Krizhevsky A, Sutskever I, Salakhutdinov R. 2014. Dropout: a simple way to prevent neural networks from overfitting. J. Mach. Learning Res. 15, 1929–1958. [Google Scholar]
  • 6.Yu CC, Tang YC, Liu BD. 2002. An adaptive activation function for multilayer feedforward neural networks. In 2002 IEEE Region 10 Conf. on Computers, Communications, Control and Power Engineering. TENCOM ’02. Proc. Beijing, China, 28–31 October. Piscataway, NJ: IEEE.
  • 7.Qian S, Liu H, Liu C, Wu S, San Wong H. 2018. Adaptive activation functions in convolutional neural networks. Neurocomputing 272, 204–212. ( 10.1016/j.neucom.2017.06.070) [DOI] [Google Scholar]
  • 8. Dushkoff M, Ptucha R. Adaptive activation functions for deep networks. Electronic imaging, computational imaging XIV, pp. 1–5(5). (doi:10.2352/ISSN.2470-1173.2016.19.COIMG-149)
  • 9.Li B, Li Y, Rong X. 2013. The extreme learning machine learning algorithm with tunable activation function. Neural Comput. & Applie 22, 531–539. ( 10.1007/s00521-012-0858-9) [DOI] [Google Scholar]
  • 10.Shen Y, Wang B, Chen F, Cheng L. 2004. A new multi-output neural model with tunable activation function and its applications. Neural Processing Letters 20, 85–104. ( 10.1007/s11063-004-0637-4) [DOI] [Google Scholar]
  • 11.Kunc V, Kléma J. 2019. On transformative adaptive activation functions in neural networks for gene expression inference. bioRxiv 587287 Cold Spring Harbor, NY: Cold Spring Harbor Laboratory Publishing. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Jagtap AD, Kawaguchi K, Karniadakis GE. 2020. Adaptive activation functions accelerate convergence in deep and physics-informed neural networks. J. Comput. Phys. 404, 109136 ( 10.1016/j.jcp.2019.109136) [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Jagtap AD, Kharazmi E, Karniadakis GE. 2020. Conservative physics-informed neural networks on discrete domains for conservation laws: applications to forward and inverse problems. Comput. Methods Appl. Mech. Eng. 365, 113028 ( 10.1016/j.cma.2020.113028) [DOI] [Google Scholar]
  • 14.Wang S, Teng Y, Perdikaris P. 2020. Understanding and mitigating gradient pathologies in physics-informed neural networks. (http://arxiv.org/abs/2001.04536).
  • 15.Baydin AG, Pearlmutter BA, Radul AA, Siskind JM. 2018. Automatic differentiation in machine learning: a survey. J. Mach. Learning Res. 18, 1–43. [Google Scholar]
  • 16.Ruder S. 2017. An overview of gradient descent optimization algorithms. (http://arxiv.org/abs/1609.04747v2).
  • 17.Kingma DP, Ba JL. 2017. ADAM: a method for stochastic optimization. (http://arxiv.org/abs/1412.6980v9).
  • 18.Bertsekas DP. 1999. Nonlinear programming. Belmont, MA: Athena Scientific. [Google Scholar]
  • 19.Pakravan S, Mistani PA, Aragon-Calvo MA, Gibou F. 2020. Solving inverse-PDE problems with physics-aware neural networks. (http://arxiv.org/abs/2001.03608).
  • 20.Jagtap AD. 2018. Method of relaxed streamline upwinding for hyperbolic conservation laws. Wave Motion 78, 132–161. ( 10.1016/j.wavemoti.2018.02.001) [DOI] [Google Scholar]
  • 21.LeCun Y, Bottou L, Bengio Y, Haffner P. 1998. Gradient-based learning applied to document recognition. Proc. IEEE 86, 2278–2324. ( 10.1109/5.726791) [DOI] [Google Scholar]
  • 22.Xiao H, Rasul K, Vollgraf R. 2017. Fashion-MNIST: a novel image dataset for benchmarking machine learning algorithms. (http://arxiv.org/abs/1708.07747).
  • 23.Clanuwat T, Bober-Irizar M, Kitamoto A, Lamb A, Yamamoto K, Ha D. 2018. Deep learning for classical Japanese literature. (http://arxiv.org/abs/1812.01718).
  • 24.Tactile Srl, Brescia, Italy (1994). Semeion Handwritten Digit Data Set. Rome, Italy: Semeion Research Center of Sciences of Communication.
  • 25.Netzer Y, Wang T, Coates A, Bissacco A, Wu B, Ng AY. 2011. Reading digits in natural images with unsupervised feature learning. NIPS Workshop on Deep Learning and Unsupervised Feature Learning.
  • 26.Krizhevsky A, Hinton G. 2009. Learning multiple layers of features from tiny images. Technical report, Citeseer.
  • 27.He K, Zhang X, Ren S, Sun J. 2016. Identity mappings in deep residual networks. Computer Vision - ECCV 2016, 14th European Conf., Amsterdam, The Netherlands, 11–14 October, Proc. Part IV , pp. 630–645. Springer.

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

https://github.com/AmeyaJagtap/Locally-Adaptive-Activation-Functions-Neural-Networks-.


Articles from Proceedings. Mathematical, Physical, and Engineering Sciences are provided here courtesy of The Royal Society

RESOURCES