Elimination
Elimination

Reputation: 2723

fasttext produces a different vector after training

Here's my training:

import fasttext

model = fasttext.train_unsupervised('data.txt', model='skipgram')

Now, let's observe the first vector (omitted the full output for readability)

model.get_input_vector(0)

# array([-0.1988439 ,  0.40966552,  0.47418243,  0.148709  ,  0.5891477

On the other hand, let's input the first string into our model:

model[data.iloc[0]]

# array([ 0.10782535,  0.3055557 ,  0.19097836, -0.15849613, 0.14204402

We get a different vector.

Why?

Upvotes: 1

Views: 274

Answers (1)

OmG
OmG

Reputation: 18838

You should have explained more about data structure. By the way, when you are using model[data.iloc[0]], it is equivalent to model.get_word_vector(data.iloc[0]). So, you should pass a word to the model.

On the other hand, model.get_input_vector(0) might input a sentence to the model. Therefore, you can compare the result of model.get_input_vector(0) with model.get_sentence_vector(data.iloc[0]), if data.iloc[0] is a sentence. Otherwise, you should get the first word in the data to input to the model and then compare their vectors.

Upvotes: 1

Related Questions