Ejemplo n.º 1
0
        public void Create(NeuralNetworkCls parent, int[] nrOfNeuronsList, int index, Synapses prevSy)
        {
            if (parent.CompleteObjList)
            {
                parent.NeuronsAndSynappses.Add(this);
            }

            Parent = parent;
            PrevSy = prevSy; // could be null

            int nrOfNeurons = nrOfNeuronsList[index];

            I = Matrix <double> .Build.Dense(nrOfNeurons, 1);

            O = Matrix <double> .Build.Dense(nrOfNeurons, 1);

            if (parent.FunctionInitializer != null)
            {
                ResultType = parent.FunctionInitializer.GetResultEnum(index);
            }
            else
            {
                ResultType = (ResultEnum)index;
            }

            if (index < nrOfNeuronsList.Length - 1)
            {
                NextSy = new Synapses();
                NextSy.Create(Parent, nrOfNeuronsList, index, this);
            }
            else
            {
                parent.LastNeurons = this;
            }
        }
Ejemplo n.º 2
0
        private void CheckIfNeuralNetworksAreEqual(NeuralNetworkCls nnFromEcel, NeuralNetworkCls neuralNetworkCls)
        {
            for (int i = 0; i < nnFromEcel.NeuronsAndSynappses.Count; i++)
            {
                if (i % 2 == 1)
                {
                    Synapses s1 = nnFromEcel.NeuronsAndSynappses[i] as Synapses;
                    Synapses s2 = neuralNetworkCls.NeuronsAndSynappses[i] as Synapses;

                    if (!s1.W.Equals(s2.W) || !s1.B.Equals(s2.B))
                    {
                        throw new Exception("W or B are not equal.");
                    }
                }
            }
            //System.Windows.Forms.MessageBox.Show("Excel test completed. The current neural network delivered the same results as the serialised class.", "Success", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
        }