bregman.manifold package

Submodules

bregman.manifold.bisector module

class bregman.manifold.bisector.Bisector(manifold: TBregmanManifold, source: Point, dest: Point, coords: Coords)

Bases: Generic[TBregmanManifold], CoordObject, ABC

Abstract class for a bisector geometric object.

Parameters:
  • manifold – Bregman manifold which the bisector is defined on.

  • source – Source point on the manifold which the bisector starts.

  • dest – Destination point on the manifold which the bisector ends.

abstract bisect_proj_point() Point

Projection point for plotting.

Returns:

Bisector projection point.

abstract shift() float

Shift scale for plotting.

Returns:

Bisector shift scale.

class bregman.manifold.bisector.BregmanBisector(manifold: BregmanManifold, source: Point, dest: Point, dcoords: DualCoords = DualCoords.THETA)

Bases: Bisector[BregmanManifold]

Bregman bisector class calculated with respect to \(\theta\)-or \(\eta\)-coordinates.

Parameters:

coords – Coordinates in which the bisector is defined on.

bisect_proj_point() Point

Projection point for plotting.

Returns:

Bregman bisector projection point.

shift() float

Shift scale for plotting.

Returns:

Bregman bisector shift scale.

bregman.manifold.connection module

class bregman.manifold.connection.Connection

Bases: ABC

Abstract connection for manifolds.

abstract christoffel_first_kind(x: ndarray) ndarray

Christoffel symbols of the first kind corresponding to connection.

Parameters:

x – value Christoffel symbol is being evaluated at.

Returns:

Christoffel symbols of the first kind evaluated at point x.

abstract cubic(x: ndarray) ndarray

Cubic tensor corresponding to connection.

Parameters:

x – Value cubic tensor is being evaluated at.

Returns:

Cubic tensor evaluated at point x.

abstract metric(x: ndarray) ndarray

Metric tensor corresponding to connection.

Parameters:

x – Value metric is being evaluated at.

Returns:

Metric tensor evaluated at point x.

class bregman.manifold.connection.FlatConnection(coords: Coords, generator: Generator)

Bases: Connection

Flat connections used in Bregman manifolds.

Parameters:
  • coord – Coordinates corresponding to the flat connection.

  • generator – Bregman generator corresponding to the connection.

christoffel_first_kind(x: ndarray) ndarray

Christoffel symbols of the first kind corresponding to a flat connection. This will always to the zero tensor.

Parameters:

x – Value Christoffel symbols is being evaluated at.

Returns:

Christoffel symbols evaluated at point x. Always zero.

cubic(x: ndarray) ndarray

Cubic tensor corresponding to flat connection. Requires the generator to be defined using autograd.numpy functions to allow for auto-differentiation.

Parameters:

x – Value cubic tensor is being evaluated at.

Returns:

Cubic tensor evaluated at point x.

metric(x: ndarray) ndarray

Metric tensor corresponding to a flat connection.

Parameters:

x – Value metric is being evaluated at.

Returns:

Metric tensor evaluated at point x.

bregman.manifold.coordinate module

class bregman.manifold.coordinate.Atlas(dimension: int)

Bases: object

The Atlas class aims to manage data coordinate conversion. In particular, it provides functionality of recording coordinate types, registering conversions between coordinates, and conversion of Point data to different coordinates.

Parameters:
  • dimension – Dimension of the canonical coordinates. Specifically, the size of the data.

  • recorded_coords – Set of coordinates which have been registered.

  • transitions – Set of transitions (coordinate changes) which have been registered.

add_coords(coords: Coords) None

Adds coordinate to Atlas.

Parameters:

coords – Coordinate type to add to Atlas.

add_transition(source_coords: Coords, target_coords: Coords, transition: Callable[[ndarray], ndarray]) None

Adds transition function (coordinate transform) to Atlas.

Parameters:
  • source_coords – Source coordinates for the coordinate transform.

  • target_coords – Target coordinates for the coordinate transform.

  • transition – Function which changes data from source to target coordinates.

convert_coord(target_coords: Coords, point: Point) Point

Converts coordinates of Point objects.

Parameters:
  • target_coords – Coords which one wants to convert point to.

  • point – Point object being converted.

Returns:

point converted to target_coords coordinates based on manifold.

exception bregman.manifold.coordinate.UnrecordedCoordConversion

Bases: Exception

Exception when specific coordinate conversion is not recorded.

exception bregman.manifold.coordinate.UnrecordedCoordType

Bases: Exception

Exception when unrecorded coordinate type is accessed.

bregman.manifold.generator module

class bregman.manifold.generator.AutoDiffGenerator(dimension: int)

