fundamentals of deep (artificial) neural networks...

80
Fundamentals of Deep (Artificial) Neural Networks (DNN) Gregory Tsagkatakis CSD – UOC & ICS – FORTH http://users.ics.forth.gr/~greg/

Upload: others

Post on 05-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Fundamentals of Deep (Artificial) Neural Networks (DNN)Gregory Tsagkatakis

CSD – UOC & ICS – FORTH

http://users.ics.forth.gr/~greg /

Page 2: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

The Big Data era

DEEP LEARNING IN ASTRONOMY - INTRODUCTION 2

Page 3: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

The Big Data era in Astronomy

DEEP LEARNING IN ASTRONOMY - INTRODUCTION 3

Sky Survey Project Volume Velocity Variety

Sloan Digital Sky Survey (SDSS) 50 TB 200 GB per day Images, redshifts

Large Synoptic Survey Telescope (LSST )

~ 200 PB 30 TB per day Images, catalogs

Square Kilometer Array (SKA ) ~ 4.6 EB 150 TB per day Images, redshifts

Garofalo, Mauro, Alessio Botta, and Giorgio Ventre. "Astrophysics and Big Data: Challenges, Methods, and Tools." Proceedings of the International Astronomical Union 12.S325 (2016)

Page 4: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Accelerated growth

4DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 5: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Brief history of DL

5DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 6: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Why Today?Lots of Data

6DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 7: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Why Today?Lots of Data

Deeper Learning

7DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 8: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Why Today?Lots of Data

Deep Learning

More Power

https://blogs.nvidia.com/blog/2016/01/12/accelerating-ai-artificial-intelligence-gpus/https://www.slothparadise.com/what-is-cloud-computing/

8DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 9: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Apps: Gaming

9DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 10: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Machine learning is everywhere

DEEP LEARNING IN ASTRONOMY - INTRODUCTION 10

Page 11: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Deep LearningInspiration from brain

86Billion neurons

1014-1015 synapses

DEEP LEARNING IN ASTRONOMY - INTRODUCTION 11

Page 12: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Key components of ANN Architecture (input/hidden/output layers)

12DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 13: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Key components of ANN Architecture (input/hidden/output layers)

Weights

13DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 14: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Key components of ANN Architecture (input/hidden/output layers)

Weights

Activations

14

LINEAR RECTIFIED

LINEAR (ReLU)

LOGISTIC /

SIGMOIDAL / TANH

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 15: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Perceptron: an early attempt

Activation function

Need to tune and

σ

x1

x2

b

w1

w2

1

15DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 16: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Multilayer perceptron

w1

w2

w3

A

B

C

D

E

A neuron is of the form

σ(w.x + b) where σ is

an activation function

We just added a neuron layer!

We just introduced non-linearity!

w1A

w2B

w1D

wAE

wDE

16DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 17: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

17

Sasen Cain (@spectralradius)

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 18: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Training & TestingTraining: determine weights◦ Supervised: labeled training examples

◦ Unsupervised: no labels available

◦ Reinforcement: examples associated with rewards

Testing (Inference): apply weights to new examples

18DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 19: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Training DNN1. Get batch of data

2. Forward through the network -> estimate loss

3. Backpropagate error

4. Update weights based on gradient

Errors

19DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 20: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

BackpropagationChain Rule in Gradient Descent: Invented in 1969 by Bryson and Ho

Defining a loss/cost function

Assume a function

and associated predictions

Examples of Loss function

•Hinge

•Exponential

•Logistic

20DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 21: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Gradient DescentMinimize function J w.r.t. parameters θ

Gradient

Stochastic Gradient Descend

21

New weights Gradient

Old weights Learning rate

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 22: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Backpropagation

22

Chain Rule:

Given:

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 23: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Backpropagation

Chain rule:

◦ Single variable

◦ Multiple variables

23

g fxy=g(x)

z=f(y)=f(g(x))

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 24: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

https://google-developers.appspot.com/machine-learning/crash-course/backprop-scroll/

24DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 25: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Optimization algorithms

25DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 26: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Visualization

26DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 27: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Training Characteristics

27

Under-fitting

Over-fitting

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 28: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Supervised Learning

28DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 29: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Supervised Learning

Exploiting prior knowledge

Expert users

Crowdsourcing

Other instruments

Spiral

Elliptical

?

29

ModelPrediction

Data Labels

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 30: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

State-of-the-art (before Deep Learning)Support Vector Machines Binary classification

30DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 31: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

State-of-the-art (before Deep Learning)Support Vector Machines Binary classification

Kernels <-> non-linearities

31DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 32: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

