NOVAS: NON - CONVEX OPTIMIZATION VIA ADAPTIVE STOCHASTIC SEARCH FOR END - TO - END LEARNING AND CONTROL
In this work we propose the use of adaptive stochastic search as a building block for general, non-convex optimization operations within deep neural network architectures.
Speciﬁcally, for an objective function located at some layer in the network and parameterized by some network parameters, we employ adaptive stochastic search to perform optimization over its output.
This operation is differentiable and does not obstruct the passing of gradients during backpropagation, thus enabling us to incorporate it as a component in end-to-end learning.
We study the proposed optimization module’s properties and benchmark it against two existing alternatives on a synthetic energy-based structured prediction task, and further showcase its use in stochastic optimal control applications.
I NTRODUCTION
Deep learning has experienced a drastic increase in the diversity of neural network architectures, both in terms of proposed structure, as well as in the repertoire of operations that deﬁne the interdependencies of its elements.
With respect to the latter, a signiﬁcant amount of attention has been devoted to incorporating optimization blocks or modules operating at some part of the network.
This has been motivated by large number of applications, including meta-learning (Finn et al., 2017; Rusu et al., 2018; Bartunov et al., 2019), differentiable physics simulators (de Avila Belbute-Peres et al., 2018), classiﬁcation (Amos et al., 2019), GANs (Metz et al., 2016), reinforcement learning with constraints, latent spaces or safety (Amos & Kolter, 2017; Srinivas et al., 2018; Amos & Yarats, 2019; Cheng et al., 2019; Pereira et al., 2020), model predictive control (Amos et al., 2018; Pereira et al., 2018), as well as tasks relying on the use of energy networks (Belanger et al., 2017; Bartunov et al., 2019), among many others.
Local 1 optimization modules lead to nested optimization operations, as they interact with the global, end-to-end training of the network that contains them.
Consider some component within the neural network architecture, e.g. a single layer, whose input and output are x i ∈ R n and x i +1 ∈ R m , respectively.
Within that layer, the input and output are linked via the solution of the following optimization problem:
[Equation]
that is, the output x i +1 is deﬁned as the solution to an optimization problem for which the input x i remains temporarily ﬁxed, i.e., acts as a parameter.
Here, F ( x ; x i , θ ) : R m × R n × Θ → R is a function possibly further parameterized by some subset of the neural network parameters θ ∈ Θ .
Note that x here is an independent variable which is free to vary.
The result of this optimization could potentially also be subject to a set of (input-dependent) constraints, though in this paper we will consider only unconstrained optimization.
It is also important to note that, depending on the problem, F can be a given function, or it can itself be represented by a multi-layer neural network (trained by the outer loop), in which case the aforementioned optimization layer consists of multiple sub-layers and is more accurately described as a module rather than a single layer.
Examples of this type of optimization are structured prediction energy networks (e.g. Belanger et al.
; another such example is Amos & Kolter (2017) which treats the case of convex F ( · ; x i , θ ) .
In order to facilitate end-to-end learning over the entire network, the gradient of its loss function L with respect to θ will require during backpropagation passing the gradient of the module’s output x i +1 with respect to parameters θ and x i .
Depending on the nature of the optimization problem under consideration, several procedures have been suggested; among them, particularly appealing is the case of convex optimization (Gould et al., 2016;
Johnson et al., 2016; Amos et al., 2017; Amos &
Kolter, 2017), in which the aforementioned gradients can be computed efﬁciently through an application of the implicit function theorem to a set of optimality conditions, such as the KKT conditions.
In the case of non-convex functions however, obtaining such gradients is not as straight-forward; solutions involve either forming and solving a locally convex approximation of the problem, or unrolling gradient descent (Domke, 2012;
Metz et al., 2016; Belanger et al., 2017; Finn et al., 2017;
Srinivas et al., 2018; Rusu et al., 2018;
Foerster et al., 2018; Amos et al., 2018).
Unrolling gradient descent approximates the arg min operator with a ﬁxed number of gradient descent iterations during the forward pass and interprets these as an unrolled compute graph that can be differentiated through during the backward pass.
One drawback in using this unrolled gradient descent operation however is the fact that doing so can lead to over-ﬁtting to the selected gradient descent hyper-parameters, such as learning rate and number of iterations.
Recently, Amos & Yarats (2019) demonstrated promising results in alleviating this phenomenon by replacing these iterations of gradient descent by iterations of sampling-based optimization, in particular a differentiable approximation of the cross-entropy method.
While still unrolling the graph created by the ﬁxed number of iterations, they showed empirically that no over-ﬁtting to the hyper-parameters occurred by performing inference on the trained network with altered inner-loop optimization hyper-parameters.
Another signiﬁcant bottleneck in all methods involving graph unrolling is the number of iterations, which has to be kept low to prevent a prohibitively large graph during backprop, to avoid issues in training.
Note that in eq.
(1) the variable of optimization is free to vary independently of the network.
This is in contrast to many applications involving nested optimization, mainly in the ﬁeld of meta-learning, in which the inner loop, rather than optimizing a free variable, performs adaptation to an initial value which is supplied to the inner loop by the outer part of the network.
For example, MAML (Finn et al., 2017) performs the inner-loop adaptation θ → θ (cid:48) , in which the starting point θ is not arbitrary (as x is in eq.
but is supplied by the network.
Thus, in the context of adaptation , unrolling the inner-loop graph during back-prop is generally necessary to trace the adaptation back to the particular network-supplied initial value.
Two notable exceptions are ﬁrst-order MAML (Finn et al., 2017; Nichol et al., 2018), which ignores second derivative terms, and implicit MAML (Rajeswaran et al., 2019), which relies on local curvature estimation.
In this paper we propose Non-convex Optimization Via Adaptive Stochastic Search (NOVAS), a module for differentiable, non-convex optimization.
The backbone of this module is adaptive stochastic search (Zhou & Hu, 2014), a sampling-based method within the ﬁeld of stochastic optimization.
The contributions of our work are as follows: (A).
We demonstrate that the NOVAS module does not over-ﬁt to optimization hyper-parameters and offers improved speed and convergence rate over its alternative (Amos & Yarats, 2019).
(B).
If the inner-loop variable of optimization is free to vary (i.e., the problem ﬁts the deﬁnition given by eq.
(1)), we show that there is no need to unroll the graph during the back-propagation of gradients .
The latter advantage is critical, as it drastically reduces the size of the overall end-to-end computation graph, thus facilitating improved ability to learn with higher convergence rates, improved speed, and reduced memory requirements.
Furthermore, it allows us to use a higher number of inner-loop iterations.
(C).
If the inner-loop represents an adaptation to a network-supplied value as it is the case in meta-learning applications, NOVAS may still be used in lieu of the gradient descent rule (though unrolling the graph may be necessary here).
Testing NOVAS in such a setting is left for future work.
(D).
We combine the NOVAS module with the framework of deep FBSDEs , a neural network-based approach to solving nonlinear partial differential equations (PDEs).
This combination allows us to solve Hamilton-Jacobi-Bellman (HJB)
PDEs of the most general form, i.e., those in which the min operator does not have a closed-form solution, a class of problems that was previously impossible to address due to the non-convexity of the corresponding Hamiltonian.
We validate the algorithm on a cart-pole task and demonstrate its scalability on a 101-dimensional continuous-time portfolio selection problem. The code is available at https://github.com/iexarchos/NOVAS.git
F URTHER BACKGROUND AND RELATED WORK
Relation to Differentiable Cross-Entropy: Particular importance should be given to Amos &
Yarats (2019), since, to the best of our knowledge, it is the ﬁrst to suggest sampling-based optimization instead of gradient descent, and features some similarities with our approach.
The authors therein propose a differentiable approximation of the cross-entropy method (CEM) (Rubinstein, 2001; De Boer et al., 2005), called differentiable cross-entropy (DCEM).
To obtain this approximation, they need to approximate CEM’s eliteness threshold operation, which is non-differentiable.
This is done by solving an additional, convex optimization problem separately for each inner loop step (and separately for each sample of x i in the batch, resulting in a total of N × M × K additional convex optimization problems , with N : batch size, M : number of inner loop iterations, K : number of outer loop iterations, i.e. training epochs).
After CEM has been locally approximated by DCEM, they replace the usual inner-loop gradient descent steps with DCEM steps, and the entire inner-loop optimization graph is unrolled during the backward pass.
Our method differs from this approach in the following ways: 1.
we employ the already differentiable adaptive stochastic search algorithm, thus not having to solve any additional optimization problem to obtain a differentiable approximation (speed improvement), while also showing some convergence rate improvements, and most importantly 2.
In the case of inner-loop optimization over an independent variable (e.g., such as the problem deﬁned by eq.
(1)), we do not unroll the optimization graph, but instead pass the gradients only through the last inner-loop iteration .
This drastically reduces its size during backpropagation, increasing speed, reducing memory requirements, and facilitating easier learning.
Sampling-based Optimization: Adaptive stochastic search (Zhou & Hu, 2014) is a sampling-based method within stochastic optimization that transforms the original optimization problem via a probabilistic approximation.
The core concept behind this algorithm is approximating the gradient of the objective function by evaluating random perturbations around some nominal value of the independent variable, a concept that also appears under the name Stochastic Variational Optimization and shares many similarities with natural evolution strategies (Bird et al., 2018).
Another comparable approach is CEM (Rubinstein, 2001; De Boer et al., 2005).
In contrast to adaptive stochastic search,
CEM is non-differentiable (due to the eliteness threshold) and the parameters are typically updated de novo in each iteration, rather than as a gradient descent update to the parameter values of the previous iteration.
In the case of Gaussian distributions, the difference between CEM and adaptive stochastic search boils down to the following: in adaptive stochastic search, the mean gets updated by calculating the average of all sampled variable values weighted by a typically exponential mapping of their corresponding objective function values, whereas in CEM only the top- k performing values are used, and are weighted equally.
Furthermore, this difference can be made even smaller if one replaces the exponential mapping in the former method with a differentiable (sigmoid) function that approximates the eliteness operation.
More details are available in the Appendix.
Deep Learning Approaches for PDEs and FBSDEs
: There has been a recent surge in research and literature in applying deep learning to approximate solutions of high-dimensional PDEs.
The transition from a PDE formulation to a trainable neural network is done via the concept of a system of
Forward-Backward Stochastic Differential Equations (FBSDEs).
Speciﬁcally, certain PDE solutions are linked to solutions of FBSDEs.
Systems of FBSDEs can be interpreted as a stochastic equivalent to a two-point boundary value problem, and can be solved using a suitably deﬁned deep neural network architecture.
This is known in the literature as the deep FBSDE approach (Han et al., 2018;
Raissi, 2018).
While applied in high-dimensional PDEs, the aforementioned results have seen very limited applicability in the ﬁeld of optimal control.
Indeed, the HJB PDE in control theory has a much more complicated structure, and in its general form involves a min operator applied on its
Hamiltonian term over the control input.
Exploiting certain structures of system dynamics and cost functions that allowed for a closed-form expression for this operator, Exarchos & Theodorou (2018);
Exarchos et al.
(2018; 2019) developed a framework for control using FBSDEs, which was then translated to a deep neural network setting in Pereira et al. (2019b)
; Wang et al.
In this work, we incorporate the NOVAS module inside deep FBSDE neural network architectures to account for
PDEs lacking a closed-form expression for their min and/or max operators.
Thus, we are able to address the most general description of a HJB PDE in which the corresponding Hamiltonian is nonconvex.
More information concerning the deep FBSDE framework can be found in the Appendix.
N ON - CONVEX OPTIMIZATION VIA ADAPTIVE STOCHASTIC SEARCH
The cornerstone of our approach is a method within stochastic optimization called adaptive stochastic search (Zhou & Hu, 2014).
Adaptive stochastic search addresses the general maximizationproblem
[Equation]
with X being non-empty and compact, and F : X → R a real-valued, non-convex, potentially discontinuous and non-differentiable function.
Instead of dealing with this function that lacks desirable properties such as smoothness, adaptive stochastic search proposes the solution of a stochastic approximation of this problem in which x is drawn from a selected probability distribution f
( x ; ρ ) of the exponential family with parameters ρ and solve
[Equation]
This new objective function, due to its probabilistic nature, exhibits desirable properties for optimization.
Algorithmically, this can be facilitated by introducing a natural log and a shape function
S ( · ) :
R → R + which is continuous, non-decreasing, and with a non-negative lower bound (an example of such a function would be the exponential).
Due to their properties, passing F ( x ) through
S ( · ) and the log does not affect the optimal solution.
The ﬁnal optimization problem is then
[Equation]
To address this optimization problem, one can sample candidate solutions x from f ( x ; ρ ) in the solution space X , and then use a gradient ascent method on eq.
(3) to update the parameter ρ .
Depending on the chosen probability distribution for sampling x , a closed-form solution for the gradient of the above objective function with respect to ρ is available.
Thus, while still being a sampling-based method at its core, adaptive stochastic search employs gradient ascent on a probabilistic mapping of the initial objective function.
While any probability density function of the exponential family will work, in our work we sample x from a Gaussian distribution.
The resulting update scheme is shown in Alg.
More details concerning its derivation are included in the Appendix.
As described in the introduction, the standard approach employed in the literature for non-convex inner-loop optimization is to apply an optimization procedure (either gradient descent or DCEM) for a ﬁxed number of iterations during the forward pass and interpret these as an unrolled compute graph that can be differentiated through during the backward pass.
In this work we argue that this needs to be done only in cases of adaptation (e.g., in meta-learning): the variable to be adapted is supplied to the inner-loop by the outer part of the network, and is adapted using a rule such as gradient descent with respect to the inner-loop objective function for a ﬁxed number of steps.
Crucially, the process is not initialized with an arbitrary initial value for the adapted variable but with the one that is supplied by the network; the backward pass which needs to pass through the optimization module also needs to ﬂow through the input of the variable of optimization in the module.
Thus, the variable’s values pre- and post-adaptation need to be linked via the unrolled computational graph of the adaptation.
In contrast, in the case in which the variable of optimization is not an input to the layer, but rather is allowed to vary freely and independently of the outer part of the network (e.g. as described by problem (1)), such a process is not only unnecessary, but further leads to complications such as reduced network trainability and learning speed, as well as increased memory usage and computation time.
Given that in this case the variable of optimization is initialized by what is typically no more than a random guess, there is no need to trace the gradients during backpropagation all the way back to that random guess.
After ﬁxing a number of iterations for optimization, say, n , a simple way to implement NOVAS in a non-unrolled fashion is to take n − 1 of the iterations off the graph and perform only the n -th on
Given:
Neural network architecture containing NOVAS module, mini-batch dataset { X j , Y j } Jj =
NOVAS objective function F · ; x i , θ ) .
Parameters:
Set x 1 ← { X j } for i = 1 to L do if f i is NOVAS layer then
Set µ ← µ 0 , σ ← σfor n = 1 to N − 1 ( off-graph operations ) do ( µ, σ ) ← NOVAS Layer ( µ, σ, α, S, M, N, (cid:15), F ) end for ( µ, σ ) ← NOVAS Layer ( µ, σ, α, S, M, N, (cid:15), F ) x i +
= µ else x i +
=
f i ( x i ; θ ) end
if { ˆ Y j } = x L +
Compute Loss: L =
MSE ( Y j , ˆ Y j )
Update Parameters: θ ← Adam ( L , θ ) end for ( µ, σ ) ← NOVAS Layer ( µ, σ, α, S, M, N, (cid:15), F )
Generate M samples of x m ∼ N ( µ, σ 2 ) , m = 1 , . .
, M ; for m = 1 to M (vectorized operation) do
Evaluate F m = F ( x m ) for maximization or F m = − F ( x m ) for minimization;
Normalize F m = (cid:0) F m − min m ( F m ) (cid:1) / (cid:0) max m ( F m ) − min m ( F m ) (cid:1) ;
Apply shape function S m = S ( F m ) ;
Normalize S m = S m / (cid:80)
Mm =1 S m ; end for
[Equation] graph.
This amounts essentially to getting a good initial guess solution and performing a single step optimization. The latter is enough to supply gradient information during back-prop as it relates to the relevant, optimized value x ∗ , rather than the intermediate steps forming the trajectory from its initial guess to its ﬁnal optimal value.
From a coding perspective, most automatic differentiation packages allow for localized deactivation of gradient information ﬂow; in PyTorch (Paszke et al., 2019), this is as simple as adding a “ with torch.no grad(): ” for the n − 1 ﬁrst iterations.
With regards to the proposed Alg. 1, we would like to mention following: A.
The forward pass of the given neural network containing the NOVAS module is a nested operation of layer transformations f i given by Y j = f L ( f L − 1 ( f L − 2 ( . . .
f 1 ( X j ) . . . ))) , wherein f i can be either a NOVAS layer or any standard neural network layer.
Also, note that the above transformation applies to recurrent layers with the forward pass unrolled wherein each f i corresponds to a time step.
B. For clarity of presentation, we outline the forward and backward (i.e. backprop) passes for a single sampled mini-batch from the training dataset.
The user is free to choose a training strategy that best suits the problem and apply the proposed algorithm to every sampled mini-batch with any variant of stochastic gradient descent for the outer loop.
C. The “Normalize F ” operation in NOVAS layer is optional, but may lead to some numerical improvements.
Further algorithm implementation details are given in the Appendix.
Finally, an important remark is necessary concerning the differentiability of the module.
Nonconvex optimization problems do not necessarily have a unique optimum, and as a result, the arg min operator is a set-valued map and not differentiable in the classical sense; even when the optimum is unique almost everywhere in the parameter space it is possible for the optimal value to be discontinuous in the parameter.
For non-global optimizers, an initialization that avoids wrong local optima is crucial.
With respect to the latter, there is some evidence (see, e.g., Bharadhwaj et al.
that sampling-based optimization methods are more robust compared to gradient descent as they evaluate the objective function over an extended area of the input space and, given enough sampling variability for exploration, have thus more chances of escaping a narrow local optimum.
A PPLICATIONS
In this section we explore the properties of NOVAS and test its applicability in a few problems involving end-to-end learning.
The ﬁrst task is a Structured Prediction Energy Network (SPEN) learning task, which we adopted directly from Amos & Yarats (2019).
We found it to be an ideal environment to test NOVAS against unrolled DCEM and unrolled gradient descent because it is simple, allows for fast training, and, being two-dimensional, one can visualize the results.
We would like to stress that this is merely an example for illustrating various algorithm differences and behavior rather than a claim on state-of-the-art results in the domain of SPENs.
We then address two optimal control problems by incorporating the NOVAS module in a deep FBSDE neural network architecture as shown in Fig.
3: the ﬁrst problem is the cart-pole swing-up task, a low-dimensional problem that has been successfully addressed with already existing deep FBSDE approaches (Pereira et al., 2019b) that exploit the structure of dynamics and cost (dynamics are afﬁne in control and the cost is quadratic in the control) in order to perform minimization of the Hamiltonian explicitly.
This problem merely serves as a means to validate the NOVAS-FBSDE algorithm.
The second problem demonstrates the establishment of a new state-of-the-art in solving high-dimensional HJB PDEs using the deep FBSDE method; speciﬁcally, we address a continuous-time portfolio optimization problem that leads to a general (i.e., without an explicit solution for the min operator)
HJB PDE in 101 dimensions.
This HJB PDE form could not be addressed by deep FBSDE methods previously.
4. S TRUCTURED PREDICTION ENERGY NETWORKS
The goal in energy-based learning is to estimate a conditional probability P ( y | x ) of an output y ∈ Y given an input x ∈ X using a parameterized energy function E ( x, y ; θ ) :
X × Y × Θ → R , wherein θ ∈ Θ are the energy function’s trainable parameters.
The conditional probability is approximated as P ( y | x ) ∝ exp( − E ( y ; x, θ )) .
Predictions can be made by minimizing the trained energy function with respect to y :
[Equation]
Initially studied in the context of linear energy functions (Taskar et al., 2005; LeCun et al., 2006), the ﬁeld recently adopted deep neural networks called structured prediction energy networks (SPENs)
(Belanger & McCallum, 2016) to increase the complexity of learned energy functions.
In particular,
Belanger et al.
(2017) suggested training SPENs in a supervised manner; unrolled gradient descent is used to obtain ˆ y which then compared to the ground-truth y ∗ by a suitable loss function.
Mimicking the unrolled gradient descent suggested by Belanger et al.
Amos & Yarats (2019) replaced the gradient descent operations with differentiable cross entropy iterations, also using an unrolled computation graph during backpropagation.
Here we adopt the same example as in Amos & Yarats (2019) to benchmark NOVAS against unrolled gradient descent and unrolled DCEM, compare their properties, and further show that unrolling the inner-loop graph is not necessary.
We consider the simple regression task where ground-truth data are generated from f ( x ) = x sin( x ) , x ∈ [0 , 2 π ] , and we use a neural network of 4 hidden layers to approximate E .
This problem belongs to the class of problems described by eq.
(1) in the introduction: the variable of optimization, y , is not an input to the optimization module from the exterior part of the network.
The energy function represented by the multi-layer neural network deﬁnes the objective function within the module (that is, it corresponds to F ( · ; x i , θ ) of eq.
While in this case the entire network is within the module, the input could instead be features extracted from an anterior part of the network, e.g. through convolution.
The results are shown in Figs.
1 and 2.
As can be seen from Fig.
2(a), unrolled gradient descent converges to a very low loss value (which implies good regression performance), but the trained energy function does not reﬂect the ground-truth relationship, Fig. 1(a).
This implies a “faulty” inner-loop optimization, which the energy network itself learns to compensate for.
The result resembles more ordinary regression than energy-based structured prediction, since no useful
[Figure]
structure is learned; furthermore, changing the inner-loop optimization parameters during inference (after training) leads to an operation that the energy network has not learned to compensate for, as seen in Fig. 2(c).
The sampling-based methods of unrolled DCEM and NOVAS both alleviate this phenomenon by learning the correct energy landscape.
Furthermore, as seen in Fig. 1(b) and (c), unrolling the graph is unnecessary and avoiding it leads to a signiﬁcant speed-up, 5x with respect to unrolled DCEM, Fig. 2(b).
Interestingly, an additional beneﬁt is that NOVAS seems to offer a greater inner-loop convergence rate than DCEM (Fig. 2(c)).
Due to the simplicity of this example, there is no learning inhibition when using an unrolled graph, as seen from the comparison between
NOVAS and unrolled NOVAS.
However, this can be the case in more complex tasks and network architectures, as we shall see in Section 4.2.
Further details are given in the Appendix.
4. C ONTROL USING FBSDE S 4.2. C ART - POLE SWING - UP TASK
We ﬁrst validate the NOVAS-FBSDE algorithm (neural network architecture seen in Fig. 3) by solving a task whose special structure (dynamics afﬁne in control and cost function quadratic in control) allows for a closed-form solution for the min operator of the Hamiltonian.
Because of this special structure, this task can be solved by already existing deep FBSDE approaches (e.g., Pereira et al. (2019b)).
Here, we replace the minimization explicit solution with NOVAS.
The results are shown in Fig. 4, and are in accordance with results obtained using explicit minimization (see Fig.in Pereira et al. (2019b)).
Equations and implementation details are given in the Appendix.
𝒙𝑽 𝒙 , 𝑽Δ𝒘ψ Δ𝒘. . . . . .
ℒ(𝑽 𝑵 ,𝑽 𝑵∗ ,𝑽 𝒙,𝑵 ,𝑽 𝒙,𝑵∗ , 𝑽 𝒙𝒙,𝑵 ,𝑽 𝒙𝒙,𝑵 ∗ ) 𝑽 𝒙,𝑵∗ 𝑽 𝑵∗
LSTM Layer
LSTM Layer
DENSE Linear 𝒉 𝟎𝟏 ,𝒄𝒉 𝟎𝟐 ,𝒄ζ 𝑽. . . . . .
𝑽 𝒙𝒙 , 𝒙𝑽 𝒙 ,
LSTM Layer
LSTM Layer
DENSE Linear 𝑽 𝒙𝒙 , 𝑽 N𝒙 N𝑽 𝒙 ,NLSTM Layer
LSTM Layer
DENSE Linear 𝑽 𝒙𝒙 ,NΔ𝒘 N- [Figure] Δ𝒘 N𝑽 N 𝒙 N 𝑽 𝒙 ,N
LSTM [Figure]
LSTM
[Figure]
Linear 𝑽 𝒙𝒙 ,N Δ𝒘 N- [Figure] 4.2. H IGH - DIMENSIONAL , CONTINUOUS - TIME PORTFOLIO SELECTION
We now demonstrate that augmenting the deep FBSDE method with NOVAS allows us to solve general, high-dimensional HJB PDEs by employing NOVAS-FBSDE on a stock portfolio optimization problem, deﬁned as follows: we consider a market index I that consists of N = 100 stocks, and select a subset of M = 20 of those for trading.
There is also a risk-less asset with (relatively low) return rate.
We may invest an initial wealth capital W among these 20 + 1 assets, and the goal is to control the percentage allocation among these assets over time such that the wealth outperforms the market index in probability .
This optimal control formulation leads to a HJB PDE on a state space of 100 + 1 dimensions ( 100 stocks of the market plus the wealth process, which incorporates the risk-less asset dynamics.
Volatility clearly dominates in such short-term horizons, so a successful trading strategy would be one that increases the odds of beating the market average compared to a random selection.
Index-tracking and wealth-maximization have long been the subject of study from a controls perspective (Primbs, 2007;
Bae et al., 2020), though with limited results due to the difﬁculty in dealing with such high uncertainties.
Primbs (2007) investigates a low-dimensional variant of this problem (5 stocks, 3 traded) but does not enforce the constraint that allocation can only be positive (thus leading to negative investments, i.e. borrowing money from stocks), and tracks the index (thus paying a penalty also when the portfolio outperforms the index) due to the approach being restricted to consider only quadratic cost functions.
We avoid these and enforce positive investments only by applying a softmax on the control input, and use (cid:0) softplus
( I − W ) (cid:1) 2 as cost function to incentivize outperforming rather than tracking the index.
We consider two alternative investment strategies as baselines: a constant and equal allocation among all traded assets, as well as random allocations.
The results are shown in Fig.
As indicated by the violin plots, the FBSDE investment strategy outperforms in probability the two alternative strategies, and is the only one who [Figure] outperforms the market index (by almost 5% on average) at the end of the planning horizon of one year.
These statistics are obtained by running 128 market realizations with test set volatility proﬁles (noise proﬁles not seen during training or validation).
All equations and implementation details are provided in the Appendix.
We note that solving this problem in an unrolled graph setting was not possible : either because it was impossible to facilitate learning when a high number of inner-loop iterations was applied (presumably due to the excessive total graph depth), or because of memory issues.
Thus, eliminating the unrolled graph is absolutely critical in this case.
C ONCLUSIONS
In this paper we presented NOVAS, an optimization module for differentiable, non-convex innerloop optimization that can be incorporated in end-to-end learning architectures involving nested optimizations.
We demonstrated its advantages over alternative algorithms such as unrolled gradient decent and DCEM on a SPEN benchmark.
We also showed that NOVAS allows us to expand the class of PDEs that can be addressed by the deep FBSDE method while resisting the curse of dimensionality, as demonstrated by the solution of a 101-dimensional HJB PDE associated with a portfolio optimization problem.
NOVAS is a general purpose differentiable non-convex optimization approach and thus, owing to its broad description and its generality, could be useful in a plethora of other applications involving nested optimization operations.
We hope that the results of this work will inspire continued investigation. A CKNOWLEDGMENTS
This research was supported by AWS Machine Learning Research Awards and NASA Langley.
We would also like to thank Brandon Amos for sharing his code for the example of Section 4.1 with us, which allowed us to reproduce his results and benchmark all algorithms.
A A PPENDIX A. NOVAS: D ERIVATION AND I MPLEMENTATION D ETAILS
Given the optimization problem deﬁned in (3) we calculate the gradient with respect to the sampling distribution parameter ρ
[Equation]
where the second equality is obtained using the log trick.
The exponential family distribution is characterized by the probability distribution function
[Equation]
where h ( x ) is the base measure whose formula depends on the particular choice of distribution, T ( x ) is the vector of sufﬁcient statistics and A ( ρ )
=
ln { (cid:82) h ( x )
exp( ρ T T ( x ))
d x } is the log partition.
The gradient with respect to log distribution can then be calculated as
[Equation]
A Gaussian N ( µ, Σ) is fully deﬁned by its mean and covariance, but one can choose to optimize (3) only over the mean µ , and sample using a ﬁxed covariance.
This results in the following parameters of the distribution:
[Equation]
and for ρ = µ the gradient can be calculated as
[Equation]
One reason for choosing to optimize over the mean only is the simplicity of the resulting update expression, as well as numerical reasons, since applying gradient descent on the covariance matrix can lead to non-positive deﬁniteness if the initial values or the learning rate are not chosen carefully.
An intermediate solution between using a ﬁxed covariance matrix and its gradient descent-based update law is assuming a diagonal covariance matrix and calculating each element of the diagonal via a simple weighted empirical estimator.
The resulting update scheme is given in Alg.
Note that we also investigated using the full gradient descent-based update rule for the covariance, as well as the use of the Hessian of the objective function (3) and other techniques like momentum, line search, trainable optimization hyper-parameter values etc. to speed up convergence, but the results were inconclusive as to their additional beneﬁt.
We tested two different shape functions: S ( y ; κ ) = exp( κy ) , as well as a shape function suggested by Zhou & Hu (2014), namely S ( y ; κ, γ ) =
( y − y min ) / (cid:0) 1 + exp( − κ ( y − γ )) (cid:1) , where y min is the minimum of the sampled values and γ is the n -th biggest value of the assorted y values.
For the ﬁrst choice it is numerically advantageous to include the normalization step in the function deﬁnition and replace the exponential with the softmax function.
The latter choice is a differentiable function approximating the level/indicator function used in CEM.
Though both shape functions exhibited similar performance, we noticed that the former was slightly faster, and the latter lead to slightly more accurate results in the SPEN example (but not in the FBSDE example, where they were equivalent).
All parameter values such as κ can be made trainable parameters of the network, though we did not notice an improvement in doing so.
In fact, the algorithm seems to be quite insensitive to its parameter values including the learning rate α , with the sole exception of σ which does indeed affect its output signiﬁcantly.
A. S TOCHASTIC O PTIMAL C ONTROL USING FBSDE S
In this section we introduce the deep FBSDE framework for solving PDEs and show that combining NOVAS with the deep FBSDE allows us to extend the capabilities of the latter framework
(Pereira et al., 2019b;a; Wang et al., 2019) in addressing Stochastic Optimal Control (SOC) problems.
The mathematical formulation of a SOC problem leads to a nonlinear PDE, the HamiltonJacobi-Bellman PDE.
This motivates algorithmic development for stochastic control that combine elements of PDE theory with deep learning.
Recent encouraging results (Han et al., 2018; Raissi, 2018) in solving nonlinear PDEs within the deep learning community illustrate the scalability and numerical efﬁciency of neural networks.
The transition from a PDE formulation to a trainable neural network is done via the concept of a system of Forward-Backward Stochastic Differential Equations (FBSDEs).
Speciﬁcally, certain PDE solutions are linked to solutions of FBSDEs, which are the stochastic equivalent of a two-point boundary value problem and can be solved using a suitably deﬁned neural network architecture.
This is known in the literature as the deep FBSDE approach.
In what follows, we will ﬁrst deﬁne the SOC problem and present the corresponding HJB PDE, as well as its associated system of FBSDEs.
The FBSDEs are then discretized over time and solved on a neural network graph.
Consider a SOC problem with the goal of minimizing an expected cost functional subject to dynamics:
[Equation]
where x ∈ R n and u ∈ R m are the state and control vectors respectively, f : R n × R m → R n is a non-linear vector-valued drift function, Σ : R n × R m → R n × v is the diffusion matrix, w ∈ R v is vector of mutually independent Brownian motions, U is the set of all admissible controls and l : R n × R m → R and φ : R n → R are the running and terminal cost functions respectively.
Equation (13) is a controlled It
ˆ o drift-diffusion stochastic process.
Through the value function deﬁnition V (cid:0) x, t (cid:1) =
inf u ∈U [0 ,T ] J (cid:0) u ) | x 0 = x,t 0 = t and using Bellman’s principle of optimality, one can derive the Hamilton Jacobi Bellman PDE, given by
[Equation]
where we drop explicit time dependencies for brevity, and use subscripts to indicate partial derivatives with respect to time and the state vector.
The term inside the inﬁmum operation is called the
Hamiltonian :
[Equation]
Given that a solution u ∗ to the minimization of H exists, the unique solution of (14) corresponds by virtue of the non-linear Feynman-Kac lemma (see for example Pardoux & Peng (1990)) to the following system of FBSDEs:
[Equation]
Here, V ( x ( t ) , t ) denotes an evaluation of V ( x, t ) along a path of x ( t ) , thus V ( x ( t ) , t ) is a stochastic process (and similarly for V x ( x ( t ) , t ) and V xx ( x ( t ) , t ) ).
Note that x ( t ) evolves forward in time (due to its initial condition x (0) = ξ ), whereas V ( x ( t ) , t ) evolves backwards in time, due to its terminal condition φ ( x ( T )) , thus leading to a system that is similar to a two-point boundary value problem.
While we can easily simulate a forward process by sampling noise and then performing
Euler integration, a simple backward integration of V ( x ( t ) , t ) would result in it depending explicitly on future values of noise, which is not desirable for a non-anticipating process, i.e., a process that does not exploit knowledge on future noise values.
Two remedies exist to mitigate this problem: either back-propagate the conditional expectation of V ( x ( t ) , t ) (e.g., as in Exarchos & Theodorou (2018)), or forward-propagate V ( x ( t ) , t ) starting from an initial condition guess, compare its terminal value V ( x ( T ) , T ) to the terminal condition, and adjust the initial condition accordingly so that the terminal condition is satisﬁed approximately.
For this forward evolution of the BSDE, the above system is discretized in time as follows:
[Equation]
Here, ∆ w k is drawn from N (0 , ∆ t ) and H is given by eq.
Note that for every sampled trajectory { x k } Kk =1 there is a corresponding trajectory { V k } Kk =1 .
Under the deep FBSDE controller framework, V 0 = ψ and V x, 0 are set to be trainable parameters of a deep neural network that approximates V x (cid:0) x
( t ) , t (cid:1) at every time step under forward-propagation, using an LSTM 3 .
The terminal value of the propagated V (cid:0) x ( t ) , t (cid:1) , namely V ( x ( T ) , T ) , is then compared to φ (cid:0) x
( T ) (cid:1) to compute a loss function to train the network.
Note that since the Hamiltonian can have any arbitrary non-linear dependence on the control, the resulting minimization problem (21) is generally non-covex and does not have a closed-form solution.
Furthermore, it must be solved for each time step, and for utilization within the deep FBSDE controller framework, the non-convex optimizer must be differentiable to facilitate end-to-end learning.
This makes NOVAS a good ﬁt.
The neural network architecture is shown in Fig.
Since the non-convex Hamiltonian minimization procedure is performed at every time step leading to a repeated use of NOVAS in the architecture, the ability to avoid unrolling the inner-loop computation graph is crucial.
A. FBSDE STOCHASTIC OPTIMAL CONTROL FOR AFFINE - QUADRATIC SYSTEMS
We now show how the previous state-of-the-art (Exarchos & Theodorou, 2018; Pereira et al., 2019b) deals with the problem of the Hamiltonian min operator by assuming a special structure of the problem.
Speciﬁcally, they restrict the dynamics of eq.
(13) to be afﬁne in control, i.e., of the form f ( x, u ) =
F ( x ) + G ( x ) u , and the cost in eq.
(12) to be quadratic in control, i.e., l ( x, u ) =
q ( x )+ u T Ru .
In this case, and if Σ( x, t ) is not a function of u , one can perform explicit minimization of the Hamiltonian with respect to u in eq.
(21) to ﬁnd the optimal control:
[Equation]
This is done by simply setting ∂ H /∂u = 0 and solving for u .
Substituted back into the HJB PDE, this yields a simpliﬁed expression without a min operator:
[Equation]
Thus, for this restricted class of systems, the deep FBSDE neural neural network architecture does not require a numerical minimization operation over u at every time step, as in eq.
The cart-pole swing-up task of the next section is an example of a system that satisﬁes these restrictions.
A similar closed-form solution exists for some cases of L 1 -optimal control (Exarchos et al., 2018), as well as some differential games (Exarchos et al., 2019).
While simplifying the problem signiﬁcantly, this approach comes with an important caveat: several dynamical systems do not have a control-afﬁne structure, and penalizing control energy ( u T Ru ) is not always meaningful in every setting.
A.3. C ART - POLE SWING - UP PROBLEM
We deﬁne the state vector to be X = (cid:2)
x, θ, ˙ x, ˙ θ (cid:3) T , where x represents the cart-position, θ represents the pendulum angular-position, ˙ x represents the cart-velocity, and ˙ θ represents the pendulum angular-velocity.
Let u ∈ R be the control force applied to the cart.
The deterministic equations of motion for the cart-pole system are,
[Equation]
For our experiments, we consider the case where noise enters the velocity channels of the state.
The stochastic dynamics therefore take the following form,
[Equation]
The task is to perform a swing-up i.e. starting from an initial state of X = (cid:2) 0 , 0 , 0 , 0 (cid:3) T at time t 0 = 0 , reach the target state of X = (cid:2) 0 , π, 0 , 0 (cid:3) T by the end of the time horizon t = T .
We consider T = 1 .
5 s with a time discretization step of ∆ t = 0 .
02 s. Notice that the dynamics are afﬁne in control, and selecting the running cost to be l = u T Ru , minimization of the Hamiltonian with respect to u assumes a closed-form solution, namely that of eq.
This fact allows us to replace the min operator in favor of this solution (Pereira et al., 2019b).
Here, we test NOVAS by avoiding this replacement.
We consider a running and terminal cost matrix of diag( Q ) =
[0 . 0 , 10 . 0 , 3 . 0 , 0 . 5] and the control cost matrix of R = 0 .
The cart-pole parameters considered are m p = 0 .
01 kg, m c
{+= 1 . 
+}
kg, l = 0 .
5 m , which are the mass of the pendulum, mass of cart, and length of the pendulum, respectively.
For the noise standard deviation, ˜ σ = 0 .
5 was used.
As far as the hyper-parameters for learning the deep FBSDE controller are concerned, we used a two-layer LSTM network as shown in Fig. 5(e) with hidden dimension of 16 in each layer, a batch size of 128 , and trained the network using the Adam optimizer for 3500 iterations with a learning rate of 5 e − 3 .
For the NOVAS layer at every time step, we used 5 inner-loop iterations and 100 samples for both training and inference.
A shape function of S = exp( · ) , initial µ = 0 , and initial σ = 10 were used.
With reference to parameters in Alg. 1, for this experiment we used 75 time steps, which means that the LSTM graph can be viewed as a 75 layered feed-forward network when unrolled.
Additionally, at each time step we use a NOVAS Layer to compute the optimal control.
Thus, the total number of network layers is L = 75 + 74 = 149 with f i ’s being NOVAS Layer for i = 2 , 4 , 6 , . . . .
A.3. P ORTFOLIO OPTIMIZATION PROBLEM
We now consider a problem for which an explicit solution of the Hamiltonian min operator does not exist.
Let N be the total number of stocks that make up an index I such that I = 1 N (cid:80)
Ni =1 S i , where
S i is the stock price process of the i -th stock.
Let M be the number of a ﬁxed selection of traded stocks taken from those N stocks such that M < N .
Furthermore, let u ∈ R M +1 be the control vector.
The ( N + 1) dimensional state vector is comprised N stock prices and a wealth process W .
The dynamics of each stock price and wealth process are given by
[Equation]
where, i = 1 , 2 , · · · , N and d η i =
[Equation]
[Equation]
(25) where π k is the fraction of wealth invested in the k -th traded stock, r is rate of return per period of the risk-free asset, µ i is the rate of return of the i th stock.
Here, σ i,j denotes the standard deviation of noise terms entering the i − the stock process wherein i =
j indicates the contribution of the process’ own noise as opposed to i (cid:54) =
j , which indicates the interaction of noises between stocks (correlation).
All w i ’s are mutually independent standard Brownian motions.
To obtain the σ ’s, we used randomly generated synthetic covariance matrices which mimic real stock-market data.
Note that the M traded stocks were randomly picked and were not constrained to be any speciﬁc subselection of the N stocks.
Separate noise realizations were used during training, validation, and testing to ensure that the network does not over-ﬁt to a particular noise proﬁle.
For our experiments we use N = 100 stocks that make up the index I and M = 20 traded stocks.
We used a scaled squared-softplus function as terminal cost, given by
[Equation]
with β = 10 , q = 500 , and no running cost, focusing on investment outperformance at the end of the planning horizon of one year.
To simulate the stock dynamics we used a time discretization of dt = 1 / 52 , which amounts to controls (and thus amounts invested) being applied on a weekly basis, for a total time of 1 year.
The deep FBSDE-NOVAS hyperparameters were as follows: 16 neurons each in a two-layer LSTM network to predict the gradient of the value function at each time step, a batch size of 32, an initial learning rate set to 1 e − 2 and reduced by factor of 0 .
1 after 4000 and 4500 training iterations.
Training was done using the Adam optimizer for a total of 5000 iterations.
For NOVAS, we used 100 samples with 5 inner-loop iterations for training and 200 samples withinner-loop iterations for inference.
The shape function used was S ( x ) =
exp ( x ) .
With reference to parameters in Alg. 1, for this experiment we used 52 time steps, which means that the LSTM graph can be viewed as a 52 layered feed-forward network when unrolled.
Additionally, at each time step (except for the last time step) we use a NOVAS Layer to compute the optimal control.
Thus, the total number of network layers is L = 52 + 51 = 103 with f i ’s being NOVAS Layer for i = 2 , 4 , 6 , . . . .
A.3. L OSS F UNCTION FOR TRAINING D EEP FBSDE C ONTROLLERS
The loss function used in our experiments to train the deep FBSDE controller with the NOVAS layer is as follows:
[Equation]
∗ ( x T , T ) (cid:1) + l 2 · H δ (cid:0) V x ( x T , T ) − V ∗ x ( x T , T ) (cid:1) + l 3 · H δ (cid:0) V xx ( x T , T ) − V ∗ xx
( x T , T ) (cid:1)
+ l 4 · (cid:0) V ∗ ( x T , T ) (cid:1) 2 + l 5 · (cid:0) V ∗ x
( x T , T ) (cid:1) 2 + l 6 · (cid:0) V ∗ xx
( x T , T ) (cid:1) 2 , where
H δ ( a ) =
(cid:26) a 2 , for | a | < δ, δ (2 | a | − δ ) , otherwise.
Here, x T denotes x ( T ) , V ( x T , T ) , V x ( x T , T ) , and V xx ( x T , T ) are the predicted value function, its predicted gradient, and the predicted last column of the Hessian matrix, respectively, at the terminal time step.
The corresponding targets are obtained through the given terminal cost function φ (cid:0) x
( T ) (cid:1) so that V ∗ ( x T , T ) =
φ ( x T ) , V x ( x T , T ) =
φ x ( x T ) and V xx ( x T , T ) =
φ xx ( x T ) .
Each term is computed by averaging across the batch samples.
Additionally, we may choose to add terms that directly minimize the targets.
This is possible because gradients ﬂow through the dynamics functions and therefore the weights of the LSTM can inﬂuence what the terminal state x ( T ) will be.
For the cart-pole problem we used δ = 50 and [ l 1 , l 2 , l 3 , l 4 , l 5 , l 6 ] =
[1 , 1 , 0 , 1 , 1 , 0] , and for the portfolio optimization problem we used δ = 50 and [ l 1 , l 2 , l 3 , l 4 , l 5 , l 6 ] =
A.3. H ARDWARE C ONFIGURATION AND R
- TIMES
All experiments were run on a NVIDIA GeForce RTX 2080Ti graphics card with 12GB memory.
The PyTorch (Paszke et al., 2019) implementation of the 101-dimensional portfolio optimization problem had a run-time of 2.5 hours.