-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[Typing][B-71] Add type annotations for python/paddle/sparse/nn/layer/activation.py
#65869
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
Update 20240709由于 In [7]: import paddle
...: paddle.seed(2022)
...:
...: mask = paddle.rand((3, 4)) < 0.7
...: x = paddle.rand((3, 4)) * mask
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[7], line 5
2 paddle.seed(2022)
4 mask = paddle.rand((3, 4)) < 0.7
----> 5 x = paddle.rand((3, 4)) * mask
TypeError: (InvalidType) Type promotion only support calculations between floating-point numbers and between complex and real numbers. But got different data type x: float32, y: bool. (at /home/shun/Documents/Projects/paddle/megemini/Paddle/paddle/phi/common/type_promotion.h:159) 个人感觉不是很合理, |
方案肯定是通过评审的,他们觉得不需要支持那就不支持呗 |
@@ -102,7 +102,7 @@ class Softmax(Layer): | |||
>>> paddle.seed(2022) | |||
|
|||
>>> mask = paddle.rand((3, 4)) < 0.7 | |||
>>> x = paddle.rand((3, 4)) * mask | |||
>>> x = paddle.to_tensor(paddle.rand((3, 4)).numpy() * mask.numpy()) |
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.
直接 x = paddle.rand([3, 4]) * mask.astype(paddle.float32)
呢?这里转 numpy 再回转就很奇怪了
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.
PR Category
User Experience
PR Types
Improvements
Description
类型标注:
python/paddle/sparse/nn/layer/activation.py
Related links
@SigureMo @megemini