Background
I have an image that I want to sample at the number (P) of x, y coordinates.
In Numpy, I can use advanced indexing for this:
n_points = n_image[ [n_pos[:,1],n_pos[:,0]] ]
Returns a vector of pixels selected from an image.
Question
How can I do this advanced indexing in Theano?
What i tried
I tried the corresponding code in anano:
t_points = t_image[ [t_pos[:,1],t_pos[:,0]] ]
it is compilation and execution without any warning messages, but leads to an output form tensor (2,8,100), so it looks like it does some basic indexing option that returns a lot of image lines, instead of highlighting pixels.
Full code
import numpy as np
import theano.tensor as T
from theano import function, shared
import theano
P = 8
n_image = np.zeros((100,100), dtype=np.int16)
n_pos = np.zeros( (P,2) , dtype=np.int32)
n_points = n_image[ [n_pos[:,1],n_pos[:,0]] ]
t_pos = T.imatrix('t_pos')
t_image = shared( n_image )
t_points = t_image[ [t_pos[:,1],t_pos[:,0]] ]
my_fun = function( [t_pos], t_points)
t_points = my_fun(n_pos)
print n_points.shape
print t_points.shape
This prints (8,) for Numpy and (2,8,100) for Theano.
My version of Theano is 0.7.0.dev-RELEASE