MLP#
- class fl_sim.models.MLP(dim_in: int, dim_out: int, dim_hidden: int | Sequence[int] | None = None, activation: str | Sequence[str] = 'relu', dropout: float | Sequence[float] = 0.2, ndim: int = 2)[source]#
Bases:
Sequential
,CLFMixin
,SizeMixin
,DiffMixin
Multi-layer perceptron.
can be used for
logistic regression (for classification) using cross entropy loss (CrossEntropyLoss, BCEWithLogitsLoss, etc)
regression (for regression) using MSE loss
SVM (for classification) using hinge loss (MultiMarginLoss, MultiLabelMarginLoss, etc)
etc.
- Parameters:
dim_in (int) – Number of input features.
dim_out (int) – Number of output features.
dim_hidden (int or List[int], optional) – Number of hidden features. If is None, then no hidden layer.
activation (str or List[str], default "relu") – Activation function(s) for hidden layers.
dropout (float or List[float], default 0.2) – Dropout rate(s) for hidden layers.
ndim (int, default 2) – Number of dimensions of input data. 2 for image data, 1 for sequence data, 0 for vectorized data.