Ejemplo n.º 1
0
 def expmap(self, u, x, c):
     K = 1. / c
     sqrtK = K**0.5
     normu = self.minkowski_norm(u)
     normu = torch.clamp(normu, max=self.max_norm)
     theta = normu / sqrtK
     theta = torch.clamp(theta, min=self.min_norm)
     result = cosh(theta) * x + sinh(theta) * u / theta
     return self.proj(result, c)
Ejemplo n.º 2
0
 def expmap0(self, u, c):
     K = 1. / c
     sqrtK = K**0.5
     d = u.size(-1) - 1
     x = u.narrow(-1, 1, d).view(-1, d)
     x_norm = torch.norm(x, p=2, dim=1, keepdim=True)
     x_norm = torch.clamp(x_norm, min=self.min_norm)
     theta = x_norm / sqrtK
     res = torch.ones_like(u)
     res[:, 0:1] = sqrtK * cosh(theta)
     res[:, 1:] = sqrtK * sinh(theta) * x / x_norm
     return self.proj(res, c)