Commit 012feede by Martin Reinecke

### cleanup

parent 561a434c
 ... ... @@ -17,18 +17,14 @@ class EnergyAdapter(Energy): def _fill_all(self): tmp = self._op(Linearization.make_var(self._position)) self._val = tmp.val if not np.isscalar(self._val): self._val = self._val.local_data[()] self._val = tmp.val.local_data[()] self._grad = tmp.gradient self._metric = tmp.metric @property def value(self): if self._val is None: self._val = self._op(self._position) if not np.isscalar(self._val): self._val = self._val.local_data[()] self._val = self._op(self._position).local_data[()] return self._val @property ... ...
 ... ... @@ -127,7 +127,7 @@ class PoissonianEnergy(EnergyOperator): x = self._op(x) res = x.sum() - x.log().vdot(self._d) if not isinstance(x, Linearization): return res return Field(self._target, res) metric = SandwichOperator.make(x.jac, makeOp(1./x.val)) return res.add_metric(metric) ... ... @@ -145,7 +145,7 @@ class BernoulliEnergy(EnergyOperator): x = self._p(x) v = x.log().vdot(-self._d) - (1.-x).log().vdot(1.-self._d) if not isinstance(x, Linearization): return v return Field(self._target, v) met = makeOp(1./(x.val*(1.-x.val))) met = SandwichOperator.make(x.jac, met) return v.add_metric(met) ... ... @@ -164,7 +164,7 @@ class Hamiltonian(EnergyOperator): def apply(self, x): if self._ic_samp is None or not isinstance(x, Linearization): return self._lh(x) + self._prior(x) return self._lh(x)+self._prior(x) else: lhx = self._lh(x) prx = self._prior(x) ... ... @@ -189,5 +189,6 @@ class SampledKullbachLeiblerDivergence(EnergyOperator): return self._h.domain def apply(self, x): return (utilities.my_sum(map(lambda v: self._h(x+v), self._res_samples)) * (1./len(self._res_samples))) res = (utilities.my_sum(map(lambda v: self._h(x+v), self._res_samples)) * (1./len(self._res_samples))) return res
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!