Letter | Published:

Fast automated analysis of strong gravitational lenses with convolutional neural networks

Nature volume 548, pages 555557 (31 August 2017) | Download Citation


Quantifying image distortions caused by strong gravitational lensing—the formation of multiple images of distant sources due to the deflection of their light by the gravity of intervening structures—and estimating the corresponding matter distribution of these structures (the ‘gravitational lens’) has primarily been performed using maximum likelihood modelling of observations. This procedure is typically time- and resource-consuming, requiring sophisticated lensing codes, several data preparation steps, and finding the maximum likelihood model parameters in a computationally expensive process with downhill optimizers1. Accurate analysis of a single gravitational lens can take up to a few weeks and requires expert knowledge of the physical processes and methods involved. Tens of thousands of new lenses are expected to be discovered with the upcoming generation of ground and space surveys2,3. Here we report the use of deep convolutional neural networks to estimate lensing parameters in an extremely fast and automated way, circumventing the difficulties that are faced by maximum likelihood methods. We also show that the removal of lens light can be made fast and automated using independent component analysis4 of multi-filter imaging data. Our networks can recover the parameters of the ‘singular isothermal ellipsoid’ density profile5, which is commonly used to model strong lensing systems, with an accuracy comparable to the uncertainties of sophisticated models but about ten million times faster: 100 systems in approximately one second on a single graphics processing unit. These networks can provide a way for non-experts to obtain estimates of lensing parameters for large samples of data.

Access optionsAccess options

Rent or Buy article

Get time limited or full article access on ReadCube.


All prices are NET prices.


  1. 1.

    , & A systematic review of strong gravitational lens modeling software. New Astron. Rev. 57, 1–13 (2013)

  2. 2.

    LSST Science Collaborations. LSST Science Book, Version 2.0. Preprint at (2009)

  3. 3.

    The population of galaxy-galaxy strong lenses in forthcoming optical imaging surveys. Astrophys. J. 811, 20 (2015)

  4. 4.

    ., & Independent Component Analysis (Wiley, 2001)

  5. 5.

    , & Isothermal elliptical gravitational lens models. Astron. Astrophys. 284, 285–299 (1994)

  6. 6.

    et al. ImageNet Large Scale Visual Recognition Challenge. Int. J. Comput. Vision 115, 211–252 (2015)

  7. 7.

    et al. Finding strong gravitational lenses in the Kilo Degree Survey with convolutional neural networks. Preprint at (2017)

  8. 8.

    , , , & Finding strong lenses in CFHTLS using convolutional neural networks. Mon. Not. R. Astron. Soc. 471, 167–181 (2017)

  9. 9.

    et al. CMU DeepLens: deep learning for automatic image-based galaxy-galaxy strong lens finding. Preprint at (2017)

  10. 10.

    ., ., ., & Enabling dark energy science with deep generative models of galaxy images. In Proc. 31st AAAI Conf. on Artificial Intelligence 1488–1494 (AAAI, 2017)

  11. 11.

    ., ., & Inception-v4, Inception-ResNet and the impact of residual connections on learning. In Proc. 31st AAAI Conf. on Artificial Intelligence 4278–4284 (AAAI, 2017)

  12. 12.

    , & Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems 25 (eds et al.) 1097–1105 (Curran Associates, 2012)

  13. 13.

    et al. OverFeat: integrated recognition, localization and detection using convolutional networks. Preprint at (2014)

  14. 14.

    et al. Galaxy Zoo: morphological classifications for 120 000 galaxies in HST legacy imaging. Mon. Not. R. Astron. Soc. 464, 4176–4203 (2017)

  15. 15.

    et al. The Third Gravitational Lensing Accuracy Testing (GREAT3) challenge handbook. Astrophys. J. Suppl. Ser. 212, 5 (2014)

  16. 16.

    et al. The Sloan Lens ACS Survey. V. The full ACS strong-lens sample. Astrophys. J. 682, 964–984 (2008)

  17. 17.

    , , , & The SL2S galaxy-scale lens sample. III. Lens models, surface photometry, and stellar masses for the final sample. Astrophys. J. 777, 97 (2013)

  18. 18.

    et al. The SL2S galaxy-scale lens sample. V. Dark matter halos and stellar IMF of massive early-type galaxies out to redshift 0.8. Astrophys. J. 800, 94 (2015)

  19. 19.

    & Semilinear gravitational lens inversion. Astrophys. J. 590, 673–682 (2003)

  20. 20.

    , , & A Bayesian analysis of regularized source inversions in gravitational lensing. Mon. Not. R. Astron. Soc. 371, 983–998 (2006)

  21. 21.

    & Dropout as a Bayesian approximation: representing model uncertainty in deep learning. In Proc. 33rd Int. Conf. on Machine Learning (ICML-16) Vol. 48, 1050–1059 (PMLR, 2016)

  22. 22.

    & Bayesian convolutional neural networks with Bernoulli approximate variational inference. Preprint at (2016)

  23. 23.

    et al. Lens models and magnification maps of the six Hubble Frontier Fields clusters. Astrophys. J. 797, 48 (2014)

  24. 24.

    Approximation by superpositions of a sigmoidal function. Math. Contr. Signals Syst. 2, 303–314 (1989)

  25. 25.

    et al. Unreasonable effectiveness of learning neural networks: from accessible states and robust ensembles to basic algorithmic schemes. Proc. Natl Acad. Sci. USA 113, E7655–E7662 (2016)

Download references


We thank R. Keisler, G. Holder, R. Blandford, R. Wechsler and W. Morningstar for discussions and comments on the manuscript. We also thank G. P. Maher and A. Dwaraknath for comments about neural networks, leading to improved performance. We thank Stanford Research Computing Center and their staff for providing computational resources (Sherlock Cluster) and support. Support for this work was provided by NASA through Hubble Fellowship grant HST-HF2-51358.001-A awarded by the Space Telescope Science Institute, which is operated by the Association of Universities for Research in Astronomy, Inc., for NASA, under contract NAS 5-26555. P.J.M. acknowledges support from the US Department of Energy under contract number DE-AC02-76SF00515. Y.D.H. is a Hubble Fellow.

Author information

Author notes

    • Yashar D. Hezaveh
    •  & Laurence Perreault Levasseur

    These authors contributed equally to this work.


  1. Kavli Institute for Particle Astrophysics and Cosmology, Stanford University, Stanford, California, USA

    • Yashar D. Hezaveh
    • , Laurence Perreault Levasseur
    •  & Philip J. Marshall
  2. SLAC National Accelerator Laboratory, Menlo Park, California, USA

    • Yashar D. Hezaveh
    • , Laurence Perreault Levasseur
    •  & Philip J. Marshall


  1. Search for Yashar D. Hezaveh in:

  2. Search for Laurence Perreault Levasseur in:

  3. Search for Philip J. Marshall in:


Y.D.H. and L.P.L. contributed equally to all aspects of this project, including design and implementation of the networks and the text of the paper. L.P.L. developed the use of ICA for lens removal. P.J.M. contributed to various aspects of this project, including the choice of tensor libraries and tests on real and simulated data.

Competing interests

The authors declare no competing financial interests.

Corresponding authors

Correspondence to Yashar D. Hezaveh or Laurence Perreault Levasseur.

Reviewer Information Nature thanks Y. Gal, A. Sonnenfeld and the other anonymous reviewer(s) for their contribution to the peer review of this work.

Publisher's note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Extended data

About this article

Publication history






Further reading


By submitting a comment you agree to abide by our Terms and Community Guidelines. If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.