gensim.matutils.unitvec()

gensim.matutils.unitvec(vec, norm='l2')[source]

Scale a vector to unit length. The only exception is the zero vector, which is returned back unchanged.

Output will be in the same format as input (i.e., gensim vector=>gensim vector, or numpy array=>numpy array, scipy.sparse=>scipy.sparse).