State-of-the-art (before Deep Learning)Support Vector Machines Binary classification

Kernels <-> non-linearities

Random Forests Multi-class classification

32DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 33: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

State-of-the-art (before Deep Learning)Support Vector Machines Binary classification

Kernels <-> non-linearities

Random Forests Multi-class classification

Markov Chains/Fields Temporal data

33DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 34: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

State-of-the-art (since 2015)Deep Learning (DL)

Convolutional Neural Networks (CNN) <-> Images

Recurrent Neural Networks (RNN) <-> Audio

34DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 35: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Convolutional Neural Networks

(Convolution + Subsampling) + () … + Fully Connected

35DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 36: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Convolution operator

36DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 37: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Convolutional Layers

channels

hei

ght

32x32x1 Image

5x5x1 filter

hei

ght

28x28xK activation map

K filters

37DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 38: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Convolutional LayersCharacteristics

Hierarchical features

Location invariance

Parameters

Number of filters (32,64…)

Filter size (3x3, 5x5)

Stride (1)

Padding (2,4)

“Machine Learning and AI for Brain Simulations” –Andrew Ng Talk, UCLA, 2012

38DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 39: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Activation LayerIntroduction of non-linearity◦ Brain: thresholding -> spike trains

39DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 40: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Activation LayerReLU: x=max(0,x)

Simplifies backprop

Makes learning faster

Avoids saturation issues

~ non-negativity constraint

(Note: The brain)

No saturated gradients

40DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 41: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Subsampling (pooling) Layers

41

<-> downsampling

Scale invariance

Parameters

• Type

• Filter Size

• Stride

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 42: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Fully Connected LayersFull connections to all activations in previous layer

Typically at the end

Can be replaced by conv

42

Feat

ure

s

Cla

sses

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 43: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

LeNet [1998]

43DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 44: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

AlexNet [2012]

Alex Krizhevsky, Ilya Sutskever and Geoff Hinton, ImageNet ILSVRC challenge in 2012http://vision03.csail.mit.edu/cnn_art/data/single_layer.png

44DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 45: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

K. Simonyan, A. Zisserman Very Deep Convolutional Networks for Large-Scale Image Recognition, arXiv technical report, 2014

VGGnet [2014]

45DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 46: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

VGGnet

D: VGG16E: VGG19All filters are 3x3

More layers smaller filters

46DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 47: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Inception (GoogLeNet, 2014)

Inception moduleInception module with dimensionality reduction

47DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 48: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Residuals

48DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 49: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

ResNet, 2015

49

He, Kaiming, et al. "Deep residual learning for image recognition." IEEE CVPR. 2016.

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 50: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Dropout

50

Srivastava, Nitish, et al. "Dropout: a simple way to prevent neural networks from overfitting." Journal of machine learning research15.1 (2014): 1929-1958.

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 51: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Batch Normalization

Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift [Ioffe and Szegedy 2015] 51DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 52: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Transfer LearningLayer 1 Layer 2 Layer L

1x

2x

……

……

……

……

……

elephant

……Nx

Pixels

……

……

……

DEEP LEARNING IN ASTRONOMY - INTRODUCTION 52

Page 53: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Transfer Learning

53

Layer 1 Layer 2 Layer L

1x

2x

……

……

……

……

……

elephant

……Nx

Pixels

……

……

……

Layer 1 Layer 2 Layer L

1x

2x

……

……

……

……

Healthy

Malignancy

Nx

Pixels

……

……

……

DEEP LEARNING IN ASTRONOMY - INTRODUCTION

Page 54: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Layer Transfer - Image

Jason Yosinski, Jeff Clune, Yoshua Bengio, Hod Lipson, “How transferable are features in deep neural networks?”, NIPS, 2014

Only train the rest layers

fine-tune the whole network

Source: 500 classes from ImageNet

Target: another 500 classes from ImageNet

DEEP LEARNING IN ASTRONOMY - INTRODUCTION 54

Page 55: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Deep Learning Applications in Astronomy

Gregory Tsagkatakis

CSD – UOC & ICS – FORTH

http://users.ics.forth.gr/~greg /

Page 56: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

DL for galaxy morphologyRecovery of galaxy parameters for HST images

Simulation of 31K galaxies (24K training), H band PSF, CANDELS survey noise

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 56

Tuccillo, D., Etienne Decencìère, and Santiago Velasco-Forero. "Deep learning for studies of galaxy morphology." Proceedings of the International Astronomical Union 12.S325 (2016): 191-196.

Page 57: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

DL for of galaxy morphology (con’t)

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 57

GALFIT CNN

Page 58: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

CNN: Star-galaxy Classification

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 58

