Created
December 14, 2020 17:48
-
-
Save Sirsirious/f49a98753daddb2ad369990e4aafec2a to your computer and use it in GitHub Desktop.
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
# To convert the model to Keras, simply run: | |
keras_layer = trax.AsKeras(sentiment_analysis_model) | |
# This will be a trax.trax2keras.AsKeras object | |
print(keras_layer) | |
# Run the Keras layer to verify it returns the same result. | |
example_input = list(data.tokenize(iter(["I loved the way that the actors were cast, also, It is clear that they've put a huge effort in post-production."]), vocab_file="en_8k.subword"))[0] | |
sentiment_activations = keras_layer(example_input[None, :]) | |
print(f'Keras returned sentiment activations: {numpy.asarray(sentiment_activations)}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment