Differentiable normalize K-max function

98 Views Asked by At

Is there any differentiable function exists that for a given vector a [1,2,3,4,5,6,7,8,9,10] and parameter k=4 produce a vector like this:

output = [0, 0, 0, 0, 0.01, 0.01, 0.8, 0.9 ,1.09 ,1.19]
sum(output)= 4

The maximum value of each entries is 4 and the minimum is 0. The values can be anything between 0 to 4.

The things that I need is very similar to k-winner-take-all with following constraint:

sum(output) = k

Any pointer/reference for such mathematic functions is appreciated.