Skip to content

Commit 24f4177

Browse files
Update examples/cloud-edge-collaborative-inference-for-llm/testenv/accuracy.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 69b4339 commit 24f4177

File tree

1 file changed

+4
-1
lines changed
  • examples/cloud-edge-collaborative-inference-for-llm/testenv

1 file changed

+4
-1
lines changed

examples/cloud-edge-collaborative-inference-for-llm/testenv/accuracy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def acc(y_true, y_pred):
5454
same_elements = [y_pred[i] == y_true[i] for i in range(len(y_pred))]
5555

5656
# 计算相同元素的数量
57-
if len(same_elements) == 0:
57+
same_elements = [p == t for p, t in zip(y_pred, y_true)]
58+
59+
# 计算相同元素的数量
60+
if not same_elements:
5861
return 0.0
5962
acc = sum(same_elements) / len(same_elements)
6063

0 commit comments

Comments
 (0)