Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
AnalysisTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
Felix Metzner
AnalysisTools
Commits
d4f38e7c
Commit
d4f38e7c
authored
4 years ago
by
Felix Metzner
Browse files
Options
Downloads
Patches
Plain Diff
Working on rbf memory issue.
parent
ba0aae0b
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#1246
failed
4 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
analysistools/reweighting/rbf_reweighter.py
+20
-2
20 additions, 2 deletions
analysistools/reweighting/rbf_reweighter.py
with
20 additions
and
2 deletions
analysistools/reweighting/rbf_reweighter.py
+
20
−
2
View file @
d4f38e7c
...
...
@@ -96,7 +96,20 @@ class RbfReweighter:
# and
# https://numpy.org/doc/stable/reference/generated/numpy.hsplit.html
weights
=
self
.
_rbf
(
*
[
origin_sample
[
variable
].
values
for
variable
in
self
.
_variables
])
weights
=
np
.
zeros
(
shape
=
len
(
origin_sample
.
index
),
dtype
=
np
.
float64
)
for
arrays
in
np
.
nditer
(
[
weights
]
+
[
origin_sample
[
v
].
values
for
v
in
self
.
_variables
],
flags
=
[
'
external_loop
'
,
'
buffered
'
],
op_flags
=
[
'
readwrite
'
]
):
assert
len
(
arrays
)
==
1
+
len
(
self
.
_variables
),
(
len
(
arrays
),
len
(
self
.
_variables
))
i_weights
=
arrays
[
0
]
assert
all
(
isinstance
(
a
,
np
.
ndarray
)
for
a
in
arrays
),
[
type
(
a
)
for
a
in
arrays
]
assert
all
(
a
.
shape
==
i_weights
.
shape
for
a
in
arrays
),
[
a
.
shape
for
a
in
arrays
]
i_weights
=
self
.
_rbf
(
*
arrays
[
1
:])
assert
len
(
i_weights
.
shape
)
==
1
,
i_weights
.
shape
# weights = self._rbf(*[origin_sample[variable].values for variable in self._variables])
weights
[
weights
<
0
]
=
0.0
num_origin_events
=
len
(
origin_sample
.
index
)
summed_weights
=
np
.
sum
(
weights
)
...
...
@@ -108,11 +121,16 @@ class RbfReweighter:
logging
.
debug
(
f
"
Scale factor:
{
self
.
_scale_factor
}
"
)
@staticmethod
def
euclidean_norm_numpy
(
x1
,
x2
):
return
np
.
linalg
.
norm
(
x1
-
x2
,
axis
=
0
)
def
_create_rbf
(
self
):
self
.
_rbf
=
Rbf
(
*
[
self
.
_weight_coords
[:,
i
]
for
i
in
range
(
len
(
self
.
_variables
))],
self
.
_hist_weights
,
function
=
"
cubic
"
function
=
"
cubic
"
,
norm
=
RbfReweighter
.
euclidean_norm_numpy
)
def
export_to_json
(
self
,
output_path
:
Union
[
AnyStr
,
os
.
PathLike
]):
...
...
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