Skip to content

Instantly share code, notes, and snippets.

@NoelKennedy
Created May 4, 2018 10:15
Show Gist options
  • Save NoelKennedy/775f88a3ce31c3f75326e2d9d62a6290 to your computer and use it in GitHub Desktop.
Save NoelKennedy/775f88a3ce31c3f75326e2d9d62a6290 to your computer and use it in GitHub Desktop.
Sentence initialisation for word2vec
def make_random_input_sentence(sequence_length=300,word2vec):
import random
input_words=list()
input_sentence=list()
for i in range(0,sequence_length):
word=random.choice(list(sg.wv.vocab.keys()))
input_words.append(word)
vector=word2vec[word]
input_sentence.append(vector)
input_sentence=np.array(input_sentence)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment