Skip to content

Conversation

@ymouad
Copy link
Contributor

@ymouad ymouad commented Sep 6, 2022

Add improvements to KLIEP: centers' selection and new possible optimization algorithms.

Add improvements to KLIEP: centers' selection and new possible optimization algorithms.
Add new tests.
@ymouad ymouad closed this Sep 6, 2022
@ymouad ymouad reopened this Sep 6, 2022
@antoinedemathelin
Copy link
Collaborator

Hi @ymouad,
It seems that this part of your test do not work:

with warnings.catch_warnings(record=True) as w:
    model = KLIEP(gamma=10**6)
    model.fit_weights(Xs, Xt)

Because an error is raised here:

def _fit_FW(self, Xs, Xt, kernel_params):
    centers, A, b = self.centers_selection(Xs, Xt, kernel_params)
    alpha = 1/(len(centers)*b)
    objective = np.mean(np.log(np.dot(A, alpha) + EPS))
    if self.verbose > 1:
            print("Alpha's optimization : iter %i -- Obj %.4f"%(0, objective))
    k = 0
    while k < self.max_iter:
        previous_objective = objective
        alpha_p = np.copy(alpha)
        g = np.dot(
            np.transpose(A), 1./(np.dot(A, alpha) + EPS)
        )
        B = np.diag(1/b.ravel())
        LP = np.dot(g.transpose(), B)
        lr = 2/(k+2)
       alpha = (1 - lr)*alpha + lr*B[np.argmax(LP)].reshape(-1,1)
       IndexError: index 2[88](https://github.com/adapt-python/adapt/runs/8211202635?check_suite_focus=true#step:6:89)5 is out of bounds for axis 0 with size 78

Fix centers selection issues.
@ymouad
Copy link
Contributor Author

ymouad commented Sep 7, 2022

Hi @antoinedemathelin,

Thank you!
Indeed, there were dimension issues.
It should work now.

@antoinedemathelin antoinedemathelin changed the title Update _kliep.py feat: Update _kliep.py Sep 7, 2022
@antoinedemathelin
Copy link
Collaborator

Hi @ymouad,
I corrected the other issues. Can you please rebase you fork to the main fork?

@antoinedemathelin antoinedemathelin merged commit 44c9b67 into adapt-python:master Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants