MCPcopy Create free account
hub / github.com/HazyResearch/butterfly / project_simplex

Function project_simplex

learning_transforms/sparsemax.py:15–31  ·  view source on GitHub ↗

Project a vector v onto the simplex. That is, return argmin_w ||w - v||^2 where w >= 0 elementwise and sum(w) = z. Parameters: v: Tensor of shape (batch_size, n) z: real number Return: Projection of v on the simplex, along the last dimension: (batch_size, n)

(v, z=1.0)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 1

forwardMethod · 0.85

Calls 1

argmaxMethod · 0.45

Tested by

no test coverage detected