Skip to content

Issue in function random(x, a) #7

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

Closed
transtrongwind opened this issue May 22, 2023 · 1 comment
Closed

Issue in function random(x, a) #7

transtrongwind opened this issue May 22, 2023 · 1 comment

Comments

@transtrongwind
Copy link

The following function in nda.optimizers.compressor seems incorrect. It does not keep a values; instead it keeps dim-a values.

Random_a compressor, keep a values

def random(x, a):
dim = x.shape[0]
if a == 0:
return 0
if a == dim:
return x
if x.ndim == 2:
for i in range(x.shape[1]):
zero_mask = xp.random.choice(dim, a, replace=False)
x[zero_mask, i] = 0
else:
zero_mask = xp.random.choice(dim, a, replace=False)
x[zero_mask] = 0
return x

To correct the above issue, replace:
xp.random.choice(dim, a, replace=False)
with
xp.random.choice(dim, dim-a, replace=False)

@liboyue
Copy link
Owner

liboyue commented May 24, 2023

Hi @letrieuphong, thanks a lot for finding out this bug. Already fixed.

@liboyue liboyue closed this as completed May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants