You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
I found that someone said it occurs because of type casting.
I fixed like this, and I could fix the error.
def __sample(a, temperature=1.0):
a = np.asarray(a).astype('float64')
a = np.log(a) / temperature
a = np.exp(a) / np.sum(np.exp(a))
return np.argmax(np.random.multinomial(1, a, 1))
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
The text was updated successfully, but these errors were encountered: