Hi haltaha!



 haltaha:

I need to use a rank-based correlation (Spearman’s Correlation) to compute my loss.


Presumably you will use your “loss” to train your network with
backpropagation by calling loss.backward().
Because the ranks of your data values are discrete integers, the
Spearman’s-rank-correlation loss you propose calculating will not
be (usefully) differentiable, so you will not be able to backpropagate
nor train.


    x, y = rankmin(x), rankmin(y)



You don’t show us the code for rankmin(), but presumably buried
in there somewhere is a non-differentiable call that returns the indices
for the sorted values of x (sometimes referred to as argsort()).
Best.
K. Frank