(logits_np, E, k)
| 553 | print(f"Training for {epochs} epochs...\n") |
| 554 | |
| 555 | def eval_hit_rate(logits_np, E, k): |
| 556 | preds = np.argsort(-logits_np, axis=1)[:, :k] |
| 557 | hits = 0 |
| 558 | total = 0 |
| 559 | for i in range(len(E)): |
| 560 | actual = set(int(x) for x in E[i] if x >= 0) # drop -1 padding |
| 561 | hits += len(actual & set(preds[i].tolist())) |
| 562 | total += len(actual) # real experts only, not padded K |
| 563 | return hits, total |
| 564 | |
| 565 | def run_eval(): |
| 566 | model.eval() |
no outgoing calls
no test coverage detected