data

class cogdl.data.Adjacency(row=None, col=None, row_ptr=None, weight=None, attr=None, num_nodes=None, types=None, **kwargs)[source]

Bases: cogdl.data.data.BaseGraph

add_remaining_self_loops()[source]
clone()[source]
col_norm()[source]
convert_csr()[source]
degrees(node_idx=None)[source]
property device
property edge_index
static from_dict(dictionary)[source]

Creates a data object from a python dictionary.

generate_normalization(norm='sym')[source]
get_weight(indicator=None)[source]

If indicator is not None, the normalization will not be implemented

is_symmetric()[source]
property keys

Returns all names of graph attributes.

normalize_adj(norm='sym')[source]
property num_edges
property num_nodes
padding_self_loops()[source]
random_walk(seeds, length=1, restart_p=0.0)[source]
remove_self_loops()[source]
property row_indptr
row_norm()[source]
property row_ptr_v
set_symmetric(val)[source]
set_weight(weight)[source]
sym_norm()[source]
to_networkx(weighted=True)[source]
to_scipy_csr()[source]
class cogdl.data.Batch(batch=None, **kwargs)[source]

Bases: cogdl.data.data.Graph

A plain old python object modeling a batch of graphs as one big (dicconnected) graph. With cogdl.data.Data being the base class, all its methods can also be used here. In addition, single graphs can be reconstructed via the assignment vector batch, which maps each node to its respective graph identifier.

cumsum(key, item)[source]

If True, the attribute key with content item should be added up cumulatively before concatenated together.

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.

static from_data_list(data_list, class_type=None)[source]

Constructs a batch object from a python list holding cogdl.data.Data objects. The assignment vector batch is created on the fly. Additionally, creates assignment batch vectors for each key in follow_batch.

property num_graphs

Returns the number of graphs in the batch.

class cogdl.data.DataLoader(*args, **kwargs)[source]

Bases: Generic[torch.utils.data.dataloader.T_co]

Data loader which merges data objects from a cogdl.data.dataset to a mini-batch.

Parameters
  • dataset (Dataset) – The dataset from which to load the data.

  • batch_size (int, optional) – How may samples per batch to load. (default: 1)

  • shuffle (bool, optional) – If set to True, the data will be reshuffled at every epoch (default: True)

batch_size: Optional[int]
static collate_fn(batch)[source]
dataset: torch.utils.data.dataset.Dataset[torch.utils.data.dataloader.T_co]
drop_last: bool
get_parameters()[source]
num_workers: int
pin_memory: bool
prefetch_factor: int
record_parameters(params)[source]
sampler: torch.utils.data.sampler.Sampler
timeout: float
class cogdl.data.Dataset(root, transform=None, pre_transform=None, pre_filter=None)[source]

Bases: Generic[torch.utils.data.dataset.T_co]

Dataset base class for creating graph datasets.

Parameters
  • root (string) – Root directory where the dataset should be saved.

  • transform (callable, optional) – A function/transform that takes in an cogdl.data.Data object and returns a transformed version. The data object will be transformed before every access. (default: None)

  • pre_transform (callable, optional) – A function/transform that takes in an cogdl.data.Data object and returns a transformed version. The data object will be transformed before being saved to disk. (default: None)

  • pre_filter (callable, optional) – A function that takes in an cogdl.data.Data object and returns a boolean value, indicating whether the data object should be included in the final dataset. (default: None)

static add_args(parser)[source]

Add dataset-specific arguments to the parser.

download()[source]

Downloads the dataset to the self.raw_dir folder.

property edge_attr_size
get(idx)[source]

Gets the data object at index idx.

get_evaluator()[source]
get_loss_fn()[source]
property max_degree
property max_graph_size
property num_classes

The number of classes in the dataset.

property num_features

Returns the number of features per node in the graph.

property num_graphs
process()[source]

Processes the dataset to the self.processed_dir folder.

property processed_file_names

The name of the files to find in the self.processed_dir folder in order to skip the processing.

property processed_paths

The filepaths to find in the self.processed_dir folder in order to skip the processing.

property raw_file_names

The name of the files to find in the self.raw_dir folder in order to skip the download.

property raw_paths

The filepaths to find in order to skip the download.

class cogdl.data.Graph(x=None, y=None, **kwargs)[source]

Bases: cogdl.data.data.BaseGraph

add_remaining_self_loops()[source]
clone()[source]
property col_indices
col_norm()[source]
csr_subgraph(node_idx, keep_order=False)[source]
degrees()[source]
property device
property edge_attr
property edge_index
edge_subgraph(edge_idx, require_idx=True)[source]
property edge_types
property edge_weight

Return actual edge_weight

eval()[source]
static from_dict(dictionary)[source]

Creates a data object from a python dictionary.

static from_pyg_data(data)[source]
property in_norm
is_inductive()[source]
is_symmetric()[source]
property keys

Returns all names of graph attributes.

local_graph()[source]
mask2nid(split)[source]
nodes()[source]
normalize(key='sym')[source]
property num_classes
property num_edges

Returns the number of edges in the graph.

property num_features

Returns the number of features per node in the graph.

property num_nodes
property out_norm
padding_self_loops()[source]
random_walk(seeds, max_nodes_per_seed, restart_p=0.0)[source]
random_walk_with_restart(seeds, max_nodes_per_seed, restart_p=0.0)[source]
property raw_edge_weight

Return edge_weight without __in_norm__ and __out_norm__, only used for SpMM

remove_self_loops()[source]
restore(key)[source]
property row_indptr
row_norm()[source]
sample_adj(batch, size=- 1, replace=True)[source]
set_asymmetric()[source]
set_grb_adj(adj)[source]
set_symmetric()[source]
store(key)[source]
subgraph(node_idx, keep_order=False)[source]
sym_norm()[source]
property test_nid
to_networkx()[source]
to_scipy_csr()[source]
train()[source]
property train_nid
property val_nid
class cogdl.data.MultiGraphDataset(root=None, transform=None, pre_transform=None, pre_filter=None)[source]

Bases: Generic[torch.utils.data.dataset.T_co]

get(idx)[source]

Gets the data object at index idx.

len()[source]
property max_degree
property max_graph_size
property num_classes

The number of classes in the dataset.

property num_features

Returns the number of features per node in the graph.

property num_graphs
cogdl.data.batch_graphs(graphs)[source]