GOOD.networks.models.DANNs

GIN and GIN-virtual implementation of the DANN algorithm from “Domain-Adversarial Training of Neural Networks” paper

Classes

DANN_GIN(config)

The Graph Neural Network modified from the "Domain-Adversarial Training of Neural Networks" paper and "How Powerful are Graph Neural Networks?" paper.

DANN_vGIN(config)

The Graph Neural Network modified from the "Domain-Adversarial Training of Neural Networks" paper and "Neural Message Passing for Quantum Chemistry" paper.

GradientReverseLayerF(*args, **kwargs)

Gradient reverse layer for DANN algorithm.

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

Bases: GNNBasic

The Graph Neural Network modified from the “Domain-Adversarial Training of Neural Networks” paper and “How Powerful are Graph Neural Networks?” paper.

Parameters

config (Union[CommonArgs, Munch]) – munchified dictionary of args (config.model.dim_hidden, config.model.model_layer, config.dataset.num_envs, config.dataset.dim_node, config.dataset.num_classes, config.dataset.dataset_type, config.model.dropout_rate)

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

The DANN-GIN 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, domain predictions]

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

Bases: DANN_GIN

The Graph Neural Network modified from the “Domain-Adversarial Training of Neural Networks” paper and “Neural Message Passing for Quantum Chemistry” paper.

Parameters

config (Union[CommonArgs, Munch]) – munchified dictionary of args (config.model.dim_hidden, config.model.model_layer, config.dataset.dim_node, config.dataset.num_envs, config.dataset.num_classes, config.dataset.dataset_type, config.model.dropout_rate)

class GOOD.networks.models.DANNs.GradientReverseLayerF(*args, **kwargs)[source]

Bases: Function

Gradient reverse layer for DANN algorithm.

static backward(ctx, grad_output)[source]

gradient backpropagation step

Parameters
  • ctx (object) – object of the GradientReverseLayerF class

  • grad_output (Tensor) – raw backpropagation gradient

Returns (Tensor):

backpropagation gradient

static forward(ctx, x, alpha)[source]

gradient forward propagation

Parameters
  • ctx (object) – object of the GradientReverseLayerF class

  • x (Tensor) – feature representations

  • alpha (float) – the GRL learning rate

Returns (Tensor):

feature representations