pub fn sparsemap_explicit(
theta: &[f64],
vertices: &[Vec<f64>],
) -> Result<SparseMapPrediction>Expand description
Compute SparseMAP over an explicit list of vertices.
Given scores theta and vertices v_j, this solves:
argmax_mu <theta, mu> - 0.5 ||mu||^2
where mu is in conv({v_j})Equivalently, it projects theta onto the convex hull of the supplied
vertices. For standard-basis vertices this recovers sparsemax.
The explicit implementation is bounded to small domains
(MAX_EXPLICIT_VERTICES) because it is the seed prototype for the
structured-oracle API, not a graph or sequence decoder.
ยงErrors
Returns Error::EmptyInput when theta or vertices is empty,
Error::LengthMismatch when a vertex has the wrong dimension, and
Error::InvalidWeights when values are non-finite or the explicit vertex
limit is exceeded.