'Embedding' object has no attribute 'shape'
Author: whitedelay
Pull request: no

## ❓ Questions & Help

**version**
tensorflow : 2.0.0
tensorflow-gpu : 2.0.0
torch : 1.3.1
transformers : 2.3.0

Also I'm using **google Colab**

I want to convert tf pretrained-model(for Korean) to pytorch model.

I just tried below code
**config = BertConfig.from_json_file(BERT_PATH+'/config.json')
model = BertForPreTraining.from_pretrained(BERT_PATH, from_tf=True, config=config)**

However, 
![image](https://user-images.githubusercontent.com/38174055/73248452-58745280-41f6-11ea-9335-e35b46df801a.png)
this error comes out.. ;(

in the BERT_PATH, 
-config.json
-model.ckpt.data-00000-of-00001
-model.ckpt.meta
-model.ckpt.index
-vocab.txt

Can anyone help me?
I found some similar issues, but it didn't help...





Comments:
You can't import a .ckpt file directly in a PyTorch model. You first need to convert your obtained BERT model to our format, using the script [convert_bert_original_tf_checkpoint_to_pytorch](https://github.com/huggingface/transformers/blob/master/src/transformers/convert_bert_original_tf_checkpoint_to_pytorch.py). It will then be usable in our TensorFlow/PyTorch architectures.

@LysandreJik  

Thanks for the comment! I've used 'convert_bert_original_tf_checkpoint_to_pytorch' but, same issue occurred.. ;(

![image](https://user-images.githubusercontent.com/38174055/73320666-7045e800-4283-11ea-8ffb-c8eff5bff593.png)
![image](https://user-images.githubusercontent.com/38174055/73320679-79cf5000-4283-11ea-9c70-b51bf9355e98.png)




If I understand correctly, you used this `convert_bert_original_tf_checkpoint_to_pytorch` script to convert it to a PyTorch model, which was dumpes in a `HanBert-54kN` folder?

Did you try using:

```py
model = BertForPreTraining.from_pretrained("HanBert-54kN")
```

? Does it raise the same error ?

yes, I've tried that before.
Is it because of the version conflict?
I recently recognized that the HanBert is pre-trained under tensorflow-gpu 1.11.0.

For me, the same problem occurred and I solved it by changing the corresponding block of load_tf_weights_in_bert function as follows:

Original:
```
        try:
            assert pointer.shape == array.shape
        except AssertionError as e:
            e.args += (pointer.shape, array.shape)
            raise
```

Changed
```
        try:
            if type(pointer).__name__ != 'Parameter':
                assert pointer.shape == array.shape
            else:
                if pointer.shape != array.shape:
                    if pointer.shape == array.transpose().shape:
                        array = array.transpose()
                assert pointer.shape == array.shape
        except AssertionError as e:
            e.args += (pointer.shape, array.shape)
            raise
```

I found that this code works without previous error, but I don't check the working of the converted parameter with this code yet... So please warn about that.

@whitedelay 

I've also confront the same issue. It's because the convert function can't skip the `optimizer parameter`. I've raised the [PR](https://github.com/huggingface/transformers/pull/2652) regarding with this issue.

@monologg 

Oh, I see. Thank you so much! 😊

I have the same problem (perhaps the PR didn't solve this issue). what can I do about it?

Hello, i am facing this same issue. If anyone found a solution already, please share it.

hi  how to solve it？ @monologg @henrique-voni