-
Notifications
You must be signed in to change notification settings - Fork 0
/
document.tex
306 lines (237 loc) · 7.41 KB
/
document.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
\documentclass{beamer}
\setlength{\parskip}{1em}
\title{GRAH-BERT Review}
\subtitle{Alex To}
%\usetheme{lucid}
\begin{document}
\frame {
\titlepage
}
\frame{
\frametitle{Agenda}
\begin{itemize}
\item Introduction
\item Linkless subgraph Batching
\item Node input vector embeddings
\begin{itemize}
\item Raw feature vector embedding
\item Weisfeiler Lehman absolute role embedding
\item Intimacy based relative positional embedding
\item Hop based relative distance embedding
\end{itemize}
\item Embeddings aggregations
\item Graph Transformer based encoder
\item GRAPH-BERT learning
\begin{itemize}
\item Pre-training
\end{itemize}
\end{itemize}
}
\frame {
\frametitle{Introduction}
\begin{itemize}
\item A graph neural network model
\item Based on attention mechanism
\item Train with sampled linkless subgraphs
\end{itemize}
\begin{figure}[htb]
\includegraphics[width=1.0\textwidth]{figures/graph-bert-overview}
\caption{GRAPH-BERT architecture}
\end{figure}
}
\frame{
\frametitle{Linkless subgraph batching}
Given a graph $G(V,E)$ how to generate sub graph batches?
\begin{itemize}
\item Calculate an intimacy score matrix $S$
\[
S = \alpha \cdot (I - (1 - \alpha) \cdot \bar{A})^{-1}
\]
where
\[
\bar{A} = AD^{-1}
\]
$A$: adjacency matrix
$D$: neighbor count diagonal matrix
\item Based on $S$, for a target node $v_i$, find top $k$ "intimate" nodes of $v_i$ with $k$ largest $S(v_i, v_j)$ score.
\end{itemize}
}
\frame {
\frametitle{Linkless subgraph batching (cont)}
\begin{minipage}{\textwidth}
\begin{columns}[T,onlytextwidth]
\begin{column}{.4\textwidth}
\begin{figure}
\includegraphics[width=0.9\textwidth]{figures/example-network}
\end{figure}
\end{column}
\begin{column}{.45\textwidth}
$A = \begin{bmatrix}
0 & 1 & 0 & 0 & 0 \\
1 & 0 & 1 & 1 & 0 \\
0 & 1 & 0 & 0 & 1 \\
0 & 1 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0
\end{bmatrix}$
\end{column}
\end{columns}
\end{minipage}
\begin{onlyenv}<2>
\begin{minipage}{\textwidth}
\begin{columns}[T,onlytextwidth]
\begin{column}{.5\textwidth}
$D = \begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
0 & 3 & 0 & 0 & 0 \\
0 & 0 & 2 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 1
\end{bmatrix}$
\end{column}
\begin{column}{.5\textwidth}
$D^{-1} = \begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
0 & 1/3 & 0 & 0 & 0 \\
0 & 0 & 1/2 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 1
\end{bmatrix}$
\end{column}
\end{columns}
\end{minipage}
\end{onlyenv}
}
\frame {
\frametitle{Linkless subgraph batching (cont)}
\begin{minipage}{\textwidth}
$AD^{-1} = \begin{bmatrix}
0 & 1/3 & 0 & 0 & 0 \\
1 & 0 & 1/2 & 1 & 0 \\
0 & 1/3 & 0 & 0 & 1 \\
0 & 1/3 & 0 & 0 & 0 \\
0 & 0 & 1/2 & 0 & 0
\end{bmatrix}$
\end{minipage}
\begin{minipage}{\textwidth}
$S = \begin{bmatrix}
0.259 & 0.128 & 0.085 & 0.109 & 0.072 \\
0.386 & 0.454 & 0.302 & 0.386 & 0.257 \\
0.171 & 0.201 & 0.369 & 0.171 & 0.313 \\
0.109 & 0.128 & 0.085 & 0.259 & 0.072 \\
0.072 & 0.085 & 0.156 & 0.072 & 0.283
\end{bmatrix}$
\end{minipage}
For a target node $v_i$, take $k$ entries in $sorted(S(i,:))$, no links (hence, linkless subgraph)
}
\frame {
\frametitle{Node input vector embeddings}
\begin{figure}
\includegraphics[width=0.7\textwidth]{figures/embeddings}
\end{figure}
\begin{itemize}
\item Raw Feature Vector Embedding
\item Weisfeiler Lehman Absolute Role Embedding
\item Intimacy based Relative Positional Embedding
\item Hop based Relative Distance Embedding
\end{itemize}
}
\frame {
\frametitle{Node input vector embeddings}
\framesubtitle{Raw feature vector embedding}
In each subgraph $g_i$
$g_i = \{v_i, v_{i,0}, v_{i,1}, v_{i,2}, ..., v_{i,k}\}$
For each node $v_j \in g_i$
\[
e^{(x)}_j = Embed(x_j) \in \mathbb{R}^{d_h}
\]
Here $Embed(\cdot)$ function can be CNN if $x_j$ denotes images or LSTM/BERT if $x_j$ denotes texts etc...
Use nn.Linear layer to produce feature vector $\mathbb{R}^{d_h}$ for $v_j$
}
\frame {
\frametitle{Node input vector embeddings}
\framesubtitle{Weisfeiler Lehman absolute role embedding}
To "color code" every node according to the following process:
\begin{itemize}
\item Step 0 Initially assign code "1" to all nodes
\item Step 1 For every target node $v_i$, concat the color codes of all neighbors (the concatenated string initially will be "1\_1\_1\_1..")
\item Step 2 Generate hash for the string in Step 1
\item Step 3 Assign a unique number for every the unique hash, so $v_i$ will have a new "color code"
\item Repeat from step 1 (until stable or after a number of iterations)
\end{itemize}
Use set of $(k+1)$ color codes and nn.Embedding to produce feature vector $\mathbb{R}^{d_h}$ for $v_j$
}
\frame {
\frametitle{Node input vector embeddings}
\framesubtitle{Intimacy based relative positional embedding}
Use $k$ entries in $sorted(S(j,:))$ and nn.Embedding to produce feature vector $\mathbb{R}^{d_h}$ for $v_j$
But in code, the intimacy score vector is [0, 1,...,k], not the real score.
}
\frame {
\frametitle{Node input vector embeddings}
\framesubtitle{Hop based relative distance embedding}
In each subgraph $g_i$
$g_i = \{v_i, v_{i,0}, v_{i,1}, v_{i,2}, ..., v_{i,k}\}$
Construct a hop-list $[0, H(v_{i,0}), H(v_{i,1}), H(v_{i,2}), ..., H(v_{i,k})]$
For e.g. $[0, 1, 1, 2, ..., 3]$
Feed into a nn.Embedding to produce feature vector $\mathbb{R}^{d_h}$ for $v_j$
}
\frame {
\frametitle{Embeddings aggregation}
In each subgraph $g_i$
$g_i = \{v_i, v_{i,0}, v_{i,1}, v_{i,2}, ..., v_{i,k}\}$
For $v_j$ $\in$ $g_i$
$h^{(0)}_j = sum(e^{x}_j, e^{r}_j, e^{p}_j, e^{d}_j) \in \mathbb{R}^{d_h} $
Organize all vectors into a matrix
$H^{(0)} = [h^{(0)}_i, h^{(0)}_{i,0}, h^{(0)}_{i,1}, h^{(0)}_{i,2}, ..., h^{(0)}_{i,k}]^T \in \mathbb{R}^{(k+1) \times d_h} $
}
\frame{
\frametitle{Graph Transformer based encoder}
\begin{figure}
\includegraphics[width=0.7\textwidth]{figures/encoder}
\end{figure}
}
\frame{
\frametitle{GRAPH-BERT learning}
\begin{figure}
\includegraphics[width=0.45\textwidth]{figures/pretrain}
\end{figure}
$H^{(D)} \in \mathbb{R}^{(k+1) \times d_h} $
Fusion: $z_i \in \mathbb{R}^{d_h} $ (average out $H^{(D)}$)
FC: nn.Linear(in\_features=$d_h$, out\_features=$x\_size$)
Activation: tanh
}
\frame{
\frametitle{GRAPH-BERT learning}
\framesubtitle{Pretraining}
Pretrained on 2 tasks
\begin{itemize}
\item Node classification
Pretrain using MSE loss on $x_i$ and $\hat{x}_i$
\[
l_1 = MSE\_Loss(x_i, \hat{x}_i)
\]
\item Graph clustering
For any two nodes $v_i$ and $v_j$, compute cosine similarity
\[
\hat{s}_{i,j} = \frac{z^T_iz_j}{\|{z_i}\|\|{z_j}\|}
\]
Loss function
\[
l_2 = \frac{1}{|V|^2}\|S-\hat{S}\|^2_F
\]
But in code, $A$ is used but not $S$
\end{itemize}
}
\frame{
\frametitle{Discussion}
\begin{itemize}
\item Pros
\item Combine multiple node features
\item Train on local node context
\item Cons
\begin{itemize}
\item Does not use link features
\end{itemize}
\end{itemize}
}
\end{document}