hypll.manifolds.poincare_ball.math.stats¶
Functions
|
|
|
|
|
Args X (tensor): point of shape [..., points, dim] y (tensor): mean point of shape [..., dim] grad (tensor): gradient K (float): curvature (must be negative) |
|
Args X (tensor): point of shape [..., points, dim] K (float): curvature (must be negative) |
|
|
|
Args x (tensor): points of shape [..., points, dim] mu (tensor): mean of shape [..., dim] |
|
Args X (tensor): point of shape [..., points, dim] y (tensor): mean point of shape [..., dim] K (float): curvature (must be negative) |
|
Args X (tensor): point of shape [..., points, dim] y (tensor): mean point of shape [..., dim] K (float): curvature (must be negative) |
|
|
|
Classes
This implementation is copied mostly from: |
- class hypll.manifolds.poincare_ball.math.stats.FrechetMean¶
- This implementation is copied mostly from:
- which is itself based on the paper:
Both by Aaron Lou (et al.)
- static forward(ctx, x, c, vec_dim, batch_dim, keepdim)¶
Define the forward of the custom autograd Function.
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context()staticmethod to handle setting up thectxobject.outputis the output of the forward,inputsare a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward()if they are intended to be used inbackward(equivalently,vjp) orctx.save_for_forward()if they are intended to be used for injvp.
- static backward(ctx, grad_output)¶
Define a formula for differentiating the operation with backward mode automatic differentiation.
This function is to be overridden by all subclasses. (Defining this function is equivalent to defining the
vjpfunction.)It must accept a context
ctxas the first argument, followed by as many outputs as theforward()returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward(). Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_gradas a tuple of booleans representing whether each input needs gradient. E.g.,backward()will havectx.needs_input_grad[0] = Trueif the first input toforward()needs gradient computed w.r.t. the output.
- hypll.manifolds.poincare_ball.math.stats.frechet_mean(x: Tensor, c: Tensor, vec_dim: int = -1, batch_dim: int | list[int] = 0, keepdim: bool = False) Tensor¶
- hypll.manifolds.poincare_ball.math.stats.midpoint(x: Tensor, c: Tensor, man_dim: int = -1, batch_dim: int | list[int] = 0, w: Tensor | None = None, keepdim: bool = False) Tensor¶
- hypll.manifolds.poincare_ball.math.stats.frechet_variance(x: Tensor, c: Tensor, mu: Tensor | None = None, vec_dim: int = -1, batch_dim: int | list[int] = 0, keepdim: bool = False) Tensor¶
Args¶
x (tensor): points of shape […, points, dim] mu (tensor): mean of shape […, dim]
where the … of the three variables match
Returns¶
tensor of shape […]
- hypll.manifolds.poincare_ball.math.stats.l_prime(y: Tensor) Tensor¶
- hypll.manifolds.poincare_ball.math.stats.frechet_ball_forward(X: Tensor, K: Tensor = tensor([1.]), max_iter: int = 1000, rtol: float = 1e-06, atol: float = 1e-06) Tensor¶
Args¶
X (tensor): point of shape […, points, dim] K (float): curvature (must be negative)
Returns¶
frechet mean (tensor): shape […, dim]
- hypll.manifolds.poincare_ball.math.stats.darcosh(x)¶
- hypll.manifolds.poincare_ball.math.stats.d2arcosh(x)¶
- hypll.manifolds.poincare_ball.math.stats.grad_var(X: Tensor, y: Tensor, K: Tensor) Tensor¶
Args¶
X (tensor): point of shape […, points, dim] y (tensor): mean point of shape […, dim] K (float): curvature (must be negative)
Returns¶
grad (tensor): gradient of variance […, dim]
- hypll.manifolds.poincare_ball.math.stats.inverse_hessian(X: Tensor, y: Tensor, K: Tensor) Tensor¶
Args¶
X (tensor): point of shape […, points, dim] y (tensor): mean point of shape […, dim] K (float): curvature (must be negative)
Returns¶
inv_hess (tensor): inverse hessian of […, points, dim, dim]
- hypll.manifolds.poincare_ball.math.stats.frechet_ball_backward(X: Tensor, y: Tensor, grad: Tensor, K: Tensor) tuple[Tensor]¶
Args¶
X (tensor): point of shape […, points, dim] y (tensor): mean point of shape […, dim] grad (tensor): gradient K (float): curvature (must be negative)
Returns¶
- gradients (tensor, tensor, tensor):
gradient of X […, points, dim], curvature []