Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tutorial_nifty_resolve
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
tutorial_nifty_resolve
Commits
3eab47f7
Commit
3eab47f7
authored
2 years ago
by
Philipp Frank
Browse files
Options
Downloads
Patches
Plain Diff
typos
parent
ae950a6e
No related branches found
No related tags found
1 merge request
!8
Add a nifty jacobian demo
Pipeline
#150165
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
demo_linearization.py
+7
-7
7 additions, 7 deletions
demo_linearization.py
with
7 additions
and
7 deletions
demo_linearization.py
+
7
−
7
View file @
3eab47f7
...
...
@@ -89,7 +89,7 @@ class _MyCustomJacobian(ift.LinearOperator):
# non-linear functions), when facing Fields or Lineariations have already been
# implemented in nifty. Therefore in many cases one can "do calculations" with
# Linearizations analogous to Fields and the Jacobians get constructed from the
# Jacobians of the pr
o
mitive operations automatically, using the chain rule:
# Jacobians of the pr
i
mitive operations automatically, using the chain rule:
# Define Operator
class
MyCustomLinModel
(
ift
.
Operator
):
...
...
@@ -115,7 +115,7 @@ class MyCustomLinModel(ift.Operator):
# 2) The Operator level (a bit less general, most fail safe)
# Similarly to Fields and Linear
o
zations, also the basic operations are
# Similarly to Fields and Linear
i
zations, also the basic operations are
# implemented for Operators. Given for example two operators op1, op2 we can
# multiply them together to create a new op3 = op1 * op2. The logic here is:
# "take the outputs (results) of op1 and op2 and multiply them together". The
...
...
@@ -124,7 +124,7 @@ class MyCustomLinModel(ift.Operator):
# share the same target space, pointwise multiplication is possible (no
# automatic broadcasting!). Nifty, however, provides many broadcasting
# operations the user can invoke to help build more general combinations (see
# e.g. `ContractionOperator`)
# e.g. `ContractionOperator`)
.
# a placeholder operator that takes 'x' from the input and passes it along.
x
=
ift
.
FieldAdapter
(
scalar_domain
,
'
x
'
)
...
...
@@ -133,12 +133,12 @@ y = ift.FieldAdapter(scalar_domain, 'y')
# First part of the model. Note that here 'calculations' are performed on
# operators to create a new operator (i.E. no inputs are provided yet).
model
=
ift
.
exp
(
x
)
*
y
# As "+" is already reserved for adding the output of two operators together
# As "+" is already reserved for adding the output of two operators together
,
# simple scalar addition has to be performed via a designated operator 'Adder'.
# Also, on operator level, the combination of operations has to be performed on
#
the sam
e space so the number '3' is cast into a Field on
the
'scalar_domain`
# to add it to the output of model. Finally sequential operator application is
# given via the matrix multiplication `@`.
#
compatibl
e space
s
so the number '3' is cast into a Field on 'scalar_domain`
# to add it to the output of
`
model
``
. Finally sequential operator application is
# given via the matrix multiplication
operation
`@`.
MyCustomModel
=
ift
.
Adder
(
ift
.
full
(
scalar_domain
,
3.
))
@
model
...
...
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