问题
How should I fix this error? Seems like an unresolved issue in this repository: https://github.com/shayanzare007/EntitySentiment/issues/7
$ python RunRNN.py
Number of unique words: 9869
Opening the file...
File successfully read
Opening the file...
File successfully read
Opening the file...
File successfully read
Number of training samples 5003
Traceback (most recent call last):
File "RunRNN.py", line 84, in <module>
curve = model.train_sgd(X,Y,idxiter_random,None,400,400)
File "/scratch2/debate_tweets/sentiment/EntitySentiment/nn/base.py", line 386, in train_sgd
if idxiter == None: # default training schedule
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
回答1:
When testing an object for nullity, the recommended practice is to always use is
:
if idxiter is None:
...
It's safer, especially because not all objects support equality comparisons with None
.
来源:https://stackoverflow.com/questions/49186324/best-way-to-check-if-an-object-is-none