Created
May 25, 2020 22:38
-
-
Save eustin/d57b208cb2b9f337624e034591de4b93 to your computer and use it in GitHub Desktop.
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 make_skipgrams(): | |
train_x, all_labels = [], [] | |
for sequence in sequences: | |
pairs, labels = tf.keras.preprocessing.sequence.skipgrams( | |
sequence, VOCAB_SIZE, negative_samples=1.0, window_size=1, shuffle=True | |
) | |
train_x.extend(pairs) | |
all_labels.extend(labels) | |
train_x = np.array(train_x) | |
all_labels = np.array(all_labels, dtype=np.float32) | |
content_words = train_x[:, 0] | |
context_words = train_x[:, 1] | |
return content_words, context_words, all_labels | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment