GCN_reweight(in_channels, out_channels, aggr, improved=False, cached=False, add_self_loops=False, normalize=True, bias=True, **kwargs)
Bases: MessagePassing
Graph Convolutional Network with edge reweighting mechanism.
| Parameters: |
|
|---|
forward(x, edge_index, edge_weight, lmda)
Forward pass of the reweighted GCN layer.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
-
Edge Weight Processing:
- Store original weights as reweighting values
- Initialize base weights as ones
-
Normalization (if enabled):
- Compute symmetric normalization if not cached
- Use cached values if available
- Handle both dense and sparse formats
-
Feature Transformation:
- Linear projection of input features
- Message passing with interpolated weights
- Optional bias addition
message(x_j, edge_index, edge_weight, edge_rw, lmda)
Compute messages from source nodes with edge reweighting.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Computes messages with interpolated weights
- Handles both normalized and original edge weights
message_and_aggregate(adj_t, x)
Fused message computation and aggregation for sparse tensors.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Optimized sparse matrix multiplication
- Uses specified aggregation method (sum, mean, etc.)
- More efficient than separate message and aggregation
GS_reweight(in_channels, out_channels, reducer, normalize_embedding=False)
Bases: MessagePassing
GraphSAGE with edge reweighting mechanism.
| Parameters: |
|
|---|
Notes
- Two-layer transformation (neighbor + self)
- Edge weight interpolation
- Optional embedding normalization
forward(x, edge_index, edge_weight, lmda)
Forward pass of the reweighted GraphSAGE layer.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Initiates message passing with proper graph size information
message(x_j, edge_index, edge_weight, lmda)
Compute messages from source nodes with edge reweighting.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
-
Linear transformation of source features
-
Interpolation between:
- Transformed features (weight: 1-λ)
- Edge-weighted features (weight: λ)
update(aggr_out, x)
Update node embeddings using aggregated messages and self-features.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Concatenate aggregated messages with self-features
- Apply learnable transformation
- Non-linear activation (ReLU)
- Optional L2 normalization
ReweightGNN(input_dim, gnn_dim, output_dim, cls_dim, gnn_layers=3, cls_layers=2, backbone='GS', pooling='mean', dropout=0.5, bn=False, rw_lmda=1.0, **kwargs)
Bases: Module
Multi-layer GNN with edge reweighting mechanism.
| Parameters: |
|
|---|
Notes
- Multiple GNN layers with reweighting
- Optional batch normalization
- Multi-layer classification head
- Dropout regularization
forward(data, h)
Forward pass of the network.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- GNN propagation with reweighting
- Activation and dropout
- Classification MLP
- Optional batch normalization
spmm(src, other, reduce='sum')
Sparse matrix multiplication with dense matrix.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Supports different sparse formats and reduction operations