Exemplo n.º 1
0
        private double DeltaHidden(CNeuronWithSynapse neuron, double delta)
        {
            double deltaHidden = DerivativeSigmoid(neuron.GetValue());
            double sum         = 0;

            for (int i = 0; i < neuron.GetSynapses().Count; ++i)
            {
                sum += (neuron.GetCertainSynapse(i) * delta);
            }
            deltaHidden *= sum;
            return(deltaHidden);
        }
Exemplo n.º 2
0
 public void Create(string name, int inputCount, int hiddenCount, int outputCount)
 {
     jsonCommander = new JsonCommander();
     m_name        = name;
     for (int i = 0; i < inputCount; ++i)
     {
         CNeuronWithSynapse inputNeuron = new CNeuronWithSynapse(0, CreateRandomList(hiddenCount));
         m_InputNeurons.Add(inputNeuron);
     }
     for (int i = 0; i < hiddenCount; ++i)
     {
         CNeuronWithSynapse hiddenNeuron = new CNeuronWithSynapse(0, CreateRandomList(outputCount));
         m_HiddenNeurons.Add(hiddenNeuron);
     }
     for (int i = 0; i < outputCount; ++i)
     {
         CNeuron outputNeuron = new CNeuron(0);
         m_OutputNeurons.Add(outputNeuron);
     }
     if (File.Exists(m_name + ".json"))
     {
         JsonData[] synapses = jsonCommander.DeSerialize(m_name);
         for (int i = 0; i < m_InputNeurons.Count; ++i)
         {
             for (int j = 0; j < m_HiddenNeurons.Count; ++j)
             {
                 m_InputNeurons[i].SetСertainOutSynape(j, synapses[0].m_values[i][j]);
             }
         }
         for (int i = 0; i < m_HiddenNeurons.Count; ++i)
         {
             for (int j = 0; j < m_OutputNeurons.Count; ++j)
             {
                 m_HiddenNeurons[i].SetСertainOutSynape(j, synapses[1].m_values[i][j]);
             }
         }
     }
     System.Console.WriteLine("Neural Network is initialized");
     //Print("After Create");
 }