pydgn.model

model.dgn

model.readout

model.interface

class pydgn.model.interface.ModelInterface(dim_node_features: int, dim_edge_features: int, dim_target: int, readout_class: Callable[[...], torch.nn.modules.module.Module], config: dict)

Bases: torch.nn.modules.module.Module

Provides the signature for any main model to be trained under PyDGN

Parameters
  • dim_node_features (int) – dimension of node features (according to the DatasetInterface property)

  • dim_edge_features (int) – dimension of edge features (according to the DatasetInterface property)

  • dim_target (int) – dimension of the target (according to the DatasetInterface property)

  • readout_class (Callable[…,:class:torch.nn.Module]) – class of the module implementing the readout. This is optional, but useful to put different readouts to try in the config file

  • config (dict) – config dictionary containing all the necessary hyper-parameters plus additional information (if needed)

forward(data: torch_geometric.data.batch.Batch) Tuple[torch.Tensor, Optional[torch.Tensor], Optional[List[object]]]

Performs a forward pass over a batch of graphs

Parameters

data (torch_geometric.data.Batch) – a batch of graphs

Returns

a tuple (model’s output, [optional] node embeddings, [optional] additional outputs

training: bool
class pydgn.model.interface.ReadoutInterface(dim_node_features: int, dim_edge_features: int, dim_target: int, config: dict)

Bases: torch.nn.modules.module.Module

Provides the signature for any readout to be trained under PyDGN

Parameters
  • dim_node_features (int) – dimension of node features (according to the DatasetInterface property)

  • dim_edge_features (int) – dimension of edge features (according to the DatasetInterface property)

  • dim_target (int) – dimension of the target (according to the DatasetInterface property)

  • config (dict) – config dictionary containing all the necessary hyper-parameters plus additional information (if needed)

forward(node_embeddings: None._VariableFunctionsClass.tensor, batch: torch.Tensor, **kwargs) Tuple[torch.Tensor, Optional[torch.Tensor], Optional[List[object]]]

Performs a forward pass over a batch of graphs

Parameters
  • node_embeddings (torch_geometric.data.Batch) – the node embeddings

  • batch (torch.Tensor) – the usual batch object of PyG

  • kwargs (dict) – additional and optional arguments

Returns

a tuple (model’s output, [optional] node embeddings, [optional] additional outputs

training: bool