[英]Theano matrix multiplication of 2d matrix to give 3d matrix
I want to do exactly what the following question is trying to do in numpy: 我想完成以下问题在numpy中尝试做的事情:
Numpy matrix multiplication of 2d matrix to give 3d matrix 2d矩阵的Numpy矩阵乘法给出3d矩阵
I have written the following code (as per the suggestion for numpy case), assuming that broadcast works in theano as well: 我已经编写了以下代码(根据numpy案例的建议),假设广播也在theano中工作:
y = T.dmatrix('y')
x = T.dmatrix('x')
z = x[...,None]*y[:,None,:]
But it is throwing following error: 但它抛出以下错误:
AsTensorError: ('Cannot convert Ellipsis to TensorType', <type 'ellipsis'>)
As per @Divakar s comment, change it to 根据@Divakar的评论,将其更改为
x[:,:,None] * y[:,None,:]
Just posting it as an answer so that people know there's an answer to this. 只需将其作为答案发布,以便人们知道答案就是这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.