waxmorph.jax.mlp.MLP#
- class waxmorph.jax.mlp.MLP(input_dim, output_dim, hidden_dim=128, num_layers=2, activation='silu', layer_norm=True, *, key)[source]#
Bases:
ModuleMLP with optional LayerNorm on its output.
num_layerscounts linear maps; one layer is affine. Hidden layers supportrelu,silu,gelu, andtanh. Callers must supply a PRNGkey; independent modules need independently split keys.- Raises:
TypeError – If
num_layersis boolean or nonintegral.ValueError – If
num_layers < 1or the activation is unsupported.
- Parameters:
Examples
>>> mlp = MLP(3, 2, hidden_dim=4, num_layers=1, layer_norm=False, key=jax.random.PRNGKey(0)) >>> print(tuple(mlp(jnp.ones((5, 3))).shape)) (5, 2)