1

In TensorFlow it is pretty straight forward to visualize filters and activation layers given a single input.

But I'm more interested in the opposite way: feeding a class (as one-hot vector) to the output layer and see something like the optimal input image for that specific class.

Is there a way to do so or to run the graph reversed?

Background: I'm using Googles Inception V3 with 15 classes and I've trained the network already with a large amount of data up to a good precision. Now I'm interested in understanding why and how the model distinguishes the different classes.

1 Answers1

1

The "basic" version of this is straightforward. You use the same graph as for training the network, but instead of optimizing w.r.t. the parameters of the network, you optimize w.r.t the input (which has to be a variable with the shape of your input image). Your optimization target is the negative (because you want to maximize, but TF optimizers minimize) logit of your target class. You want to run it with a couple of different initial values for the image.

There's also a few related techniques, if you search for DeepDream and adversarial examples you should find a lot of literature.

etarion
  • 16,935
  • 4
  • 43
  • 66
  • But since the graph in TensorFlow is directed, I cannot simply change my optimization target. I would have to rebuild a reversed model manually, right? – Marc Osterland Oct 05 '16 at 09:44
  • @MarcOsterland no, it's the same. The only thing is what is fixed and what is variable - in the typical setting, your image is fixed and you change the model parameters, in your case the model parameters are fixed and you change the image. – etarion Oct 05 '16 at 12:30
  • @etarion: But how do you fixate your parameters after you created them variable for training? – thomas Oct 24 '16 at 14:32
  • @thomas TensorFlow optimizers have a var_list parameter in minimize that lets you specify exactly which variables to update - other variables don't get touched. – etarion Oct 24 '16 at 14:36
  • @etarion: Id didn't know that. But now I have another problem. To not spam the answer with comments I opened a new question. I would be grateful if you could have a look at http://stackoverflow.com/questions/40235727/optimize-input-image-with-class-prior – thomas Oct 25 '16 at 09:04