SVDFeatureReduction
¶
SVDFeatureReduction(out_channels: int)
Bases: BaseTransform
Reduces the dimension of the node features with a Singular Value
Decomposition, as PyG's SVDFeatureReduction.
If the node features \(\mathbf{X}\) have more than out_channels
columns, they are replaced by \(\mathbf{U}_{:, :k}
\mathrm{diag}(\mathbf{S}_{:k})\), where \(\mathbf{X} = \mathbf{U}
\mathrm{diag}(\mathbf{S}) \mathbf{V}^\top\) and \(k\) is
out_channels. The SVD is computed on the host with NumPy. Singular
vectors are only defined up to their sign, so columns may have the
opposite sign of PyG's.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_channels
|
int
|
Number of node features after the reduction. |
required |
Example:
graph = GraphData(
edge_index=mx.array([[0, 1], [1, 2]]),
node_features=mx.random.normal((3, 8)),
)
graph = SVDFeatureReduction(2)(graph)
graph.node_features.shape
# (3, 2)
Methods:
| Name | Description |
|---|---|
process |
Reduces the node features of |
Source code in mlx_graphs/transforms/spectral.py
process
¶
Reduces the node features of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph with the reduced |
Source code in mlx_graphs/transforms/spectral.py
from mlx_graphs.transforms import SVDFeatureReduction · mlx_graphs/transforms/spectral.py