def test_get_targ(self, other, T = 5e-3, outlierprior=1e-1, outlierfrac=1e-2, outliercutoff=1e-2, norm_iters = DEFAULT_NORM_ITERS): self.transform_points() other.transform_points() init_prob_nm(self.pt_ptrs, other.pt_ptrs, self.pt_w_ptrs, other.pt_w_ptrs, self.dims_gpu, other.dims_gpu, self.N, outlierprior, outlierfrac, T, self.corr_cm_ptrs, self.corr_rm_ptrs) norm_prob_nm(self.corr_cm_ptrs, self.corr_rm_ptrs, self.dims_gpu, other.dims_gpu, self.N, outlierfrac, norm_iters, self.r_coef_ptrs, self.c_coef_rn_ptrs, self.c_coef_cn_ptrs) get_targ_pts(self.pt_ptrs, other.pt_ptrs, self.pt_w_ptrs, other.pt_w_ptrs, self.corr_cm_ptrs, self.corr_rm_ptrs, self.r_coef_ptrs, self.c_coef_rn_ptrs, self.c_coef_cn_ptrs, self.dims_gpu, other.dims_gpu, outliercutoff, self.N, self.pt_t_ptrs, other.pt_t_ptrs) n, m = self.dims[0], other.dims[0] x = self.pts[0].get()[:n] xw = self.pts_w[0].get()[:n] xt = self.pts_t[0].get()[:n] y = other.pts[0].get()[:m] yw = other.pts_w[0].get()[:m] yt = other.pts_t[0].get()[:m] init_corr = self.corr_rm[0].get() init_corr = init_corr.flatten()[:(n + 1) * (m + 1)].reshape(n+1, m+1).astype(np.float32) gpu_c_cn_coefs = self.c_coefs_cn[0].get().flatten()[:m + 1].reshape(m+1) gpu_c_rn_coefs = self.c_coefs_rn[0].get().flatten()[:m + 1].reshape(m+1) gpu_r_coefs = self.r_coefs[0].get().flatten()[:n + 1].reshape(n+1) rn_corr = (init_corr * gpu_c_rn_coefs[None, :]) * gpu_r_coefs[:, None] cn_corr = (init_corr * gpu_c_cn_coefs[None, :]) * gpu_r_coefs[:, None] rn_corr = rn_corr[:n, :m] cn_corr = cn_corr[:n, :m] wt_n = rn_corr.sum(axis=1) inlier = wt_n > outliercutoff xtarg = np.empty((n, DATA_DIM)) xtarg[inlier, :] = rn_corr.dot(y)[inlier, :] xtarg[~inlier, :] = xw[~inlier, :] if not np.allclose(xtarg, xt): print "xt values differ" ipy.embed() sys.exit(1) wt_m = cn_corr.sum(axis=0) inliner = wt_m > outliercutoff ytarg = np.empty((m, DATA_DIM)) ytarg[inlier, :] = cn_corr.T.dot(x)[inliner, :] ytarg[~inlier, :] = yw[~inlier, :] if not np.allclose(ytarg, yt): print "yt values differ" ipy.embed() sys.exit(1)
def get_target_points( self, other, outlierprior=1e-1, outlierfrac=1e-2, outliercutoff=1e-2, T=5e-3, norm_iters=DEFAULT_NORM_ITERS ): """ computes the target points for self and other using the current warped points for both """ init_prob_nm( self.pt_ptrs, other.pt_ptrs, self.pt_w_ptrs, other.pt_w_ptrs, self.dims_gpu, other.dims_gpu, self.N, outlierprior, outlierfrac, T, self.corr_cm_ptrs, self.corr_rm_ptrs, ) sync() norm_prob_nm( self.corr_cm_ptrs, self.corr_rm_ptrs, self.dims_gpu, other.dims_gpu, self.N, outlierfrac, norm_iters, self.r_coef_ptrs, self.c_coef_rn_ptrs, self.c_coef_cn_ptrs, ) sync() get_targ_pts( self.pt_ptrs, other.pt_ptrs, self.pt_w_ptrs, other.pt_w_ptrs, self.corr_cm_ptrs, self.corr_rm_ptrs, self.r_coef_ptrs, self.c_coef_rn_ptrs, self.c_coef_cn_ptrs, self.dims_gpu, other.dims_gpu, outliercutoff, self.N, self.pt_t_ptrs, other.pt_t_ptrs, ) sync()