Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'config' #14

Open
KangChou opened this issue May 25, 2022 · 1 comment
Open

AttributeError: 'NoneType' object has no attribute 'config' #14

KangChou opened this issue May 25, 2022 · 1 comment

Comments

@KangChou
Copy link

  • UBUNTU16.04
  • PYTHON3.6

# of word in train: 55304: 
# of n-gram in memory: 71499
Traceback (most recent call last):
  File "wmseg_main.py", line 677, in <module>
    main()
  File "wmseg_main.py", line 667, in main
    train(args)
  File "wmseg_main.py", line 101, in train
    seg_model = WMSeg(word2id, gram2id, label_map, hpara, args)
  File "/data/my_project/nlp_text/WMSeg/wmseg_model.py", line 98, in __init__
    self.hpara['config'] = self.bert.config
AttributeError: 'NoneType' object has no attribute 'config'
@YingZhuY
Copy link

你需要在 bert 预训练模型同目录下加个 config.json 文件

bert

比如我用的 bert-base-chinese 就是

{
  "attention_probs_dropout_prob": 0.1, 
  "directionality": "bidi", 
  "hidden_act": "gelu", 
  "hidden_dropout_prob": 0.1, 
  "hidden_size": 768, 
  "initializer_range": 0.02, 
  "intermediate_size": 3072, 
  "max_position_embeddings": 512, 
  "num_attention_heads": 12, 
  "num_hidden_layers": 12, 
  "pooler_fc_size": 768, 
  "pooler_num_attention_heads": 12, 
  "pooler_num_fc_layers": 3, 
  "pooler_size_per_head": 128, 
  "pooler_type": "first_token_transform", 
  "type_vocab_size": 2, 
  "vocab_size": 21128
}

具体方法可参考 此博客

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants