-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OSCP] 使用 SPU 实现 AP(average_precision_score) 函数 #801
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外,,需要在classification_emul.py
中增加ap的调用测试,具体方式可以参考里面的其他例子
TODO @z0gSh1u :
|
👌🏻 I'll ping you when I'm ready. |
已修改,可以再次评审~ |
提供一个比较直接的思路:
anyway,核心还是围绕AP的计算公式,只不过要小心处理尾0,使得整个计算结果保持和明文一致 |
调整完成,使用thresholds > 0作为mask调整了precision的计算区间,并改用了更严格的tol检查。由于y_score存在0值时thresholds > 0条件不准确(trailing 0 和 0 score无法区分),因此还添加了下界score_eps。 |
hello,,正确性看上去应该没问题了,但是性能上仍然有巨大的优化空间
Link details: total send bytes 25116300315, recv bytes 25137340315, send actions 720907, recv actions 721170 可以发现这个cost还是很离谱,,主要的原因在于 sorted_pairs = pairs[jnp.argsort(pairs[:, 1], descending=True, stable=True)] 这里会调用secret index,这个在MPC下是无比昂贵的。。 sorted_pairs = create_sorted_label_score_pair(y_true, y_score)
max_tp = jnp.max(tp)
recalls = jnp.where(max_tp == 0, jnp.ones_like(tp), tp / max_tp) 替换后,可以发现通信量缩减在250x以上,耗时也减少100x左右。。 |
另外,,我发现emulation的文件里其他两个函数在run之前也没加seal,,这也是有问题的,,麻烦你也顺便都加上吧🙏 |
@z0gSh1u |
好的,我晚些检查&修改下,顺便合一下master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Pull Request
What problem does this PR solve?
Issue Number: Fixed #727
Implemented
average_precision_score
function for binary classification and multi-class classification with three average methods.