/// <summary> /// Trains the ANN that has been previously been loaded using "LoadANN()" /// </summary> /// <param name="?"></param> /// <returns></returns> public bool TrainAnn(TrainOptions options, int numTrainingSets, float[] inputs, float[] outputs, ref int terminatedAfterIter) { int numInputLayers = inputs.Count() / numTrainingSets; int numOutputLayers = 1; Console.WriteLine("Starting Training with theses parameters: " + " Number of Training Datasets: " + numTrainingSets + " Number of Input Layers: " + numInputLayers + " Number of Output Layers: " + numOutputLayers); Console.WriteLine("Inputs:"); for (int i = 0; i < inputs.Count(); i++) { if (i == 16) { Console.WriteLine(); } Console.Write(inputs[i] + " "); } Console.WriteLine("Outputs:"); for (int i = 0; i < outputs.Count(); i++) { if (i == 1) { Console.WriteLine(); } Console.Write(outputs[i] + " "); } int res = klu_trainAnn(options, numTrainingSets, inputs, numInputLayers, outputs, numOutputLayers, out terminatedAfterIter); Console.WriteLine("Training finished after iteration #: " + terminatedAfterIter); return(res == 1); }
private static extern int klu_trainAnn( [In, MarshalAs(UnmanagedType.LPStruct)] TrainOptions options, int numTrainingSets, [In, MarshalAs(UnmanagedType.LPArray)] float[] inputs, int numInputNeurons, [In, MarshalAs(UnmanagedType.LPArray)] float[] outputs, int numOutputNeurons, out int terminatedAfterIter );
/// <summary> /// Trains the ANN that has been previously been loaded using "LoadANN()" /// </summary> /// <param name="?"></param> /// <returns></returns> public bool TrainAnn(TrainOptions options, int numTrainingSets, float[] inputs, float[] outputs, ref int terminatedAfterIter) { int numInputLayers = inputs.Count() / numTrainingSets; int numOutputLayers = 1; Console.WriteLine("Starting Training with theses parameters: " + " Number of Training Datasets: " + numTrainingSets + " Number of Input Layers: " + numInputLayers + " Number of Output Layers: " + numOutputLayers); Console.WriteLine("Inputs:"); for (int i = 0; i < inputs.Count(); i++) { if (i == 16) { Console.WriteLine(); } Console.Write(inputs[i] + " "); } Console.WriteLine("Outputs:"); for (int i = 0; i < outputs.Count(); i++) { if (i == 1) { Console.WriteLine(); } Console.Write(outputs[i] + " "); } int res = klu_trainAnn(options, numTrainingSets, inputs, numInputLayers, outputs, numOutputLayers, out terminatedAfterIter); Console.WriteLine("Training finished after iteration #: " + terminatedAfterIter); return (res == 1); }