protected function compute(Matrix $z) : Matrix
    {
        if (!$this->alpha) {
            throw new RuntimeException('Layer is not initialized.');
        }

        $alphas = $this->alpha->w();

        $computed = [];

        foreach ($z as $i => $row) {
            $alpha = $alphas[$i];

            $activations = [];

            foreach ($row as $value) {
                $activations[] = $value > 0.
                    ? $value
                    : $alpha * $value;
            }

            $computed[] = $activations;
        }

        return Matrix::quick($computed);
    }
protected function compute(Matrix $z) : Matrix
    {
        if (!$this->alpha) {
            throw new RuntimeException('Layer is not initialized.');
        }

        $alphas = $this->alpha->w();

        $computed = [];

        foreach ($z as $i => $row) {
            $alpha = $alphas[$i];

            $activations = [];

            foreach ($row as $value) {
                $activations[] = $value > 0.
                    ? $value
                    : $alpha * $value;
            }

            $computed[] = $activations;
        }

        return Matrix::quick($computed);
    }
protected function compute ( Matrix $ z ) : Matrix { if ( ! $ this -> alpha ) { throw new RuntimeException ( 'Layer is not initialized.' ) ; } $ alphas = $ this -> alpha -> w ( ) ; $ computed = [ ] ; foreach ( $ z as $ i => $ row ) { $ alpha = $ alphas [ $ i ] ; $ activations = [ ] ; foreach ( $ row as $ value ) { $ activations [ ] = $ value > 0. ? $ value : $ alpha * $ value ; } $ computed [ ] = $ activations ; } return Matrix :: quick ( $ computed ) ; }
Compute the leaky ReLU activation function and return a matrix.

@param \Rubix\Tensor\Matrix $z
@throws \RuntimeException
@return \Rubix\Tensor\Matrix
Compute the leaky ReLU activation function and return a matrix .