Created
September 21, 2020 14:17
-
-
Save megha444/7d8a1c5795c4905ceab2a5df0f95ad2e 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
#importing the glove library | |
from glove import Corpus, Glove | |
# creating a corpus object | |
corpus = Corpus() | |
#training the corpus to generate the co occurence matrix which is used in GloVe | |
corpus.fit(new_lines, window=10) | |
#creating a Glove object which will use the matrix created in the above lines to create embeddings | |
#We can set the learning rate as it uses Gradient Descent and number of components | |
glove = Glove(no_components=5, learning_rate=0.05) | |
glove.fit(corpus.matrix, epochs=30, no_threads=4, verbose=True) | |
glove.add_dictionary(corpus.dictionary) | |
glove.save('glove.model') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment