cogdl.data.data
¶
Module Contents¶
Classes¶
A plain old python object modeling a single graph with various |
-
class
cogdl.data.data.
Data
(x=None, edge_index=None, edge_attr=None, y=None, pos=None)[source]¶ Bases:
object
A plain old python object modeling a single graph with various (optional) attributes:
- Args:
- x (Tensor, optional): Node feature matrix with shape :obj:`[num_nodes,
num_node_features]`. (default:
None
)- edge_index (LongTensor, optional): Graph connectivity in COO format
with shape
[2, num_edges]
. (default:None
)- edge_attr (Tensor, optional): Edge feature matrix with shape
[num_edges, num_edge_features]
. (default:None
)- y (Tensor, optional): Graph or node targets with arbitrary shape.
(default:
None
)- pos (Tensor, optional): Node position matrix with shape
[num_nodes, num_dimensions]
. (default:None
)
The data object is not restricted to these attributes and can be extented by any other additional data.
-
__iter__
(self)[source]¶ Iterates over all present attributes in the data, yielding their attribute names and content.
-
__call__
(self, *keys)[source]¶ Iterates over all attributes
*keys
in the data, yielding their attribute names and content. If*keys
is not given this method will iterative over all present attributes.
-
cat_dim
(self, key, value)[source]¶ Returns the dimension in which the attribute
key
with contentvalue
gets concatenated when creating batches.Note
This method is for internal use only, and should only be overridden if the batch concatenation process is corrupted for a specific data attribute.
-
__inc__
(self, key, value)[source]¶ “Returns the incremental count to cumulatively increase the value of the next attribute of
key
when creating batches.Note
This method is for internal use only, and should only be overridden if the batch concatenation process is corrupted for a specific data attribute.
-
is_coalesced
(self)[source]¶ Returns
True
, if edge indices are ordered and do not contain duplicate entries.
-
apply
(self, func, *keys)[source]¶ Applies the function
func
to all attributes*keys
. If*keys
is not given,func
is applied to all present attributes.
-
contiguous
(self, *keys)[source]¶ Ensures a contiguous memory layout for all attributes
*keys
. If*keys
is not given, all present attributes are ensured to have a contiguous memory layout.