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
157d13f5
Commit
157d13f5
authored
5 years ago
by
Lukas Platz
Browse files
Options
Downloads
Patches
Plain Diff
replace integral/1-norm over amplitudes with 2-norm
parent
3022d9c8
No related branches found
No related tags found
1 merge request
!353
WIP: Mf new
Pipeline
#61609
passed
5 years ago
Stage: build_docker
Stage: test
Stage: demo_runs
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nifty5/library/correlated_fields.py
+4
-3
4 additions, 3 deletions
nifty5/library/correlated_fields.py
nifty5/operators/operator_normalizer.py
+7
-5
7 additions, 5 deletions
nifty5/operators/operator_normalizer.py
with
11 additions
and
8 deletions
nifty5/library/correlated_fields.py
+
4
−
3
View file @
157d13f5
...
...
@@ -171,13 +171,14 @@ def MultiCorrelatedField(target, amplitudes, gs_mean, gs_var, name='xi'):
# Normalize amplitudes and apply spreader stack
if
amplitudes
[
i
]
is
not
None
:
# Dimension with correlation structure
normed_amplitude
=
OperatorNormalizer
(
amplitudes
[
i
])
normed_amplitude
=
OperatorNormalizer
(
amplitudes
[
i
]
,
p
=
2
)
a_i
.
append
(
spr
@
normed_amplitude
)
else
:
# No correlation structure in this dimension
# -> constant amplitude
# still got to normalize, though.
amplitude_integral
=
Field
.
full
(
spr
.
domain
,
1.
).
integrate
()
# Still got to normalize, tough:
# Since the field contains only ones, 2-norm = sqrt(1-norm)
amplitude_integral
=
Field
.
full
(
spr
.
domain
,
1.
).
integrate
().
sqrt
()
fct
/=
amplitude_integral
fct
=
ScalingOperator
(
fct
,
pd
.
domain
)
...
...
This diff is collapsed.
Click to expand it.
nifty5/operators/operator_normalizer.py
+
7
−
5
View file @
157d13f5
...
...
@@ -19,25 +19,27 @@ from ..field import Field
from
.simple_linear_operators
import
VdotOperator
,
WeightApplier
def
OperatorNormalizer
(
op
):
def
OperatorNormalizer
(
op
,
p
=
1
):
"""
Wraps `op` into a shell that ensures the fields returned by
(shell @ op) will have a
n integral
of one.
(shell @ op) will have a
p-norm
of one.
Implements an operator analogously to
OperatorNormalizer(op) = op / op
.integrate()
OperatorNormalizer(op) = op /
|
op
|_p
where the integration is implemented as an operator chain.
Parameters
----------
op : Operator
p : int
Which p-norm to normalize under
"""
ones_field
=
Field
.
full
(
op
.
target
,
1.
)
vdot
=
VdotOperator
(
ones_field
)
wa
=
WeightApplier
(
op
.
target
,
spaces
=
None
,
power
=
1
)
# integrate as an operator
op_integrated
=
vdot
.
adjoint
@
vdot
@
wa
@
op
op_integrated
_inv
=
vdot
.
adjoint
@
(
vdot
@
wa
@
(
op
)
**
p
)
**
(
-
1
/
p
)
return
op
*
op_integrated
**
(
-
1
)
return
op
*
op_integrated
_inv
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