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,ABCAbstract 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:
ABCAbstract 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:
ConnectionFlat 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:
objectThe 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.
- exception bregman.manifold.coordinate.UnrecordedCoordConversion
Bases:
ExceptionException when specific coordinate conversion is not recorded.
- exception bregman.manifold.coordinate.UnrecordedCoordType
Bases:
ExceptionException when unrecorded coordinate type is accessed.
bregman.manifold.generator module
- class bregman.manifold.generator.AutoDiffGenerator(dimension: int)
Bases:
Generator,ABCBregman 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:
ABCAbstract 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.
- class bregman.manifold.geodesic.Geodesic(manifold: TBregmanManifold, source: Point, dest: Point)
Bases:
Generic[TBregmanManifold],CurveAbstract 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:
ABCBase 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:
EtaGeneratorNotAssigned – If dcoords = DualCoords.ETA and
self.self.eta_generator is not defined. –
- 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:
EtaGeneratorNotAssigned – If dcoords = DualCoords.ETA and
self.self.eta_generator is not defined. –
- Returns:
Generator corresponding to specified dual coordinates.
- exception bregman.manifold.manifold.EtaGeneratorNotAssigned
Bases:
ExceptionException for when \(\eta\) Bregman generator not assigned.