Adversary

class olympus.metrics.adversary.ClassifierAdversary(frequency_new_epoch: int = 0, frequency_new_batch: int = 0, frequency_new_trial: int = 0, priority: int = 0, epsilon: float = 0.25, accuracies: list = <factory>, losses: list = <factory>, distortions: list = <factory>, loader: torch.utils.data.dataloader.DataLoader = None) → None[source]

Bases: olympus.observers.observer.Observer

Simple Adversary Generator from arxiv Measure how robust a network is from adversary attacks

\[adversary(image) = image + epsilon * sign(grad(cost(theta, image, t), image)\]

An adversary takes as input an image and returns a modified image that will try to induce an error on the classifier.

References

[1]Ian J. Goodfellow, Jonathon Shlens, Christian Szegedy. “Explaining and Harnessing Adversarial Examples”, 20 Dec 2014
Attributes:
epislon: float = 0.25 (for mnist) 0.07 (for ImageNet)

Epsilon corresponds to the magnitude of the smallest bit of an image encoding converted to real number

Methods

every(*args[, epoch, batch]) Define how often this metric should be called
load_state_dict(state_dict) Load a state dictionary to resume a previous training
on_end_train(task[, step]) Called at the end of training after the last epoch
on_new_batch(task, step[, input, context]) Called after a batch has been processed
on_new_epoch(task, epoch, context) Called at the end of an epoch, before a new epoch starts
on_new_trial(task, step, parameters, uid) Called after a trial has been processed
on_start_train(task[, step]) Called on ce the training starts
state_dict() Return a state dictionary used to checkpointing and resuming
value() Return the key values that metrics computes
adversarial  
on_end_batch  
on_end_epoch  
accumulator = 0
adversarial(task, batch, target)[source]
count = 0
distortion = 0
epsilon = 0.25
load_state_dict(state_dict)[source]

Load a state dictionary to resume a previous training

loader = None
loss = 0
on_end_batch(task, step, input, context)[source]
on_end_epoch(task, epoch, context)[source]
on_end_train(task, step=None)[source]

Called at the end of training after the last epoch

state_dict()[source]

Return a state dictionary used to checkpointing and resuming

time = <olympus.utils.stat.StatStream object>
value()[source]

Return the key values that metrics computes