Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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);

            
            // train the neural network
            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.
Posted
Comments
Richard MacCutchan 18-Feb-20 7:38am    
You need to talk to the people who wrote this library.
phil.o 18-Feb-20 7:39am    
Please specify the exact error message.
Member 14129828 19-Feb-20 4:04am    
There is no error >>>>save the empty network with 0kb
phil.o 19-Feb-20 4:15am    
"this program do not accept the command "Persist.EncogDirectoryPersistence"
A program does not accept anyhting. Either you use proper object/syntax of the language/framework, or you don't.
Anyway, as it has already been told on your former question, your best chance to get meaningful advise is to ask people who wrote this library, or use it regularly.
Member 14129828 23-Feb-20 4:33am    
thank you, sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900