Skip to content

Word2Vec 负样本 id 没有做到单词的映射 #982

@KiraYeetar

Description

@KiraYeetar

word2vec_reader.py 第 116 行左右

  for i in range(self.neg_num):
      tmp.append(random.random())
  neg_array = self.cs.searchsorted(tmp)

  output.append(
      np.array([int(i)
                for i in neg_array]).astype('int64'))

  yield output

负采样得到的 id 用的是采样 list (self.cs) 的 index 值,并且直接作为了输出,没有映射到单词的 word_id,这可能导致模型的负采样逻辑完全出错。

另外,在取 context 词的时候为什么要对 window_size 的大小做随机呢,是为了 demo 能快速运行吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions