litian96 / fair_flearn

Fair Resource Allocation in Federated Learning (ICLR '20)
MIT License
242 stars 59 forks source link

An issue about the function flearn.utils.model_utils.project #10

Closed WwZzz closed 3 years ago

WwZzz commented 3 years ago

Dear author, sorry for bothering you again. When I use optimizer 'afl', I notice the function 'flearn.utils.model_utils.project' sometimes returns a result not in the probability simplex. image image Then I read the article "Projection onto the probability simplex: An efficient algorithm with a simple proof, and an application" and compare the algorithm with your code. I think 'np.asarray(u)[:i]' should be replaced by 'np.asarray(u)[:i+1]' in the red line.
image image And after this change, it projects a result in the probability simplex. image image

litian96 commented 3 years ago

Thanks for catching it! Yes, you are correct---this is an error when we were cleaning up the code for the release.