mercredi 13 juillet 2016

Indexing matrix with values from vector in theano


I'm working on a cost function in theano and faced the following problem: I have a matrix M (say [[3,4],[5,6]]), a vector v ([0,1]) and I would like to get the vector of entries in M corresponding to the indexes contained in v (here [3,6]). Is there a command to do exactly that? Edit: I ended up doing the following : M[T.arange(v.shape[0]), v], where T.arange(v.shape[0]) is just a vector which entries are integers in the range of the length of v. M needed to be indexed with a list of two vectors

Aucun commentaire:

Enregistrer un commentaire