Example #1
0
 /**
  * @param \Sereban\NeuronNet\Layout\Collection $layoutCollection
  * @param array $initialValues
  * @param array $teacherValues
  * @throws \Exception
  */
 public function initNeuronsInLayoutCollection(NeuronNet\Layout\Collection &$layoutCollection, $initialValues, $teacherValues)
 {
     $layoutIndex = 0;
     /** @var array $neuronsSchema -> $type: $count*/
     $neuronsSchema = array(Factory::STIM => count($initialValues), Factory::ASSOC => count($initialValues), Factory::REACT => count($teacherValues));
     foreach ($neuronsSchema as $type => $count) {
         $layout = $layoutCollection->seek($layoutIndex++);
         for ($j = 0; $j < $count; $j++) {
             /** @var Neuron $neuron */
             $neuron = Factory::neuron($type, $j);
             $layout->addNeuron($neuron);
             $neuron->setLayout($layout);
         }
         //Set Data to Neurons
         if ($type == Factory::STIM) {
             $layout->setValues($initialValues);
         } elseif ($type == Factory::REACT) {
             $layout->setValues($teacherValues);
         }
     }
 }