MLP
¶
MLP(
dims: List[int],
dropout: float = 0.0,
act: Activation = "relu",
norm: Normalization = None,
plain_last: bool = True,
bias: bool = True,
)
Bases: Module
Multi-layer perceptron.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dims
|
List[int]
|
Sizes of the input, of every hidden layer and of the output,
e.g. |
required |
dropout
|
float
|
Dropout probability applied after each hidden layer.
Default: |
0.0
|
act
|
Activation
|
Activation applied after each hidden layer: a name ( |
'relu'
|
norm
|
Normalization
|
Normalization applied after each hidden layer: |
None
|
plain_last
|
bool
|
If |
True
|
bias
|
bool
|
Whether the linear layers have a bias. Default: |
True
|
Example:
import mlx.core as mx
from mlx_graphs.nn import MLP
mlp = MLP([16, 64, 64, 2], dropout=0.5, norm="batch")
>>> mlp(mx.random.normal((10, 16))).shape
(10, 2)
Source code in mlx_graphs/nn/models/basic_gnn.py
from mlx_graphs.nn import MLP · mlx_graphs/nn/models/basic_gnn.py