bethgelab / bethgelab/foolbox

Is there a way to change/override the expected loss function of Foolbox's 'attack' function?

Open
#689 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
3k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

Hi,
I am currently trying to generate adversarial images of a CIFAR10 dataset that can fool a CNN in a simple color estimation task.

As a little background for this color estimation task, I created a CNN to estimate the average global color of an image as a 3d column vector in terms of [average red channel, average blue channel, average green channel]. To train this CNN, I used a relabeled CIFAR10 dataset (where each label is no longer a number denoting it's class but a 3d vector of the average color) and MSE as my loss function.

But now, when I tried to use foolbox's _attack_ function
`raw_advs, clipped_advs, success = attack(fmodel, images, labels, epsilons=epsilons)`
to create an adversarial image, I ran into this error:

![Screen Shot 2022-05-30 at 7 31 55 PM](https://user-images.githubusercontent.com/82011021/172483365-f41340c5-b0c9-4940-bc27-05d7d18e4434.png)

From this error trace, it seems that the _attack_ function is automatically geared toward object recognition models that use cross entropy loss and output a 1d label.

So my question is: **is there any way to modify the _attack_ function's expected loss function to be Mean Square Error instead of Cross Entropy? Or perhaps I should not use the built-in _attack_ function, and instead generate the adversarial images manually?**
Thank you for any thoughts or tips.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.