Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weighted norm minimization #19

Closed
narges-mhm opened this issue Mar 3, 2020 · 7 comments · Fixed by #25
Closed

weighted norm minimization #19

narges-mhm opened this issue Mar 3, 2020 · 7 comments · Fixed by #25

Comments

@narges-mhm
Copy link

narges-mhm commented Mar 3, 2020

I have a problem with using weighted-l2. In fact, according to the docs, the dimension of w should be the same as the dimension of y while I get a dimension error. I need to know whether you have tried the weighted ones. The error is exactly in the same part as it is mentioned:
Nati: I've checked this code the use of 'y' seems correct

@nperraud
Copy link
Collaborator

nperraud commented Mar 3, 2020

Yes this has been tested here:

f = functions.norm_l2(A=L, tight=False, y=np.array([1, 2, 3, 4]),

Nati: I've checked this code the use of 'y' seems correct this is actually in the norm_l1

I have added some test in the norm_l1 and did not found any bugs... See this PR: #21

@nperraud nperraud closed this as completed Mar 4, 2020
@narges-mhm
Copy link
Author

narges-mhm commented Mar 4, 2020

Thanks for your response but the error still persists. Suppose A is M*N (where M>N) and consequently x dim would be Nx1 and w&y are Mx1. In this case:
class norm_l2:
def _prox:
if self.tight:
sol = x + 2. * gamma * self.At(self.y() * self.w2)
sol /= 1. + 2. * gamma * self.nu * self.w
2

from the first line sol is Nx1 and in the second line, sol is going to be divide by w which is Mx1. And that is why I get dimension error.

@nperraud
Copy link
Collaborator

nperraud commented Mar 4, 2020

Could you simply make a simple example with an error?

@nperraud nperraud reopened this Mar 4, 2020
@narges-mhm
Copy link
Author

@nperraud
Copy link
Collaborator

nperraud commented Mar 4, 2020 via email

@narges-mhm
Copy link
Author

narges-mhm commented Mar 4, 2020

import numpy as np
from pyunlocbox import functions, solvers

w=np.array([1,2,2,1])
A=np.random.normal(size=(4,3))
x=np.array([1,-1,1])
y=A@x
f1=functions.norm_l2(A=A,y=y,w=w,tight=True)
f2=functions.dummy()
step= 0.5 / np.linalg.norm(A, ord=2)**2
x1=np.array([.2,.2,.2])
solver2= solvers.generalized_forward_backward(step=step*0.1)
ret2= solvers.solve([f1,f2], x1, solver2, rtol=1e-6, maxit=1000)
objective2= np.array(ret2['objective'])

@nperraud
Copy link
Collaborator

Sorry for my late reply. I was able to reproduce the problem.

One thing that see is that you are using tight=True, which is not correct in your example. Indeed A is not a tight operator. If ignore this, the proximal solution for a tight operator requires a constant weight to be valid. Hence, if tight=True, then w should be a scalar. To solve this problem, you can simply set tight=False in your code.

i will add a check for this in the code such that one cannot define a function with multiple weights and a tight operator.

@nperraud nperraud mentioned this issue Mar 25, 2020
@mdeff mdeff linked a pull request Mar 25, 2020 that will close this issue
@mdeff mdeff closed this as completed in #25 Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants