public void Train(double[][] i, double[][] o = null, int outputLength = 10, int hiddenLayer = -1)
{
if (n == null)
{
if (File.Exists(p)) n = DeepBeliefNetwork.Load(p);
else
{
outputLength = (o == null) ? outputLength : o[0].Length;
hiddenLayer = (hiddenLayer == -1) ? (int)Math.Log(i[0].Length, outputLength) : hiddenLayer;
List<int> layers = new List<int>();
for (int j = 0; j < hiddenLayer; j++) layers.Add(i[0].Length);
layers.Add(outputLength);
n = new DeepBeliefNetwork(new BernoulliFunction(), i[0].Length, layers.ToArray());
new GaussianWeights(n).Randomize();
}
}
dynamic t;
if (o == null)
{
t = new DeepBeliefNetworkLearning(n) { Algorithm = (h, v, j) => new ContrastiveDivergenceLearning(h, v), LayerIndex = n.Machines.Count - 1, };
while (true) e = t.RunEpoch(t.GetLayerInput(i));
}
else
{
t = new DeepNeuralNetworkLearning(n) { Algorithm = (ann, j) => new ParallelResilientBackpropagationLearning(ann), LayerIndex = n.Machines.Count - 1, };
while (true) e = t.RunEpoch(t.GetLayerInput(i), o);
}
}