Phpml\NeuralNetwork\Training\Backpropagation::train PHP Method

train() public method

public train ( array $samples, array $targets, float $desiredError = 0.001, integer $maxIterations = 10000 )
$samples array
$targets array
$desiredError float
$maxIterations integer
    public function train(array $samples, array $targets, float $desiredError = 0.001, int $maxIterations = 10000)
    {
        for ($i = 0; $i < $maxIterations; ++$i) {
            $resultsWithinError = $this->trainSamples($samples, $targets, $desiredError);
            if ($resultsWithinError == count($samples)) {
                break;
            }
        }
    }

Usage Example

コード例 #1
0
ファイル: MLPRegressor.php プロジェクト: php-ai/php-ml
 /**
  * @param array $samples
  * @param array $targets
  */
 public function train(array $samples, array $targets)
 {
     $layers = $this->hiddenLayers;
     array_unshift($layers, count($samples[0]));
     $layers[] = count($targets[0]);
     $this->perceptron = new MultilayerPerceptron($layers, $this->activationFunction);
     $trainer = new Backpropagation($this->perceptron);
     $trainer->train($samples, $targets, $this->desiredError, $this->maxIterations);
 }
All Usage Examples Of Phpml\NeuralNetwork\Training\Backpropagation::train