protected function runTraining(array $samples, array $targets): void
    {
        // The cost function is the sum of squares
        $callback = function ($weights, $sample, $target) {
            $this->weights = $weights;

            $output = $this->output($sample);
            $gradient = $output - $target;
            $error = $gradient ** 2;

            return [$error, $gradient];
        };

        $isBatch = $this->trainingType == self::BATCH_TRAINING;

        parent::runGradientDescent($samples, $targets, $callback, $isBatch);
    }
protected function runTraining(array $samples, array $targets): void
    {
        // The cost function is the sum of squares
        $callback = function ($weights, $sample, $target) {
            $this->weights = $weights;

            $output = $this->output($sample);
            $gradient = $output - $target;
            $error = $gradient ** 2;

            return [$error, $gradient];
        };

        $isBatch = $this->trainingType == self::BATCH_TRAINING;

        parent::runGradientDescent($samples, $targets, $callback, $isBatch);
    }
protected function runTraining ( array $ samples , array $ targets ) : void { // The cost function is the sum of squares $ callback = function ( $ weights , $ sample , $ target ) { $ this -> weights = $ weights ; $ output = $ this -> output ( $ sample ) ; $ gradient = $ output - $ target ; $ error = $ gradient ** 2 ; return [ $ error , $ gradient ] ; } ; $ isBatch = $ this -> trainingType == self :: BATCH_TRAINING ; parent :: runGradientDescent ( $ samples , $ targets , $ callback , $ isBatch ) ; }
Adapts the weights with respect to given samples and targets
by use of gradient descent learning rule
Adapts the weights with respect to given samples and targets by use of gradient descent learning rule