T AYLOR N ET : A T AYLOR -D RIVEN G ENERIC N EURAL A RCHITECTURE
Anonymous authors
Paper under double-blind review
A BSTRACT
In this work, we propose the Taylor Neural Network (TaylorNet), a generic neural architecture that parameterizes Taylor polynomials using DNNs without non-linear activation functions.
The key challenges of developing TaylorNet lie in: (i) mitigating the curse of dimensionality caused by higher-order terms, and (ii) improving the stability of model training.
To overcome these challenges, we first adopt
Tucker decomposition to decompose the higher-order derivatives in Taylor expansion parameterized by DNNs into low-rank tensors.
Then we propose a novel reducible TaylorNet to further reduce the computational complexity by removing more redundant parameters in the hidden layers.
In order to improve training accuracy and stability, we develop a new Taylor initialization method.
Finally, the proposed models are evaluated on a broad spectrum of applications, including image classification, natural language processing (NLP), and dynamical systems.
The results demonstrate that our proposed Taylor-Mixer, which replaces MLP and activation layers in the MLP-Mixer with Taylor layer, can achieve comparable accuracy on image classification, and similarly on sentiment analysis in NLP, while significantly reducing the number of model parameters.
More importantly, our method can explicitly learn and interpret some dynamical systems with Taylor polynomials.
Meanwhile, the results demonstrate that our Taylor initialization can significantly improve classification accuracy compared to Xavier and Kaiming initialization.
I NTRODUCTION
This paper proposes a generic neural architecture, called TaylorNet, that parameterizes Taylor polynomials using deep neural networks.
It can be employed to a variety of application domains, including image classification, dynamical systems, and natural language processing (NLP).
Importantly, the proposed method does not use non-linear activation functions , thus promoting interpretability of
DNNs in some applications, such as dynamical systems.
This work is motivated by a growing popularity of physics-guided machine learning (ML)
(Jia et al., 2021;
Daw et al., 2017), which integrates physical priors into neural networks.
Thus, it endows neural networks with the ability to generalize to new domains better.
As a result, physics guided
ML has been widely applied to a variety of areas, such as dynamical systems (Cranmer et al., 2020;
Lusch et al., 2018; Greydanus et al., 2019), quantum mechanics (Sch¨utt et al., 2017), and climate changes (Kashinath et al., 2021; Pathak et al., 2022).
However, existing methods based on DNNs are either tailored to solve certain specific problems, such as PDEs (Li et al., 2020; Raissi et al., 2017) and dynamics prediction (Greydanus et al., 2019;
Lusch et al., 2018; Wang et al., 2019), or hard to explain the results.
Hence, the question is, can we develop a generic interpretable neural architecture that can be used in a wide range of machine learning domains?
In this paper, we develop a novel Taylor-driven neural architecture, called TaylorNet, that parameterizes Taylor polynomials using DNNs without non-linear activation functions , as shown in Fig.
The proposed TaylorNet is able to generalize to a wide spectrum of ML tasks, ranging from computer vision and dynamical systems to NLP.
However, developing TaylorNet poses two main challenges.
First, the computational complexity of Taylor polynomial parameterized by DNNs grows exponentially as the polynomial order increases.
Second, its higher-order terms often lead to training instability.
To deal with these challenges, we first adopt Tucker decomposition to decompose the higher-order
# "" ∑ $ ! ! " !
# "" ∑ $ ! ! " ! # "" ∑ $ & #$!
[Figure]
[Figure]
tensors in TaylorNet into a set of low-rank tensors (Malik & Becker, 2018; Kolda & Bader, 2009).
To further reduce its computational complexity, we propose a reducible TaylorNet that removes more redundant learnable parameters in the hidden layers.
In order to show the generalization of our architecture, we propose a Taylor-Mixer that uses Taylor layers in place of both the MLP layers and activation functions in the MLP-Mixer (Tolstikhin et al., 2021).
Then a new Taylor initialization method is developed to improve the stability and accuracy of the model.
Finally, we evaluate the proposed Taylor-Mixer and TaylorNet in a variety of applications, including image classification, dynamical system, and NLP.
The results show that our Taylor-Mixer can achieve comparable accuracy to the MLP-Mixer on image classification while exhibiting a considerable reduction of model parameters.
The proposed TaylorNet also explicitly learns and interprets the dynamics of two classic physical systems with polynomials.
Besides, our method can also be applied to NLP.
The evaluation results on sentiment analysis demonstrate a competitive accuracy to the recently proposed pNLP-Mixer (Fusco et al., 2022).
Meanwhile, our Taylor initialization can reach an accuracy that is over 10% higher than the Xavier and Kaiming initialization methods for the proposed TaylorNet (Glorot & Bengio, 2010; He et al., 2015).
In summary, our contributions include: 1) we design the TaylorNet, a novel neural architecture without activation functions that can generalize to a broad spectrum of ML domains, 2)
we then propose a reducible TaylorNet that remarkably reduces the number of learning parameters, 3)
a new
Taylor initialization method is proposed to stabilize model training, 4) we develop a Taylor-Mixer that replaces both the MLP layers and activation functions in MLP-Mixer with Taylor layers, which can achieve comparable accuracy to the MLP-Mixer on image classification and sentiment analysis, and 5)
Our approach can explicitly learn and explain some dynamical systems with polynomials, making way for interpretable ML.
R ELATED W ORK
Polynomial Neural Networks.
We summarize the significant difference between the proposed
TaylorNet and existing Polynomial Neural Networks.
Earlier work Nikolaev & Iba (2006) mainly adopted Group Method of Data Handling to learn partial descriptors in polynomial neural networks.
Then a follow-up pi-sigma network Shin & Ghosh (1991) was developed to filter the input features using predefined basis.
These methods, however, fail to scale to high-dimensional data Chrysos et al.
Recently, researchers designed Π -Nets Chrysos et al.
(2020; 2022) that parameterizes the polynomial functions using deep neural networks and tensor decomposition.
However, the performance of Π -Nets will degrade in larger networks.
In addition, Π -Net can be viewed as a special case of TaylorNet at expansion point 0 since its adopted CP-decomposition is a special case of Tucker decomposition.
Furthermore, we develop a novel Taylor initialization to improve the training stability while Π -Net does not.
Our initialization method is different from the initialization paradigm for
Tensorial Convolutional Neural Networks Pan et al.
Related Work on Taylor Series.
Some recent studies developed Taylor-based neural networks.
For example, TaylorSwiftNet Pourheydari et al.
(2021) was developed for time-series prediction, but it is not applicable to high-dimensional classification.
Recently, Mao et al Mao et al.
(2022) developed
Phy-Taylor to learn the physical dynamics based on partial physics knowledge, but it suffers from the curse of dimensionality.
Different from these methods, it can be used in a wide spectrum of application domains without using activation functions.
Moreover, it can interpret some dynamical systems using Taylor polynomials.
Learning Dynamics.
Some researchers developed physics-based DNNs to learn the dynamics of physical systems.
For example, Lusch et al. designed the Koopman operator (Geneva & Zabaras, 2022; Lusch et al., 2018) that maps the non-linear dynamics into a linear Koopman representation space for predicting the future states of dynamical systems.
Recent studies proposed Hamiltonian and
Lagrangian neural networks (Cranmer et al., 2020) that strictly follow conservation laws.
However, these methods are designed for specific problems, and they are hard to apply to other domains, such as computer vision and natural language processing (NLP).
Tensor Decomposition.
Tensor decomposition (Kolda & Bader, 2009) aims to represent highdimensional tensors using multilinear operations over the factor matrices or tensors.
Some popular tensor decomposition methods include CP decomposition (Carroll & Chang, 1970), Tucker decomposition (Tucker, 1966), tensor train (TT) decomposition (Oseledets, 2011), and tensor ring (TR) decomposition (Zhao et al., 2016).
Thanks to their ability to reduce computational complexity without breaking out data structure, tensor decomposition techniques are increasingly being widely used in machine learning applications (Wu et al., 2020; Pan et al., 2022; Qiu et al., 2021).
Inspired by prior work, we adopt tensor decomposition to deal with the curse of dimensionality in our TaylorNet.
P RELIMINARIES
Notations .
We summarize the main notations used throughout this paper in Appendix A.
Regarding mathematical symbols, scalars are denoted by normal letters, e.g. x and y , while vectors are denoted by lowercase boldface letters, e.g. x .
In addition, matrices are denoted by uppercase boldface letters, e.g. X , while tensors are denoted by calligraphic letters, e.g. X and W .
Taylor Polynomial.
Taylor polynomial is able to approximate non-linear smooth functions given an arbitrary compact Hausdorff space according to Stone–Weierstrass theorem (Stone, 1948).
According to Taylor’s theorem (Thomas et al., 2005), for a vector-valued multivariate function f : R d → R o , its Taylor polynomial at a point x = x 0 can be expressed as
[Equation]
where x ∈ R d , x 0 ∈ R d , ∆ x j = x j − x j, 0 , j = 1 , . . .
, d .
It can also be written as the following tensor form (Chrysos et al., 2020),
[Equation]
where ¯ × m denotes mode- m vector product , ∆ x = x − x 0 and W [ k ] ∈
R o (cid:81) km =1 × d are scaled higher-order derivatives of f at x = x 0 .
However, the problem of Taylor polynomial is that its computational complexity grows exponentially as the order increases, making it hard to be applied to high-dimensional data.
Tucker Decomposition.
Tucker decomposition aims to decompose a tensor into a small core tensor multiplied by a set of matrices along the corresponding mode (Tucker, 1966; Kolda & Bader, 2009).
In essence, Tucker decomposition can be viewed as a higher-order principal component analysis.
Let
X be N -way tensors, then its Tucker decomposition is given by
[Equation]
where G is a core tensor and A ( n ) ( n = 1 , . .
. , N ) are the factor matrices.
According to mode- n unfolding (Kolda & Bader, 2009), Eq.
3 can be expressed as the following matricized form:
[Equation]
where X ( n ) and G ( n ) are matrices that mean the mode- n matricization of the tensor X and G and ⊗ denotes Kronecker product.
P ROPOSED M ETHOD
In this section, we first introduce a lightweight Taylor Neural Network using Tucker decomposition.
As an extension, we propose a reducible TaylorNet to further improve the computational efficiency by removing redundant trainable parameters in the middle layers.
In order to stabilize the model training process and improve accuracy, a novel Taylor initialization method is developed in this work.
Moreover, we present the connection between TaylorNet and some other existing neural networks.
4. T AYLOR N EURAL N ETWORKS
Since mapping function f in Eq.
2 is unknown and needs to be learned by deep neural networks, we cannot calculate the derivatives W [ k ] of f directly.
To deal with this issue, this work adopts deep neural networks to parameterize the Taylor polynomial in Eq. 2, where f ( x 0 ) and W [ k ] ( k = 1 , . .
. , N ) are learnable parameters during model training.
However, the computational complexity of tensor W [ k ] grows exponentially, O ( d k ) , as the polynomial order k increases.
To overcome this issue, Tucker decomposition is adopted in this work.
According to Eq. 3, the scaled derivatives W [ k ] can be decomposed into
[Equation]
where G [ k ] ∈ R r out ,k (cid:81) kj =1 × r in ,k,j is the core tensor, I kj ∈ R d × r in ,k,j ( j = 1 , . . .
, k ) and O k ∈
R o × r out ,k are input and output factor matrices, respectively.
Here we use r in ,k,j and r out ,k to represent the Tucker ranks corresponding to the j -th input and output dimension in the k -th-order term of the Taylor polynomial.
Substituting Eq.
5 into 2, the k -th term of Taylor polynomial can be written as
[Equation]
Based on commutative law and associative property in mode- n product (Kolda & Bader, 2009), Eq.can be reformulated as
[Equation]
Please refer to the detailed transformation in Appendix.
B.
However, to our knowledge, the current deep learning frameworks (e
[Equation]
g, Pytorch and TensorFlow) do not support batch-size-based mode- n product in Eq. 7.
Fortunately, since the result of Eq.is a vector, according to mode- n unfolding as illustrated in Eqs. 3 and 4, we can convert it into a matricized form as follows.
[Equation]
Finally, substituting the above Eq. 8 into Taylor polynomial in Eq. 1, resulting in a lightweight
N -th-order Taylor layer as follows.
[Equation]
where β
= f ( x 0 ) , O k , G k , and I ⊤ kj ( k = 1 , . . .
, N ; j = 1 , . . .
, k ) are learnable parameters.
After that, we can stack L Taylor layers with a N -th order expansion to construct a new neural network, referred as the TaylorNet.
According to Eq.
9 above, the output of the l -th layer in our
TaylorNet with a N -th-order expansion can be written as
[Equation]
where y ( l ) ∈ R d ( l +1) is the output of the l -th layer and y (0)
=
∆ x ∈ R d (1) , d (1) =
d .
Here d ( l ) is the input dimension of the l -th layer.
In addition, β ( l ) ∈ R d ( l +1) , O ( l ) k ∈ R d ( l +1) × r ( l ) out ,k , G ( l ) k ∈
R r ( l ) out ,k × (cid:81) kj =1 r ( l ) in ,k,j , I ( l ) kj ∈ R d ( l ) × r ( l ) in ,k,j ( k = 1 , . .
. , N ; j = 1 , . .
. , k ) are learnable parameters of the l -th Tucker Taylor layer.
Fig.
1 shows the overall framework of the proposed TaylorNet.
In this paper, we use the Taylor layer with a second order expansion , since it is able to mitigate the overfitting problem and also reduce the number of trainable parameters in DNNs.
Remark 4.1.
The computational complexity of the k -th-order term in Taylor layer decreases from
O ( od k ) to O ( r out ,k (cid:81) kj =1 r in ,k,j + or out ,k + d (cid:80) kj =1 r in ,k,j ) , where d and o denote the dimension of the input and the output.
When o and d are much larger than the rank of a core tensor in Tucker decomposition, the number of parameters will be reduced by orders of magnitude.
4. R EDUCIBLE T AYLOR N ET AND T AYLOR -M IXER
Reducible TaylorNet .
We further propose a reducible TaylorNet, called R-TaylorNet, to reduce the number of trainable parameters of TaylorNet.
The basic idea is to use a single matrix as the new trainable parameter to replace the original product of the current layer’s output factor matrix and the next layer’s input factor matrix, namely, compositing two consecutively multiplying parameter matrices O ( l ) k and I kj ( l +1) into a single parameter matrix.
Below, we will theoretically derive the
R-TaylorNet.
According to the block multiplication of matrices, Eq.
10 can be rewritten as
[Equation]
where z ( l ) kj = (cid:16) I ( l ) kj (cid:17) ⊤ y
( l − 1) ∈ R r ( l ) in ,k,j , we call it hidden features of the l -th layer in this work.
In order to further simplify the above equation
[Equation]
we define the following notations:
[Equation]
Then z ( l +1) kj in the ( l + 1) -th hidden layer can be expressed by the following recursive form
[Equation]
where k
= 1 , . . . , N , and j = 1 , . . .
, k .
In order to reduce some intermediate parameters in DNNs, we introduce new lower-dimensional matrices (vectors) to replace the product of some matrices in the above Eq. 13.
Namely, v ( l ) kj = (cid:16) I ( l +1) kj (cid:17) ⊤ β ( l ) and T ( l ) kj = (cid:16) I ( l +1) kj (cid:17) ⊤ O ( l ) .
By doing so, we can simplify Eq.
13 as
[Equation]
where v ( l ) kj ∈ R r ( l +1) in ,k,j and T ( l ) kj ∈ R r ( l +1) in ,k,j × (cid:80) N k
=1 r ( l ) out ,k are the new parameters in DNNs.
Finally, we can use Eq.
14 above to implement a L -layer reducible TaylorNet.
The feedforward method of a single layer is summarized in Algorithm 1 in Appendix C.
Remark 4.2.
In R-TaylorNet, the computational complexity of calculating hidden features z ( l +1), . . .
, z ( l +1)
NN from z ( l ) 11 , . .
, z ( l ) NN in the l -th layer can be reduced by O ( (cid:80)
Nk =1 ( d ( l +1) r
( l ) out ,k + d ( l +1) (cid:80) kj =1 r ( l +1) in ,k,j − ( (cid:80)
Nm =1 r ( l ) out ,m )( (cid:80) kj =1 r ( l +1) in ,k,j )))
compared to the original TaylorNet.
Taylor-Mixer .
Building on the R-TaylorNet, we also propose a new Taylor-Mixer that replaces both the MLP layers and non-linear activation functions in the MLP-Mixer Tolstikhin et al.
(2021) with
Taylor layer.
The resulting Taylor-Mixer can be applied to image classification and natural language processing (NLP).
4. T AYLOR I NITIALIZATION
We also develop a robust Taylor initialization method to mitigate the training instability caused by higher-order terms.
For simplicity, we omit superscript ( l ) unless otherwise specified.
Following
Xavier Glorot & Bengio (2010) and Kaiming initialization He et al. (2015), we assume that: 1) the input elements (variables) of the l -th layer, denoted by y ( l − 1) , follow independent zero-mean
Gaussian distribution.
2) the weights in O k , G k , I kj ( k = 1 , . . .
, N ; j = 1 , . . .
, k ) are initialized independently with zero mean.
3) β is initialized to 0.
Then we have the following proposition.
Proposition 4.1.
The variance of input and output variables of the l -th layer satisfies:
[Equation] [Equation]
where !!
denotes double factorial, ( σ ( l ) y ) 2 and ( σ ( l − 1) y ) 2 denote the variance of y ( l ) and y ( l − 1) .
And σ 2 O,k , σ 2 G,k , and σ 2 I,k denote the variance of the weights in O k , G k , and I kj ( k = 1 , . . .
, N ; j = 1 , . . .
, k ) , respectively.
Following the prior works He et al.
; Glorot & Bengio (2010), we should enforce ( σ ( l ) y )
= ( σ ( l − 1) y ) 2 for stabilizing the model training.
Plus, we would also like to ensure that all intermediate features inside the Taylor layer have similar variance as ( σ ( l − 1) y ) 2 .
To satisfy these requirements, the variance of weights should be initialized to:
[Equation]
where λ k is a coefficient that can be used to scale the importance of the k -th-order term.
Please refer to the theoretical analysis of Proposition 4.1 in Appendix E.
Similarly, we have also developed an initialization method for Reducible TaylorNet, please refer to
Appendix F for more details.
4. C ONNECTIONS TO E XISTING M ODELS
We present the connection between TaylorNet and some existing neural networks.
According to
Eq. 3, one-layer TaylorNet of order 1 is a linear function, f ( x ) =
f
( x 0 )
+ J ( x − x 0 ) , where J is the Jacobian matrix of f ( x ) at x = x 0 .
Thus, the TaylorNet of order 1 can be viewed as fully connected layers in deep neural networks.
The second order term in a Taylor layer can be expressed as H (1) [( x − x 0 ) ⊗ ( x − x 0 )] , where H is the scaled second-order derivative tensor of f ( x ) at x = x 0 .
The Kronecker product of x − x 0 can be viewed as the pixel-level attention, analogous to the token-level attention in Transformer Vaswani et al.
; Dosovitskiy et al.
Finally, our
TaylorNet adopts higher-order terms to compensate for the residual errors, as shown in Fig.
1 (b), which shares the similar philosophy as a residual (or highway) network Srivastava et al.
; He et al.
E XPERIMENTS
We first verify the effectiveness of the proposed Taylor initialization method.
Then we evaluate the performance of the proposed methods in three different applications, including image classification, explainable dynamical systems, and NLP.
The detailed model configurations and hyperparameter settings are presented in Appendix D
5. T AYLOR INITIALIZATION
[Figure]
First of all, we compare our Taylor initialization with two commonly used initialization approaches:
Xavier and Kaiming initialization.
In this task, we conduct experiments on CIFAR10 using four-layer
Taylor-Mixer (34.4M parameters) as described in
Section 4.2.
Fig.
2 illustrates the comparison results of different methods using 3 random seeds.
We can observe that our Taylor initialization can significantly increase the classification accuracy by over 10% compared to the next best approach, Xavier initialization.
The primary reason why both Xavier and Kaiming initialization do not perform well is that they fail to ensure the same variance for input and output at each layer.
5. E VALUATION ON I MAGE C LASSIFICATION
We evaluate the performance of our proposed Taylor-Mixer on image classification.
We compare it with the MLP-Mixer Tolstikhin et al.
(2021), which can achieve competitive results on image classification benchmarks.
In our experiment, we choose the point of expansion at x 0 = 0 for
Taylor-Mixer since the input data are normalized.
Following the similar method in MLP-Mixer, we pre-train our model on ILSVRC2012 ImageNet that contains 1.3M training examples and 1k classes, and then test it on CIFAR10 and CIFAR100 datasets.
Also, this work adopts the same data augmentation techniques, including RandAugment Cubuk et al.
(2020), mixup Zhang et al.
(2018), and stochastic depth Huang et al.
In addition, we use the same fine-tuning strategy as MLP-Mixer.
The detailed parameter settings are introduced in Appendix D.1.
Table 1 shows the performance comparison of our Taylor-Mixer and the baselines under different model sizes.
We can see that the proposed Taylor-Mixer performs better than Π -nets and achieves comparable accuracy to the MLP-Mixer with fewer model parameters on both CIFAR10 and CIFAR100.
In particular, the parameters of our Base model can be reduced by about 42% compared to the MLP-Mixer.
Therefore, we can conclude that our Taylor-Mixer outperforms the MLP-Mixer.
[Table]
5. E VALUATION ON D YNAMICAL S YSTEMS
Next
[Table]
we apply our TaylorNet to predict and interpret the dynamics of physical systems.
We evaluate it on two dynamical systems, Duffing equation and High-dimensional non-linear flow attractor.
To train our model, we generate 100 trajectories by randomly choosing 100 initial conditions.
Then we use the 20 trajectories generated from 20 different initial conditions as the validation data.
The time span of each trajectory is t = 0 , 0 . 01 , 0 .
, 10 with sampling time, 0.01.
Thus, we can
[Figure] [Figure]
convert a continuous dynamical system into a discrete dynamical system, x k +
= f
( x k ) .
Next, we use regression technique to predict the next state using TaylorNet.
We compare our approach with two methods: ODE solver (ground truth), called odeint, from SciPy package and 3-layer MLP.
Duffing equation.
We first adopt TaylorNet to predict the dynamics of Duffing equation, given by
[Equation]
In our experiment, we choose x 1 (0) , x 2 (0) ∈ [ − 1 , 1] .
Fig.
3 illustrates the trajectory prediction of different methods on Duffing dynamics using one random initial condition .
We can observe from it that our TaylorNet can attain very good trajectory prediction and its error is 1 .
492 × 10 − 7 compared to the ODE solver, odeint, from SciPy package.
It thus significantly outperforms the MLP whose error is about 0 .
More importantly, since our method does not use activation functions, it has the ability to explicitly learn the dynamical systems in the following Eq. 18.
After comparing to the original Duffing equation, we can see that our predicted model is very close to the ground-truth model in Eq.17.
[Equation]
High-dimensional non-linear flow attractor.
We then apply our method to predict the dynamics of non-linear fluid flow.
According to Noack et al.
(2003), the dynamical system can be described by the following low-dimensional model.
[Equation]
Following the prior work Lusch et al.
(2018), we choose µ = 0 .
1 , ω = 1 , λ = 10 , A = − 0 .
1 , and x 1 (0) , x 2 (0) ∈ [ − 1 . 1 , 1 . 1] , x 3 (0) ∈
[0 , 2 . 42] in the experiment.
Fig.
4 shows the trajectory predictions of flow attractor using different methods.
We can observe that our approach can accurately predict the trajectory as the ODE solver, odeint (ground truth).
In addition, the error of our method is about 3 .
361 × 10 − 6 , which is three orders of magnitude smaller than that of the MLP ( 4 . 447 × 10 − 3 ).
Finally, we leverage our TaylorNet to reconstruct the dynamical system in the following.
We can see the predicted model is very close to the ground truth in the above
Eq. 19.
Based on these two examples, we can conclude that our TaylorNet is able to explicitly learn and interpret the dynamics of some physical systems with polynomials.
[Equation]
5. E VALUATION ON NLP
Finally, we also explore our method in NLP applications.
In this work, we use sentiment analysis on IMDB Maas et al.
(2011) as a running example.
Similar to image classification, we propose a new Taylor-NLP that replaces all the MLP layers, other than those in the attention mechanism, in the recently developed pNLP-Mixer Fusco et al.
The parameter settings are described in Appendix D.3.
Table 2 illustrates the performance comparison of different methods, and our
Taylor-NLP attains comparable accuracy to the pNLP-Mixer XL but with much fewer parameters.
Importantly, our Taylor-NLP does not use activation functions.
[Table]
C ONCLUSION
This paper developed a Taylor-driven generic neural architecture, called TaylorNet, that is able to naturally introduce inductive bias to deep neural networks (DNNs).
Different from classical DNNs, our TaylorNet adopted higher-order terms to replace the conventional non-linear activation functions.
More specifically, we first proposed a lightweight Taylor Neural Network (TaylorNet) based on
Tucker decomposition.
As an extension, we also developed a reducible TaylorNet that can remove redundant parameters in hidden layers to improve computational efficiency.
Then we proposed a new Taylor-Mixer that replaces both the MLP layers and activation functions in the MLP-Mixer with
Taylor layers.
In order to improve the model performance, a novel Taylor initialization approach was proposed.
Evaluation results illustrated that the proposed method can achieve comparable accuracy to the baselines on image classification and sentiment analysis in NLP.
In particular, our approach can significantly reduce the number of desired model parameters on image classification.
Importantly, our approach could explicitly learn and interpret some dynamical systems with polynomials, making way for explainable ML.
A N OTATIONS
We summarize the main notations used throughout the paper in the following table.
[Table]
B P ROPERTIES OF T ENSOR M ODE - N P RODUCT
Lemma B.1.
For mode- n matrix product, it satisfies the commutative law (Kolda & Bader, 2009)
[Equation] [Equation]
which means that the order of multiplication is irrelevant when it comes to different modes in a series of mode matrix product.
Lemma B.2.
For mode- n matrix product, it satisfies the following associative property(Kolda &
Bader, 2009)
[Equation]
Proof.
Based on Lemma.
B.1, the k -th term of Taylor expansion in Eq.
6 can be rewritten as
[Equation]
Based on Lemma.
B.2, the above Eq.
23 can be reformulated as
[Equation]
Proof finished.
C F EEDFORWARD M ETHOD FOR R EDUCIBLE T AYLOR N ET
We summarize the feedforward method for Reducible TaylorNet below.
Input
[Equation]
Output
[Equation]
Initialize
[Equation]
/*from
*/ for l = 1 , . . .
, L do /*from
the 1 -st order to the N -th order */ for k = 1 , . . .
, N do for j = 1 , . . .
, k do if l = 1 then z (1) kj = (cid:16) I (1) kj (cid:17)
⊤ ∆ x else z ( l ) kj = v ( l − 1) kj + T ( l − 1) kj h (cid:16) z ( l − 1), . .
, z ( l − 1) NN (cid:17) end end end end y
=
y
( L ) =
β ( L ) + O ( L ) h (cid:16)
z ( L ) 11 , . . .
, z ( L ) NN (cid:17)
D M ODEL C ONFIGURATIONS AND P ARAMETER S ETTINGS
In this section, we present the detailed model configurations and parameter settings for the following four different tasks.
D. E XPERIMENTAL D ETAILS FOR I MAGE C LASSIFICATION
For image classification, our Taylor-Mixer is built on the existing MLP-mixer Tolstikhin et al.
Thus we follow the experimental settings in the MLP-mixer for pre-training and fine-tuning, unless stated otherwise.
Pre-training .
We pre-train all the models at resolution 224 using linear learning rate warm-up and cosine learning rate decay.
We set the batch-size to 1024 for Base and Small model due to
GPU memory capacity limitation in our servers.
Since the input data are normalized, we choose
Taylor expansion point x 0 = 0 in our model.
The detailed model configurations and parameters settings are presented in Table 4.
Our Taylor-Mixer is set to 2 and 4 layers in our experiments.
The Tucker rank of input and output factor matrices are set to 110 and 140 , respectively.
We describe the rule of thumb for choosing the ranks as follows.
For a N -th order Taylor layer with input and output rank r in ,k,j and r out ,k , the effective width of this layer is approximately min( (cid:80)
Nk =1 (cid:80) kj =1 jr in ,k,j , (cid:80) Nk
=1 r out ,k ) .
Therefore, in order to achieve larger width with fixed number of parameters, we should set (cid:80) Nk =1 (cid:80) kj =1 jr in ,k,j ≈ (cid:80) Nk
=1 r out ,k .
Then we can scale r in ,k,j and r out ,k together to adjust the number of parameters of the model.
[Table]
Fine-tuning .
For a fair comparison, we follow the experimental settings in the MLP-Mixer work.
We use momentum SGD optimizer and a cosine learning rate scheduler with a linear warm-up.
The batch size of fine-tuning is set to 512 .
We also use gradient clipping at global norm 1 .
In addition, we do not use dropout, the same as MLP-Mixer.
D. E XPERIMENTAL D ETAILS FOR D YNAMICAL S YSTEMS
In this experiment, we leverage one-layer TaylorNet based on Tucker decomposition.
The rank of each dimension in the core tensor is set to 16 .
In addition, the batch size is set to 128 .
We use Adam optimizer with learning rate 0 .
D. E XPERIMENTAL D ETAILS FOR NLP
For sentiment analysis in NLP, we follow the same experimental setup in the pNLP-Mixer Fusco et al.
(2022) unless otherwise stated.
Following pNLP-Mixer, we set the batch size and hidden size to 256 and 256 respectively.
We use Adam optimizer with learning rate 10 − 4 .
Different from pNLP-Mixer, the length of input tokens is set to 512 .
we use BERT embeddings for a token by averaging the embeddings of its subword units.
In order to make the number of parameters similar to that of pNLP-Mixer, we choose 2-layers Taylor-NLP with the rank of 30 and 50 for the input and output matrices respectively.
We also use dropout of 0.5 and weight decay of 0.01 to mitigate overfit problem.
Initialization λ 1 , λ 2 are set to 0.99, 0.01.
E A NALYSIS ON T AYLOR I NITIALIZATION IN P ROPOSITION 4.
In this section, we offer the theoretical analysis on Taylor initialization in Proposition 4.1.
First, we introduce two lemmas used to decompose the variance of the output variables.
Lemma E.1.
Suppose that (i) w 1 is independent to w 2 , x 1 , and x 2 , (ii) w 2 is independent to w 1 , xand x 2 , and (iii) E [ w 1 ]
=
E [ w 2 ] = 0 , then we have
[Equation]
Proof.
[Equation]
completing the proof.
Lemma E.2.
If E [ w j ] = 0 , and w j is independent to w k and x i , for all j, k ̸
= j, i , then we have
[Equation]
Proof.
[Equation]
According to Lemma E.1, we can eliminate the second term above.
Thus we have
[Equation]
completing the proof.
Next, we introduce a conjecture which will be used in our main proof.
Conjecture E.1.
For a random vector x following standard multivariate Gaussian distribution and for arbitrary k ≤ d , we have
[Equation]
where i 1 , .
, i k denote the indices of x , d is the dimension of the input and k is the order of the
Taylor series expansion.
We first offer a proof of this conjecture for small k ( k = 1 , 2 , 3 , 4 ) using enumeration below.
This is because we often choose lower-order Taylor expansion for each layer in TaylorNet considering the computational cost.
Proof.
We use the property of Unit Gaussian distribution that
[Equation]
where x follows Unit Gaussian distribution and p is a positive even integer.
For k = 1 , Eq. 30 can be rewritten as
[Equation] [Equation]
For k = 2 , Eq. 30 can be rewritten and proved as d
[Equation]
For k = 3 , Eq. 30 can be rewritten and proved as
[Equation] [Equation]
For k = 4 , Eq. 30 can be rewritten and proved as d (cid:88)
[Equation]
Cd (cid:88) i 1 ,i 2 ̸
= i 1 ,i 3 ̸
= i 1 ,i
E [ x 4 i 1 x 2 i 2 x 2 i 3 ] + d (cid:88) i 1 ,i 2 ̸
= i 1 ,i 3 ̸
= i 1 ,i 2 ,i 4 ̸
= i 1 ,i 2 ,i
E [ x 2 i 1 x 2 i 2 x 2 i 3 x 2 i 4 ] =
d ×
[Equation]
d
[Equation]
(35) completing the proof.
Based on the above proof for small k , we can extrapolate Conjecture E.1 to all k ≤ d .
We have empirically validated that the this conjecture still holds for d ∈ 1 , . . .
, 64 , k ≤ d using computer simulation.
Nevertheless, we are still attempting to prove it thoroughly for our future work.
Based on the above lemmas and Conjecture E.1, we can offer the proof of Proposition 4.1 below.
Proof.
We first define two hidden features in the Taylor layer ˜
z
k
= (cid:16) I kk ⊤ y ( l − 1) (cid:17) ⊗ · · · ⊗ (cid:16)
I k 1 ⊤ y ( l − 1) (cid:17) , and h k
= G k ˜
z
k .
Let σ 2 h ,k
= Var[( h k ) j ] denotes the variance of h k , and ν z,k = E
[(˜ z k ) 2 i ] denotes the second order origin moment of ˜ z k .
We can first derive the relationship between the variance of y ( l ) and h k .
According to Eq.
10, in
TaylorNet, we have y ( l ) =
β + (cid:80)
Nk
=
O k h k .
And it can be decomposed into
[Equation] [Equation]
Therefore, according to Lemma E.2, we can derive the variance of y ( l ) as
[Equation]
Given that E [( h k ) j ] = E [ G k ˜
z k ] = 0 , the above Eq.
37 can be further simplified as
[Equation]
Next, we establish the relationship between σ 2 h ,k and ν z,k .
We can decompose h k
= G k ˜
z k into the following formula.
[Equation]
Therefore, according to Lemma E.2, we can derive σ 2 h ,k as
[Equation]
Next, we establish the relationship between ν z,k and ( σ ( l − 1) y ) 2 .
We can decompose ˜ z
k = (cid:16)
I kk ⊤ y ( l − 1) (cid:17) ⊗ · · · ⊗ (cid:16)
I k 1 ⊤ y ( l − 1) (cid:17) into (˜
[Equation] [Equation]
Therefore we can derive ν
z,k as
[Equation] [Equation]
According to Conjecture E.
[Equation]
we can further simplify the above Eq.
42 as
[Equation]
Combining Equation
[Equation]
40 and
[Equation]
we have
[Equation]
completing the proof
[Equation]
Initialization.
In order to stabilize the model training of our TaylorNet, we should choose σ 2 O,k , σ 2 G,k , σ 2 I,k such that ( σ ( l ) y )
= ( σ ( l − 1) y ) 2 .
Namely, any combinations of σ 2 O,k , σ 2 G,k , σ 2 I,k satisfying the following equation is a viable choice for initialization.
[Equation]
In addition to the requirement of ( σ ( l ) y ) 2 =
( σ ( l − 1) y ) 2 , another desirable property is that the second order moments of intermediate features h k , ˜
z k should also be equal to the variance of the input.
Namely, we would also like to ensure that σ 2 h ,k
= ν
z,k = ( σ ( l − 1) y ) 2 .
Consequently, we should choose the initialization
[Equation]
F A NALYSIS ON R EDUCIBLE T AYLOR I NITIALIZATION
In this section, we will elaborate the initialization method for Reducible TaylorNet (R-TaylorNet).
We keep using the notations in Section 4.2, 4.3 and E. Since the original input and output variable y
( l − 1) , y ( l ) are omitted in reduced TaylorNet, we will alternatively examine the relationship between the variance of h ( l − 1) and h ( l ) .
Recall that h ( l ) is defined in 4.2 and E as
[Equation]
Similar to the analysis in Section 4.3, we assume that 1) all elements in h ( l − 1) follow independent zero-mean Gaussian distribution, 2) the weights in T k , G k are initialized independently with zero mean.
3) v k is initialized to 0.
First, we can establish the relationship between ( σ ( l ) h ,k ) 2 and ν z,k in the same way as described in
Section E, which can be written as
[Equation]
Next, we establish the relationship between ν z,k and ( σ ( l − 1) h ) 2 .
In reducible TaylorNet, ˜ z k is calculated as
[Equation]
Below, we introduce a more fine-grained block multiplication notation of T
kj h
( l − 1)
[Equation]

[Equation] [Equation]
Given that v k is initialized to
[Equation]
we can decompose the above matrix multiplication into (
[Equation]
When choosing the initialization variance for the original TaylorNet as shown in Eq.
[Equation]
we can set different λ k to scale the importance of k-th-order term.
Similarly.
in Reducible TaylorNet, we would also like to scale the variance of T kjm for different m .
Namely, let σ 2 T,km denote the variance of
T kjm , and σ 2 T,k be the standard variance for T kj , then they should satisfy σ 2 T,km =
λ m σ 2 T,k .
Now we focus on 2-order Reducible TaylorNet.
We can derive ν z,k for k = 1 , 2 as
[Equation]
Initialization.
Using the same methodology in Section E, we need to choose σ 2 T,k , σ 2 G,k such that ( σ
[Equation]
l
[Equation]
h ,k ) 2 =
( σ ( l − 1) h ) 2 .
On the other hand, we would also like to ensure that ν z,k = ( σ ( l − 1) h ) 2 .
Hence, according to Eq. 49, 53 and 54, 2-order Reducible TaylorNet in our paper should use the following initialization
[Equation]