Hi,
I am getting this error when calling the predict function in regressor.
AttributeError Traceback (most recent call last)
in
----> 1 regressor.predict(corpus.test[0:3])~/anaconda3/envs/torch/lib/python3.8/site-packages/flair/models/text_regression_model.py in predict(self, sentences, mini_batch_size, embedding_storage_mode)
67
68 for (sentence, score) in zip(batch, scores.tolist()):
---> 69 sentence.labels = [Label(value=str(score[0]))]
70
71 # clearing token embeddings to save memoryAttributeError: can't set attribute
Should it be sentence.set_labels() here?
Thanks
Hi,
I received the exact same error.
@heukirne Any insights here?
Thanks
@aditya-malte , I help this project a long time ago, can't remeber this error.
Do you have the Traceback?
The traceback is exactly the same as the one mentioned by the author of this issue
`AttributeError Traceback (most recent call last)
in
----> 1 regressor.predict(corpus.test[0:3])
~/anaconda3/envs/torch/lib/python3.8/site-packages/flair/models/text_regression_model.py in predict(self, sentences, mini_batch_size, embedding_storage_mode)
67
68 for (sentence, score) in zip(batch, scores.tolist()):
---> 69 sentence.labels = [Label(value=str(score[0]))]
70
71 # clearing token embeddings to save memory
AttributeError: can't set attribute`
Also tried the solution suggested earlier in this thread by @cpuyyp . I think the issue might be that the sentence object is immutable. Trying an alternate approach where a new object gets created.
We're running in to the same issue; feel free to keep us posted @aditya-malte
Sure :)
Have you tried to run your code similarly to the regression tests?
https://github.com/flairNLP/flair/blob/master/tests/test_text_regressor.py
Yes you're right, its an error in the way the labels are set. I'll put in a PR to fix this!
Should be fixed now! If you install directly from master, you can test.
~
pip install --upgrade git+https://github.com/flairNLP/flair.git
~
Great! The problem appears to be solved now. Thanks for such a quick resolution.
Most helpful comment
Should be fixed now! If you install directly from master, you can test.
~pip install --upgrade git+https://github.com/flairNLP/flair.git
~