
    -i/                         S r SSKrSSKJr  SSKJr  S rS rS r	S r
S	 rS
 r\\\
\	\\S.rS rS rS rS r\\\\S.rSS jrSS jrSS jrSS jr\\\\S.rg)z(Utilities for the neural network modules    N)expit)xlogyc                     g)zSimply 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    O/var/www/html/venv/lib/python3.13/site-packages/sklearn/neural_network/_base.pyinplace_identityr
              c                 ,    [         R                  " X S9  g)zCompute the exponential inplace.

Parameters
----------
X : {array-like, sparse matrix}, shape (n_samples, n_features)
    The input data.
outN)npexpr   s    r	   inplace_expr      s     FF1r   c                     [        X S9  g)zCompute the logistic function inplace.

Parameters
----------
X : {array-like, sparse matrix}, shape (n_samples, n_features)
    The input data.
r   N)logistic_sigmoidr   s    r	   inplace_logisticr   "   s     Qr   c                 ,    [         R                  " X S9  g)zCompute the hyperbolic tan function inplace.

Parameters
----------
X : {array-like, sparse matrix}, shape (n_samples, n_features)
    The input data.
r   N)r   tanhr   s    r	   inplace_tanhr   -   s     GGAr   c                 0    [         R                  " U SU S9  g)zCompute 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   8   s     JJq!r   c                     X R                  SS9SS2[        R                  4   -
  n[        R                  " XS9  X R	                  SS9SS2[        R                  4   -  n g)zCompute the K-way softmax function inplace.

Parameters
----------
X : {array-like, sparse matrix}, shape (n_samples, n_features)
    The input data.
   axisNr   )maxr   newaxisr   sum)r   tmps     r	   inplace_softmaxr$   C   sN     eeemArzzM*
*CFF3Aq"**}	%%Ar   )identityr   r   logisticrelusoftmaxc                     g)ad  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-   Z   r   r   c                     X-  nUSU -
  -  ng)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/   i   s     
JE	QUNEr   c                     USU S-  -
  -  ng)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_derivativer2   |   s     
QAXEr   c                     SXS:H  '   g)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_derivativer4      s     Eq&Mr   )r%   r   r&   r'   c                 Z    S[         R                  " X-
  S-  USS9R                  5       -  $ )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.

sample_weight : array-like of shape (n_samples,), default=None
    Sample weights.

Returns
-------
loss : float
    The degree to which the samples are correctly predicted.
g      ?r1   r   weightsr   )r   averagemeany_truey_predsample_weights      r	   squared_lossr>      s.    ( 	bjj&/a/QOTTVVr   c                 n    [         R                  " [        X U-  5      U -
  U-   USS9R                  5       $ )a  Compute (half of the) Poisson deviance loss for regression.

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

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

sample_weight : array-like of shape (n_samples,), default=None
    Sample weights.

Returns
-------
loss : float
    The degree to which the samples are correctly predicted.
r   r6   )r   r8   r   r"   r:   s      r	   poisson_lossr@      s7    , ::fvo&/&8-VW	cer   c                    [         R                  " UR                  5      R                  n[         R                  " XSU-
  5      nUR
                  S   S:X  a  [         R                  " SU-
  USS9nU R
                  S   S:X  a  [         R                  " SU -
  U SS9n [         R                  " [        X5      USS9R                  5       * $ )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.

sample_weight : array-like of shape (n_samples,), default=None
    Sample weights.

Returns
-------
loss : float
    The degree to which the samples are correctly predicted.
r   r   r   r6   )
r   finfodtypeepsclipshapeappendr8   r   r"   r;   y_probr=   rD   s       r	   log_lossrJ      s    ( ((6<<
 
$
$CWWV!c'*F||A!1v:vA6||A!1v:vA6JJuV,m!LPPRRRr   c                    [         R                  " UR                  5      R                  n[         R                  " XSU-
  5      n[         R
                  " [        X5      [        SU -
  SU-
  5      -   USS9R                  5       * $ )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.

sample_weight : array-like of shape (n_samples,), default=None
    Sample weights.

Returns
-------
loss : float
    The degree to which the samples are correctly predicted.
r   r   r6   )r   rB   rC   rD   rE   r8   r   r"   rH   s       r	   binary_log_lossrL      sq    . ((6<<
 
$
$CWWV!c'*FJJfa&j!f* == 
ce	 r   )squared_errorpoissonrJ   rL   )N)__doc__numpyr   scipy.specialr   r   r   r
   r   r   r   r   r$   ACTIVATIONSr-   r/   r2   r4   DERIVATIVESr>   r@   rJ   rL   LOSS_FUNCTIONSr   r   r	   <module>rU      s    .
  3 
& ! &$& ,#+#	06S>B "&	r   