I want to flip order of elements in the second dimension of a tensor:

x = T.tensor3('x')
f = theano.function([x], ?)
print(f(x_data))

input:

x_data = [[[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]],
          [[5, 0, 0, 0], [0, 6, 0, 0], [0, 0, 7, 0], [0, 0, 0, 8]],
          [[9, 0, 0, 0], [0, 10, 0, 0], [0, 0, 11, 0], [0, 0, 0, 12]]
         ]

desired output:

x_data = [[[0, 0, 0, 4], [0, 0, 3, 0], [0, 2, 0, 0], [1, 0, 0, 0]],
          [[0, 0, 0, 8], [0, 0, 7, 0], [0, 6, 0, 0], [5, 0, 0, 0]],
          [[0, 0, 0, 12], [0, 0, 11, 0], [0, 10, 0, 0], [9, 0, 0, 0]]
         ]

x_data[::-1] flips the overall second dimension (not desirable):

x_data = [[[ 11.   0.   0.   0.]
           [  0.  12.   0.   0.]
           [  0.   0.  13.   0.]
           [  0.   0.   0.  14.]]


           [[  5.   0.   0.   0.]
            [  0.   6.   0.   0.]
            [  0.   0.   7.   0.]
            [  0.   0.   0.   8.]]


           [[  1.   0.   0.   0.]
            [  0.   2.   0.   0.]
            [  0.   0.   3.   0.]
            [  0.   0.   0.   4.]]]


What is the simplest way to achieve the desired output ?


P.S: It's a cross-posting - 
http://stackoverflow.com/questions/38467955/flip-second-dimension-of-tensor

-- 

--- 
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.

Reply via email to