textattack.loggers package

Misc Loggers: Loggers track, visualize, and export attack results.

Managing Attack Logs.

class textattack.loggers.attack_log_manager.AttackLogManager(metrics: Dict | None)[source]

Bases: object

Logs the results of an attack to all attached loggers.

add_output_csv(filename, color_method)[source]
add_output_file(filename, color_method)[source]
add_output_summary_json(filename)[source]
disable_color()[source]
enable_stdout()[source]
enable_visdom()[source]
enable_wandb(**kwargs)[source]
flush()[source]
log_attack_details(attack_name, model_name)[source]
log_result(result)[source]

Logs an AttackResult on each of self.loggers.

log_results(results)[source]

Logs an iterable of AttackResult objects on each of self.loggers.

log_sep()[source]
log_summary()[source]
log_summary_rows(rows, title, window_id)[source]
metrics: Dict

Attack Logs to CSV

class textattack.loggers.csv_logger.CSVLogger(filename='results.csv', color_method='file')[source]

Bases: Logger

Logs attack results to a CSV.

close()[source]
flush()[source]
log_attack_result(result)[source]

Attack Logs to file

class textattack.loggers.file_logger.FileLogger(filename='', stdout=False, color_method='ansi')[source]

Bases: Logger

Logs the results of an attack to a file, or stdout.

close()[source]
flush()[source]
log_attack_result(result)[source]
log_sep()[source]
log_summary_rows(rows, title, window_id)[source]

Attack Logger Wrapper

class textattack.loggers.logger.Logger[source]

Bases: ABC

An abstract class for different methods of logging attack results.

close()[source]
flush()[source]
log_attack_result(result, examples_completed=None)[source]
log_hist(arr, numbins, title, window_id)[source]
log_sep()[source]
log_summary_rows(rows, title, window_id)[source]

Attack Logs to Visdom

class textattack.loggers.visdom_logger.VisdomLogger(env='main', port=8097, hostname='localhost')[source]

Bases: Logger

Logs attack results to Visdom.

bar(X_data, numbins=10, title=None, window_id=None)[source]
flush()[source]
hist(X_data, numbins=10, title=None, window_id=None)[source]
log_attack_result(result)[source]
log_hist(arr, numbins, title, window_id)[source]
log_summary_rows(rows, title, window_id)[source]
table(rows, window_id=None, title=None, header=None, style=None)[source]

Generates an HTML table.

text(text_data, title=None, window_id='default')[source]
textattack.loggers.visdom_logger.port_is_open(port_num, hostname='127.0.0.1')[source]

Attack Logs to WandB

class textattack.loggers.weights_and_biases_logger.WeightsAndBiasesLogger(**kwargs)[source]

Bases: Logger

Logs attack results to Weights & Biases.

log_attack_result(result)[source]
log_sep()[source]
log_summary_rows(rows, title, window_id)[source]