shuffling the first ith column in a theano matrix

209 views Asked by At

I need to shuffle the first i column of each row for a theano tensor matrix.

The only method I find is raw_random.shuffle_row_elements, but it shuffles every entire row (all columns).

Can anyone give me a hint?

1

There are 1 answers

0
Alexander McFarlane On

Use the following

theano.tensor.basic.swapaxes(y, axis1, axis2)

This is defined as:

def swapaxes(y, axis1, axis2):
    "swap axes of inputted tensor"
    y = as_tensor_variable(y)
    ndim = y.ndim
    li = range(0, ndim)
    li[axis1], li[axis2] = li[axis2], li[axis1]
    return y.dimshuffle(li)