Flair: AttributeError: module 'tensorflow_core.keras.activations' has no attribute 'swish'

Created on 4 Dec 2020  Â·  6Comments  Â·  Source: flairNLP/flair

I am very new to this flair package but belive that it can help me resolve the current challenges I am facing right now. I am just trying to get some basics right and while using the following code:

from flair.data import Sentence
sentence = Sentence('The grass is green.')
print(sentence)

I got this error:
AttributeError: module 'tensorflow_core.keras.activations' has no attribute 'swish'

Can someone explain this to me why is this happening? TF is already there on my system and I am not sure why I am getting this error

bug

All 6 comments

Hi @ishan42d, you're code is working just fine. Here's my print out:
Sentence: "The grass is green ." [− Tokens: 5]
Flair is built up on PyTorch, not on TensorFlow - so i guess it is rather another error on your side and nothing related to flair. You might wanna look at this issue here which seems more related to your problem: Issue

@whoisjones : Thank you so much! Let me look into this.

Reinstalling Tensorflow helped actually! PyTorch was running fine and was not the issue, TF was. Closing this issue

Hi, I had the same exact problem, which I can reproduce by just doing:

from flair.data import Sentence
flair_sentence = Sentence('hello')

However, looking at the repo it seems there is nothing about TF nor Keras. Do you have any insight of why this is happening? Maybe some cross-imports?

By the way, as mentioned, the issue can be resolved by changing TF version. The question is: Why a TF error?

Thanks for your work and support!

As mentioned in this issue, your problem arises from using transformers (which we are using in flair) and this is not compatible with TF versions >= 2.1

As mentioned in this issue, your problem arises from using transformers (which we are using in flair) and this is not compatible with TF versions >= 2.1

It makes a lot of sense now! Flair uses PyTorch but it has a "far" requirement with TF through transformers.

Thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jewl123 picture jewl123  Â·  3Comments

jannenev picture jannenev  Â·  3Comments

davidsbatista picture davidsbatista  Â·  3Comments

aschmu picture aschmu  Â·  3Comments

mnishant2 picture mnishant2  Â·  3Comments