Reputation: 317
I am messing with the different deep learning algorithms in Accord.NET. I decided to do this with spectra data I had lying around. I PCA transform the data so that it is reduced to 10 data points, using Accord's statistics toolbox. then follow the tutorial to the letter:
// Setup the deep belief network and initialize with random weights.
DeepBeliefNetwork network = new DeepBeliefNetwork(transformedInputs.First().Length, 10, 10);
new GaussianWeights(network, 0.1).Randomize();
network.UpdateVisibleWeights();
// Setup the learning algorithm.
DeepBeliefNetworkLearning teacher = new DeepBeliefNetworkLearning(network)
{
Algorithm = (h, v, i) => new ContrastiveDivergenceLearning(h, v)
{
LearningRate = 0.1,
Momentum = 0.5,
Decay = 0.001,
}
};
// Setup batches of input for learning.
int batchCount = Math.Max(1, transformedInputs.Length / 100);
// Create mini-batches to speed learning.
int[] groups = Accord.Statistics.Tools.RandomGroups(transformedInputs.Length, batchCount);
double[][][] batches = transformedInputs.Subgroups(groups);
// Learning data for the specified layer.
double[][][] layerData;
// Unsupervised learning on each hidden layer, except for the output layer.
for (int layerIndex = 0; layerIndex < network.Machines.Count - 1; layerIndex++)
{
teacher.LayerIndex = layerIndex;
layerData = teacher.GetLayerInput(batches);
for (int i = 0; i < 200; i++)
{
double error = teacher.RunEpoch(layerData) / transformedInputs.Length;
if (i % 10 == 0)
{
Console.WriteLine(i + ", Error = " + error);
}
}
}
// Supervised learning on entire network, to provide output classification.
var teacher2 = new BackPropagationLearning(network)
{
LearningRate = 0.1,
Momentum = 0.5
};
// Run supervised learning.
for (int i = 0; i < 500; i++)
{
double error = teacher2.RunEpoch(transformedInputs, output: outputs);
if (i % 10 == 0)
{
Console.WriteLine(i + ", Error = " + error);
}
}
I checked the inputted data and it is in the correct double[][] format fr both inputs and outputs. I also checked the original app:https://github.com/primaryobjects/deep-learning And that worked perfectly, so I am struggling to see what simply changing the inputted data is messing up so much. Any help would be greatly appreciated. The error I am getting is:
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Accord.Neuro.dll
Additional information: Index was outside the bounds of the array.
Upvotes: 2
Views: 527
Reputation: 317
And of course it was immediately after posting this question that I realized that my network would have to reflect the number of outputs, and that was set to 10. I am very sorry for disturbing this fantastic community.
Upvotes: 3