如何将两个 4D TensorVariable 相乘,python

How to multipy two 4D TensorVariable, python

我有两个 4D TensorVariable,X=[100,1,28,28]W=[100,1,28,28]X 包括 100 个大小为 (28,28) 的图像(单通道)。 W100 图像对应的权重。我们想将每个图像乘以它的权重。换句话说,我想要 100 个图像,其中每个单独的图像都来自 T.dot(a,b),其中 a 是一个图像,b 是它的权重。

T.dot(X,W) 对我不起作用,因为它给了我一个 5D TensorVariable。

Theano T.dot function is a matrix multiplication (inner product). You want an element-wise multiplication, which, as described in the documentation,只需使用 * 运算符即可完成,即

X * W