I'm working to proof basic neural network results and so far haven't been able to. I'm doing a feed-forward xor problem in encog and export the final weights and calculated output.
To proof I just have an excel sheet where I input the weights, then I1*W1+I2*W2 | I1*W3+I2*W4 to the hidden layer, then sigmoid activation for each, then H1*W5+H2*W6 then sigmoid again for the output.
So no bias, just a basic 2x2x1, but the output values I get once I plug the weights in are no where close to the expected output values that I receive with encog.
I have 8 output sets from encog to test against, but so far, I'm not comming up with the same conclusions. Any help would be appreciated.
Below is a sample output if that would be of any help. Thanks, Israel
Output Weights
61.11812639080170, -70.09419692460420, 2.58264325902522, 2.59015713019213, 1.16050691499417, 1.16295830927117
Output Values
0.01111771776254, 0.96929877340644, 0.96926035361899, 0.04443376315742
In excel, here's what I'm using for the sigmoid function: =1/(1+EXP(-1*(C3))), don't know if more would help since it's just addition and multiplication outside of sigmoid.
Here's Form1.cs:
using Encog.Engine.Network.Activation;
using Encog.ML.Data.Basic;
using Encog.Neural.Networks;
using Encog.Neural.Networks.Layers;
using Encog.Neural.Networks.Training.Propagation.Resilient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Encog_Visual
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
double[][] XOR_Input =
{
new[] {0.0,0.0},
new[] {1.0,0.0},
new[] {0.0,1.0},
new[] {1.0,1.0}
};
double[][] XOR_Ideal =
{
new[] {0.0},
new[] {1.0},
new[] {1.0},
new[] {0.0}
};
var trainingSet = new BasicMLDataSet(XOR_Input, XOR_Ideal);
BasicNetwork network = CreateNetwork();
var train = new ResilientPropagation(network, trainingSet);
int epoch = 0;
do
{
train.Iteration();
epoch++;
string result0 = String.Format("Iteration No :{0}, Error: {1}", epoch, train.Error);
textBox1.AppendText(result0 + Environment.NewLine);
} while (train.Error > 0.001);
foreach (var item in trainingSet)
{
var output = network.Compute(item.Input);
string result1 = String.Format("Input : {0}, {1} Ideal : {2} Actual : {3}", item.Input[0], item.Input[1], item.Ideal[0], output[0]);
textBox1.AppendText(result1 + Environment.NewLine + network.DumpWeights() + Environment.NewLine);
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private static BasicNetwork CreateNetwork()
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, false, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
network.Structure.FinalizeStructure();
network.Reset();
return network;
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}