Contractivity of neural ODEs: an eigenvalue optimization problem

Nicola Guglielmi1 โ€ข Arturo De Marinis1 โ€ข Anton Savostianov1,2 โ€ข Francesco Tudisco3,1

1Gran Sasso Science Institute, L'Aquila, Italy {nicola.guglielmi, arturo.demarinis, anton.savostianov, francesco.tudisco}@gssi.it
2RWTH Aachen University, Germany
3School of Mathematics and Maxwell Institute for Mathematical Sciences, The University of Edinburgh, UK f.tudisco@ed.ac.uk

Abstract We propose a novel methodology to solve a key eigenvalue optimization problem which arises in the contractivity analysis of neural ODEs. When looking at contractivity properties of a one layer weight-tied neural ODE ๐‘ข.(๐‘ก)=๐œŽ(๐ด๐‘ข(๐‘ก)+๐‘) (with ๐‘ข,๐‘โˆˆโ„๐‘›, ๐ด is a given ๐‘›ร—๐‘› matrix, ๐œŽ:โ„โ†’โ„ denotes an activation function and for a vector ๐‘งโˆˆโ„๐‘›, ๐œŽ(๐‘ง)โˆˆโ„๐‘› has to be interpreted entry-wise), we are led to study the logarithmic norm of a set of products of type ๐ท๐ด, where ๐ท is a diagonal matrix such that diag(๐ท)โˆˆ๐œŽโ€ฒ(โ„๐‘›). Specifically, given a real number ๐‘ (usually ๐‘=0), the problem consists in finding the largest positive interval IโІ[0,โˆž) such that the logarithmic norm ๐œ‡(๐ท๐ด)โ‰ค๐‘ for all diagonal matrices ๐ท with ๐ท๐‘–๐‘–โˆˆI. We propose a two-level nested methodology: an inner level where, for a given I, we compute an optimizer ๐ทโ‹†(I) by a gradient system approach, and an outer level where we tune I so that the value ๐‘ is reached by ๐œ‡(๐ทโ‹†(I)๐ด). We extend the proposed two-level approach to the general multilayer, and possibly time-dependent, case ๐‘ข.(๐‘ก)=๐œŽ(๐ด๐‘˜(๐‘ก)โ€ฆ๐œŽ(๐ด1(๐‘ก)๐‘ข(๐‘ก)+๐‘1(๐‘ก))โ€ฆ+๐‘๐‘˜(๐‘ก)) and we propose several numerical examples to illustrate its behaviour, including its stabilizing performance on a one-layer neural ODE applied to the classification of the MNIST handwritten digits dataset.

Acknowledgements: We wish to thank an anonymous Referee for their helpful suggestions and constructive remarks. N.G. acknowledges that his research was supported by funds from the Italian MUR (Ministero dellโ€™Universitร  e della Ricerca) within the PRIN 2022 Project โ€œAdvanced numerical methods for time dependent parametric partial differential equations with applicationsโ€ and the PRO3 joint project entitled โ€œCalcolo scientifico per le scienze naturali, sociali e applicazioni: sviluppo metodologico e tecnologicoโ€. N.G. and F.T. acknowledge support from MUR-PRO3 grant STANDS and PRIN-PNRR grant FIN4GEO. The authors are members of the INdAM-GNCS (Gruppo Nazionale di Calcolo Scientifico).

1 Introduction

Consider a ResNet [1], defined as the sequence of inner layers (for a given ๐‘ข0โˆˆโ„๐‘›)

๐‘ข๐‘˜+1=๐‘ข๐‘˜+โ„Ž๐œŽ(๐ด๐‘ข๐‘˜+๐‘),๐‘˜=0,โ€ฆ,๐พโˆ’1,

(1)

where ๐‘ข๐‘˜,๐‘โˆˆโ„๐‘›, ๐ดโˆˆโ„๐‘›,๐‘›, โ„Ž is a (typically small) positive constant, and ๐œŽ is a suitable absolutely continuous and strictly monotonic activation function that acts entry-wise. It is immediate to see that (1) corresponds to the forward Euler discretization of the ordinary differential equation [2], [3], [4]

๐‘ข.(๐‘ก)=๐œŽ(๐ด๐‘ข(๐‘ก)+๐‘),๐‘กโˆˆ[0,๐‘‡],

(2)

with ๐‘ข๐‘˜โ‰ˆ๐‘ข(๐‘ก๐‘˜). The robustness of (2) against adversarial attacks [5], [6], [7] is one of the key topics of investigation of modern machine learning [8], [9], [10], [11], [12], [13] and is tightly related to the qualitative properties of the differential equation (2), see e.g. [3], [4], [13], [14], [15], [16]. An important stability condition is that small perturbations in the input data do not lead to large differences in the output. More specifically, for any two solutions ๐‘ข1(๐‘ก) and ๐‘ข2(๐‘ก) to (2), one requires

โ€–๐‘ข1(๐‘‡)โˆ’๐‘ข2(๐‘‡)โ€–โ‰ค๐ถโ€–๐‘ข1(0)โˆ’๐‘ข2(0)โ€–,

(3)

for a moderately sized constant ๐ถ. This topic has received increasing attention in recent years since it has been shown that neural ODEs can significantly benefit in terms of both robustness and accuracy by this type of forward stability [17], [18], [19]. In particular, in the context of deep learning, that is when โ„Ž is small, it appears clear - at least in the non-stiff case - that the stability properties of (1) and (2) are strongly related.

1.1 Contractivity

Let us consider the norm โ€–โ‹…โ€–=โŸจโ‹…,โ‹…โŸฉ1/2 induced by the standard Euclidean inner product โŸจโ‹…,โ‹…โŸฉ. With this choice, (3) is directly related to the notion of logarithmic norm. Let ๐‘“(๐‘ก,๐‘ข)=๐œŽ(๐ด๐‘ข+๐‘) and let ๐œ‡โˆˆโ„ such that

โŸจ๐‘“(๐‘ก,๐‘ข)โˆ’๐‘“(๐‘ก,๐‘ฃ),๐‘ขโˆ’๐‘ฃโŸฉโ‰ค๐œ‡โ€–๐‘ขโˆ’๐‘ฃโ€–2,

(4)

for all ๐‘ข,๐‘ฃโˆˆโ„๐‘› and ๐‘กโˆˆ[0,๐‘‡]. Then we have (3) with ๐ถ=e๐œ‡๐‘‡. By the Lagrange theorem, we get (note that since ๐œŽ is assumed to be absolutely continuous it is differentiable almost everywhere)

๐œŽ(๐ด๐‘ข+๐‘)โˆ’๐œŽ(๐ด๐‘ฃ+๐‘)=diag(๐œŽโ€ฒ(๐ด๐‘ค+๐‘))๐ด(๐‘ขโˆ’๐‘ฃ),

with ๐‘ค=๐‘ ๐‘ข+(1โˆ’๐‘ )๐‘ฃ, for a certain ๐‘ โˆˆ(0,1), and it is immediate to see that the vector field ๐œŽ(๐ด๐‘ข+๐‘) - for ๐œŽ absolutely continuous - satisfies (4) with ๐œ‡=๐œ‡โ‹† given by

๐œ‡โ‹†=sup๐ทโˆˆฮฉsup๐‘ฅโˆˆโ„๐‘›,โ€–๐‘ฅโ€–=1โŸจ๐ท๐ด๐‘ฅ,๐‘ฅโŸฉ,

(5)

where ฮฉ indicates the set of diagonal matrices ๐ท whose entries belong to the image ๐œŽโ€ฒ(โ„), i.e. ๐ท๐‘–๐‘–โˆˆ๐œŽโ€ฒ(โ„) for all ๐‘–=1,โ€ฆ,๐‘›.

Let ๐œ†max(๐‘‹) denote the rightmost eigenvalue of ๐‘‹ and, for a given matrix ๐ต,

Sym(๐ต)=๐ต+๐ตโŠค2.

Then, the logarithmic 2-norm of ๐ต (see e.g. [20]) is defined as

max๐‘ขโˆˆโ„๐‘›,โ€–๐‘ขโ€–=1โŸจ๐ต๐‘ข,๐‘ขโŸฉ=๐œ†max(Sym(๐ต))=:๐œ‡2(๐ต).

In this way we can write (5) in terms of ๐œ‡2 as

๐œ‡โˆ—โ‰”sup๐ทโˆˆฮฉ๐œ‡2(๐ท๐ด).

(6)

We say that the linear map associated to ๐ต is contractive (or strictly contractive) in ๐ฟ2 if ๐œ‡2(๐ต)โ‰ค0 (or ๐œ‡2(๐ต)<0, respectively), in which case we would get the stability bound (3) with ๐ถ=1 (๐ถ<1), i.e. for all ๐‘‡>0,

โ€–๐‘ข1(๐‘‡)โˆ’๐‘ข2(๐‘‡)โ€–โ‰ค(<)โ€–๐‘ข1(0)โˆ’๐‘ข2(0)โ€–,

Note that, by continuity of eigenvalues and closedness of ฮฉ, the sup in (6) is a max. The computation of ๐œ‡โ‹† in (6) is a non-trivial eigenvalue optimization problem, which is also considered in [4]. Its computation provides a worst-case contractivity estimate for the neural ODE (2).

Normalization

Note that for an arbitrary activation function ๐œŽ we have ๐œŽโ€ฒ(๐œ‰)โˆˆ[๐‘šโ„“,๐‘š๐‘ข]for๐œ‰โˆˆโ„, with 0โ‰ค๐‘šโ„“<๐‘š๐‘ข. Moreover, by the positive homogeneity of logarithmic norms we have ๐œ‡2(๐ท๐ด)=๐‘š๐‘ข๐œ‡2(1๐‘š๐‘ข๐ท๐ด). Thus, we can rescale the problem and consider (6) over the set ฮฉ of diagonal matrices ๐ท with entries in [๐‘š,1], which we indicate by ฮฉ๐‘š, i.e. we let

ฮฉ๐‘š={๐ทโˆˆ๐”ป๐‘›,๐‘›:๐‘šโ‰ค๐ท๐‘–๐‘–โ‰ค1โˆ€๐‘–},

where ๐”ป๐‘›,๐‘› denotes the set of real ๐‘›ร—๐‘› diagonal matrices.

1.2 Uniform contractivity versus asymptotic stability

As we have seen we are asking for uniform contractivity with respect to all possible trajectories, which translates into the uniform logarithmic norm property with respect to all possible diagonal matrices in ฮฉ๐‘š. Why not choose a more local approximation as in [21]? Why focus on the entire range? The reason is that this appears the only way to guarantee the stability bound (3).

Instead of asking for contractivity we may ask for a weaker asymptotic stability condition (as it is done e.g. in [3]), even if this would not guarantee a monotone reduction of the norm of the error. However this would be simple for autonomous systems but not for non-autonomous problems, as we are going to clarify.

We observe that at time ๐‘ก the linearization of the neural ODE leads us to a linear problem of the form

๐‘ฃ.(๐‘ก)=๐ต(๐‘ก)๐‘ฃ(๐‘ก)where๐ต(๐‘ก)=๐ท(๐‘ก)๐ด,

with a certain diagonal matrix ๐ท(๐‘ก)โˆˆฮฉ๐‘š, that is with entries in ๐œŽโ€ฒ(โ„). One may argue that imposing the condition that โ„œ๐œ†(๐‘ก)<0 for any eigenvalue ๐œ† of the matrix ๐ท(๐‘ก)๐ด and for all ๐‘ก would guarantee asymptotic stability. Unfortunately this is a necessary but not sufficient condition (see e.g. the counterexample in [22, Example 2, page 88]).

For this reason, asking that the eigenvalues of ๐ท๐ด lie within the left complex half-plane for all ๐ทโˆˆฮฉ๐‘š is not sufficient to guarantee asymptotic stability (and therefore neither contractivity, which is a stronger stability notion).

1.3 Overview of our contribution

In this paper we address several problems connected with contractivity bounds for neural ODEs. Most importantly we introduce an algorithm for the efficient computation of ๐œ‡โˆ— (see (5)) both for the constant and for the time-dependent weight matrix ๐ด=๐ด(๐‘ก) (see Problem (P1)). In contrast, in Problems (P2) and (P3) (which is relevant to the considered application in Section 7) the activation ๐œŽ is considered fixed. In Problem (P3), in particular, the weight matrix ๐ด is adjusted to fulfil a certain stability bound, established a priori. In more detail we deal with the following problems.

Problem (P1)

Given a matrix ๐ด, we aim to compute the smallest value ๐‘šโ‹† such that

๐œ‡2(๐ท๐ด)=0for all๐ทโˆˆฮฉ๐‘šโ‹†,

(7)

For the time-dependent case ๐ด=๐ด(๐‘ก), we aim to compute ๐‘šโ‹†(๐‘ก) as a function of ๐‘ก. Relaxing the bound (7) to a moderate positive constant is also possible. This allows to identify switching functions for which the neural ODE is (uniformly) contractive. See Section 2 for the proposed two-level procedure, Section 3 for the details about the eigenvalue optimization method and Section 4 for the computation of the lower extremal slope ๐‘šโˆ—. A combinatorial relaxation, to the aim of accelerating the computation of critical diagonal matrices is proposed in Section 5.

Problem (P2)

Given a matrix ๐ด(๐‘ก) and a given activation function ๐œŽ, whose slope assumes values in [๐‘š,1], we aim to approximate

๐ถ=exp(โˆซ0๐‘‡๐œ‡2(๐ท~(๐‘ )๐ด(๐‘ ))๐‘‘๐‘ ),

with

๐ท~(๐‘ก)=argmax๐ทโˆˆฮฉ๐‘š๐œ‡2(๐ท๐ด(๐‘ก)),

which gives the uniform estimate โ€–๐‘ข1(๐‘‡)โˆ’๐‘ข2(๐‘‡)โ€–โ‰ค๐ถโ€–๐‘ข1(0)โˆ’๐‘ข2(0)โ€–. Section 6 explains how to extend the methodology from the case when ๐ด has constant coefficients. In Subsection 6.4 we also adopt a different perspective, that is fixing ๐‘š (instead of optimizing with respect to ๐‘š) and still optimizing with respect to the set of diagonal matrices ฮฉ๐‘š, compute by quadrature a worst-case stability bound for the error, that is a worst case value for the constant in (3).

Moreover, in view of the application to train a real-life contractive neural ODE (used for image classification), which we will present in Section 7, we are interested in the following complementary Problem to (P1) and (P2).

Problem (P3)

Given an activation function ๐œŽ whose slope assumes values in [๐‘š,1] (with ๐‘š fixed a priori), and a matrix ๐ด for which condition (7) is not fulfilled1, we aim to determine a matrix ๐ต (which would replace ๐ด) such that

๐œ‡2(๐ท๐ต)=0for all๐ทโˆˆฮฉ๐‘š,

with โ€–๐ตโˆ’๐ดโ€–โ†’min with ๐ตโˆ’๐ด belonging to a certain subset of matrices in โ„๐‘›,๐‘›. This requires repeatedly solving Problem (P1), while optimizing with respect to ๐ต.

In this paper we shall restrict modifications of ๐ด to the special form ๐ตโˆ’๐ด=โˆ’๐›ฟI, with ๐›ฟ>0 as small as possible (which we will motivate in Section 7).

Extension to multilayer networks

While we focus on the single-layer case for the sake of simplicity, a variety of observations and results carry over to the multilayer setting as well, where the vector field in the neural ODE is explicitly modeled by several interconnected layers, with weight matrices ๐ด๐‘– and bias vectors ๐‘๐‘–:

๐‘ข.(๐‘ก)=๐œŽ(๐ด๐‘˜๐œŽ(๐ด๐‘˜โˆ’1โ€ฆ๐œŽ(๐ด1๐‘ข(๐‘ก)+๐‘1)โ€ฆ+๐‘๐‘˜โˆ’1)+๐‘๐‘˜).

We will provide details on how to extend to the multilayer case when appropriate throughout the paper (see Subsection 3.5).

1.4 Paper organization

The paper is organized as follows. Section 2 describes in detail Problem (P1). Section 3 outlines our solution strategy, which is a two-level nested approach and is dedicated to the derivation of the inner iteration, while Section 4 is devoted to the numerical solution of the external level. In Subsection 4.5, numerical examples on small matrices, for which the solution can be derived analytically, show that the numerical solution is a very reliable approximation of the analytical solution. Section 5 deals with a combinatorial relaxation of Problem (P1), and provides important insights on its solution. We then deal with Problem (P2) in Section 6. Finally, Section 7 shows how the proposed algorithm can be employed to train a real-life contractive neural ODE (used for image classification), which is more robust and stable against adversarial attacks than the original one. The last Section 8 outlines our conclusions.

2 A two-level nested iterative method for solving (P1)

Let us consider a matrix ๐ดโˆˆโ„๐‘›,๐‘› with negative logarithmic 2-norm ๐œ‡2(๐ด)<0.

Our goal is to compute

๐‘šโ‹†=argmin๐‘šโˆˆ[0,1]{๐‘š:๐œ‡2(๐ท๐ด)=0for all ๐ทโˆˆฮฉ๐‘š}.

(8)

Our approach consists of two levels.

  • Inner problem: Given ๐‘š>0, we aim to solve

    min๐ทโˆˆฮฉ๐‘š๐น(๐ท)

    (9)

    for the functional

    ๐น(๐ท)=โˆ’๐œ‡2(๐ท๐ด)=โˆ’๐œ†max(Sym(๐ท๐ด)),

    (10)

    with ๐ทโˆˆฮฉ๐‘š.

    The functional does not depend explicitely on ๐‘š but its argument ๐ทโˆˆฮฉ๐‘š does. We indicate the minimum

    min๐ทโˆˆฮฉ๐‘š๐น(๐ท)=โˆ’๐œ†[๐‘š].
  • Outer problem: We compute the smallest positive value ๐‘šโ‰ค1 such that

    ๐œ†[๐‘š]=0,

    and indicate it as ๐‘šโ‹†.

It is obvious that ๐‘šโ‹† exists since ฮฉ๐‘š is compact and non empty.

Def 2.1

We call a matrix ๐ท[๐‘š]โˆˆฮฉ๐‘š a global extremizer of ๐น if

๐ท[๐‘š]=arg min๐ทโˆˆฮฉ๐‘š๐น(๐ท).

Similarly, we say that ๐ท[๐‘š] is a local extremizer of ๐น if there exists a closed neighborhood ๐œ”๐‘šโŠ‚ฮฉ๐‘š of ๐ท[๐‘š] such that ๐น(๐ท[๐‘š])โ‰ค๐น(๐ท) for all ๐ทโˆˆ๐œ”๐‘š.

Then we set ๐œ†max(Sym(๐ท[๐‘š]๐ด))=๐œ†[๐‘š], even in the case where the minimum is a local one.

3 Inner problem: a gradient system approach

In order to minimize ๐น(๐ท)=โˆ’๐œ‡2(๐ท๐ด) with respect to ๐ท over the set ฮฉ๐‘š, we let ๐œ† the rightmost (i.e. largest) eigenvalue of Sym(๐ท๐ด) over the set ฮฉ๐‘š. We let ๐ท(๐œ) be a smooth matrix-valued function of the independent variable ๐œ and look for a gradient system for the rightmost eigenvalue of Sym(๐ท(๐œ)๐ด). We propose to solve this problem by integrating a differential equation with trajectories that follow the gradient descent direction associated to the functional ๐น and satisfy further constraints. To develop such a method, we first recall a classical result (see e.g. [23]) for the derivative of a simple eigenvalue of a differentiable matrix valued function ๐ถ(๐œ) with respect to ๐œ. Here we use the notation ๐ถ.(๐œ)โ‰”๐‘‘๐‘‘๐œ๐ถ(๐œ) to denote the derivative with respect toย ๐œ. Moreover, for ๐ด,๐ตโˆˆโ„๐‘›,๐‘›, we denote (with tr standing for the trace)

โŸจ๐ด,๐ตโŸฉ=tr(๐ตโŠค๐ด)

the Frobenius inner product on โ„๐‘›,๐‘›.

Lem 3.1

[23, Section II.1.1] Consider a continuously differentiable matrix valued function ๐ถ(๐œ):โ„โ†’โ„๐‘›,๐‘›, with ๐ถ(๐œ) symmetric. Let ๐œ†(๐œ) be a simple eigenvalue of ๐ถ(๐œ) for all ๐œ and let ๐‘ฅ(๐œ) with โ€–๐‘ฅ(๐œ)โ€–=1 be the associated (right and left) eigenvector. Then ๐œ†(๐œ) is differentiable with

๐œ†.(๐œ)=๐‘ฅ(๐œ)โŠค๐ถ.(๐œ)๐‘ฅ(๐œ)=โŸจ๐‘ฅ(๐œ)๐‘ฅ(๐œ)โŠค,๐ถ.(๐œ)โŸฉ.

Let us consider the symmetric part of ๐ท(๐œ)๐ด, with ๐ท(๐œ) arbitrary. Applying Lemmaย 3.1 to the rightmost eigenvalue ๐œ†(๐œ) of Sym(๐ท(๐œ)๐ด) we obtain:

๐‘‘๐‘‘๐œ๐œ†=๐œ†.=12๐‘ฅโŠค(๐ท.๐ด+๐ดโŠค๐ท.)๐‘ฅ=12โŸจ๐ท.,๐ด๐‘ฅ๐‘ฅโŠคโŸฉ+12โŸจ๐ท.,๐‘ฅ๐‘ฅโŠค๐ดโŠคโŸฉ=โŸจ๐ท.,๐‘ง๐‘ฅโŠค+๐‘ฅ๐‘งโŠค2โŸฉ=โŸจ๐ท.,๐‘†โŸฉ,with๐‘†=Sym(๐‘ง๐‘ฅโŠค),

where ๐‘ง=๐ด๐‘ฅ and the dependence on ๐œ is omitted for conciseness.

To comply with the constraint ๐ทโˆˆ๐”ป๐‘›,๐‘›, in view of Lemmaย 3.1 we are thus led to the following constrained optimization problem for the admissible direction of steepest descent. In the following, for a given matrix ๐ต, diag(๐ต) denotes the diagonal matrix having diagonal entries equal to those of ๐ต.

Lem 3.2

Let ๐‘†โˆˆโ„๐‘›,๐‘› a matrix with at least a nonzero diagonal entry. A solution of the optimization problem

๐‘โ‹†=argmin๐‘โˆˆ๐”ป๐‘›,๐‘›,โ€–๐‘โ€–๐น=1โŸจ๐‘,๐‘†โŸฉ

(where the norm constraint โ€–๐‘โ€–๐น=1 is only considered to get a unique solution) is given by

๐œˆ๐‘โ‹†=โˆ’diag(๐‘†)

(11)

and ๐œˆ is the Frobenius norm of the matrix on the right-hand side.

Proof. The proof is obtained by simply noting that (11) represents the orthogonal projection โ€“ with respect to the Frobenius inner product โ€“ onto the set of diagonal matrices.

Observing that for ๐‘†=Sym(๐‘ง๐‘ฅโŠค), we have diag(Sym(๐‘ง๐‘ฅโŠค))=diag(๐‘ง๐‘ฅโŠค), using Lemmaย 3.2, we obtain the constrained gradient for the functional (10)

๐บ=โˆ’diag(๐‘ง๐‘ฅโŠค).

(12)

Hence the constrained gradient system to minimize ๐น(๐ท) is given by

๐ท.=โˆ’๐บ=diag(๐‘ง๐‘ฅโŠค),

(13)

which holds until one of the entries of ๐ท(๐œ) equals ๐‘š or 1, in which case inequality constraints should be considered. Note that the ODE system (13) can be conveniently rewritten componentwise. With ๐ท=diag(๐‘‘1,๐‘‘2,โ€ฆ,๐‘‘๐‘›), we get

๐‘‘.๐‘–=๐‘ฅ๐‘–๐‘ง๐‘–,

with (๐œ†,๐‘ฅ) the rightmost eigenpair of Sym(๐ท๐ด), and ๐‘ง=๐ด๐‘ฅ.

3.1 Inequality constraints: admissible directions

To comply with the lower bound constraint of the diagonal matrix ๐ท(๐œ), we need to impose that ๐ท.๐‘–๐‘–(๐œ)โ‰ฅ0 for all ๐‘– such that ๐ท๐‘–๐‘–(๐œ)=๐‘š. For a diagonal matrix ๐ทโˆˆฮฉ๐‘š we set

โ„ฐ๏ธ€0(๐ท)โ‰”{๐‘–:๐ท๐‘–๐‘–=๐‘š},

and we define ๐‘ƒโ„ฐ๏ธ€0(๐ท) as follows:

