首页 Paddle框架 帖子详情
layers.reverse gets unexpected behavior with negative axis
收藏
快速回复
Paddle框架 问答深度学习模型训练 682 1
layers.reverse gets unexpected behavior with negative axis
收藏
快速回复
Paddle框架 问答深度学习模型训练 682 1

Thank you for contributing to PaddlePaddle.
Before submitting the issue, you could search issue in the github in case that there was a similar issue submitted or resolved before.
If there is no solution,please provide us with the following details :
System information
-PaddlePaddle version 2019/12/19 develop
-GPU: cuda 10.1 / cudnn 7.5
-OS Platform and DistributionL ubuntu 16.04LTS
-Python version 3.7.4

reproduce:

import numpy as np
from paddle import fluid
import paddle.fluid.layers as F
import paddle.fluid.dygraph as dg

x = np.reshape(np.arange(20), (4, 5)).astype(np.float32)
print(x)
place = fluid.CPUPlace()
with dg.guard(place):
    x_var = dg.to_variable(x)
    y_var = F.reverse(x_var, axis=-1)
    y_np = y_var.numpy()
    print(y_np)

output:

[[ 0.  1.  2.  3.  4.]
 [ 5.  6.  7.  8.  9.]
 [10. 11. 12. 13. 14.]
 [15. 16. 17. 18. 19.]]

[[ 0.  1.  2.  3.  4.]
 [ 5.  6.  7.  8.  9.]
 [10. 11. 12. 13. 14.]
 [15. 16. 17. 18. 19.]]

expected ouput:

[[ 0.  1.  2.  3.  4.]
 [ 5.  6.  7.  8.  9.]
 [10. 11. 12. 13. 14.]
 [15. 16. 17. 18. 19.]]

[[ 4.  3.  2.  1.  0.]
 [ 9.  8.  7.  6.  5.]
 [14. 13. 12. 11. 10.]
 [19. 18. 17. 16. 15.]]

When I use axis=1, I get the expected behavior.

0
收藏
回复
全部评论(1)
时间顺序
aistudio_2
#4 回复于2021-05

mark

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户