is anything wrong with this,
let us assume we have a 3x3 matrix, like
1 2 3
4 5 6
7 8 9

now we want to learn an integer threshold, and want to zero out elements that fall below this threshold,
let us assume that final target matrix is
0 0 0
0 5 6
7 8 9

so, we want neural network to learn that 5 is the threshold.
we initialize the threshold to be a random integer, let us say 8, and also specify that this integer would be in a range [1-9], so task is to update this 8 till neural network learns that 5 is the threshold.
if we represent each of these discrete values that this threshold could take, as a vector, something like
1 -> [0.1, 0.4, -0.5, 0.9, 0.02]
2 -> [0.01, 0.04, 0.3, -0.5, 0.4]

and so on, for [3-9]
and then assign a score to them, based on scalar dot product (sdp) with other vectors, and difference between them, so
1 -> [0.1, 0.4, -0.5, 0.9, 0.02] -> sum(sdp of 1 with [1-9] * difference between vectors 1 with [1-9]) -> score = 0.5
2 -> [0.01, 0.04, 0.3, -0.5, 0.4] -> sum(sdp of 2 with [1-9] * difference between vectors 1 with [1-9]) -> score = 0.2
3 -> [...] -> sum(sdp of 3 with [1-9] * difference between vectors 1 with [1-9]) -> score = 0.8

one example to get score for number 3 would be,
score_3 = (vector_3)*(vector_1)*abs(vector_3 - vector_1)
+ (vector_3)*(vector_2)*abs(vector_3 - vector_2)
+ (vector_3)*(vector_3)*abs(vector_3 - vector_3)
...
+ (vector_3)*(vector_9)*abs(vector_3 - vector_9)

the number with highest score would be our expected threshold, the task of neural network is to update these weights within each of these continuous vectors by gradient based approach, till high score is obtained for expected threshold.
so after one training iteration, suppose we get high score for number 7, then we get a matrix like
0 0 0
0 0 0
7 8 9

we compare this matrix with our target, and find a loss, which would be high, so we go for more iterations, till we get threshold as 5.