public void TestComputeClassification() { var network = new RBFNetwork(2, 1, 2); double[] ltm = { 2.0, // input 1 to RBF 1 2.0, // input 2 to RBF 1 5.0, // RBF width 2.0, // RBF, center-0 4.0, // RBF, center-1 3.0, // RBF1 to Output 1 4.0, // Bias to Output 1 5.0, // RBF1 to Output 2 6.0}; // Bias to Output 2 Array.Copy(ltm, 0, network.LongTermMemory, 0, ltm.Length); double[] x = { 1, 2 }; double[] y = network.ComputeRegression(x); // Inputs: (2*1) + (2*2) = 6 // RBF: Gaussian(6) = 1 // Outputs: (1*3) + (1*4) = 7 Assert.AreEqual(7, y[0], AIFH.DefaultPrecision); // Inputs: (2*1) + (2*2) = 6 // RBF: Gaussian(6) = 1 // Outputs: (1*5) + (1*6) = 11 Assert.AreEqual(11, y[1], AIFH.DefaultPrecision); int cls = network.ComputeClassification(x); // class 1 is higher than class 0 Assert.AreEqual(1, cls); }
public void TestComputeRegression() { var network = new RBFNetwork(2, 1, 1); double[] ltm = { 2.0, // input 1 to RBF 1 2.0, // input 2 to RBF 1 5.0, // RBF width 2.0, // RBF, center-0 4.0, // RBF, center-1 3.0, // RBF1 to Output 1 4.0}; // Bias to Output 1 Array.Copy(ltm, 0, network.LongTermMemory, 0, ltm.Length); double[] x = { 1, 2 }; double y = network.ComputeRegression(x)[0]; // Inputs: (2*1) + (2*2) = 6 // RBF: Gaussian(6) = 1 // Outputs: (1*3) + (1*4) = 7 Assert.AreEqual(7, y, AIFH.DefaultPrecision); }