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
a54c890a
Commit
a54c890a
authored
Aug 14, 2018
by
Martin Reinecke
Browse files
fix partial inference with Newton minimizers
parent
c749042e
Changes
2
Hide whitespace changes
Inline
Side-by-side
nifty5/minimization/energy_adapter.py
View file @
a54c890a
...
...
@@ -4,6 +4,8 @@ from ..compat import *
from
..minimization.energy
import
Energy
from
..linearization
import
Linearization
from
..multi_field
import
MultiField
from
..operators.scaling_operator
import
ScalingOperator
from
..operators.block_diagonal_operator
import
BlockDiagonalOperator
import
numpy
as
np
...
...
@@ -25,14 +27,10 @@ class EnergyAdapter(Energy):
if
len
(
self
.
_constants
)
==
0
:
tmp
=
self
.
_op
(
Linearization
.
make_var
(
self
.
_position
))
else
:
ctmp
=
MultiField
.
from_dict
({
key
:
val
for
key
,
val
in
self
.
_position
.
items
()
if
key
in
self
.
_constants
})
vtmp
=
MultiField
.
from_dict
({
key
:
val
for
key
,
val
in
self
.
_position
.
items
()
if
key
not
in
self
.
_constants
})
lin
=
Linearization
.
make_var
(
vtmp
)
+
Linearization
.
make_const
(
ctmp
)
tmp
=
self
.
_op
(
lin
)
ops
=
[
ScalingOperator
(
0.
if
key
in
self
.
_constants
else
1.
,
dom
)
for
key
,
dom
in
self
.
_position
.
domain
.
items
()]
bdop
=
BlockDiagonalOperator
(
self
.
_position
.
domain
,
tuple
(
ops
))
tmp
=
self
.
_op
(
Linearization
(
self
.
_position
,
bdop
))
self
.
_val
=
tmp
.
val
.
local_data
[()]
self
.
_grad
=
tmp
.
gradient
if
self
.
_controller
is
not
None
:
...
...
nifty5/operators/diagonal_operator.py
View file @
a54c890a
...
...
@@ -159,8 +159,8 @@ class DiagonalOperator(EndomorphicOperator):
def
process_sample
(
self
,
samp
,
from_inverse
):
if
(
self
.
_complex
or
(
self
.
_diagmin
<
0.
)
or
(
self
.
_diagmin
==
0.
and
from_inverse
)):
raise
ValueError
(
"operator not positive definite"
)
(
self
.
_diagmin
==
0.
and
from_inverse
)):
raise
ValueError
(
"operator not positive definite"
)
if
from_inverse
:
res
=
samp
.
local_data
/
np
.
sqrt
(
self
.
_ldiag
)
else
:
...
...
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