embedding.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:histwords 作者: williamleif 项目源码 文件源码
def __init__(self, path, normalize=True, eig=0.0, **kwargs):
        ut = np.load(path + '-u.npy', mmap_mode="c")
        s = np.load(path + '-s.npy', mmap_mode="c")
        vocabfile = path + '-vocab.pkl'
        self.iw = load_pickle(vocabfile)
        self.wi = {w:i for i, w in enumerate(self.iw)}

        if eig == 0.0:
            self.m = ut
        elif eig == 1.0:
            self.m = s * ut
        else:
            self.m = np.power(s, eig) * ut

        self.dim = self.m.shape[1]

        if normalize:
            self.normalize()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号