I trained my work by using encog library, after getting the desirable result,I want to save my training network
I wrote this code:
What I have tried:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using Encog.Neural.Networks;
using Encog.Neural.Networks.Layers;
using Encog.Neural.NeuralData;
using Encog.Neural.Networks.Training;
using Encog.Neural.Networks.Training.Propagation.Resilient;
using Encog.Neural.Data.Basic;
using Encog.Neural.Activation;
using Encog.Neural.Data;
using Encog.Persist;
<pre>public class Program
{
public static double[][] XOR_INPUT ={
new double[4] { 0.0, 0.0,0.0,0.2 },
new double[4] { 0.5, 1.0 ,0.0,0.7},
new double[4] { 0.5, 0.0 ,1.0,0.3},
new double[4] { 0.5, 1.0 ,0.0,0.7},
new double[4] { 0.5, 1.0 ,0.0,0.7},
new double[4] { 0.0, 1.0,0.0,0.4 },
new double[4] { 1.0, 1.0 ,0.0,0.5} };
public static double[][] XOR_IDEAL = {
new double[1] { 0.0 },
new double[1] { 1.0 },
new double[1] { 0.5 },
new double[1] { 1.0 },
new double[1] { 1.0 },
new double[1] { 0.5 },
new double[1] { 1.0 } };
public static void Main()
{
BasicNetwork network = new BasicNetwork();
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 4));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 6));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 1));
network.Structure.FinalizeStructure();
network.Reset();
INeuralDataSet trainingSet = new BasicNeuralDataSet(XOR_INPUT, XOR_IDEAL);
ITrain train = new ResilientPropagation(network, trainingSet);
int epoch = 1;
do
{
train.Iteration();
Console.WriteLine("Epoch #" + epoch + " Error:" + train.Error);
epoch++;
} while ((epoch < 5000) && (train.Error > 0.001));
FileInfo networkFile = new FileInfo(@"C:\Data\network.eg");
Encog.Persist.EncogDirectoryPersistence.SaveObject(networkFile, (BasicNetwork)network);
this program do not accept the command "Persist.EncogDirectoryPersistence". How to solve the problem please, I want help for replacing "Encog.Persist.EncogDirectoryPersistence.SaveObject(networkFile, (BasicNetwork)network);" or fixing this problem.