Phpml\NeuralNetwork\Network::getLayers PHP Method

getLayers() public method

public getLayers ( ) : array
return array
    public function getLayers() : array;

Usage Example

Example #1
0
 /**
  * @param array $sample
  * @param array $target
  */
 private function trainSample(array $sample, array $target)
 {
     $this->network->setInput($sample)->getOutput();
     $this->sigmas = [];
     $layers = $this->network->getLayers();
     $layersNumber = count($layers);
     for ($i = $layersNumber; $i > 1; --$i) {
         foreach ($layers[$i - 1]->getNodes() as $key => $neuron) {
             if ($neuron instanceof Neuron) {
                 $sigma = $this->getSigma($neuron, $target, $key, $i == $layersNumber);
                 foreach ($neuron->getSynapses() as $synapse) {
                     $synapse->changeWeight($this->theta * $sigma * $synapse->getNode()->getOutput());
                 }
             }
         }
     }
 }