Last active
January 20, 2020 16:28
-
-
Save stefanondisponibile/9e5682087c6354974fcb2910b63a49b2 to your computer and use it in GitHub Desktop.
TensorFlow TextVectorizationLayer.
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
# No standardization. | |
vectorize_layer = TextVectorization(output_mode="int", max_tokens=5, standardize=None) | |
# Lowercase text and strip punctuation. [DEFAULT] | |
vectorize_layer = TextVectorization(output_mode="int", max_tokens=5, standardize="lower_and_strip_punctuation") | |
# Apply a custom standardization function. | |
def replace_foo_with_bar(input_data): | |
return tf.strings.regex_replace(input_data, "foo", "bar") | |
vectorize_layer = TextVectorization(output_mode="int", max_tokens=5, standardize=replace_foo_with_bar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment