AttentiveFP
¶
AttentiveFP(
in_channels: int,
hidden_channels: int,
out_channels: int,
edge_dim: int,
num_layers: int,
num_timesteps: int,
dropout: float = 0.0,
)
Bases: Module
The Attentive FP model for molecular representation learning from the "Pushing the Boundaries of Molecular Representation for Drug Discovery with the Graph Attention Mechanism" paper, based on graph attention mechanisms.
Atom embeddings are updated by graph attention layers (a
GATEConv using the bond features, then
GATConv layers) followed by GRU cells; the
molecule embedding is then refined for num_timesteps steps by
attending over the atoms of the molecule (a GAT layer from the atoms to a
virtual molecule node, followed by a GRU cell).
The model follows PyG's AttentiveFP
(same arguments, parameters and initialization).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
Size of each input sample. |
required |
hidden_channels
|
int
|
Hidden node feature dimensionality. |
required |
out_channels
|
int
|
Size of each output sample. |
required |
edge_dim
|
int
|
Edge feature dimensionality. |
required |
num_layers
|
int
|
Number of GNN layers. |
required |
num_timesteps
|
int
|
Number of iterative refinement steps for global readout. |
required |
dropout
|
float
|
Dropout probability. Default: |
0.0
|
Example:
import mlx.core as mx
from mlx_graphs.nn import AttentiveFP
model = AttentiveFP(
in_channels=9, hidden_channels=64, out_channels=1, edge_dim=3,
num_layers=2, num_timesteps=2,
)
x = mx.random.normal((5, 9))
edge_index = mx.array([[0, 1, 1, 2, 3, 4], [1, 0, 2, 1, 4, 3]])
edge_features = mx.random.normal((6, 3))
batch_indices = mx.array([0, 0, 0, 1, 1])
model(x, edge_index, edge_features, batch_indices).shape
>>> (2, 1)
Methods:
| Name | Description |
|---|---|
__call__ |
Predicts the target properties of each molecule. |
Source code in mlx_graphs/nn/models/attentive_fp.py
__call__
¶
__call__(
node_features: array,
edge_index: array,
edge_features: array,
batch_indices: Optional[array] = None,
) -> array
Predicts the target properties of each molecule.
The arguments are in PyG's order (x, edge_index, edge_attr, batch).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features
|
array
|
Atom features, of shape |
required |
edge_index
|
array
|
Bonds, of shape |
required |
edge_features
|
array
|
Bond features, of shape |
required |
batch_indices
|
Optional[array]
|
Molecule of each atom, of shape |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The predictions, of shape |
Source code in mlx_graphs/nn/models/attentive_fp.py
from mlx_graphs.nn import AttentiveFP · mlx_graphs/nn/models/attentive_fp.py