Ë
    ÷Q(hº  ã                   óš   — d Z ddlZddlmZ ddlmZ d„ Zd„ Zd„ Z	d„ Z
d	„ Zee	ee
ed
œZd„ Zd„ Zd„ Zd„ ZeeeedœZd„ Zd„ Zd„ ZeeedœZy)z(Utilities for the neural network modulesé    N)Úexpit)Úxlogyc                  ó   — y)zûSimply leave the input array unchanged.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        Data, where `n_samples` is the number of samples
        and `n_features` is the number of features.
    N© ©ÚXs    úZ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sklearn/neural_network/_base.pyÚinplace_identityr
      ó   � ó    c                 ó   — t        | | ¬«       y)z¥Compute the logistic function inplace.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        The input data.
    ©ÚoutN)Úlogistic_sigmoidr   s    r	   Úinplace_logisticr      s   € ô �Q˜AÖr   c                 ó2   — t        j                  | | ¬«       y)z«Compute the hyperbolic tan function inplace.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        The input data.
    r   N)ÚnpÚtanhr   s    r	   Úinplace_tanhr   "   s   € ô ‡G�GˆA�1Ör   c                 ó4   — t        j                  | d| ¬«       y)z²Compute the rectified linear unit function inplace.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        The input data.
    r   r   N)r   Úmaximumr   s    r	   Úinplace_relur   -   s   € ô ‡J�Jˆq�!˜Ör   c                 óÚ   — | | j                  d¬«      dd…t        j                  f   z
  }t        j                  || ¬«       | | j	                  d¬«      dd…t        j                  f   z  } y)zªCompute the K-way softmax function inplace.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        The input data.
    é   ©ÚaxisNr   )Úmaxr   ÚnewaxisÚexpÚsum)r   Útmps     r	   Úinplace_softmaxr"   8   sT   € ð ˆa�e‰e˜ˆe‹mšAœrŸz™z˜MÑ*Ñ
*€CÜ‡F�Fˆ3�AÕØˆ�‰�Aˆ‹’qœ"Ÿ*™*�}Ñ	%Ñ%�Ar   )Úidentityr   ÚlogisticÚreluÚsoftmaxc                  ó   — y)a„  Apply the derivative of the identity function: do nothing.

    Parameters
    ----------
    Z : {array-like, sparse matrix}, shape (n_samples, n_features)
        The data which was output from the identity activation function during
        the forward pass.

    delta : {array-like}, shape (n_samples, n_features)
         The backpropagated error signal to be modified inplace.
    Nr   ©ÚZÚdeltas     r	   Úinplace_identity_derivativer+   N   r   r   c                 ó   — || z  }|d| z
  z  }y)aó  Apply the derivative of the logistic sigmoid function.

    It exploits the fact that the derivative is a simple function of the output
    value from logistic function.

    Parameters
    ----------
    Z : {array-like, sparse matrix}, shape (n_samples, n_features)
        The data which was output from the logistic activation function during
        the forward pass.

    delta : {array-like}, shape (n_samples, n_features)
         The backpropagated error signal to be modified inplace.
    r   Nr   r(   s     r	   Úinplace_logistic_derivativer-   ]   s   € ð 
ˆQ�J€EØ	ˆQ�‰U�N�Er   c                 ó   — |d| dz  z
  z  }y)aý  Apply the derivative of the hyperbolic tanh function.

    It exploits the fact that the derivative is a simple function of the output
    value from hyperbolic tangent.

    Parameters
    ----------
    Z : {array-like, sparse matrix}, shape (n_samples, n_features)
        The data which was output from the hyperbolic tangent activation
        function during the forward pass.

    delta : {array-like}, shape (n_samples, n_features)
         The backpropagated error signal to be modified inplace.
    r   é   Nr   r(   s     r	   Úinplace_tanh_derivativer0   p   s   € ð 
ˆQ��A‘‰XÑ�Er   c                 ó   — d|| dk(  <   y)a  Apply the derivative of the relu function.

    It exploits the fact that the derivative is a simple function of the output
    value from rectified linear units activation function.

    Parameters
    ----------
    Z : {array-like, sparse matrix}, shape (n_samples, n_features)
        The data which was output from the rectified linear units activation
        function during the forward pass.

    delta : {array-like}, shape (n_samples, n_features)
         The backpropagated error signal to be modified inplace.
    r   Nr   r(   s     r	   Úinplace_relu_derivativer2   ‚   s   € ð €Eˆ!ˆq‰&‚Mr   )r#   r   r$   r%   c                 ó4   — | |z
  dz  j                  «       dz  S )a„  Compute the squared loss for regression.

    Parameters
    ----------
    y_true : array-like or label indicator matrix
        Ground truth (correct) values.

    y_pred : array-like or label indicator matrix
        Predicted values, as returned by a regression estimator.

    Returns
    -------
    loss : float
        The degree to which the samples are correctly predicted.
    r/   )Úmean)Úy_trueÚy_preds     r	   Úsquared_lossr7   œ   s!   € ð  �f‰_ Ñ"×(Ñ(Ó*¨QÑ.Ð.r   c                 ó’  — t        j                  |j                  «      j                  }t        j                  ||d|z
  «      }|j
                  d   dk(  rt        j                  d|z
  |d¬«      }| j
                  d   dk(  rt        j                  d| z
  | d¬«      } t        | |«      j                  «        |j
                  d   z  S )a°  Compute Logistic loss for classification.

    Parameters
    ----------
    y_true : array-like or label indicator matrix
        Ground truth (correct) labels.

    y_prob : array-like of float, shape = (n_samples, n_classes)
        Predicted probabilities, as returned by a classifier's
        predict_proba method.

    Returns
    -------
    loss : float
        The degree to which the samples are correctly predicted.
    r   r   r   )	r   ÚfinfoÚdtypeÚepsÚclipÚshapeÚappendr   r    ©r5   Úy_probr;   s      r	   Úlog_lossrA   ¯   s¤   € ô" �(‰(�6—<‘<Ó
 ×
$Ñ
$€CÜ�W‰W�V˜S ! c¡'Ó*€FØ‡|�|�A�˜!ÒÜ—‘˜1˜v™: v°AÔ6ˆà‡|�|�A�˜!ÒÜ—‘˜1˜v™: v°AÔ6ˆä�&˜&Ó!×%Ñ%Ó'Ð'¨&¯,©,°q©/Ñ9Ð9r   c                 ó   — t        j                  |j                  «      j                  }t        j                  ||d|z
  «      }t        | |«      j                  «       t        d| z
  d|z
  «      j                  «       z    |j                  d   z  S )a!  Compute binary logistic loss for classification.

    This is identical to log_loss in binary classification case,
    but is kept for its use in multilabel case.

    Parameters
    ----------
    y_true : array-like or label indicator matrix
        Ground truth (correct) labels.

    y_prob : array-like of float, shape = (n_samples, 1)
        Predicted probabilities, as returned by a classifier's
        predict_proba method.

    Returns
    -------
    loss : float
        The degree to which the samples are correctly predicted.
    r   r   )r   r9   r:   r;   r<   r   r    r=   r?   s      r	   Úbinary_log_lossrC   Ë   sz   € ô( �(‰(�6—<‘<Ó
 ×
$Ñ
$€CÜ�W‰W�V˜S ! c¡'Ó*€Fä
�˜Ó
×
#Ñ
#Ó
%¬¨a°&©j¸!¸f¹*Ó(E×(IÑ(IÓ(KÑ
KÐLØ
�,‰,�q‰/ñ	ðr   )Úsquared_errorrA   rC   )Ú__doc__Únumpyr   Úscipy.specialr   r   r   r
   r   r   r   r"   ÚACTIVATIONSr+   r-   r0   r2   ÚDERIVATIVESr7   rA   rC   ÚLOSS_FUNCTIONSr   r   r	   ú<module>rK      sŽ   ðÙ .ó
 Ý 3Ý òòòòò
&ð !ØØ ØØñ€òòò&ò$ð& ,Ø#Ø+Ø#ñ	€ò/ò&:ò8ð: "ØØ&ñ�r   