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
6e6b4f76
Commit
6e6b4f76
authored
7 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
running, but not correctly
parent
4067aa04
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
nifty5/field.py
+2
-0
2 additions, 0 deletions
nifty5/field.py
nifty5/operator.py
+18
-4
18 additions, 4 deletions
nifty5/operator.py
nifty5/operators/relaxed_sum_operator.py
+2
-2
2 additions, 2 deletions
nifty5/operators/relaxed_sum_operator.py
with
22 additions
and
6 deletions
nifty5/field.py
+
2
−
0
View file @
6e6b4f76
...
...
@@ -49,6 +49,8 @@ class Field(object):
def
__init__
(
self
,
domain
,
val
):
if
not
isinstance
(
domain
,
DomainTuple
):
raise
TypeError
(
"
domain must be of type DomainTuple
"
)
if
np
.
isscalar
(
val
):
val
=
np
.
full
((),
val
)
if
not
isinstance
(
val
,
dobj
.
data_object
):
raise
TypeError
(
"
val must be of type dobj.data_object
"
)
if
domain
.
shape
!=
val
.
shape
:
...
...
This diff is collapsed.
Click to expand it.
nifty5/operator.py
+
18
−
4
View file @
6e6b4f76
...
...
@@ -11,9 +11,10 @@ from .multi.multi_field import MultiField
class
Linearization
(
object
):
def
__init__
(
self
,
val
,
jac
):
def
__init__
(
self
,
val
,
jac
,
metric
=
None
):
self
.
_val
=
val
self
.
_jac
=
jac
self
.
_metric
=
metric
@property
def
domain
(
self
):
...
...
@@ -31,17 +32,25 @@ class Linearization(object):
def
jac
(
self
):
return
self
.
_jac
@property
def
metric
(
self
):
return
self
.
_metric
def
__neg__
(
self
):
return
Linearization
(
-
self
.
_val
,
self
.
_jac
*
(
-
1
))
return
Linearization
(
-
self
.
_val
,
self
.
_jac
*
(
-
1
),
None
if
self
.
_metric
is
None
else
self
.
_metric
*
(
-
1
))
def
__add__
(
self
,
other
):
if
isinstance
(
other
,
Linearization
):
from
.operators.relaxed_sum_operator
import
RelaxedSumOperator
met
=
None
if
self
.
_metric
is
not
None
and
other
.
_metric
is
not
None
:
met
=
RelaxedSumOperator
((
self
.
_metric
,
other
.
_metric
))
return
Linearization
(
self
.
_val
.
unite
(
other
.
_val
),
RelaxedSumOperator
((
self
.
_jac
,
other
.
_jac
)))
RelaxedSumOperator
((
self
.
_jac
,
other
.
_jac
))
,
met
)
if
isinstance
(
other
,
(
int
,
float
,
complex
,
Field
,
MultiField
)):
return
Linearization
(
self
.
_val
+
other
,
self
.
_jac
)
return
Linearization
(
self
.
_val
+
other
,
self
.
_jac
,
self
.
_metric
)
def
__radd__
(
self
,
other
):
return
self
.
__add__
(
other
)
...
...
@@ -76,6 +85,11 @@ class Linearization(object):
d1
=
makeOp
(
other
)
return
Linearization
(
self
.
_val
*
other
,
d1
*
self
.
_jac
)
def
sum
(
self
):
from
.sugar
import
full
from
.operators.vdot_operator
import
VdotOperator
return
Linearization
(
full
((),
self
.
_val
.
sum
()),
VdotOperator
(
full
(
self
.
_jac
.
target
,
1
))
*
self
.
_jac
)
@staticmethod
def
make_var
(
field
):
from
.operators.scaling_operator
import
ScalingOperator
...
...
This diff is collapsed.
Click to expand it.
nifty5/operators/relaxed_sum_operator.py
+
2
−
2
View file @
6e6b4f76
...
...
@@ -60,6 +60,6 @@ class RelaxedSumOperator(LinearOperator):
self
.
_check_mode
(
mode
)
res
=
None
for
op
in
self
.
_ops
:
x
=
op
.
apply
(
x
.
extract
(
op
.
_dom
(
mode
)),
mode
)
res
=
x
if
res
is
None
else
res
.
unite
(
x
)
tmp
=
op
.
apply
(
x
.
extract
(
op
.
_dom
(
mode
)),
mode
)
res
=
tmp
if
res
is
None
else
res
.
unite
(
tmp
)
return
res
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