hit-computer / SC-LSTM

Implement SC-LSTM model for text generation in control of words, in Python/TensorFlow
88 stars 31 forks source link

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

Open liuyue94 opened 6 years ago

liuyue94 commented 6 years ago

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 commented 6 years ago

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

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

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

hit-computer commented 3 years ago

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