Last active
February 5, 2021 17:02
-
-
Save RayWilliam46/46a3adba467b73396b26ae0be370ff47 to your computer and use it in GitHub Desktop.
Imports the base DistilBERT architecture from the Hugging Face library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import TFDistilBertModel, DistilBertConfig | |
DISTILBERT_DROPOUT = 0.2 | |
DISTILBERT_ATT_DROPOUT = 0.2 | |
# Configure DistilBERT's initialization | |
config = DistilBertConfig(dropout=DISTILBERT_DROPOUT, | |
attention_dropout=DISTILBERT_ATT_DROPOUT, | |
output_hidden_states=True) | |
# The bare, pre-trained DistilBERT transformer model outputting raw hidden-states | |
# and without any specific head on top. | |
distilBERT = TFDistilBertModel.from_pretrained('distilbert-base-uncased', config=config) | |
# Make DistilBERT layers untrainable | |
for layer in distilBERT.layers: | |
layer.trainable = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment