def _KeenerMatrix(self, A, C, regularization, func, epsilon):
"""func is a regularization function imposed on every element of matrix.
"""
# Apply Laplace Law
B = A+A.T+2;
A = A+1
A = A/B
# Regularization
if func is not None:
h = np.frompyfunc(func, 1, 1)
A = np.require(h(A), dtype=np.float32)
# divide by contest number
C = C+C.T
c = np.sum(C, axis=1)
if regularization:
A = A/np.expand_dims(c, axis=1)
A[C==0]=0
if epsilon is not None:
A += epsilon*np.ones(A.shape, A.dtype)
return A
评论列表
文章目录