pipeline.GNN.models package#
A package that defines various triplet-based GNNs.
- pipeline.GNN.models.get_model(model_type=None)[source]#
Get a GNN model class from its name.
- Parameters:
model_type (
Optional
[str
]) – GNN type. Available aretriplet_interaction
,edge_based
andscifi_triplet_interaction
.- Return type:
Type
[TripletGNNBase
]- Returns:
The GNN model class that can be instantiated.
pipeline.GNN.models.edge_based_gnn module#
- class pipeline.GNN.models.edge_based_gnn.EdgeBasedGNN(hparams)[source]#
Bases:
TripletGNNBase
A triplet-based GNN without using node encodings.
- forward_edges(x, start, end)[source]#
Forward step for edge classification.
- Parameters:
x (
Tensor
) – Hit featuresedge_index – Torch tensor with 2 rows that define the edges.
- Returns:
the hit encodings and edge encodings after message passing, and the edge classifier output.
- Return type:
A tuple of 3 tensors
- forward_triplets(e, filtered_edge_index, edge_mask, dict_triplet_indices, **kwargs)[source]#
Forward step for triplet classification.
- Parameters:
e (
Tensor
) – Edge encodings after the edge forward stepfiltered_edge_index (
Tensor
) – edge index after requiring the minimal edge scoreedge_mask (
Tensor
) – edge mask of edges kept after filteringedge_score_cut – custom edge score cut. If not specified, the value is taken from the internal
hparams
dictionary.
- Return type:
Dict
[str
,Tensor
]- Returns:
A dictionary that associates
articulation
,elbow_left
andelbow_right
with the logits of the corresponding triplets.
- property input_kwargs: Dict[str, Any]#
Associates an input name with a dictionary corresponding to the keyword arguments used to build a dummy tensor representing the input. This dictionary basically gives the
size
anddtype
of the tensor.
- property input_to_dynamic_axes#
A dictionary that associates an input name with the dynamic axis specification.
- property subnetwork_groups: Dict[str, List[str]]#
A dictionary that associates a subnetwork actually corresponding to a list of subnetworks, with this list of subnetworks.
- property subnetwork_to_outputs: Dict[str, List[str]]#
A dictionary that associates a subnetwork name with the list of its output names.
- property subnetworks: List[str]#
List of subnetworks available. It is derived from
subnetwork_to_outputs
.
pipeline.GNN.models.incremental_triplet_interaction_gnn module#
pipeline.GNN.models.scifi_triplet_interaction_gnn module#
pipeline.GNN.models.triplet_interaction_gnn module#
- class pipeline.GNN.models.triplet_interaction_gnn.TripletInteractionGNN(*args: Any, **kwargs: Any)[source]#
Bases:
TripletGNNBase
A triplet-based interaction network.
- encoding_step(x, start, end)[source]#
Initial encoding step of the GNN.
- Parameters:
x (
Tensor
) – hit input featuresstart (
Tensor
) – start indices of the edgesend (
Tensor
) – end indices of the edges
- Return type:
Tuple
[Tensor
,Tensor
]- Returns:
The node encodings
h
and edge encodingse
- forward_edges(x, start, end)[source]#
Forwrd step for edge classification.
- Parameters:
x (
Tensor
) – hit input featuresstart (
Tensor
) – start indices of the edgesend (
Tensor
) – end indices of the edges
- Returns:
the hit encodings and edge encodings after message passing, and the edge classifier output.
- Return type:
A tuple of 3 tensors
- forward_triplets(h, e, filtered_edge_index, edge_mask, dict_triplet_indices, **kwargs)[source]#
Forward step for triplet classification.
- Parameters:
h (
Tensor
) – Hit encodings after the edge forward stepe (
Tensor
) – Edge encodings after the edge forward stepfiltered_edge_index (
Tensor
) – edge index after requiring the minimal edge scoreedge_mask (
Tensor
) – edge mask of edges kept after filteringedge_score_cut – custom edge score cut. If not specified, the value is taken from the internal
hparams
dictionary.
- Return type:
Dict
[str
,Tensor
]- Returns:
A dictionary that associates
articulation
,elbow_left
andelbow_right
with the logits of the corresponding triplets.
- property input_kwargs: Dict[str, Any]#
Associates an input name with a dictionary corresponding to the keyword arguments used to build a dummy tensor representing the input. This dictionary basically gives the
size
anddtype
of the tensor.
- property input_to_dynamic_axes#
A dictionary that associates an input name with the dynamic axis specification.
- message_step(h, start, end, e, step)[source]#
Apply one step of message-passing that updates the node and edge encodings.
- Return type:
Tuple
[Tensor
,Tensor
]
- property n_graph_iters: int#
Number of message-passing iterations
- property only_e: bool#
- output_step(h, start, end, e)[source]#
Apply the edge output classifier to edges to get edge logits.
- Return type:
Tensor
- property recursive: bool#
Whether the GNN is recursive, i.e., the networks involved in the message step are the same.
- scatter_add(source, index, h)[source]#
Scatter add operation. In ONNX export mode for TensorRT, the operation is replaced by a fake operator that is implemented through a plugin in TensorRT.
- Return type:
Tensor
- property subnetwork_groups: Dict[str, List[str]]#
A dictionary that associates a subnetwork actually corresponding to a list of subnetworks, with this list of subnetworks.
- property subnetwork_to_outputs: Dict[str, List[str]]#
A dictionary that associates a subnetwork name with the list of its output names.