【论文复现】矩阵乘法
Created by: AlanJie
x = fluid.layers.ones((2, 1, 2, 2), dtype='float32')
y = fluid.layers.ones((1, 65, 2, 1), dtype='float32')
out = fluid.layers.matmul(x, y)
请问这样的矩阵乘法在paddle中如何实现,pytorch和numpy都可以正常运算,但paddle会报维度不匹配的错误,如果中间使用numpy会导致无法计算梯度
InvalidArgumentError: The batch size of the two matrices should be equal, or at least one is zero.
But received X's shape: [2, 2, 2], Y's shape: [65, 2, 1].
[Hint: Expected mat_dim_x.batch_size_ == mat_dim_y.batch_size_ || mat_dim_x.batch_size_ == 0 || mat_dim_y.batch_size_ == 0 == true, but received mat_dim_x.batch_size_ == mat_dim_y.batch_size_ || mat_dim_x.batch_size_ == 0 || mat_dim_y.batch_size_ == 0:0 != true:1.] at (/paddle/paddle/fluid/operators/matmul_op.cc:357)