dgld.models.SLGAD.SL_GAD_utils

dgld.models.SLGAD.SL_GAD_utils.get_subargs(args)[source]
dgld.models.SLGAD.SL_GAD_utils.loss_fun(pos_scores, neg_scores, criterion, device)

The function to compute loss function of Bayesian personalized ranking

Parameters
  • pos_scores (Tensor.tensor) – anomaly score of postive subgraph

  • neg_scores (Torch.tensor) – anomaly score of negative subgrph

  • criterion (torch.nn.Functions) – functions to compute loss

  • device (string) – device of computation

Returns

L – loss

Return type

Torch.tensor

dgld.models.SLGAD.SL_GAD_utils.loss_fun_BCE(pos_scores, neg_scores, criterion, device)[source]

The function to compute loss function of Bayesian personalized ranking

Parameters
  • pos_scores (Tensor.tensor) – anomaly score of postive subgraph

  • neg_scores (Torch.tensor) – anomaly score of negative subgrph

  • criterion (torch.nn.Functions) – functions to compute loss

  • device (string) – device of computation

Returns

L – loss

Return type

Torch.tensor

dgld.models.SLGAD.SL_GAD_utils.loss_fun_BPR(pos_scores, neg_scores, criterion, device)[source]

The function to compute loss function of Bayesian personalized ranking

Parameters
  • pos_scores (Tensor.tensor) – anomaly score of postive subgraph

  • neg_scores (Torch.tensor) – anomaly score of negative subgrph

  • criterion (torch.nn.Functions) – functions to compute loss

  • device (string) – device of computation

Returns

L – loss

Return type

Torch.tensor

dgld.models.SLGAD.SL_GAD_utils.set_subargs(parser)[source]
dgld.models.SLGAD.SL_GAD_utils.test_epoch(epoch, args, loader, net, device, criterion, optimizer)[source]

The function to train

Parameters
  • epoch (int) – the number of epoch to train

  • loader (GraphDataLoader) – get subgraph set

  • net (class) – model

  • device (string) – device of computation

  • criterion (torch.nn.Functions) – functions to compute loss

  • optimizer (optim.Adam) – optimizer to adjust model

Returns

predict_scores – anomaly scores of anchor nodes

Return type

Torch.tensor

dgld.models.SLGAD.SL_GAD_utils.train_epoch(epoch, args, loader, net, device, criterion, optimizer)[source]

The function to train

Parameters
  • epoch (int) – the number of epoch to train

  • loader (GraphDataLoader) – get subgraph set

  • net (class) – model

  • device (string) – device of computation

  • criterion (torch.nn.Functions) – functions to compute loss

  • optimizer (optim.Adam) – optimizer to adjust model

Returns

L – loss

Return type

Torch.tensor