Kim, Edward J., and Robert J. Brunner. "Star-galaxy classification using deep convolutional neural networks." Monthly Notices of the Royal Astronomical Society (2016): stw2672.

Page 59: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 59

Star

Gal

axy

Page 60: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Gravitational Lensing

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 60

Page 61: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

CNN for lensing CNNs in Kilo Degree Survey

21789 colour-magnitude selected Luminous Red Galaxies, of which 3 are known lenses, the CNN retrieves 761 strong-lens candidates and correctly classifies 2/3 of known lenses.

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 61

Petrillo, C. E., C. Tortora, S. Chatterjee, G. Vernardos, et al. "Finding strong gravitational lenses in the Kilo Degree Survey with convolutional neural networks." Monthly Notices of the Royal Astronomical Society 472, no. 1 (2017)

Page 62: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

DeepLens Training

20,000 LSST-like observations

Testingfor a rejection rate of non-lenses of 99%, a completeness of 90% can be achieved for lenses with Einstein radii larger than 1.400 and S/N larger than 20 on individual g-band LSST exposures.

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 62

Lanusse, Francois, et al. "CMU DeepLens: Deep Learning For Automatic Image-based Galaxy-Galaxy Strong Lens Finding." arXiv preprint arXiv:1703.02642 (2017).

Page 63: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Detecting strong lensingStrong galaxy-galaxy lensing systems

CA-FR-HA Telescope Legacy Survey (CFHTLS)

Ensemble of trained DL networks

Search of 1.4 million early type galaxies selected from the survey catalog as potential deflectors,

