theano/tensor/sort.py
def __get_argsort_indices(self, a, axis):
        """
        Calculates indices which can be used to reverse sorting operation of
        "a" tensor along "axis".

        Returns
        -------
        1d array if axis is None
        list of length len(a.shape) otherwise

        """

        # The goal is to get gradient wrt input from gradient
        # wrt sort(input, axis)
        idx = argsort(a, axis, kind=self.kind, order=self.order)
        # rev_idx is the reverse of previous argsort operation
        rev_idx = argsort(idx, axis, kind=self.kind, order=self.order)
        indices = []
        axis_data = theano.tensor.switch(theano.tensor.ge(axis.data, 0),
                                         axis.data, a.ndim + axis.data)
        for i in range(a.ndim):
            index_val = theano.tensor.switch(theano.tensor.eq(i, axis_data),
                                             rev_idx,
                                             self.__get_expanded_dim(a,
                                                                     axis, i))
            indices.append(index_val)
        return indices

        Calculates indices which can be used to reverse sorting operation of
        "a" tensor along "axis".

        Returns
        -------
        1d array if axis is None
        list of length len(a.shape) otherwise

        
Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis".

Returns

1d array if axis is None
list of length len(a.shape) otherwise
Calculates indices which can be used to reverse sorting operation of " a " tensor along " axis " . Returns 1d array if axis is None list of length len ( a . shape ) otherwise
def __get_argsort_indices(self, a, axis):
        idx = argsort(a, axis, kind=self.kind, order=self.order)
        rev_idx = argsort(idx, axis, kind=self.kind, order=self.order)
        indices = []
        axis_data = theano.tensor.switch(theano.tensor.ge(axis.data, 0),
                                         axis.data, a.ndim + axis.data)
        for i in range(a.ndim):
            index_val = theano.tensor.switch(theano.tensor.eq(i, axis_data),
                                             rev_idx,
                                             self.__get_expanded_dim(a,
                                                                     axis, i))
            indices.append(index_val)
        return indices
def __get_argsort_indices ( self , a , axis ) : idx = argsort ( a , axis , kind = self . kind , order = self . order ) rev_idx = argsort ( idx , axis , kind = self . kind , order = self . order ) indices = [ ] axis_data = theano . tensor . switch ( theano . tensor . ge ( axis . data , 0 ) , axis . data , a . ndim + axis . data ) for i in range ( a . ndim ) : index_val = theano . tensor . switch ( theano . tensor . eq ( i , axis_data ) , rev_idx , self . __get_expanded_dim ( a , axis , i ) ) indices . append ( index_val ) return indices
Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis".
Calculates indices which can be used to reverse sorting operation of " a " tensor along " axis " .
"""
        Calculates indices which can be used to reverse sorting operation of
        "a" tensor along "axis".

        Returns
        -------
        1d array if axis is None
        list of length len(a.shape) otherwise

        """ # The goal is to get gradient wrt input from gradient # wrt sort(input, axis) # rev_idx is the reverse of previous argsort operation
self
a
axis