openhgnn.layers.HeteroFeature

class HeteroFeature(h_dict, n_nodes_dict, embed_size, act=None, need_trans=True, all_feats=True)[源代码]

This is a feature preprocessing component which is dealt with various heterogeneous feature situation.

In general, we will face the following three situations.

  1. The dataset has not feature at all.

  2. The dataset has features in every node type.

  3. The dataset has features of a part of node types.

To deal with that, we implement the HeteroFeature.In every situation, we can see that

  1. We will build embeddings for all node types.

  2. We will build linear layer for all node types.

  3. We will build embeddings for parts of node types and linear layer for parts of node types which have original feature.

参数:
  • h_dict (dict) – Input heterogeneous feature dict, key of dict means node type, value of dict means corresponding feature of the node type. It can be None if the dataset has no feature.

  • n_nodes_dict (dict) – Key of dict means node type, value of dict means number of nodes.

  • embed_size (int) – Dimension of embedding, and used to assign to the output dimension of Linear which transform the original feature.

  • need_trans (bool, optional) – A flag to control whether to transform original feature linearly. Default is True.

  • act (callable activation function/layer or None, optional) – If not None, applies an activation function to the updated node features. Default: None.

embed_dict

store the embeddings

Type:

nn.ParameterDict

hetero_linear

A heterogeneous linear layer to transform original feature.

Type:

HeteroLinearLayer