Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KerasROOTClassification
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
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
Eric.Schanet
KerasROOTClassification
Commits
96759ea3
Commit
96759ea3
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
fixing range in plot_NN_2D
parent
b8d18de9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/plot_NN_2D.py
+6
-9
6 additions, 9 deletions
scripts/plot_NN_2D.py
utils.py
+12
-0
12 additions, 0 deletions
utils.py
with
18 additions
and
9 deletions
scripts/plot_NN_2D.py
+
6
−
9
View file @
96759ea3
...
@@ -20,7 +20,12 @@ from KerasROOTClassification.plotting import (
...
@@ -20,7 +20,12 @@ from KerasROOTClassification.plotting import (
plot_cond_avg_actmax_2D
,
plot_cond_avg_actmax_2D
,
plot_NN_vs_var_2D_all
,
plot_NN_vs_var_2D_all
,
)
)
from
KerasROOTClassification.utils
import
get_single_neuron_function
,
get_max_activation_events
,
weighted_quantile
from
KerasROOTClassification.utils
import
(
get_single_neuron_function
,
get_max_activation_events
,
weighted_quantile
,
get_ranges
)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Create various 2D plots for a single neuron
'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Create various 2D plots for a single neuron
'
)
parser
.
add_argument
(
"
project_dir
"
)
parser
.
add_argument
(
"
project_dir
"
)
...
@@ -89,14 +94,6 @@ except NameError:
...
@@ -89,14 +94,6 @@ except NameError:
# percentilesx = weighted_quantile(varx_test[x_not_masked], [0.01, 0.99], sample_weight=total_weights[x_not_masked])
# percentilesx = weighted_quantile(varx_test[x_not_masked], [0.01, 0.99], sample_weight=total_weights[x_not_masked])
# percentilesy = weighted_quantile(vary_test[y_not_masked], [0.01, 0.99], sample_weight=total_weights[y_not_masked])
# percentilesy = weighted_quantile(vary_test[y_not_masked], [0.01, 0.99], sample_weight=total_weights[y_not_masked])
def
get_ranges
(
x
,
quantiles
,
weights
,
mask_value
=
None
,
filter_index
=
None
):
ranges
=
[]
for
var_index
in
range
(
x
.
shape
[
1
]):
x_var
=
x
[:,
var_index
]
not_masked
=
np
.
where
(
x_var
!=
mask_value
)[
0
]
ranges
.
append
(
weighted_quantile
(
x_var
[
not_masked
],
quantiles
,
sample_weight
=
weights
[
not_masked
]))
return
ranges
percentilesx
=
get_ranges
(
c
.
x_test
,
[
0.01
,
0.99
],
total_weights
,
mask_value
=
mask_value
,
filter_index
=
varx_index
)[
0
]
percentilesx
=
get_ranges
(
c
.
x_test
,
[
0.01
,
0.99
],
total_weights
,
mask_value
=
mask_value
,
filter_index
=
varx_index
)[
0
]
percentilesy
=
get_ranges
(
c
.
x_test
,
[
0.01
,
0.99
],
total_weights
,
mask_value
=
mask_value
,
filter_index
=
vary_index
)[
0
]
percentilesy
=
get_ranges
(
c
.
x_test
,
[
0.01
,
0.99
],
total_weights
,
mask_value
=
mask_value
,
filter_index
=
vary_index
)[
0
]
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
12
−
0
View file @
96759ea3
...
@@ -39,6 +39,18 @@ def create_random_event(ranges):
...
@@ -39,6 +39,18 @@ def create_random_event(ranges):
return
random_event
return
random_event
def
get_ranges
(
x
,
quantiles
,
weights
,
mask_value
=
None
,
filter_index
=
None
):
"
Get ranges for plotting or random event generation based on quantiles
"
ranges
=
[]
for
var_index
in
range
(
x
.
shape
[
1
]):
if
(
filter_index
is
not
None
)
and
(
var_index
!=
filter_index
):
continue
x_var
=
x
[:,
var_index
]
not_masked
=
np
.
where
(
x_var
!=
mask_value
)[
0
]
ranges
.
append
(
weighted_quantile
(
x_var
[
not_masked
],
quantiles
,
sample_weight
=
weights
[
not_masked
]))
return
ranges
def
max_activation_wrt_input
(
gradient_function
,
random_event
,
threshold
=
None
,
maxthreshold
=
None
,
maxit
=
100
,
step
=
1
,
const_indices
=
[],
def
max_activation_wrt_input
(
gradient_function
,
random_event
,
threshold
=
None
,
maxthreshold
=
None
,
maxit
=
100
,
step
=
1
,
const_indices
=
[],
input_transform
=
None
,
input_inverse_transform
=
None
):
input_transform
=
None
,
input_inverse_transform
=
None
):
if
input_transform
is
not
None
:
if
input_transform
is
not
None
:
...
...
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