예제 #1
0
 public function calculate($layer, array $inputs)
 {
     $neurons = $this->layers[$layer];
     $result = [];
     $n = new Neuron();
     foreach ($neurons as $neuron => $array) {
         $n->reset();
         if (count($array) !== count($inputs)) {
             throw new RuntimeException('Counts are different');
         }
         foreach ($array as $link => $weight) {
             $n->addWeight($link, $weight);
         }
         $result[] = $n->power($inputs);
     }
     return $result;
 }