Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
a3185498
Commit
a3185498
authored
Mar 01, 2021
by
Jakob Knollmüller
Browse files
debug
parent
317ba8d0
Pipeline
#94605
failed with stages
in 5 minutes and 24 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/meanfield_demo.py
View file @
a3185498
...
@@ -58,24 +58,10 @@ def main():
...
@@ -58,24 +58,10 @@ def main():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# Choose space on which the signal field is defined
if
len
(
sys
.
argv
)
==
2
:
# Two-dimensional regular grid with inhomogeneous exposure
mode
=
int
(
sys
.
argv
[
1
])
position_space
=
ift
.
RGSpace
([
10
,
10
])
else
:
exposure
=
exposure_2d
(
position_space
)
mode
=
1
if
mode
==
0
:
# One-dimensional regular grid with uniform exposure of 10
position_space
=
ift
.
RGSpace
(
1024
)
exposure
=
ift
.
Field
.
full
(
position_space
,
10.
)
elif
mode
==
1
:
# Two-dimensional regular grid with inhomogeneous exposure
position_space
=
ift
.
RGSpace
([
512
,
512
])
exposure
=
exposure_2d
(
position_space
)
else
:
# Sphere with uniform exposure of 100
position_space
=
ift
.
HPSpace
(
128
)
exposure
=
ift
.
Field
.
full
(
position_space
,
100.
)
# Define harmonic space and harmonic transform
# Define harmonic space and harmonic transform
harmonic_space
=
position_space
.
get_default_codomain
()
harmonic_space
=
position_space
.
get_default_codomain
()
...
@@ -120,10 +106,11 @@ if __name__ == '__main__':
...
@@ -120,10 +106,11 @@ if __name__ == '__main__':
H
=
ift
.
StandardHamiltonian
(
likelihood
)
H
=
ift
.
StandardHamiltonian
(
likelihood
)
initial_position
=
ift
.
from_random
(
domain
,
'normal'
)
initial_position
=
ift
.
from_random
(
domain
,
'normal'
)
meanfield_model
=
ift
.
MeanfieldModel
(
H
.
domain
)
# meanfield_model = ift.MeanfieldModel(H.domain)
initial_position
=
meanfield_model
.
get_initial_pos
()
fullcov_model
=
ift
.
FullCovarianceModel
(
H
.
domain
)
initial_position
=
fullcov_model
.
get_initial_pos
()
position
=
initial_position
position
=
initial_position
KL
=
ift
.
ParametricGaussianKL
.
make
(
initial_position
,
H
,
meanfield
_model
,
3
,
False
)
KL
=
ift
.
ParametricGaussianKL
.
make
(
initial_position
,
H
,
fullcov
_model
,
3
,
False
)
plt
.
figure
(
'data'
)
plt
.
figure
(
'data'
)
plt
.
imshow
(
sky
(
mock_position
).
val
)
plt
.
imshow
(
sky
(
mock_position
).
val
)
plt
.
pause
(
0.001
)
plt
.
pause
(
0.001
)
...
@@ -133,5 +120,5 @@ if __name__ == '__main__':
...
@@ -133,5 +120,5 @@ if __name__ == '__main__':
position
=
KL
.
position
position
=
KL
.
position
plt
.
figure
(
'result'
)
plt
.
figure
(
'result'
)
plt
.
cla
()
plt
.
cla
()
plt
.
imshow
(
sky
(
meanfield
_model
.
generator
(
KL
.
position
)).
val
)
plt
.
imshow
(
sky
(
fullcov
_model
.
generator
(
KL
.
position
)).
val
)
plt
.
pause
(
0.001
)
plt
.
pause
(
0.001
)
\ No newline at end of file
src/library/variational_models.py
View file @
a3185498
...
@@ -55,7 +55,7 @@ class FullCovarianceModel():
...
@@ -55,7 +55,7 @@ class FullCovarianceModel():
co_part
=
PartialExtractor
(
matmul_setup_dom
,
co
.
domain
)
co_part
=
PartialExtractor
(
matmul_setup_dom
,
co
.
domain
)
lat_part
=
PartialExtractor
(
matmul_setup_dom
,
lat
.
domain
)
lat_part
=
PartialExtractor
(
matmul_setup_dom
,
lat
.
domain
)
matmul_setup
=
lat_part
.
adjoint
@
lat
.
adjoint
@
lat
+
co_part
.
adjoint
@
co
.
adjoint
@
cov
matmul_setup
=
lat_part
.
adjoint
@
lat
.
adjoint
@
lat
+
co_part
.
adjoint
@
co
.
adjoint
@
cov
breakpoint
()
MatMult
=
MultiLinearEinsum
(
matmul_setup
.
domain
,
'ij,ki->jk'
,
key_order
=
(
'co'
,
'latent'
))
MatMult
=
MultiLinearEinsum
(
matmul_setup
.
domain
,
'ij,ki->jk'
,
key_order
=
(
'co'
,
'latent'
))
Resp
=
Respacer
(
MatMult
.
target
,
mean
.
target
)
Resp
=
Respacer
(
MatMult
.
target
,
mean
.
target
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment