在Theano索引

Joh*_*ues 6 matrix-indexing theano

如何通过索引向量索引Theano中的矩阵?
更确切地说,说:

  • v的类型为theano.tensor.vector(例如[0,2])
  • A有类型theano.tensor.matrix(例如[[1,0,0],[0,1,0],[0,0,1]])

期望的结果是[[1,0,0],[0,0,1]].
我提到我的目标是将索引列表转换为单热行向量矩阵,其中索引表示热点位置.我最初的尝试是让A = theano.tensor.eye并使用索引向量对其进行索引.

nou*_*uiz 5

你可以做:

A[v]
Run Code Online (Sandbox Code Playgroud)

它会做你想要的.