PyTorch Geometric Temporal Signal¶
Contents
Temporal Signal Iterators¶
- class StaticGraphTemporalSignal(edge_index: Optional[numpy.ndarray], edge_weight: Optional[numpy.ndarray], features: List[Optional[numpy.ndarray]], targets: List[Optional[numpy.ndarray]], **kwargs: List[numpy.ndarray])[source]¶
A data iterator object to contain a static graph with a dynamically changing constant time difference temporal feature set (multiple signals). The node labels (target) are also temporal. The iterator returns a single constant time difference temporal snapshot for a time period (e.g. day or week). This single temporal snapshot is a Pytorch Geometric Data object. Between two temporal snapshots the features and optionally passed attributes might change. However, the underlying graph is the same.
- Parameters
edge_index (Numpy array) – Index tensor of edges.
edge_weight (Numpy array) – Edge weight tensor.
features (List of Numpy arrays) – List of node feature tensors.
targets (List of Numpy arrays) – List of node label (target) tensors.
**kwargs (optional List of Numpy arrays) – List of additional attributes.
- class DynamicGraphTemporalSignal(edge_indices: List[Optional[numpy.ndarray]], edge_weights: List[Optional[numpy.ndarray]], features: List[Optional[numpy.ndarray]], targets: List[Optional[numpy.ndarray]], **kwargs: List[numpy.ndarray])[source]¶
A data iterator object to contain a dynamic graph with a changing edge set and weights . The feature set and node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric Data object. Between two temporal snapshots the edges, edge weights, target matrices and optionally passed attributes might change.
- Parameters
edge_indices (List of Numpy arrays) – List of edge index tensors.
edge_weights (List of Numpy arrays) – List of edge weight tensors.
features (List of Numpy arrays) – List of node feature tensors.
targets (List of Numpy arrays) – List of node label (target) tensors.
**kwargs (optional List of Numpy arrays) – List of additional attributes.
- class DynamicGraphStaticSignal(edge_indices: List[Optional[numpy.ndarray]], edge_weights: List[Optional[numpy.ndarray]], feature: Optional[numpy.ndarray], targets: List[Optional[numpy.ndarray]], **kwargs: List[numpy.ndarray])[source]¶
A data iterator object to contain a dynamic graph with a changing edge set and weights . The node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric Data object. Between two temporal snapshots the edges, edge weights, target matrices and optionally passed attributes might change.
- Parameters
edge_indices (List of Numpy arrays) – List of edge index tensors.
edge_weights (List of Numpy arrays) – List of edge weight tensors.
feature (Numpy array) – Node feature tensor.
targets (List of Numpy arrays) – List of node label (target) tensors.
**kwargs (optional List of Numpy arrays) – List of additional attributes.
Heterogeneous Temporal Signal Iterators¶
- class StaticHeteroGraphTemporalSignal(edge_index_dict: Optional[Dict[Tuple[str, str, str], numpy.ndarray]], edge_weight_dict: Optional[Dict[Tuple[str, str, str], numpy.ndarray]], feature_dicts: List[Optional[Dict[str, numpy.ndarray]]], target_dicts: List[Optional[Dict[str, numpy.ndarray]]], **kwargs: List[Optional[Dict[str, numpy.ndarray]]])[source]¶
A data iterator object to contain a static heterogeneous graph with a dynamically changing constant time difference temporal feature set (multiple signals). The node labels (target) are also temporal. The iterator returns a single constant time difference temporal snapshot for a time period (e.g. day or week). This single temporal snapshot is a Pytorch Geometric HeteroData object. Between two temporal snapshots the features and optionally passed attributes might change. However, the underlying graph is the same.
Note that in this example all feature and target dicts have the same keys.
To skip initializing nodes of all types in a specific snapshot simply pass
None
instead of a dictionary:
To skip initializing node features of type
"paper"
in a specific snapshot simply passNone
as dictionary value or omit this feature type:
- Parameters
edge_index_dict (Dictionary of keys=Tuples and values=Numpy arrays) – Relation type tuples and their edge index tensors.
edge_weight_dict (Dictionary of keys=Tuples and values=Numpy arrays) – Relation type tuples and their edge weight tensors.
feature_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their feature tensors.
target_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their label (target) tensors.
**kwargs (optional List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their additional attributes.
- class DynamicHeteroGraphTemporalSignal(edge_index_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dicts: List[Optional[Dict[str, numpy.ndarray]]], target_dicts: List[Optional[Dict[str, numpy.ndarray]]], **kwargs: List[Optional[Dict[str, numpy.ndarray]]])[source]¶
A data iterator object to contain a dynamic heterogeneous graph with a changing edge set and weights. The feature set and node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric HeteroData object. Between two temporal snapshots the edges, edge weights, target matrices and optionally passed attributes might change.
- Parameters
edge_index_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge index tensors.
edge_weight_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge weight tensors.
feature_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their feature tensors.
target_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their label (target) tensors.
**kwargs (optional List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their additional attributes.
- class DynamicHeteroGraphStaticSignal(edge_index_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dict: Optional[Dict[str, numpy.ndarray]], target_dicts: List[Optional[Dict[str, numpy.ndarray]]], **kwargs: List[Optional[Dict[str, numpy.ndarray]]])[source]¶
A data iterator object to contain a dynamic heterogeneous graph with a changing edge set and weights. The node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric HeteroData object. Between two temporal snapshots the edges, edge weights, target matrices and optionally passed attributes might change.
- Parameters
edge_index_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge index tensors.
edge_weight_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge weight tensors.
feature_dict (Dictionary of keys=Strings and values=Numpy arrays) – Node type tuples and their node feature tensor.
target_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their label (target) tensors.
**kwargs (optional List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their additional attributes.
Temporal Signal Batch Iterators¶
- class StaticGraphTemporalSignalBatch(edge_index: Optional[numpy.ndarray], edge_weight: Optional[numpy.ndarray], features: List[Optional[numpy.ndarray]], targets: List[Optional[numpy.ndarray]], batches: Optional[numpy.ndarray], **kwargs: List[numpy.ndarray])[source]¶
A data iterator object to contain a static graph with a dynamically changing constant time difference temporal feature set (multiple signals). The node labels (target) are also temporal. The iterator returns a single constant time difference temporal snapshot for a time period (e.g. day or week). This single temporal snapshot is a Pytorch Geometric Batch object. Between two temporal snapshots the feature matrix, target matrices and optionally passed attributes might change. However, the underlying graph is the same.
- Parameters
edge_index (Numpy array) – Index tensor of edges.
edge_weight (Numpy array) – Edge weight tensor.
features (List of Numpy arrays) – List of node feature tensors.
targets (List of Numpy arrays) – List of node label (target) tensors.
batches (Numpy array) – Batch index tensor.
**kwargs (optional List of Numpy arrays) – List of additional attributes.
- class DynamicGraphTemporalSignalBatch(edge_indices: List[Optional[numpy.ndarray]], edge_weights: List[Optional[numpy.ndarray]], features: List[Optional[numpy.ndarray]], targets: List[Optional[numpy.ndarray]], batches: List[Optional[numpy.ndarray]], **kwargs: List[numpy.ndarray])[source]¶
A data iterator object to contain a dynamic graph with a changing edge set and weights . The feature set and node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric Batch object. Between two temporal snapshots the edges, edge weights, the feature matrix, target matrices and optionally passed attributes might change.
- Parameters
edge_indices (List of Numpy arrays) – List of edge index tensors.
edge_weights (List of Numpy arrays) – List of edge weight tensors.
features (List of Numpy arrays) – List of node feature tensors.
targets (List of Numpy arrays) – List of node label (target) tensors.
batches (List of Numpy arrays) – List of batch index tensors.
**kwargs (optional List of Numpy arrays) – List of additional attributes.
- class DynamicGraphStaticSignalBatch(edge_indices: List[Optional[numpy.ndarray]], edge_weights: List[Optional[numpy.ndarray]], feature: Optional[numpy.ndarray], targets: List[Optional[numpy.ndarray]], batches: List[Optional[numpy.ndarray]], **kwargs: List[numpy.ndarray])[source]¶
A batch iterator object to contain a dynamic graph with a changing edge set and weights . The node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric Batch object. Between two temporal snapshots the edges, batch memberships, edge weights, target matrices and optionally passed attributes might change.
- Parameters
edge_indices (List of Numpy arrays) – List of edge index tensors.
edge_weights (List of Numpy arrays) – List of edge weight tensors.
feature (Numpy array) – Node feature tensor.
targets (List of Numpy arrays) – List of node label (target) tensors.
batches (List of Numpy arrays) – List of batch index tensors.
**kwargs (optional List of Numpy arrays) – List of additional attributes.
Heterogeneous Temporal Signal Batch Iterators¶
- class StaticHeteroGraphTemporalSignalBatch(edge_index_dict: Optional[Dict[Tuple[str, str, str], numpy.ndarray]], edge_weight_dict: Optional[Dict[Tuple[str, str, str], numpy.ndarray]], feature_dicts: List[Optional[Dict[str, numpy.ndarray]]], target_dicts: List[Optional[Dict[str, numpy.ndarray]]], batch_dict: Optional[Dict[str, numpy.ndarray]], **kwargs: List[Optional[Dict[str, numpy.ndarray]]])[source]¶
A data iterator object to contain a static heterogeneous graph with a dynamically changing constant time difference temporal feature set (multiple signals). The node labels (target) are also temporal. The iterator returns a single constant time difference temporal snapshot for a time period (e.g. day or week). This single temporal snapshot is a Pytorch Geometric Batch object. Between two temporal snapshots the feature matrix, target matrices and optionally passed attributes might change. However, the underlying graph is the same.
- Parameters
edge_index_dict (Dictionary of keys=Tuples and values=Numpy arrays) – Relation type tuples and their edge index tensors.
edge_weight_dict (Dictionary of keys=Tuples and values=Numpy arrays) – Relation type tuples and their edge weight tensors.
feature_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their feature tensors.
target_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their label (target) tensors.
batch_dict (Dictionary of keys=Strings and values=Numpy arrays) – Batch index tensor of each node type.
**kwargs (optional List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their additional attributes.
- class DynamicHeteroGraphTemporalSignalBatch(edge_index_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dicts: List[Optional[Dict[str, numpy.ndarray]]], target_dicts: List[Optional[Dict[str, numpy.ndarray]]], batch_dicts: List[Optional[Dict[str, numpy.ndarray]]], **kwargs: List[Optional[Dict[str, numpy.ndarray]]])[source]¶
A data iterator object to contain a dynamic heterogeneous graph with a changing edge set and weights. The feature set and node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric HeteroData Batch object. Between two temporal snapshots the edges, edge weights, the feature matrix, target matrices and optionally passed attributes might change.
- Parameters
edge_index_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge index tensors.
edge_weight_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge weight tensors.
feature_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their feature tensors.
target_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their label (target) tensors.
batch_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of batch index tensor for each node type.
**kwargs (optional List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their additional attributes.
- class DynamicHeteroGraphStaticSignalBatch(edge_index_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: List[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dict: Optional[Dict[str, numpy.ndarray]], target_dicts: List[Optional[Dict[str, numpy.ndarray]]], batch_dicts: List[Optional[Dict[str, numpy.ndarray]]], **kwargs: List[Optional[Dict[str, numpy.ndarray]]])[source]¶
A batch iterator object to contain a dynamic heterogeneous graph with a changing edge set and weights . The node labels (target) are also dynamic. The iterator returns a single discrete temporal snapshot for a time period (e.g. day or week). This single snapshot is a Pytorch Geometric Batch object. Between two temporal snapshots the edges, batch memberships, edge weights, target matrices and optionally passed attributes might change.
- Parameters
edge_index_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge index tensors.
edge_weight_dicts (List of dictionaries where keys=Tuples and values=Numpy arrays) – List of relation type tuples and their edge weight tensors.
feature_dict (Dictionary of keys=Strings and values=Numpy arrays) – Node type tuples and their node feature tensor.
target_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their label (target) tensors.
batch_dicts (List of dictionaries where keys=Strings and values=Numpy arrays) – List of batch index tensor for each node type.
**kwargs (optional List of dictionaries where keys=Strings and values=Numpy arrays) – List of node types and their additional attributes.
Temporal Signal Train-Test Split¶
Function to split a data iterator according to a fixed ratio.
- Arg types:
data_iterator (Signal Iterator) - Node features.
train_ratio (float) - Graph edge indices.
- Return types:
(train_iterator, test_iterator) (tuple of Signal Iterators) - Train and test data iterators.