data.data

Module Contents

Classes

Data

A plain old python object modeling a single graph with various

class 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.

static from_dict(dictionary)[source]

Creates a data object from a python dictionary.

__getitem__(self, key)[source]

Gets the data of the attribute key.

__setitem__(self, key, value)[source]

Sets the attribute key to value.

property keys(self)[source]

Returns all names of graph attributes.

__len__(self)[source]

Returns the number of all present attributes.

__contains__(self, key)[source]

Returns True, if the attribute key is present in the 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 content value 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.

property num_edges(self)[source]

Returns the number of edges in the graph.

property num_features(self)[source]

Returns the number of features per node in the graph.

property num_nodes(self)[source]
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.

to(self, device, *keys)[source]

Performs tensor dtype and/or device conversion to all attributes *keys. If *keys is not given, the conversion is applied to all present attributes.

cuda(self, *keys)[source]
clone(self)[source]
__repr__(self)[source]

Return repr(self).