Infer Vector Doc2Vec

35 views
Skip to first unread message

Divya Gangwani

unread,
Feb 28, 2022, 3:52:57 PM2/28/22
to Gensim
I am using Doc2Vec for paragraph embedding .  I am following exact steps from 

when I reached to this step :
category_vector = [model.infer_vector((dummy['category_list_clean'][i]).split(' ')) for i in range(0,len(dummy['category_list_clean']))]

This gives me key error : 0 

Gordon Mohr

unread,
Mar 1, 2022, 4:03:13 PM3/1/22
to Gensim
Without the full error message – with multiple lines of 'traceback' info, showing involved files & lines-of-code – it's much harder to guess what's going wrong for you. 

Also, it's anyone's guess what your code...

    (dummy['category_list_clean'][i]).split(' ')) for i in range(0,len(dummy['category_list_clean'])

...might be returning.

But, if you get an error calling a method, you are very likely calling it with bad, or at least inappropriate, arguments, so the 1st order of business is figuring out what you're passing-in. So, take a look at what that code is returning – assigning it to its own temp var if need be. If it's not a simple list of string words, it's not what `.infer_vector()` is expecting.

- Gordon

Reply all
Reply to author
Forward
0 new messages