Hi all,
I have a Theano tensor3 (i.e., a 3-dimensional array) x: [[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] [[12 13 14 15] [16 17 18 19] [20 21 22 23]]] as well as a Theano vector (i.e., a 1-dimensional array) y, which we will refer as an "offset" vector, since it specifies the desired offset: [2, 1] I want to shift the location of elements of x based on vector y, so that the output be as follows (the shift is performed on the second dimension): [[[ a b c d] [ e f g h] [ 0 1 2 3]] [[ i j k l] [12 13 14 15] [16 17 18 19]]] where the a, b, …, l could be any number. For example, a valid output could be: [[[ 0 0 0 0] [ 0 0 0 0] [ 0 1 2 3]] [[ 0 0 0 0] [12 13 14 15] [16 17 18 19]]] Another valid output could be: [[[ 4 5 6 7] [ 8 9 10 11] [ 0 1 2 3]] [[20 21 22 23] [12 13 14 15] [16 17 18 19]]] ------------------------------ I am aware of the function theano.tensor.roll(x, shift, axis=None) <http://deeplearning.net/software/theano/library/tensor/basic.html#theano.tensor.roll>, however the shift can only take a scalar as input, i.e. it shifts all elements with the same offset. E.g., the code: import theano.tensorfrom theano import sharedimport numpy as np x = shared(np.arange(24).reshape((2,3,4)))print('theano.tensor.roll(x, 2, axis=1).eval(): \n{0}'. format(theano.tensor.roll(x, 2, axis=1).eval())) outputs: theano.tensor.roll(x, 2, axis=1).eval():[[[ 4 5 6 7] [ 8 9 10 11] [ 0 1 2 3]] [[16 17 18 19] [20 21 22 23] [12 13 14 15]]] which is not what I want. How can I shift the location of tensor3 elements based on an offset vector? (note that in the code provided in this example, the tensor3 is a shared variable for convenience, but in my actual code it will be a symbolic variable) Thanks, Franck -- --- You received this message because you are subscribed to the Google Groups "theano-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
