3
$\begingroup$

I've trained a neural network (NN) on a problem where multiple inputs can be mapped to the same output. I'd like to use this NN to go from an output to an input i.e. given an output vector $y$, I want to find an input $x$ such that the NN returns some $z$ close to the given output $y$ when fed an input of $x$.

I was thinking of using gradient descent to do this. Do any of the common deep learning APIs let you take gradients of NNs with respect to their inputs?

I've looked around and haven't found anything, but figured I'd check here before moving forward.

$\endgroup$
0
$\begingroup$

iNNvestigate is a very powerful and well-written library for inspecting the neural networks. Among others, it includes the gradient method.

However, if you want to synthesize an input that will cause the network to produce certain output - this technique is known as code inversion. Follow the paper by Mahendran et al. for more details. I found the following implementations for it:

| improve this answer | |
$\endgroup$
0
$\begingroup$

Yes there is. This is called "back-propagation to the input". I would like to invite you to read this awesome blog which relies on lucid. You will see some code on their notebooks.

| improve this answer | |
$\endgroup$
  • $\begingroup$ From the linked blog: "Neural networks are, generally speaking, differentiable with respect to their inputs. If we want to find out what kind of input would cause a certain behavior — whether that’s an internal neuron firing or the final output behavior — we can use derivatives to iteratively tweak the input towards that goal" -- seems to validate OP's idea! $\endgroup$ – Imran Jan 11 '19 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.