public void Initialize(int inputNeuron, int hiddenLayer, int hiddenNeuron, int outputNeuron)
        {
            Util utility = new Util();

            for (int i = 0; i < inputNeuron; i++)
            {
                Neuron neron = new Neuron();
                neron.Input  = utility.NextDouble();
                neron.Weight = utility.NextDouble();
                InputLayer.NeuronList.Add(neron);
            }

            for (int i = 0; i < hiddenLayer; i++)
            {
                NetworkLayer networkLayer = new NetworkLayer();
                for (int j = 0; j < hiddenNeuron; j++)
                {
                    Neuron neuron = new Neuron();
                    neuron.Input  = utility.NextDouble();
                    neuron.Weight = utility.NextDouble();
                    networkLayer.NeuronList.Add(neuron);
                }
                HiddenLayer.Add(networkLayer);
            }

            for (int i = 0; i < outputNeuron; i++)
            {
                Neuron neuron = new Neuron();
                neuron.Input  = utility.NextDouble();
                neuron.Weight = utility.NextDouble();
                OutputLayer.NeuronList.Add(neuron);
            }
        }
Exemple #2
0
        public void OpenNW(byte[] binNW)
        {
            int k = 0;

            // Извлекаем количество слоев из массива
            countLayers = ReadFromArrayInt(binNW, ref k);
            Layers      = new NetworkLayer[countLayers];

            // Извлекаем размерность слоев
            int CountY1 = 0, CountX1 = ReadFromArrayInt(binNW, ref k);

            // Размерность входа
            countX = CountX1;
            // Выделяемпамять под выходы нейронов и дельта
            NETOUT    = new double[countLayers + 1][];
            NETOUT[0] = new double[CountX1];
            DELTA     = new double[countLayers][];

            for (int i = 0; i < countLayers; i++)
            {
                CountY1   = ReadFromArrayInt(binNW, ref k);
                Layers[i] = new NetworkLayer(CountX1, CountY1);
                CountX1   = CountY1;

                // Выделяем память
                NETOUT[i + 1] = new double[CountY1];
                DELTA[i]      = new double[CountY1];
            }
            // Размерность выхода
            countY = CountY1;
            // Извлекаем и записываем сами веса
            for (int r = 0; r < countLayers; r++)
            {
                for (int p = 0; p < Layers[r].countX; p++)
                {
                    for (int q = 0; q < Layers[r].countY; q++)
                    {
                        Layers[r][p, q] = ReadFromArrayDouble(binNW, ref k);
                    }
                }
            }
        }
Exemple #3
0
 public void addLayer(NetworkLayer layer)
 {
     layers.Add(layer);
 }