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: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() #8

Open
Noxius888 opened this issue Mar 19, 2019 · 2 comments

Comments

@Noxius888
Copy link

Running the code brings a Value error:

0.8 -mbsize 10 -dataset nips
{'infSeed': 1, 'alpha': 1.0, 'gamma': 2.0, 'Nmax': 40, 'kappa_sgd': 0.6, 'tau': 0.8, 'mbsize': 10.0, 'dataset': 'nips'}
Loading the glove dict file....
Main runner ...
num_docs: 1566
Traceback (most recent call last):
File "./runner.py", line 225, in
HDPRunner(args)
File "./runner.py", line 121, in HDPRunner
components=[vonMisesFisherLogNormal(**obs_hypparams) for itr in range(K)]
File "./runner.py", line 121, in
components=[vonMisesFisherLogNormal(**obs_hypparams) for itr in range(K)]
File "/home/noxius/Git/sHDP/core/core_distributions.py", line 242, in init
if (mu,kappa) == (None,None) and None not in (mu_0,C_0,m_0,sigma_0):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I tried different methods, including changing the boolean check in core_distributions.py, line 243:

if ((mu,kappa) == (None,None)) and any(x != None for x in (mu_0, C_0, m_0, sigma_0)):
or
if ((mu,kappa) == (None,None)) and not any(x == None for x in (mu_0, C_0, m_0, sigma_0)):

However it doesn't change anything and the error stays. Have you any solution?

@IvanAntipov
Copy link

IvanAntipov commented Jul 17, 2019

I had the same problem and I solved it with downgrading numpy to version 1.11.3

My environment:

Ubuntu 18.04 LTS
python 3.6

@ajbouh
Copy link

ajbouh commented Jan 27, 2020

I replaced

        if (mu,kappa) == (None,None) and None not in (mu_0,C_0,m_0,sigma_0):

with

        if (mu,kappa) == (None,None) and mu_0 is not None and C_0 is not None and m_0 is not None and sigma_0 is not None:

And it seems to have made forward progress.

I also needed to replace

            logISweights = log_f - sc.misc.logsumexp(log_f)

with

            logISweights = log_f - sc.special.logsumexp(log_f)

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