Deep Learning for Macroeconomics

Honours — The University of Edinburgh

This course teaches you to solve dynamic economic models with neural networks. Building on the numerical methods you learned in Programming & Numerical Methods — root-finding, optimisation, function approximation, and value-function iteration — we introduce deep learning as a powerful new tool for problems that defeat traditional methods: high-dimensional state spaces, occasionally binding constraints, and heterogeneous agents. The approach follows Simon Scheidegger’s open-source framework, adapted for Honours undergraduates. Edinburgh students should check Learn for assessed coursework and announcements.

Prerequisites

You should have completed Programming & Numerical Methods (ECNM10115) or equivalent. Specifically, you need:

  • Comfortable programming in Python (NumPy, Matplotlib)
  • Familiarity with function approximation (polynomial, spline, Chebyshev)
  • Experience with value-function iteration (the neoclassical growth model)
  • Basic optimisation (gradient descent, Newton’s method)

No prior deep learning experience is required — we build everything from the ground up.

How to use these materials

Each week has a notebook you can read online, download, or run in the cloud, plus a slide deck for the lecture:

  • Read online — click the notebook link; it renders as a webpage with all code and output.
  • Run in Google Colab — click the Colab badge and the notebook opens ready to run, with GPU access. Nothing to install.
  • Run locally — install Anaconda, then pip install torch matplotlib scikit-learn. Download the .ipynb file and open it in Jupyter.

Note on compute: most notebooks run fine on a laptop CPU. Weeks marked with ⚡ benefit from a GPU — use Colab’s free GPU runtime (Runtime → Change runtime type → T4 GPU).

Materials

Week Topic Notebook Slides Problem Set Colab
1 From Numerical Methods to Neural Networks View · Download PDF PS1 Open in Colab
2 Deep Learning Fundamentals View · Download PDF PS2 Open in Colab
3 Automatic Differentiation for Economics View · Download PDF PS3 Open in Colab
4 Deep Equilibrium Networks I — The Idea View · Download PDF PS4 Open in Colab
5 Deep Equilibrium Networks II — Stochastic Models ⚡ View · Download PDF PS5 Open in Colab
6 Constraints and Real-World Models ⚡ View · Download PDF PS6 Open in Colab
7 Physics-Informed Neural Networks ⚡ View · Download PDF PS7 Open in Colab
8 Heterogeneous Agents ⚡ View · Download PDF PS8 Open in Colab
9 Surrogates, Estimation, and Climate Economics View · Download PDF PS9 Open in Colab
10 Frontiers and Course Synthesis View · Download PDF Open in Colab

Notebooks include interactive exercises with hidden solutions — try first, then click to check.

Syllabus

  1. From Numerical Methods to Neural Networks — why traditional methods struggle with high-dimensional models; neural networks as universal function approximators; your first network in PyTorch
  2. Deep Learning Fundamentals — gradient descent, backpropagation, MLPs, activation functions, training loops, overfitting, regularisation
  3. Automatic Differentiation for Economics — forward vs reverse mode; PyTorch autograd; computing Jacobians and Hessians of economic models; why this matters for equilibrium conditions
  4. Deep Equilibrium Networks I — from VFI to neural-network solutions; the DEQN principle (minimise equilibrium residuals); deterministic Brock–Mirman growth model with closed-form verification
  5. Deep Equilibrium Networks II — adding uncertainty; Gauss–Hermite quadrature for expectations; stochastic Brock–Mirman; loss-function design (MSE, Huber, log-cosh)
  6. Constraints and Real-World Models — borrowing constraints via Fischer–Burmeister complementarity; consumption–savings with an occasionally binding constraint; architecture search basics
  7. Physics-Informed Neural Networks — continuous-time economics; the PINN principle (ODE/PDE residual minimisation); cake-eating as an HJB equation; soft vs hard boundary conditions
  8. Heterogeneous Agents — the curse of dimensionality in HA models; Young’s histogram method; Krusell–Smith with DEQNs; deep learning’s comparative advantage
  9. Surrogates, Estimation, and Climate Economics — Gaussian-process surrogates; simulated method of moments; the DICE integrated assessment model
  10. Frontiers and Course Synthesis — sequence-space methods, continuous-time HA, decision guide for when to use deep learning vs traditional approaches

How this course relates to PNM

PNM (Weeks 5–8) This course
Root-finding (bisection, Newton) Equilibrium conditions as loss functions
Optimisation (BFGS, Nelder–Mead) Gradient descent, Adam, learning-rate schedules
Function approximation (polynomials, splines, Chebyshev) Neural networks as universal approximators
Value-function iteration Deep Equilibrium Networks (DEQNs)
Grid-based methods Grid-free neural-network solutions

The key shift: in PNM you approximated value or policy functions on a grid. Here, you parameterise them as neural networks — which scales to problems with 10, 50, or 500 state variables where grids are infeasible.

References

Primary

  • Scheidegger, S. (2025). Deep Learning for Solving and Estimating Dynamic Economic Models — open-source course; our main reference and the source of many exercises.
  • Azinovic, M., Gaegauf, L., & Scheidegger, S. (2022). “Deep Equilibrium Nets.” International Economic Review, 63(4), 1471–1525.
  • Fernández-Villaverde, J., Hurtado, S., & Nuño, G. (2023). “Financial Frictions and the Wealth Distribution.” Econometrica, 91(4), 1251–1293.

Supplementary

  • QuantEcon — Sargent & Stachurski, especially the neural-network lectures
  • Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning — for the machine-learning foundations (Chapters 6–8)
  • Judd, K. (1998). Numerical Methods in Economics — bridges to PNM content

Questions

Found an error in a notebook, or stuck on setup? Email juan.zurita@ed.ac.uk — see For Students for how to get a fast answer.