Last active
December 4, 2020 14:47
-
-
Save Sirsirious/9ba0a9658351ddb31ebbba263f3046ac 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
# First, we need the same structure: | |
new_model = tl.Serial( | |
tl.Embedding(data.vocab_size(vocab_file='en_8k.subword'), d_feature=256), | |
tl.Mean(axis=1), | |
tl.Dense(2), | |
tl.LogSoftmax() | |
) | |
# Then, we load the weights: | |
new_model.init_from_file(file_name="/root/output_dir/model.pkl.gz", weights_only=True) # Only load weights | |
# Same result as before (I used a helper function for simplicity) | |
print("The sentiment is: ", parse_sentiment("Very bad movie", new_model)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment