jaxopt.projection.projection_box

jaxopt.projection.projection_box(x, hyperparams)[source]

Projection onto box constraints:

\[\underset{p}{\text{argmin}} ~ ||x - p||_2^2 \quad \textrm{subject to} \quad \text{lower} \le p \le \text{upper}\]
Parameters
  • x (Any) – pytree to project.

  • hyperparams (Tuple) – a tuple hyperparams = (lower, upper), where lower and upper can be either scalar values or pytrees of the same structure as x.

Return type

Any

Returns

projected pytree, with the same structure as x.