Commit 4a67895d authored by Lukas Platz's avatar Lukas Platz

Start optimization at zero instead of rand position

Sample more often to make better use of the computation time.
Beforehand, when starting from zero, convergence was far from
reached in the time the demo ran, while much time was used
to optimize for the initial samples.
parent 1f84d24e
...@@ -70,13 +70,13 @@ if __name__ == '__main__': ...@@ -70,13 +70,13 @@ if __name__ == '__main__':
# set up minimization and inversion schemes # set up minimization and inversion schemes
ic_sampling = ift.GradientNormController(iteration_limit=100) ic_sampling = ift.GradientNormController(iteration_limit=100)
ic_newton = ift.GradInfNormController( ic_newton = ift.GradInfNormController(
name='Newton', tol=1e-7, iteration_limit=1000) name='Newton', tol=1e-7, iteration_limit=35)
minimizer = ift.NewtonCG(ic_newton) minimizer = ift.NewtonCG(ic_newton)
# build model Hamiltonian # build model Hamiltonian
H = ift.Hamiltonian(likelihood, ic_sampling) H = ift.Hamiltonian(likelihood, ic_sampling)
INITIAL_POSITION = ift.from_random('normal', H.domain) INITIAL_POSITION = ift.MultiField.full(H.domain, 0.)
position = INITIAL_POSITION position = INITIAL_POSITION
plot = ift.Plot() plot = ift.Plot()
...@@ -87,7 +87,7 @@ if __name__ == '__main__': ...@@ -87,7 +87,7 @@ if __name__ == '__main__':
# number of samples used to estimate the KL # number of samples used to estimate the KL
N_samples = 20 N_samples = 20
for i in range(2): for i in range(5):
KL = ift.KL_Energy(position, H, N_samples) KL = ift.KL_Energy(position, H, N_samples)
KL, convergence = minimizer(KL) KL, convergence = minimizer(KL)
position = KL.position position = KL.position
......
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