MLP¶
- class madspace.MLP(self: madspace._madspace_py.MLP, input_dim: SupportsInt, output_dim: SupportsInt, hidden_dim: SupportsInt = 32, layers: SupportsInt = 3, activation: madspace._madspace_py.MLP.Activation = <Activation.leaky_relu: 1>, prefix: str = '')¶
Bases:
FunctionGeneratorFully connected neural network as a compute-graph function.
A stack of
layersdense layers of widthhidden_dimwithactivationbetween them and a linear output layer. Used as the subnetwork of the Flow and DiscreteFlow adaptive samplers [1]. The weights and biases are compute-graph globals named withprefix. Callinitialize_globals(context)once before use.batchis the leading batch dimension.Arguments
input–float, shape(batch, input_dim)– the network input.
Returns
output–float, shape(batch, output_dim)– the network output.
References
[1] T. Heimel, O. Mattelaer, R. Winterhalder, “MadSpace”, https://arxiv.org/abs/2602.06895 (Sec. 3.2.2)
- Parameters:
input_dim – Input width.
output_dim – Output width.
hidden_dim – Hidden-layer width.
layers – Number of layers.
activation – Activation between the hidden layers.
prefix – Prefix for the trainable global names.
- class Activation(*args, **kwargs)¶
Bases:
pybind11_objectMembers:
relu
leaky_relu
elu
gelu
sigmoid
softplus
linear
Overloaded function.
__init__(self: madspace._madspace_py.MLP.Activation, value: typing.SupportsInt) -> None
__init__(self: madspace._madspace_py.MLP.Activation, name: str) -> None
- elu = <Activation.elu: 2>¶
- gelu = <Activation.gelu: 3>¶
- leaky_relu = <Activation.leaky_relu: 1>¶
- linear = <Activation.linear: 6>¶
- MLP.Activation.name -> str
- relu = <Activation.relu: 0>¶
- sigmoid = <Activation.sigmoid: 4>¶
- softplus = <Activation.softplus: 5>¶
- property value¶
- elu = <Activation.elu: 2>¶
- gelu = <Activation.gelu: 3>¶
- global_names(self: madspace._madspace_py.MLP) list[str]¶
Global names of all trainable parameters.
- initialize_globals(self: madspace._madspace_py.MLP, context: madspace._madspace_py.Context, seed: SupportsInt | None = None) None¶
Register the network’s trainable parameters on
context.- Parameters:
context – Context receiving the globals.
seed – Seed for the random initialization. If unset (the default), the initialization is non-deterministic.
- input_dim(self: madspace._madspace_py.MLP) int¶
Input width.
- last_layer_bias_name(self: madspace._madspace_py.MLP) str¶
Global name of the final layer’s bias vector.
- leaky_relu = <Activation.leaky_relu: 1>¶
- linear = <Activation.linear: 6>¶
- output_dim(self: madspace._madspace_py.MLP) int¶
Output width.
- relu = <Activation.relu: 0>¶
- sigmoid = <Activation.sigmoid: 4>¶
- softplus = <Activation.softplus: 5>¶