openhgnn.layers.HeteroLinearLayer

class HeteroLinearLayer(linear_dict, act=None, dropout=0.0, has_l2norm=True, has_bn=True, **kwargs)[源代码]

Transform feature with nn.Linear. In general, heterogeneous feature has different dimension as input. Even though they may have same dimension, they may have different semantic in every dimension. So we use a linear layer for each node type to map all node features to a shared feature space.

参数:

linear_dict (dict) – Key of dict can be node type(node name), value of dict is a list contains input dimension and output dimension.

示例

>>> import torch as th
>>> linear_dict = {}
>>> linear_dict['author'] = [110, 64]
>>> linear_dict['paper'] = [128,64]
>>> h_dict = {}
>>> h_dict['author'] = th.tensor(10, 110)
>>> h_dict['paper'] = th.tensor(5, 128)
>>> layer = HeteroLinearLayer(linear_dict)
>>> out_dict = layer(h_dict)