Skip to content

Instantly share code, notes, and snippets.

@henry16lin
Created February 15, 2020 15:04
Show Gist options
  • Save henry16lin/a5b7b17071beac7b940587c7c98e34d7 to your computer and use it in GitHub Desktop.
Save henry16lin/a5b7b17071beac7b940587c7c98e34d7 to your computer and use it in GitHub Desktop.
load_bert
from transformers import BertForSequenceClassification
NUM_LABELS = 2
model = BertForSequenceClassification.from_pretrained(
PRETRAINED_MODEL_NAME, num_labels=NUM_LABELS)
print("""
name module
--------------------""")
for name, module in model.named_children():
if name == "bert":
for n, _ in module.named_children():
print("{:10}{}".format(name,n) )
else:
print("{:10} {}".format(name, module))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment