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 tensorflow_addons.layers import embeddingbag | |
import numpy as np | |
from time import perf_counter | |
@tf.function | |
def composite_run(indices, values, weights): | |
with tf.GradientTape() as tape: | |
tape.watch(values) |
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 tensorflow_addons.layers import embeddingbag | |
import numpy as np | |
from time import perf_counter | |
@tf.function | |
def composite_run(indices, values, weights): | |
with tf.GradientTape() as tape: | |
tape.watch(values) |
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 AutoTokenizer, TFAutoModelForSequenceClassification | |
import tensorflow as tf | |
model_name = 'bert-base-cased' | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = TFAutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2) | |
texts = ["I'm a positive example!", "I'm a negative example!"] | |
labels = [1, 0] |
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 AutoTokenizer, TFAutoModelForSequenceClassification | |
import tensorflow as tf | |
model_name = 'bert-base-cased' | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = TFAutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2) | |
texts = ["I'm a positive example!", "I'm a negative example!"] | |
labels = [1, 0] |
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 collections import Counter | |
words = [word.strip() for word in open("wordle-answers-alphabetical.txt").readlines() if word.strip()] | |
allowed_words = [word.strip() for word in open("wordle-allowed-guesses.txt").readlines() if word.strip()] | |
allowed_words = list(set(allowed_words) | set(words)) | |
def compare_guess(guess, answer): | |
answer = list(answer) | |
output = ['X' for _ in range(len(answer))] | |
for i, letter in enumerate(guess): |
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 collections import Counter | |
words = [word.strip() for word in open("wordle-answers-alphabetical.txt").readlines() if word.strip()] | |
allowed_words = [word.strip() for word in open("wordle-allowed-guesses.txt").readlines() if word.strip()] | |
allowed_words = list(set(allowed_words) | set(words)) | |
def compare_guess(guess, answer): | |
answer = list(answer) | |
output = ['X' for _ in range(len(answer))] | |
for i, letter in enumerate(guess): |
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) | |
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
# This is a new feature, so make sure to install transformers from main first! | |
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) |
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
# This is a new feature, so make sure to install transformers from main first! | |
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) |
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
# This is a new feature, so make sure to update to the latest version of transformers! | |
# You will also need to pip install tensorflow_text | |
import tensorflow as tf | |
from transformers import TFAutoModel, TFBertTokenizer | |
class EndToEndModel(tf.keras.Model): | |
def __init__(self, checkpoint): | |
super().__init__() |
OlderNewer