Top Banner
Lab3 EM & GCN Chen Houshuang [email protected]
35

Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang [email protected]. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Jun 14, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Lab3EM & GCN

Chen Houshuang

[email protected]

Page 2: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

contents

➢ GCN

➢ EM

Page 3: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Graph Convolutional Networks

Page 4: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Traditional Deep Learning

• CNN

ImageNet

Grid Games

Page 5: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Traditional Deep Learning

• RNN

speech

NLP

Page 6: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Graph structured Data

Page 7: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Inspiration from CNN

• Pros of CNNs• Local connections

• Shared weights

• Use of multiple layers

• Cons of CNNs• hard to define convolutional and

pooling layers for non-Euclidean data

Image in Euclidean space

Graph in non-Euclidean space

Page 8: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

GCN: Definitions

• Input:• 𝑁 × 𝐷 feature matrix

• N: number of nodes• D: dimension of input features

• Adjacent matrix 𝐴(with shape 𝑁 × 𝑁)

• Output• Node level output Z

• An 𝑁 × 𝐹 feature matrix, where 𝐹 is the feature dimension of output per node

• Hidden neural network layer𝐻(𝑙+1) = 𝑓 𝐻 𝑙 , 𝐴

𝐻 0 = 𝑋 and 𝐻 𝐿 = 𝑍(𝐿: number of layers) and 𝑓 is a non-linear function

Page 9: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

GCN: the intuition

• A simple example𝑓 𝐻 𝑙 , 𝐴 = 𝜎 𝐴𝐻 𝑙 𝑊 𝑙

𝑊 𝑙 : weight matrix for the 𝑙-th neural network layer

𝜎(⋅): non-linear activation function like ReLU

• Despite its simplicity, this model is already quite powerful

Page 10: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

GCN: the intuition

• A simple example𝑓 𝐻 𝑙 , 𝐴 = 𝜎 𝐴𝐻 𝑙 𝑊 𝑙

𝑊 𝑙 : weight matrix for the 𝑙-th neural network layer𝜎(⋅): non-linear activation function like ReLU

• Limitations:• Sum up all feature vectors of all neighbor nodes except the node itself• 𝐴 is not normalized

• Tricks:• Enforce self-loop in graph: add identity matrix to 𝐴• Normalize 𝐴: all rows sum to one

• i.e. 𝐷−1𝐴 (D: diagonal node degree matrix)

• Use symmetrical normalization in practice: 𝐷−1

2𝐴𝐷−1

2

Page 11: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

GCN

• A simple example𝑓 𝐻 𝑙 , 𝐴 = 𝜎 𝐴𝐻 𝑙 𝑊 𝑙

𝑊 𝑙 : weight matrix for the 𝑙-th neural network layer

𝜎(⋅): non-linear activation function like ReLU

• Real used propagate rules

𝑓 𝐻 𝑙 , 𝐴 = 𝜎(𝐷−12 መ𝐴𝐷−

12𝐻 𝑙 𝑊 𝑙 )

where መ𝐴 = 𝐴 + 𝐼 and 𝐷 is the diagonal node degree matrix of መ𝐴

• Note:

• In the forward propagation, 𝐷−1

2 መ𝐴𝐷−1

2 only needs to be calculated once.

Page 12: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Examples

• Construct a two layer GCN𝑍 = softmax ሚ𝐴 ReLU ሚ𝐴𝑋𝑊 0 𝑊 1

where ሚ𝐴 = 𝐷−1

2 መ𝐴𝐷−1

2

• Add loss for nodes with labels

ℒ = −

𝑙∈𝑦𝐿

𝑓=1

𝐹

𝑌𝑙𝑓 ln 𝑍𝑙𝑓

𝐹 is the number of classes(output feature dimension)

𝑦𝐿 is the set of node indices that have labels

Page 13: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Examples

• 3-layer GCN with random initialized weights

Page 14: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Examples

• Semi-supervised learning• label one node per class/community

Page 15: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Molecule representation

• for each molecule, extract• Adjacent matrix with shape 𝑁 × 𝑁

• feature vector for each node• different feature vectors for the same atom

Page 16: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Model: one layer

• internal layer transition

Page 17: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Model training

• molecule⇒feature vectors⇒feature vectors⇒prediction

Page 18: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Expectation MaximizationEM algorithm for GMM

Page 19: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

EM: the intuition

slide from Stefanos Zafeiriou: Statistical Machine Learning

Page 20: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

EM: the intuition

slide from Stefanos Zafeiriou: Statistical Machine Learning

Page 21: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

EM: the intuition

slide from Stefanos Zafeiriou: Statistical Machine Learning

Page 22: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

EM: the intuition

slide from Stefanos Zafeiriou: Statistical Machine Learning

Page 23: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Import library

Page 24: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Generate Dataset

Page 25: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Supervised learning

Page 26: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Supervised learning

• 𝜃 = {𝑤𝑗 , 𝜇𝑗 , Σ𝑗: 𝑗}

• 𝑝 𝑧 𝑖 = 𝑗 𝑥 𝑖 ; 𝜃 =𝑝 𝑧 𝑖 = 𝑗, 𝑥 𝑖 𝜃

𝑝(𝑥 𝑖 |𝜃)=

𝑝(𝑥 𝑖 |𝑧 𝑖 =𝑗,𝜃)𝑝 𝑧 𝑖 = 𝑗 𝜃

𝑝(𝑥 𝑖 |𝜃)

Page 27: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

EM

Page 28: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

EM

Page 29: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Add Old Faithful 2D dataset

Page 30: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Create GMM with different cluster number

Page 31: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid
Page 32: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Fit criteria: Choose the number of mixtures

Page 33: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

Plot areas of dominance of a component

Page 34: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid
Page 35: Lab3 EM & GCN - GitHub Pages · Lab3 EM & GCN Chen Houshuang chenhoushuang@sjtu.edu.cn. contents GCN EM. Graph Convolutional Networks. Traditional Deep Learning •CNN ImageNet Grid

reference

• Kipf, Thomas N., and Max Welling. "Semi-supervised classification with graph convolutional networks." arXiv preprint arXiv:1609.02907 (2016).

• https://tkipf.github.io/graph-convolutional-networks/

• code for GCN: https://github.com/tkipf/gcn

• code for EM: http://iacs-courses.seas.harvard.edu/courses/am207/blog/lab-on-em.html

• https://mp.weixin.qq.com/s?__biz=MzI5NTIxNTg0OA==&mid=2247497717&idx=2&sn=0c3ac7100ada7e74ff97c8befd7cda31&chksm=ec544072db23c964bcb19346c9889dd0fb3757b9de6a254dd1cb77492ae69eef7cdfe2de5267&mpshare=1&scene=1&srcid=&sharer_sharetime=1573653749774&sharer_shareid=a74670ea9d0508a5bf81c9a18d234a70#rd

• https://mp.weixin.qq.com/s?__biz=MzIzNjc1NzUzMw==&mid=2247532164&idx=4&sn=f7f33fb633328b429607f4d2636951e0&chksm=e8d0c9f6dfa740e0f67bfa317979fa4288c82c96b26ddacab27fe37557fcac8f65eb7b2229ec&mpshare=1&scene=1&srcid=&sharer_sharetime=1573653677792&sharer_shareid=a74670ea9d0508a5bf81c9a18d234a70#rd