Ok, figured it out - the trick was to define a generic permutation-applying function in theano, and generate the specific list of every permutation at runtime in numpy. The actual list of permutations is then passed in as a parameter to Theano, rather than being calculated from within Theano.
On Monday, August 7, 2017 at 5:20:55 PM UTC-6, Alexander Farley wrote: > > I would like to define a Theano operation taking this vector: > > [1,2,3] > > To this array: > > [[1,2,3], > [1,3,2], > [2,3,1], > [2,1,3], > [3,1,2], > [3,2,1]] > > The problem I'm having is that while I can get the correct result using > numpy operations and arrays, I'm having trouble converting to Theano > operations. In numpy, I get the correct result using itertools.permutations: > > np.array(list(itertools.permutations(x))) > > However, if I swap in a Theano vector X as the argument: > > X = T.vector() > np.array(list(itertools.permutations(X))) > > then I get an error: > ValueError: length is not known > > I think what's happening is that X is symbolic so it can't be evaluated by > itertools.permutations. Is there a simple way to do this in Theano or do I > have to construct the set of permutations from lower-level operations? > > -- --- 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.
