Skip to content

Latest commit

 

History

History

1-2.Glove

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Pytorch implementation of Glove

原理

glove1 glove2 glove3 glove4 glove5 glove6 glove7

附SVD及应用

SVD分解将任意矩阵分解成一个正交矩阵和一个对角矩阵以及另一个正交矩阵的乘积。 glove8 glove9 glove10

可视化

Save the embedding along with the words to TSV files as shown below, upload these two TSV files to Embedding Projector for better visualization.

def save_embedding(self, outdir, idx2word):
    embeds = self.in_embed.weight.data.cpu().numpy()        
    f1 = open(os.path.join(outdir, 'vec.tsv'), 'w')
    f2 = open(os.path.join(outdir, 'word.tsv'), 'w')        
    for idx in range(len(embeds)):
        word = idx2word[idx]
        embed = '\t'.join([str(x) for x in embeds[idx]])
        f1.write(embed+'\n')
        f2.write(word+'\n')