
    ~Wh                         d Z ddlmc m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 )zSoftmax activation layer.    N)backend)Layer)tf_utils)keras_exportc                 H    | t           j        k    rt           j        j        S dS )a  Large negative number as Tensor.

    This function is necessary because the standard value for epsilon
    in this module (-1e9) cannot be represented using tf.float16

    Args:
      tensor_type: a dtype to determine the type.

    Returns:
      a large negative number.
    g    e)tffloat16min)tensor_types    e/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/keras/layers/activation/softmax.py_large_compatible_negativer      s      bj  z~4    zkeras.layers.Softmaxc                   V     e Zd ZdZd fd	Zd	dZ fdZej        d             Z	 xZ
S )
Softmaxa  Softmax activation function.

    Example without mask:

    >>> inp = np.asarray([1., 2., 1.])
    >>> layer = tf.keras.layers.Softmax()
    >>> layer(inp).numpy()
    array([0.21194157, 0.5761169 , 0.21194157], dtype=float32)
    >>> mask = np.asarray([True, False, True], dtype=bool)
    >>> layer(inp, mask).numpy()
    array([0.5, 0. , 0.5], dtype=float32)

    Input shape:
      Arbitrary. Use the keyword argument `input_shape`
      (tuple of integers, does not include the samples axis)
      when using this layer as the first layer in a model.

    Output shape:
      Same shape as the input.

    Args:
      axis: Integer, or list of Integers, axis along which the softmax
        normalization is applied.
    Call arguments:
      inputs: The inputs, or logits to the softmax layer.
      mask: A boolean mask of the same shape as `inputs`. Defaults to `None`.
        The mask specifies 1 to keep and 0 to mask.

    Returns:
      softmaxed output with the same shape as `inputs`.
    c                 V     t                      j        di | d| _        || _        d S )NT )super__init__supports_maskingaxis)selfr   kwargs	__class__s      r   r   zSoftmax.__init__O   s3    ""6""" $			r   Nc                    |7dt          j        ||j                  z
  t          |j                  z  }||z  }t	          | j        t          t          f          rjt          | j                  dk    r1t          j	        |t          j
        || j        d          z
            S t          j        || j        d                   S t          j        || j                  S )Ng      ?   T)r   keepdimsr   )r   )r   castdtyper   
isinstancer   tuplelistlenexpreduce_logsumexpr   softmax)r   inputsmaskadders       r   callzSoftmax.callT   s     274666*6<88E eOFdi%// 	B49~~!!v)&ty4PPPQ  
 vDIaLAAAAvDI6666r   c                     d| j         i}t                                                      }t          t	          |                                          t	          |                                          z             S )Nr   )r   r   
get_configdictr"   items)r   configbase_configr   s      r   r,   zSoftmax.get_configj   s[    $)$gg((**D**,,--V\\^^0D0DDEEEr   c                     |S Nr   )r   input_shapes     r   compute_output_shapezSoftmax.compute_output_shapeo   s    r   )r   r2   )__name__
__module____qualname____doc__r   r*   r,   r   shape_type_conversionr4   __classcell__)r   s   @r   r   r   -   s         @     
7 7 7 7,F F F F F
 #  $#    r   r   )r8   tensorflow.compat.v2compatv2r   kerasr   keras.engine.base_layerr   keras.utilsr    tensorflow.python.util.tf_exportr   r   r   r   r   r   <module>rB      s       " ! ! ! ! ! ! ! !       ) ) ) ) ) )             : 9 9 9 9 9  " $%%C C C C Ce C C &%C C Cr   