Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
93f99d30
Commit
93f99d30
authored
Mar 29, 2018
by
Martin Reinecke
Browse files
second try to tweak NoiseEnergy
parent
fe4ad58f
Pipeline
#26577
passed with stages
in 8 minutes and 41 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty4/library/noise_energy.py
View file @
93f99d30
...
...
@@ -38,29 +38,21 @@ class NoiseEnergy(Energy):
grad
=
-
.
5
*
self
.
N
.
inverse_times
(
s
.
conjugate
()
*
s
)
if
self
.
_gradient
is
None
:
self
.
_value
=
lh
self
.
_gradient
=
grad
.
copy
()
self
.
_gradient
=
grad
else
:
self
.
_value
+=
lh
self
.
_gradient
+=
grad
expmpos
=
exp
(
-
position
)
self
.
_value
*=
1.
/
len
(
res_sample_list
)
#
possum = position.sum()
#
s1 = (alpha-1.)*possum if np.isscalar(alpha) \
#
else (alpha-1.).vdot(position)
#
s2 = q*expmpos.sum() if np.isscalar(q) else q.vdot(expmpos)
#
self._value += .5*possum + s1 + s2
possum
=
position
.
sum
()
s1
=
(
alpha
-
1.
)
*
possum
if
np
.
isscalar
(
alpha
)
\
else
(
alpha
-
1.
).
vdot
(
position
)
s2
=
q
*
expmpos
.
sum
()
if
np
.
isscalar
(
q
)
else
q
.
vdot
(
expmpos
)
self
.
_value
+=
.
5
*
possum
+
s1
+
s2
# self._gradient *= 1./len(res_sample_list)
# 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
*=
1.
/
len
(
res_sample_list
)
self
.
_gradient
+=
(
alpha
-
0.5
)
-
q
*
expmpos
self
.
_gradient
.
lock
()
def
at
(
self
,
position
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment