Commit 537fb1a6 authored by Reimar H Leike's avatar Reimar H Leike
Browse files

fixup

parent 1f598ab5
Pipeline #61339 passed with stages
in 9 minutes and 29 seconds
...@@ -187,8 +187,8 @@ class NewtonCG(DescentMinimizer): ...@@ -187,8 +187,8 @@ class NewtonCG(DescentMinimizer):
e = QuadraticEnergy(0*energy.position, energy.metric, energy.gradient) e = QuadraticEnergy(0*energy.position, energy.metric, energy.gradient)
p = None p = None
if self._napprox > 1: if self._napprox > 1:
unscmet, sc = energy.unscaled_metric() met = energy.metric
p = makeOp(approximation2endo(unscmet, self._napprox)*sc).inverse p = makeOp(approximation2endo(met, self._napprox)).inverse
e, conv = ConjugateGradient(ic, nreset=self._nreset)(e, p) e, conv = ConjugateGradient(ic, nreset=self._nreset)(e, p)
return -e.position return -e.position
......
...@@ -23,7 +23,7 @@ from .energy import Energy ...@@ -23,7 +23,7 @@ from .energy import Energy
from mpi4py import MPI from mpi4py import MPI
import numpy as np import numpy as np
from ..probing import approximation2endo from ..probing import approximation2endo
from ..sugar import makeOp from ..sugar import makeOp, full
from ..field import Field from ..field import Field
from ..multi_field import MultiField from ..multi_field import MultiField
...@@ -70,7 +70,7 @@ class KLMetric(EndomorphicOperator): ...@@ -70,7 +70,7 @@ class KLMetric(EndomorphicOperator):
return self._KL.apply_metric(x) return self._KL.apply_metric(x)
def draw_sample(self, from_inverse=False, dtype=np.float64): def draw_sample(self, from_inverse=False, dtype=np.float64):
self._KL.metric_sample(from_inverse, dtype) return self._KL.metric_sample(from_inverse, dtype)
...@@ -241,9 +241,9 @@ class MetricGaussianKL_MPI(Energy): ...@@ -241,9 +241,9 @@ class MetricGaussianKL_MPI(Energy):
if from_inverse: if from_inverse:
raise NotImplementedError() raise NotImplementedError()
lin = self._lin.with_want_metric() lin = self._lin.with_want_metric()
samp = ift.full(self._hamiltonian.domain, 0.) samp = full(self._hamiltonian.domain, 0.)
for s in self._samples: for v in self._samples:
samp = samp + self._hamiltonian(lin+v).metric.draw_sample(dtype) samp = samp + self._hamiltonian(lin+v).metric.draw_sample(from_inverse=False, dtype=dtype)
return allreduce_sum_field(samp) return allreduce_sum_field(samp)
def metric_sample(self, from_inverse=False, dtype=np.float64): def metric_sample(self, from_inverse=False, dtype=np.float64):
......
Markdown is supported
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