neuralogic.nn.module.meta package
Submodules
neuralogic.nn.module.meta.magnn module
- class MAGNNLinear(in_channels: int, out_channels: int, output_name: str, feature_name: str, relation_name: str, type_name: str | None, meta_paths: ~typing.List[str], activation: ~neuralogic.core.constructs.function.function.TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>, aggregation: ~neuralogic.core.constructs.function.function.AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>)[source]
Bases:
MAGNNMeanIntra-metapath Aggregation module with Linear encoder from “MAGNN: Metapath Aggregated Graph Neural Network for Heterogeneous Graph Embedding”. Which can be expressed as:
\[\mathbf{h}_{P(v,u)} = \mathbf{W}_p \cdot MEAN(\{\mathbf{x}_t | \forall t \in P(v,u) \})\]\[\mathbf{h}^P_{v} = act(\sum_{u \in N^P_v} \mathbf{h}_{P(v,u)})\]Where act is an activation function, \(P(v,u)\) is a single metapath instance, \(N^P_{v}\) is set of metapath-based neighbors.
- Parameters:
in_channels (int) – Input feature size.
out_channels (int) – Output feature size.
output_name (str) – Output (head) predicate name of the module.
feature_name (str) – Feature predicate name to get features from.
relation_name (str) – Relation predicate name for connectivity checks between entities.
type_name (Optional[str]) – Metapath type predicate name. If none,
meta_pathswill be used instead.meta_paths (List[str]) – Name of types forming a single metapath.
activation (TransformationFunction) – Activation function of the output. Default:
Transformation.SIGMOIDaggregation (AggregationFunction) – Aggregation function of the output. Default:
Aggreagtion.SUM
- class MAGNNMean(output_name: str, feature_name: str, relation_name: str, type_name: str | None, meta_paths: ~typing.List[str], activation: ~neuralogic.core.constructs.function.function.TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>, aggregation: ~neuralogic.core.constructs.function.function.AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>)[source]
Bases:
ModuleIntra-metapath Aggregation module with Mean encoder from “MAGNN: Metapath Aggregated Graph Neural Network for Heterogeneous Graph Embedding”. Which can be expressed as:
\[\mathbf{h}_{P(v,u)} = MEAN(\{\mathbf{x}_t | \forall t \in P(v,u) \})\]\[\mathbf{h}^P_{v} = act(\sum_{u \in N^P_v} \mathbf{h}_{P(v,u)})\]Where act is an activation function, \(P(v,u)\) is a single metapath instance, \(N^P_{v}\) is set of metapath-based neighbors.
- Parameters:
output_name (str) – Output (head) predicate name of the module.
feature_name (str) – Feature predicate name to get features from.
relation_name (str) – Relation predicate name for connectivity checks between entities.
type_name (Optional[str]) – Metapath type predicate name. If none,
meta_pathswill be used instead.meta_paths (List[str]) – Name of types forming a single metapath.
activation (TransformationFunction) – Activation function of the output. Default:
Transformation.SIGMOIDaggregation (AggregationFunction) – Aggregation function of the output. Default:
Aggreagtion.SUM
neuralogic.nn.module.meta.meta module
- class MetaConv(in_channels: int, out_channels: int, output_name: str, feature_name: str, role_name: str | None, roles: ~typing.List[str], activation: ~neuralogic.core.constructs.function.function.TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>, aggregation: ~neuralogic.core.constructs.function.function.AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>)[source]
Bases:
ModuleMetagraph Convolutional Unit layer.
From Meta-GNN: metagraph neural network for semi-supervised learning in attributed heterogeneous information networks. Which can be expressed as:
\[\mathbf{x}^{\prime}_i = act(\mathbf{W_0} \cdot \mathbf{x}_i + {agg}_{j \in \mathcal{N}_r(i)} \sum_{k \in \mathcal{K}} (\mathbf{W_k} \cdot \mathbf{x}_j))\]Where act is an activation function, agg aggregation function (by default average), \(W_0\) is a learnable root parameter and \(W_k\) is a learnable parameter for each role.
- Parameters:
in_channels (int) – Input feature size.
out_channels (int) – Output feature size.
output_name (str) – Output (head) predicate name of the module.
feature_name (str) – Feature predicate name to get features from.
role_name (str, optional) – Role predicate name to use for role relations. When
None, elements fromrolesare used instead.roles (List[str]) – List of relations’ names.
activation (TransformationFunction, optional) – Activation function of the output. Default:
Transformation.SIGMOID.aggregation (AggregationFunction, optional) – Aggregation function of nodes’ neighbors. Default:
Aggregation.AVG.