class pygod.nn.GAANBase(in_dim, noise_dim, hid_dim=64, num_layers=4, dropout=0.0, act=<function relu>, **kwargs)[source]

Bases: Module

Generative Adversarial Attributed Network Anomaly Detection

GAAN is a generative adversarial attribute network anomaly detection framework, including a generator module, an encoder module, a discriminator module, and uses anomaly evaluation measures that consider sample reconstruction error and real sample recognition confidence to make predictions. This model is transductive only.

See [CLW+20] for details.

  • in_dim (int) – Input dimension of the node features.

  • noise_dim (int, optional) – Input dimension of the Gaussian random noise. Defaults: 16.

  • hid_dim (int, optional) – Hidden dimension of model. Default: 64.

  • num_layers (int, optional) – Total number of layers in model. A half (floor) of the layers are for the generator, the other half (ceil) of the layers are for encoder. Default: 4.

  • dropout (float, optional) – Dropout rate. Default: 0..

  • act (callable activation function or None, optional) – Activation function if not None. Default: torch.nn.functional.relu.

  • **kwargs – Other parameters for the backbone.

forward(x, noise)[source]

Forward computation.


  • x_ (torch.Tensor) – Reconstructed node features.

  • a (torch.Tensor) – Reconstructed adjacency matrix from real samples.

  • a_ (torch.Tensor) – Reconstructed adjacency matrix from fake samples.

static process_graph(data)[source]

Obtain the dense adjacency matrix of the graph.


data ( – Input graph.