
    &Vf                     z    d dl mZ d dl mZ d dlmZ d dlmZ d Z ed           G d de                      Zd	S )
    )activations)backend)keras_export)Layerc                 :    t          j        |           dk    rdS dS )z.Return a Large negative number based on dtype.float16g     Lg    e)r   standardize_dtype)dtypes    a/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/layers/activations/softmax.py_large_negative_numberr      s"     ''944t4    zkeras.layers.Softmaxc                   <     e Zd ZdZd fd	Zd	dZ fdZd Z xZS )
Softmaxa!  Softmax activation layer.

    Formula:
    ``` python
    exp_x = exp(x - max(x))
    f(x) = exp_x / sum(exp_x)
    ```

    Example:
    >>>softmax_layer = keras.layers.activations.Softmax()
    >>>input = np.array([1.0, 2.0, 1.0])
    >>>result = softmax_layer(input)
    [0.21194157, 0.5761169, 0.21194157]


    Args:
        axis: Integer, or list of Integers, axis along which the softmax
            normalization is applied.
        **kwargs: Base layer keyword arguments, such as `name` and `dtype`.

    Call arguments:
        inputs: The inputs (logits) to the softmax layer.
        mask: A boolean mask of the same shape as `inputs`. The mask
            specifies 1 to keep and 0 to mask. Defaults to `None`.

    Returns:
        Softmaxed output with the same shape as `inputs`.
    c                 d     t                      j        di | d| _        || _        d| _        d S )NT )super__init__supports_maskingaxisbuilt)selfr   kwargs	__class__s      r   r   zSoftmax.__init__-   s:    ""6""" $	


r   Nc                    |7dt          j        ||j                  z
  t          |j                  z  }||z  }t	          | j        t          t          f          rt          | j                  dk    rGt           j	        
                    |t           j                            || j        d          z
            S t          j        || j        d                   S t          j        || j                  S )Ng      ?   T)r   keepdimsr   )r   )r   castr
   r   
isinstancer   tuplelistlennumpyexpmath	logsumexpr   softmax)r   inputsmaskadders       r   callzSoftmax.call3   s    gl4666&v|445E eOFdi%// 		F49~~!!}((l,,TY -     #*6	!EEEE"6	::::r   c                     t                                                      }|                    d| j        i           |S )Nr   )r   
get_configupdater   )r   configr   s     r   r-   zSoftmax.get_configE   s6    ##%%vty)***r   c                     |S Nr   )r   input_shapes     r   compute_output_shapezSoftmax.compute_output_shapeJ   s    r   )r   r1   )	__name__
__module____qualname____doc__r   r+   r-   r3   __classcell__)r   s   @r   r   r      s         :     ; ; ; ;$    
      r   r   N)		keras.srcr   r   keras.src.api_exportr   keras.src.layers.layerr   r   r   r   r   r   <module>r<      s    ! ! ! ! ! !       - - - - - - ( ( ( ( ( (   $%%< < < < <e < < &%< < <r   