EntitySentiment icon indicating copy to clipboard operation
EntitySentiment copied to clipboard

Error in base.py

Open ttavni opened this issue 7 years ago • 2 comments

ValueError Traceback (most recent call last) in () 10 model = BRNN(L0, U0=None, alpha=0.05, rseed=10, bptt=20) 11 #print w ---> 12 curve = model.train_sgd(X,Y,idxiter_random,None,400,400) 13 score1.append(build_confusion_matrix(X_dev,Y_dev,model)) 14 print score1

/Users/Desktop/Python/EntitySentiment-master/nn/base.py in train_sgd(self, X, y, idxiter, alphaiter, printevery, costevery, devidx) 384 printevery=10000, costevery=10000, 385 devidx=None): --> 386 if idxiter==None: # default training schedule 387 idxiter = xrange(len(y)) 388 if alphaiter == None: # default training schedule

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

ttavni avatar Jan 09 '18 16:01 ttavni

I have the same error:

$ 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()

@tavni96 did you solve it?

monajalal avatar Mar 09 '18 03:03 monajalal

Fix with if idxiter is None: Don't use == comparisons when testing for nullity, use is instead, it's safer and faster.

Coldsp33d avatar Mar 09 '18 04:03 Coldsp33d