Full text
id179037 ON THE COMPOSITION OF NEURAL AND KERNEL LAYERS FOR MACHINE LEARNING ALEX MARTORELL LOCASCIO Thesis supervisor: LUIS ANTONIO BELANCHE MUÑOZ (Department of Computer Science) Degree: Master's degree in data science Thesis report Facultat d'Informàtica de Barcelona (FIB) Universitat Politècnica de Catalunya (UPC) - BarcelonaTech
Abstract Deep Learning architectures in which neural layers alternate with mappings to infinitedimensional feature spaces have been proposed in recent years, showing improvements on the results obtained when using either technique separately. However, these new algorithms have been presented without delving into the rich mathematical structure that sustains kernel methods. The main focus of this thesis is not only to review these advances in the field of Deep Learning, but to extend and generalize them by defining a broader family of models that operate under the mathematical framework defined by the composition of a neural layer with a kernel mapping, all of which operate in reproducing kernel Hilbert spaces that are then concatenated. Each of these spaces has a specific reproducing kernel that we can characterize. Together all of this defines a regularization-based learning optimization problem, for which we prove that minimizers exist. This strong mathematical background is complemented by the presentation of a new a model, the Kernel Network, which manages to produce successful results on many classification problems. i
“S’ha d’escriure amb llibertat, amb gust, amb plaer, per`o amb la m`axima observaci´o possible” Josep Pla “Hi un amor profund en la mem`oria del que havies volgut ser” Jordi Graupera Acknowledgements I want to start by thanking my professor and advisor Dr Llu´ıs Belanche, who through countless meetings and too many coffees has given me helpful advice and most importantly, good ideas. The conversations we had helped me carry on with this thesis. I am certain that his lectures and his knowledge are present in my writing. My parents also deserve a big acknowledgement, for all their support during my student life and all the difficulties of it. This thesis is a big milestone and I am grateful to share it with them. My classmates (and close friends) Pim, Enric and Louis are also part of this. It has been 2 tough years, but being able to work with them has made everything a little bit easier. ii
Contents 1 Introduction 1 2 Literature Review 3 2.1 The term ”Deep Kernel Learning” . . . . . . . . . . . . . . . . . . . . . . 3 2.2 DeepHybridmodels .............................. 5 2.3 Representer Theorem and Deep Learning . . . . . . . . . . . . . . . . . . 9 2.4 Random Fourier Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3 Important concepts in RKHS Theory 12 3.1 Kernel methods, RKHS and The Representer Theorem . . . . . . . . . . . 12 3.2 Approximations of the Gaussian RBF Kernel: Random Fourier Features . 16 3.3 Vector Valued Reproducing Kernel Hilbert Spaces . . . . . . . . . . . . . 17 3.3.1 Definitions and main properties . . . . . . . . . . . . . . . . . . . . 18 3.3.2 Representer Theorems . . . . . . . . . . . . . . . . . . . . . . . . . 19 4 A Representer Theorem for the concatenation of Llayers 22 5 A Deep Kernel Learning model: The Kernel Network 26 5.1 TheKernelNetwork .............................. 26 5.2 The RKHS in a Kernel Network . . . . . . . . . . . . . . . . . . . . . . . 27 5.3 Optimization of the Kernel Network . . . . . . . . . . . . . . . . . . . . . 31 6 Experimental Results 34 6.1 Evaluating the kernel network and other ML models over different data sets 36 7 Limitations and Future work 40 8 Conclusions 42 iii
List of Figures 2.1 Graphical Representation of the Deep Hybrid Model . . . . . . . . . . . . 6 2.2 Comparison between the explicit feature mapping in a Deep Hybrid Model and the ReLU activation function in a Feed-Forward Neural Net . . . . . 7 2.3 Illustration of deep hybrid model with two maxout neural-kernel blocks. Figure extracted from article “Deep neural-kernel blocks” . . . . . . . . . 8 6.1 Loss for kernel network with deep hybrid model parameters . . . . . . . . 35 6.2 Accuracy for kernel network with deep hybrid model parameters . . . . . 35 6.3 Loss for SGD with alternate optimization (3) . . . . . . . . . . . . . . . . 36 6.4 Accuracy for SGD with alternate optimization (3) . . . . . . . . . . . . . 36 6.5 Loss for Adam with alternate optimization (6) . . . . . . . . . . . . . . . 36 6.6 Accuracy for Adam with alternate optimization (6) . . . . . . . . . . . . . 36 6.7 Loss for kernel network in the australian data set across epochs . . . . . . 37 6.8 Accuracy for kernel network in the australian data set across epochs . . . 37 6.9 Kernel matrix for RFF Layer at epoch 0 . . . . . . . . . . . . . . . . . . 38 6.10 Kernel matrix for RFF Layer at epoch 150 . . . . . . . . . . . . . . . . . . 38 6.11 Kernel matrix for FC Layer at epoch 0 . . . . . . . . . . . . . . . . . . . 38 6.12 Kernel matrix for FC Layer at epoch 150 . . . . . . . . . . . . . . . . . . 38 6.13 Kernel matrix for Neural Layer at epoch 0 . . . . . . . . . . . . . . . . . 39 6.14 Kernel matrix for Neural Layer at epoch 150 . . . . . . . . . . . . . . . . 39 6.15 Norm of the weight matrix for the neural layer . . . . . . . . . . . . . . . 39 List of Tables 5.1 Number of parameters in a Neural-Kernel Block + Fully Connected Layer 26 6.1 Details of data sets used during experiments . . . . . . . . . . . . . . . . . 34 6.2 Results for CNAE-9 data set listed in deep hybrid model references . . . . 34 6.3 Comparison between SGD and Adam via alternate optimization or not, withassociatedmetrics ............................ 35 6.4 Results on different models . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.5 Running time for different models . . . . . . . . . . . . . . . . . . . . . . . 38 iv
1 Introduction Deep Neural Networks and Kernel methods are two pillars of Machine Learning algorithms, and more specifically, of regularization-based learning. They have been studied as independent methods and both of them have gone through an uncountable amount of extensions, ramifications and generalizations. In fact, if someone now mentions these model families without giving more details, the reader asks for more specifications: which type of neural network are they referring to, what are we trying to predict, which kernel are we using, how many hyperparameters does it have, whether it is a deep model or not, ... as it is expected, the sophistication has not ceased to increase. However, let us try to set some boundaries to orientate the reader. In neural networks, born with the multilayer perceptron (MLP), have have gone through many advancements, to produce complex models as LSTMs, convolutional neural networks (CNNs) and autoencoders. All these newer architectures belong to the framework defined by the umbrella term deep neural network, or sometimes an even bigger one, deep learning. The word ”deep”, usually just means more than one hidden layer; as the original models had just one hidden layer between the input and output. With regards to Kernel methods, the limits are easier to set. The main idea is to try to solve a problem but in a different space. If we are discussing a classification problem, this is easy to explain: it is more often than not impossible to find a separating hyperplane between the two classes. However, what if these data points are mapped to a higher dimension ? Then, it may be possible to find a function the correctly classifies the two classes. This concept of optimizing a function in a different space is the fundamental notion behind kernel methods. They rely on a strong mathematical theory which is branch from functional analysis. To summarize, the data points are mapped to a Hilbert space of functions H. Then, a function f∈ H can be found such that a prediction f(x) is a linear combination of the data points mapped to this new space. In recent years, research seems to be willing to see if these two groups of models - in theory far apart from each other - have anything in common besides that they take data points as inputs. The authors of [1] refer to this process as hybridization. The idea behind it is to apply from the deep learning field to kernel methods and vice-versa. A starting point were gaussian processes, as the authors of [2] show us. They present a model that lays the first stone in this hybridization technique between deep networks and kernel methods. In their paper, the authors go over the comparison kernel-neural net: It seems like that in the 1990s, neural networks were seen as a revolutionary model that would take away the podium from kernel methods. This article , which was published in 2015, is a clear sign that this never happened, and subsequent research has proven that hybridization produces better results in many performance metrics, and what is more interesting, allows to solve new problems in Machine Learning for which an answer had yet to be found. This thesis is structured in three main parts: The first one, to which Chapter 2 is dedicated, is a review of the literature published in the recent years about the main topics the are crucial to this writing. These are grouped in 4 categories: Firstly, what do we understand for the term ”deep kernel learning” as of today. Secondly, it covers one of the better known hybridization proposals, the deep hybrid model. This proposal is what this thesis aims to formalize and generalize. After this, the two aspects that are more related to kernel methods are reviewed: representer theorem and approximations to kernels. The first aspect deals with the different versions of this essential result in 1
kernel methods. The second one discusses the advances in approximating one of the more important kernels used in kernel methods, the gaussian RBF. The second part is the theoretical backbone of the thesis and spans over three chapters: 3, 4 and 5. The first one, whilst trying to avoid excessive meanders and unnecessary technical detail that exceed our scope, it presents the essential mathematical tools behind the goal to establish connections between Kernel methods and Deep Learning. Chapter 4 is dedicated to stating a Representer Theorem for a multi class Deep Kernel Learning problem, a fundamental result to be able to characterize the Deep Kernel Learning model presented in Chapter 5, the Kernel Network. Aside from the equations of this new model and its mathematical details, a thorough training algorithm for it is also given. Finally, the last part of the thesis, reserved to Chapter 6 and 7, is dedicated to presenting the experimental results obtained, as well as comparing them with other existing machine learning models. A rigorous approach is used to assess the quality of the model. Last but not least, and before some concluding thoughts, a brief chapter is included which a dissertation about some of the limitations encountered, as well as possible extensions and a future outlook. 2
2 Literature Review There are several building blocks that come into place when discussing Deep Kernel Learning (DKL). Firstly, the term itself. Nowadays, there are many machine learning algorithms that are said to be DKL, hence, it becomes necessary to list a set of characteristics that such algorithms fulfill. It is also important to consider the theoretical framework behind DKL. Functional analysis and the representer theorem provide it for Kernel methods, and it is crucial to this thesis to see if this framework can be extended to DKL. Finally, kernel approximation is an important topic, in order to reduce the computational cost of learning algorithms. In the whole of this thesis, a Learning problem in the context of machine learning is assumed. This consists of a set X⊂Rd,Y=R, a kernel function k:X×X→Rwhich induces a mapping ϕinto an RKHS H, a Hilbert space of functions f:X→R. (See Chapter 3 for more details). 2.1 The term ”Deep Kernel Learning” It is clear that the term deep kernel learning is already mainstream in the machine learning community. To put it into the context of our thesis, it can be useful to trace it back to its origins. Survey paper [3] is a good reference for the array of terminologies that have appeared in recent years, as it also focuses on finding points in common between Deep Kernel Learning (DKL) and Multiple Kernel Learning. (MKL) In MKL, the kernel kis defined as a combination of predefined kernels k=PM m=1 µmkm. The feature mapping is to a space induced by several kernels, defined as ϕ(x) = ϕ1(x),...ϕM(x)T The term µmindicates the weight of each kernel, a combination that is learnt during training. Additional constraints may be imposed, such that Pmµm= 1. [3]. One of the main references for Multiple Kernel Learning is, which states that combining kernels instead of 1 yields to better results in existing algorithms [4]. For instance, one of the more simple kernel combinations which is the sum k1+k2or the multiplication k1·k2in a SVM arw shown to improve the test accuracy significantly. DKL, on the other hand, is not based upon on a convex combination of kernels but rather in their composition. In general, a DKL model consists of several mappings into different feature spaces, which can be expressed as: k(xi, xj) = ϕ1◦ϕ2◦. . . ◦ϕL(xi)Tϕ1◦ϕ2◦. . . ◦ϕL(xj) Article [2] is the first one to coin in 2015 the term ”Deep Kernel Learning”, as its title suggests. Their proposal is a Neural Network with Llayers followed by a Gaussian Process (which produces a probabilistic mapping). Recall that a Gaussian Process f(X)∼ GP(µ, kγ) produces an output: f(X)∼[f(x1). . . f(xn)]T∼N(µ, KX,X ) (2.1) where µ=µ(xi) is the mean function and (KX,X )i,j=1÷n=kγ(xi, xj) is the covariance kernel. γis a hyperparameter, meaning that the covariances are parametrized by γ. It is clear then that a gaussian process is a collection of functions. The architecture proposed is: 3
Input →Hidden Layer 1 → ··· → Hidden Layer L→ ∞-layer The novelty of this model is the ∞-layer. This is the author’s way of referring to a gaussian process with an RBF Kernel, since as it is explained in Chapter 3, the feature mapping of an RBF kernel can be seen as an infinite basis function representation. The justification for this choice can be found in the introduction of [2]: In the late 90s, there was a debate about whether gaussian processes would end up replacing neural networks. This rivalry between models produced an important amount of literature comparing neural networks (adpative finite basis functions, architecture, regularization) and gaussian processes (infinite basis functions, kernels), which brings research to a new stage: Combining the structural properties of neural networks with the non-parametric flexibility of kernel methods. Kernel methods are non-parametric in the sense that they do not make assumptions about the data distribution, something that is not common to many other ML models. The structural properties of neural networks (neurons, activation functions, stacking layers) succeed in learning complex data patterns. Many developments have made since 2015. As of 2021, according to survey [3] there are three major families of models in the DKL context: •Combination of deep learning architectures and kernel machines, the first one being the front-end and the latter the back-end part of the model. An example is a combination of a CNN with an SVM. The features learnt by a CNN are then used to train an SVM with the Gaussian kernel. •Incorporation of kernel methods into deep architectures via the stacking principle: A first example is an SVM trained in a standard way and then applying a kernel activation on the support vectors, which are used as inputs for a second SVM. Another example is training deep neural networks with kernel blocks in between neural layers, which provides new representations of the data to possibly improve learning. This architecture, called Deep Hybrid Model was ideated by Mehrkanoon et al. and explained in [5, 6]. Since this architecture is one of the main inspirations and is studied throughout this thesis find a thorough introduction to its structure in section 2.2. The DKL model presented in this thesis, called Kernel Network, would also fall into this category. (Chapter 5) •Integrating Deep Learning ideas into Kernel Learning. One of the more well-known examples of this is the arc-cosine kernels which mimic deep neural networks. An attempt to combine MKL and DKL (which is explained below) is found in [7]. The authors generalize the MKL optimization problem as: min k∈Kmin f∈Hk N X i=1 L(yi, f(xi)) + λ∥f∥Hk(2.2) where Hkis the reproducing kernel Hilbert space associated to kernel k, and Kis the optimization domain of the candidate kernels. Since this is an MKL framework, one should expect that Kis the domain obtained by a convex combination of kernels (see above). The extension proposed by the authors is Multiple Layer Multiple Kernel Learning (MLMKL), which is to generalize equation 2.2 to a concatenation of layers, which results in a domain of l-level multi layers: K(l)={k(l)(·,·) = g(l)([k(l−1) 1(·,·),...k(l−1) m(·,·)])}(2.3) 4
Finally, a mention to developments from a mathematical point of view. Reserach has focused on generalizing and unifying the different statements that have appeared as Representer Theorems. [18] is a generalization by offering necessary and sufficient conditions for these theorems, a complicated issue as seen in section 3.3.2. Mathematical preliminaries are needed which clearly , such as linear operator theory and specifically subspace valued maps . On this same note, [19] states a representer theorem for Hilbert space valued functions (Vector Valued in our case). 2.4 Random Fourier Features Random Fourier features are introduced by Rahimi in Recht in 2007 [9], as an approximation for the Gaussian RBF Kernel. ( cf. Section 3.2) k(x, y) = ⟨ϕ(x), ϕ(y)⟩ ≈ z(x)Tz(y) (2.15) with z:X→RD. Instead of evaluating the kernel function, or relying on the kernel trick (first equality) the input is transformed via z. As it will be shown, there is not just one definition for z. This is only possible for shift-invariant kernels, i.e. k(x, y) = k(x−y). The authors in [9] show that this approximation |k(x, y)−z(x, y)|can be bounded to error εwith only D=O(Dε−2log 1 ε2). Another perspective which of special interest in this thesis is the error bounds for Random Fourier Features. In [9], a first error bound is given. The article entitled ”On the Error Bounds of Random Fourier Features”, [20] reviews the definition of Random Fourier Features in attempts to tighten the probability bound in [9]. However, the important addition to the study of this approximation is that the authors study the error in specific ML models, like Kernel Ridge Regression or Support Vector Machines. In other words, they study directly the difference in predictions due to using zinstead of k. If h(x) = αTk(xi, x) and ˆ h(x) = αTˆ kxis the function obtained through the Representer Theorem, it is possible to bound |ˆ h(x)−h(x)|by the differences ∥ˆ kx−kx∥2and ∥ˆ K−K∥2. What about the applications of Random Fourier Features in different settings? They have been used in Machine Learning algorithm since their appearance in 2007. Survey [21] lists many of them. The simplicity and practical usage of this approximation sparked the question if other kernels, could have also a low-dimensional approximation. This applies to the inhomogeneous polynomial kernel k(x, y)=(⟨x, x′⟩+c)pfor which we know the feature mapping ϕ(x) has dimension d+p p, a combinatorial number that explodes for large p. Spherical Random Features are presented in [22]. They provide an approximation for the polynomial kernel in the unit sphere. The impossibility of applying Bochner’s Theorem to guarantee a non-negative Fourier Transform of the polynomial kernel is remedied by Spherical Random Features, which are similar to RFFs when it comes to defining the mapping ϕ, but different when it comes to defining p(ω) This finding is useful to extend Deep Hybrid models, in the sense that the kernel layer could be a mapping by a different kernel than the Gaussian RBF. 11
3 Important concepts in RKHS Theory In this chapter, an overview is given of the necessary concepts that illustrate the results of Chapters 4 and 5. This consists of a brief summary of Kernel Methods and the Representer Theorem as well as detailed definition of two important kernels: The Gaussian RBF kernel and the Polynomial Kernel. This allows to introduce further concepts in RKHS Theory, which are central to this thesis: Bochner’s Theorem guarantees that a shift invariant kernel is positive definite if and only if it is the Fourier Transform of non-negative measure. This gives us a possibility to approximate the Gaussian RBF Kernel through computation of the fourier transform. Since this is an approximation, an error with respect to the true value is incurred. In section 3.2 some of the error bounds are listed, which will be useful to further characterize the models in Chapter 5. Section 3.3.2 is devoted to Vector Valued reproducing kernel Hilbert spaces, an extension to the definition of provided in Section 3.1. As shown, this consists of an extension to functions f:X→R, to the case f:X→RD, for D > 1. representer theorems, which also are an extension from the real-valued function to the vector-valued function are presented. Vector valued RKHS are defined by matrix valued kernels, meaning that now there is a kernel matrix k:X×X→RD×D. Studying matrix-valued kernels and its properties are not the objective of this thesis, but rather to study their relationship with a scalar-valued kernels, so that the models presented have a simpler expression. 3.1 Kernel methods, RKHS and The Representer Theorem Let Xbe a non empty set. From now on, X=Rdis assumed. A symmetric function is called a positive semi definite kernel if k:X×X→Rif for every n∈N, for every x1, . . . , xn∈Xand ∀ai, ajPiPjaiajK(xi, xj)≥0. A simple example of a kernel is the linear kernel, k(x, y) = ⟨x, y⟩Rdfor x, y ∈Rd, which clearly is symmetric and positive semi definite. The definition below links the concept of kernel and Hilbert space. Note that in some texts this appears as a Proposition. Definition 3.1. Let Xbe a non-empty set. A function k:X×X→Ris a kernel if and only if there exists a Hilbert space Hand a map ϕ:X→ H such that for all x, x′∈ H: k(x, x′) = ⟨ϕ(x), ϕ(x′)⟩H(3.1) Equation is referred to as the kernel trick. This means that similarities can be computed in the Hilbert space directly by evaluating the kernel instead of computing the inner product in H. This can be advantageous as we might not have an explicit expression ϕ, or such expression can be hard to obtain. The following two definitions, which are intertwined, are the backbone of Kernel methods. Definition 3.2. Let X⊆Rdand Ha Hilbert space. A kernel function k:X×X→R is called a reproducing kernel of H: (1) ∀x,k(x, ·)∈ H 12
(2) ∀f∈ H and ∀x∈X f(x) = ⟨f(·), k(x, ·)⟩(reproducing property) Then His a reproducing kernel Hilbert space. Example 3.3. Most Hilbert spaces are Reproducing Kernel Hilbert spaces. Spaces (with their respective inner product) such as R,Rd, l2, L2are examples of RKHS. A more formal definition for an RKHS follows. Definition 3.4. An RKHS is a Hilbert space of functions where the linear evaluational functions are continuous [x](·) :H→R f→[x]f=f(x)∀f∈H∀x∈X Kernel methods and RKHS on their own cannot work without the representer theorem. This is a result that comes form Riesz’s representation lemma. In Section 2.3, a few mentions were made to the representer theorem and some extensions that have been tried. However, it is important to stress its importance in the context of machine learning. Observe that the optimization problem min f∈H L((x1, f(x1)),...,(xn, f(xn))) + λ∥f∥2(3.2) is solved in a Hilbert space H. As said before, the space Hcan be of high dimension or infinite. The representer theorem says that the solution to equation (3.2) is a linear combination f(·) = N X i=1 K(·, xi) Theorem 3.5. (Representer Theorem) X=Rd,Y=Rand k:X×X→Ra kernel function. His the RKHS induced by k, Θ : H → Ra non-decreasing function (regularizer) and the loss L. The optimization problem: minf∈HL(f(x1), y1), . . . (f(xn), yn)+ Θ(∥f∥2) has a solution of the form f(·) = Pn i=1 αiK(xi,·)∈ H Proof. Consider Y= span{K(xi,·)i= 1, . . . , N} ⊂ H, a closed set. By the Orthogonal decomposition Theorem H=Y⊕Y⊥. Therefore, if f∈ H,f=fY+f⊥ Y. By applying the reproducing property, f(x) = ⟨f(·), K(x, ·)⟩=⟨fY, Kx⟩ ∀x∀f∈ H Now, fY=PN i=1 αiK(xi,·). By definition ∥f∥2=∥fY+fY⊥∥2≥ ∥fY∥2. Since Θ is non decreasing, Θ(∥f∥2)≥Θ(∥fY∥2) for all f∈ H. The minimizer fneed not be unique. For that, the convexity of the functional is necessary. (More on that in Section 3.3.2). It is important to point out that the monotonicity of Θ (i.e. it is a non decreasing function) is to guarantee that there always exists a minimizer of the form f(·) = PN i=1 αik(·, xi). This is used in the last line of the proof. 13
One of the references for Kernel methods and Support Vector Machines is [23], which sets it in the broader context of Statistical Learning. Chapter 4 is dedicated to Kernels and provides a formal theory about the gaussian rbf kernel and its RKHS, which this review on Kernels and RKHS Theory is partly based on. In [23], a distinction is made between real valued kernels and complex valued kernels. That is not the case of [24], another important reference for Kernel methods. Complex valued kernels are not considered in this thesis, as the possible solutions of the function to be approximated are in an R-Hilbert space. For more information, the reader is referred to Chapter 4 in [23]. Let us move to discuss infinite feature mappings. The first concept needed is the one of sequence, but a particular one: a square summable sequence is {αk}k≥1for which ∥αk∥2=P∞ k=1 α2 k<∞. Definition 3.6. The Hilbert space of square summable sequences l2is the complete vector space of sequences such that for (αk)k∈l2then P∞ n=1 α2 k<∞.l2is endowed with inner product ⟨{αk}k,{βk}k⟩=Pkαkβk. Observe that feature map ϕ:X→ H need not be unique. Consider the kernel matrix K= (k(xi, xj))i,j=1,...,N . Since a kernel matrix Kis positive semidefinite it can be decomposed as K=V DV T. By definition of a kernel K=ϕϕTwhere ϕ= ϕ(x1) . . . ϕ(xN) (3.3) Which is why ϕ(xi)T=vT iD1/2is a feature map. However, ϕ′(x) = Qϕ(x), when Qis an orthogonal matrix, is another valid feature map. This is clear since for all i, j ∈ {1, . . . , N} we have ϕ′(x)ϕ′(x′) = ϕ(x)TQTQϕ(x) = ϕ(x)Tϕ(x). The following lemma characterizes an important fact: Kernels can be described as the inner product between two sequences of l2, meaning that it possible to have a kernel with a feature mapping to an infinite dimensional Hilbert space. Lemma 3.7. Let Xbe a set and (ϕi(x))i≥1a sequence of l2, where ϕi(x) is the i-th coordinate of the feature map to the Hilbert space H=l2. The function defined as k(x, x′) = ∞ X i=1 ϕi(x)ϕ(x′) is a kernel. This Lemma is a classical result in Kernel methods, and can be found in Section 4.1 of [23]. Proof. H¨older’s inequality for l2spaces gives ∞ X i=1 |ϕi(x)ϕi(x′)|≤∥ϕi(x)∥l2∥ϕi(x′)∥l2<∞ because (ϕi(x)) belongs to l2. Now, define H:= l2and trivially ϕ(x) := (ϕi(x)) maps X to the Hilbert space. This proves that kis a kernel. 14
It is clear that the Gaussian RBF Kernel and the Polynomial Kernel are widely used in machine learning [24, 13, 25]. Observe that they are both kernels with infinite or potentially infinite dimensional feature mappings, which In Chapter 5 these kernels will become necessary to describe the kernel network model, as well as a link between activation functions and RKHS. Find below detailed of these two kernels. Notation. [d] is used to indicate {1, . . . , d}. Hence [d]pindicates the cartesian product {1, . . . , d}× p ···×{1, . . . , d} Example 3.8 (Homogeneous Polynomial Kernel).The Polynomial kernel is defined as k(x, x′)=(⟨x, x⟩+c)d,dis the dimension. Note that if c= 0 the polynomial kernel is referred to as homogeneous. For instance, given p= 2 and d= 2, the expansion of the product is (x1, x2),(x′ 1, x′ 2)2 = (x1x′ 1+x2x′ 2)2=x2 1x2 1′+ 2x1x′ 1x2x′ 2+x2 2x2 2′= =X j∈[2]2 [x1]j1[x2]j2·[x′ 1]j1[x′ 2]j2 More generally, ⟨x, x′⟩p=X j∈[d]p [x]j1·. . . ·[x]jp[x′]j1·. . . ·[x′]jp=⟨ϕ(x), ϕ(x′)⟩(3.4) where ϕ(x) has components being all possible p-th degree ordered products of the entries of x. In other words, for the case d= 2, p = 2, we have ϕ(x)=(x2 2, x2x1, x2 1) Example 3.9 (Gaussian RBF Kernel).The Gaussian RBF kernel is defined as k(x, x′) = e−∥x−x′∥2 2σ2=e−γ∥x−x′∥2 σ2or its equivalent γis a hyperparameter. To find the feature mapping, observe e−γ∥x−x′∥2=e−γ∥x∥2e2γxTx′e−γ∥x′∥2 Using the taylor expansion at x= 0 e2γxTx′= ∞ X k=0 1 k!(2γ⟨x, x′⟩)k Using the results from the polynomial kernel, we obtain the feature map ϕ e2γxTx′=2kγk k!X j∈[d]k [x]j1·····[x]jk[x′]j1·····[x′]jk(3.5) Clearly, the feature mapping for the Gaussian RBF kernel is: ϕ(x) = e−γ∥x∥2r2kγk k! k Y i=0 xji(3.6) If the polynomial is of infinite degree, the feature mapping defined for both kernels is ϕ:Rd→l2(N). The next section is devoted to approximations to the Gaussian RBF Kernel via Random Fourier Features. An interesting discussion, which is found in [26] attemps to approximate the Gaussian RBF through the taylor expansion and comparing its error with the approximation through RFFs. 15
3.2 Approximations of the Gaussian RBF Kernel: Random Fourier Features Let us begin with two important definitions. Definition 3.10. The Fourier transform of a function on the eucliedan space Rnis defined as: ˆ f(ξ) = ZRn f(x)e−i2π⟨ξ,x⟩dx (3.7) where ξand xare vectors of Rn. Definition 3.11. A scale invariant kernel on Rdis a kernel function k:X×X→Rsuch that k(x, x′) = k(x−x′) for x, x′∈Rd The Gaussian, Laplacian and Cauchy Kernel are examples of shift-invariant kernels. Notation. If v∈Cn,v∗denotes the conjugate transpose, i.e. the operation of transposing v, and then applying the complex conjugate (a+ib becomes a−ib) Theorem 3.12 (Bochner).A continuous shift-invariant kernel is positive definite if and only if it is the Fourier transform of a non-negative measure p(ω). Observation 3.13. If k(0) = 1, p(ω) is a normalized probability density function. Now, in application of Bochner’s Theorem k(x−y) = ZRd p(ω)eiωT(x−y)dω =Eω[ξω(x)ξω(y)∗] (3.8) where ξω(x) = eiωTx. The second equality is the definition of expected value. In particular, ξω(x)ξω(y)∗is an unbiased estimate of k(x, y) when ωis drawn form p(the probability distribution). [9]. Observe that the expected value can be approximated (Monte-Carlo): Eω[ξω(x)ξω(y)∗]≈ D X j=1 ξωj(x)ξωj(y) = D X j=1 exp(iωT j(x−y)) where ωjare taken i.i.d from the probability distribution p. By Euler’s Formula and ∀j: exp(iωT j(x−y)) = cos(ωT j(x−y)) −isin(ωT j(x−y)) Since the kernel is assumed to be real-valued: k(x−y) = Re Eω[ξω(x)ξω(y)∗]=EωRe (ξω(x)ξω(y)∗)=Eω[cos(ωT(x−y))] Now, one can make the following observation (Law of total expectation) Eω[cos(ωTx+b)] = Eω[Eb[cos(ωTx+b)] |ω] = 0 b∼U[0,2π] which allows us to write Eω[cos(ωT(x−y))] = Eω[cos(ωT(x−y))] + Eω[cos(ωT(x+y)+2b)] =Eω[cos(ωT(x−y)) cos(ωT(x+y)+2b)] = Eω[√2 cos(ωTx+b)√2 cos(ωTy+b)] 16
The last equality is trigonometry 2. Observe that we now a mapping defined: ξω(x) = zω(x) = √2 cos(ωTx+b), with ω∼p(ω) and b∼U[0,2π]. In summary, we have proved the ξω(x)ξω(y)has expected value k(x, y). Now, the final step is to define the mapping ϕ(x), which has dimension D. As explained in the following algorithm, the mapping will be based on sampling D ω’s and b’s from their respective distributions. The algorithm for calculating Random Fourier Features provided in [9] for the Gaussian RBF Kernel is summarized in the steps below: (1) Compute the Fourier transform pof the shift-invariant kernel k (2) Draw Diid samples ω1, . . . , ωD∈Rdfrom p(ω). as well as Diid samples for b, b1, . . . , bD∈Rfrom the uniform(0, 2π) . (3) Define z(x) = q2 Dcos(ωT 1x+b1). . . ωT Dx+bD)T First note that the fourier transform of the gaussian RBF kernel is also a gaussian, in particular p(ω) = (2π)−D 2e−∥ω∥2 2 2. Also, note the differences between the feature mapping and the one the author of the Deep Hybrid model employs (see Section 2.2). These differences and their affect will be discussed in Chapter 5. It is clear now that the definition z(x) is not unique and that authors have used different versions. Research paper [20] attempts to list advantages and disadvantages between using the z(x) defined previously or as: ˘z(x) = r2 Dsin(wT 1x) cos(wT 1x). . . sin(wT D/2x) cos(wT D/2x)T The reason why it is possible is direct consequence from trigonometry and noting that we have only sampled D/2. ω’s from p(ω). The conclusion that z(x) is superior than ˘z(x) for the Gaussian Kernel. Finally, to show the versatility of RFFs, recall the representer theorem from Section 3.1, and apply it to obtain a linear expansion of the RFFs: f(x) = N X i=1 αik(xi, x) = N X i=1 αi⟨ϕ(xi), ϕ(x′)⟩ ≈ N X i=1 αiz(xi)Tz(x) = ˆwTz(x) (3.9) with w=PN i=1 αiz(xi). 3.3 Vector Valued Reproducing Kernel Hilbert Spaces The representer theorem considers Xto be set and Y=R. [14], which is the most common application. As mentioned in section 2.3 there have been extensions of the representer theorem to the case Y=Rd. More generally, the problem of learning real-valued function is extended to learning Hilbert-space valued functions. This needs a more complex mathematical structure, which is an extension of the field of Learning in Reproducing Kernel Hilbert Spaces (RKHS). The case where the output is a vector, i.e. Y=Rdis referred vector-valued. Hence, a theory was developed for the 2cos(x+y) + cos(x−y) = 2 cos(x) cos(y) 17
concept of Vector Valued Reproducing Kernel Hilbert Spaces (vector valued RKHS or VVRKHS from now on). It is not the goal of this thesis to provide a thorough presentation the theory surrounding vector valued RKHS, but rather to highlight the important definitions and results that allow to prove the statement for the two-layer representer theorem, one of the main results of the Thesis. The following definitions and properties are extracted from the main reference in vector valued RKHS ([10]). A less formal introduction to vector valued RKHS, among other topics, can be found in [27]. Notation. In [10] two different notations are used for the inner product: (·,·) and ⟨·,·⟩. The first one is used for the Hilbert space Y(i.e. the output ), and the latter for the RKHS HHere we adopt ⟨·,·⟩ to denote the inner product of any Hilbert space. 3.3.1 Definitions and main properties Let Xbe set, Ya Hilbert space, and Hthe Hilbert space of functions f:X→Y. From now on, Y=RD Definition 3.14. His a Vector Valued Reproducing Kernel Hilbert space if there exists a kernel function K:X×X→RD×Dsuch that (1) K(x, ·)z∈H(X, RD)∀x∈Xand z∈RD (2) zTf(x) = ⟨f, K(x,·)z⟩H(X,RD)∀x∈X,∀z∈RDand ∀f∈H(X, RD) Observe the main difference with the RKHS theory described in [13], which is for kernels K:X×X→R, which is called a scalar-valued kernel in comparison to the function defined above, which is a matrix-valued kernel. Also, the difference in the reproducing property with respect to a scalar-valued RKHS. Example 3.15. K(x, y) = xyTis a matrix-valued kernel. [28] When constructing matrix-valued kernels, a relationship with the scalar valued counterpart can be established. Definition 3.16. Let K:X×X→RD×D,k:X×X→Rand A∈RD×Dpositive semi-definite matrix. Define K(x, x′) = k(x, x′)A Kis called a separable kernel. There exists is an extension of this definition to a more general case, K(x, x′) = p X i=1 ki(x, x′)Qi where Qipositive semi definite matrices. Observe that the matrix Acan be initialized in many different ways, and learnt. [27]. Definition 3.16 allows to work with scalar valued kernels in vector valued RKHS. For 18
instance, for a matrix valued kernel K:X×X→RD×Dthe Gaussian RBF Kernel can be adapted to this new context by defining: K(x, x′) = e−γ∥x−y∥2diag(A) (3.10) In other words, between two data points xand x′, the matrix valued kernel Khas nonzero values in the diagonal, and they are all the same. This means that the outputs are treated as unrelated, i.e. i-th component does not have any relationship with j-th component. In other words Bencodes dependencies between the outputs. The following section goes over the representer theorems in the context of vector-valued output. As one clearly notices, these are equivalent versions of the Representer Theorem for scalar output. 3.3.2 Representer Theorems The following result is a representer theorem for the regularization problem in vectorvalued spaces, with the squared error loss. [10] Theorem 3.17. (Representer Theorem for vector valued functions) Consider {(xi, yi)}n i=1 ⊆ X×Ywith the following approximation scheme J(f) = n X j=1 ∥yi−f(xi)∥2+λ∥f∥2 If ˆ fminimizes Jin H, it is unique and has the form ˆ f= n X i=1 Kxici where the coefficients cj∈Yare the unique solution of the linear equations n X j=1 (K(xi, xl) + µδil)cl=yii= 1, . . . , n Proof. cf. p.7-8 [10]. The proof is similar to the scalar version of the representer theorem. Note that the statement of the theorem says the minimzer is unique. This is a rare case in representer theorems, as it is clear that for many functionals there will not be a unique minimizer. In this case, the uniqueness is thanks to the convexity of the loss function and the regularizer. Note the difference between the minimizer of the scalar case and the vector valued: f= n X i=1 αikxif= n X i=1 ciKxi(3.11) for αi∈Rand ci∈RD,k:X×X→Rand K:X×X→RD×D. In the previous section, the concept of separable kernel was introduced. For the vector valued case, we write the following: f(·) = n X i=1 K(·, xi)ci= n X i=1 k(·, xi)Aci= n X i=1 k(·, xi)diag(aj)ci(3.12) 19
where diag(aj). for aj∈Rfor j= 1, . . . , D. Observe that the output vector f(·) has D components, with fjbeingthe sum across the training data set of the product k(·, xi)ajcj,i. This observation is the basis for the presentation of the kernel network in Chapter 5. Notation. Yn=Y×n ···×Yis used to express the space that contains all the data points. Note that it is a Hilbert space with inner product ⟨c, c′⟩=Pn j=1⟨cj, c′ j⟩, for c, c′∈Yn, i.e. c= (cj∈RD)∈Yn This applies to the square error loss, but in general one can define the functional E(f) = V(f(xj),∥f∥2) (3.13) where V:Yn×R→Ras V(f(xj),∥f∥2) for all f∈ H. This notation is a formal way of describing the minimization problem: E(f) := n X j=1 L(yj, f(xj)) + Θ(∥f∥2) (3.14) The authors in [10] prove a theorem for any function which minimizes the functional E(f) Theorem 3.18. If for every y∈Ynthe function Θ : R+→R+defined for t∈R+ by h(t) := V(y, t) is strictly increasing and f0∈ H minimizes the functional V, then f0=Pj∈[m]Kxjcjfor cj∈Y. If Vis strictly convex, the minimizer is unique. Proof. cf. p. 9-10 [10]. The proof is very simple, and can be seen as a corollary of the previous theorem. Two other straightforward corollaries are stated below appear from this theorem. They appear under what is a common circumstance Emight have one than more minimum, provided that it is a function of sveral variables. Is the form of the f0the same? Corollary 3.19. If Vsatisfies the hypothesis of theorem 3.18 and f0∈ H is a local minimum of E, then f0=Pj∈[m]Kxjcjfor cj∈Y Proof. cf. p. 10 [10]. This first theorem shows that there is a representation theorem for any global or local minimum of E, provided that Vis strictly increasing. The corollary below is a result that can be applied when this strict convexity cannot be fulfilled. Corollary 3.20. If Vis differentiable at the local minimum f0∈ H of E then there exists c∈Ynsuch that f0=Pj∈[m]Kxjcj Proof. cf. p. 10 [10]. In summary, so far the following versions of the representer theorem have been covered: (1) For the scalar-valued case, a representer theorem is presented with a general loss function, and non-decreasing regularizer Θ. This is called non-parametric representer theorem [14]. 20
A more simplified equivalent expression of the kernel network is: f1(·) = N X i=1 d1 X p=1 c(1) i,p K(xi,·)ep(5.1) where the outer kernel Kis defined as K(x, x′) = K(f2◦f3(x), f2◦f3(x′)) 5.2 The RKHS in a Kernel Network In the kernel network ,we start by making the following observation: The first forward pass is defined as, f(x) = Wx +b, with x∈Rd,b∈Rd3. In order to include the bias in the computation of the Kernel, we define ˜ W= (b W)T, meaning that W∈R(d3+1)×dObserve that now x= (1 x1. . . xd)T. The linear kernel k(x, y) = xTyfor x, y ∈Rdcan be extended to a more general kernel k′(x, y) = xTAy where Ais a psd matrix. (If A=Id,k′(x, y) is the linear kernel) However, there is an important difference between the linear kernel and the general linear kernel. The linear kernel is just the dot product between two vectors, and the feature mapping, which is the identity, does not change the dimension of the space. This is why it is referred sometimes as a non-kernel. The general linear kernel does map the data points into another space, as its feature mapping ϕ:Rd→Rpis defined as ϕ(x) = WTx(see propositions below) Proposition 5.1. Given x, y ∈Rd, then k(x, y) = xTAy where A∈Rd×dis psd, is a kernel, and is called the general linear kernel. Proof. kis a kernel if it is symmetric and positive semi definite. If Ais psd , we can write A=WWTwhere Wdoes not to be a square matrix. Now, for x1, . . . , xN∈Rd, construct the matrix K= (kij)i,j=1,...,N defined as k(xi, xj) = xT iAxj. Then, for every c∈RN: N X i=1 N X j=1 cicjkij = N X i=1 N X j=1 cicjxT iAxj= N X i=1 N X j=1 cicj(xT iW)(WTxj) = = N X i=1 N X j=1 cicj(WTxi)T(WTxj) = N X i=1 ci(WTxi) 2 ≥0 What is next is to describe the RKHS of the general linear kernel. In the proof above, we have seen that an inner product can be derived from the kernel k(x, y) = xTWWTy, defined as ⟨ϕ(x), ϕ(y)⟩=⟨Wx, W y⟩Rp. A candidate RKHS is needed. Given f∈ H, f(x) = N X i=1 αiK(xi, x) = N X i=1 αi⟨WTxi, WTx⟩Rp=N X i=1 αiWTxi, WTxRp = =⟨α1WTx1+. . . +αnWTxn, WTx⟩Rp Clearly α1WTx1+. . . +αnWTxn=s∈RpSo, the functions are of the form f(x) = ⟨s, WTx⟩Rp, with s∈Rp. The candidate His defined to have inner product ⟨f1, f2⟩H= 27
sT 1s2, denoting the standard inner product in Rp. That His a Hilbert space is clear because His isomorphic to Rp, which is a Hilbert space. The remaining step is to check that it is indeed an RKHS: •Hcontains Kx=K(x, ·) : y7→ ⟨Wx, Wy⟩ •fs∈ H,x∈X: f(x) = ⟨s, WTx⟩Rp=⟨fs, fWTx⟩H=⟨fs, kx⟩ The following proposition summarizes this reasoning. Proposition 5.2. The RKHS of the general linear kernel is the space of functions f(x) = ⟨s, WTx⟩Rp, for s∈Rp. The RKHS is endowed with the inner product ⟨fW,x, fW,y⟩= ⟨WTx, WTy⟩. The norm induced by the inner product is ∥f∥2=xTAx, where A=W WT. The RKHS of the Gaussian RBF Kernel can be quite complex if a rigorous approach is taken. Find details in Chapter 4 of [23]. Considering that the RKHS is already known, few things can be said. However, recall that in ther kernel network, the RBF Kernel is approximated through random Fourier features. The feature map is z:X→ H′defined as z(x) = cos(ωTx) where ω∼N(0, σ2Id) The approximate RBF kernel k(x, y)≈z(x)Tz(y) defines an RKHS H′that may not be contained in the RKHS Hdefined by the Gaussian RBF Kernel [21]. For the last layer, which is fully connected, observe that its equations are defined by y=σ(Wh2+b), with W∈Rd2×d1, and where σ:Rd1→Rd1is an activation function. The question is if it possible to describe a pass through a fully connected with a function from an RKHS. In other words, an RKHS that contains the class of functions σ(⟨w, x⟩) for w, x ∈Rd2. We have already characterized a neural pass has activation function. The article titled Convexified Convolutional Neural Networks [11] by Zhang et al. aims to desribe a class of convolutional neural networks that are a convex optimization problem. This is done by developing the innovative idea that non linear convolutional filters ( h(z) = σ(⟨ω, z⟩) are seen as vector of a reproducing kernel hilbert space. An interesting result linked to statistical analysis is proven: For two-layer convolutional neural networks, the generalization error obtained by a convexified CNN converges to the generalization error of the best possible CNN. Establishing this strong bridge between deep neural networks and kernel methods comes with finding reproducing kernel hilbert spaces that can contain functions that represent the convolutional opreation. The authors introduce two important results, which we can study and apply to our problem. In the context of CNNs, the filters h:z7→ σ⟨w, z⟩, for w, z in Rd2are shown to be elements of the RKHS induced by the gaussian RBF kernel and the inverse polynomial kernel. Let us review the architecture they use to see if it can be compared to the kernel network. In [11] the different building blocks of a CNN are described in the following way: Given an input x∈Rd0a collection of patches {zp(x)}P j=1 of the full input vector x. For each vector, zp(x)∈Rd1. The convolutional operation is defined as: hj(z) := σ(ωT jz)z∈Rd1(5.2) where σ:R→R. Observe that ωj∈ {ωj}r j=1. In the CNN context, each function hjis called a filter. Observe that that h(z)∈Rr. The final expression for this CNN, a vector 28
f(x)=(f1(x), . . . , fd2(x)) ∈Rd2: fk(x) = r X j=1 P X p=1 αk,j,phj(zp(x)) Observe the similarities between this framework and the last layer of a kernel network. In a kernel network, the fully connected layer can be written as: fj(x) = σ(ωT jx) for j= 1, . . . , d1(5.3) i.e. a vector f(x) = (f1(x), . . . , fd1(x)) The equations for a Fully Connected Layer in the Deep hybrid model [5] are s=σ(Wh2+b). Observe that the problem can be reducec to si=σi(wx+b) for w∈Rd2. Applying the represnter theorem, we can obtain: σ(⟨ω, ·⟩)j= N X i=1 ciK(f2(xi), f2(·))jj= 1, . . . , N In this case, σbelongs to the RKHS induced by kernel K. However, this is not a trivial matter. In [11] the explicit feature map for both kernels is needed to prove Lemma 5.4 and 5.5. (In [11], the RBF Kernel is defined as ϕ:Rd1→l2(N), which is the definition given in this thesis) There exists a restriction over the activation function σ. A polynomial expansion is assumed: σ(x) = P∞ j=0 ajtj. The RKHS of the gaussian RBF kernel captures activation functions that are either a polynomial or a sinuosidal function (which can be approximated by the polynomial). The polynomial expansions of the sigmoid function and the ReLU are not contained in the RKHS of the gaussian RBF kernel [11]. This is because the coefficients of the polynomial expansion do not converge quickly enough to zero. These lemmas used in a CNN context study if the RKHS of these two respective kernels contain the function h:z7→ σ(⟨ω, z⟩). As explained before, we consider an equivalent in the fully connected layer of the kernel network, where the last part of it is defined as a vector x∈Rd1of components x= (σ(⟨w1,·, x⟩), . . . , σ(⟨wd1,·, x⟩), where w1,·are the rows of the weight matrix. Definition 5.3. The inverse polynomial kernel, for x, x′∈Rdis defined as k(x, x′) = 1 2−⟨x, x′⟩(5.4) The following two lemmas have very similar proofs, so only the proof for the RBF kernel is reproduced. Lemma 5.4. Assume that the function σ(x) has a polynomial expansion σ(t) = P∞ j=0 ajtj. Let Cσ(λ) := qP∞ j=0 2j+1a2 jλ2j. If Cσ(∥ω∥2)<∞, then the RKHS induced by the inverse polynomial kernel contains the function h:z7→ σ(⟨ω, z⟩) with Hilbert norm ∥h∥H=Cσ(∥ω∥2) Proof. Found in [11]. We assume ∥x∥2=∥x′∥2= 1 for this lemma on the gaussian RBF kernel. 29
Lemma 5.5. Assume that the function σ(x) has a polynomial expansion σ(t) = P∞ j=0 ajtj. Let Cσ(λ) := qP∞ j=0 j!e2γ (2γ)ja2 jλ2j. If Cσ(∥ω∥2)<∞, then the RKHS induced by the Gaussian kernel contains the function h:z7→ σ(⟨ω, z⟩) with Hilbert norm ∥h∥H=Cσ(∥ω∥2) Proof. Recall the feature mapping of the gaussian RBF kernel ϕ:Rd→l2(N): ϕ(x) = e−γ∥x∥2r2kγk k! k Y i=0 xji(5.5) (to the k-th coordinate) By assumption, ∥x∥2=∥x′∥2= 1. Observe that the feature map can be written as follows. Similarly, a vector ω∈l2(N) is defined as ω=eγr2kγk k!−1 2aj k Y i=0 ωji Now, the image of ⟨w, x⟩through the activation function is computed σ(⟨ω, x⟩) = ∞ X j=0 aj(⟨ω, z⟩)j= ∞ X j=0 ajX (j1,...,jk)∈[d1]k ωj1·. . . ·ωjkxj1·. . . ·xjk=⟨ω, x⟩(5.6) where the definition for the polynomial kernel is applied. Now, observe eγr2kγk k!−1 2e−γr2kγk k!= 1 (5.7) which is why ωcan be inferred from the product after the second equal sign of 5.6. This shows h∈ H The second part of the proof has to do with verifying hilbert norm of H: ∥ω∥2 2= ∞ X k=0 k!e2γ (2γ)ka2 kX (j1,...,jk)∈[d1]k ω2 j1ω2 j2·ω2 jk= ∞ X k=0 k!e2γ (2γ)ka2 j∥ω∥2j 2=C2 σ(∥ω∥2)<∞ This concludes the proof, ∥h∥H=∥ω∥2=Cσ(∥ω∥2) Now, in the CNN framework described in [11], as well as ours, the representer theorem can be applied, f3(t)j=σ(⟨ω, t⟩)j= N X i=1 ciK(f3(t), f3(ti))jj= 1, . . . , d1 i.e. there exists a kernel function K:Rd1×Rd1→Rsuch that K(z, z′) = ⟨ϕ(z), ϕ(z′)⟩, such that σ(⟨ωj, z⟩) = ⟨ωj, ϕ(z)⟩(5.8) However, both ϕ(z) and ωjbelong to l2(N). The problem needs to be reduced to a finite-dimensional one, which the author tackles by projecting onto a linear space, the one spanned by ϕ(f2(xi)). Note that this is not done for the kernel network, as the idea is to replicate the deep hybrid model, where the last layer is a fully connected layer. This is considered as possible and important extension of the model. 30
5.3 Optimization of the Kernel Network Notation. Sometimes, in attempt to simplify notation, it can be useful to refer to the row of the coefficient matrix c(i)for i= 1,2,3. We write either ck=ck,·where kis the row. The optimization problem described in Section 5.1 and extended in ?? is solved by minimizing the following functional given by the Representer Theorem: Jλ,µ,ν(f1, f2, f3) = N X j=1 L(f1◦f2◦f3(xj), yj) + λ∥f1∥2 H(Φ,Rd1)+µ∥f2∥2 H(Γ,Φ) +ν∥f3∥2 H(Ω,Γ) (5.9) As explained in previous section, recall that the definition of matrix-valued kernels through its scalar-valued used in this thesis is: K(xi, xj) = K(xi, xj)A where Ais a diagonal matrix. A= diag(a1, . . . , an) Let us compute the squared norm of f3(the rest are analogous): ∥f3∥2 Γ=N X k=1 d3 X o=1 c(3) k,oK(·, xk)eo, N X k′=1 d3 X o=1 c(3) k′,oK(·, x′ k)eo= = N X k=1 N X k′=1 d3 X o=1 c(3) k,oK(·, xk)eo, d3 X o=1 c(3) k′,oK(·, x′ k)eo= = N X k=1 N X k′=1 d3 X o=1 c(3) k,oc(3) k′,ok(xk, x′ k) where we have observed that eT iej=δij. To ease the notation, we can write: ∥f3∥2 Γ=cTKc = N X k,k′=1 c(3) k,·k(xk, x′ k)c(3) k′,·(5.10) As explained previously the Kernel Network has 5 sets of parameters: c(1)={c(1) i,p |i= 1, . . . , N, p = 1,...d1} W(1)=W∈Rd1×d2 c(2)={c(1) j,l |j= 1, . . . , N, l = 1,...d1} c(3)={c(3) k,o |k= 1, . . . , N, o = 1,...d3} W(3)=W∈Rd3×d Let us discuss the derivatives of the functional with respect to the parameters of the model. As it is clear, layers L= 1,2 have parameters that depend from L= 3. Therefore, full expressions for the derivatives ∂J ∂c(3) k,o and ∂J ∂w(3) k,o contain the derivatives with respect to 31
the other parameters of the kernel network and can be adapted accordingly. Ignoring the derivative of the cross-entropy (which is already known), we apply the chain rule. ∂J ∂f2f3(xi)=∂J ∂L ∂L ∂f1f2f3(xi) ∂f1f2f3(xi) ∂f2(f3(xi)) = =∂J ∂L ∂L ∂f1f2f3(xi) N X i′=1 d1 X p=1 c(1) i,p ∂ ∂f2f3(xi)f2(f3(xi)TWTW f2(f3(x′ i)) The derivative process can stop here (if f3is considered a constant) or continue ∂f2f3(xi) ∂f3(xi)= N X j=1 d2 X l=1 c(2) j,l ∂ ∂f3(xi)φ(f3(xi))Tφ(f3(xj)) (5.11) And now the expression of f3(xi) given by the representer theorem would be used in case the goal is to obtain ∂J ∂c(3) k,o , for instance. As it is standard in neural network training L(θ) = PN i=1 Li(θ), meaning that the derivatives are computed with respect to the functions evalueated at each data point xi. Note that the partial derivative with respect to a coefficient is computed for each data point i= 1, . . . , N. This explains the isubscript. Algorithm 1 below states the training process of the Kernel Network. Algorithm 1 Learning the Kernel Network (with one Neural-Kernel Block) Input. Data {(xi, yi)}n i=1, dimensions d1, d2, variance σ. 1. Initialize weight matrices W∈Rd3×d, V ∈Rd2×d1, as well as coefficient matrices c(1)∈RN×d1,c(2)∈RN×d2,c(3)∈RN×d3 2. Construct the kernel matrices K3∈Rd×d3,K2∈Rd3×d2,K1∈Rd2×d1while computing f3, f2, f1in this order for each x∈X: K3(x, x′) = xTWTWx′f3x= N X k=1 c(3) kk(xk, x) K2(f3x, f3x′) = ϕ(f3x)Tϕ(f3x′)f2f3x= N X j=1 c(2) jk(f3xj, f3x) K1(f2f3x, f2f3x′) = (f2x)TVTV f2x′f3f2f1x= N X i=1 c(1) ik(f3f2xi, f3f2x) 3. Solve the following optimization problem: ˆ h∈arg min J(h)λ,µ,ν where J(h) = N X i=1 L(h(xi), yi) + λ∥f1∥2 H1+µ∥f2∥2 H2+ν∥f3∥2 H3 (5.12) Output. A prediction h(x) = PN i=1 c(1) iK(xi, x) 32
The optimization problem 5.12 involves performing backpropagation over the different sets of parameters described. Backpropagation is done using a gradient descent algorithm. In the next chapter, performance is evaluated using the following two algorithms: stochastic gradient descent and Adam. In summary, if θdenotes the set of all parameters in the kernel network: θt+1 =θt−η∇θL where ηis the learning rate. On a final note, recall that [5] and [6], the functional minimized is J(W1, W2, b1, b2) = 1 n n X i=1 L(xi, yi) + γ[Tr(W1WT 1) + Tr(W2WT 2)] (5.13) Observe that the regularizer only affects the matrices of the neural layers. 33
6 Experimental Results In this section, the accuracy and the generalization capability of the kernel network model, as well as other metrics are put to the test. This is performed in comparison with two other Machine Learning model: The deep hybrid model (The core Neural-Kernel model) presented in [5, 6] and the multi-layer perceptron (MLP) In the Experimental Results section of [5] the deep hybrid model is put to test in 15 different data sets, varying in number of features and in size. The comparison of the deep hybrid model (One neural-kernel block or two) is made with two different models: neural networks (One hidden layer or two). and Shallow LS-SVM (primal and dual). In [6], the experiments section is dedicated to exploring any positive differences between the extended deep hybrid model (deep Neural-Kernel architectures: average, maxout and CNN) and the original deep hybrid model. Also, accuracies on the test set are stated for LS-SVM and TROP-ELM. In this second reference, the number of data sets put to the test is reduced to 12, a subset of the ones tested in the first reference, together with the Motor data set. Table 6.1 lists the different data sets (retrieved from the UCI ML repository) tested in this report, with their dimension and number of attributes. Data set N Partition train-test Features Classes Australian 690 552/138 14 2 Titanic 2201 1760/441 3 2 Sonar 208 166/42 60 2 CNAE-9 1080 864/216 856 2 Adults 31100 880/220 93 2 Table 6.1: Details of data sets used during experiments The author of the deep hybrid model only provides the specific parameters for CNAE-9 dataset, which are listed in [5]. These are h1= 300, h2= 400, σ= 0.7 and an unspecified learning rate. In page 50-51 of [5], it is stated that the parameters for h1and h2for all the data sets are found using random search strategy. The author seems to indicate that he uses stochastic gradient descent (SGD) as the algorithm that optimizes the parameters of the deep hybrid model. The author claims accuracy results that are summarized in table 6.2 Deep Hybrid Model Neural Networks One Neural-Kernel Block Two Neural-Kernel Blocks One layer Two layers 0.93 ±0.01 0.94 ±0.02 0.91 ±0.02 0.92 ±0.01 Table 6.2: Results for CNAE-9 data set listed in deep hybrid model references The deep hybrid model was also reproduced in PyTorch (cf. source code), which gave different results than the ones claimed in table above. This is important to note for the comparison, as the results stated for neural networks in [5, 6] were lower than the ones obtained. When training the kernel network with an RFF layer, using SGD and the parameters that work for the deep hybrid model are not valid now, as shown in figures 6.1 and 6.2. 3Extracted random subset 34
In other words, the conclusion here is that the kernel network learns differently than the deep hybrid model, despite their similarities. A separate search must be conducted in order to maximize the performance of the model. Figure 6.1: Loss for kernel network with deep hybrid model parameters Figure 6.2: Accuracy for kernel network with deep hybrid model parameters Reducing the number of neurons in the hidden layer to h1= 50 seems adequate to make a comparison between the different algorithms, as well as optimization strategies. As we will see, the kernel network seems to learn well with few neurons in the first layer, which is generally not the case for the deep hybrid model. This is because as shown later on, the learning happens especially through the RFF and the fully connected layer. One of the strategies proposed is alternate optimization. Given a function f:Rs→R with x= (x1, . . . , xs) , consider a partition of the variables and differentiate only with respect to those, leaving the others constant [29]. The parameters to optimize here are the weights for the neural layer and fully connected layer, and the coefficients obtained by the three layers in the kernel network. A conjecture is made that it can be beneficial to train the weights and the coefficients separately. In other words, during the even epochs, backpropagation is performed but the coefficients are considered to be constant, and hence only the weights are updated. The opposite happens for the odd epochs. Also, two different optimizers are considered: Stochastic gradient descent and Adam. The optimizer in Pytorch refers to the algorithm used to update the parameters of the model. Some tests are performed using the CNAE-9 data set in order to compare the optimizers and the usage of alternate optimization. The results are summarized in Table 6.3. Algorithm Alternate Layer dim Param. Epochs Time Learns data Acc. 1 SGD Yes h1= 300, h2= 400 612576 250 ×2 124 sec. No - 2 Adam Yes h1= 300, h2= 400 612576 250 ×2 146 sec. No - 3 SGD Yes h1= 50, h2= 400 396576 250 ×2 132 sec. Yes 0.81 4 Adam Yes h1= 50, h2= 400 396576 250 ×2 127 sec. Yes 0.68 5 SGD No h1= 50, h2= 400 443035 500 152 sec. Yes 0.81 6 Adam No h1= 50, h2= 400 443035 500 168 sec. Memorizes training 0.78 7 Adam No h1= 50, h2= 200 268435 500 89 sec. Memorizes training 0.92 Table 6.3: Comparison between SGD and Adam via alternate optimization or not, with associated metrics 35
Figures 6.3, 6.4, 6.5 and 6.6 below show the loss function for different cases. Figure 6.3: Loss for SGD with alternate optimization (3) Figure 6.4: Accuracy for SGD with alternate optimization (3) Figure 6.5: Loss for Adam with alternate optimization (6) Figure 6.6: Accuracy for Adam with alternate optimization (6) Clearly, to stabilize the training process of the kernel network is to use Adam with no alternate optimization. 6.1 Evaluating the kernel network and other ML models over different data sets Four different models are evaluated in this section: firstly, a neural network with one layer, which is trained in two different ways: by passing the entire data set or batches of a specific dimension. The two studied hybrid models are Mehrkanoon’s deep hybrid model and the kernel network. To find the different hyperparameters, such as regularizers and layer dimensions, Random Search is used (as in the case of citing the article). For the regularizers, a uniform 36
References [1] L. Belanche and M. Ruiz, “Bridging deep and kernel methods. a: European symposium on artificial neural networks. ”esann2017: 25th european symposium on artificial neural networks: Bruges, belgium, april 26-27-28”.,” pp. 1–10, 2017. [2] A. G. Wilson, Z. Hu, R. Salakhutdinov, and E. P. Xing, “Deep kernel learning,” 2015. [3] T. Wang, L. Zhang, and W. Hu, “Bridging deep and multiple kernel learning: A review,” Information Fusion, vol. 67, pp. 3–13, 2021. [4] M. G¨onen and E. Alpaydin, “Multiple kernel learning algorithms,” Journal of Machine Learning Research, vol. 12, no. 64, pp. 2211–2268, 2011. [5] S. Mehrkanoon and J. A. Suykens, “Deep hybrid neural-kernel networks using random fourier features,” Neurocomputing, vol. 298, pp. 46–54, 2018. [6] S. Mehrkanoon, “Deep neural-kernel blocks,” Neural Networks, vol. 116, pp. 46–55, 2019. [7] J. Zhuang, I. W. Tsang, and S. C. Hoi, “Two-layer multiple kernel learning,” in Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics (G. Gordon, D. Dunson, and M. Dud´ık, eds.), vol. 15 of Proceedings of Machine Learning Research, (Fort Lauderdale, FL, USA), pp. 909–917, PMLR, 11– 13 Apr 2011. [8] Y. Lecun, Y. Bengio, and G. Hinton, “Deep learning,” Nature Cell Biology, vol. 521, pp. 436–444, May 2015. [9] A. Rahimi and B. Recht, “Random features for large-scale kernel machines,” in Advances in Neural Information Processing Systems (J. Platt, D. Koller, Y. Singer, and S. Roweis, eds.), vol. 20, Curran Associates, Inc., 2007. [10] C. A. Micchelli and M. A. Pontil, “On learning vector-valued functions,” Neural Comput., vol. 17, p. 177–204, jan 2005. [11] Y. Zhang, P. Liang, and M. J. Wainwright, “Convexified convolutional neural networks,” 2016. [12] Y. Miche, M. van Heeswijk, P. Bas, O. Simula, and A. Lendasse, “Trop-elm: A double-regularized elm using lars and tikhonov regularization,” Neurocomputing, vol. 74, no. 16, pp. 2413–2421, 2011. Advances in Extreme Learning Machine: Theory and Applications Biological Inspired Systems. Computational and Ambient Intelligence. [13] T. Hofmann, B. Sch¨olkopf, and A. J. Smola, “Kernel methods in machine learning,” The Annals of Statistics, vol. 36, jun 2008. [14] B. Sch¨olkopf, R. Herbrich, and A. J. Smola, “A generalized representer theorem,” in Computational Learning Theory (D. Helmbold and B. Williamson, eds.), (Berlin, Heidelberg), pp. 416–426, Springer Berlin Heidelberg, 2001. [15] B. Bohn, M. Griebel, and C. Rieger, “A representer theorem for deep kernel learning,” 2018. 43
[16] F. Dinuzzo, “Kernel machines with two layers and multiple kernel learning,” CoRR, vol. abs/1001.2709, 2010. [17] F. Dinuzzo, “Learning functions with kernel methods,” 2011. [18] A. Argyriou and F. Dinuzzo, “A unifying view of representer theorems,” in Proceedings of the 31st International Conference on Machine Learning (E. P. Xing and T. Jebara, eds.), vol. 32 of Proceedings of Machine Learning Research, (Bejing, China), pp. 748–756, PMLR, 22–24 Jun 2014. [19] S. Diwale and C. Jones, “A generalized representer theorem for hilbert space - valued functions,” 2018. [20] D. J. Sutherland and J. Schneider, “On the error of random fourier features,” 2015. [21] F. Liu, X. Huang, Y. Chen, and J. A. K. Suykens, “Random features for kernel approximation: A survey on algorithms, theory, and beyond,” 2021. [22] J. Pennington, F. X. X. Yu, and S. Kumar, “Spherical random features for polynomial kernels,” in Advances in Neural Information Processing Systems (C. Cortes, N. Lawrence, D. Lee, M. Sugiyama, and R. Garnett, eds.), vol. 28, Curran Associates, Inc., 2015. [23] I. Steinwart and A. Christmann, Support Vector Machines. Springer Publishing Company, Incorporated, 1st ed., 2008. [24] J. Shawe-Taylor and N. Cristianini, Kernel Methods for Pattern Analysis. Cambridge University Press, 2004. [25] C. M. Bishop, Pattern Recognition and Machine Learning (Information Science and Statistics). Berlin, Heidelberg: Springer-Verlag, 2006. [26] A. Cotter, J. Keshet, and N. Srebro, “Explicit approximations of the gaussian kernel,” 2011. [27] M. A. Alvarez, L. Rosasco, and N. D. Lawrence, “Kernels for vector-valued functions: a review,” 2012. [28] “Approximation with matrix-valued kernels and highly effective error estimators for reduced basis approximations.” [29] J. C. Bezdek and R. J. Hathaway, “Some notes on alternating optimization,” in Advances in Soft Computing — AFSS 2002 (N. R. Pal and M. Sugeno, eds.), (Berlin, Heidelberg), pp. 288–300, Springer Berlin Heidelberg, 2002. [30] S. Zhang, J. Li, P. Xie, Y. Zhang, M. Shao, H. Zhou, and M. Yan, “Stacked kernel network,” 2017. 44