def transform_frames(self, x_ma, rot_mad, orthogonalize="cross"): """ orthogonalize: none, svd, qr """ m, d = x_ma.shape grad_mga = tps.tps_grad(x_ma, self.lin_ag, self.trans_g, self.w_ng, self.x_na) newrot_mgd = np.array([ grad_ga.dot(rot_ad) for (grad_ga, rot_ad) in zip(grad_mga, rot_mad) ]) newpt_mg = tps.tps_eval(x_ma, self.lin_ag, self.trans_g, self.w_ng, self.x_na) if orthogonalize == "qr": newrot_mgd = orthogonalize3_qr(newrot_mgd) elif orthogonalize == "svd": newrot_mgd = orthogonalize3_svd(newrot_mgd) elif orthogonalize == "cross": newrot_mgd = orthogonalize3_cross(newrot_mgd) elif orthogonalize == "none": pass else: raise Exception("unknown orthogonalization method %s" % orthogonalize) return newpt_mg, newrot_mgd
def transform_frames(self, x_ma, rot_mad, orthogonalize="cross"): """ orthogonalize: none, svd, qr """ m,d = x_ma.shape grad_mga = tps.tps_grad(x_ma, self.lin_ag, self.trans_g, self.w_ng, self.x_na) newrot_mgd = np.array([grad_ga.dot(rot_ad) for (grad_ga, rot_ad) in zip(grad_mga, rot_mad)]) newpt_mg = tps.tps_eval(x_ma, self.lin_ag, self.trans_g, self.w_ng, self.x_na) if orthogonalize == "qr": newrot_mgd = orthogonalize3_qr(newrot_mgd) elif orthogonalize == "svd": newrot_mgd = orthogonalize3_svd(newrot_mgd) elif orthogonalize == "cross": newrot_mgd = orthogonalize3_cross(newrot_mgd) elif orthogonalize == "none": pass else: raise Exception("unknown orthogonalization method %s"%orthogonalize) return newpt_mg, newrot_mgd
def transform_frames(self, x_ma, rot_mda, orthogonalize="cross"): """ orthogonalize: none, svd, qr """ m,d = x_ma.shape grad_mga = tps.tps_grad(x_ma, self.lin_ag, self.trans_g, self.w_ng, self.x_na) newrot_mdg = (rot_mda[:,:,None,:] * grad_mga[:,None,:,:]).sum(axis=3) # mdg md_a m_ga newpt_mg = tps.tps_eval(x_ma, self.lin_ag, self.trans_g, self.w_ng, self.x_na) if orthogonalize == "qr": newrot_mdg = orthogonalize3_qr(newrot_mdg) elif orthogonalize == "svd": newrot_mdg = orthogonalize3_svd(newrot_mdg) elif orthogonalize == "cross": newrot_mdg = orthogonalize3_cross(newrot_mdg) elif orthogonalize == "none": pass else: raise Exception("unknown orthogonalization method %s"%orthogonalize) return newpt_mg, newrot_mdg
def compute_jacobian(self, x_ma): grad_mga = tps_grad(x_ma, self.lin_ag, self.trans_g, self.w_ng, self.x_na) return grad_mga