我知道这里有更多关于这个主题的主题,但它们都没有真正帮助我。
我将提供完整的代码:
namespace ConsoleApplication1
{
public static class Load
{
public static double[][] FromFile(string path)
{
var rows = new List<double[]>();
foreach (var line in File.ReadAllLines(path))
{
// HERE IS THE ERROR
rows.Add(line.Split(new[] { ' ' }).Select(double.Parse).ToArray());
}
return rows.ToArray();
}
}
public class Program
{
static void Main( string [ ] args )
{
string cestain = @"E:\vstup.txt";
double[][] innput = Load.FromFile(cestain);
string cestaout = @"E:\vystup.txt";
double[][] ooutput = Load.FromFile(cestaout);
// c r e a t e a neural network
var network = new BasicNetwork ( ) ;
network . AddLayer (new BasicLayer ( null , true , 2) ) ;
network . AddLayer (new BasicLayer (new ActivationSigmoid ( ) , true , 3) ) ;
network . AddLayer (new BasicLayer (new ActivationSigmoid ( ) , false , 1) ) ;
network . Structure . FinalizeStructure ( ) ;
network . Reset( );
// c r e a t e t r a i n i n g data
IMLDataSet trainingSet = new BasicMLDataSet (innput , ooutput ) ;
// t r a i n the neural network
IMLTrain train = new ResilientPropagation (network , trainingSet) ;
int epoch = 1 ;
do
{
train.Iteration( ) ;
Console.WriteLine(@"Epoch #" + epoch + @" Error : " + train.Error );
epoch++;
} while ( train.Error> 0.01 ) ;
Console.ReadLine();
}
}
}
这是我要加载到double[][]
输入的内容:
166 163 180 228
165 162 160 226
166 163 180 228
166 164 180 228
171 162 111 225
这是我要加载到double[][]
输出的内容:
1 0 0
1 0 0
0 1 0
0 1 0
1 0 0