art.summary_writer

This module defines and implements the summary writers for TensorBoard output.

Base Class SummaryWriter

class art.summary_writer.SummaryWriter(summary_writer: str | bool)

This abstract base class defines the API for summary writers.

reset()

Flush and reset the summary writer.

property summary_writer

Return the TensorBoardX summary writer instance.

abstract update(batch_id, global_step, grad=None, patch=None, estimator=None, x=None, y=None, targeted=False, **kwargs)

Update the summary writer.

Parameters:
  • batch_id – Id of the current mini-batch.

  • global_step – Global iteration step.

  • grad – Loss gradients.

  • patch – Adversarial patch.

  • estimator – The estimator to evaluate or calculate gradients of grad is None to obtain new metrics.

  • x – Input data.

  • y – True or target labels.

  • targeted (bool) – Indicates whether the attack is targeted (True) or untargeted (False).

Summary Writer Default

class art.summary_writer.SummaryWriterDefault(summary_writer: str | bool, ind_1: bool = False, ind_2: bool = False, ind_3: bool = False, ind_4: bool = False)

Implementation of the default ART Summary Writer.

__init__(summary_writer: str | bool, ind_1: bool = False, ind_2: bool = False, ind_3: bool = False, ind_4: bool = False)

Create summary writer.

Parameters:

summary_writer – Activate summary writer for TensorBoard. Default is False and deactivated summary writer. If True save runs/CURRENT_DATETIME_HOSTNAME in current directory. If of type str save in path. Use hierarchical folder structure to compare between runs easily. e.g. pass in ‘runs/exp1’, ‘runs/exp2’, etc. for each new experiment to compare across them.

update(batch_id: int, global_step: int, grad: ndarray | None = None, patch: ndarray | None = None, estimator=None, x: ndarray | None = None, y: ndarray | None = None, targeted: bool = False, **kwargs)

Update the summary writer.

Parameters:
  • batch_id (int) – Id of the current mini-batch.

  • global_step (int) – Global iteration step.

  • grad – Loss gradients.

  • patch – Adversarial patch.

  • estimator – The estimator to evaluate or calculate gradients of grad is None to obtain new metrics.

  • x – Input data.

  • y – True or target labels.

  • targeted (bool) – Indicates whether the attack is targeted (True) or untargeted (False).