Bases: Generator, ABC

Bregman generator defined via autograd’s auto-differentiation. As a result, only the function definition of the Bregman generator needs to be defined. The gradient and hessian will be automatically defined.

autograd’s auto-differentiation requires functions to take vectors as inputs. As such, to utilize this class one may need to define wrapper functions (reshape operations) before and after autograd is utilized.

F(x: ndarray) ndarray

Function of generator.

Parameters:

x – Input for generator.

Returns:

Generator evaluated at x.

grad(x: ndarray) ndarray

Gradient of generator.

Parameters:

x – Input for generator.

Returns:

Generator’s gradient evaluated at x.

hess(x: ndarray) ndarray

Hessian of generator.

Parameters:

x – Input for generator.

Returns:

Generator’s hessian evaluated at x.

class bregman.manifold.generator.Generator(dimension: int)

Bases: ABC

Abstract class for Bregman manifolds.

Parameters:

dimension – Dimension of input data.

abstract F(x: ndarray) ndarray

Function of generator.

Parameters:

x – Input for generator.

Returns:

Generator evaluated at x.

bregman_divergence(x: ndarray, y: ndarray) ndarray

Bregman divergence on raw data defined by generator.

Parameters:
  • x – Left argument of Bregman divergence.

  • y – Right argument of Bregman divergence.

Returns:

Bregman divergence between x and y.

abstract grad(x: ndarray) ndarray

Gradient of generator.

Parameters:

x – Input for generator.

Returns:

Generator’s gradient evaluated at x.

abstract hess(x: ndarray) ndarray

Hessian of generator.

Parameters:

x – Input for generator.

Returns:

Generator’s hessian evaluated at x.

bregman.manifold.geodesic module

class bregman.manifold.geodesic.BregmanGeodesic(manifold: BregmanManifold, source: Point, dest: Point, dcoords: DualCoords = DualCoords.THETA)

Bases: Geodesic[BregmanManifold]

Bregman geodesic class calculated with respect to \(\theta\)-or \(\eta\)-coordinates.

Parameterization is assumed to be defined for t in [0, 1].

Parameters:

coords – Coordinates in which the geodesic is defined on.

path(t: float) Point

Evaluation of Bregman geodesic path parameterized by t. The path is defined on the flat geometric of the dual coordinate.

Parameters:

t – Value in [0, 1] corresponding to the parameterization of the geodesic.

Returns:

Bregman geodesic evaluated at t.

class bregman.manifold.geodesic.Geodesic(manifold: TBregmanManifold, source: Point, dest: Point)

Bases: Generic[TBregmanManifold], Curve

Abstract class for a geodesic geometric object.

Parameterization is assumed to be defined for t in [0, 1].

Parameters:
  • manifold – Bregman manifold which the geodesic is defined on.

  • source – Source point on the manifold which the geodesic starts.

  • dest – Destination point on the manifold which the geodesic ends.

bregman.manifold.manifold module

class bregman.manifold.manifold.BregmanManifold(theta_generator: Generator, eta_generator: Generator | None, dimension: int)

Bases: ABC

Base class for Bregman manifold. Constructs basic components of a Bregman manifold.

Parameters:
  • dimension – Dimension of canonical parameterizations (\(\theta\)-or \(\eta\)-coordinates).

  • theta_generator – Primal generator for \(\theta\)-coordinates.

  • eta_generator – Dual generator for \(\eta\)-coordinates.

  • theta_connection – Connection object generated by theta_generator.

  • eta_connection – Connection object generated by eta_generator.

  • atlas – Atlas object used to manage different coordinates types of the manifold.

bregman_connection(dcoords: DualCoords) FlatConnection

Get Bregman connection of a specific \(\theta\)-or \(\eta\)-coordinate.

Parameters:

dcoords – DualCoords specifying \(\theta\)-or \(\eta\)-coordinates.

Raises:
Returns:

FlatConnection corresponding to specified dual coordinates.

bregman_generator(dcoords: DualCoords) Generator

Get Bregman generator of a specific \(\theta\)-or \(\eta\)-coordinate.

Parameters:

dcoords – DualCoords specifying \(\theta\)-or \(\eta\)-coordinates.

Raises:
Returns:

Generator corresponding to specified dual coordinates.

convert_coord(target_coords: Coords, point: Point) Point

Converts coordinates of Point objects.

Parameters:
  • target_coords – Coords which one wants to convert point to.

  • point – Point object being converted.

Returns:

point converted to target_coords coordinates based on manifold.

exception bregman.manifold.manifold.EtaGeneratorNotAssigned

Bases: Exception

Exception for when \(\eta\) Bregman generator not assigned.

Module contents