Skip to content

Instantly share code, notes, and snippets.

View Rocketknight1's full-sized avatar

Matt Rocketknight1

View GitHub Profile
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)
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)
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]
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]
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):
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):
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 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 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 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__()