Indexing in Theano

How can I index a matrix in Teano with an index vector?
To be precise:

  • v is of type theano.tensor.vector (for example, [0,2])
  • A is of type anano.tensor.matrix (for example, [[1,0,0], [0,1,0], [0,0,1]])

The desired result is [[1,0,0], [0,0,1]].
I mention that my goal is to convert the list of indices into a matrix of single-row row vectors, where the indices indicate a hot position. My initial attempt was to allow A = theano.tensor.eye and index it using an index vector.

+6
source share
1 answer

You can do:

A[v] 

He will do what you want.

+5
source

Source: https://habr.com/ru/post/970741/


All Articles