Exemplo n.º 1
0
 public void AddConnection(NNConnection conn)
 {
     m_Connections.Add(conn);
 }
Exemplo n.º 2
0
        virtual public void Serialize(Archive ar)
        {
            int ii, jj;

            if (ar.IsStoring())
            {
                // TODO: add storing code here
                // TODO: add storing code here

                ar.Write(label);
                //ar.WriteString(_T("\r\n"));  // ar.ReadString will look for \r\n when loading from the archive
                ar.Write(m_Neurons.Count);
                ar.Write(m_Weights.Count);



                foreach (NNNeuron nit in m_Neurons)
                {
                    ar.Write(nit.label);
                    ar.Write(nit.m_Connections.Count);

                    foreach (NNConnection cit in nit.m_Connections)
                    {
                        ar.Write(cit.NeuronIndex);
                        ar.Write(cit.WeightIndex);
                    }
                }

                foreach (NNWeight wit in m_Weights)
                {
                    ar.Write(wit.label);
                    ar.Write(wit.value);
                }
            }
            else
            {
                // TODO: add loading code here

                string str;
                //Read Layter's label
                ar.Read(out str);
                label = str;

                int    iNumNeurons, iNumWeights, iNumConnections;
                double value;

                NNNeuron pNeuron;
                NNWeight pWeight;

                //Read No of Neuron, Weight
                ar.Read(out iNumNeurons);
                ar.Read(out iNumWeights);
                if (iNumNeurons != 0)
                {
                    //clear neuron list and weight list.
                    m_Neurons.Clear();
                    m_Neurons = new NNNeuronList(iNumNeurons);
                    m_Weights.Clear();
                    m_Weights = new NNWeightList(iNumWeights);

                    for (ii = 0; ii < iNumNeurons; ii++)
                    {
                        //ar.Read Neuron's label
                        ar.Read(out str);
                        //Read Neuron's Connection number
                        ar.Read(out iNumConnections);
                        pNeuron       = new NNNeuron(str, iNumConnections);
                        pNeuron.label = str;
                        m_Neurons.Add(pNeuron);
                        for (jj = 0; jj < iNumConnections; jj++)
                        {
                            var conn = new NNConnection();
                            ar.Read(out conn.NeuronIndex);
                            ar.Read(out conn.WeightIndex);
                            pNeuron.AddConnection(conn);
                        }
                    }

                    for (jj = 0; jj < iNumWeights; jj++)
                    {
                        ar.Read(out str);
                        ar.Read(out value);

                        pWeight = new NNWeight(str, value);
                        m_Weights.Add(pWeight);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void AddConnection(uint iNeuron, uint iWeight)
        {
            NNConnection conn = new NNConnection(iNeuron, iWeight);

            m_Connections.Add(conn);
        }