Ejemplo n.º 1
0
    def claim_n_points(self, nnn, newclazz):
        working_set = self.working_set
        if self.classcounts_ws[newclazz] == self.size_ws:
            raise Exception('The whole working set already belongs to class ' +
                            str(newclazz))
        gradient_vec = np.zeros((self.size_ws))
        tempvec = np.zeros((self.Y.shape[1]))
        _interactive_rls_classifier.compute_gradient(
            self.Y_ws, gradient_vec, self.classcounts_ws, self.classvec_ws,
            self.size_ws, self.size, self.DVTY, self.sqrtRx2_ws,
            self.sqrtR.shape[1], newclazz, tempvec, self.Y.shape[1])

        claiminds = np.argsort(gradient_vec)

        clazzcountchanges = np.zeros((self.labelcount), dtype=np.int32)
        _interactive_rls_classifier.claim_n_points(
            self.Y_ws, gradient_vec, self.classcounts_ws, self.classvec_ws,
            claiminds, nnn, self.DVTY, self.sqrtRx2_ws, self.sqrtR.shape[1],
            newclazz, clazzcountchanges)

        self.Y[working_set] = self.Y_ws
        self.classvec[working_set] = self.classvec_ws
        #self.classcounts[oldclazz] -= nnn
        self.classcounts[newclazz] += nnn
        for i in range(self.labelcount):
            self.classcounts[i] += clazzcountchanges[i]
Ejemplo n.º 2
0
 def compute_steepness_vector(self):        
     gradient_vec0 = np.zeros((self.size_ws))
     tempvec = np.zeros((self.Y.shape[1]))
     _interactive_rls_classifier.compute_gradient(self.Y_ws,
                  gradient_vec0,
                  self.classcounts_ws,
                  self.classvec_ws,
                  self.size_ws,
                  self.size,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  0,
                  tempvec,
                  self.Y.shape[1])
     gradient_vec1 = np.zeros((self.size_ws))
     tempvec = np.zeros((self.Y.shape[1]))
     _interactive_rls_classifier.compute_gradient(self.Y_ws,
                  gradient_vec1,
                  self.classcounts_ws,
                  self.classvec_ws,
                  self.size_ws,
                  self.size,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  1,
                  tempvec,
                  self.Y.shape[1])
     
     steepness_vector = np.zeros((self.size_ws))
     steepness_vector[0:self.classcounts_ws[1]] = np.sort(gradient_vec0)[0:self.classcounts_ws[1]][::-1]
     steepness_vector[self.classcounts_ws[1]:] = np.sort(gradient_vec1)[0:self.classcounts_ws[0]]
     #print steepness_vector
     return steepness_vector
Ejemplo n.º 3
0
    def compute_steepness_vector(self):
        gradient_vec0 = np.zeros((self.size_ws))
        tempvec = np.zeros((self.Y.shape[1]))
        _interactive_rls_classifier.compute_gradient(
            self.Y_ws, gradient_vec0, self.classcounts_ws, self.classvec_ws,
            self.size_ws, self.size, self.DVTY, self.sqrtRx2_ws,
            self.sqrtR.shape[1], 0, tempvec, self.Y.shape[1])
        gradient_vec1 = np.zeros((self.size_ws))
        tempvec = np.zeros((self.Y.shape[1]))
        _interactive_rls_classifier.compute_gradient(
            self.Y_ws, gradient_vec1, self.classcounts_ws, self.classvec_ws,
            self.size_ws, self.size, self.DVTY, self.sqrtRx2_ws,
            self.sqrtR.shape[1], 1, tempvec, self.Y.shape[1])

        steepness_vector = np.zeros((self.size_ws))
        steepness_vector[0:self.classcounts_ws[1]] = np.sort(
            gradient_vec0)[0:self.classcounts_ws[1]][::-1]
        steepness_vector[self.classcounts_ws[1]:] = np.sort(
            gradient_vec1)[0:self.classcounts_ws[0]]
        #print steepness_vector
        return steepness_vector
Ejemplo n.º 4
0
 def claim_n_points(self, nnn, newclazz):
     working_set = self.working_set
     if self.classcounts_ws[newclazz] == self.size_ws:
         raise Exception('The whole working set already belongs to class '+str(newclazz))
     gradient_vec = np.zeros((self.size_ws))
     tempvec = np.zeros((self.Y.shape[1]))
     _interactive_rls_classifier.compute_gradient(self.Y_ws,
                  gradient_vec,
                  self.classcounts_ws,
                  self.classvec_ws,
                  self.size_ws,
                  self.size,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  newclazz,
                  tempvec,
                  self.Y.shape[1])
     
     claiminds = np.argsort(gradient_vec)
     
     clazzcountchanges = np.zeros((self.labelcount), dtype = np.int32)
     _interactive_rls_classifier.claim_n_points(self.Y_ws,
                  gradient_vec,
                  self.classcounts_ws,
                  self.classvec_ws,
                  claiminds,
                  nnn,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  newclazz,
                  clazzcountchanges)
     
     self.Y[working_set] = self.Y_ws
     self.classvec[working_set] = self.classvec_ws
     #self.classcounts[oldclazz] -= nnn
     self.classcounts[newclazz] += nnn
     for i in range(self.labelcount):
         self.classcounts[i] += clazzcountchanges[i]