DNGR.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:DNGR-Keras 作者: MdAsifKhan 项目源码 文件源码
def PPMI_matrix(M):

    M = scale_sim_mat(M)
    nm_nodes = len(M)

    col_s = np.sum(M, axis=0).reshape(1,nm_nodes)
    row_s = np.sum(M, axis=1).reshape(nm_nodes,1)
    D = np.sum(col_s)
    rowcol_s = np.dot(row_s,col_s)
    PPMI = np.log(np.divide(D*M,rowcol_s))
    PPMI[np.isnan(PPMI)] = 0.0
    PPMI[np.isinf(PPMI)] = 0.0
    PPMI[np.isneginf(PPMI)] = 0.0
    PPMI[PPMI<0] = 0.0

    return PPMI
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号