Search code examples
imageneural-networkclassificationdeep-learninginversion

Inversing the goal of neural networks


I am studying neural networks, or more specifically image classification at the moment. While I was reading, I was wondering if the following has ever been done/ is doable. If anybody could point me to some sources or ideas, I'd appreciate it!

In a traditional neural network, you have a training data set of images and the weights of the neurons in the network. The goal is to optimize the weights so that the classification of the images is accurate for training data and new images is as good as possible.

I was wondering if you could reverse this: Given a neural network and the weights to its neurons, generate a set of images corresponding to the classes that the network separates, i.e., a proto-type of the kinds of images this specific network is able to classify well.

In my mind it would work as follows (I'm sure this is not quite achievable, but just to get the idea across): Imagine a neural network that is able to classify images containing labels cat, dog and neither of those. What I want is the "inverse", i.e. an image of a cat, an image of a dog and one that is "furthest away" from the other two classes. I think that this could be done by generating images and minimizing the loss function for one specific class, while maximizing it for all other classes at the same time.

Is this kind of how Google Deep Dream visualizes what it is "dreaming"?


Solution

  • Is this kind of how Google Deep Dream visualizes what it is "dreaming"?

    Pretty much, it seems, at least that's how the people behind it explain it:

    One way to visualize what goes on [in a neural network layer] is to turn the network upside down and ask it to enhance an input image in such a way as to elicit a particular interpretation. Say you want to know what sort of image would result in “Banana.” Start with an image full of random noise, then gradually tweak the image towards what the neural net considers a banana (see related work [...]). By itself, that doesn’t work very well, but it does if we impose a prior constraint that the image should have similar statistics to natural images, such as neighboring pixels needing to be correlated.

    Source - The whole blog post is worth reading.