尝试加载在Encog 3.3中训练的网络时出现EncogDirectoryPersistence错误

时间:2015-01-04 01:29:35

标签: load persistence encog

我在Encog 3.3中训练了一个时态神经网络。然后我去了C#并尝试使用以下代码调用它:

class Program
{
    public static  BasicNetwork LoadEG(FileInfo dir)
{
    if (!dir.Exists)
    {
       Console.WriteLine(" File Does Not Exists...");
       return null;
    }
    else
    {
        var netWork1 = new BasicNetwork();
            netWork1 = ( BasicNetwork)EncogDirectoryPersistence.LoadObject(dir);
        return netWork1;
    }

}
    static void Main(string[] args)
    {   
        var fileName =new FileInfo( @"C:\Users\YandyChang\EncogProjects\Temporal Test More Variables\DataSet_train.eg");
        var trainingFile = new FileInfo(@"C:\Users\YandyChang\EncogProjects\Temporal Test More Variables\DataSet_train.egb");
       var network=LoadEG(fileName);
       var trainingSet = (IMLDataSet)EncogUtility.LoadEGB2Memory(trainingFile);
       double errorRate= network.CalculateError(trainingSet);
       Console.WriteLine(" Error rate of training: "+errorRate);
       Console.WriteLine("InputSize:"+trainingSet.InputSize);
       Console.WriteLine("Ideal Size: "+trainingSet.IdealSize);
       Console.WriteLine("Training: "+trainingSet.Supervised);
       Console.ReadLine();
       trainingSet.Close();

    }
}

尝试加载EG文件时出现以下错误: 类型' System.NullReferenceException'的未处理异常发生在encog-core-cs.dll

附加信息:未将对象引用设置为对象的实例。

有没有人有同样的问题,知道如何解决它?

0 个答案:

没有答案