Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
11e62c4e
Commit
11e62c4e
authored
5 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Add performance check to jacobian consistency
parent
128309f6
No related branches found
No related tags found
1 merge request
!417
Performance pa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty6/extra.py
+32
-0
32 additions, 0 deletions
nifty6/extra.py
with
32 additions
and
0 deletions
nifty6/extra.py
+
32
−
0
View file @
11e62c4e
...
...
@@ -123,6 +123,37 @@ def _domain_check(op):
'
be instances of either DomainTuple or MultiDomain.
'
)
def
_performance_check
(
op
,
pos
,
raise_on_fail
):
class
CountingOp
(
LinearOperator
):
def
__init__
(
self
,
domain
):
from
.sugar
import
makeDomain
self
.
_domain
=
self
.
_target
=
makeDomain
(
domain
)
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
self
.
_count
=
0
def
apply
(
self
,
x
,
mode
):
self
.
_count
+=
1
return
x
@property
def
count
(
self
):
return
self
.
_count
cop
=
CountingOp
(
op
.
domain
)
op
=
op
@
cop
lin
=
op
(
Linearization
.
make_var
(
pos
))
cond
=
[
cop
.
count
!=
1
]
lin
.
jac
(
pos
)
cond
.
append
(
cop
.
count
!=
2
)
lin
.
jac
.
adjoint
(
lin
.
val
)
cond
.
append
(
cop
.
count
!=
3
)
if
any
(
cond
):
s
=
'
The operator has a performance problem.
'
if
raise_on_fail
:
raise
RuntimeError
(
s
)
from
.logger
import
logger
logger
.
warn
(
s
)
def
consistency_check
(
op
,
domain_dtype
=
np
.
float64
,
target_dtype
=
np
.
float64
,
atol
=
0
,
rtol
=
1e-7
,
only_r_linear
=
False
):
"""
...
...
@@ -219,6 +250,7 @@ def check_jacobian_consistency(op, loc, tol=1e-8, ntries=100):
"""
_domain_check
(
op
)
_actual_domain_check_nonlinear
(
op
,
loc
)
_performance_check
(
op
,
loc
,
True
)
# FIXME Make the default False
for
_
in
range
(
ntries
):
lin
=
op
(
Linearization
.
make_var
(
loc
))
loc2
,
lin2
=
_get_acceptable_location
(
op
,
loc
,
lin
)
...
...
This diff is collapsed.
Click to expand it.
Philipp Arras
@parras
mentioned in issue
#285 (closed)
·
5 years ago
mentioned in issue
#285 (closed)
mentioned in issue #285
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment