optax.projections.projection_hypercube

optax.projections.projection_hypercube#

optax.projections.projection_hypercube(tree: Any, scale: Any = 1) Any[source]#

Projection onto the (unit) hypercube.

\[\underset{p}{\text{argmin}} ~ \|x - p\|_2^2 \quad \textrm{subject to} \quad 0 \le p \le \text{scale}\]

where \(x\) is the input tree.

By default, we project to the unit hypercube (scale=1).

This is a convenience wrapper around projection_box.

Parameters:
  • tree โ€“ tree to project.

  • scale โ€“ scale of the hypercube, a scalar or a tree (default: 1).

Returns:

projected tree, with the same structure as tree.