dense_mincut_pool
¶
dense_mincut_pool(
adj: array,
node_features: array,
s: array,
mask: Optional[array] = None,
temp: float = 1.0,
) -> Tuple[array, array, array, array]
The MinCut pooling operator from the "Spectral Clustering in Graph Neural Networks for Graph Pooling" paper.
based on the dense learned assignments \(\mathbf{S} \in \mathbb{R}^{B \times N \times C}\). Also returns the MinCut loss
where \(\mathbf{D}\) is the degree matrix, and the orthogonality loss
As in PyG, the returned adjacency has a zero diagonal and is symmetrically normalized by its degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adj
|
array
|
Adjacency matrices of shape |
required |
node_features
|
array
|
Node features of shape |
required |
s
|
array
|
Assignment logits of shape |
required |
mask
|
Optional[array]
|
Optional boolean mask of shape |
None
|
temp
|
float
|
Temperature of the softmax. Default: |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[array, array, array, array]
|
A tuple |
Example:
import mlx.core as mx
from mlx_graphs.nn import dense_mincut_pool
adj = (mx.random.uniform(shape=(2, 10, 10)) > 0.7).astype(mx.float32)
x = mx.random.normal((2, 10, 16))
s = mx.random.normal((2, 10, 3))
x, adj, mincut_loss, ortho_loss = dense_mincut_pool(adj, x, s)
Source code in mlx_graphs/nn/pooling/dense_pool.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
from mlx_graphs.nn import dense_mincut_pool · mlx_graphs/nn/pooling/dense_pool.py