

TITLE
BertEncoder has no attribute 'bias' when convert tf checkpoint

COMMENTS
1

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
# ❓ Questions & Help
BertEncoder object has no attribute 'bias' when convert tf checkpoint
<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->
I tried to convert my pretrained BERT tf checkpoint but I got this error:
```
/usr/local/lib/python3.6/dist-packages/transformers/modeling_bert.py in load_tf_weights_in_bert(model, config, tf_checkpoint_path)
    133                 pointer = getattr(pointer, "weight")
    134             elif scope_names[0] == "output_bias" or scope_names[0] == "beta":
--> 135                 pointer = getattr(pointer, "bias")
    136             elif scope_names[0] == "output_weights":
    137                 pointer = getattr(pointer, "weight")
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in __getattr__(self, name)
    770                 return modules[name]
    771         raise ModuleAttributeError("'{}' object has no attribute '{}'".format(
--> 772             type(self).__name__, name))
    773 
    774     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:
ModuleAttributeError: 'BertEncoder' object has no attribute 'bias'
```


I used both load_tf_weights_in_bert function and BertForPreTraining but it was not working.

My code:
```
config = BertConfig.from_json_file('bertvn_base/bertvn_base_config.json')
model = BertForPreTraining.from_pretrained('bertvn_base/model.ckpt', from_tf=True, config=config)
```

My config:
```
{"attention_probs_dropout_prob": 0,
"hidden_act": "gelu",
  "hidden_dropout_prob": 0,
  "embedding_size": 768,
  "hidden_size": 768,
  "initializer_range": 0.02,
  "intermediate_size": 3072,
  "max_position_embeddings": 192,
  "num_attention_heads": 12,
  "num_hidden_layers": 12,
  "num_hidden_groups": 12,
  "net_structure_type": 0,
  "gap_size": 0,
  "num_memory_blocks": 0,
  "inner_group_num": 1,
  "down_scale_factor": 1,
  "type_vocab_size": 2,
  "vocab_size": 120000
}
```

Thanks for your help!
<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->