The Deep_Learning_for_Stoch_Opt_Control.ipynb
notebook in the Financial_frictions
folder shows how to apply deep neural networks (DNNs) to solve stochastic optimal control problems arising from economic models of financial frictions. Solving such models boils down to finding approximations of high dimensional non-linear PDEs (more commonly referred to as Hamilton-Jacobi-Bellman equations (HJBEs) in the field of stochastic optimal control). In the notebook, these approximations are obtained using deep neural networks. More precisely, the Deep_Learning_for_Stoch_Opt_Control.ipynb
notebook illustrates how to solve a 3 dimensional model of financial frictions where the HJBEs (alternatively PDEs) for two types of agents, households indexed by
and
An additional complication is posed by the approximation of an ODE embedded in a
Its solution is also estimated with a deep neural network.
The notebook provides further explanations, derivations, code implementation and a comparison with a solution based on finite difference methods.
- The main result showcased in the notebook is that DNNs approximate the solutions of the two high-dimensional non-linear PDEs (HJBEs) and the ODE above with overall the same level of accuracy as finite difference methods (FDMs) but DNNs are significantly faster: for the economy paremtrized in the notebook computational time for DNN approximations is 10 minutes and 42 seconds vs 3 hours and 42 minutes for FDMs. The DNN approach is thus more than 20 times faster. In general for the 3d case (with idiosyncratic volatility set to 0) finite differences will take anywhere from 1 hour and 30 minutes to 10 or more hours depending on the complexity of the problem (e.g. how many constraints are binding, heterogeneity in the risk aversion, time preference etc of the two types of agents) while the deep neural network (DNN) approach takes on average 10 to 13 minutes. The computational speedup from the NN approach is from ~ x10 to ~ x90.
The easiest/most convenient way to run the code is to download the Financial_frictions
folder into your Google drive and run the Deep_Learning_for_Stoch_Opt_Control.ipynb
notebook on Google Colab
. Alternatively, if you have access to a GPU and TensorFlow
and installed in a virtual environment you can run on your local machine.
To view interactive 3D surface plots of the equilibrium value functions, risk prices, price of capital, interest rates etc. click the Colab notebook link in the top left corner of the Deep_Learning_for_Stoch_Opt_Control.ipynb
notebook.