Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
3f00aed2
Commit
3f00aed2
authored
Jul 10, 2018
by
Martin Reinecke
Browse files
minor cleanups
parent
59d7def9
Changes
5
Show whitespace changes
Inline
Side-by-side
nifty5/energies/hamiltonian.py
View file @
3f00aed2
...
...
@@ -31,10 +31,10 @@ class Hamiltonian(Energy):
lh: Likelihood (energy object)
prior:
"""
super
(
Hamiltonian
,
self
).
__init__
(
lh
.
position
)
super
(
Hamiltonian
,
self
).
__init__
(
lh
.
_
position
)
self
.
_lh
=
lh
self
.
_ic_samp
=
iteration_controller_sampling
self
.
_prior
=
GaussianEnergy
(
Variable
(
self
.
position
))
self
.
_prior
=
GaussianEnergy
(
Variable
(
self
.
_
position
))
def
at
(
self
,
position
):
return
self
.
__class__
(
self
.
_lh
.
at
(
position
),
self
.
_ic_samp
)
...
...
nifty5/library/gaussian_energy.py
View file @
3f00aed2
...
...
@@ -32,7 +32,7 @@ class GaussianEnergy(Energy):
value = 0.5 * s.vdot(s), i.e. a log-Gauss distribution with unit
covariance
"""
super
(
GaussianEnergy
,
self
).
__init__
(
inp
.
position
)
super
(
GaussianEnergy
,
self
).
__init__
(
inp
.
_
position
)
self
.
_inp
=
inp
self
.
_mean
=
mean
self
.
_cov
=
covariance
...
...
nifty5/minimization/quadratic_energy.py
View file @
3f00aed2
...
...
@@ -35,14 +35,14 @@ class QuadraticEnergy(Energy):
self
.
_grad
=
_grad
Ax
=
_grad
if
b
is
None
else
_grad
+
b
else
:
Ax
=
self
.
_A
(
self
.
position
)
Ax
=
self
.
_A
(
self
.
_
position
)
self
.
_grad
=
Ax
if
b
is
None
else
Ax
-
b
self
.
_value
=
0.5
*
self
.
position
.
vdot
(
Ax
)
self
.
_value
=
0.5
*
self
.
_
position
.
vdot
(
Ax
)
if
b
is
not
None
:
self
.
_value
-=
b
.
vdot
(
self
.
position
)
self
.
_value
-=
b
.
vdot
(
self
.
_
position
)
def
at
(
self
,
position
):
return
QuadraticEnergy
(
position
=
position
,
A
=
self
.
_A
,
b
=
self
.
_b
)
return
QuadraticEnergy
(
position
,
self
.
_A
,
self
.
_b
)
def
at_with_grad
(
self
,
position
,
grad
):
""" Specialized version of `at`, taking also a gradient.
...
...
@@ -63,8 +63,7 @@ class QuadraticEnergy(Energy):
Energy
Energy object at new position.
"""
return
QuadraticEnergy
(
position
=
position
,
A
=
self
.
_A
,
b
=
self
.
_b
,
_grad
=
grad
)
return
QuadraticEnergy
(
position
,
self
.
_A
,
self
.
_b
,
grad
)
@
property
def
value
(
self
):
...
...
nifty5/models/multi_model.py
View file @
3f00aed2
...
...
@@ -35,7 +35,7 @@ class MultiModel(Model):
val
=
self
.
_model
.
value
if
not
isinstance
(
val
.
domain
,
DomainTuple
):
raise
TypeError
self
.
_value
=
MultiField
({
key
:
val
})
self
.
_value
=
MultiField
.
from_dict
({
key
:
val
})
self
.
_jacobian
=
(
MultiAdaptor
(
self
.
value
.
domain
)
*
self
.
_model
.
jacobian
)
...
...
nifty5/operators/symmetrizing_operator.py
View file @
3f00aed2
Write
Preview
Markdown
is supported
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