Skip to content

[Accuracy diff No.65, 66] Fix accuracy diff for paddle.Tensor.meidan API - #265

Merged
wanghuancoder merged 2 commits into
PFCCLab:mainfrom
NKNaN:median-fix
Jun 16, 2025
Merged

wanghuancoder merged 2 commits into
PFCCLab:mainfrom
NKNaN:median-fix

Conversation

@NKNaN

@NKNaN NKNaN commented Jun 14, 2025

Copy link
Copy Markdown
Contributor

原结果梯度误差的原因是 paddle.Tensor.median 默认 mode 参数为 ‘avg’,元素个数为偶数时取中间两元素的均值,torch.Tensor.median 的行为是取中间两元素的较小值,所以需要将 mode 参数设置为 ‘min’。

回测结果:
GPU:
image
image

CPU:
image
image

@cangtianhuang cangtianhuang left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应该直接修改配置,而是将 torch 与 paddle 进行对齐,我们需要保证完全地模拟出 paddle 的行为

目前 paddle.median 已经修复成功,可以参考 tester/paddle_to_torch/mapping.json 中对 paddle.median 的配置,以及 tester/paddle_to_torch/rules.py 的 MedianRule,将 paddle.Tensor.meidan 也用上 MedianRule~

辛苦同学继续修改啦😉~

@NKNaN

NKNaN commented Jun 16, 2025

Copy link
Copy Markdown
Contributor Author

已修改

回测结果:
GPU
image
CPU
image

@cangtianhuang cangtianhuang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wanghuancoder wanghuancoder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wanghuancoder
wanghuancoder merged commit 59c9fea into PFCCLab:main Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants