Skip to content
Snippets Groups Projects
Commit 93f99d30 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

second try to tweak NoiseEnergy

parent fe4ad58f
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -38,29 +38,21 @@ class NoiseEnergy(Energy): ...@@ -38,29 +38,21 @@ class NoiseEnergy(Energy):
grad = -.5 * self.N.inverse_times(s.conjugate()*s) grad = -.5 * self.N.inverse_times(s.conjugate()*s)
if self._gradient is None: if self._gradient is None:
self._value = lh self._value = lh
self._gradient = grad.copy() self._gradient = grad
else: else:
self._value += lh self._value += lh
self._gradient += grad self._gradient += grad
expmpos = exp(-position) expmpos = exp(-position)
self._value *= 1./len(res_sample_list) self._value *= 1./len(res_sample_list)
# possum = position.sum() possum = position.sum()
# s1 = (alpha-1.)*possum if np.isscalar(alpha) \ s1 = (alpha-1.)*possum if np.isscalar(alpha) \
# else (alpha-1.).vdot(position) else (alpha-1.).vdot(position)
# s2 = q*expmpos.sum() if np.isscalar(q) else q.vdot(expmpos) s2 = q*expmpos.sum() if np.isscalar(q) else q.vdot(expmpos)
# self._value += .5*possum + s1 + s2 self._value += .5*possum + s1 + s2
# self._gradient *= 1./len(res_sample_list) self._gradient *= 1./len(res_sample_list)
# self._gradient += (alpha-0.5) - q*expmpos self._gradient += (alpha-0.5) - q*expmpos
alpha_field = Field(position.domain, val=alpha)
q_field = Field(position.domain, val=q)
self._value += .5 * self.position.sum()
self._value += (alpha_field-1.).vdot(self.position) + \
q_field.vdot(expmpos)
self._gradient *= 1./len(self.res_sample_list)
self._gradient += (alpha_field-0.5) - q_field*expmpos
self._gradient.lock() self._gradient.lock()
def at(self, position): def at(self, position):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment