def _calcWordTypeCooccurMatrix(self, Q, sameWordVec, nDoc):
""" Transform building blocks into the final Q matrix
Returns
-------
Q : 2D array, size W x W (where W is vocab_size)
"""
Q /= np.float32(nDoc)
sameWordVec /= np.float32(nDoc)
diagIDs = np.diag_indices(self.vocab_size)
Q[diagIDs] -= sameWordVec
# Fix small numerical issues (like diag entries of -1e-15 instead of 0)
np.maximum(Q, 1e-100, out=Q)
return Q
评论列表
文章目录