def create_zca(imgs, filter_bias=0.1):
meanX = np.mean(imgs, axis=0)
covX = np.cov(imgs.T)
D, E = np.linalg.eigh(covX + filter_bias * np.eye(covX.shape[0], covX.shape[1]))
assert not np.isnan(D).any()
assert not np.isnan(E).any()
assert D.min() > 0
D **= -.5
W = np.dot(E, np.dot(np.diag(D), E.T))
def transform(images):
return np.dot(images - meanX, W)
return transform
评论列表
文章目录