【问题标题】:Theano matrix multiplication of 2d matrix to give 3d matrix2d 矩阵的 Theano 矩阵乘法得到 3d 矩阵
【发布时间】:2016-02-02 21:06:59
【问题描述】:

我想在 numpy 中做以下问题试图做的事情:
Numpy matrix multiplication of 2d matrix to give 3d matrix

我已经编写了以下代码(根据 numpy 案例的建议),假设广播也可以在 theano 中工作:

y = T.dmatrix('y')
x = T.dmatrix('x')
z = x[...,None]*y[:,None,:]

但它抛出以下错误:

AsTensorError: ('Cannot convert Ellipsis to TensorType', <type 'ellipsis'>)

【问题讨论】:

  • 或者试试x[:,:,None]*y[:,None,:]。 x[...,None] 是 x[:,:,None] 的简写符号/方式。
  • Theano 跟踪器上有一个未解决的问题:github.com/Theano/Theano/issues/2487
  • @Divakar,它正在工作......太棒了!谢谢
  • @Shweta 不错!那么,将带有该评论的答案作为解决方案代码发布?

标签: python numpy matrix theano


【解决方案1】:

根据@Divakar 的评论,将其更改为

x[:,:,None] * y[:,None,:]

只是将其发布为答案,以便人们知道对此有答案。

【讨论】:

    猜你喜欢
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多