Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Text Attacks
Manage
Activity
Members
Plan
Wiki
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adversarial Attacks
Text Attacks
Commits
c02d743f
There was an error fetching the commit references. Please try again later.
Commit
c02d743f
authored
2 years ago
by
Paweł Walkowiak
Browse files
Options
Downloads
Patches
Plain Diff
explain ag_news
parent
db943861
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
data/explanations/.gitignore
+1
-0
1 addition, 0 deletions
data/explanations/.gitignore
dvc.lock
+28
-8
28 additions, 8 deletions
dvc.lock
experiments/scripts/explain.py
+2
-0
2 additions, 0 deletions
experiments/scripts/explain.py
with
31 additions
and
8 deletions
data/explanations/.gitignore
+
1
−
0
View file @
c02d743f
...
...
@@ -2,3 +2,4 @@
/wiki_pl
/20_news
/poleval
/ag_news
This diff is collapsed.
Click to expand it.
dvc.lock
+
28
−
8
View file @
c02d743f
...
...
@@ -940,16 +940,16 @@ stages:
cmd: PYTHONPATH=. python experiments/scripts/tag_dataset.py --dataset_name ag_news
deps:
- path: data/datasets/ag_news/
md5:
c67ae5399a7bbbe3e25d3864b43c7b54
.dir
size: 3
394601
1
md5:
98d7192236c2f868e52f772e9a3aa01b
.dir
size: 3
402003
1
nfiles: 3
- path: experiments/scripts/tag_dataset.py
md5: 19015179757440a5639ee263dcabfde3
size: 5010
outs:
- path: data/preprocessed/ag_news/
md5:
f87f6ac5c43e28205abec35a3f18f0e7
.dir
size: 499
2481
9
md5:
225096ec90dfb5085b6a8e3835681155
.dir
size: 499
9883
9
nfiles: 3
reduce@ag_news:
cmd: PYTHONPATH=. python experiments/scripts/token_reduce.py --dataset_name ag_news
...
...
@@ -960,16 +960,16 @@ stages:
size: 438958577
nfiles: 6
- path: data/preprocessed/ag_news/
md5:
f87f6ac5c43e28205abec35a3f18f0e7
.dir
size: 499
2481
9
md5:
225096ec90dfb5085b6a8e3835681155
.dir
size: 499
9883
9
nfiles: 3
- path: experiments/scripts/token_reduce.py
md5: 091c622fce2349978e61b8f6e4d22f27
size: 4945
outs:
- path: data/reduced/ag_news
md5:
5ab65584e3b005a19cb527fd69dfaf2c
.dir
size: 11
64833
2
md5:
adac9c05622da5a0895de488a2dc80fa
.dir
size: 11
71562
2
nfiles: 1
classify@ag_news:
cmd: PYTHONPATH=. python experiments/scripts/classify.py --dataset_name ag_news
...
...
@@ -991,3 +991,23 @@ stages:
md5: d9cabd3c3554172bf43b296079eec947.dir
size: 11806224
nfiles: 2
explain@ag_news:
cmd: PYTHONPATH=. python experiments/scripts/explain.py --dataset_name ag_news
--output_dir data/explanations/ag_news
deps:
- path: data/models/ag_news
md5: af9183a3115fd5f07ec2ba8e9086200b.dir
size: 438958577
nfiles: 6
- path: data/preprocessed/ag_news
md5: 225096ec90dfb5085b6a8e3835681155.dir
size: 49998839
nfiles: 3
- path: experiments/scripts/explain.py
md5: 2c1eca09f7cbdc5d93278b2cd27b126c
size: 4717
outs:
- path: data/explanations/ag_news/
md5: ae37f6468f0b44e40cf421e2544d2646.dir
size: 54861964
nfiles: 30405
This diff is collapsed.
Click to expand it.
experiments/scripts/explain.py
+
2
−
0
View file @
c02d743f
...
...
@@ -103,12 +103,14 @@ def main(
os
.
makedirs
(
output_dir
/
"
global
"
,
exist_ok
=
True
)
for
class_id
,
class_name
in
model
.
config
.
id2label
.
items
():
importance_df
=
get_importance
(
shap_values
[:,
:,
class_id
].
mean
(
0
))
class_name
=
class_name
.
replace
(
"
/
"
,
"
_
"
)
importance_df
.
to_json
(
output_dir
/
"
global
"
/
f
"
{
class_name
}
__importance.json
"
,
)
# LOCAL IMPORTANCE
for
class_id
,
class_name
in
model
.
config
.
id2label
.
items
():
class_name
=
class_name
.
replace
(
"
/
"
,
"
_
"
)
sub_dir
=
output_dir
/
"
local
"
/
"
adversarial
"
/
class_name
os
.
makedirs
(
sub_dir
,
exist_ok
=
True
)
for
shap_id
,
text_id
in
enumerate
(
test
[
"
id
"
]):
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment