Some word vectors return values of infinite or -infinite

Home / Uncategorized / Some word vectors return values of infinite or -infinite

Question:
I trained my word vector like i normally would. I cleaned the text before hand where each line is a sentence with tokens separated by a space
class Sentences:def __init__(self):pass

def __iter__(self):i = 0
with codecs.open(‘./data/cleaned_corpus.txt’, ‘r’, ‘utf-8’) as file:for line in file:i += 1
if i % 5000 == 0:print(‘processed ‘ + str(i))

yield line.split()

w2v = Word2Vec(Sentences(), size=100, min_count=10)
w2v.wv.save(‘model’)
The issue is that some of the vectors return arrays with values that are numpy infs
array([-inf, inf, -inf, inf, inf, inf, inf, inf, -inf, -inf, inf,
inf, -inf, -inf, inf, inf, -inf, -inf, inf, inf, inf, -inf,
inf, inf, -inf, -inf, -inf, inf, -inf, inf, -inf, inf, inf,
-inf, -inf, inf, inf, inf, inf, inf, inf, inf, -inf, -inf,
-inf, -inf, inf, inf, inf, -inf, -inf, -inf, -inf, -inf, -inf,
-inf, -inf, -inf, -inf, inf, -inf, inf, inf, inf, inf, -inf,
inf, -inf, -inf, -inf, -inf, inf, inf, inf, inf, -inf, inf,
-inf, -inf, inf, inf, inf, inf, -inf, inf, -inf, -inf, inf,
-inf, -inf, inf, inf, inf, -inf, -inf, inf, -inf, -inf, -inf,
inf], dtype=float32)
I’ve already retrained the vector 3 times, I don’t know what’s causing this


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *