0
votes

I've programmed (Java) my own feed-forward network learning by back propagation. My network is trained to learn the XOR problem. I have an input matrix 4x2 and target 4x1.

Inputs:

{{0,0},
{0,1},
{1,0},
{1,1}}

Outputs:

{0.95048}
{-0.06721}
{-0.06826}
{0.95122}

I have this trained network and now I want to test it on new inputs like:

{.1,.9} //should result in 1

However, I'm not sure how to implement a float predict(double[] input) method. From what I can see, my problem is that my training data has a different size than my input data.

Please suggest.

EDIT: The way I have this worded, it sounds like I want a regression value. However, I'd like the output to be a probability vector (classification) which I can then analyze.

2

2 Answers

0
votes

Basically, when you train a neural network, you get a bunch of parameters that can be used to predict the result. You get the result by adding the products of your features and weights in each layer and then you apply your activation function to it. for example, let's say your network has 3 layers (other than features), and each hidden layer has three neurons and your output layer has one neuron. W1 denotes your weights for the first layer, therefore it has a shape of [3,2]. With the same argument, W2, the weights for your second layer has a shape of [3,3]. Finally, W3 which is the weights for your output layer has a shape of [1,3]. Now if we use a function called g(z) as your activation function, you can calculate the result for an example like this:

Z1 = W1.X
A1 = g(Z1)
Z2 = W2.A1
A2 = g(Z2)
Z3 = W3.A2
A3 = g(Z3)

and A3 is your result, predicting the XOR of two numbers. Please note that I have not considered bias terms for this example.

0
votes

In your situation your neural network should have a input with dimension 2 and output 1. So during training you will provide each example input {x0, x1} and output {y0} for it to learn. Then finally when predicting you can provide a vector {.9, .1} and get the desired output.