MLP¶
-
class MLP : public madspace::FunctionGenerator¶
Fully 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)
Public Types
Public Functions
-
MLP(std::size_t input_dim, std::size_t output_dim, std::size_t hidden_dim = 32, std::size_t layers = 3, Activation activation = leaky_relu, const std::string &prefix = "")¶
- 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.
-
inline std::size_t input_dim() const¶
Input width.
-
inline std::size_t output_dim() const¶
Output width.
-
void initialize_globals(ContextPtr context, std::optional<std::uint64_t> seed = std::nullopt) const¶
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.
-
inline std::string last_layer_bias_name() const¶
Global name of the final layer’s bias vector.
-
std::vector<std::string> global_names() const¶
Global names of all trainable parameters.