Unverified Commit 7d747ea9 authored by Lintang Sutawika's avatar Lintang Sutawika Committed by GitHub
Browse files

Fix Brier Score (#1847)

`gold_one_hot` needs to follow the dimension of predictions so that it still works when `--limit` is used and the indexes in gold does not cover all gold indexes.
parent 5f3a6621
......@@ -119,9 +119,10 @@ def ter(items):
@register_aggregation("brier_score")
def brier_score(items): # This is a passthrough function
gold, predictions = list(zip(*items))
bs, num_class = np.array(predictions).shape
gold = list(gold)
gold_one_hot = np.eye(np.max(gold) + 1)[gold]
predictions = list(zip(*items))[1]
gold_one_hot = np.eye(num_class)[gold]
return np.mean(np.sum((predictions - gold_one_hot) ** 2, axis=1))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment