predictions = np.array(y_pred)
predictions = np.argsort(predictions, -1)
ranks = []
for i in range(predictions.shape[0]):
for j in range(predictions.shape[1]):
if predictions[i][j] in np.arange(labels[i][j]):
ranks.append(j)
After Change
@register_metric("rank_response")
def rank_response(y_true, y_pred):
num_examples = float(len(y_pred))
predictions = np.array(y_pred)
predictions = np.flip(np.argsort(predictions, -1), -1)
rank_tot = 0
for el in predictions: