
    &Vf                     h    d dl mZ d dlmZ d dlmZ  ed           G d de                      ZdS )    )backend)keras_export)TFDataLayerzkeras.layers.Rescalingc                   :     e Zd ZdZd fd	Zd Zd Z fdZ xZS )	Rescalinga  A preprocessing layer which rescales input values to a new range.

    This layer rescales every value of an input (often an image) by multiplying
    by `scale` and adding `offset`.

    For instance:

    1. To rescale an input in the `[0, 255]` range
    to be in the `[0, 1]` range, you would pass `scale=1./255`.

    2. To rescale an input in the `[0, 255]` range to be in the `[-1, 1]` range,
    you would pass `scale=1./127.5, offset=-1`.

    The rescaling is applied both during training and inference. Inputs can be
    of integer or floating point dtype, and by default the layer will output
    floats.

    **Note:** This layer is safe to use inside a `tf.data` pipeline
    (independently of which backend you're using).

    Args:
        scale: Float, the scale to apply to the inputs.
        offset: Float, the offset to apply to the inputs.
        **kwargs: Base layer keyword arguments, such as `name` and `dtype`.
            c                 d     t                      j        di | || _        || _        d| _        d S )NT )super__init__scaleoffsetsupports_masking)selfr   r   kwargs	__class__s       e/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/layers/preprocessing/rescaling.pyr   zRescaling.__init__"   s<    ""6"""
 $    c           	         | j         }| j                            | j        |          }| j                            | j        |          }| j        j                            |          }t          |          dk    rMt          j                    dk    r6| j        j	        
                    ||ddt          |          z
  z  z             }| j                            ||          |z  |z   S )Nr   channels_first)      )compute_dtyper   castr   r   coreshapelenimage_data_formatnumpyreshape)r   inputsdtyper   r   scale_shapes         r   callzRescaling.call(   s    "!!$*e44""4;66l'--e44q  )++/???L&..{TQ[1A1A-A%BB E |  //%7&@@r   c                     |S )Nr
   )r   input_shapes     r   compute_output_shapezRescaling.compute_output_shape6   s    r   c                 n    t                                                      }| j        | j        d}i ||S )N)r   r   )r   
get_configr   r   )r   base_configconfigr   s      r   r)   zRescaling.get_config9   s@    gg((**Zk
 
 )+(((r   )r   )	__name__
__module____qualname____doc__r   r$   r'   r)   __classcell__)r   s   @r   r   r      s         4% % % % % %A A A  ) ) ) ) ) ) ) ) )r   r   N)	keras.srcr   keras.src.api_exportr   ,keras.src.layers.preprocessing.tf_data_layerr   r   r
   r   r   <module>r4      s          - - - - - - D D D D D D &''8) 8) 8) 8) 8) 8) 8) ('8) 8) 8)r   