InnerProductDecoder
¶
Bases: Module
The inner product decoder from the "Variational Graph Auto-Encoders" paper.
where \(\mathbf{Z} \in \mathbb{R}^{N \times d}\) denotes the latent space produced by the encoder.
Example:
import mlx.core as mx
from mlx_graphs.nn import InnerProductDecoder
decoder = InnerProductDecoder()
z = mx.random.normal((5, 16))
edge_index = mx.array([[0, 1, 2], [1, 2, 3]])
>>> decoder(edge_index, z).shape
(3,)
>>> decoder.forward_all(z).shape
(5, 5)
Methods:
| Name | Description |
|---|---|
__call__ |
Decodes the latent variables |
forward_all |
Decodes the latent variables |
__call__
¶
__call__(edge_index: array, z: array, sigmoid: bool = True) -> array
Decodes the latent variables z into edge probabilities for the
node pairs of edge_index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Node pairs to score, of shape |
required |
z
|
array
|
The latent space \(\mathbf{Z}\), shape |
required |
sigmoid
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
array
|
One probability (or logit) per pair, shape |
Source code in mlx_graphs/nn/models/autoencoder.py
forward_all
¶
forward_all(z: array, sigmoid: bool = True) -> array
Decodes the latent variables z into a dense adjacency matrix of
probabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
array
|
The latent space \(\mathbf{Z}\), shape |
required |
sigmoid
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
array
|
An array of shape |
Source code in mlx_graphs/nn/models/autoencoder.py
from mlx_graphs.nn import InnerProductDecoder · mlx_graphs/nn/models/autoencoder.py