Skip to content

Instantly share code, notes, and snippets.

@eustin
Created May 25, 2020 22:38
Show Gist options
  • Save eustin/d57b208cb2b9f337624e034591de4b93 to your computer and use it in GitHub Desktop.
Save eustin/d57b208cb2b9f337624e034591de4b93 to your computer and use it in GitHub Desktop.
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