

TITLE
ValueError: Layer weight shape (30522, 768) not compatible with provided weight shape torch.Size([1, 15, 3072])

COMMENTS
7

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

BODY
 I tried to use word embedding from using BERT as an embedding layer using Keras like that 
```
    inputs2 = Input(shape=(max_length,)) 
    sent = Embedding(vocab_size, 768, mask_zero=True)(inputs2)
    model.layers[1].set_weights([embedding_matrix])    
    model.layers[1].trainable = False
```
but got the following error 
 ```
  model.layers[1].set_weights([embedding_matrix])
  File "/home/user/.local/lib/python3.6/site-packages/keras/engine/base_layer.py", line 1801, in set_weights
    'shape %s' % (ref_shape, weight_shape))
ValueError: Layer weight shape (30522, 768) not compatible with provided weight shape torch.Size([1, 15, 3072])

```