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
2155fa91
Commit
2155fa91
authored
Jun 16, 2020
by
Reimar Leike
Browse files
Fixed complex Fisher metric for Gaussian
parent
a25614fd
Pipeline
#76674
passed with stages
in 11 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty6/operators/energy_operators.py
View file @
2155fa91
...
...
@@ -27,7 +27,7 @@ from .linear_operator import LinearOperator
from
.operator
import
Operator
from
.sampling_enabler
import
SamplingDtypeSetter
,
SamplingEnabler
from
.scaling_operator
import
ScalingOperator
from
.simple_linear_operators
import
VdotOperator
from
.simple_linear_operators
import
VdotOperator
,
FieldAdapter
def
_check_sampling_dtype
(
domain
,
dtypes
):
...
...
@@ -167,6 +167,15 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
return
res
.
add_metric
(
SamplingDtypeSetter
(
met
,
self
.
_sampling_dtype
))
def
_build_MultiScalingOperator
(
domain
,
scales
):
op
=
None
for
k
,
dom
in
domain
.
items
():
o
=
ScalingOperator
(
dom
,
scales
[
k
])
FA
=
FieldAdapter
(
dom
,
k
)
o
=
FA
.
adjoint
@
o
@
FA
op
=
o
if
op
is
None
else
op
+
o
return
op
class
GaussianEnergy
(
EnergyOperator
):
"""Computes a negative-log Gaussian.
...
...
@@ -235,7 +244,18 @@ class GaussianEnergy(EnergyOperator):
self
.
_met
=
inverse_covariance
if
sampling_dtype
is
not
None
:
self
.
_met
=
SamplingDtypeSetter
(
self
.
_met
,
sampling_dtype
)
if
isinstance
(
sampling_dtype
,
dict
):
from
.sandwich_operator
import
SandwichOperator
scale
=
{
k
:
np
.
sqrt
(
2.
)
if
np
.
issubdtype
(
v
,
np
.
complexfloating
)
else
1.
for
k
,
v
in
sampling_dtype
.
items
()}
scale
=
_build_MultiScalingOperator
(
self
.
_domain
,
scale
)
self
.
_met
=
SandwichOperator
.
make
(
scale
,
self
.
_met
)
else
:
if
np
.
issubdtype
(
sampling_dtype
,
np
.
complexfloating
):
from
.sandwich_operator
import
SandwichOperator
scale
=
ScalingOperator
(
self
.
_met
.
domain
,
np
.
sqrt
(
2
))
self
.
_met
=
SandwichOperator
.
make
(
scale
,
self
.
_met
)
def
_checkEquivalence
(
self
,
newdom
):
newdom
=
makeDomain
(
newdom
)
if
self
.
_domain
is
None
:
...
...
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