Plug-and-Play Regularization

A group of regularization terms that can not be directly written down as function are learned plug-and-play (PnP) priors. These are terms based on deep neural networks, which are trainted to implement the proximal map corresponding to the regularization term. Such a PnP prior can be used in the same way as any other regularization term.

The following example shows how to use a PnP prior in the context of the Kaczmarz solver.

using RegularizedLeastSquares
A = randn(32, 16)
x = randn(16)
b = A*x;

For the documentation we will just use the identity function as a placeholder for the PnP prior.

model = identity
identity (generic function with 1 method)

In practice, you would replace this with a neural network:

using Flux
model = Flux.loadmodel!(model, ...)

The model can then be used together with the PnPRegularization term:

reg = PnPRegularization(1.0; model = model, shape = [16]);

Since models often expect a specific input range, we can use the MinMaxTransform to normalize the input:

reg = PnPRegularization(1.0; model = model, shape = [16], input_transform = RegularizedLeastSquares.MinMaxTransform);

Custom input transforms can be implemented by passing something callable as the input_transform keyword argument. For more details see the PnPRegularization documentation.

The regularization term can then be used in the solver:

solver = createLinearSolver(Kaczmarz, A; reg = reg, iterations = 32)
x_approx = solve!(solver, b)
16-element Vector{Float64}:
  1.4022194320967984
  0.8549491684816322
 -1.4965292809749708
 -0.7092432504990294
  1.0154100719194115
  0.9058532120498985
 -0.2884617620226724
 -0.8602100501859025
  0.18195737252183264
 -1.7391975014867498
 -1.8422441705811354
  0.5918746445434104
  0.15178033916523725
 -0.6042345187818525
 -0.22338513573888563
 -0.5552958778011803

This page was generated using Literate.jl.