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
c1b69ae1
Commit
c1b69ae1
authored
6 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Add ConstantOperator2
parent
17e3b653
No related branches found
No related tags found
1 merge request
!295
Simplify for const
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty5/operators/operator.py
+29
-0
29 additions, 0 deletions
nifty5/operators/operator.py
with
29 additions
and
0 deletions
nifty5/operators/operator.py
+
29
−
0
View file @
c1b69ae1
...
...
@@ -179,6 +179,35 @@ class _ConstantOperator(Operator):
def
__repr__
(
self
):
return
'
ConstantOperator <- {}
'
.
format
(
self
.
domain
.
keys
())
class
_ConstantOperator2
(
Operator
):
def
__init__
(
self
,
target
,
constant_output
):
from
..sugar
import
makeDomain
self
.
_target
=
makeDomain
(
target
)
dom_keys
=
set
(
target
.
keys
())
-
set
(
constant_output
.
domain
.
keys
())
self
.
_domain
=
makeDomain
({
key
:
self
.
_target
[
key
]
for
key
in
dom_keys
})
self
.
_constant_output
=
constant_output
def
apply
(
self
,
x
):
from
..linearization
import
Linearization
self
.
_check_input
(
x
)
if
not
isinstance
(
x
,
Linearization
):
return
x
.
unite
(
self
.
_constant_output
)
from
.simple_linear_operators
import
_PartialExtractor
op
=
_PartialExtractor
(
self
.
target
,
x
.
jac
.
target
).
adjoint
val
=
x
.
val
.
unite
(
self
.
_constant_output
)
assert
val
.
domain
is
self
.
target
assert
val
.
domain
is
op
.
target
return
x
.
new
(
val
,
op
(
x
.
jac
))
def
__repr__
(
self
):
return
'
ConstantOperator2: {} <- {}
'
.
format
(
self
.
target
.
keys
(),
self
.
domain
.
keys
())
class
_FunctionApplier
(
Operator
):
def
__init__
(
self
,
domain
,
funcname
):
from
..sugar
import
makeDomain
...
...
This diff is collapsed.
Click to expand it.
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