Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

expand_as没有设置 output shape 么?

Open colin1988 opened this issue 6 years ago • 3 comments

https://github.com/PaddlePaddle/Paddle/blob/a9520db24ef8b101514b0bcaff39dd359f72dcb7/paddle/fluid/operators/expand_as_op.cc#L48

colin1988 avatar Jul 21 '20 13:07 colin1988

问题已在用户群解决,发现,expand_asAPI返回的shape全是0,复现代码如下: paddle版本1.7

import paddle.fluid as fluid
from paddle.fluid.dygraph.base import to_variable
import numpy as np


pad_value = fluid.layers.assign(np.array([[2,3]]).astype(np.float32))
print(pad_value.shape)

tmp = fluid.layers.assign(np.ones([3, 2]).astype(np.float32))
print(tmp.shape)
res = fluid.layers.expand_as(x=pad_value, target_tensor=tmp)

print(res.shape)

打印结果 (1, 2) (3, 2) (0, 0)

LDOUBLEV avatar Jul 22 '20 02:07 LDOUBLEV

问题已在用户群解决,发现,expand_asAPI返回的shape全是0,复现代码如下: paddle版本1.7

import paddle.fluid as fluid
from paddle.fluid.dygraph.base import to_variable
import numpy as np


pad_value = fluid.layers.assign(np.array([[2,3]]).astype(np.float32))
print(pad_value.shape)

tmp = fluid.layers.assign(np.ones([3, 2]).astype(np.float32))
print(tmp.shape)
res = fluid.layers.expand_as(x=pad_value, target_tensor=tmp)

print(res.shape)

打印结果 (1, 2) (3, 2) (0, 0)

请问这个问题要怎么解决?

shuangw98 avatar Aug 01 '20 04:08 shuangw98

Since you haven't replied for more than a year, we have closed this issue/pr. If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. 由于您超过一年未回复,我们将关闭这个issue/pr。 若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。

paddle-bot-old avatar Sep 14 '21 09:09 paddle-bot-old