ValueError: 在手套嵌入过程中,无法将字符串转换为float: '.'。

问题描述 投票:0回答:1

enter image description here我试图用Glove对单词向量进行编码,却得到了上面所说的错误。数据由两个文本列组成,用于句子相似性的确定。请你帮我解决这个错误好吗?

[代码]

embeddings_index = {}
f = open(r'C:\Users\15084\Downloads\glove.840B.300d\glove.840B.300d.txt',errors = 
'ignore',encoding='utf-8')
for line in f:
    values = line.split()
    word = values[0]
    coefs = np.asarray(values[1:], dtype='float32')
    embeddings_index[word] = coefs
f.close()

print('Found %s word vectors.' % len(embeddings_index))
python embedding glove
1个回答
0
投票

我想这对你会有帮助

f = open(r'C:\Users\15084\Downloads\glove.840B.300d\glove.840B.300d.txt',errors ='ignore',encoding='utf-8','r')
© www.soinside.com 2019 - 2024. All rights reserved.