openhgnn.models.HAN

class HAN(ntype_meta_paths_dict, in_dim, hidden_dim, out_dim, num_heads, dropout)[source]

This model shows an example of using dgl.metapath_reachable_graph on the original heterogeneous graph HAN from paper Heterogeneous Graph Attention Network.. Because the original HAN implementation only gives the preprocessed homogeneous graph, this model could not reproduce the result in HAN as they did not provide the preprocessing code, and we constructed another dataset from ACM with a different set of papers, connections, features and labels.

\[\mathbf{h}_{i}^{\prime}=\mathbf{M}_{\phi_{i}} \cdot \mathbf{h}_{i}\]

where \(h_i\) and \(h'_i\) are the original and projected feature of node \(i\)

\[e_{i j}^{\Phi}=a t t_{\text {node }}\left(\mathbf{h}_{i}^{\prime}, \mathbf{h}_{j}^{\prime} ; \Phi\right)\]

where \({att}_{node}\) denotes the deep neural network.

\[\alpha_{i j}^{\Phi}=\operatorname{softmax}_{j}\left(e_{i j}^{\Phi}\right)=\frac{\exp \left(\sigma\left(\mathbf{a}_{\Phi}^{\mathrm{T}} \cdot\left[\mathbf{h}_{i}^{\prime} \| \mathbf{h}_{j}^{\prime}\right]\right)\right)}{\sum_{k \in \mathcal{N}_{i}^{\Phi}} \exp \left(\sigma\left(\mathbf{a}_{\Phi}^{\mathrm{T}} \cdot\left[\mathbf{h}_{i}^{\prime} \| \mathbf{h}_{k}^{\prime}\right]\right)\right)}\]

where \(\sigma\) denotes the activation function, || denotes the concatenate operation and \(a_{\Phi}\) is the node-level attention vector for meta-path \(\Phi\).

\[\mathbf{z}_{i}^{\Phi}=\prod_{k=1}^{K} \sigma\left(\sum_{j \in \mathcal{N}_{i}^{\Phi}} \alpha_{i j}^{\Phi} \cdot \mathbf{h}_{j}^{\prime}\right)\]

where \(z^{\Phi}_i\) is the learned embedding of node i for the meta-path \(\Phi\). Given the meta-path set {\(\Phi_0 ,\Phi_1,...,\Phi_P\)},after feeding node features into node-level attentionwe can obtain P groups of semantic-specific node embeddings, denotes as {\(Z_0 ,Z_1,...,Z_P\)}. We use MetapathConv to finish Node-level Attention and Semantic-level Attention.

Parameters:
  • ntype_meta_paths_dict (dict[str, dict[str, list[etype]]]) – Dict from node type to dict from meta path name to meta path. For node classification, there is only one node type. For link prediction, there can be multiple node types which are source and destination node types of target links.

  • in_dim (int) – Input feature dimension.

  • hidden_dim (int) – Hidden layer dimension.

  • out_dim (int) – Output feature dimension.

  • num_heads (list[int]) – Number of attention heads.

  • dropout (float) – Dropout probability.