1
0
mirror of https://github.com/QData/TextAttack.git synced 2021-10-13 00:05:06 +03:00

remove pyyaml as a dependency

This commit is contained in:
Jack Morris
2020-06-23 23:13:02 -04:00
parent a10b228849
commit 4db4999186
3 changed files with 4 additions and 6 deletions

View File

@@ -6,7 +6,6 @@ nlp
nltk nltk
numpy numpy
pandas pandas
pyyaml>=5.1
scikit-learn scikit-learn
scipy==1.4.1 scipy==1.4.1
sentence_transformers sentence_transformers

View File

@@ -12,8 +12,6 @@ class AttackLogManager:
def __init__(self): def __init__(self):
self.loggers = [] self.loggers = []
self.results = [] self.results = []
self.max_words_changed = 0
self.max_seq_len = 2 ** 16
def enable_stdout(self): def enable_stdout(self):
self.loggers.append(FileLogger(stdout=True)) self.loggers.append(FileLogger(stdout=True))
@@ -71,7 +69,9 @@ class AttackLogManager:
# Count things about attacks. # Count things about attacks.
all_num_words = np.zeros(len(self.results)) all_num_words = np.zeros(len(self.results))
perturbed_word_percentages = np.zeros(len(self.results)) perturbed_word_percentages = np.zeros(len(self.results))
num_words_changed_until_success = np.zeros(2**16) # @ TODO: be smarter about this num_words_changed_until_success = np.zeros(
2 ** 16
) # @ TODO: be smarter about this
failed_attacks = 0 failed_attacks = 0
skipped_attacks = 0 skipped_attacks = 0
successful_attacks = 0 successful_attacks = 0
@@ -156,7 +156,7 @@ class AttackLogManager:
summary_table_rows, "Attack Results", "attack_results_summary" summary_table_rows, "Attack Results", "attack_results_summary"
) )
# Show histogram of words changed. # Show histogram of words changed.
numbins = max(self.max_words_changed, 10) numbins = max(max_words_changed, 10)
for logger in self.loggers: for logger in self.loggers:
logger.log_hist( logger.log_hist(
num_words_changed_until_success[:numbins], num_words_changed_until_success[:numbins],

View File

@@ -10,7 +10,6 @@ import filelock
import requests import requests
import torch import torch
import tqdm import tqdm
import yaml
def path_in_cache(file_path): def path_in_cache(file_path):