Last active
October 24, 2019 18:39
-
-
Save LysandreJik/9df5034d53944f9a7d88c6eefa8b4d00 to your computer and use it in GitHub Desktop.
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
model = TFBertForSequenceClassification.from_pretrained("bert-base-cased") | |
tokenizer = BertTokenizer.from_pretrained("bert-base-cased") | |
data = tensorflow_datasets.load("glue/mrpc") | |
train_dataset = data["train"] | |
train_dataset = glue_convert_examples_to_features(train_dataset, tokenizer, 128, 'mrpc') | |
optimizer = tf.keras.optimizers.Adam(learning_rate=3e-5, epsilon=1e-08, clipnorm=1.0) | |
loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) | |
metric = tf.keras.metrics.SparseCategoricalAccuracy('accuracy') | |
model.compile(optimizer=optimizer, loss=loss, metrics=[metric]) | |
model.fit(train_dataset, epochs=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment