Skip to content
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

Paddle的paddle.distribution.Categorical 支持props输入,接口对齐Torch #70943

Open
zhiminzhang0830 opened this issue Jan 22, 2025 · 2 comments
Assignees
Labels

Comments

@zhiminzhang0830
Copy link
Contributor

zhiminzhang0830 commented Jan 22, 2025

需求描述 Feature Description

paddle.distribution.Categorical 支持props输入

参考链接:
https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.categorical.Categorical.html

替代实现 Alternatives

目前仿照torch进行替代实现:

eps = paddle.finfo(q_probs.dtype).eps
q_logits = paddle.log(x=q_probs.clip(min=eps, max=1 - eps))
d1 = paddle.distribution.Categorical(logits=q_logits)
@wangguan1995
Copy link

打错字了,是probs参数
https://pytorch.org/docs/stable/distributions.html#categorical

Image

@guhaohao0991
Copy link

结果paddle和torch下使用prob或者log_prob方法,结果还是不一样
Image

Image

Image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants