Solved – Find Neural Network Inputs Given Outputs

artificial intelligencemachine learningneural networks

I've trained a neural network with two inputs, a single hidden layer with two neurons, and one output using a bipolar sigmoid activation function. If a single input is known, how would I determine the second input to create a desired output?

For example, let's say the neural network is trained to add two inputs to produce an output. So if input_1 = 3 and input_2 = 4, the output will be 7, (3 + 4 = 7). Given input_1 = 3 and the desired output is 7, I want to calculate the second input required to produce the desired output (the answer should be 4).

How would I do this for a network that is more complicated than basic addition and has multiple inputs/outputs? For example, for a network with four inputs and two outputs, how would I calculate input_3 and input_4 given input_1, input_2, output_1 and output_2?

Best Answer

I'm no expert in this field, so I might be wrong. Therefore, correct me if I'm wrong.

consider this neural network (which I suppose is equivalent to yours):

A---H1
 \ /  \
  X    C
 / \  /
B---H2

consider that the activation function of H1, H2 and C is the bipolar sigmoid, to which we'll refer to as "bsig(x)"

also, we'll name the connections as follows:
A, H1: wa1;
A, H2: wa2;
B, H1: wb1;
B, H2: wb2;
H1, C: wh1;
H2, C: wh2

now the values of H1, H2 and C can be defined as:

H1 = bsig(wa1 * A + wb1 * B)
H2 = bsig(wa2 * A + wb2 * B)
C = bsig(wh1 * H1 + wh2 * H2)

So, C can be written as:

C = bsig(wh1 * bsig(wa1 * A + wb1 * B) + wh2 * bsig(wa2 * A + wb2 * B))

All you need to do is solve this equation in order to B or A depending on which of the values is unkown.