Esempio n. 1
0
 def funProjL12(self, w):
     normedW, alpha = self.getGroupNorm(w)
     alpha_proj = randomProject(alpha, self.lbda)
     wOut = normedW.copy()
     for i in range(self.nGroups):
         groupInd = self.groupPtr[self.groupStart[i]:self.groupStart[i + 1]].astype(int)
         wOut[groupInd] *= alpha_proj[i]
     return wOut
Esempio n. 2
0
    def fun_project(self, w):

        d1, d2 = self.X.shape

        v = np.zeros((d2, ))
        v1 = np.zeros(d2)
        for i in range(d2):
            v[i] = abs(w[i])
            if v[i] != 0:
                v1[i] = w[i] / v[i]

        p = randomProject(v, self.alpha_lasso)
        test = v1 * p

        return test
Esempio n. 3
0
    def fun_project(self, w):

        markers, repeats = np.unique(self.marker_groups, return_counts=True)
        marker_groups_ravel = np.repeat(markers, repeats*(self.n_classes-1))

        v = np.zeros((markers.shape[0],))
        v1 = np.zeros(w.shape)

        for i in markers:
            indices1 = np.where(marker_groups_ravel == i)[0]
            w_group = w[indices1]
            v[i] = LA.norm(w_group, 2)

            if v[i] != 0:
                v1[indices1] = w_group / v[i]

        p = randomProject(v, self.lbda)

        test = v1 * np.repeat(p, repeats*(self.n_classes-1))

        return test
Esempio n. 4
0
 def funProj(self, w):
     if self.isDeep:
         return np.hstack( (np.sign(w[0:self.d*self.h1]) * randomProject(np.fabs(w[:self.d*self.h1]), self.tau), w[self.d*self.h1:])) 
     else:
         return np.hstack( (np.sign(w[:-1]) * randomProject(np.fabs(w[:-1]), self.tau), w[-1]))