Logo
  • Installation
  • Introduction
  • Citing
  • Data Structures
    • Data Classes
    • Benchmark Datasets
    • Node Splitting
    • Edge Splitting
  • Real-World Data Set Descriptions
    • Directed Unsigned Real-World Data Sets
    • Signed Real-World Data Sets
  • Case Study Examples
    • Case Study on Signed Networks
    • Case Study on Directed Networks
  • External Resources
    • External Resources - Architectures
    • External Resources - Synthetic Data Generators
    • External Resources - Real-World Data Sets
  • PyTorch Geometric Signed Directed Models
    • Directed (Unsigned) Network Models and Layers
    • Signed (Directed) Network Models and Layers
    • Auxiliary Methods and Layers
  • PyTorch Geometric Signed Directed Data Generators and Data Loaders
    • Data Classes
    • Data Generators
    • Data Loaders
  • PyTorch Geometric Signed Directed Utils
    • Task-Specific Objectives and Evaluation Methods
    • Utilities and Preprocessing Methods
PyTorch Geometric Signed Directed
  • torch_geometric_signed_directed.utils.signed.link_sign_loss
  • View page source

torch_geometric_signed_directed.utils.signed.link_sign_loss

Classes

Sign_Triangle_Loss

An implementation of the Signed Triangle Loss used in

Sign_Direction_Loss

An implementation of the Signed Direction Loss used in

Sign_Product_Entropy_Loss

An implementation of the Signed Entropy Loss used in

Link_Sign_Product_Loss

An implementation of the Product Loss used in

Link_Sign_Entropy_Loss

An implementation of the Entropy Loss used in

Sign_Structure_Loss

Module Contents

class Sign_Triangle_Loss(emb_dim: int, edge_weight: scipy.sparse.csc_matrix)

Bases: torch.nn.Module

An implementation of the Signed Triangle Loss used in

“SDGNN: Learning Node Representation for Signed Directed Networks” paper.

Parameters:

emb_dim (int) – The embedding size.

lin
edge_weight
forward(z: torch.Tensor, pos_edge_index: torch.LongTensor, neg_edge_index: torch.LongTensor) → torch.Tensor
class Sign_Direction_Loss(emb_dim: int)

Bases: torch.nn.Module

An implementation of the Signed Direction Loss used in

“SDGNN: Learning Node Representation for Signed Directed Networks” paper.

Parameters:

emb_dim (int) – The embedding size.

score_function1
score_function2
forward(z: torch.Tensor, pos_edge_index: torch.LongTensor, neg_edge_index: torch.LongTensor) → torch.Tensor
class Sign_Product_Entropy_Loss

Bases: torch.nn.Module

An implementation of the Signed Entropy Loss used in “SDGNN: Learning Node Representation for Signed Directed Networks” paper.

forward(z: torch.Tensor, pos_edge_index: torch.LongTensor, neg_edge_index: torch.LongTensor) → torch.Tensor
class Link_Sign_Product_Loss

Bases: torch.nn.Module

An implementation of the Product Loss used in the “Signed Graph Attention Networks” paper.

forward(z: torch.Tensor, pos_edge_index: torch.LongTensor, neg_edge_index: torch.LongTensor) → torch.Tensor
class Link_Sign_Entropy_Loss(emb_dim: int)

Bases: torch.nn.Module

An implementation of the Entropy Loss used in the “Signed Graph Convolutional Network” paper. and “Learning Signed Network Embedding via Graph Attention” paper

Parameters:

emb_dim (int) – The embedding size.

lin
reset_parameters()
discriminate(z: torch.Tensor, edge_index: torch.LongTensor) → torch.FloatTensor

Given node embeddings z, classifies the link relation between node pairs edge_index to be either positive, negative or non-existent.

Parameters:
  • x (Tensor) – The input node features.

  • edge_index (LongTensor) – The edge indices.

forward(z: torch.Tensor, pos_edge_index: torch.LongTensor, neg_edge_index: torch.LongTensor) → torch.Tensor

Computes the discriminator loss based on node embeddings z, and positive edges pos_edge_index and negative edges neg_edge_index.

Parameters:
  • z (Tensor) – The node embeddings.

  • pos_edge_index (LongTensor) – The positive edge indices.

  • neg_edge_index (LongTensor) – The negative edge indices.

class Sign_Structure_Loss

Bases: torch.nn.Module

forward(z: torch.Tensor, pos_edge_index: torch.LongTensor, neg_edge_index: torch.LongTensor) → torch.Tensor
pos_embedding_loss(z: torch.Tensor, pos_edge_index: torch.LongTensor) → torch.Tensor

Computes the triplet loss between positive node pairs and sampled non-node pairs.

Parameters:
  • z (Tensor) – The node embeddings.

  • pos_edge_index (LongTensor) – The positive edge indices.

neg_embedding_loss(z: torch.Tensor, neg_edge_index: torch.LongTensor) → torch.Tensor

Computes the triplet loss between negative node pairs and sampled non-node pairs.

Parameters:
  • z (Tensor) – The node embeddings.

  • neg_edge_index (LongTensor) – The negative edge indices.


© Copyright 2026, Yixuan He.

Built with Sphinx using a theme provided by Read the Docs.