# Recognizing Neural Network Array Patterns with Encog - How to validate the following pattern?

I am using the Encog library to solve a pattern recognition problem, following the basic example provided by Mr. Jeff Histon. I have a template

```
1 3 5 4 3 5 4 3 1
```

which is my perfect template with an output of 1 (which means it is 100% the same) Now I want to introduce another template and see how similar it looks to the perfect template.

This code is used to create a network

```
BasicNetwork network = new BasicNetwork();
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, NumberOfInputNeurons));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 20));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 15));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 1));
network.Structure.FinalizeStructure();
network.Reset();
INeuralDataSet trainingSet = new BasicNeuralDataSet(XOR_INPUT, XOR_IDEAL);
```

Then I train the network

```
do
{
train.Iteration();
Console.WriteLine("Epoch #" + epoch + " Error:" + train.Error);
epoch++;
} while ((epoch <= 20000) && (train.Error > 0.001));
```

And finally, I print the results:

```
foreach (INeuralDataPair pair in trainingSet)
{
INeuralData output = network.Compute(pair.Input);
Console.WriteLine(pair.Input[0] + "-" + pair.Input[1] + "-" + pair.Input[2] + ....
+ ": actual = " + output[0] + " ideal=" + pair.Ideal[0]) ;
}
```

Back to my question again:

** How do I enter a different template and see if it looks like mine?**

Any ideas that might lead me to a solution are appreciated. Thanks to

source to share

I'm not sure if I follow this completely. Do you have more models than you? Or is your training set tuned to exactly one template and you just want to see how other templates are similar to it? The neural network doesn't really compare the degree of similarity between samples. The neural network is trained to derive some vector based on the training set, which gives input data and ideal vectors.

If you really want to just compare "1 3 5 4 3 5 4 3" with another similar vector, I would suggest just using Euclidean distance or a similar measurement.

If, on the other hand, you want to train a neural network to recognize how something similar to this step is, you will need to generate some more training data. I would create 1000 or so cases and create a Euclidean distance between each random case and your vector above and scale it down to a percentage. For best performance, you will also need to normalize your input vector to 0 to 1 for the neural network.

** Edit:**

Here's how I would represent it. You will have the number of input neurons equal to the maximum number of x-axis points you can have. However, you need to normalize these values, so I would suggest setting the maximum Y value to be and normalizing between 0 and that value. Then, for your outputs, you will have one output neuron for every possible letter you can receive. Perhaps the first output neuron is A, the second is B. Then use the one-of-n encoding and set the only ONE of the output neurons to 1 and the rest to zero:

```
[input pattern for A] -> [1 0 0]
[input pattern for B] -> [0 1 0]
[input pattern for C] -> [0 0 1]
[another input pattern for C] -> [0 0 1]
```

Use the above as a training kit. Of course, if you have all 26 letters, you have 26 outputs.

source to share