Closed hlian188 closed 3 years ago
I'm not sure what might be causing the problem. Could you please post the code that is causing the error and print logits
right before you get the error? And also the complete error message.
I also get the same error. Please see the code I used and the logits before the error
When I modify the code like hlian1888 (logits = softmax(np.array(logits[0]))), I get these results which are different from the notebook on github
My results
@sharebear1993 sorry for the very late response. This problem should be fixed with the latest commit.
When I call predict, I get the error "only one element tensors can be converted to Python scalars" on line 618 of finbert.py. When I modify the line from:
logits = softmax(np.array(logits))
tologits = softmax(np.array(logits[0]))
I get no error, but the predictions and sentiment scores do not seem right when I tested it on examples.csv. The logit looks like [small number, .99..., small number], so the labels are all negative and the scores are all around -.99...
For reference, I copied predict.py, finbert.py, and util.py into a jupyter notebook and used the following as my model
model = BertForSequenceClassification.from_pretrained("ipuneetrathore/bert-base-cased-finetuned finBERT",num_labels=3,cache_dir=None)