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

ValueError: sum(pvals[:-1]) > 1.0 #4

Open
saitaiky opened this issue Mar 22, 2017 · 5 comments
Open

ValueError: sum(pvals[:-1]) > 1.0 #4

saitaiky opened this issue Mar 22, 2017 · 5 comments

Comments

@saitaiky
Copy link

saitaiky commented Mar 22, 2017

def __sample(a, temperature=1.0):
a = np.log(a) / temperature
a = np.exp(a) / np.sum(np.exp(a))
return np.argmax(np.random.multinomial(1, a, 1))

It shows up multinomial has an error
np.argmax(np.random.multinomial(1, a, 1))
File "mtrand.pyx", line 4593, in mtrand.RandomState.multinomial (numpy\random\mtrand\mtrand.c:37541)
ValueError: sum(pvals[:-1]) > 1.0

@saitaiky
Copy link
Author

Here is my solution: The problem is because of the probabilities sometimes sum to just above 1.0
I dunno much about the maths, but there is my work around.
a = np.log(a) / temperature dist = np.exp(a)/np.sum(np.exp(a)) choices = range(len(a)) return np.random.choice(choices, p=dist)

@developerator
Copy link

Thanks a lot for this workaround, had the same issue. @llSourcell Please adopt it

@japrogramer
Copy link

Had this problem too, @saitai0802 patch seems to allow it to continue and finish. not shure if the result is better, if the probabilities are adding up to more than 1, something else is causing that.

@jasondesante
Copy link

jasondesante commented Sep 17, 2017

I have the same issue

was fixed with the workaround

then I got another error that said I needed to install pygame

after that it worked

but I also had a bunch of errors before posting here, like a whole bunch of the code was written for python 2 but I'm using python 3.....not sure if I was supposed to use python 2 at the start

@PandaWhoCodes
Copy link

I have uploaded a python3 version here - for anyone who needs it

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

5 participants