Skip to content

Instantly share code, notes, and snippets.

@eileen-code4fun
Last active January 17, 2022 20:44
Show Gist options
  • Save eileen-code4fun/dc36634779d20c632844fefc206e8029 to your computer and use it in GitHub Desktop.
Save eileen-code4fun/dc36634779d20c632844fefc206e8029 to your computer and use it in GitHub Desktop.
NO_OP
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