elementwise_mul ShapeError
收藏
0
收藏
全部评论(1)
您好,默认情况下,fluid.layers.data会在shape前面加-1作为batch_size,所以x的shape是[-1, 1],而y是[1],详见fluid.layers.data。
可以设置x = fluid.layers.data(name='x', shape=[1], dtype='float32', append_batch_size=False),不加-1。
0
请登录后评论
环境
cpu
paddle1.6
python3.7
代码
`import paddle.fluid as fluid
import numpy as np
x = fluid.layers.data(name='x', shape=[1], dtype='float32')
x_s = fluid.layers.shape(x)
y = fluid.layers.create_parameter(name='y', shape=[1], dtype='float32')
y_s = fluid.layers.shape(y)
out_put = fluid.layers.elementwise_mul(y, x)`
错误信息
line 10, in <module> out_put = fluid.layers.elementwise_mul(y, x) Error: ShapeError: the dimension of input X must greater than or equal to the one of input Y. But received: the shape of input X = [1], the dimension of input X = 1, the shape of input Y = [-1, 1], the dimension of input Y = 2 [Hint: Expected x_dim.size() >= y_dim.size(), but received x_dim.size():1 < y_dim.size():2.] at (/paddle/paddle/fluid/operators/elementwise/elementwise_op.h:61) [operator < elementwise_mul > error]
x,y的shape都是[1],这里怎么说有一个是[-1,1]呢