

def train_dual(self, precision=(10 ** (- 3))):
    pnorm = self.pnorm
    iter = 0
    lastsol = ([0.0] * self.num_kernels)
    while (sum([abs((lastsol[i] - self.dm[i])) for i in range(self.num_kernels)]) > pnorm):
        self.ssad.set_train_kernel(self.combine_kernels(self.kernels))
        self.ssad.train_dual()
        lastsol = matrix(self.dm)
        alphas = self.ssad.get_alphas()
        cy = self.cy
        norm_w_sq_m = matrix(0.0, (self.num_kernels, 1))
        for j in range(self.samples):
            for k in range(self.samples):
                foo = (((float(cy[k]) * float(cy[j])) * alphas[k]) * alphas[j])
                for l in range(self.num_kernels):
                    norm_w_sq_m[l] += (((self.dm[l] * self.dm[l]) * foo) * self.kernels[l][(j, k)])
        dm = ([0.0] * self.num_kernels)
        sum_norm_w = 0.0
        for i in range(self.num_kernels):
            sum_norm_w += math.pow(norm_w_sq_m[i], (pnorm / (pnorm + 1.0)))
        sum_norm_w = math.pow(sum_norm_w, (1.0 / pnorm))
        for i in range(self.num_kernels):
            dm[i] = (math.pow(norm_w_sq_m[i], (1.0 / (pnorm + 1.0))) / sum_norm_w)
        print('New mixing coefficients:')
        print(dm)
        dm_norm = 0.0
        for i in range(self.num_kernels):
            dm_norm += math.pow(abs(dm[i]), pnorm)
        dm_norm = math.pow(dm_norm, (1.0 / pnorm))
        print(dm_norm)
        self.dm = dm
        iter += 1
    print('Num iterations = {0}.'.format(iter))
    return 0

dataset/ETHPy150Open nicococo/tilitools/mkl.py MKLWrapper.train_dual/VarMisuse@76/87 `precision`->`pnorm`