spamosaic.architectures.wlgcn
Weighted Light graph convolution (WLGCN) layers for SpaMosaic.
Implements a parameter-free propagation layer on pre-normalized sparse adjacencies and an MLP head for embedding + reconstruction.
- class spamosaic.architectures.wlgcn.HEAD(*args: Any, **kwargs: Any)[source]
Bases:
ModuleMLP head that outputs an L2-normalized embedding and reconstructs input features.
- Parameters:
input_size (int) – Input feature dimension.
output_size (int) – Embedding dimension.
dec_l (int, default=1) – Number of decoder layers (
1= linear decoder).hidden_size (int, default=512) – Hidden size of the MLP trunk.
dropout (float, default=0.2) – Dropout rate.
slope (float, default=0.2) – Negative slope for LeakyReLU.
- class spamosaic.architectures.wlgcn.WLGCN_vanilla(*args: Any, **kwargs: Any)[source]
Bases:
ModuleParameter-free LightGCN-style propagation.
Accepts a precomputed normalized sparse adjacency \(\hat{A} \approx D^{-1/2}(A + I\cdot\text{fill})D^{-1/2}\) as a
torch_sparse.SparseTensor.- Parameters:
K (int, default=1) – Number of propagation steps (returns
K+1representations including the 0-th order input).agg ({'cat', 'sum', 'mean'}, default='cat') – How to aggregate representations across steps.
- forward(x: torch.Tensor, A_hat: torch_sparse.SparseTensor) torch.Tensor[source]
Propagate features via
A_hatforKsteps and aggregate.- Parameters:
x (torch.Tensor) – Node features of shape
[N, F].A_hat (torch_sparse.SparseTensor) – Pre-normalized sparse adjacency on the correct device.
- Returns:
Aggregated output. Shapes depend on
agg: -'cat'→[N, F * (K+1)]-'sum'→[N, F]-'mean'→[N, F]- Return type:
torch.Tensor
Classes
MLP head that outputs an L2-normalized embedding and reconstructs input features. |
|
Parameter-free LightGCN-style propagation. |