spamosaic.architectures.wlgcn

class spamosaic.architectures.wlgcn.WLGCN(*args: Any, **kwargs: Any)[source]

Bases: Module

Deep WLGCN with encoder-decoder structure for representation learning.

Parameters:
  • input_size (int) – Input feature dimension.

  • output_size (int) – Output embedding dimension.

  • K (int, optional) – Number of GCN propagation steps (default: 8).

  • dec_l (int, optional) – Number of layers in the decoder (1 or 2). Default is 1.

  • hidden_size (int, optional) – Hidden layer size for encoder. Default is 512.

  • dropout (float, optional) – Dropout rate. Default is 0.2.

  • slope (float, optional) – LeakyReLU negative slope. Default is 0.2.

forward(feature, edge_index, edge_weight=None)[source]

Forward pass of the WLGCN model.

Parameters:
  • feature (torch.Tensor) – Input node features of shape (N, F).

  • edge_index (torch.Tensor) – Edge indices in COO format.

  • edge_weight (torch.Tensor or None) – Optional edge weights.

Returns:

  • Normalized latent embeddings.

  • Reconstructed input features.

Return type:

Tuple[torch.Tensor, torch.Tensor]

class spamosaic.architectures.wlgcn.WLGCN_vanilla(*args: Any, **kwargs: Any)[source]

Bases: MessagePassing

Vanilla Weighted Light Graph Convolutional Network (WLGCN) layer.

This layer performs K steps of message passing and returns a concatenated representation of all intermediate embeddings.

Parameters:
  • K (int, optional) – Number of propagation steps. Default is 1.

  • cached (bool, optional) – Not used; for compatibility.

  • bias (bool, optional) – Not used; for compatibility.

forward(x: torch.Tensor, edge_index: torch.Tensor, edge_weight: Optional[torch.Tensor] = None)[source]

Forward pass for WLGCN_vanilla.

Parameters:
  • x (torch.Tensor) – Input node features of shape (N, F).

  • edge_index (torch.Tensor) – Edge indices in COO format.

  • edge_weight (torch.Tensor or None) – Optional edge weights.

Returns:

Concatenated output features from all propagation steps.

Return type:

torch.Tensor

message(x_j, norm)[source]
spamosaic.architectures.wlgcn.sym_norm(edge_index: torch.Tensor, num_nodes: int, edge_weight: Optional[Union[Any, torch.Tensor]] = None, improved: Optional[bool] = False, dtype: Optional[Any] = None) List[source]

Compute the symmetric normalized adjacency matrix with optional edge weights.

Parameters:
  • edge_index (torch.Tensor) – The edge indices of the graph (2, num_edges).

  • num_nodes (int) – Number of nodes in the graph.

  • edge_weight (torch.Tensor, optional) – Edge weights corresponding to edge_index. If None, assumes unweighted graph.

  • improved (bool, optional) – Whether to use improved self-loops (value=2 instead of 1). Default is False.

  • dtype (torch.dtype, optional) – Data type for the output tensor.

Returns:

  • edge_index (torch.Tensor) – Edge indices with added self-loops.

  • norm (torch.Tensor) – Normalized edge weights.

Functions

spamosaic.architectures.wlgcn.sym_norm

Compute the symmetric normalized adjacency matrix with optional edge weights.

Classes

spamosaic.architectures.wlgcn.WLGCN

Deep WLGCN with encoder-decoder structure for representation learning.

spamosaic.architectures.wlgcn.WLGCN_vanilla

Vanilla Weighted Light Graph Convolutional Network (WLGCN) layer.