optax.projections.projection_box

Contents

optax.projections.projection_box#

optax.projections.projection_box(tree: Any, lower: Any, upper: Any) Any[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}\]

where \(x\) is the input tree.

Parameters:
  • tree โ€“ tree to project.

  • lower โ€“ lower bound, a scalar or tree with the same structure as tree.

  • upper โ€“ upper bound, a scalar or tree with the same structure as tree.

Returns:

projected tree, with the same structure as tree.