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

Instability of entmax bisect around 0? #36

Open
azhx opened this issue Apr 10, 2024 · 2 comments
Open

Instability of entmax bisect around 0? #36

azhx opened this issue Apr 10, 2024 · 2 comments

Comments

@azhx
Copy link

azhx commented Apr 10, 2024

Hi, I was plotting the output of the entmax_bisect function at different levels of alpha

from matplotlib import pyplot as plt
x = torch.linspace(-1, 1, 10000).unsqueeze(-1)
x = torch.cat((x, torch.zeros_like(x)), dim=-1)
y = entmax_bisect(x, 10, dim=-1)[..., 0]

plt.plot(x.numpy(), y.numpy())

Here's what I'm getting
image

I'm expecting this to be a smooth function except for two points when it transitions to 0 or 1

Any explanation for this?

@bpopeters
Copy link
Collaborator

Hello,

The issue seems to be about numerical stability (I can tell because the plot looks closer to expected when I switched to float64). We haven't really optimized for very large alpha values (10 is an extremely large alpha value) because mathematically it becomes almost an expensive-to-compute step function/argmax. Do you have an application in mind for which you need this?

@1207382225
Copy link

hello,I use entmax_bisect(x, 1.33, dim=-1),get alpha<0.do you know why?

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

3 participants