rllm.nn.models.RECT_L¶
- class rllm.nn.models.RECT_L(in_dim: int, hidden_dim: int, dropout: float = 0.0)[source]¶
Bases:
ModuleThe RECT model, or more specifically its supervised part RECT-L, from the “Network Embedding with Completely-imbalanced Labels” paper. In particular, a GCN model is trained that reconstructs semantic class knowledge.
- Parameters:
in_dim (int) – Size of each input sample.
hidden_dim (int) – Intermediate size of each sample.
dropout (float, optional) – The dropout probability. (default:
0.0)
Example
>>> import torch >>> model = RECT_L(in_dim=16, hidden_dim=8) >>> x = torch.randn(4, 16) >>> adj = torch.tensor([[0, 1, 2], [1, 2, 3]]) >>> model(x, adj).shape torch.Size([4, 16])
- embed(x: Tensor, adj: Tensor)[source]¶
Compute hidden embeddings without gradient updates.
- Parameters:
x (Tensor) – Input node features.
adj (Tensor) – Graph connectivity.
- Returns:
Hidden node embeddings.
- Return type:
Tensor
- forward(x: Tensor, adj: Tensor)[source]¶
Encode node features and reconstruct semantic targets.
- Parameters:
x (Tensor) – Input node features.
adj (Tensor) – Graph connectivity.
- Returns:
Reconstructed output features.
- Return type:
Tensor
- get_semantic_labels(x: Tensor, y: Tensor, mask: Tensor)[source]¶
Replace labels with corresponding class-center embeddings.
- Parameters:
x (Tensor) – Node embeddings.
y (Tensor) – Class labels.
mask (Tensor) – Mask selecting labeled nodes.
- Returns:
Class-center embeddings for labeled nodes.
- Return type:
Tensor