GOOD.networks.models.GILGNNs

Implementation of the GIL algorithm from “Learning Invariant Graph Representations for Out-of-Distribution Generalization”.

Functions

clear_masks(model)

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

set_masks(mask, model)

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

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

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

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

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

Classes

BatchSequential()

ExtractorMLP(config)

GILGIN(config)

GILvGIN(config)

The GIN virtual node version of GSAT.

MLP(channels, dropout[, bias])

class GOOD.networks.models.GILGNNs.BatchSequential(*args: Module)[source]
class GOOD.networks.models.GILGNNs.BatchSequential(arg: OrderedDict[str, Module])

Bases: Sequential

forward(inputs, batch)[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.GILGNNs.ExtractorMLP(config: Union[CommonArgs, Munch])[source]

Bases: Module

forward(emb, edge_index, batch)[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.GILGNNs.GILGIN(config: Union[CommonArgs, Munch])[source]

Bases: GNNBasic

control_sparsity(mask, top_t=None)[source]
Parameters
  • mask – mask that need to transform

  • top_t – sparsity we need to control i.e. 0.7, 0.5

Returns

transformed mask where top 1 - sparsity values are set to inf.

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

The GIL 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.GILGNNs.GILvGIN(config: Union[CommonArgs, Munch])[source]

Bases: GILGIN

The GIN virtual node version of GSAT.

class GOOD.networks.models.GILGNNs.MLP(channels, dropout, bias=True)[source]

Bases: BatchSequential