Skip to content

Commit

Permalink
fix: negative stride error from scoring (#86)
Browse files Browse the repository at this point in the history
* fix: add .copy() when creating tensors from np array

* chore: deleted duplicate logs
  • Loading branch information
mediumsizeworkingdog authored and karootplx committed Dec 9, 2024
1 parent 23669b7 commit 50c86c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions commons/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ def _reward_cubic(
# shape: (num_miners,)
# number range [-1, 1]
x = F.cosine_similarity(
torch.from_numpy(miner_outputs), torch.from_numpy(ground_truth), dim=1
torch.from_numpy(miner_outputs.copy()),
torch.from_numpy(ground_truth.copy()),
dim=1,
).numpy()

# Convert nans to -1 to send it to the bottom
x = np.where(np.isnan(x), -1, x)

Expand Down Expand Up @@ -411,7 +414,6 @@ def ground_truth_score_V1(
)

miner_outputs = miner_outputs_normalised
logger.debug(f"scoring: raw miner outputs with nans\n{miner_outputs}")

# use minmax scale to ensure ground truth is in the range [0, 1]
ground_truth_arr = minmax_scale(
Expand All @@ -423,7 +425,6 @@ def ground_truth_score_V1(
# after minmax scale: [0, 0.33, 0.667, 1]
# but we want the reverse, so: [1, 0.667, 0.33, 0], since cid1 is the best
ground_truth_arr = ground_truth_arr[::-1]
logger.debug(f"scoring: ground truth\n{ground_truth_arr}")

logger.info(f"scoring: Miner outputs\n{miner_outputs}")
logger.info(f"scoring: Ground truth\n{ground_truth_arr}")
Expand Down Expand Up @@ -455,7 +456,7 @@ def ground_truth_score_V1(
logger.debug(f"scoring: error calculating segment sums: {e}")
pass

return torch.from_numpy(cubic_reward)
return torch.from_numpy(cubic_reward.copy())

@staticmethod
def cmp_ground_truth(
Expand Down

0 comments on commit 50c86c6

Please sign in to comment.