Ejemplo n.º 1
0
        public ImageCompress()
        {
            int[] layersizes = new int[3] {
                8, 18, 8
            };
            ActivationFunction[] activFunctions = new ActivationFunction[3] {
                ActivationFunction.None, ActivationFunction.Sigmoid, ActivationFunction.Linear
            };


            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(Server.MapPath("resources/ann.xml"));

            ds = new DataSet();
            ds.Load((XmlElement)xdoc.DocumentElement.ChildNodes[0]);

            bpnetwork = new BackPropNetwork(layersizes, activFunctions);
            nt        = new NetworkTrainer(bpnetwork, ds);

            nt.maxError      = 0.00001;
            nt.maxiterations = 10000;
            nt.nudgewindow   = 500;
            nt.traininrate   = 0.1;
            nt.TrainDataset();

            // save error
            double[] err      = nt.geteHistory();
            string[] filedata = new string[err.Length];

            for (int i = 0; i < err.Length; i++)
            {
                filedata[i] = i.ToString() + " " + err[i].ToString();
            }
        }
Ejemplo n.º 2
0
        public CompressText()
        {
            int[] layersizes = new int[10] {
                1, 10, 9, 8, 7, 5, 4, 3, 2, 1
            };
            ActivationFunction[] activFunctions = new ActivationFunction[10] {
                ActivationFunction.None, ActivationFunction.Gaussian, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid,
                ActivationFunction.Linear
            };


            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(Path.Combine(HttpRuntime.AppDomainAppPath, "resources/ann.xml"));

            ds = new DataSet();
            ds.Load((XmlElement)xdoc.DocumentElement.ChildNodes[0]);


            bpnetwork = new BackPropNetwork(layersizes, activFunctions);
            nt        = new NetworkTrainer(bpnetwork, ds);

            nt.maxError      = 0.1;
            nt.maxiterations = 10000;
            nt.traininrate   = 0.1;
            nt.TrainDataset();

            // save error
            double[] err      = nt.geteHistory();
            string[] filedata = new string[err.Length];

            for (int i = 0; i < err.Length; i++)
            {
                filedata[i] = i.ToString() + " " + err[i].ToString();
            }
        }