Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gensim KeydVectors dimensions

Im gensims latest version, loading trained vectors from a file is done using KeyedVectors, and dosent requires instantiating a new Word2Vec object. But now my code is broken because I can't use the model.vector_size property. What is the alternative to that? I mean something better than just kv[kv.index2word[0]].size.

like image 802
proton Avatar asked Apr 04 '17 08:04

proton


1 Answers

kv.vector_size still works; I'm using gensim 2.3.0, which is the latest as I write. (I am assuming kv is your KeyedVectors object.) It appears object properties are not documented on the API page, but auto-complete suggests it, and there is no deprecated warning or anything.

Your question helped me answer my own, which was how to get the number of words: len(kv.index2word)

like image 149
Darren Cook Avatar answered Oct 13 '22 12:10

Darren Cook