Skip to content
GitLab
Menu
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
695b9d9d
Commit
695b9d9d
authored
Sep 10, 2018
by
Martin Reinecke
Browse files
allow specification of constants for samples
parent
94d60caa
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/minimization/kl_energy.py
View file @
695b9d9d
...
...
@@ -7,12 +7,17 @@ from .. import utilities
class
KL_Energy
(
Energy
):
def
__init__
(
self
,
position
,
h
,
nsamp
,
constants
=
[],
_samples
=
None
):
def
__init__
(
self
,
position
,
h
,
nsamp
,
constants
=
[],
constants_samples
=
None
,
_samples
=
None
):
super
(
KL_Energy
,
self
).
__init__
(
position
)
self
.
_h
=
h
self
.
_constants
=
constants
if
constants_samples
is
None
:
constants_samples
=
constants
self
.
_constants_samples
=
constants_samples
if
_samples
is
None
:
met
=
h
(
Linearization
.
make_var
(
position
,
True
)).
metric
met
=
h
(
Linearization
.
make_partial_var
(
position
,
constants_samples
,
True
)).
metric
_samples
=
tuple
(
met
.
draw_sample
(
from_inverse
=
True
)
for
_
in
range
(
nsamp
))
self
.
_samples
=
_samples
...
...
@@ -32,7 +37,8 @@ class KL_Energy(Energy):
self
.
_metric
=
None
def
at
(
self
,
position
):
return
KL_Energy
(
position
,
self
.
_h
,
0
,
self
.
_constants
,
self
.
_samples
)
return
KL_Energy
(
position
,
self
.
_h
,
0
,
self
.
_constants
,
self
.
_constants_samples
,
self
.
_samples
)
@
property
def
value
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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