jaxmat.nn.icnn package#
Input-convex neural networks.
Convexity comes from non-negative hidden-to-hidden weights combined with a convex non-decreasing activation. Monotonicity is a separate property, coming from the sign of the input skip weights, and it is a property of each input rather than of the network:
an input entering through an affine feature (\(\mathrm{tr}\,\varepsilon\), \(M:\varepsilon\), \(J\), …) needs an unconstrained skip so that its coefficient is free in sign;
an input entering through a nonlinear convex feature (\(\|P_\alpha:\varepsilon\|^2\), \(I_4\), \(I_5^*\), …) needs a non-negative skip, otherwise the convex-of-convex composition is no longer convex.
Hence monotone accepts a per-input mask. When in doubt use
monotone=True: it is the conservative choice, preserving the convexity
certificate of the composite at the cost of some expressiveness.
- class ICNN[source]#
Bases:
_ConvexBaseInput-convex neural network (Amos et al., 2017), with skip connections.
\[z_1 = \sigma(U_0 x + b_0), \qquad z_{k+1} = \sigma(W_k^+ z_k + U_k x + b_k), \qquad f = w^+ \cdot z_L + u \cdot x\]- Parameters:
in_dim (int) – Number of inputs.
0is accepted and treated as1.hidden_dims (Sequence[int]) – Hidden layer widths.
key (jax.Array) – PRNG key.
scale (float, optional) – Target output magnitude at initialization (default 1.0). Held roughly constant across both width and depth.
monotone (bool | Sequence[bool], optional) – Whether
fmust be non-decreasing in each input.True(default) constrains every skip weight; a sequence gives a per-input mask.positive ({"softplus", "exp", "square"}, optional) – Reparametrization enforcing non-negative weights.
activation (callable, optional) – Must be convex and non-decreasing.
softplus(default) is smooth, which matters whenever second derivatives are needed: a ReLU network is piecewise linear and its Hessian vanishes almost everywhere, so it cannot supply a meaningful tangent operator.init_std (float, optional) – Relative spread of the random initialization (default 0.1).
Notes
The first layer carries no
Wterm: applying a non-negativeWto the raw input would force monotonicity in the first layer regardless of the skip weights.-
activation:
Callable#
-
Ws:
list[Array]#
-
Us:
list[Array]#
-
final_W:
Array#
-
final_U:
Array#
-
bs:
list[Array]#
- class ICNNSkip[source]#
Bases:
ICNNDeprecated alias of
ICNN, which now always has skip connections.
- class PolyhedralICNN[source]#
Bases:
_ConvexBaseConvex polyhedral gauge \(g(x)\).
Suitable for polyhedral yield functions and rate-independent dissipation potentials. Architecture is built from ICN dropping the biases and using a positively 1-homogeneous activation, here ReLU.
- Parameters:
monotone (bool | Sequence[bool], optional) – Default
False:
Warning
ReLU makes the gauge polytopal. It cannot reproduce curved boundaries exactly. Use for that the more general
GaugeICNN.-
Ws:
list[Array]#
-
Us:
list[Array]#
-
final_W:
Array#