Egidius
Egidius

Reputation: 1469

Importing BertModelLayer for Bert

I want to import BertModelLayer for Bert but I keep getting error ImportError: cannot import name 'BertModelLayer' from 'bert', I have installed bert but kept having the same error.

from bert import BertModelLayer

what is the right installation for BertModelLayer?

Upvotes: 1

Views: 1764

Answers (2)

Abhi25t
Abhi25t

Reputation: 4683

The installation command is:

pip install bert-for-tf2

as per PyPi documentation

then you can use:

from bert import BertModelLayer

I am assuming that you are using tensorflow-2

Upvotes: 2

corvusMidnight
corvusMidnight

Reputation: 648

Maybe you are looking for a different package?

Try installing bert-tensorflow instead, since bert is not the name of the package.

Upvotes: 0

Related Questions