Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate power in PointCloud, introduce TICost and use it to compute Entropic (Brenier) maps. #167

Merged
merged 25 commits into from
Nov 15, 2022

Conversation

marcocuturi
Copy link
Contributor

@marcocuturi marcocuturi commented Nov 9, 2022

  • introduce RBF costs, i.e. cost(x,y) := h(x-y) where h is from vectors to reals. Specify (when known) the legendre transform of h. This plays a role in the application of the Brenier theorem.
  • Introduce new SqPNorms , i.e. squared p-norms, cost functions. Squared p-norms have closed forms for their legendre transform (corresponding squared q-norm, where 1/p + 1/q = 1)
  • Because of the introduction of these options, deprecate the power option in PointCloud geometries. This was confusing and redundant with the ability to write down directly a custom CostFn for that purpose. Raise an error if power is passed to help debugging.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ott-jax ott-jax deleted a comment from codecov-commenter Nov 10, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 10, 2022

Codecov Report

Merging #167 (09bffc0) into main (7249909) will increase coverage by 0.07%.
The diff coverage is 94.31%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   89.83%   89.91%   +0.07%     
==========================================
  Files          51       51              
  Lines        5068     5118      +50     
  Branches      519      521       +2     
==========================================
+ Hits         4553     4602      +49     
- Misses        391      397       +6     
+ Partials      124      119       -5     
Impacted Files Coverage Δ
ott/core/quad_problems.py 87.31% <66.66%> (-1.36%) ⬇️
ott/core/potentials.py 88.29% <89.47%> (+1.23%) ⬆️
ott/geometry/costs.py 97.18% <97.72%> (+0.67%) ⬆️
ott/core/bar_problems.py 81.92% <100.00%> (-2.26%) ⬇️
ott/core/neuraldual.py 70.37% <100.00%> (+0.22%) ⬆️
ott/geometry/pointcloud.py 85.20% <100.00%> (+1.62%) ⬆️
ott/tools/transport.py 95.83% <100.00%> (ø)

@michalk8 michalk8 added the enhancement New feature or request label Nov 10, 2022

import jax
import jax.numpy as jnp
import jax.scipy as jsp
import jax.tree_util as jtu
from typing_extensions import Literal

from ott.geometry import pointcloud
from ott.geometry import costs, pointcloud

__all__ = ["DualPotentials", "EntropicPotentials"]
Potential_t = Callable[[jnp.ndarray], float]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the same vein as cost_fn, I'm wondering if Potential_t could be renamed to PotentialFn_t or just PotentialFn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same reflex when Michal used it for the first time, but I think it makes sense :) Here it turns out this is just a type (_t) and can be either a vector of a function.


c(x,y) = h(z), where z := x-y.

where h is a function strictly convex (or concave) function mapping vectors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small repetition here: I think you meant "where h is a strictly convex (or concave) function ...". It's minor, I know ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch! thanks.

ott/core/potentials.py Outdated Show resolved Hide resolved
ott/core/potentials.py Show resolved Hide resolved
ott/core/potentials.py Outdated Show resolved Hide resolved
ott/core/potentials.py Outdated Show resolved Hide resolved
ott/core/potentials.py Outdated Show resolved Hide resolved
ott/geometry/costs.py Show resolved Hide resolved
ott/geometry/costs.py Outdated Show resolved Hide resolved
ott/geometry/costs.py Outdated Show resolved Hide resolved
ott/geometry/costs.py Show resolved Hide resolved
ott/geometry/costs.py Outdated Show resolved Hide resolved
@marcocuturi marcocuturi changed the title Making a few changes in point cloud API Deprecate power in point cloud API, introduce RBF costs. Nov 10, 2022
@marcocuturi marcocuturi changed the title Deprecate power in point cloud API, introduce RBF costs. Deprecate power in PointCloud, introduce RBFCost and use it to compute Entropic (Brenier) maps. Nov 10, 2022
ott/core/potentials.py Outdated Show resolved Hide resolved
ott/core/potentials.py Outdated Show resolved Hide resolved
ott/core/potentials.py Outdated Show resolved Hide resolved
ott/geometry/costs.py Outdated Show resolved Hide resolved
@marcocuturi marcocuturi changed the title Deprecate power in PointCloud, introduce RBFCost and use it to compute Entropic (Brenier) maps. Deprecate power in PointCloud, introduce TIFCost and use it to compute Entropic (Brenier) maps. Nov 14, 2022
@marcocuturi marcocuturi changed the title Deprecate power in PointCloud, introduce TIFCost and use it to compute Entropic (Brenier) maps. Deprecate power in PointCloud, introduce TICost and use it to compute Entropic (Brenier) maps. Nov 14, 2022
Copy link
Collaborator

@michalk8 michalk8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor fixes for Potentials, then it can be merged.

ott/core/potentials.py Outdated Show resolved Hide resolved
ott/core/potentials.py Outdated Show resolved Hide resolved
ott/core/potentials.py Outdated Show resolved Hide resolved
@marcocuturi
Copy link
Contributor Author

marcocuturi commented Nov 14, 2022

Just minor fixes for Potentials, then it can be merged.

It seems I need your explicit approval? maybe related to changes I did in "branch protection"

@michalk8 michalk8 merged commit c9ff6fb into main Nov 15, 2022
@marcocuturi marcocuturi deleted the marco-main branch November 23, 2022 13:04
michalk8 pushed a commit that referenced this pull request Jun 27, 2024
…ompute Entropic (Brenier) maps. (#167)

* deperecate `power`, introduce h maps in potentials

* Deprecate power and introduce h function in costs.

* linter

* linter

* revert abstractmethod.

* linter

* linter

* PNorm -> SqPNorm

* PNorm -> SqPNorm in tests.

* another fix for abstract method.

* fix abc.abstractmethod

* linter

* nb fix

* linter

* nb bug fix

* modify ipynb

* abc.abstractmethod for RBF

* fixes and additions.

* fix `cor` in neuraldual

* fix in neuraldual

* p-norm ** p implemented, fixes.

* various fixes. Change to `TICost`

* various fixes

* fix nb

* last fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants