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
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adversarial Attacks
Text Attacks
Commits
e1b2bef3
Commit
e1b2bef3
authored
Aug 17, 2023
by
Paweł Walkowiak
Browse files
Options
Downloads
Patches
Plain Diff
Add zero div check
parent
571078ef
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
experiments/scripts/attack.py
+6
-6
6 additions, 6 deletions
experiments/scripts/attack.py
with
6 additions
and
6 deletions
experiments/scripts/attack.py
+
6
−
6
View file @
e1b2bef3
...
...
@@ -157,8 +157,8 @@ def data_saver(queue_in, queue_log, queue_recurse, output_file,
"
attacks_succeeded
"
:
ch_suc
,
"
attacks_all
"
:
ch_all
,
"
synonyms_nbr
"
:
synonyms_nbr
,
"
success_rate
"
:
ch_suc
/
ch_all
,
"
success_rate_per_synonym
"
:
ch_suc
/
synonyms_nbr
,
"
success_rate
"
:
ch_suc
/
ch_all
if
ch_all
>
0
else
0
,
"
success_rate_per_synonym
"
:
ch_suc
/
synonyms_nbr
if
synonyms_nbr
>
0
else
0
,
"
time
"
:
time
()
-
start
,
"
samples
"
:
samples
,
"
samples_succ
"
:
samples_succ
,
...
...
@@ -176,8 +176,8 @@ def data_saver(queue_in, queue_log, queue_recurse, output_file,
"
attacks_succeeded
"
:
ch_suc
,
"
attacks_all
"
:
ch_all
,
"
synonyms_nbr
"
:
synonyms_nbr
,
"
success_rate
"
:
ch_suc
/
ch_all
,
"
success_rate_per_synonym
"
:
ch_suc
/
synonyms_nbr
,
"
success_rate
"
:
ch_suc
/
ch_all
if
ch_all
>
0
else
0
,
"
success_rate_per_synonym
"
:
ch_suc
/
synonyms_nbr
if
synonyms_nbr
>
0
else
0
,
"
time
"
:
time
()
-
start
,
"
samples
"
:
samples
,
"
samples_succ
"
:
samples_succ
,
...
...
@@ -191,7 +191,7 @@ def data_saver(queue_in, queue_log, queue_recurse, output_file,
except
Exception
as
e
:
queue_log
.
put
(
f
"
Error in data saver:
{
e
}
"
)
with
open
(
log_file
,
"
a
"
)
as
f
:
f
.
write
(
"
Saver failed with {e}
\n
"
)
f
.
write
(
f
"
Saver failed with
{
e
}
\n
"
)
queue_in
.
put
(
None
)
...
...
@@ -336,7 +336,7 @@ def main(dataset_name: str, attack_type: str):
output_path
=
os
.
path
.
join
(
output_dir
,
"
test.jsonl
"
)
dataset_df
=
pd
.
read_json
(
input_file
,
lines
=
True
)
log_file
=
f
"
{
attack_type
}
_
{
dataset_name
}
_
{
datetime
.
now
().
strftime
(
'
%Y-%m-%d_%H-%M
'
)
}
.log
"
log_file
=
f
"
logs/
{
attack_type
}
_
{
dataset_name
}
_
{
datetime
.
now
().
strftime
(
'
%Y-%m-%d_%H-%M
'
)
}
.log
"
m
=
Manager
()
queues
=
[
m
.
Queue
(
maxsize
=
QUEUE_SIZE
)
for
_
in
range
(
4
)]
...
...
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