JuliaOptimalTransport / OptimalTransport.jl

Optimal transport algorithms for Julia
https://juliaoptimaltransport.github.io/OptimalTransport.jl/dev
MIT License
94 stars 8 forks source link

check ForwardDiff results against analytic formula in tests #120

Closed zsteve closed 3 years ago

zsteve commented 3 years ago

As mentioned in https://github.com/JuliaOptimalTransport/OptimalTransport.jl/pull/90#discussion_r644203936, this PR checks the gradients of sinkhorn2 in its source and target measures (as obtained by ForwardDiff) against the analytic expression for the gradients.

Reference: Proposition 2.3 of Cuturi, Marco, and Gabriel Peyré. "A smoothed dual approach for variational Wasserstein problems." SIAM Journal on Imaging Sciences 9.1 (2016): 320-343.

Note that for the result of Prop 2.3 to yield a valid gradient, one needs to run Sinkhorn up til convergence (potentially many iterations). The benefit of using Sinkhorn+AD is that AD can be used to yield a valid gradient (of the suboptimal Sinkhorn objective at a fixed iteration) for relatively small number of iterations. See e.g. https://arxiv.org/pdf/1708.01955.pdf.

coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 1165241204

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Totals Coverage Status
Change from base Build 1164895949: 0.0%
Covered Lines: 666
Relevant Lines: 682

💛 - Coveralls
codecov-commenter commented 3 years ago

Codecov Report

Merging #120 (f0addb0) into master (cfd4321) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #120   +/-   ##
=======================================
  Coverage   97.65%   97.65%           
=======================================
  Files          13       13           
  Lines         682      682           
=======================================
  Hits          666      666           
  Misses         16       16           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cfd4321...f0addb0. Read the comment docs.

zsteve commented 3 years ago

Merging since this only affects tests.