torch_geometric_signed_directed.utils.signed.link_sign_loss
Classes
An implementation of the Signed Triangle Loss used in |
|
An implementation of the Signed Direction Loss used in |
|
An implementation of the Signed Entropy Loss used in |
|
An implementation of the Product Loss used in |
|
An implementation of the Entropy Loss used in |
|
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.ModuleAn 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.ModuleAn 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.ModuleAn 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 pairsedge_indexto 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 edgespos_edge_indexand negative edgesneg_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.