Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问运行preprocess.py报这个错,该怎么解决啊? #15

Open
liuyue94 opened this issue Oct 28, 2018 · 3 comments
Open

请问运行preprocess.py报这个错,该怎么解决啊? #15

liuyue94 opened this issue Oct 28, 2018 · 3 comments

Comments

@liuyue94
Copy link

Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/textgeneration/Preprocess.py", line 77, in
vocab, _ = Read_WordVec(config)
File "C:/Users/user/PycharmProjects/textgeneration/Preprocess.py", line 36, in Read_WordVec
assert len(wordLS) == config.vocab_size
AssertionError

@TobiasLee
Copy link

这里的 word2vec 文件存储的格式是第一行注明 vocab_siz embedding_size 的,读取的时候跳过了这一行。猜测是因为少了一行导致,可以把读取第一行的注释掉:

def Read_WordVec(config):
    with open(config.vec_file, 'r') as fvec:
        wordLS = []
        vec_ls =[]
        # fvec.readline() # 这一行是读取文件头信息的,如果没有信息可以注释掉,避免 size 不匹配

@19970623
Copy link

您好,请问这个问题解决了吗,我注释了fvec.readline(),但依然报错assert len(wordLS) == config.vocab_size
AssertionError

@hit-computer
Copy link
Owner

@19970623 这里把 vocab_size 设置成词表大小就行了(即和 vec_file 里word数量相同)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants