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
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
NIFTy
Commits
d89a7ee0
Commit
d89a7ee0
authored
May 29, 2019
by
Martin Reinecke
Browse files
Merge branch 'PowerGrid' of gitlab.mpcdf.mpg.de:ift/NIFTy into PowerGrid
parents
ef3f25d2
8a8e6751
Pipeline
#50168
failed with stages
in 5 minutes and 10 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/getting_started_3.py
View file @
d89a7ee0
...
...
@@ -109,7 +109,8 @@ if __name__ == '__main__':
minimizer
=
ift
.
NewtonCG
(
ic_newton
)
# Set up likelihood and information Hamiltonian
likelihood
=
ift
.
GaussianEnergy
(
mean
=
data
,
covariance
=
N
)(
signal_response
)
likelihood
=
ift
.
GaussianEnergy
(
mean
=
data
,
inverse_covariance
=
N
.
inverse
)(
signal_response
)
H
=
ift
.
StandardHamiltonian
(
likelihood
,
ic_sampling
)
initial_mean
=
ift
.
MultiField
.
full
(
H
.
domain
,
0.
)
...
...
nifty5/operators/adder.py
View file @
d89a7ee0
...
...
@@ -28,12 +28,15 @@ class Adder(Operator):
field : Field or MultiField
The field by which the input is shifted.
"""
def
__init__
(
self
,
field
):
def
__init__
(
self
,
field
,
neg
=
False
):
if
not
isinstance
(
field
,
(
Field
,
MultiField
)):
raise
TypeError
self
.
_field
=
field
self
.
_domain
=
self
.
_target
=
field
.
domain
self
.
_neg
=
bool
(
neg
)
def
apply
(
self
,
x
):
self
.
_check_input
(
x
)
if
self
.
_neg
:
return
x
-
self
.
_field
return
x
+
self
.
_field
nifty5/operators/energy_operators.py
View file @
d89a7ee0
...
...
@@ -110,8 +110,8 @@ class GaussianEnergy(EnergyOperator):
----------
mean : Field
Mean of the Gaussian. Default is 0.
covariance : LinearOperator
C
ovariance of the Gaussian. Default is the identity operator.
inverse_
covariance : LinearOperator
Inverse c
ovariance of the Gaussian. Default is the identity operator.
domain : Domain, DomainTuple, tuple of Domain or MultiDomain
Operator domain. By default it is inferred from `mean` or
`covariance` if specified
...
...
@@ -121,28 +121,27 @@ class GaussianEnergy(EnergyOperator):
At least one of the arguments has to be provided.
"""
def
__init__
(
self
,
mean
=
None
,
covariance
=
None
,
domain
=
None
):
def
__init__
(
self
,
mean
=
None
,
inverse_
covariance
=
None
,
domain
=
None
):
if
mean
is
not
None
and
not
isinstance
(
mean
,
(
Field
,
MultiField
)):
raise
TypeError
if
covariance
is
not
None
and
not
isinstance
(
covariance
,
LinearOperator
):
if
inverse_covariance
is
not
None
and
not
isinstance
(
inverse_covariance
,
LinearOperator
):
raise
TypeError
self
.
_domain
=
None
if
mean
is
not
None
:
self
.
_checkEquivalence
(
mean
.
domain
)
if
covariance
is
not
None
:
self
.
_checkEquivalence
(
covariance
.
domain
)
if
inverse_
covariance
is
not
None
:
self
.
_checkEquivalence
(
inverse_
covariance
.
domain
)
if
domain
is
not
None
:
self
.
_checkEquivalence
(
domain
)
if
self
.
_domain
is
None
:
raise
ValueError
(
"no domain given"
)
self
.
_mean
=
mean
if
covariance
is
None
:
if
inverse_
covariance
is
None
:
self
.
_op
=
SquaredNormOperator
(
self
.
_domain
).
scale
(
0.5
)
else
:
self
.
_op
=
QuadraticFormOperator
(
covariance
.
inverse
)
self
.
_icov
=
None
if
covariance
is
None
else
covariance
.
inverse
self
.
_op
=
QuadraticFormOperator
(
inverse_
covariance
)
self
.
_icov
=
None
if
inverse_
covariance
is
None
else
inverse_
covariance
def
_checkEquivalence
(
self
,
newdom
):
newdom
=
makeDomain
(
newdom
)
...
...
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