Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
e288f5be
Commit
e288f5be
authored
Jul 28, 2018
by
Martin Reinecke
Browse files
cosmetics
parent
9ebbecf5
Changes
5
Hide whitespace changes
Inline
Side-by-side
nifty5/data_objects/distributed_do.py
View file @
e288f5be
...
...
@@ -264,7 +264,7 @@ def empty_like(a, dtype=None):
def
vdot
(
a
,
b
):
tmp
=
np
.
array
(
np
.
vdot
(
a
.
_data
,
b
.
_data
))
if
a
.
_distaxis
==-
1
:
if
a
.
_distaxis
==
-
1
:
return
tmp
[()]
res
=
np
.
empty
((),
dtype
=
tmp
.
dtype
)
_comm
.
Allreduce
(
tmp
,
res
,
MPI
.
SUM
)
...
...
nifty5/extra/energy_and_model_tests.py
View file @
e288f5be
...
...
@@ -93,8 +93,8 @@ def check_value_gradient_metric_consistency(op, loc, tol=1e-8, ntries=100):
dgrad2
=
(
lin2
.
gradient
-
lin
.
gradient
)
/
dirnorm
xtol
=
tol
*
dirder
.
norm
()
/
np
.
sqrt
(
dirder
.
size
)
if
((
abs
(
numgrad
-
dirder
)
<=
xtol
).
all
()
and
(
abs
(
dgrad
-
dgrad2
)
<=
xtol
).
all
()):
break
(
abs
(
dgrad
-
dgrad2
)
<=
xtol
).
all
()):
break
dir
=
dir
*
0.5
dirnorm
*=
0.5
loc2
=
locmid
...
...
nifty5/field.py
View file @
e288f5be
...
...
@@ -621,6 +621,7 @@ class Field(object):
def
positive_tanh
(
self
):
return
0.5
*
(
1.
+
self
.
tanh
())
for
op
in
[
"__add__"
,
"__radd__"
,
"__sub__"
,
"__rsub__"
,
"__mul__"
,
"__rmul__"
,
...
...
nifty5/library/amplitude_model.py
View file @
e288f5be
...
...
@@ -100,7 +100,7 @@ class AmplitudeModel(Operator):
im, iv : y-intercept_mean, y-intercept_variance of power_slope
'''
def
__init__
(
self
,
s_space
,
Npixdof
,
ceps_a
,
ceps_k
,
sm
,
sv
,
im
,
iv
,
keys
=
[
'tau'
,
'phi'
]):
keys
=
[
'tau'
,
'phi'
]):
from
..operators.exp_transform
import
ExpTransform
from
..operators.qht_operator
import
QHTOperator
from
..operators.slope_operator
import
SlopeOperator
...
...
@@ -119,9 +119,11 @@ class AmplitudeModel(Operator):
phi_sig
=
np
.
array
([
sv
,
iv
])
self
.
_slope
=
SlopeOperator
(
param_space
,
logk_space
,
phi_sig
)
self
.
_norm_phi_mean
=
Field
.
from_global_data
(
param_space
,
phi_mean
/
phi_sig
)
self
.
_norm_phi_mean
=
Field
.
from_global_data
(
param_space
,
phi_mean
/
phi_sig
)
self
.
_domain
=
MultiDomain
.
make
({
keys
[
0
]:
dof_space
,
keys
[
1
]:
param_space
})
self
.
_domain
=
MultiDomain
.
make
({
keys
[
0
]:
dof_space
,
keys
[
1
]:
param_space
})
kern
=
lambda
k
:
_ceps_kernel
(
dof_space
,
k
,
ceps_a
,
ceps_k
)
cepstrum
=
create_cepstrum_amplitude_field
(
dof_space
,
kern
)
...
...
nifty5/linearization.py
View file @
e288f5be
...
...
@@ -47,8 +47,9 @@ class Linearization(object):
return
Linearization
(
self
.
_val
[
name
],
FieldAdapter
(
dom
,
name
))
def
__neg__
(
self
):
return
Linearization
(
-
self
.
_val
,
self
.
_jac
*
(
-
1
),
None
if
self
.
_metric
is
None
else
self
.
_metric
*
(
-
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
):
...
...
@@ -77,8 +78,9 @@ class Linearization(object):
if
isinstance
(
other
,
Linearization
):
d1
=
makeOp
(
self
.
_val
)
d2
=
makeOp
(
other
.
_val
)
return
Linearization
(
self
.
_val
*
other
.
_val
,
RelaxedSumOperator
((
d2
*
self
.
_jac
,
d1
*
other
.
_jac
)))
return
Linearization
(
self
.
_val
*
other
.
_val
,
RelaxedSumOperator
((
d2
*
self
.
_jac
,
d1
*
other
.
_jac
)))
if
isinstance
(
other
,
(
int
,
float
,
complex
)):
# if other == 0:
# return ...
...
...
@@ -100,8 +102,8 @@ class Linearization(object):
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
)
return
Linearization
(
full
((),
self
.
_val
.
sum
()),
VdotOperator
(
full
(
self
.
_jac
.
target
,
1
))
*
self
.
_jac
)
def
exp
(
self
):
tmp
=
self
.
_val
.
exp
()
...
...
@@ -132,4 +134,3 @@ class Linearization(object):
def
make_const
(
field
):
from
.operators.null_operator
import
NullOperator
return
Linearization
(
field
,
NullOperator
({},
field
.
domain
))
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment