tfmri.math.project_onto_simplex

project_onto_simplex(x, radius=1.0, name=None)[source]

Projects an input vector onto the simplex.

Parameters
  • x – A tf.Tensor of shape [..., n].

  • radius

    A scalar tf.Tensor. Must have type x.dtype.real_dtype. The radius of the circumscribed circle of the simplex, or the distance to the vertices. Defaults to 1.

  • name – A str. The name of this operation.

Returns

A tf.Tensor of shape [..., n] and dtype equal to x.dtype.

Raises

ValueError – If inputs are invalid.

References

1

Duchi, J., Shalev-Shwartz, S., Singer, Y., & Chandra, T. (2008). Efficient projections onto the l1-ball for learning in high dimensions. In Proceedings of the 25th International Conference on Machine Learning (pp. 272-279).