Example #1
0
        public void ReadWeights(string fn)
        {
            string fn1;
            string fn2;

            if (fn.EndsWith(".xml"))
            {
                fn1  = fn.Substring(0, fn.Length - 4);
                fn1 += " w.xml";

                fn2  = fn.Substring(0, fn.Length - 4);
                fn2 += " d.xml";
            }
            else
            {
                fn1 = fn + " w.xml";
                fn2 = fn + " d.xml";
            }

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(FeedForwardNNDescriptor));

            using (FileStream fs = new FileStream(fn2, FileMode.Open))
            {
                Descriptor = (FeedForwardNNDescriptor)xmlSerializer.Deserialize(fs);
            }

            InitNN(Descriptor.LayersData);

            xmlSerializer = new XmlSerializer(typeof(List <List <List <float> > >));

            using (FileStream fs = new FileStream(fn1, FileMode.Open))
            {
                Weights = (List <List <List <float> > >)xmlSerializer.Deserialize(fs);
            }
        }
Example #2
0
        public List <List <float> > Outputs = new List <List <float> >();                       // слой, номер нейрона в слое

        public FeedForwardNN(FeedForwardNNDescriptor descriptor)                                // layersData - кол-во нейронов в слое, кол-во элементов layersdata = кол-во слоев
        {
            if (descriptor.LayersData != null)
            {
                Descriptor = descriptor;
                InitNN(descriptor.LayersData);
            }
        }