How To Use Cosssim In Gensim
My questioon is about cossim usage. I have this fragment of a very big fuction: for elem in lList: temp = [] try: x = dict(np.ndenumerate(np.asarray(model[elem])))
Solution 1:
The arguments of gensim.matutils.cossim are expected to be of type list of (int, float)
but you are using dictionaries.
The exception happens in the cossim
function with the following cossim implementation:
vec1, vec2 = dict(vec1), dict(vec2)
With the correct type, dict(vec)
works:
dict([(1, 2.), (3, 4.), (5, 6.)])
But if you do not provide the correct type, it throws the exception, for instance with:
dict([1, 2, 3])
Post a Comment for "How To Use Cosssim In Gensim"