cleverhans - clip_min, clip_max when they vary by channels

89 Views Asked by At

cleverhans has clip_min and clip_max to make sure that the perturbed data is still within the valid range. This works fine, e.g. if I'm working with an image where the range of values in the matrix is 0-255 or 0-1. However, when the range differs on different dimensions, a single value is not enough to constrain the image to be valid. For example, in most ImageNet models, the images are preprocessed by subtracting the mean and dividing by the standard deviation per channel, hence making a single value clip not ideal. Is there a smart workaround to this problem?

1

There are 1 best solutions below

0
On

I have the same question as you.

After investigation I found that, for Vgg and Resnet wihch channels go through different transformations, some one set clip_min and clip_max the same for different channels: clip_min=min(channel1_min,channel2_min,channel3_min), channel1_min means the theoretical minimum value in channel1, after anti-normalization(multiply std, add mean), the image will be clipped by [0,1].

I think this is a feasible approach.

By the way, I encountered some problems, please take a look. The use of method which needs sess param in Cleverhans Library