PyTorch Geometric Temporal Signal¶
Contents
Temporal Signal Iterators¶
- class StaticGraphTemporalSignal(edge_index: Optional[numpy.ndarray], edge_weight: Optional[numpy.ndarray], features: Sequence[Optional[numpy.ndarray]], targets: Sequence[Optional[numpy.ndarray]], **kwargs: Sequence[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 (Sequence of Numpy arrays) – Sequence of node feature tensors.
targets (Sequence of Numpy arrays) – Sequence of node label (target) tensors.
**kwargs (optional Sequence of Numpy arrays) – Sequence of additional attributes.
- class DynamicGraphTemporalSignal(edge_indices: Sequence[Optional[numpy.ndarray]], edge_weights: Sequence[Optional[numpy.ndarray]], features: Sequence[Optional[numpy.ndarray]], targets: Sequence[Optional[numpy.ndarray]], **kwargs: Sequence[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 (Sequence of Numpy arrays) – Sequence of edge index tensors.
edge_weights (Sequence of Numpy arrays) – Sequence of edge weight tensors.
features (Sequence of Numpy arrays) – Sequence of node feature tensors.
targets (Sequence of Numpy arrays) – Sequence of node label (target) tensors.
**kwargs (optional Sequence of Numpy arrays) – Sequence of additional attributes.
- class DynamicGraphStaticSignal(edge_indices: Sequence[Optional[numpy.ndarray]], edge_weights: Sequence[Optional[numpy.ndarray]], feature: Optional[numpy.ndarray], targets: Sequence[Optional[numpy.ndarray]], **kwargs: Sequence[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 (Sequence of Numpy arrays) – Sequence of edge index tensors.
edge_weights (Sequence of Numpy arrays) – Sequence of edge weight tensors.
feature (Numpy array) – Node feature tensor.
targets (Sequence of Numpy arrays) – Sequence of node label (target) tensors.
**kwargs (optional Sequence of Numpy arrays) – Sequence 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: Sequence[Optional[Dict[str, numpy.ndarray]]], target_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], **kwargs: Sequence[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 (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their feature tensors.
target_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their label (target) tensors.
**kwargs (optional Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their additional attributes.
- class DynamicHeteroGraphTemporalSignal(edge_index_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], target_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], **kwargs: Sequence[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 (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence of relation type tuples and their edge index tensors.
edge_weight_dicts (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence of relation type tuples and their edge weight tensors.
feature_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their feature tensors.
target_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their label (target) tensors.
**kwargs (optional Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their additional attributes.
- class DynamicHeteroGraphStaticSignal(edge_index_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dict: Optional[Dict[str, numpy.ndarray]], target_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], **kwargs: Sequence[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 (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence of relation type tuples and their edge index tensors.
edge_weight_dicts (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence 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 (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their label (target) tensors.
**kwargs (optional Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their additional attributes.
Temporal Signal Batch Iterators¶
- class StaticGraphTemporalSignalBatch(edge_index: Optional[numpy.ndarray], edge_weight: Optional[numpy.ndarray], features: Sequence[Optional[numpy.ndarray]], targets: Sequence[Optional[numpy.ndarray]], batches: Optional[numpy.ndarray], **kwargs: Sequence[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 (Sequence of Numpy arrays) – Sequence of node feature tensors.
targets (Sequence of Numpy arrays) – Sequence of node label (target) tensors.
batches (Numpy array) – Batch index tensor.
**kwargs (optional Sequence of Numpy arrays) – Sequence of additional attributes.
- class DynamicGraphTemporalSignalBatch(edge_indices: Sequence[Optional[numpy.ndarray]], edge_weights: Sequence[Optional[numpy.ndarray]], features: Sequence[Optional[numpy.ndarray]], targets: Sequence[Optional[numpy.ndarray]], batches: Sequence[Optional[numpy.ndarray]], **kwargs: Sequence[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 (Sequence of Numpy arrays) – Sequence of edge index tensors.
edge_weights (Sequence of Numpy arrays) – Sequence of edge weight tensors.
features (Sequence of Numpy arrays) – Sequence of node feature tensors.
targets (Sequence of Numpy arrays) – Sequence of node label (target) tensors.
batches (Sequence of Numpy arrays) – Sequence of batch index tensors.
**kwargs (optional Sequence of Numpy arrays) – Sequence of additional attributes.
- class DynamicGraphStaticSignalBatch(edge_indices: Sequence[Optional[numpy.ndarray]], edge_weights: Sequence[Optional[numpy.ndarray]], feature: Optional[numpy.ndarray], targets: Sequence[Optional[numpy.ndarray]], batches: Sequence[Optional[numpy.ndarray]], **kwargs: Sequence[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 (Sequence of Numpy arrays) – Sequence of edge index tensors.
edge_weights (Sequence of Numpy arrays) – Sequence of edge weight tensors.
feature (Numpy array) – Node feature tensor.
targets (Sequence of Numpy arrays) – Sequence of node label (target) tensors.
batches (Sequence of Numpy arrays) – Sequence of batch index tensors.
**kwargs (optional Sequence of Numpy arrays) – Sequence 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: Sequence[Optional[Dict[str, numpy.ndarray]]], target_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], batch_dict: Optional[Dict[str, numpy.ndarray]], **kwargs: Sequence[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 (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their feature tensors.
target_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence 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 Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their additional attributes.
- class DynamicHeteroGraphTemporalSignalBatch(edge_index_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], target_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], batch_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], **kwargs: Sequence[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 (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence of relation type tuples and their edge index tensors.
edge_weight_dicts (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence of relation type tuples and their edge weight tensors.
feature_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their feature tensors.
target_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their label (target) tensors.
batch_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of batch index tensor for each node type.
**kwargs (optional Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their additional attributes.
- class DynamicHeteroGraphStaticSignalBatch(edge_index_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], edge_weight_dicts: Sequence[Optional[Dict[Tuple[str, str, str], numpy.ndarray]]], feature_dict: Optional[Dict[str, numpy.ndarray]], target_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], batch_dicts: Sequence[Optional[Dict[str, numpy.ndarray]]], **kwargs: Sequence[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 (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence of relation type tuples and their edge index tensors.
edge_weight_dicts (Sequence of dictionaries where keys=Tuples and values=Numpy arrays) – Sequence 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 (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of node types and their label (target) tensors.
batch_dicts (Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence of batch index tensor for each node type.
**kwargs (optional Sequence of dictionaries where keys=Strings and values=Numpy arrays) – Sequence 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.