/parallel-cut-pursuit

Parallel cut pursuit

Primary LanguageC++GNU General Public License v3.0GPL-3.0

Cut-Pursuit Algorithms, Parallelized Along Components

Fork of official repository from Hugo Raguet (https://gitlab.com/1a7r0ch3/parallel-cut-pursuit) that contains only the extension modules for Python.

Generic C++ classes for implementing cut-pursuit algorithms.
Specialization to convex problems involving graph total variation, and nonconvex problems involving contour length, as explained in our articles (Landrieu and Obozinski, 2016; Raguet and Landrieu, 2018).

Table of Content

  1. General problem statement
  2. C++ classes and Specializations
    2.1. Proximity operator of the graph total variation
    2.2. Quadratic functional and graph total variation
    2.3. Separable multidimensional loss and graph total variation
    2.4. Separable distance and contour length
  3. Documentation
    3.1. Directory tree
    3.2. Graph structure
    3.3. Python
  4. References
  5. License

General problem statement

The cut-pursuit algorithms minimize functionals structured, over a weighted graph G = (V, E, w), as

    F: x ∈ ΩVf(x) + ∑(u,v) ∈ E w(u,v) ψ(xu, xv) ,

where Ω is some base set, and the functional ψ: Ω² → ℝ penalizes dissimilarity between its arguments, in order to enforce solutions which are piecewise constant along the graph G.

The cut-pursuit approach is to seek partitions V of the set of vertices V, constituting the constant connected components of the solution, by successively solving the corresponding problem, structured over the reduced graph G = (V, E), that is

  arg minξ ∈ ΩV  F(x) ,    such that ∀ UV, ∀ uU, xu = ξU ,

and then refining the partition.
A key requirement is thus the ability to solve the reduced problem, which often have the exact same structure as the original one, but with much less vertices |V| ≪ |V|. If the solution of the original problem has only few constant connected components in comparison to the number of vertices, the cut-pursuit strategy can speed-up minimization by several orders of magnitude.

Cut-pursuit algorithms come in two main flavors, namely “directionally differentiable” and “noncontinuous”.

  • In the directionally differentiable case, the base set Ω is typically a vector space, and it is required that f is differentiable, or at least that its nondifferentiable part is separable along the graph and admits (potentially infinite) directional derivatives. This comprises notably many convex problems, where ψ(xu, xv) = ║xuxv║, that is to say involving a graph total variation. The refinement of the partition is based on the search for a steep directional derivative, and the reduced problem is solved using convex or continuous optimization; optimality guarantees can be provided.

  • In the noncontinuous case, the dissimilarity penalization typically uses ψ(xu, xv) = 0 if xu =xv, 1 otherwise, resulting in a measure of the contour length of the constant connected components. The functional f is typically required to be separable along the graph, and to have computational properties favorable enough for solving reduced problems. The refinement of the partition relies on greedy heuristics.

Both flavors admit multidimensional extensions, that is to say Ω is not required to be only a set of scalars.

C++ classes and Specializations

The class Cp_graph is a modification of the Graph class of Y. Boykov and V. Kolmogorov, for making use of their maximum flow algorithm.
The class Cp is the most generic, defining all steps of the cut-pursuit approach in virtual methods.
The class Cp_d1 specializes methods for directionally differentiable cases involving the graph total variation.
The class Cp_d0 specializes methods for noncontinuous cases involving the contour length penalization.

Cp_prox_tv: proximity operator of the graph total variation

Also coined “graph total variation denoising” or “general fused LASSO signal approximation”. The base set is Ω = ℝ, and the objective functional is

    F: x ∈ ℝV ↦ 1/2 ║yx2 + ∑(u,v) ∈ E w(u,v) |xuxv| ,

where y ∈ ℝn and w ∈ ℝE are regularization weights.

Cp_d1_ql1b: quadratic functional, ℓ1 norm, bounds, and graph total variation

The base set is Ω = ℝ, and the general form is

    F: x ∈ ℝV ↦ 1/2 ║y(q)Ax2 + ∑vV λv |y(ℓ1)xv| + ∑vV ι[mv, Mv](xv)
                 + ∑(u,v) ∈ E w(u,v) |xuxv| ,

where y(q) ∈ ℝn, A: ℝn → ℝV is a linear operator, y(ℓ1) ∈ ℝV and λ ∈ ℝV and w ∈ ℝE are regularization weights, m, M ∈ ℝV are parameters and ι[a,b] is the convex indicator of [a, b] : x ↦ 0 if x ∈ [a, b], +∞ otherwise.

When y(ℓ1) is zero, the combination of ℓ1 norm and total variation is sometimes coined fused LASSO.

When A is the identity, λ is zero and there are no box constraints, the problem boils down to the proximity operator of the graph total variation.

Currently, A must be provided as a matrix. See the documentation for special cases.

The reduced problem is solved using the preconditioned forward-Douglas–Rachford splitting algorithm (see also the corresponding repository).

Two examples where A is a full ill-conditioned matrix are provided with GNU Octave or Matlab and Python interfaces: one with positivity and fused LASSO constraints on a task of brain source identification from electroencephalography, and another with boundary constraints on a task of image reconstruction from tomography.

ground truth raw retrieved activity identified sources

Specialization Cp_d1_lsx: separable loss, simplex constraints, and graph total variation

The base set is Ω = ℝD, where D can be seen as a set of labels, and the general form is

    F: x ∈ ℝVDf(y, x) + ∑vV ιΔD(xv) + ∑(u,v) ∈ E w(d1)(u,v)dD λd |xu,dxv,d| ,

where y ∈ ℝVD, f is a loss functional (see below), w(d1) ∈ ℝE and λ ∈ ℝD are regularization weights, and ιΔD is the convex indicator of the simplex ΔD = {x ∈ ℝD | ∑d xd = 1 and ∀ d, xd ≥ 0}: x ↦ 0 if x ∈ ΔD, +∞ otherwise.

The following loss functionals are available, where w(f) ∈ ℝV are weights on vertices.
Linear: f(y, x) = − ∑vV w(f)vdD xv,d yv,d
Quadratic: f(y, x) = ∑vV w(f)vdD (xv,dyv,d)2
Smoothed Kullback–Leibler divergence (equivalent to cross-entropy):
f(y, x) = ∑vV w(f)v KL(α u + (1 − α) yv, α u + (1 − α) xv),
where α ∈ ]0,1[, u ∈ ΔD is the uniform discrete distribution over D, and KL: (p, q) ↦ ∑dD pd log(pd/qd).

The reduced problem is also solved using the preconditioned forward-Douglas–Rachford splitting algorithm (see also the corresponding repository).

An example with the smoothed Kullback–Leibler is provided with GNU Octave or Matlab and Python interfaces, on a task of spatial regularization of semantic classification of a 3D point cloud.

ground truth random forest classifier regularized classification

Specialization Cp_d0_dist: separable distance and weighted contour length

The base set is Ω = ℝD or ΔD and the general form is

    F: x ∈ ℝVDf(y, x) + ∑(u,v) ∈ E w(d0)(u,v)xuxv0 ,

where y ∈ ΩV, f is a loss functional akin to a distance (see below), and ║·║0 is the ℓ0 pseudo-norm x ↦ 0 if x = 0, 1 otherwise.

The following loss functionals are available, where w(f) ∈ ℝV are weights on vertices and m(f) ∈ ℝD are weights on coordinates.
Weighted quadratic: Ω = ℝD and f(y, x) = ∑vV w(f)vdD m(f)d (xv,dyv,d)2
Weighted smoothed Kullback–Leibler divergence (equivalent to cross-entropy): Ω = ΔD and
f(y, x) = ∑vV w(f)v KLm(f)(α u + (1 − α) yv, α u + (1 − α) xv),
where α ∈ ]0,1[, u ∈ ΔD is the uniform discrete distribution over D, and
KLm(f): (p, q) ↦ ∑dD m(f)d pd log(pd/qd).

The reduced problem amounts to averaging, and the split step uses k-means++ algorithm.

When the loss is quadratic, the resulting problem is sometimes coined “minimal partition problem”.

An example with the smoothed Kullback–Leibler is provided with GNU Octave or Matlab interface, on a task of spatial regularization of semantic classification of a 3D point cloud.

Documentation

Graph structure

Graph structures must be given as forward-star representation. For conversion from simple adjacency list representation, or for creation from scratch for regular N-dimensionnal grids (2D for images, 3D for volumes, etc.), see my grid graph repository.

Python

Requires numpy package.
See the script setup.py for compiling modules with distutils; on UNIX systems, it can be directly interpreted as python setup.py build_ext.
Compatible with Python 2 and Python 3.

Extensive documentation of the Python wrappers can be found in the corresponding .py files.
The scripts are mostly written for Python 3, and should work with Python 2 with minor tweaking.

The script example_EEG.py exemplifies the use of Cp_d1_ql1b, on a task of brain source identification from electroencephalography.

The script example_tomography.py exemplifies the use of Cp_d1_ql1b, on a task of image reconstruction from tomography.

The scripts example_labeling_3D.py and example_labeling_3D_d0.py exemplify the use of, respectively, Cp_d1_lsx and Cp_d0_dist, on a task of spatial regularization of semantic classification of a 3D point cloud.

References

L. Landrieu and G. Obozinski, Cut Pursuit: Fast Algorithms to Learn Piecewise Constant Functions on Weighted Graphs, 2017.

H. Raguet and L. Landrieu, Cut-pursuit Algorithm for Regularizing Nonsmooth Functionals with Graph Total Variation, 2018.

Y. Boykov and V. Kolmogorov, An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision, IEEE Transactions on Pattern Analysis and Machine Intelligence, 2004.

License

This software is under the GPLv3 license.