protected function differentiate(Matrix $z) : Matrix
    {
        if (!$this->alpha) {
            throw new RuntimeException('Layer has not been initlaized.');
        }

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

        $gradient = [];

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

            $temp = [];

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

            $gradient[] = $temp;
        }

        return Matrix::quick($gradient);
    }