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

Add debugging factor back in

parent b4452b8b
......@@ -153,7 +153,7 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
Data type of the samples. Usually either 'np.float*' or 'np.complex*'
"""
def __init__(self, domain, residual_key, inverse_covariance_key, sampling_dtype):
def __init__(self, domain, residual_key, inverse_covariance_key, sampling_dtype, _debugging_factor=1.):
self._kr = str(residual_key)
self._ki = str(inverse_covariance_key)
dom = DomainTuple.make(domain)
......@@ -161,6 +161,7 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
self._dt = {self._kr: sampling_dtype, self._ki: np.float64}
_check_sampling_dtype(self._domain, self._dt)
self._cplx = _iscomplex(sampling_dtype)
self._fac = float(_debugging_factor)
def apply(self, x):
self._check_input(x)
......@@ -171,7 +172,7 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
res = 0.5*(r.vdot(r*i) - i.ptw("log").sum())
if not x.want_metric:
return res
met = i.val if self._cplx else 0.5*i.val
met = self._fac*(i.val if self._cplx else 0.5*i.val)
met = MultiField.from_dict({self._kr: i.val, self._ki: met**(-2)})
return res.add_metric(SamplingDtypeSetter(makeOp(met), self._dt))
......
......@@ -129,7 +129,8 @@ def test_VariableCovarianceGaussianEnergy(dtype, factor):
res = ift.from_random(dom, 'normal', dtype=dtype)
ivar = ift.from_random(dom, 'normal')**2+4.
mf = ift.MultiField.from_dict({'res':res, 'ivar':ivar})
energy = ift.VariableCovarianceGaussianEnergy(dom, 'res', 'ivar', dtype, _debugging_factor=factor)
energy = ift.VariableCovarianceGaussianEnergy(dom, 'res', 'ivar', dtype,
_debugging_factor=factor)
def get_noisy_data(mean):
samp = ift.from_random(dom, 'normal', dtype)
samp = samp/mean['ivar'].sqrt()
......
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