-
Notifications
You must be signed in to change notification settings - Fork 513
Building custom model over the final embedding layer #19
Comments
It looks that the author provided a demo: |
#7 Sentence Embedding
keras-bert/keras_bert/layers/pooling.py Lines 5 to 21 in b7ecdc3
I've added a demo for sentence embedding with pooling: keras-bert/demo/load_model/load_and_pool.py Lines 20 to 39 in 02c7eb2
|
@CyberZHG Oh sweet! Will check this out. Going through the paper for BERT cleared my masking queries. |
Thanks. The
InvalidArgumentError: Incompatible shapes: [32] vs. [32,512] Would you help
PS: |
I forgot to return a |
@CyberZHG I notice in the code above (2) model = load_trained_model_from_checkpoint(config_path, checkpoint_path, training=True, seq_len=seq_len) ` Thanks |
BERT supposedly generates 768 dimensional embeddings for tokens. I am trying to build a multi-class classification model on top of this. My assumption is that the output of layer
Encoder-12-FeedForward-Norm
of shape(None, [seq_length], 768)
would give this embeddings. This is what I am trying :I get the following error for
new_out = GlobalMaxPool1D()(new_out)
:I am not sure how masking is involved if I am just using the output of the encoder.
The paper mentions that the output corresponding to just the first
[CLS]
token should be used for classification. On trying this :the model trains (although with poor results).
How can the pre-loaded model be used for classification?
The text was updated successfully, but these errors were encountered: