entmax | R Documentation |
With alpha = 1.5 and normalizing sparse transform (a la softmax).
entmax(dim = -1)
entmax15(dim = -1L, k = NULL)
dim |
The dimension along which to apply 1.5-entmax. |
k |
The number of largest elements to partial-sort input over. For optimal
performance, should be slightly bigger than the expected number of
non-zeros in the solution. If the solution is more than k-sparse,
this function is recursively called with a 2*k schedule. If |
Solves the optimization problem:
\max_p <input, P> - H_{1.5}(P) \text{ s.t. } P \geq 0, \sum(P) == 1
where H_{1.5}(P)
is the Tsallis alpha-entropy with \alpha=1.5
.
The projection result P of the same shape as input, such that
\sum_{dim} P = 1 \forall dim
elementwise.
## Not run:
input <- torch::torch_randn(10,5, requires_grad = TRUE)
# create a top3 alpha=1.5 entmax on last input dimension
nn_entmax <- entmax15(dim=-1L, k = 3)
result <- nn_entmax(input)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.