GOOD.networks.models.DIRGNN

The implementation of Discovering Invariant Rationales for Graph Neural Networks.

Functions

clear_masks(model)

Adopted from https://github.com/wuyxin/dir-gnn.

relabel(x, edge_index, batch[, pos])

Adopted from https://github.com/wuyxin/dir-gnn.

set_masks(mask, model)

Adopted from https://github.com/wuyxin/dir-gnn.

sparse_sort(src, index[, dim, descending, eps])

Adopted from https://github.com/rusty1s/pytorch_scatter/issues/48.

sparse_topk(src, index, ratio[, dim, ...])

Sparse topk calculation.

split_batch(g)

Adopted from https://github.com/wuyxin/dir-gnn.

split_graph(data, edge_score, ratio)

Adapted from https://github.com/wuyxin/dir-gnn.

GOOD.networks.models.DIRGNN.clear_masks(model: Module)[source]

Adopted from https://github.com/wuyxin/dir-gnn.

GOOD.networks.models.DIRGNN.relabel(x, edge_index, batch, pos=None)[source]

Adopted from https://github.com/wuyxin/dir-gnn.

GOOD.networks.models.DIRGNN.set_masks(mask: Tensor, model: Module)[source]

Adopted from https://github.com/wuyxin/dir-gnn.

GOOD.networks.models.DIRGNN.sparse_sort(src: Tensor, index: Tensor, dim=0, descending=False, eps=1e-12)[source]

Adopted from https://github.com/rusty1s/pytorch_scatter/issues/48.

GOOD.networks.models.DIRGNN.sparse_topk(src: Tensor, index: Tensor, ratio: float, dim=0, descending=False, eps=1e-12)[source]

Sparse topk calculation.

GOOD.networks.models.DIRGNN.split_batch(g)[source]

Adopted from https://github.com/wuyxin/dir-gnn.

GOOD.networks.models.DIRGNN.split_graph(data, edge_score, ratio)[source]

Adapted from https://github.com/wuyxin/dir-gnn.

Classes

CausalAttNet(causal_ratio, config, **kwargs)

Causal Attention Network adapted from https://github.com/wuyxin/dir-gnn.

DIRGIN(config)

DIRvGIN(config)

The GIN virtual node version of DIR.

DIRvGINNB(config)

The GIN virtual node without batchnorm version of DIR.

class GOOD.networks.models.DIRGNN.CausalAttNet(causal_ratio, config, **kwargs)[source]

Bases: Module

Causal Attention Network adapted from https://github.com/wuyxin/dir-gnn.

forward(*args, **kwargs)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class GOOD.networks.models.DIRGNN.DIRGIN(config: Union[CommonArgs, Munch])[source]

Bases: GNNBasic

forward(*args, **kwargs)[source]

The DIR model implementation.

Parameters
  • *args (list) – argument list for the use of arguments_read. Refer to arguments_read

  • **kwargs (dict) – key word arguments for the use of arguments_read. Refer to arguments_read

Returns (Tensor):

Label predictions and other results for loss calculations.

class GOOD.networks.models.DIRGNN.DIRvGIN(config: Union[CommonArgs, Munch])[source]

Bases: DIRGIN

The GIN virtual node version of DIR.

class GOOD.networks.models.DIRGNN.DIRvGINNB(config: Union[CommonArgs, Munch])[source]

Bases: DIRGIN

The GIN virtual node without batchnorm version of DIR.