'AttributeError: module 'bert' has no attribute 'Layer'

I imported :

from bert.model import BertModelLayer

But I got the error :

class PositionEmbeddingLayer(bert.Layer): AttributeError: module 'bert' has no attribute 'Layer'

I also tried with :

from bert import BertModelLayer

But it also doesn't work!



Solution 1:[1]

I guess you have to install pip install bert-for-tf2

Reference: https://pypi.org/project/bert-for-tf2/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitry Barsukoff