Harsha Kokel
Graph Attention Networks
Veličković, Petar, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio, ICLR 2018
Convolutional Neural Networks (CNNs) can effectively transform gridlike structures and have been used for various image segmentation/classification tasks. Various approaches have not been proposed to extended CNNs graph structures. These approaches are broadly divided into two categories:

Spectral appraoch leverages the spectral representations of graph and defines convolution in the Fourier domain. However, because such convolutions require eigendecomposition of graph laplacian, they can not be directly generalized to different graph structures. Most famous of this is Convolutional Graph Networks by Kipf and Welling, ICLR 2017. One major drawback of CNN is that is assigns equal importance to all the neighbors.

Spatial approach on other hand perform convolution directly on the graph, leveraging the neighborhood structure. This can be challenging because of varying neighborhood and most approaches perform some form of aggregation on the neighbors. Since the neighbors in graph have no particular order, the aggregation provides equal importance to all the neighbors.
Besides, attention mechanisms allow for focusing on relevant parts of input and have attained stateoftheart for various tasks. This paper proposes the use of attention mechanism to provide a relevant weights to different neighbors.
Attention layer
Generally, each graph convolutional layer take input and generates output by linearly transforming the input vectors using weight matrix – , taking weighted aggregate over the neighborhood – (including the node itself), and finally passing the value from a nonlinear activation function – .
This can be equivalently written in matrix form as
In GCN, the convolutional layer is where is a renormalized laplacian which indicated neighbor. So, effectively because the
This paper proposes to use the attention mechanism – to compute the in following way:
Intuitively, is importance of node on and is normalized importance.
The framework proposed is agnostic to the choice of attention mechanism – . However, in the paper authors use a singlelayer feedforward neural network parameterized by weight vector and LeakyReLU nonlinearity, which takes the input , where represents concatenation. The activation mechanism is represented in the figure below. Mathematically, the activation mechanism used in the experiments is:
src: Veličković et al. 2018
Intuitively, is a linear combination of transformed and . It can be thought of as a distance between node and or some aggregate.
Since the slope of ReLU is zero for ve values, the ability to train the model is compromised in that region. This is called dying ReLU problem. LeakyReLU activation function is used instead of ReLU with a=0.01 in the figure below to avoid that problem. LeakyReLU helps speed up learning and is more balanced.
Following Vaswani et al. 2017, authors proposes to use independent attention mechanism to employ multihead attention. So the mathematical form of each layer is:
and the output consists features instead of .
Only, in last layer the multihead attentions are aggregated instead of concatenation. So, the mathematical form of last layer is:
src: Veličković et al. 2018
Complexity
Time complexity of computing single attention head is sum of complexity of computing the for each node and then computing the softmax. The feed forward neural network, computing is effectively equivalent to complexity of matrix multiplication for each node, , where is number of nodes. Complexity of computing for all the edges is , where is number of edges. So, total complexity of a single attention head is .
Memory complexity of GAT for sparse matrix is linear in terms of nodes and edges.
Experiments
Authors evaluate the GAT architecture for two type of learning tasks on graph structures:

Transductive learning task is where the algorithm sees whole graph but labels of only few nodes are available. Algorithm is trained on these nodes and whole graph and the task is to produce labels for nodes which do not have labels while training. GCN works only for transductive setting.

Inductive learning task is when the algorithm sees only training nodes and edges between those nodes. Labels of all the training nodes are available and the task is to predict label for test nodes, which are unseen during training.
Transductive learning
For transductive learning task, 10 baseline architectures are compared (including GCN, MoNet, Chebyshev, MLP etc), for three datasets Cora, Citeseer and pubmed. Two layer GAT architecture was used as shown in figure below, with 8 attention heads in first layer and 1 attention head in second layer. Softmax was used in final layer and ELU activation is used in the first layer.
Mathematical form of the architecture:
Inductive Learning
For inductive learning task, 6 baseline architectures are compared (including GraphSAGE, MLP etc), for PPI dataset. Three layer architecture was used as shown in the figure below.
Mathematical form of the architecture:
Extensions
The GAT network can be extended to use for Graph classification by simply appending a pooling layer at the end. Figure below represents one such architecture.
GAT can also be used for embedding the nodes to twodimensional space. One such architecture is presented below, where instead of Softmax, the last layer outputs 2D vector for each node.
Mathematical form of this 2D embedding GAT network is
Questions

What attention mechanism is used in the experiments?Link to Answer

Why LeakyReLU but not the standard ReLU ? Link to Answer

Proof complexity of GAT layer is . Link to Answer

What is the memory complexity of GAT layer? Link to Answer

Explain difference between transductive and inductive learning. Link to Answer

Draw architecture of two layer GAT model for transductive learning. What is the Mathematical formulation? Link to Answer

Draw architecture of three layer GAT model for inductive learning. What is the Mathematical formulation? Link to Answer

Design a GAT model that embed the nodes of the cora network in a twodimensional space. Draw the architecture and give the mathematic form. Link to Answer

Design a GAT model for graph classification. Draw the architecture and give the mathematic form. Link to Answer
References
 Veličković, Petar, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio, Graph Attention Networks , ICLR 2018
 Graph Attention Networks overview by Peter Veličković
 ML Paper explained  AISC by Karim Khayrat: Graph Attention Networks Explained
 A Tutorial on Attention in Deep Learning, by Alex Smola and Aston Zhang, ICML 2019
 https://towardsdatascience.com/illustratedselfattention2d627e33b20a
 https://towardsdatascience.com/activationfunctionsneuralnetworks1cbd9f8d91d6