PyTorch Geometric Transforms

TemporalPyGTransform

The TemporalPyGTransform creates a sequence of subgraph batches out of a single batch of data produced by a NeighborLoader or HGTLoader. It assumes that there are datetime attributes on vertices and edges. If vertex attributes change over time, children vertex attributes are moved to the appropriate parent, and then the children are removed from the graph.

_init_()

init(vertex_start_attrs: dict, vertex_end_attrs: dict, edge_start_attrs: dict, edge_end_attrs: dict, start_dt: int, end_dt: int, feature_transforms: dict, timestep: int = 86400)

Instantiate a TemporalPyGTransform.

Parameters:

  • vertex_start_attrs (str, dict): If using on a homogeneous graph, string of the attribute storing the timestamp of when a vertex becomes valid to include. If using on a heterogenous graph, dictionary that describes the attribute storing the timestamp of when a vertex becomes a valid vertex to include in the graph. In the format of {"VERTEX_TYPE": "attribute_name"}.

  • vertex_end_attrs (str, dict): If using on a homogeneous graph, string of the attribute storing the timestamp of when a vertex stops being valid to include. If using on a heterogenous graph, dictionary that describes the attribute storing the timestamp of when a vertex stops being a valid vertex to include in the graph. In the format of {"VERTEX_TYPE": "attribute_name"}

  • edge_start_attrs (str, dict): If using on a homogeneous graph, string of the attribute storing the timestamp of when an edge becomes valid to include. If using on a heterogenous graph, dictionary that describes the attribute storing the timestamp of when an edge becomes a valid edge to include in the graph. Uses the PyG edge format of ("SourceVertexType", "EdgeName", "DestinationVertexType"). In the format of {("SourceVertexType", "EdgeName", "DestinationVertexType"): "attribute_name"}.

  • edge_end_attrs (str, dict): If using on a homogeneous graph, string of the attribute storing the timestamp of when an edge stops being valid to include. If using on a heterogenous graph, dictionary that describes the attribute storing the timestamp of when an edge stops being a valid edge to include in the graph. Uses the PyG edge format of ("SourceVertexType", "EdgeName", "DestinationVertexType"). In the format of {("SourceVertexType", "EdgeName", "DestinationVertexType"): "attribute_name"}

  • start_dt (int): The UNIX epoch time to start generating the sequence of subgraphs.

  • end_dt (int): The UNIX epoch time to stop generating the sequence of subgraphs.

  • feature_transforms (dict, optional): Only available on heterogeneous graphs. Moves temporally dynamic features from "children" vertices to "parent" vertices when modelling temporal attributes in TigerGraph. The key of the dictionary is the edge to move the attributes from the child type to the parent type, and the value is a list of attributes to move. In the fromat of {("ItemInstance", "reverse_DESCRIBED_BY", "Item"): ["x"]}

  • timestep (int, optional): The number of seconds to use in between timesteps. Defaults to 86400 seconds (1 day).

call()

call(data) → list

Perform the transform. Returns a list of PyTorch Geometric data objects, a sequence of snapshots in time of the graph. Edges are removed between vertices that do not have connections at the given time. All vertices are in each snapshot, but are marked as present with the "vertex_present" attribute in the produced data objects.

Parameter:

  • data (pyg.data.HeteroData or pyg.data.Data): Takes in a PyTorch Geometric data object, such as ones produced by the dataloaders.