We are exploring the images classified by a CNN at its decision boundary, using Genetic Algorithms to generate them. We have created a fine-tuned binary grayscale image classifier for cats. As the base model, we are using an Inception-ResNet v2 pre-trained on the ImageNet dataset, and then fine-tune it with a subset of cat and non-cat images (grayscale) from ImageNet. The model achieves ~97% accuracy for a test set.
We have constrained the problem such that evolution starts from a pure white image, and random crossover and mutations are performed with only black pixels. Crossover and mutation probabilities are kept at 0.8 and 0.015 respectively.
As an incentive to generate a "cat" with the minimum number of black pixels, I add a penalty for the black pixel count in the image. The initial population is a set of 100 white images that have a single random pixel coloured black in them.
The evolution generates images with only black and white pixels, and we have a fitness function that is taken as a linear transformation of loss calculated between target label and network prediction as follows;
loss = binary cross entropy (target, prediction) + λ(# of black pixels)
Target value (y) = target label cat - in this case, 0.
λ = hyperparameter to weight the penalty for black pixel count.
My problem is that across multiple runs of evolution, all images classified as cats tend to have black pixels towards the edges of the image. Below is an example.
This image is classified as a cat with over 96% confidence.
I have tried different crossover mechanisms including
- Random rectangular area swap between parents
- Alternating column interchange
- Direct black pixel crossover after encoding the image to a reduced form that only kept track of the black pixels (black pixel list is the genome)
Initially, we ran evolution with a similarly fine-tuned VGG-16 model, and then moved to the Inception ResNet due to better accuracy. Pixels tend to edges across models and crossover mechanisms.
In one run, I explicitly constrained the evolution to perform mutations in the middle section of the images for 3,000 generations before lifting this restriction. But the images generated after that point always had better scores.
We are at a loss as to why the images never have pixels coloured in the middle.
Does anyone have any ideas on this?