I am trying to learn the API to geoopt and Python at once, but have this example so far:
import geoopt
import torch
import matplotlib.pyplot as plt
# Create the Poincare ball model
poincare = geoopt.PoincareBall()
# Define two points in the hyperbolic space
point1 = torch.tensor([0.1, 0.2])
point2 = torch.tensor([0.3, 0.4])
#Map the points to the tangent space at the identity element
point1_tangent = poincare.expmap(point1, torch.tensor([1.0,0.0,0.0,1.0]))
point2_tangent = poincare.expmap(point2, torch.tensor([1.0,0.0,0.0,1.0]))
# Map the points back to the hyperbolic space
point1_hyperbolic = poincare.logmap(point1_tangent, torch.tensor([1.0,0.0,0.0,1.0]))
point2_hyperbolic = poincare.logmap(point2_tangent, torch.tensor([1.0,0.0,0.0,1.0]))
# Transform the points using the Poincare ball model
transformed_point1 = poincare.mobius_add(torch.tensor([1.0,0.0,0.0,1.0]), point1_hyperbolic)
transformed_point2 = poincare.mobius_add(torch.tensor([1.0,0.0,0.0,1.0]), point2_hyperbolic)
# Plot the line connecting the two points
plt.plot([transformed_point1[0], transformed_point2[0]], [transformed_point1[1], transformed_point2[1]])
plt.show()
This doesn't quite work, any ideas how to get a simple line drawn in the hyperbolic plane using geoopt, something as simple as this (or simpler) is all I'm trying to do: