Ejemplo n.º 1
0
void NeuralNetwork::ConnectNeurons()
{
   
   // Connect the input neuron outputs to the first hidden layer neurons
   for(int inputNeuron = 0; inputNeuron < m_numInputNeurons; inputNeuron++)
   {
      for(int hiddenNeuron = 0; hiddenNeuron < Network[1].size(); hiddenNeuron++)
      {
         Network[0][inputNeuron]->AddOutputConnection(Network[1][hiddenNeuron]);
         Network[1][hiddenNeuron]->IncreaseNumberOfInputConnections(1);
      }
   }

   // Connect the hidden neurons to themselves and the output neurons
   for(int layerNumber = 1; layerNumber < Network.size() - 1; layerNumber++)
   {
      for(int hiddenNeuron = 0; hiddenNeuron < Network[layerNumber].size(); hiddenNeuron++)
      {
         for(int outputConnection = 0; outputConnection < Network[layerNumber + 1].size(); outputConnection++)
         {
            Neuron* outputConnectionNeuron = Network[layerNumber + 1][outputConnection];
            Network[layerNumber][hiddenNeuron]->AddOutputConnection(outputConnectionNeuron);
            outputConnectionNeuron->IncreaseNumberOfInputConnections(1);
         }
      }
   }

}