Commit e7f235e5 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add possibility to add approximation to Sampling Enabler

parent 3028acad
......@@ -63,16 +63,20 @@ class SamplingEnabler(EndomorphicOperator):
s = self._prior.draw_sample(from_inverse=True)
sp = self._prior(s)
nj = self._likelihood.draw_sample()
energy = QuadraticEnergy(s, self._op, sp + nj,
_grad=self._likelihood(s) - nj)
inverter = ConjugateGradient(self._ic)
if self._approximation is not None:
energy = QuadraticEnergy(s, self._op, sp + nj)
energy, convergence = inverter(
energy, preconditioner=self._approximation.inverse)
energy = QuadraticEnergy(s, self._op, sp + nj,
_grad=self._likelihood(s) - nj)
energy, convergence = inverter(energy)
return energy.position
def add_approximation(self, approx):
self._approximation = approx
def apply(self, x, mode):
return self._op.apply(x, mode)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment