DenseGCNConv
¶
DenseGCNConv(
node_features_dim: int,
out_features_dim: int,
improved: bool = False,
bias: bool = True,
)
Bases: Module
Dense version of GCNConv.
where \(\hat{\mathbf{A}}\) is adj whose diagonal is set to 1 (2 if
improved) when add_loop is True, and \(\hat{\mathbf{D}}\)
its degree matrix (degrees are clamped to at least 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
int
|
Size of the input node features. |
required |
out_features_dim
|
int
|
Size of the output node features. |
required |
improved
|
bool
|
Whether the self-loops have a weight of 2 instead of 1.
Default: |
False
|
bias
|
bool
|
Whether to add a bias. Default: |
True
|
Example:
import mlx.core as mx
from mlx_graphs.nn import DenseGCNConv
conv = DenseGCNConv(16, 32)
adj = (mx.random.uniform(shape=(2, 10, 10)) > 0.7).astype(mx.float32)
node_features = mx.random.normal((2, 10, 16))
>>> conv(adj, node_features).shape
(2, 10, 32)
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the node embeddings. |
Source code in mlx_graphs/nn/conv/dense_conv.py
__call__
¶
__call__(
adj: array,
node_features: array,
mask: Optional[array] = None,
add_loop: bool = True,
) -> array
Computes the node embeddings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adj
|
array
|
Adjacency matrices of shape |
required |
node_features
|
array
|
Node features of shape |
required |
mask
|
Optional[array]
|
Optional boolean mask of shape |
None
|
add_loop
|
bool
|
Whether to set the diagonal of |
True
|
Returns:
| Type | Description |
|---|---|
array
|
The node embeddings, of shape `[batch_size, num_nodes, |
array
|
out_features_dim]`. |
Source code in mlx_graphs/nn/conv/dense_conv.py
from mlx_graphs.nn import DenseGCNConv · mlx_graphs/nn/conv/dense_conv.py