Algorithmadvanced
Split Bregman method
Also called Goldstein-Osher split Bregman, split Bregman iteration.
Solve L1 and total variation problems by moving the regularizer onto a new variable d = Φx, then alternate a linear solve, a shrinkage and a Bregman update.
- Solves
- Image denoising, Image deblurring
- Time
- O(n^3 + K (n^2 + (m + q) n)) worst
- Space
- O(n^2 + q) extra
- Where
- K = the number of iterations; m = the number of data values; n = the number of unknowns; q = the number of rows of Φ
- Model
- Real RAM
- Properties
- converges for every mudeterministicequivalent to admmnot exactiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Tom Goldstein, Stanley Osher, 2009
The split Bregman method solves problems of the form , where is a linear map such as the image gradient. This covers total variation denoising, total variation deblurring and the LASSO. The term is hard because it is not smooth and couples the unknowns. The method adds a new variable with the constraint , so that the coupling and the nonsmooth part are in different variables. It then applies Bregman iteration to the constraint, with one alternating sweep per step: a linear solve for , a soft thresholding for , and an update of the Bregman variable . The method is the same as ADMM with penalty and scaled multiplier , so it converges for every , and converges to a dual solution.
In plain words
Some image problems ask for an image that matches the measurements and has few edges. The two wishes pull in different directions, and the "few edges" part has sharp corners that break normal solvers. The method gives the edges their own variable. Now there are two easy jobs. The first job finds an image that matches the measurements and is close to the current edge map: this is a linear system, which is easy. The second job cleans the edge map by setting small edges to zero: this is one simple rule per pixel. A third variable keeps a record of how much the edge map and the image still disagree, and it pushes them together a little more at each round. After enough rounds they agree, and the image is the solution of the original problem.
The problem
The input is a matrix , data , a matrix , a weight and a penalty . The goal is a minimizer of
where is the norm (anisotropic total variation when is the gradient) or the sum of the Euclidean norms of pairs (isotropic total variation, with the horizontal and vertical differences of one pixel in one pair). We require that and have no common null vector, so that is positive definite and has a minimizer. For denoising and this holds for any . The weight is a design choice of the model; the penalty is a parameter of the solver and does not change the solution.
The algorithm
The split problem is subject to . Bregman iteration on the constraint, with the quadratic penalty , and one Gauss-Seidel sweep over and in place of the exact joint solve, gives:
SplitBregman(A, y, Φ, λ, μ, K)- 1
factor M = AᵀA + μΦᵀΦ by Cholesky; d ← 0; b ← 0 - 2
for k = 0 to K - 1 - 3
x ← M⁻¹ (Aᵀy + μΦᵀ(d - b)) ▷ argmin ½‖Ax - y‖² + μ/2‖Φx - d + b‖² - 4
d ← shrink(Φx + b, λ/μ) ▷ argmin λN(d) + μ/2‖d - Φx - b‖² - 5
b ← b + Φx - d ▷ Bregman update, add back the misfit - 6
return x
For the norm, . For the isotropic norm, each pair of is replaced by . Both are the proximal operator of . Line L3 is the only coupled step. Here it uses a Cholesky factor computed once. For deconvolution with periodic boundaries, is diagonalized by the fast Fourier transform, and for large problems a few conjugate gradient or Gauss-Seidel steps are enough.
Line L5 is the Bregman step of the constraint : the misfit is added back, in the same way as Bregman iteration adds back the data residual. If lines L3 and L4 were repeated until minimizes the joint problem, the method would be exact Bregman iteration, which is the augmented Lagrangian method for the split problem. One sweep is enough, and that is the point of the method.
Example
Take total variation denoising of the signal : , the forward difference matrix with 3 rows, and . Then is tridiagonal with diagonal and off diagonal .
Step 1: with , line L3 solves , which gives . Then , and shrinkage by gives . Line L5 gives .
| 1 | 3.0612 | |||
| 2 | 3.0816 | |||
| 3 | 2.6406 | |||
| 5 | 2.7140 | |||
| 10 | 2.5088 | |||
| 20 | 2.5000 |
The limit is the exact total variation solution: each half moves toward the other by divided by its length 2, and . The edge variable has the single jump 2 at the right place from step 2 on; only its size still changes. The limit is the dual solution: it satisfies , its entries are at most in size, and it equals where is not zero. The table also shows that is not monotone (it rises at steps 2 and 5), so it is not a useful stop test.
Correctness
The full proof is in proofs/correctness.md. The steps:
- Equivalence with ADMM. With , and the constraint , lines L3 to L5 are the three steps of scaled ADMM with penalty and scaled multiplier . This is a theorem (Esser 2009, Setzer 2009).
- Optimality of each step: with , line L3 gives , and line L4 gives .
- A saddle point exists. Since and have no common null vector, is coercive and has a minimizer , and the subdifferential chain rule gives with and .
- Lyapunov function: satisfies for . This follows from the monotonicity of and only.
- Convergence: the iterates are bounded and the two residuals go to 0, so every cluster point satisfies the optimality conditions. Using with that cluster point gives convergence of the whole sequence: , a minimizer of , and , a dual solution. This holds for every .
Proof: Split Bregman is ADMM, has a nonincreasing Lyapunov function, and converges to a minimizer and a dual solution for every penaltyfull
Setting. , , , , . is the norm on or a sum of Euclidean norms of disjoint groups of entries. Let , and . We assume . Then is positive definite, because for .
The method starts with and, for , does
The first problem is strictly convex with the normal equation , which is line L3. The second is the proximal map of at , which is the shrinkage of line L4 (for the norm entry by entry, for groups group by group). Both minimizers exist and are unique. Write , and , so .
Remark (ADMM). For subject to , scaled ADMM with penalty and scaled multiplier is , , . With and these are the three steps above. The proof below is the ADMM argument written out for this case.
Lemma 1 (optimality of the steps). For ,
Proof. The -step gives , and . The -step gives , and .
Lemma 2 (optimality conditions). Call a KKT point if
(a) If is a KKT point, then minimizes . (b) A KKT point exists.
Proof. (a) For any , convexity of and the subgradient inequality for at give
(b) Existence of a minimizer: the map is injective, so there is with for all . Since , we have . If then or , and in both cases this lower bound tends to . So is continuous and coercive and has a minimizer . Since is differentiable and is convex and finite everywhere, (Rockafellar, Convex Analysis, Theorems 23.8 and 23.9). So gives with . Put .
Lemma 3 (Lyapunov function). Let be a KKT point and . Then for
and for
Proof. The gradient of the convex function is monotone. With Lemma 1 and the KKT condition, and , so
The subdifferential of is monotone, so . Add the two and use :
Now . The identity gives
Multiply the inequality by 2 and insert these. With :
For , Lemma 1 at steps and gives and , and monotonicity gives , that is, . So .
Theorem 1 (residual rate). is nonincreasing, , and
In particular and .
Proof. Lemma 3 with a KKT point from Lemma 2(b). Sum the second inequality for ; the smallest term is at most the mean. has this form because and .
Theorem 2 (convergence). For every , , and , where minimizes and is a KKT point. In particular for all and where (for the norm).
Proof. By Theorem 1, the sequences and are bounded. The -step is , a fixed affine map of , so is bounded too. Choose a subsequence with . By Theorem 1, and , so . Lemma 1 at step gives, in the limit, . The graph of is closed, because is convex and continuous, so gives . So is a KKT point, and minimizes by Lemma 2(a).
Now apply Lemma 3 with this KKT point. The sequence is nonincreasing and , so : and . Then . This vector is : from the KKT conditions , and is invertible. The last claim is written out for .
Remarks. The minimizer of need not be unique, for example when has a null space; the method then converges to one of them. The proof uses exact solves in lines L3 and L4. The ergodic bound for the objective and the constraint residual follows from the general ADMM argument on the ADMM page with and .
Complexity
With dense matrices, line L1 costs once. Each step then costs for the two triangular solves, for the products with , and (only is needed, and it is computed once), and for the shrinkage. So steps cost time and extra memory for the factor and , . For an image with pixels, the gradient and a convolution, all products cost and line L3 costs with the FFT, so each step is .
The rate is that of ADMM: the smallest squared constraint residual among the first steps is at most , and the averaged iterates of have an objective error and a constraint residual of order (see the ADMM page). These are theorems. In the example above, 20 steps give 4 correct digits; that is a measurement on one small problem, and the count depends on .
Properties
- The penalty does not change the limit, only the speed. A large enforces fast but shrinks by the small amount , so the edge set settles slowly. A small does the opposite. This trade-off is a heuristic, not a theorem.
- Line L3 is a linear system with the same matrix at every step. This is the main practical gain over methods that need a new system per step.
- Line L4 sets entries of exactly to zero, so the edge map is sparse at every step, while is only close to piecewise constant.
- At a limit, is a dual certificate; a stop test can use the two residuals and , as for ADMM.
- The objective is not monotone.
- The iteration is deterministic and uses no step size, unlike Chambolle-Pock, whose steps must satisfy .
Variants and improvements
- Several inner sweeps: Goldstein and Osher allow sweeps of lines L3 and L4 before line L5. Many sweeps approach the augmented Lagrangian method, one sweep is ADMM. One sweep is usually the fastest.
- Inexact line L3: one Gauss-Seidel sweep for , as in the original paper for denoising, or a few conjugate gradient steps. The method still works in practice; the convergence proof above needs an exact solve or summable errors.
- More splittings: for problems with several terms, for example a total variation term and a nonnegativity constraint, each term gets its own variable and Bregman variable. This is ADMM with several blocks stacked into one .
- Frames and wavelets: can be a tight frame. Setzer (2009) related the method to Douglas-Rachford splitting on the dual problem and studied frame shrinkage.
- Total generalized variation and other higher order models fit the same template with a larger .
- Adaptive penalty: changing during the run needs a new factor of and a rescaling , so that stays the same.
When to use it
Use it when the regularizer is an norm of a linear map and the system is cheap to solve, for example deconvolution with the FFT, or compressed sensing MRI with Fourier sampling, where both matrices are diagonal in the Fourier basis. If that system is expensive, a method that uses only products with , , and is better: Chambolle-Pock, or iterative shrinkage thresholding when .
Pitfalls
- A common null vector of and makes singular. With the gradient, constants are in the null space of , so must not map constants to 0. The implementation raises an error in that case.
- The shrinkage threshold is , not . Mixing the two gives the solution of a problem with a different weight.
- Line L5 must use the new and of the same step. With an old value it is not the Bregman update, and the proof does not apply.
- Changing without rescaling breaks the method, because the true multiplier is .
- The isotropic shrinkage must act on the pair of differences of one pixel together. Shrinking each component on its own gives anisotropic total variation, which favors edges along the axes.
- Do not judge convergence by , which can rise; use the residuals.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/split-bregman-method/. The authors are listed in prov/4TK5JZ.jsonl.
"""The split Bregman method of Goldstein and Osher (2009).
It solves min_x (1/2)||A x - y||^2 + lam ||Phi x||_1 (anisotropic) or with the
isotropic group norm sum_i |((Phi x)_i, (Phi x)_{i+g})|, by introducing
d = Phi x and applying Bregman iteration to the constraint d = Phi x with one
alternating sweep per step. A and Phi are dense matrices (lists of rows).
The x-step solves (A^T A + mu Phi^T Phi) x = A^T y + mu Phi^T (d - b) with a
Cholesky factor computed once.
"""
import math
Mat = list[list[float]]
Vec = list[float]
def mat_vec(M: Mat, x: Vec) -> Vec:
return [sum(a * b for a, b in zip(row, x)) for row in M]
def mat_t_vec(M: Mat, y: Vec) -> Vec:
n = len(M[0])
out = [0.0] * n
for row, v in zip(M, y):
if v != 0.0:
for j in range(n):
out[j] += row[j] * v
return out
def cholesky(M: Mat) -> Mat:
"""Lower triangular L with L L^T = M. Precondition: M symmetric positive definite. Cost O(n^3)."""
n = len(M)
L = [[0.0] * n for _ in range(n)]
for i in range(n):
for j in range(i + 1):
s = M[i][j] - sum(L[i][k] * L[j][k] for k in range(j))
if i == j:
if s <= 0.0:
raise ValueError("matrix is not positive definite: ker A and ker Phi meet")
L[i][i] = math.sqrt(s)
else:
L[i][j] = s / L[j][j]
return L
def chol_solve(L: Mat, r: Vec) -> Vec:
n = len(r)
z = [0.0] * n
for i in range(n):
z[i] = (r[i] - sum(L[i][k] * z[k] for k in range(i))) / L[i][i]
x = [0.0] * n
for i in range(n - 1, -1, -1):
x[i] = (z[i] - sum(L[k][i] * x[k] for k in range(i + 1, n))) / L[i][i]
return x
def shrink(v: Vec, t: float, group: int = 0) -> Vec:
"""Soft thresholding by t; with group = g > 0, entries i and i + g form one 2-vector (isotropic)."""
if group == 0:
return [math.copysign(max(abs(a) - t, 0.0), a) for a in v]
out = v[:]
for i in range(group):
r = math.hypot(v[i], v[i + group])
s = max(r - t, 0.0) / r if r > 0.0 else 0.0
out[i], out[i + group] = v[i] * s, v[i + group] * s
return out
def split_bregman(A: Mat, y: Vec, Phi: Mat, lam: float, mu: float, iters: int,
group: int = 0) -> tuple[Vec, Vec, Vec]:
"""Return (x, d, b) after iters steps.
Precondition: lam > 0, mu > 0, and A and Phi have no common null vector,
so that A^T A + mu Phi^T Phi is positive definite. The iterates converge
to a minimizer for every mu > 0 (it is ADMM). At a limit, mu b is a dual
certificate: A^T (A x - y) + Phi^T (mu b) = 0 and mu b in lam d||.||_1(Phi x).
Cost: O(n^3) once for the factor, then O(n^2 + (m + q) n) per step.
"""
n, q = len(Phi[0]), len(Phi)
M = [[sum(A[k][i] * A[k][j] for k in range(len(A))) + mu * sum(Phi[k][i] * Phi[k][j] for k in range(q))
for j in range(n)] for i in range(n)]
L = cholesky(M) # @line L1
d, b = [0.0] * q, [0.0] * q
aty = mat_t_vec(A, y)
x = [0.0] * n
for _ in range(iters): # @line L2
rhs = [a + mu * c for a, c in zip(aty, mat_t_vec(Phi, [di - bi for di, bi in zip(d, b)]))]
x = chol_solve(L, rhs) # @line L3
phx = mat_vec(Phi, x)
d = shrink([a + c for a, c in zip(phx, b)], lam / mu, group) # @line L4
b = [bi + a - di for bi, a, di in zip(b, phx, d)] # @line L5
return x, d, b # @line L6
def objective(A: Mat, y: Vec, Phi: Mat, lam: float, x: Vec, group: int = 0) -> float:
r = [a - c for a, c in zip(mat_vec(A, x), y)]
p = mat_vec(Phi, x)
reg = sum(abs(a) for a in p) if group == 0 else sum(math.hypot(p[i], p[i + group]) for i in range(group))
return 0.5 * sum(a * a for a in r) + lam * reg
def difference_matrix(n: int) -> Mat:
"""The (n-1) x n forward difference matrix."""
return [[(-1.0 if j == i else 1.0 if j == i + 1 else 0.0) for j in range(n)] for i in range(n - 1)]
def gradient_matrix(n1: int, n2: int) -> Mat:
"""The 2N x N forward difference gradient with a Neumann border (zero rows at the border)."""
N = n1 * n2
G = [[0.0] * N for _ in range(2 * N)]
for i in range(n1):
for j in range(n2):
k = i * n2 + j
if i < n1 - 1:
G[k][k], G[k][k + n2] = -1.0, 1.0
if j < n2 - 1:
G[N + k][k], G[N + k][k + 1] = -1.0, 1.0
return G
test_split_bregman_method.py 133 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/split-bregman-method/. The authors are listed in prov/4TK5JZ.jsonl.
import itertools
import math
import random
from split_bregman_method import (
chol_solve,
cholesky,
difference_matrix,
gradient_matrix,
mat_t_vec,
mat_vec,
objective,
split_bregman,
)
def eye(n):
return [[1.0 if i == j else 0.0 for j in range(n)] for i in range(n)]
def rof_brute(f, lam):
"""Exact 1D TV denoising by trying every sign pattern of the differences."""
n = len(f)
I, D = eye(n), difference_matrix(n)
best, best_val = None, math.inf
for s in itertools.product((-1, 0, 1), repeat=n - 1):
cuts = [0] + [b + 1 for b in range(n - 1) if s[b] != 0] + [n]
u = []
for a, b in zip(cuts, cuts[1:]):
sl = s[a - 1] if a > 0 else 0
sr = s[b - 1] if b < n else 0
u.extend([sum(f[a:b]) / (b - a) - lam * (sl - sr) / (b - a)] * (b - a))
val = objective(I, f, D, lam, u)
if val < best_val:
best, best_val = u, val
return best
def lasso_brute(A, y, lam):
n = len(A[0])
best, best_val = [0.0] * n, objective(A, y, eye(n), lam, [0.0] * n)
for s in itertools.product((-1, 0, 1), repeat=n):
S = [j for j in range(n) if s[j] != 0]
if not S:
continue
M = [[sum(A[i][p] * A[i][q] for i in range(len(y))) for q in S] for p in S]
r = [sum(A[i][p] * y[i] for i in range(len(y))) - lam * s[p] for p in S]
try:
xs = chol_solve(cholesky(M), r)
except ValueError:
continue
x = [0.0] * n
for p, v in zip(S, xs):
x[p] = v
val = objective(A, y, eye(n), lam, x)
if val < best_val:
best, best_val = x, val
return best
def test_cholesky() -> None:
rng = random.Random(1)
B = [[rng.uniform(-1, 1) for _ in range(5)] for _ in range(7)]
M = [[sum(B[k][i] * B[k][j] for k in range(7)) for j in range(5)] for i in range(5)]
r = [rng.uniform(-1, 1) for _ in range(5)]
x = chol_solve(cholesky(M), r)
assert max(abs(a - b) for a, b in zip(mat_vec(M, x), r)) < 1e-10
def test_example_first_step() -> None:
f = [0.0, 0.0, 3.0, 3.0]
x, d, b = split_bregman(eye(4), f, difference_matrix(4), 1.0, 1.0, 1)
assert max(abs(a - c) for a, c in zip(x, (3 / 7, 6 / 7, 15 / 7, 18 / 7))) < 1e-12
assert max(abs(a - c) for a, c in zip(d, (0, 2 / 7, 0))) < 1e-12
assert max(abs(a - c) for a, c in zip(b, (3 / 7, 1, 3 / 7))) < 1e-12
def test_tv1d_brute_force() -> None:
rng = random.Random(6)
for _ in range(8):
n = rng.randint(2, 6)
f = [float(rng.randint(-3, 3)) for _ in range(n)]
lam = rng.choice((0.3, 0.7, 1.5))
mu = rng.choice((0.5, 1.0, 2.0))
x, _, _ = split_bregman(eye(n), f, difference_matrix(n), lam, mu, 400)
ref = rof_brute(f, lam)
assert max(abs(a - c) for a, c in zip(x, ref)) < 1e-6
def test_isotropic_step_image() -> None:
f = [0.0, 0.0, 4.0, 4.0] * 4
x, _, _ = split_bregman(eye(16), f, gradient_matrix(4, 4), 1.0, 1.0, 300, group=16)
for a, c in zip(x, [0.5, 0.5, 3.5, 3.5] * 4):
assert abs(a - c) < 1e-6
def test_lasso_brute_force() -> None:
rng = random.Random(3)
for _ in range(5):
m, n = 5, rng.randint(2, 4)
A = [[rng.gauss(0, 1) for _ in range(n)] for _ in range(m)]
y = [rng.gauss(0, 1) for _ in range(m)]
lam = rng.choice((0.2, 0.8, 2.0))
x, _, _ = split_bregman(A, y, eye(n), lam, 1.0, 600)
ref = lasso_brute(A, y, lam)
assert max(abs(a - c) for a, c in zip(x, ref)) < 1e-6
def test_deblur_dual_certificate() -> None:
# TV deblurring with a 3-tap blur: check the optimality conditions with v = mu b.
rng = random.Random(10)
n, lam, mu = 8, 0.3, 1.0
A = [[{0: 0.5, 1: 0.25, -1: 0.25}.get(j - i, 0.0) for j in range(n)] for i in range(n)]
x0 = [0.0, 0.0, 2.0, 2.0, 2.0, -1.0, -1.0, -1.0]
y = [a + rng.gauss(0, 0.05) for a in mat_vec(A, x0)]
D = difference_matrix(n)
x, d, b = split_bregman(A, y, D, lam, mu, 3000)
v = [mu * bi for bi in b]
grad = [a + c for a, c in zip(mat_t_vec(A, [p - q for p, q in zip(mat_vec(A, x), y)]), mat_t_vec(D, v))]
assert max(abs(g) for g in grad) < 1e-6
dx = mat_vec(D, x)
for vi, di in zip(v, dx):
assert abs(vi) <= lam + 1e-6
if abs(di) > 1e-4:
assert abs(vi - lam * math.copysign(1.0, di)) < 1e-6
# The certificate implies optimality: no random point does better.
best = objective(A, y, D, lam, x)
for _ in range(50):
z = [a + rng.uniform(-0.05, 0.05) for a in x]
assert objective(A, y, D, lam, z) >= best - 1e-9
History
Osher, Burger, Goldfarb, Xu and Yin (2005) introduced Bregman iteration for total variation imaging, and Yin, Osher, Goldfarb and Darbon (2008) applied it to problems. In 2009 Tom Goldstein and Stanley Osher proposed to split the term off with a new variable and to apply the Bregman update to the constraint. They gave fast results for total variation denoising and compressed sensing MRI. In the same year Ernie Esser (UCLA CAM report 09-31) and Simon Setzer showed that the method with one sweep is the alternating direction method of multipliers, which Glowinski and Marroco and Gabay and Mercier had studied in the 1970s, and that it is Douglas-Rachford splitting on the dual. This gave convergence for every and placed the method in the wider family of operator splitting methods.
References
- Tom Goldstein and Stanley Osher, The split Bregman method for L1-regularized problems, SIAM Journal on Imaging Sciences 2(2), 2009, pages 323 to 343
- Simon Setzer, Split Bregman algorithm, Douglas-Rachford splitting and frame shrinkage, Scale Space and Variational Methods in Computer Vision (SSVM 2009), LNCS 5567, pages 464 to 476
- Stanley Osher, Martin Burger, Donald Goldfarb, Jinjun Xu and Wotao Yin, An iterative regularization method for total variation-based image restoration, Multiscale Modeling and Simulation 4(2), 2005, pages 460 to 489
- Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato and Jonathan Eckstein, Distributed optimization and statistical learning via the alternating direction method of multipliers, Foundations and Trends in Machine Learning 3(1), 2011, pages 1 to 122
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 4TK5JZ Edit this page History Report an error Markdown