Identified 2,465 candidates (117 previously known lens candidates, 29 confirmed lenses, 266 novel probable or potential lenses and 2097 false positives.

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 63

Jacobs, Colin, et al. "Finding strong lenses in CFHTLS using convolutional neural networks." Monthly Notices of the Royal Astronomical Society 471.1 (2017)

Page 64: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Fast Strong Gravitational Lenses analysis

Typical ML approaches: single lens → few weeks & experts

Estimation of lensing parameters via CNN• Singular Isothermal Ellipsoid density profile

• Parameters: Einstein radius, complex ellipticity, the coordinates of the lens center

Lens removal through ICA

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 64

Hezaveh, Yashar D., Laurence Perreault Levasseur, and Philip J. Marshall. "Fast automated analysis of strong gravitational lenses with convolutional neural networks." Nature 548.7669 (2017)

Page 65: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Exoplanet detectionThe ideal algorithm should be

fast

robust to noise

capable of learning and abstracting highly non-linear systems.

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 65

Pearson, Kyle A., Leon Palafox, and Caitlin A. Griffith. "Searching for exoplanets using artificial intelligence." Monthly Notices of the Royal Astronomical Society 474.1 (2017): 478-491.

Page 66: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Exoplanet detection

66DEEP LEARNING IN ASTRONOMY - APPLICATIONS

Page 67: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Exoplanet detection

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67

Pearson, Kyle A., Leon Palafox, and Caitlin A. Griffith. "Searching for exoplanets using artificial intelligence." Monthly Notices of the Royal Astronomical Society 474.1 (2017): 478-491.

Page 68: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Quasar micro-lensing light curves Use CNN to model quasar microlensing light curves and extract the size and temperature profile of the accretion disc.

68DEEP LEARNING IN ASTRONOMY - APPLICATIONS

G. Vernardos and G. Tsagkatakis "Quasar microlensing light curve analysis using deep machine learning", Monthly Notices of the Royal Astronomical Society, Vol. 486 (2), pp. 1944–1952, June 2019,

Page 69: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Other applications Classifying Radio Galaxies With Convolutional Neural Network1

Deep-HITS: Rotation Invariant Convolutional Neural Network For Transient Detection2

Galaxy surface brightness profile3

Gravitational wave detection4

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 69

1. Aniyan AK, Thorat K. Classifying Radio Galaxies with the Convolutional Neural Network. The Astrophysical Journal Supplement Series. 2017 Jun 13

2. Cabrera-Vives G, Reyes I, Förster F, Estévez PA, Maureira JC. Deep-HiTS: Rotation invariant convolutional neural network for transient detection. The Astrophysical Journal. 2017 Feb 10

3. Tuccillo D, Huertas-Company M, Decencière E, Velasco-Forero S, Domínguez Sánchez H, DimauroP. Deep learning for galaxy surface brightness profile fitting. Monthly Notices of the Royal Astronomical Society. 2017 Dec 11

4. George, Daniel, and E. A. Huerta. "Deep Learning for real-time gravitational wave detection and parameter estimation: Results with Advanced LIGO data." Physics Letters B 778 (2018): 64-70.

Page 70: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

GANs for deconvolution4,550 SDSS images of nearby galaxies at 0:01 < z < 0:02

COMPUTATIONAL INTELLIGENCE IN ASTROPHYSICS WORKSHOP 70

Schawinski, Kevin, et al. "Generative Adversarial Networks recover features in astrophysical images of galaxies beyond the deconvolution limit." arXiv preprint arXiv:1702.00403 (2017).

Page 71: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

TensorFlowDeep learning library, open-sourced by Google (11/2015)

TensorFlow provides primitives for ◦ defining functions on tensors

◦ automatically computing their derivatives

What is a tensor

What is a computational graph

71

Material from lecture by Bharath Ramsundar, March 2018, Stanford

DEEP LEARNING IN ASTRONOMY - APPLICATIONS

Page 72: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Introduction to KerasOfficial high-level API of TensorFlow

◦ Python◦ 250K developers◦ Developed by Francois Chollet

Same front-end <-> Different back-ends◦ TensorFlow (Google)◦ CNTK (Microsoft)◦ MXNet (Apache)◦ Theano (RIP)

Hardware◦ GPU (Nvidia)◦ CPU (Intel/AMD)◦ TPU (Google)

Companies: AWS, Uber, Google, Nvidia…

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 72

Page 73: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Keras modelsInstallation ◦ Anaconda -> Tensorflow -> Keras

Build-in◦ Conv1D, Conv2D, Conv3D…

◦ MaxPooling1D, MaxPooling2D, MaxPooling3D…

◦ Dense, Activation, RNN…

The Sequential Model◦ Very simple

◦ Single-input, Single-output, sequential layer stacks

The functional API◦ Mix & Match

◦ Multi-input, multi-output, arbitrary static graph topologies

73DEEP LEARNING IN ASTRONOMY - APPLICATIONS

Page 74: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Sequential API>> import keras

>> from keras import layers

>> model = Sequential()

>> model.add(layers.Dense(24, activation='relu', input_shape(10,)))

>> model.add(layers.Dense(20, activation=‘relu'))

>> model.add(layers.Dense(10, activation=‘softmax'))

>> model.fit(x_train, y_train, epochs=5, batch_size=32)

74DEEP LEARNING IN ASTRONOMY - APPLICATIONS

Page 75: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Functional API>> import keras

>> from keras import layers

>> inputs = keras.Input(shape=(10,))

>> x = layers.Dense(20, activation='relu')(inputs)

>> x = layers.Dense(20, activation='relu')(x)

>> outputs = layers.Dense(10, activation='softmax')(x)

>> model = keras.Model(inputs, outputs)

>> model.fit(x_train, y_train, epochs=5, batch_size=32)

75DEEP LEARNING IN ASTRONOMY - APPLICATIONS

Page 76: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Sequential>>from keras.models import Sequential

>>model = Sequential()

>> from keras.layers import Dense

>> model.add(Dense(units=64, activation='relu', input_dim=100))

>> model.add(Dense(units=10, activation='softmax'))

>> model.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy'])

>> model.fit(x_train, y_train, epochs=5, batch_size=32)

>> loss_and_metrics = model.evaluate(x_test, y_test, batch_size=128)

>> classes = model.predict(x_test)

76DEEP LEARNING IN ASTRONOMY - APPLICATIONS

Page 77: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Functional >> from keras.layers import Input, Dense

>> from keras.models import Model

>> inputs = Input(shape=(784,))

>> x = Dense(64, activation='relu')(inputs)

>> x = Dense(64, activation='relu')(x)

>> predictions = Dense(10, activation='softmax')(x)

>> model = Model(inputs=inputs, outputs=predictions)

>> model.compile(optimizer=‘SGD',loss='categorical_crossentropy', metrics=['accuracy'])

>> model.fit(data, labels)

77DEEP LEARNING IN ASTRONOMY - APPLICATIONS

Page 78: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Case study #1: Galaxy morphologyEuclid mission

Mission: map the dark universe

Planned launch in 2022

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 78

Page 79: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Case study

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 79

Band y Band J Band H

Page 80: Fundamentals of Deep (Artificial) Neural Networks (DNN)users.ics.forth.gr/~greg/Docs/AstroSS_DL_in_Astronomy...DEEP LEARNING IN ASTRONOMY - APPLICATIONS 67 Pearson, Kyle A., Leon Palafox,

Kaggle kernelshttps://www.kaggle.com/greg1982/astroschool-morphology

DEEP LEARNING IN ASTRONOMY - APPLICATIONS 80