Last active
January 17, 2022 20:44
-
-
Save eileen-code4fun/dc36634779d20c632844fefc206e8029 to your computer and use it in GitHub Desktop.
NO_OP
This file contains hidden or 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
def preprocess(dataset, fn): | |
features = [] | |
labels = [] | |
for example, label in dataset: | |
features.append(fn(example.numpy().decode('utf-8'))) | |
labels.append(label.numpy()) | |
features_dataset = tf.data.Dataset.from_tensor_slices(features) | |
labels_dataset = tf.data.Dataset.from_tensor_slices(labels) | |
return tf.data.Dataset.zip((features_dataset, labels_dataset)) | |
def no_op(txt): | |
return txt | |
train = preprocess(train_dataset, no_op) | |
test = preprocess(test_dataset, no_op) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment