Answers.Body: <blockquote>
    <p>Now I have a network trained to get an output value from an random set of attributes but, can I use this trained network to get the input attributes using only the desired output?</p>
  </blockquote>
  
  <p>It depends:</p>
  
  <ul>
  <li><p>If you are happy to find any inputs, even non-realistic ones, that get your desired output, then you can use your trained network, with a minor modification. Freeze all the weights, and allow back-propagation to determine the gradient of the input (which should now be a variable to optimise, not source data). Start with a noise input, back-propagate the error to find gradient to make the input better at creating your desired output, then take a gradient step towards it in the input data. This is essentially how Deep Dream works. Like Deep Dream, you will not necessarily get realistic input values, but will get <a href="https://mtyka.github.io/deepdream/2016/02/05/bilateral-class-vis.html" rel="nofollow noreferrer">semi-random ones that cause your network to predict a specific class</a>.</p></li>
  <li><p>If you want the newly generated input to be a best guess at something from the original dataset, then you have to look at one of more advanced models:</p>
  
  <ul>
  <li><p><a href="https://en.wikipedia.org/wiki/Restricted_Boltzmann_machine" rel="nofollow noreferrer">Restricted Boltzmann Machines (RBMs)</a>.</p></li>
  <li><p><a href="http://kvfrans.com/variational-autoencoders-explained/" rel="nofollow noreferrer">Variational Autoencoders (VAEs)</a></p></li>
  <li><p><a href="https://en.wikipedia.org/wiki/Generative_adversarial_network" rel="nofollow noreferrer">Generative Adversarial Networks (GANs)</a>. These have become popular recently, and there are many variations on the basic idea, including VAEGANs that combine VAEs with GANs.</p></li>
  </ul></li>
  </ul>
  
  <p>These network types are quite advanced, and can be tricky to understand and train successfully. You will want to spend some time researching each type. </p>
  
  <p>To generalise terribly: A GAN will tend to generate realistic "noise" in the generated items, but at the expense of overall structure and cohesion (images tend to look distorted but with realistic textures). A VAE will tend to produce smooth, coherent inputs, but at the expense of lack of fine detail (VAE images tend to look smoothed and/or blurred). </p>
  
  <p>If not sure what to try, probably GAN is a reasonable choice, since there are lots of tutorials available, and <a href="https://www.youtube.com/watch?v=36lE9tV9vm0&amp;t=3099s" rel="nofollow noreferrer">recent advances with image generation can look very impressive</a>. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-07T20:02:57.923Z
Answers.Text: Thanks. I've thought about this question because I'm using genetic algorithm to optimize a function. I know which is the desirable output, 0, and I have tested a lot without successful. Maybe I can use a neural network to find the input to the genetic algorithm to get 0 as output. Thanks again.
Answers.UserDisplayName: VansFannel
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-07T18:35:03.100Z
Answers.LastActivityDate: 2018-03-07T18:35:03.100Z
Answers.UserDisplayName: Neil Slater
Answers.Body: <p>NN isn't symmetric and the result may haven't any seems.
  You can just use loss like this (target_output - model_output)**2 - MSE
  differentiate this loss  according to input variables and use optimizer to solve this task. Try to search about <a href="https://en.wikipedia.org/wiki/Adversary_model" rel="nofollow noreferrer">adversarial models</a>, the idea is very similar.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T18:04:39.427Z
Answers.Text: could I ask you to give this answer an edit?  I would do it, but I'm not sure of the meaning of the first sentence...
Answers.UserDisplayName: DukeZhou
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-07T12:37:41.823Z
Answers.LastActivityDate: 2018-03-09T18:09:01.630Z
Answers.LastEditDate: 2018-03-09T18:09:01.630Z
Answers.UserDisplayName: user2674414
Body: <p>I have an idea about how to use neural networks but I'm not sure if it is possible or not.</p>
  
  <p>In supervised learning we have a set of attributes labeled with an output value. I can use these set to train my network.</p>
  
  <p>Now I have a network trained to get an output value from an random set of attributes but, <strong>can I use this trained network to get the input attributes using only the desired output?</strong></p>
  
  <p>I will have N input values and only 1 output value. I've thought that I can use the weights for that network into a new one with 1 input value and N output values but I'm not sure if I can do that.</p>
  
Tags: <neural-networks><generative-model>
Title: Neural network to get input attributes using only the output value
UserDisplayName: VansFannel
ThreadText: # Neural network to get input attributes using only the output value
  
  (Asked by: username_0 on 2018-03-07)
  
  I have an idea about how to use neural networks but I'm not sure if it is possible or not.
  
  In supervised learning we have a set of attributes labeled with an output value. I can use these set to train my network.
  
  Now I have a network trained to get an output value from an random set of attributes but, **can I use this trained network to get the input attributes using only the desired output?**
  
  I will have N input values and only 1 output value. I've thought that I can use the weights for that network into a new one with 1 input value and N output values but I'm not sure if I can do that.
  
  **Tags:** neural-networks, generative-model
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-03-07. Score: 2
  
  > Now I have a network trained to get an output value from an random set of attributes but, can I use this trained network to get the input attributes using only the desired output?
  
  It depends:
  
  * If you are happy to find any inputs, even non-realistic ones, that get your desired output, then you can use your trained network, with a minor modification. Freeze all the weights, and allow back-propagation to determine the gradient of the input (which should now be a variable to optimise, not source data). Start with a noise input, back-propagate the error to find gradient to make the input better at creating your desired output, then take a gradient step towards it in the input data. This is essentially how Deep Dream works. Like Deep Dream, you will not necessarily get realistic input values, but will get [semi-random ones that cause your network to predict a specific class](https://mtyka.github.io/deepdream/2016/02/05/bilateral-class-vis.html).
  * If you want the newly generated input to be a best guess at something from the original dataset, then you have to look at one of more advanced models:
  
    + [Restricted Boltzmann Machines (RBMs)](https://en.wikipedia.org/wiki/Restricted_Boltzmann_machine).
    + [Variational Autoencoders (VAEs)](http://kvfrans.com/variational-autoencoders-explained/)
    + [Generative Adversarial Networks (GANs)](https://en.wikipedia.org/wiki/Generative_adversarial_network). These have become popular recently, and there are many variations on the basic idea, including VAEGANs that combine VAEs with GANs.
  
  These network types are quite advanced, and can be tricky to understand and train successfully. You will want to spend some time researching each type.
  
  To generalise terribly: A GAN will tend to generate realistic "noise" in the generated items, but at the expense of overall structure and cohesion (images tend to look distorted but with realistic textures). A VAE will tend to produce smooth, coherent inputs, but at the expense of lack of fine detail (VAE images tend to look smoothed and/or blurred).
  
  If not sure what to try, probably GAN is a reasonable choice, since there are lots of tutorials available, and [recent advances with image generation can look very impressive](https://www.youtube.com/watch?v=36lE9tV9vm0&t=3099s).
  
  > **Comments:**
  > **username_0**: Thanks. I've thought about this question because I'm using genetic algorithm to optimize a function. I know which is the desirable output, 0, and I have tested a lot without successful. Maybe I can use a neural network to find the input to the genetic algorithm to get 0 as output. Thanks again.  
  
  ---
  
  ### Answer by username_2 on 2018-03-07. Score: 0
  
  NN isn't symmetric and the result may haven't any seems.
  You can just use loss like this (target\_output - model\_output)\*\*2 - MSE
  differentiate this loss according to input variables and use optimizer to solve this task. Try to search about [adversarial models](https://en.wikipedia.org/wiki/Adversary_model), the idea is very similar.
  
  > **Comments:**
  > **username_3**: could I ask you to give this answer an edit?  I would do it, but I'm not sure of the meaning of the first sentence...  
  
  ---
  
  