int numNeurons = (int)Math.pow(numNeuronsPerDimension, dimensions);
int numEdges = (int)(dimensions * Math.pow(2, dimensions - 1));
pattern.addHiddenLayer(numNeurons);
RBFNetwork network = (RBFNetwork)pattern.generate();
//Position the multidimensional RBF neurons, with equal spacing, within the provided sample space from 0 to 1.
network.setRBFCentersAndWidthsEqualSpacing(0, 1, RBFEnum.Gaussian, volumeNeuronWidth, includeEdgeRBFs);
//Create some training data that can not easily be represented by gaussians
//There are other training examples for both 1D and 2D
//Degenerate training data only provides outputs as 1 or 0 (averaging over all outputs for a given set of inputs would produce something approaching the smooth training data).
//Smooth training data provides true values for the provided input dimensions.
create2DSmoothTainingDataGit();
//Create the training set and train.
MLDataSet trainingSet = new BasicMLDataSet(INPUT, IDEAL);
MLTrain train = new SVDTraining(network, trainingSet);
//SVD is a single step solve
int epoch = 1;
do
{
train.iteration();
System.out.println("Epoch #" + epoch + " Error:" + train.getError());
epoch++;
} while ((epoch < 1) && (train.getError() > 0.001));
// test the neural network
System.out.println("Neural Network Results:");
//Create a testing array which may be to a higher resoltion than the original training data
set2DTestingArrays(100);
trainingSet = new BasicMLDataSet(INPUT, IDEAL);
FileWriter outFile = new FileWriter("results.csv");
PrintWriter out = new PrintWriter(outFile);
for (MLDataPair pair : trainingSet)
{
MLData output = network.compute(pair.getInput());
//1D//sw.WriteLine(InverseScale(pair.Input[0]) + ", " + Chop(InverseScale(output[0])));// + ", " + pair.Ideal[0]);
out.println(inverseScale(pair.getInputArray()[0]) + ", " + inverseScale(pair.getInputArray()[1]) + ", " + chop(inverseScale(output.getData(0))));// + ", " + pair.Ideal[0]);// + ",ideal=" + pair.Ideal[0]);
//3D//sw.WriteLine(InverseScale(pair.Input[0]) + ", " + InverseScale(pair.Input[1]) + ", " + InverseScale(pair.Input[2]) + ", " + Chop(InverseScale(output[0])));// + ", " + pair.Ideal[0]);// + ",ideal=" + pair.Ideal[0]);
//Console.WriteLine(pair.Input[0] + ", actual=" + output[0] + ",ideal=" + pair.Ideal[0]);
}