Created
June 29, 2022 14:44
-
-
Save Rocketknight1/56ad64716ea1a0531087ced48299b730 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
import tensorflow as tf | |
from transformers import TFAutoModel, TFBertTokenizer | |
class EndToEndModel(tf.keras.Model): | |
def __init__(self, checkpoint): | |
super().__init__() | |
self.tokenizer = TFBertTokenizer.from_pretrained(checkpoint) | |
self.model = TFAutoModel.from_pretrained(checkpoint) | |
def call(self, inputs): | |
tokenized = self.tokenizer(inputs) | |
return self.model(**tokenized) | |
model = EndToEndModel(checkpoint='bert-base-cased') | |
test_inputs = [ | |
'This is a test sentence!', | |
'This is another one!' | |
] | |
model.predict(test_inputs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment