Encog训练数据输入大小为0,但计算得出的输入大小为5

时间:2018-11-14 20:04:50

标签: c# machine-learning neural-network artificial-intelligence encog

正如标题所示,我收到错误“机器学习方法的输入长度为5,但是训练数据为0。它们必须相同。”因为我的训练数据输入大小为0,但计算得出的输入大小为5(正确)。用于读取csv文件并将其存储为数据集的代码:

        //Get file path.
        var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
        path = path.Replace("file:\\", "");
        IVersatileDataSource source = new CSVDataSource(path + @"\enpcsv.csv", false, CSVFormat.DecimalPoint);

        //Setup training dataset.
        var data = new VersatileMLDataSet(source);
        data.DefineSourceColumn("A", 0, ColumnType.Continuous);
        data.DefineSourceColumn("B", 1, ColumnType.Continuous);
        data.DefineSourceColumn("C", 2, ColumnType.Continuous);
        data.DefineSourceColumn("D", 3, ColumnType.Continuous);
        data.DefineSourceColumn("E", 4, ColumnType.Continuous);
        ColumnDefinition outputColumn = data.DefineSourceColumn("F", 5, ColumnType.Nominal);

        data.Analyze();
        data.DefineSingleOutputOthersInput(outputColumn);

        data.Normalize();

        //Setup network
        BasicNetwork network = new BasicNetwork();
        network.AddLayer(new BasicLayer(null, true, 5)); //Input.
        network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 10)); //Hidden.
        network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1)); //Output.
        network.Structure.FinalizeStructure();
        network.Reset();

        //Train.
        IMLTrain learner = new Backpropagation(network, data);

另一点可能是,与输入大小类似,理想大小为0,但计算出的理想大小为6,这不是我设置的理想值。我已经看到了解决此问题的一种方法,他们将数据集另存为csv,然后再次读取:Encog :"The Machine Learning Method has an input length of 7, but the training has 0" error 这似乎是一种不好的做法,所以我想看看是否有人知道另一种解决方案或可以在我的代码中调出错误,谢谢您的时间。

0 个答案:

没有答案