(๐‘ƒโ„ฐ๏ธ€0(๐ท)๐‘)๐‘–๐‘–={๐‘๐‘–๐‘–if๐ท๐‘–๐‘–>๐‘šmax(0,๐‘๐‘–๐‘–)if๐ท๐‘–๐‘–=๐‘š.

Similarly, we proceed to impose the upper bound constraint: we set

โ„ฐ๏ธ€1(๐ท)โ‰”{๐‘–:๐ท๐‘–๐‘–=1},

and we define ๐‘ƒโ„ฐ๏ธ€1(๐ท) as

(๐‘ƒโ„ฐ๏ธ€1(๐ท)๐‘)๐‘–๐‘–={๐‘๐‘–๐‘–if๐ท๐‘–๐‘–<1min(0,๐‘๐‘–๐‘–)if๐ท๐‘–๐‘–=1.

3.2 Constrained gradient system

To include constraints in the gradient system we make use of Karush-Kuhn-Tucker (KKT) conditions. Let us consider, for conciseness, only the inequality ๐ท๐‘–๐‘–โ‰ฅ๐‘š for all ๐‘–. The optimization problem to determine the constrained steepest descent direction is

๐‘โ‹†=argmin๐‘โˆˆ๐”ป๐‘›,๐‘›,โ€–๐‘โ€–๐น=1,๐ทโ‰ฅ๐‘šโŸจ๐‘†,๐‘โŸฉ.

(14)

Analogously to Lemmaย 3.2 we have that the solution of (14) satisfies the KKT conditions

๐‘=โˆ’๐บ^,๐œˆ๐‘–๐‘๐‘–๐‘–=0 for all ๐‘–โˆˆโ„ฐ๏ธ€0(๐ท),๐œˆ๐‘–โ‰ฅ0 for all ๐‘–โˆˆโ„ฐ๏ธ€0(๐ท),

where

๐œ๐บ^=diag(๐‘†)+โˆ‘๐‘–โˆˆโ„ฐ๏ธ€0(๐ท)๐œˆ๐‘–๐‘ข๐‘–๐‘ข๐‘–โŠค,

๐‘ขโ„“ is the โ„“-th canonical versor ((๐‘ขโ„“)๐‘–=1 if โ„“=๐‘– and (๐‘ขโ„“)๐‘–=0 otherwise), while {๐œˆ๐‘–} are the Lagrange multipliers associated to the non-negativity constraints, and ๐œ is the Frobenius norm of the matrix on the right-hand side. In a completely analogous way, we can treat the inequality ๐ท๐‘–๐‘–โ‰ค1.

3.3 Structure of extremizers: a theoretical result

We state now an important theoretical result on the structure of extremizers (see Definitionย 2.1).

Thm 3.1 [necessary condition for an extremizer to assume intermediate values in (๐‘š,1)]

For a given matrix ๐ดโˆˆโ„๐‘›,๐‘› such that ๐œ‡2(๐ด)<0, assume that ๐ท[๐‘š] is a local extremizer of the inner optimization Problem (9), and assume (generically) that the rightmost eigenvalue ๐œ† of ๐ต=Sym(๐ท[๐‘š]๐ด) is simple. Let ๐‘ฅ be the eigenvector associated to ๐œ†, ๐‘ง=๐ด๐‘ฅ and ๐‘ฅ๐‘– and ๐‘ง๐‘– are the ๐‘–-th entries of the vectors ๐‘ฅ and ๐‘ง, respectively.

Then the ๐‘–-th diagonal entry of ๐ท[๐‘š] either assumes values in {๐‘š,1} (extremal ones) or - if ๐‘š<๐‘‘๐‘–๐‘–<1 - the following condition has to hold true:

๐‘ฅ๐‘–๐‘ง๐‘–=0.

(15)

Proof. Assume that the ๐‘–-th diagonal entry of the extremizer ๐ท=๐ท[๐‘š] is equal to ๐‘‘, with ๐‘š<๐‘‘<1. Now consider a small perturbation ๐›ฟ of such a diagonal element and consider the associated diagonal matrix

๐ท(๐›ฟ)=๐ท+๐›ฟ๐‘ข๐‘–๐‘ข๐‘–โŠคโˆˆฮฉ๐‘š,

(with ๐‘ข๐‘– the ๐‘–-th versor of the canonical basis of โ„๐‘›). Note that ๐ท(๐›ฟ)โˆˆฮฉ๐‘š is still admissible for |๐›ฟ| sufficiently small.

We indicate by ๐œ†=๐œ†[๐‘š] the rightmost eigenvalue of Sym(๐ท๐ด) and by ๐œ†(๐›ฟ) the perturbed rightmost eigenvalue of Sym(๐ท(๐›ฟ)๐ด). By applying the first order formula for eigenvalues we obtain, for ๐œ†(๐›ฟ) the first order expansion:

๐œ†(๐›ฟ)=๐œ†+12๐›ฟ๐‘ฅโŠค(๐‘ข๐‘–๐‘ข๐‘–โŠค๐ด+๐ดโŠค๐‘ข๐‘–๐‘ข๐‘–โŠค)๐‘ฅ+๐’ช๏ธ€(๐›ฟ2)=๐œ†+๐›ฟ๐‘ฅ๐‘–๐‘ง๐‘–+๐’ช๏ธ€(๐›ฟ2),

with ๐‘ฅ๐‘– the ๐‘–-th component of the eigenvector ๐‘ฅ and ๐‘ง๐‘– the ๐‘–-th component of ๐‘ง=๐ด๐‘ฅ. If ๐‘ฅ๐‘–๐‘ง๐‘–โ‰ 0, suitably choosing the sign of ๐›ฟ would increase ๐œ†(๐›ฟ) for ๐›ฟ sufficiently small, and thus would imply ๐œ‡2(๐ท(๐›ฟ)๐ด)>๐œ‡2(๐ท๐ด), that is a contradiction.

We are also in the position to state the following results.

Lem 3.3

Assume that ๐ท[๐‘š]โˆˆฮฉ๐‘š is an extremizer s.t. ๐น(๐ท[๐‘š])>0. Then min1โ‰ค๐‘–โ‰ค๐‘›๐ท๐‘–๐‘–=๐‘š.

Proof. Let ๐œ†=๐œ†[๐‘š]<0 the rightmost eigenvalue of Sym(๐ท[๐‘š]๐ด). Assume that the statement is not true, that is

min1โ‰ค๐‘–โ‰ค๐‘›๐ท๐‘–๐‘–=๐‘š^>๐‘š.

Then, there exists a positive ๐›พ<1 such that ๐ท^=๐›พ๐ท[๐‘š] has still entries in [๐‘š,1], and thus belongs to ฮฉ๐‘š, i.e. it is admissible. This implies that Sym(๐ท^๐ด) has the rightmost eigenvalue ๐œ†^=๐›พ๐œ†>๐œ† (which here is negative), which contradicts extremality.

Similarly we can prove the following analogous result.

Lem 3.4

Assume that ๐ท[๐‘š]โˆˆฮฉ๐‘š is an extremizer s.t. ๐น(๐ท[๐‘š])<0. Then max1โ‰ค๐‘–โ‰ค๐‘›๐ท๐‘–๐‘–=1.

Finally we can prove the following result.

Lem 3.5

Assume that ๐ท[๐‘š]โˆˆฮฉ๐‘š is an extremizer s.t. ๐น(๐ท[๐‘š])=0 and assume (generically) that ๐ท[๐‘š] (as a function of ๐‘š) is continuous at ๐‘š. Then max1โ‰ค๐‘–โ‰ค๐‘›๐ท๐‘–๐‘–=1 and min1โ‰ค๐‘–โ‰ค๐‘›๐ท๐‘–๐‘–=๐‘š.

Proof. The proof combines Lemmaย 3.3 and Lemmaย 3.4 and continuity of eigenvalues.

Rem 3.1 [Multiple eigenvalues]

Throughout the article we assume that the rightmost eigenvalue is simple. However, along a trajectory ๐ท(๐‘ก), a multiple eigenvalue ๐œ†(๐‘ก) may occur at some finite ๐‘ก because of a coalescence of eigenvalues. Even if some continuous trajectory runs into a coalescence, this generally does not happen after discretization of the differential equation, and so the computation will not be affected. As such situation is either non-generic or can happen generically only at isolated times ๐‘ก, it does not affect the computation after discretization of the differential equation.

However, close-to-multiple eigenvalues may impair the accuracy of the computed eigenpairs and should be detected numerically and treated carefully.

3.4 Numerical integration

In Algorithmย 1 we provide a schematic description of the integration step. For simplicity, we make use of the Euler method, but considering other explicit methods would be similar. Classical error control is not necessary here since the goal is just that of diminishing the functional ๐น(๐ท) (see lines 9 and 10 in Algorithmย 1).

Also note that, in practice, it is not necessary to compute the Lagrange multipliers for the entries of ๐ท that assume extremal values as in Subsection 3.2; the numerical procedure has just to check when one of the entries of the diagonal matrix ๐ท reaches either the extreme value ๐‘š or the extreme value 1 (by an event-detection algorithm) coupled with the numerical integrator. In the first case, as in Subsection 3.1, if ๐ท๐‘–๐‘–=๐‘š, we have to check the steepest descent direction โˆ’๐บ, and set ๐ท.๐‘–๐‘–=0 if โˆ’๐บ๐‘–๐‘–<0 or let it unvaried otherwise. In the second case, if the entry ๐ท๐‘–๐‘–=1, we have to set ๐ท.๐‘–๐‘–=0 if โˆ’๐บ๐‘–๐‘–>0 and let it unvaried otherwise.

3.5 Multilayer networks

Let us examine now networks with several interconnected layers; for simplicity we consider time-independent ๐ด๐‘– and ๐‘๐‘–:

๐‘ข.(๐‘ก)=๐œŽ(๐ด๐‘˜๐œŽ(๐ด๐‘˜โˆ’1โ€ฆ๐œŽ(๐ด1๐‘ข(๐‘ก)+๐‘1)โ€ฆ+๐‘๐‘˜โˆ’1)+๐‘๐‘˜).

Making use of Lagrange theorem, we get

๐œŽ(๐ด๐‘˜๐œŽ(๐ด๐‘˜โˆ’1โ€ฆ๐œŽ(๐ด1๐‘ข(๐‘ก)+๐‘1)โ€ฆ+๐‘๐‘˜โˆ’1)+๐‘๐‘˜)โˆ’๐œŽ(๐ด๐‘˜๐œŽ(๐ด๐‘˜โˆ’1โ€ฆ๐œŽ(๐ด1๐‘ฃ(๐‘ก)+๐‘1)โ€ฆ+๐‘๐‘˜โˆ’1)+๐‘๐‘˜)=diag(๐œŽโ€ฒ(๐‘ฆ๐‘˜))๐ด๐‘˜diag(๐œŽโ€ฒ(๐‘ฆ๐‘˜โˆ’1))๐ด๐‘˜โˆ’1โ‹ฏdiag(๐œŽโ€ฒ(๐‘ฆ1))๐ด1(๐‘ขโˆ’๐‘ฃ),

for suitable vectors ๐‘ฆ1,โ€ฆ,๐‘ฆ๐‘˜โˆ’1,๐‘ฆ๐‘˜. The proposed methodology extends to the study of the logarithmic norm of matrices of the form

Sym(๐ท๐‘˜๐ด๐‘˜๐ท๐‘˜โˆ’1๐ด๐‘˜โˆ’1โ‹ฏ๐ท1๐ด1).

Again the functional we aim to minimize is

๐น(๐ท1,โ€ฆ,๐ท๐‘˜)=โˆ’๐œ†max(Sym(๐ท๐‘˜๐ด๐‘˜๐ท๐‘˜โˆ’1๐ด๐‘˜โˆ’1โ‹ฏ๐ท1๐ด1)),

for ๐ท๐‘–โˆˆฮฉ๐‘š for ๐‘–=1,โ€ฆ,๐‘˜. Letting

(๐ท1[๐‘š],โ€ฆ,๐ท๐‘˜[๐‘š])=argmin๐ท1,โ€ฆ,๐ท๐‘˜โˆˆฮฉ๐‘š๐น(๐ท1,โ€ฆ,๐ท๐‘˜),

we indicate by ๐œ†[๐‘š] the rightmost eigenvalue of Sym(๐ท๐‘˜๐ด๐‘˜๐ท๐‘˜โˆ’1๐ด๐‘˜โˆ’1โ‹ฏ๐ท1๐ด1).

Optimizing with respect to ๐‘š, our task is again to find the smallest solution of the scalar equation ๐œ†[๐‘š]=0, which we still indicate as ๐‘šโ‹†.

Inner iteration

In analogy to the single layer case, let us consider the symmetric part of ๐ท๐‘˜(๐œ)๐ด๐‘˜โ‹ฏ๐ท1(๐œ)๐ด1, with ๐ท๐‘–(๐œ) diagonal for ๐‘–=1,โ€ฆ,๐‘˜. Applying Lemmaย 3.1 to the rightmost eigenvalue ๐œ†(๐œ) of Sym(๐ท๐‘˜(๐œ)๐ด๐‘˜โ‹ฏ๐ท1(๐œ)๐ด1) we obtain (omitting the dependence on ๐œ):

๐‘‘๐‘‘๐œ๐œ†=๐œ†.=12๐‘ฅโŠค(Sym(๐ท๐‘˜.๐ด๐‘˜๐ท๐‘˜โˆ’1๐ด๐‘˜โˆ’1โ‹ฏ๐ท1๐ด1+๐ท๐‘˜๐ด๐‘˜๐ท.๐‘˜โˆ’1๐ด๐‘˜โˆ’1โ‹ฏ๐ท1๐ด1+โ‹ฏ+๐ท๐‘˜๐ด๐‘˜๐ท๐‘˜โˆ’1๐ด๐‘˜โˆ’1โ‹ฏ๐ท.1๐ด1))๐‘ฅ=โˆ‘๐‘–=1๐‘˜โŸจ๐ท.๐‘–,๐‘ง๐‘–๐‘ค๐‘–โŠค+๐‘ค๐‘–๐‘ง๐‘–โŠค2โŸฉ=โˆ‘๐‘–=1๐‘˜โŸจ๐ท.๐‘–,Sym(๐‘ง๐‘–๐‘ค๐‘–โŠค)โŸฉ,

with ๐‘ง1=๐ด1๐‘ฅ, โ€ฆ, ๐‘ง๐‘˜โˆ’1=๐ด๐‘˜โˆ’1โ‹ฏ๐ท1๐ด1๐‘ฅ, ๐‘ง๐‘˜=๐ด๐‘˜๐ท๐‘˜โˆ’1๐ด๐‘˜โˆ’1โ‹ฏ๐ท1๐ด1๐‘ฅ and ๐‘ค1=๐ด2โŠค๐ท2โ‹ฏ๐ด๐‘˜โˆ’1โŠค๐ท๐‘˜โˆ’1๐ด๐‘˜โŠค๐ท๐‘˜๐‘ฅ, โ€ฆ, ๐‘ค๐‘˜โˆ’1=๐ด๐‘˜โŠค๐ท๐‘˜๐‘ฅ,โ€ฆ,๐‘ค๐‘˜=๐‘ฅ.

This allows us to get an expression for the free gradient analogous to the single layer case.

The associated constrained gradient system is given โ€” in analogy to (13) โ€” by

๐ท.๐‘–=diag(๐‘ง๐‘–๐‘ค๐‘–โŠค),๐‘–=1,โ€ฆ,๐‘˜.

(16)

Every ODE in (16) is integrated with no modifications until one of the entries of ๐ท๐‘–(๐œ) equals ๐‘š or 1, in which case inequality constraints should be considered.

4 Outer iteration: computing ๐‘šโ‹†

In order to compute the smallest positive value ๐‘šโ‹† such that ๐œ†[๐‘šโˆ—]=0 in the outer-level iteration, we have to face two issues:

  1. which initial value of ๐‘š to consider;

  2. how to tune ๐‘š until the desired approximation of ๐‘šโ‹†.

In this section we discuss a number of results that will directly lead to a proposal for a possible way to address both these two issues. Before - in the next two subsections - we provide some insights into the problem.

4.1 The value ๐œ‡2(๐ด) is strongly unspecific.

Unfortunately, the only information of ๐œ‡2(๐ด) is very unspecific for the determination of ๐‘šโ‹† and the behaviour of Sym(๐ท๐ด). Here is an illuminating example, just in dimension 2. Let ๐‘Ž11,๐‘Ž22<0, ๐‘˜>0 and

๐ด=(๐‘Ž11๐‘˜โˆ’๐‘˜๐‘Ž22)and๐ท=diag(1,๐‘š).

We have Sym(๐ด)=diag(๐‘Ž11,๐‘Ž22) and ๐œ‡2(๐ด)=max{๐‘Ž11,๐‘Ž22}<0; we get

Sym(๐ท๐ด)=12(2๐‘Ž11๐‘˜โˆ’๐‘˜๐‘š๐‘˜โˆ’๐‘˜๐‘š2๐‘Ž22๐‘š),

having eigenvalues

๐œ†1,2=12(โˆ“๐‘Ž112โˆ’2๐‘Ž11๐‘Ž22๐‘š+๐‘Ž222๐‘š2+๐‘š2๐‘˜2โˆ’2๐‘š๐‘˜2+๐‘˜2+๐‘Ž11+๐‘Ž22๐‘š),

We indicate by ๐‘šโ‹†(๐‘˜) the value of ๐‘šโ‹† as a function of ๐‘˜. Choosing ๐‘˜=0 (๐ด diagonal) we get ๐‘šโ‹†(0)=0. Choosing instead ๐‘˜โ‰ซ1, we get the first order expansion

๐œ†1,2=ยฑ12(1โˆ’๐‘š)๐‘˜+12(๐‘Ž11+๐‘Ž22๐‘š)+๐’ช๏ธ€(1๐‘˜).

This immediately implies that lim๐‘˜โ†’โˆž๐‘šโ‹†(๐‘˜)=1, which is consistent with Theoremย 4.1, as โ€–๐ดโ€–2=๐‘˜+(๐‘Ž11โˆ’๐‘Ž22)/2+๐’ช๏ธ€(1/๐‘˜).

This shows that, in order to obtain a meaningful estimate of ๐‘šโ‹†, we need more information on ๐ด than the only logarithmic norm. For example, the non-normality of the matrix and the structure of the non-symmetric part ofย ๐ด.

4.2 A theoretical upper bound for ๐‘šโ‹†

We have the following upper bound for ๐‘šโ‹†, obtained for a general absolute norm by applying the Bauerโ€“Fike theorem.

Recall that a general property of any logarithmic norm states that for any matrix ๐ด, it holds โˆ’โ€–๐ดโ€–โ‰ค๐œ‡(๐ด)โ‰คโ€–๐ดโ€–.

Thm 4.1 [Upper bound for ๐‘šโ‹†]

For a given matrix ๐ดโˆˆโ„๐‘›,๐‘› such that ๐œ‡(๐ด)<0, assume that ๐‘šโ‹† solves Problem (8). Let โ€–โ‹…โ€– be an absolute norm and

๐›ฝ(๐ด)=โ€–๐ดโ€–+โ€–๐ดโŠคโ€–2.

Then, if |๐œ‡(๐ด)|<๐›ฝ(๐ด),

๐‘šโ‹†โ‰ค1โˆ’|๐œ‡(๐ด)|๐›ฝ(๐ด)โ‰”๐‘š๐‘ข๐‘โ‹†<1.

(17)

If โ€–โ‹…โ€– is such that โ€–๐ดโ€–=โ€–๐ดโŠคโ€–, then |๐œ‡(๐ด)|<โ€–๐ดโ€– and ๐‘šโ‹†โ‰ค1โˆ’|๐œ‡(๐ด)|โ€–๐ดโ€–.

Proof. Let ๐ท=๐ท[๐‘šโ‹†]โˆˆฮฉ๐‘šโ‹† be an extremizer, and write ๐ท=I+๐ธ. Then we have ๐œ‡(๐ท๐ด)=0 and

Sym(๐ท๐ด)=12(๐ท๐ด+๐ดโŠค๐ท)=Sym(๐ด)+12(๐ธ๐ด+๐ดโŠค๐ธ).

Applying Bauer-Fike theorem and exploiting the normality of Sym(๐ท๐ด), we obtain

|๐œ‡(๐ด)|โ‰คโ€–Sym(๐ท๐ด)โˆ’Sym(๐ด)โ€–=12โ€–๐ธ๐ด+๐ดโŠค๐ธโ€–โ‰คโ€–๐ดโ€–+โ€–๐ดโŠคโ€–2โ€–๐ธโ€–=๐›ฝ(๐ด)โ€–๐ธโ€–.

Using Lemmaย 3.4 and the assumption that โ€–โ‹…โ€– is an absolute norm we get that, if the largest entry of ๐ท equals 1, โ€–๐ธโ€–=1โˆ’๐‘šโ‹†, otherwise โ€–๐ธโ€–โ‰ค1โˆ’๐‘šโ‹†. Consequently - since ๐›ฝ(๐ด)โ‰ฅ|๐œ‡(๐ด)| - we get

|๐œ‡(๐ด)|โ‰ค๐›ฝ(๐ด)(1โˆ’๐‘šโ‹†),

which concludes the proof.

Cor 4.1

Under the assumptions of Theoremย 4.1, if ๐ด is symmetric and โ€–โ‹…โ€–=โ€–โ‹…โ€–2, then

๐‘šโ‹†โ‰ค1โˆ’๐œ…2(๐ด)โˆ’1,where๐œ…2(๐ด)=|๐œ†max(๐ด)๐œ†min(๐ด)|

is the condition number of ๐ด (๐œ†max(๐ด)=๐œ‡2(๐ด) denotes the smallest eigenvalue (in modulus) of ๐ด and ๐œ†min(๐ด)=โˆ’๐œŒ(๐ด) the rightmost eigenvalue of ๐ด (in modulus)).

Proof. For a symmetric matrix โ€–๐ดโ€–2=๐œŒ(๐ด); moreover by the contractivity assumption, ๐œ‡2(๐ด)=๐œ†max(๐ด) and ๐œŒ(๐ด)=โˆ’๐œ†min(๐ด).

4.3 Iterative computation of ๐‘šโ‹†

We aim to compute ๐‘šโ‹†, the smallest positive solution of the one-dimensional root-finding problem

๐น๐‘š(๐ท[๐‘š])=0,

(18)

where ๐ท[๐‘š] denotes a minimizer of ๐น(๐ท). This can be solved by a variety of methods, such as bisection. Theoremย 4.1 suggests to start applying the outer level step with an initial value ๐‘šโ‰ค๐‘š๐‘ข๐‘โ‹† (see (17)).

After computing an extremizer ๐ท[๐‘š], which minimizes the functional ๐น๐‘š(๐ท) with respect to ๐ท, for fixed ๐‘š, in the case when |๐น๐‘š(๐ท[๐‘š])| is not below a certain tolerance, we have to further modify ๐‘š, until we reach a value ๐‘š~ such that ๐น๐‘š~(๐ท[๐‘š~])=0, which would approximate the searched value ๐‘šโ‹†=๐‘š~. We derive now a costless variational formula and a fast outer iteration to approximate ๐‘šโ‹†. With such formula, we aim for a locally quadratically convergent Newton-type method, which can be justified under regularity assumptions that appear to be usually satisfied. If these assumptions are not met, we can always resort to bisection. The algorithm proposed in the following in fact uses a combined Newton-bisection approach. Let ๐ท=๐ท[๐‘š] be an extremizer. We denote by ๐ฝ=๐ฝ[๐‘š] the diagonal matrix with binary entries (either 0 or 1), according to the following:

๐ฝ๐‘˜๐‘˜={1if๐ท๐‘˜๐‘˜=๐‘š,0otherwise.

(19)

Next we make an assumption, which we have always encountered in our experiments.

Assumption 4.1

For ๐‘š sufficiently close to ๐‘šโ‹†, we assume for the extremizer ๐ท[๐‘š] that:

  • the eigenvalue ๐œ†[๐‘š]=๐œ†max(Sym(๐ท[๐‘š]๐ด)) is a simple eigenvalue;

  • the map ๐‘šโ†ฆ๐ท[๐‘š] is continuously differentiable;

  • the matrix ๐ฝ[๐‘š] is constant2.

Under this assumption, the branch of eigenvalues ๐œ†[๐‘š] and its corresponding eigenvectors ๐‘ฅ[๐‘š] are also continuously differentiable functions of ๐‘š in a neighbourhood of ๐‘šโ‹†. The following result gives us an explicit and easily computable expression for the derivative of ๐œ™[๐‘š]=๐น(๐ท[๐‘š])=โˆ’๐œ†[๐‘š] with respect to ๐‘š in simple terms. Its proof exploits Theoremย 3.1.

Thm 4.2 [Derivative of ๐œ™]

Under Assumptionย 4.1, the function ๐œ™ is continuously differentiable in a neighborhood of ๐‘š and its derivative is given as

๐œ™โ€ฒ[๐‘š]=๐‘‘๐œ™[๐‘š]๐‘‘๐‘š=โˆ’๐‘ฅ[๐‘š]โŠค๐ฝ[๐‘š]๐‘ง[๐‘š]<0,

where ๐‘ฅ[๐‘š] is the eigenvector associated to the eigenvalue ๐œ†[๐‘š] of Sym(๐ท[๐‘š]๐ด) and ๐‘ง[๐‘š]=๐ด๐‘ฅ[๐‘š].

Proof. According to (19), we indicate by ๐ฝ=๐ฝ[๐‘š] the set of indices of entries of ๐ท=๐ท[๐‘š] that are equal to ๐‘š. Under the given assumptions we have

๐ท๐‘˜โ€ฒ[๐‘š]=1if๐ท๐‘˜[๐‘š]=๐‘š,๐ท๐‘˜โ€ฒ[๐‘š]=๐›ฝโ€ฒ[๐‘š]if๐ท๐‘˜[๐‘š]=๐›ฝ[๐‘š]โˆˆ(๐‘š,1),๐ท๐‘˜โ€ฒ[๐‘š]=0if๐ท๐‘˜[๐‘š]=1.

By Lemmaย 3.1 we have that

๐œ™โ€ฒ[๐‘š]=โˆ’๐œ†โ€ฒ[๐‘š]=โˆ’๐‘ฅ[๐‘š]โŠค๐ทโ€ฒ[๐‘š]๐‘ง[๐‘š]=โˆ’โˆ‘๐‘˜=1๐‘›๐‘ฅ๐‘˜[๐‘š]๐ท๐‘˜โ€ฒ[๐‘š]๐‘ง๐‘˜[๐‘š]=โˆ’โˆ‘๐‘˜โˆˆ๐ฝ๐ท๐‘˜โ€ฒ[๐‘š]๐‘ฅ๐‘˜[๐‘š]๐‘ง๐‘˜[๐‘š].

If the index ๐‘˜ in the summation corresponds to a zero diagonal entry of ๐ทโ€ฒ[๐‘š] then it does not contribute to it; similarly if ๐‘˜ is such that ๐ท๐‘˜[๐‘š]=๐›ฝ[๐‘š]โˆˆ(๐‘š,1), by Theoremย 3.1, we have that ๐‘ฅ๐‘˜[๐‘š]๐‘ง๐‘˜[๐‘š]=0, hence the index does not contribute too. In conclusion only indices corresponding to entries equal to ๐‘š enter into the summation with value 1. This implies that

๐œ™โ€ฒ[๐‘š]=โˆ’๐‘ฅ[๐‘š]โŠค๐ทโ€ฒ[๐‘š]๐‘ง[๐‘š]=โˆ’๐‘ฅ[๐‘š]โŠค๐ฝ[๐‘š]๐‘ง[๐‘š],

which proves the statement.

In view of Theoremย 4.2, applying Newtonโ€™s method to the equation ๐œ™[๐‘š]=0 yields the following iteration:

๐‘š๐‘˜+1=๐‘š๐‘˜+๐œ™[๐‘š๐‘˜]๐‘ฅ[๐‘š๐‘˜]โŠค๐ฝ[๐‘š๐‘˜]๐‘ง[๐‘š๐‘˜],

(20)

where the right-hand side can be computed knowing the extremizer ๐ท[๐‘š๐‘˜] computed by the inner iteration in the ๐‘˜-th step. For this, we expect that with a few iterations (on average 5 in our experiments), we are able to obtain an approximation ๐‘š๐‘˜โ‰ˆ๐‘šโ‹†.

4.4 Extension to multilayer networks

The following result extends to the multilayer case an explicit and easily computable expression for the derivative of

๐œ™[๐‘š]=๐น(๐ท1[๐‘š],โ€ฆ,๐ท๐‘˜[๐‘š])=โˆ’๐œ†[๐‘š]

with respect to ๐‘š.

For ๐ท=๐ท๐‘–, we also denote as ๐ฝ(๐‘–)=๐ฝ(๐‘–)[๐‘š] the diagonal matrix with binary entries (either 0 or 1), according to the following:

๐ฝ๐‘˜๐‘˜(๐‘–)={1if๐ท๐‘˜๐‘˜=๐‘š,0otherwise.

Similarly to Theoremย 4.2, we have the following result which gives us a formula to implement the cheap Newton-type iteration discussed in Subsection 4.3.

Thm 4.3 [Derivative of ๐œ™]

Under Assumptionย 4.1 for all matrices ๐ท๐‘–[๐‘š], in a neighbourhood of ๐‘šโ‹†, the function ๐œ™ is continuously differentiable in a neighbourhood of ๐‘š and its derivative is given as

๐œ™โ€ฒ[๐‘š]=๐‘‘๐œ™[๐‘š]๐‘‘๐‘š=โˆ’โˆ‘๐‘–=1๐‘˜๐‘ค๐‘–[๐‘š]โŠค๐ฝ(๐‘–)[๐‘š]๐‘ง๐‘–[๐‘š]<0,

where ๐‘ค๐‘–[๐‘š],๐‘ง๐‘–[๐‘š] are defined according to Subsection 3.5.

Strict contractivity

In order to impose strict contractivity one can replace equation (18) with ๐น๐‘š(๐ท[๐‘š])=โˆ’๐‘, ๐‘>0. In this case, we can extend the previous results easily. In particular, the upper bound for ๐‘šโ‹† in Theoremย 4.1 becomes

๐‘šโ‹†โ‰ค1โˆ’|๐œ‡(๐ด)+๐‘|๐›ฝ(๐ด),

and the Newton iteration step (20) takes the form

๐‘š๐‘˜+1=๐‘š๐‘˜+๐œ™[๐‘š๐‘˜]+๐‘๐‘ฅ[๐‘š๐‘˜]โŠค๐ฝ[๐‘š๐‘˜]๐‘ง[๐‘š๐‘˜].

Everything else remains exactly the same.

4.5 Illustrative numerical examples

We consider first the simple 2ร—2 matrix

๐ด=(โˆ’212โˆ’3),

(21)

whose logarithmic 2-norm is ๐œ‡2(๐ด)=๐œ†max((๐ด+๐ดโŠค)/2)=โˆ’0.9189โ€ฆ Applying Theoremย 4.1 and choosing the 2-norm we get

๐‘šโ‹†โ‰ค๐‘š๐‘ข๐‘โ‹†=0.7776โ€ฆ

Indeed, the exact value can be computed exactly considering the extremal matrices

๐ท1=(100๐‘š),๐ท2=(๐‘š001),

and it turns out to be ๐‘šโ‹†=10โˆ’46=0.202041โ€ฆ Applying the proposed numerical method, with a 4-digit accuracy, we get indeed the extremizer ๐ท1 with ๐‘šโ‹†โ‰ˆ0.2021, which agrees very well with the exact value.

Next consider the 3ร—3 example,

๐ด=(โˆ’212โˆ’1โˆ’3104โˆ’3),

(22)

whose logarithmic 2-norm is ๐œ‡2(๐ด)=๐œ†max(๐ด+๐ดโŠค)/2=โˆ’0.2058โ€ฆ. Applying the proposed numerical method we get ๐‘šโ‹†โ‰ˆ0.8023, which is obtained for the extremal diagonal matrix

๐ท=(1.00000000.80230001.0000),

where we observe that all entries assume extremal values in the interval [๐‘šโ‹†,1].

Figure 1: The function ๐œ™[๐‘š] for the example matrix (22).

Let us apply Newtonโ€™s method to compute ๐‘šโ‹†, using the costless derivative formula in Theoremย 4.2. The results are shown in Tableย 1, which shows quadratic convergence.

๐‘˜๐‘š๐œ™[๐‘š]๐œ™โ€ฒ[๐‘š]
00.90.1063080754141471.041560098368530
10.797933805662616โˆ’0.0050218775356311.140880961822965
20.802335559836519โˆ’9.673874699522855โ‹…10โˆ’61.136487060632446
30.802344071921729โˆ’3.612360410798487โ‹…10โˆ’111.136478572827426

Table 1:Example (22): quadratic convergence of Newtonโ€™s method. For ๐‘˜=3 we observe up to 10 exact digits, highlighted in bold font.

5 A combinatorial relaxation

The numerical integration of (9) is certainly a demanding step in terms of CPU time. However, when slightly modifying the value ๐‘š (or considering a smooth function ๐ด(๐‘ก)), in order to solve (9) for the new data, we propose an alternative strategy to the reintegration of (9), which is based on Theoremย 3.1.

5.1 On the necessary condition (15) of Theoremย 3.1

Theoremย 3.1 provides an analytic condition to identify intermediate entries. Equation (15) is a codimension-1 condition. It means that for having entries of the extremizer ๐ท[๐‘š] assuming intermediate values, either the ๐‘–-th component of the eigenvector ๐‘ฅ associated to the rightmost eigenvalue of Sym(๐ท[๐‘š]๐ด), or the ๐‘–-th component of the vector ๐‘ง=๐ด๐‘ฅ have to vanish.

In the 2ร—2 case it is direct to prove that extremizers are either

diag(1,๐‘šโ‹†)ordiag(๐‘šโ‹†,1),

and cannot assume intermediate values, as one expects. We omit the proof for sake of conciseness.

In the general ๐‘›-dimensional case, assume that we know an extremizer ๐ท[๐‘š], whose diagonal entries only assume the extremal values ๐‘š and 1 and that the eigenvector ๐‘ฅ of Sym(๐ท[๐‘š]๐ด) and the vector ๐‘ง=๐ด๐‘ฅ have entries suitably bounded away from zero. If we slightly perturb ๐‘š (or even the matrix ๐ด), then by continuity arguments we expect generically that the new extremizer has the same entry-pattern of ๐ท[๐‘š], which means that the new vectors ๐‘ฅ~ and ๐‘ง~ remain close to ๐‘ฅ and ๐‘ง and thus have still non-zero entries. This remains true also for moderate changes of ๐‘š. As an example, for the matrix (22) we get, using the proposed inner-outer scheme:

(๐‘ฅ,๐‘ฅโ‹†)=(0.38360.35950.61580.66640.68820.6532)and(๐‘ง,๐‘งโ‹†)=(1.22511.2537โˆ’1.5427โˆ’1.70550.39840.7059),

where ๐‘ฅ indicates the rightmost eigenvector of Sym(๐ด) and ๐‘ง=๐ด๐‘ฅ, ๐‘ฅโ‹† the rightmost eigenvector of Sym(๐ท๐‘šโ‹†๐ด) and ๐‘งโ‹†=๐ด๐‘ฅโ‹†. This illustrates the slight change between the above starting vectors and those in the extremizer.

Figure 2: The behaviour of the 3 entries of ๐‘ฅ (left) and ๐‘ง=๐ด๐‘ฅ (right) for extremizers for problem (22) as a function of ๐‘š.

The plot (as a function of ๐‘šโˆˆ[๐‘šโ‹†,1]) of the entries of ๐‘ฅ and of ๐‘ง is shown in Figureย 2.

Rem 5.1

Extremizers in general are not unique. Consider for example the following matrix ๐ด and ๐‘š=0.2

๐ด=(โˆ’313/2โˆ’1โˆ’13โˆ’1โˆ’30),Sym(๐ด)=(โˆ’301/40โˆ’101/400).

Then ๐ท1=diag(๐‘š,๐‘š,1), ๐ท2=diag(1,1,๐‘š) and ๐ท3=diag(๐‘š,1,๐‘š) are local extremizers, with ๐น(๐ท1)=โˆ’1.1427, ๐น(๐ท2)=โˆ’0.8764, ๐น(๐ท3)=โˆ’0.8237, so that ๐ท1 is the global minimizer. Instead for the matrix ๐ด in (22) with ๐‘š=0.8 the extremizer ๐ท=diag(1,๐‘š,1) turns out to be unique.

5.2 A greedy combinatorial algorithm

An algorithm to check possible extremizers only assuming extremal values is the following. Compute all possible diagonal matrices with combinatorial structure (which are 2๐‘›) and compute the gradient ๐บ for each of them. Looking at the sign of the vector ๐บ we can assert whether a certain matrix ๐ท is a local extremizer.

Rem 5.2 [Efficient combinatorics]

The combinatorial algorithm is very expensive when ๐‘› increases. However, starting from the knowledge of an extremizer ๐ท[๐‘š], the problem of minimizing ๐น for ๐‘šโ€ฒ close to ๐‘š might be efficiently tackled by maintaining as an initial guess the extremizer ๐ท[๐‘š], just replacing its entries equal to ๐‘š with the value ๐‘šโ€ฒ, and then checking the sign of the gradient. Similarly one could tackle the problem where the matrix ๐ด instead of ๐‘š is slightly changed, as we will see in the next section. This would allow to avoid the numerical integration of the system of ODEs to minimize ๐น and is somehow reminiscent of an approach based on interior point methods as opposed to simplex methods in linear programming problems.

For example (22), this gives only the detected matrix (for all ๐‘šโ‰ค๐‘šโ‹†)

๐ท[๐‘š]=(1000๐‘š0001).

For example, still considering Example (22), for the starting non-optimal diagonal matrix

๐ท=diag(๐‘š,๐‘š,1),

with ๐‘š=0.9, we get ๐œ†=โˆ’0.1523 and

๐บ=diag(๐ŸŽ.๐ŸŽ๐Ÿ•๐ŸŽ๐ŸŽ,โˆ’0.1602,0.0580),

which indicates that the optimality condition for the first entry is violated. Changing the value of the first entry to the opposite extremal value and modifying to

๐ท^[๐‘š]=diag(1,๐‘š,1),

(23)

allows us to find the optimal solution for the problem. At this point, it is sufficient to tune ๐‘š through the scalar equation

find๐‘š:๐œ†max(Sym(๐ท^[๐‘š]๐ด))=0,

where ๐ท^[๐‘š] has the structure in (23) to obtain the optimal value ๐‘šโ‹†โ‰ˆ0.8023.

6 Time-dependent case: problems (P1) and (P2)

We are now interested to consider the more general time-varying problem setting where ๐ด=๐ด(๐‘ก), for which we assume

๐œ‡2(๐ด(๐‘ก))<0.

The problem now would be that of computing the function of ๐‘ก

๐‘šโ‹†(๐‘ก)=argmin๐‘šโˆˆ[0,1]{๐‘š:๐œ‡2(๐ท๐ด(๐‘ก))โ‰ค0for all matrices ๐ทโˆˆฮฉ๐‘š}.

(24)

We denote by ๐ท[๐‘š](๐‘ก) an associated extremizer, that is such that ๐œ‡2(๐ท[๐‘š](๐‘ก)๐ด(๐‘ก))=0, and by ๐‘šโ‹†(๐‘ก) its smallest entry. To a given diagonal matrix ๐ทโˆˆฮฉ๐‘š, we associate the structured matrix

๐‘†(๐ท)={๐ผ1,๐ผ2,๐ผ3},

with

๐ผ1={๐‘–โˆˆ{1,โ€ฆ,๐‘›}:๐ท๐‘–๐‘–=1},๐ผ2={๐‘–โˆˆ{1,โ€ฆ,๐‘›}:๐ท๐‘–๐‘–=๐‘š},๐ผ3={๐‘–โˆˆ{1,โ€ฆ,๐‘›}:๐ท๐‘–๐‘–=๐›ฝ๐‘–โˆˆ(๐‘š,1)}.

(25)

By continuity arguments, we have generically that the structure of ๐‘†(๐ท[๐‘š](๐‘ก)) is piecewise constant along [0,๐‘‡], that means that indexes of the entries equal to 1 and to ๐‘š(๐‘ก), as well as those assuming intermediate values, remain so within certain intervals.

Let us consider the symmetric part of ๐ท[๐‘š](๐‘ก)๐ด(๐‘ก). Applying Lemmaย 3.1 to the rightmost eigenvalue of Sym(๐ท[๐‘š](๐‘ก)๐ด(๐‘ก)), under smoothness assumptions we obtain (where time dependence is omitted for conciseness):

0โ‰ก๐‘‘๐‘‘๐‘ก๐œ†=๐œ†.=12๐‘ฅโŠค(๐ท.๐ด+๐ดโŠค๐ท.+๐ท๐ด.+๐ด.โŠค๐ท)๐‘ฅ=12๐‘ฅโŠค(๐ท.๐ด+๐ดโŠค๐ท.)๐‘ฅ+๐›พ=๐‘ฅโŠค๐ท.๐‘ง+๐›พ,

with ๐‘ง=๐ด๐‘ฅ and

๐›พ=๐‘ฅโŠค(๐ท๐ด.+๐ด.โŠค๐ท)๐‘ฅ.

Then we have (exploiting Theoremย 3.1)

โˆ‘๐‘–=1๐‘›๐‘ฅ๐‘–๐ท.๐‘–๐‘–๐‘ง๐‘–=โˆ‘๐‘–โˆˆ๐ผ2๐‘ฅ๐‘–๐ท.๐‘–๐‘–๐‘ง๐‘–=(โˆ‘๐‘–โˆˆ๐ผ2๐‘ฅ๐‘–๐‘ง๐‘–)๐‘š.โ‹†(๐‘ก).

Consequently, we obtain the following scalar ODE for ๐‘šโ‹†(๐‘ก),

๐‘š.โ‹†(๐‘ก)=โˆ’๐›พ(๐‘ก)๐œ(๐‘ก),๐œ(๐‘ก)=โˆ‘๐‘–โˆˆ๐ผ2๐‘ฅ๐‘–(๐‘ก)๐‘ง๐‘–(๐‘ก).

(26)

This shows that from the sign of the r.h.s.ย of (26) we obtain the growth/decrease of ๐‘šโ‹†(๐‘ก). The resulting algorithm for the time-varying case is discussed in the next subsection.

6.1 Algorithm for the time varying problem

On a uniform time grid {๐‘ก๐‘˜}๐‘˜โ‰ฅ0 (๐‘ก๐‘˜+1=๐‘ก๐‘˜+ฮ”๐‘ก), given an extremizer ๐ท(๐‘ก๐‘˜) with minimal entry ๐‘šโ‹†(๐‘ก๐‘˜)=๐‘š๐‘˜โ‹†, we first approximate ๐‘šโ‹†(๐‘ก๐‘˜+1) by an Euler step (where we denote as ๐ด(๐‘˜)=๐ด(๐‘ก๐‘˜) and ๐ด.(๐‘˜)=๐ด.(๐‘ก๐‘˜)):

๐‘š๐‘˜+1=๐‘š๐‘˜โ‹†โˆ’ฮ”๐‘ก๐›พ๐‘˜๐œ๐‘˜,

with

๐›พ๐‘˜=(๐‘ฅ(๐‘˜))โŠค(๐ท(๐‘˜)๐ด.(๐‘˜)+(๐ด.(๐‘˜))โŠค๐ท(๐‘˜))๐‘ฅ(๐‘˜),๐œ๐‘˜=โˆ‘๐‘–โˆˆ๐ผ2๐‘ฅ๐‘–(๐‘˜)(๐‘ก)๐‘ง๐‘–(๐‘˜)(๐‘ก),

with ๐‘ฅ(๐‘˜) eigenvector of Sym(๐ท(๐‘˜)๐ด(๐‘˜)) associated to the rightmost eigenvalue and ๐‘ง(๐‘˜)=๐ด๐‘ฅ(๐‘˜). Next, we update ๐ท(๐‘ก๐‘˜+1) by setting its minimal entries as ๐‘š๐‘˜+1 and compute ๐‘ฅ(๐‘˜+1), i.e. the eigenvector of Sym(๐ท(๐‘˜+1)๐ด(๐‘ก๐‘˜+1)) associated to its rightmost eigenvalue, and set ๐‘ง(๐‘˜+1)=๐ด๐‘ฅ(๐‘˜+1). Then, in order to obtain a more accurate approximation of ๐‘š๐‘˜+1โ‹†, we apply a single Newton step, as described in Subsection 4.3. Finally we verify that the resultant matrix ๐ท(๐‘˜+1)=๐ท[๐‘š๐‘˜+1โ‹†] is an extremizer by checking (see (25))

๐‘ฅ๐‘–(๐‘˜+1)๐‘ง๐‘–(๐‘˜+1)>0for๐‘–โˆˆ๐ผ1and๐‘ฅ๐‘–(๐‘˜+1)๐‘ง๐‘–(๐‘˜+1)<0for๐‘–โˆˆ๐ผ2.

(27)

If, for at least one index ๐‘–, one of the previous conditions (27) is violated, then an optimizer with a new structure is searched by running the whole Algorithm described in Section 3 for the matrix ๐ด=๐ด(๐‘ก๐‘˜+1).

6.2 Illustrative examples

Consider next the matrix

๐ด(๐‘ก)=(โˆ’2โˆ’sin(๐‘ก)cos(๐‘ก)2โˆ’2โˆ’cos(๐‘ก)),๐‘กโˆˆ[0,๐‘‡],๐‘‡=๐œ‹,

(28)

which for ๐‘ก=0 coincides to Example (21). Figureย 3a illustrates the behaviour of ๐‘šโ‹†(๐‘ก).

Figure 3:Behaviour of ๐‘šโ‹† as a function of ๐‘ก, for two different matrix-valued functions ๐ด(๐‘ก).

Next, consider the matrix

๐ด(๐‘ก)=(โˆ’๐‘กโˆ’11๐‘ก2+12โˆ’1๐‘กโˆ’3๐‘ก+13โˆ’2๐‘ก1โˆ’2๐‘ก2๐‘กโˆ’4),๐‘กโˆˆ[0,๐‘‡],๐‘‡=1.

(29)

Figureย 3b shows the sudden change of extremizer at ๐‘กโ‰ˆ0.7. The set ๐ผ2={1,2} switches to ๐ผ2={3}, when ๐‘ก crosses the discontinuity point for (๐‘šโ‹†)โ€ฒ(๐‘ก).

6.3 Remarks

Applying the proposed method we obtain an accurate approximation of the extremizers ๐ท[๐‘š](๐‘ก) for the considered problem (24) for ๐‘ก=๐‘ก๐‘˜,๐‘˜=0,1,โ€ฆ To have a uniform choice which guarantees contractivity we have to choose

๐‘šโ‹†=max๐‘˜๐‘š๐‘˜โ‹†,

which might be too restrictive. Another possibility would be that of changing the slope ๐‘š=๐‘š(๐‘ก) in the function ๐œŽ(๐‘ก). Finally, relaxing the bound

๐œ†max(Sym(๐ท[๐‘š](๐‘ก)๐ด(๐‘ก)))โ‰ค0to๐œ†max(Sym(๐ท[๐‘š](๐‘ก)๐ด(๐‘ก)))โ‰ค๐›ผ

for some moderate ๐›ผ>0, would allow maintaining control on the growth of the solution (the constant ๐ถ in (3) would be ๐ถโ‰คe๐›ผ๐‘‡), without restricting the range of ๐œŽโ€ฒ.

6.4 A different outlook. Problem (P2): stability bound for fixed ๐‘š

Assume that ๐‘š is fixed and we want to compute a bound for the growth of the error in the solution of Problem (P2), that is to get a worst-case estimate of the type (3). We write the solution to the differential equation ๐‘ข.=๐ท(๐‘ก)๐ด(๐‘ก)๐‘ข, ๐‘ข(๐‘ก0)=๐‘ข0 (with ๐ท(๐‘ก) unknown a priori), as

๐‘ข(๐‘ก)=ฮฆ(๐‘ก,๐‘ก0)๐‘ข0.

By Grรถnwall Lemma, it can be shown that a bound for the norm of the state transition matrix ฮฆ(๐‘ก,๐‘ก0) is given by

โ€–ฮฆ(๐‘ก,๐‘ก0)โ€–โ‰คexp(โˆซ๐‘ก0๐‘ก๐œ‡2(๐ท(๐‘ )๐ด(๐‘ ))๐‘‘๐‘ ),

for all ๐‘กโ‰ฅ๐‘ก0. This means that if we compute the worst case quantity ๐œ‡2(๐‘ )=๐œ‡2(๐ท(๐‘ )๐ด(๐‘ )) for ๐ท(๐‘ )โˆˆฮฉ๐‘š, by applying a quadrature formula we get an upper bound for the constant ๐ถ, that is

๐ถโ‰คexp(โˆซ0๐‘‡๐œ‡2(๐ท~(๐‘ )๐ด(๐‘ ))๐‘‘๐‘ )โ‰ˆexp(๐‘„[๐œ‡2(๐ท~(๐‘ )๐ด(๐‘ ))])โ‰”๐ถ~,

(30)

with ๐ท~(๐‘ก)=argmax๐ทโˆˆฮฉ๐‘š๐œ‡2(๐ท๐ด(๐‘ก)) and ๐‘„[โ‹…] a suitable quadrature formula, e.g. the trapezoidal rule.

Figure 4: The behaviour (for fixed ๐‘š) of ๐œ‡2(๐‘ก) (see (31)) for the matrix-valued function (29) as a function of ๐‘ก.

Figureย 4 illustrates the behaviour of

๐œ‡2(๐‘ก):=๐œ‡2(๐ท~(๐‘ก)๐ด(๐‘ก))

(31)

for the matrix-valued function ๐ด(๐‘ก) of example (29), where for the quadrature we have used trapezoidal rule.

Rem 6.1

It is not guaranteed that there exists a trajectory ๐‘ข(๐‘ก) of the dynamical system (2) to which corresponds the critical matrix sequence ๐ท~(๐‘ก). However, if such a trajectory exists, then the bound (30) is sharp.

6.5 Illustrative example

Let us consider the Cauchy problem (2) with ๐‘‡=2 and the example matrix (29). Note that, for ๐‘š=0.5, the problem is strictly contractive in the spectral norm. We compute the upper bound (30) for several values of ๐‘š. The results are illustrated in Tableย 2.

๐‘šmin๐‘ก๐œ‡2(๐‘ก)๐‘„[๐œ‡2(๐‘ก)]๐ถ~
0.010.28901.24673.4787
0.050.22021.11703.0556
0.10.13790.96052.6129
0.2โˆ’0.02160.66101.9368
0.5โˆ’0.4076โˆ’0.14140.8681

Table 2:The upper bound ๐ถ~ for Example (29).

7 An application: a neural network for digits classification

To conclude, we apply the theory developed in the previous sections to increase the robustness of a neural ODE image classifier. To this end, we consider MNIST handwritten digits dataset [24] perturbed via the Fast Gradient Sign Method (FGSM) adversarial attack [7].

Here, in order to maintain accuracy (the percentage of correctly classified testing images) of the neural network, the minimal slope ๐‘š<1 cannot be too large. For this reason we have to face Problem (P3), since when we solve Problem (P1) with the learnt matrix ๐ด, it can happen that the value ๐‘šโˆ— computed by solving Problem (P1) in order to get uniform contractivity of the neural ODE, might be larger than ๐‘š. In this case we modify the matrix ๐ด in order to increase the stability of the network, by simple perturbations of the form โˆ’๐›ฟI, that is suitably shifting ๐ด by a scaled identity matrix. The use of optimal modifications of ๐ด is not considered in this article, although we consider it an important research topic.

Let us recall that MNIST consists of 70000 28ร—28 grayscale images (60000 training images and 10000 testing images), that is vectors of length 784 after vectorization. We consider a neural network made up of the following blocks:

  1. a downsampling affine layer that reduces the dimension of the input from 784 to 64, i.e. a simple transformation of the kind ๐‘ฆ=๐ด1๐‘ฅ+๐‘1, where ๐‘ฅโˆˆโ„784 is the input, ๐‘ฆโˆˆโ„64 is the output, and ๐ด1โˆˆโ„64,784 and ๐‘1โˆˆโ„64 are the parameters;

  2. a neural ODE block that models the feature propagation,

    {๐‘ฅ.(๐‘ก)=๐œŽ(๐ด๐‘ฅ(๐‘ก)+๐‘),๐‘กโˆˆ[0,1],๐‘ฅ(0)=๐‘ฆ,

    whose initial value is the output of the previous layer, where ๐‘ฅ(๐‘ก):[0,1]โ†’โ„64 is the feature vector evolution function, ๐ดโˆˆโ„64,64 and ๐‘โˆˆโ„64 are the parameters, and ๐œŽ is a custom activation function, defined as

    ๐œŽ(๐‘ฅ)={๐‘ฅ,if ๐‘ฅโ‰ฅ0,tanh๐‘ฅ,if โˆ’๐‘ฅยฏโ‰ค๐‘ฅ<0,๐›ผ๐‘ฅ,otherwise,

    where ๐‘ฅยฏ>0 is such that tanhโ€ฒ(ยฑ๐‘ฅยฏ)=๐›ผ=0.1 (see Figureย 5);

    Figure 5: Custom activation function: a smoothed Leaky Rectified Linear Unit (LeakyReLU) with minimal slope ๐›ผ=0.1.

  3. a final classification layer that reduces the dimension of the input from 64 to 10, followed by the softmax activation function

    ๐‘ฅout=softmax(๐ด2๐‘ฅ(1)+๐‘2),

    where ๐‘ฅ(1)โˆˆโ„64 is the output of the neural ODE block, ๐ด2โˆˆโ„10,64 and ๐‘2โˆˆโ„10 are the parameters, and ๐‘ฅout is the output vector whose component ๐‘– is the probability that the input ๐‘ฅ belongs to the class ๐‘–. Recall that softmax is a vector-valued function that maps the vector ๐‘ฅ into the vector softmax(๐‘ฅ)=๐‘’๐‘ฅโ€–๐‘’๐‘ฅโ€–1โˆ’1, where exponentiation is done entrywise.

We require the neural ODE block to be contractive, so that small perturbations added to the input, such as adversarial attacks, are not amplified.

Making use of the proposed algorithm for solving Problem (P1), we compute the smallest value ๐‘šโ‹† that the entries of the diagonal matrix ๐ท can assume, such that

sup{๐œ‡2(๐ท๐ด),โˆ€๐ทโˆˆ๐”ป64,64 such that ๐ท๐‘–๐‘–โˆˆ[๐‘šโ‹†,1]}=0,

(32)

which implies the neural ODE is contractive if ๐‘šโ‹†โ‰ค๐›ผ. If the value ๐‘šโ‹† computed by the algorithm in Subsection 4.3 is larger than ๐›ผ, we set ๐›ฟ>0 a small positive constant and replace the matrix ๐ด by the shifted matrix

๐ด^=๐ดโˆ’โ„“๐›ฟ๐ผ,

where โ„“ is the smallest positive integer such that (32) holds for ๐ด^ in place of ๐ด.

Note that shifting the matrix ๐ด, and thus its entire spectrum, to get ๐‘šโ‹† below the specified threshold ๐›ผ, is a greedy algorithm that allows us to obtain (32). Other strategies may be used here, including computing the nearest matrix to ๐ด in some suitable metric while ensuring ๐‘šโ‹†โ‰ค๐›ผ.

We add the proposed shifting to the standard training methodology via adjoint method [2] after parameter initialization and after each step of gradient descent to guarantee that (32) holds with ๐‘šโ‹†โ‰ค๐›ผ during training.

Rem 7.1

Observe that we apply the algorithm in Subsection 4.3 to compute ๐‘šโ‹† after parameter initialization and after each step of gradient descent during training, to decide if the weight matrix needs to be shifted or not. Therefore, the algorithm for solving Problem (P1) is applied each time to a different matrix.

Then, we train a first version of the above-mentioned neural network according to standard training, and we train a second version of the same neural network employing the proposed modification to the standard training. The networks are trained for 70 epochs. As a further comparison, we consider two models in the literature to improve adversarial robustness: the structural approach asymODEnet, where the vector field is constrained to be antisymmetric, i.e.

๐‘ฅ.(๐‘ก)=โˆ’๐ดโŠค๐œŽ(๐ด๐‘ฅ(๐‘ก)+๐‘),๐‘กโˆˆ[0,1],

considered for example in [3], [15], [16], and the method SODEF by Kang et al. in [17], which is a neural ODE whose equilibrium points correspond to the classes of the considered dataset. By ensuring that the equilibrium points are Lyapunov-stable, the solution for an input with a small perturbation is guaranteed to converge to the same solution corresponding to the unperturbed initial datum.

Loss and accuracy values for all four aforementioned methods are provided in Figureย 6. We eventually compare in Tableย 3 the test accuracy of the considered models as a function of ๐œ€>0. This quantity measures the size in the ๐ฟโˆž-norm of the FGSM perturbation applied to each testing image, i.e. if ๐‘ฅ๐‘– is a testing image, ๐‘ฅ๐‘–+๐œ€๐›ฟ๐‘– is the perturbed image, with ๐›ฟ๐‘– the FGSM attack on ๐‘ฅ๐‘– and โ€–๐›ฟ๐‘–โ€–โˆž=1. Incorporating the strategy proposed here, we observe a clear improvement in robustness against the FGSM attack.

๐œ€00.010.020.030.040.050.06
ODEnet [2]0.97070.94470.89270.79740.65590.48940.343
stabODEnet0.96840.94960.91880.87430.80490.70190.5769
SODEF [17]0.97070.94380.89320.80010.67210.5220.3893
asymODEnet [3]0.93210.88980.81960.74390.63810.49680.3565

Table 3:Comparison of test accuracy across different models as a function of ๐œ€. Tests are implemented fixing the Euler step to โ„Ž=0.05. The models with the best performance are highlighted.

Figure 6: Losses (on the left) and accuracy (on the right) behaviour during training for ODEnet, stabilized stabODEnet, SODEF, and asymODEnet.

Rem 7.2

In our experiments, Tableย 3, the neural ODE block (b) has been numerically integrated with the forward Euler method with step size โ„Ž=0.05. Notice that, if the step size โ„Ž is sufficiently small and the neural ODE is contractive, then the discretization of the neural ODE preserves the contractivity of its continuous counterpart. Tableย 4 shows the performance of the model with the neural ODE block discretized using different step sizes. It is worth pointing out that the contractive behaviour seems to decrease approximately when โ„Ž=0.33.

๐œ€00.010.020.030.040.050.06
โ„Ž=0.010.96990.95080.92600.88260.81160.71630.5880
โ„Ž=0.01250.96970.94950.92350.88250.81510.72140.6014
โ„Ž=0.0250.96850.95030.92360.88040.81330.72190.6033
โ„Ž=0.050.96840.94960.91880.87430.80490.70190.5769
โ„Ž=0.10.96890.95020.92620.88680.82290.73580.6261
โ„Ž=0.20.96560.94560.91920.88070.82340.73810.6318
โ„Ž=0.330.94720.92880.90170.86410.81450.74290.6354

Table 4:Comparison of test accuracy as a function of ๐œ€ for the varying Euler step โ„Ž for the stabilized stabODEnet (our method). The settings with the best performance are highlighted.

8 Conclusions

In this article we have proposed a novel methodology to solve numerically a class of eigenvalue optimization problems arising when analyzing contractivity of neural ODEs. Solving such problems is essential in order to make a neural ODE stable (contractive) with respect to perturbations of initial data, and thus preventing the output of the neural ODE to be sensitive to small input perturbations, such those induced by adversarial attacks.

The proposed method consists of a two-level nested algorithm, consisting of an inner iteration for the solution of an inner eigenvalue optimization problem by a gradient system approach, and in an outer iteration tuning a parameter of the problem until a certain scalar equation is verified.

The proposed algorithm appears to be fast and its behaviour has been analyzed through several numerical examples, showing its effectiveness and reliability. A real application of a neural ODE to digits classification shows how this algorithm can be easily embedded in the contractive training of a neural ODE, making it robust and stable against adversarial attacks.

Bibliography

  • [1] K. He, X. Zhang, S. Ren, and J. Sun, โ€œDeep Residual Learning for Image Recognition,โ€ in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2016.
  • [2] R. T. Q. Chen, Y. Rubanova, J. Bettencourt, and D. K. Duvenaud, โ€œNeural Ordinary Differential Equations,โ€ in Advances in Neural Information Processing Systems, 2018.
  • [3] E. Haber and L. Ruthotto, โ€œStable Architectures for Deep Neural Networks,โ€ Inverse Problems, 2018.
  • [4] E. Celledoni et al., โ€œStructure-Preserving Deep Learning,โ€ European Journal of Applied Mathematics, 2021.
  • [5] B. Biggio et al., โ€œEvasion Attacks against Machine Learning at Test Time,โ€ in Machine Learning and Knowledge Discovery in Databases, 2013.
  • [6] C. Szegedy et al., โ€œIntriguing Properties of Neural Networks,โ€ in International Conference on Learning Representations, 2014.
  • [7] I. J. Goodfellow, J. Shlens, and C. Szegedy, โ€œExplaining and Harnessing Adversarial Examples,โ€ in International Conference on Learning Representations, 2015.
  • [8] F. Carrara, R. Caldelli, F. Falchi, and G. Amato, โ€œOn the Robustness to Adversarial Examples of Neural ODE Image Classifiers,โ€ in IEEE International Workshop on Information Forensics and Security, 2019.
  • [9] H. Yan, J. Du, V. Y. F. Tan, and J. Feng, โ€œOn Robustness of Neural Ordinary Differential Equations,โ€ in International Conference on Learning Representations, 2020.
  • [10] M. Li, L. He, and Z. Lin, โ€œImplicit Euler Skip Connections: Enhancing Adversarial Robustness via Numerical Stability,โ€ in International Conference on Machine Learning, 2020.
  • [11] F. Carrara, R. Caldelli, F. Falchi, and G. Amato, โ€œDefending Neural ODE Image Classifiers from Adversarial Attacks with Tolerance Randomization,โ€ in International Conference on Pattern Recognition, 2021.
  • [12] F. Carrara, R. Caldelli, F. Falchi, and G. Amato, โ€œImproving the Adversarial Robustness of Neural ODE Image Classifiers by Tuning the Tolerance Parameter,โ€ Information, 2022.
  • [13] R. Caldelli, F. Carrara, and F. Falchi, โ€œTuning Neural ODE Networks to Increase Adversarial Robustness in Image Forensics,โ€ in IEEE International Conference on Image Processing, 2022.
  • [14] B. Chang, L. Meng, E. Haber, L. Ruthotto, D. Begert, and E. Holtham, โ€œReversible Architectures for Arbitrarily Deep Residual Neural Networks,โ€ in Conference on Artificial Intelligence, 2018.
  • [15] E. Celledoni, D. Murari, B. Owren, C.-B. Schรถnlieb, and F. Sherry, โ€œDynamical Systems-Based Neural Networks,โ€ SIAM Journal on Scientific Computing, 2023.
  • [16] F. Sherry, E. Celledoni, M. J. Ehrhardt, D. Murari, B. Owren, and C.-B. Schรถnlieb, โ€œDesigning stable neural networks using convex analysis and ODEs,โ€ Physica D: Nonlinear Phenomena, 2024.
  • [17] Q. Kang, Y. Song, Q. Ding, and W. P. Tay, โ€œStable Neural ODE with Lyapunov-Stable Equilibrium Points for Defending against Adversarial Attacks,โ€ in Advances in Neural Information Processing Systems, 2021.
  • [18] X. Li, Z. Xin, and W. Liu, โ€œDefending Against Adversarial Attacks via Neural Dynamic System,โ€ in Advances in Neural Information Processing Systems, 2022.
  • [19] Y. Huang, Y. Yu, H. Zhang, Y. Ma, and Y. Yao, โ€œAdversarial Robustness of Stabilized Neural ODE Might Be From Obfuscated Gradients,โ€ in Mathematical and Scientific Machine Learning, 2022.
  • [20] G. Sรถderlind, โ€œThe logarithmic norm. History and modern theory,โ€ BIT Numerical Mathematics, 2006.
  • [21] D. Rim, S. Suri, S. Hong, K. Lee, and R. J. LeVeque, โ€œA Stability Analysis of Neural Networks and Its Application to Tsunami Early Warning,โ€ EarthArXiv, 2023.
  • [22] E. Hairer, S. P. Nรธrsett, and G. Wanner, Solving Ordinary Differential Equations I: Nonstiff Problems. Springer, 1993.
  • [23] T. Kato, Perturbation Theory for Linear Operators. Springer, 2013.
  • [24] L. Deng, โ€œThe MNIST Database of Handwritten Digit Images for Machine Learning Research,โ€ IEEE Signal Processing Magazine, 2012.
  1. 1If ๐‘šโ‹†โ‰ค๐‘š, then the behaviour of the neural ODE is contractive and there is no need to modify ๐ด, otherwise there is the option to modify ๐ด (for example shifting ๐ด to ๐ดโˆ’๐›ฟI with ๐›ฟโ‰ฅ0) until the condition above is satisfied.
  2. 2This means that the entries that are equal to the extremal value ๐‘š in the matrix ๐ท[๐‘š] remain extremal for ๐‘š in a neighborhood of ๐‘šโ‹†, which looks quite reasonable.