kpe / bert-for-tf2

A Keras TensorFlow 2.0 implementation of BERT, ALBERT and adapter-BERT.
https://github.com/kpe/bert-for-tf2
MIT License
802 stars 193 forks source link

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

Open Innocent607 opened 3 years ago

Innocent607 commented 3 years ago

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

In embeddings.py should be "from bert.layer import Layer" not "import bert" as bert is a directory that reside in a directory bert-for-tf2.

Here is the error:

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

AttributeError Traceback (most recent call last)

in 13 import bert 14 #from bert import * ---> 15 from bert.model import BertModelLayer 16 from bert.loader import StockBertConfig, map_stock_config_to_params, load_stock_weights 17 #from bert.tokenizer.bert_tokenization import FullTokenizer ~\AppData\Local\Programs\Python\Python39\lib\site-packages\bert\model.py in 10 11 from bert.layer import Layer ---> 12 from bert.embeddings import BertEmbeddingsLayer 13 from bert.transformer import TransformerEncoderLayer 14 ~\AppData\Local\Programs\Python\Python39\lib\site-packages\bert\embeddings.py in 15 16 ---> 17 class PositionEmbeddingLayer(bert.Layer): 18 class Params(bert.Layer.Params): 19 max_position_embeddings = 512 AttributeError: module 'bert' has no attribute 'Layer' PLEASE CORRECT ME IF UM WRONG,